:root {
  --color-brand-500: #3d78f2;
  --color-brand-600: #2f66d0;
  --color-brand-700: #2452aa;
  --color-accent: #15947d;
  --color-shell: #0d1b2a;
  --color-shell-elevated: #14283e;
  --color-surface-page: #edf2f6;
  --color-surface: #fff;
  --color-surface-muted: #f6f8fb;
  --color-surface-strong: #e8eef4;
  --color-text: #152235;
  --color-text-secondary: #4a5d73;
  --color-text-muted: #6f7f91;
  --color-border: #d6e0e9;
  --color-success: #13795f;
  --color-warning: #9a6208;
  --color-danger: #bd3e4b;
  --color-disabled: #687586;
  --focus-ring: 0 0 0 3px rgb(47 102 208 / 18%);
  --font-sans: "SF Pro Text", "Helvetica Neue", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-display: "Avenir Next", "SF Pro Display", "Helvetica Neue", "PingFang SC", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --radius-control: 9px;
  --radius-card: 16px;
  --radius-dialog: 20px;
  --shadow-card: 0 10px 30px rgb(30 48 70 / 7%);
  --shadow-overlay: 0 24px 68px rgb(7 19 34 / 24%);
  --blue: var(--color-brand-600);
  --paper: var(--color-surface-page);
  --line: var(--color-border);
  --ink: var(--color-text);
  --muted: var(--color-text-muted);
  --green: var(--color-success);
  --red: var(--color-danger);
  --amber: var(--color-warning);
}

html {
  background: var(--color-surface-page);
}

body {
  position: relative;
  color: var(--color-text);
  background: var(--color-surface-page) !important;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: .005em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 92% -8%, rgb(95 139 196 / 13%), transparent 29%),
    linear-gradient(135deg, #edf2f6 0%, #f5f7fa 54%, #eaf0f5 100%);
}

h1,
h2,
h3,
.brand,
.stat-value,
.ow-stat strong {
  font-family: var(--font-display);
}

button,
input,
select,
textarea {
  font: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--color-brand-500);
  outline-offset: 2px;
  box-shadow: var(--focus-ring);
}

.shell {
  grid-template-columns: 256px minmax(0, 1fr) !important;
  background: transparent !important;
}

.shell > main,
#page,
#page > *,
.pc-page,
.oc-page,
.pc-directory,
.oc-directory {
  min-width: 0;
}

.shell > main {
  position: relative;
  background: transparent;
}

#page {
  box-sizing: border-box;
  width: 100%;
  max-width: 1680px;
  margin-inline: auto;
  padding: 30px 34px 42px;
}

.side {
  position: sticky;
  z-index: 20;
  top: 0;
  min-height: 100vh;
  max-height: 100vh;
  padding: 22px 14px 16px;
  overflow-y: auto;
  border: 0 !important;
  background:
    radial-gradient(circle at 18% 0, rgb(66 117 177 / 22%), transparent 26%),
    var(--color-shell) !important;
  box-shadow: 14px 0 42px rgb(7 20 37 / 10%) !important;
  color: #dbe6f1;
}

.side .brand {
  gap: 11px;
  padding: 0 10px 22px;
  color: #f7fbff;
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -.02em;
}

.side .brand-mark {
  width: 34px;
  height: 34px;
  border: 1px solid rgb(255 255 255 / 14%);
  border-radius: 10px;
  background: linear-gradient(145deg, #4c86f7, #2459c0);
  box-shadow: 0 8px 20px rgb(22 72 157 / 34%);
  color: #fff;
}

.side .workspace {
  align-items: center;
  margin: 0 4px 18px;
  padding: 10px 11px;
  border: 1px solid rgb(188 211 237 / 12%);
  border-radius: 11px;
  background: rgb(255 255 255 / 5%);
  color: #b9c8d8;
  font-size: 12px;
}

.side .workspace button {
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid rgb(171 200 235 / 15%);
  background: rgb(255 255 255 / 7%);
  color: #dfe9f4;
}

.side nav {
  gap: 4px;
}

.side nav button {
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 9px;
  color: #9fb1c5;
  font-weight: 520;
  transition: background .16s ease, color .16s ease;
}

.side nav button:hover {
  background: rgb(255 255 255 / 6%);
  color: #edf5fc;
}

.side nav button.active {
  background: linear-gradient(90deg, rgb(64 119 224 / 28%), rgb(64 119 224 / 12%));
  box-shadow: inset 3px 0 0 #5d91f5;
  color: #fff;
  font-weight: 650;
}

.side .subnav {
  margin: 3px 0 6px 16px !important;
  padding-left: 7px !important;
  border-left-color: rgb(163 190 219 / 15%) !important;
}

.side .subnav button {
  min-height: 36px;
  color: #8498ae;
  font-size: 12px !important;
}

.side .subnav button:hover,
.side .subnav button.active {
  background: rgb(255 255 255 / 5%);
  color: #dce9f7;
}

.side-footer {
  color: #71879f !important;
  letter-spacing: .02em;
}

.side-footer .dot {
  box-shadow: 0 0 0 4px rgb(45 212 156 / 9%);
}

.topbar {
  position: sticky !important;
  z-index: 12 !important;
  top: 0;
  height: 78px;
  padding: 15px 34px;
  border-color: rgb(202 214 226 / 76%) !important;
  background: rgb(248 250 252 / 92%) !important;
  box-shadow: 0 8px 24px rgb(32 50 72 / 4%) !important;
  backdrop-filter: blur(18px);
}

.topbar h1 {
  color: var(--color-text);
  font-size: 22px;
  font-weight: 720;
  letter-spacing: -.025em;
}

.topbar .crumb {
  margin-bottom: 2px;
  color: #708196;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .06em;
}

.icon,
.avatar {
  border-color: #d4dee8 !important;
  background: #fff !important;
  box-shadow: 0 4px 12px rgb(29 49 72 / 5%);
}

.icon {
  color: #4e6075 !important;
}

.avatar {
  color: var(--color-brand-700) !important;
  font-weight: 750;
}

.top-actions #langToggle {
  width: auto;
  min-width: 52px;
  padding-inline: 10px;
  white-space: nowrap;
}

.page-tabs {
  min-height: 44px;
  padding: 0 24px;
  border-bottom-color: #d6e0e9 !important;
  background: rgb(255 255 255 / 68%) !important;
  box-shadow: none !important;
  backdrop-filter: blur(14px);
}

.page-tab {
  min-width: 108px;
  border: 0 !important;
  border-bottom: 2px solid transparent !important;
  background: transparent !important;
  color: #697a8d !important;
  font-size: 13px !important;
}

.page-tab:hover {
  color: var(--color-brand-600) !important;
}

.page-tab.active {
  border-bottom-color: var(--color-brand-600) !important;
  color: var(--color-text) !important;
  font-weight: 680;
}

.mobile-nav-toggle,
.nav-backdrop {
  display: none;
}

.button,
.mini-action,
.icon,
.input,
.config-form input,
.config-form select,
.config-form textarea {
  border-radius: var(--radius-control);
}

.button {
  min-height: 40px;
  padding-inline: var(--space-4);
  border: 1px solid var(--color-brand-600);
  background: var(--color-brand-600);
  box-shadow: 0 6px 15px rgb(47 102 208 / 18%);
  color: #fff;
  font-weight: 650;
}

.button:hover:not(:disabled) {
  border-color: var(--color-brand-700);
  background: var(--color-brand-700);
  box-shadow: 0 9px 20px rgb(47 102 208 / 23%);
}

.button.secondary {
  border-color: #cfdbe6;
  background: #fff;
  box-shadow: 0 3px 9px rgb(32 50 72 / 4%);
  color: #425970;
}

.button.secondary:hover:not(:disabled) {
  border-color: #aebfd0;
  background: #f6f8fb;
  color: #24384e;
}

.button.danger {
  border-color: var(--color-danger);
  background: var(--color-danger);
  box-shadow: 0 6px 15px rgb(189 62 75 / 16%);
}

.button:disabled,
.mini-action:disabled,
button:disabled {
  cursor: not-allowed;
  box-shadow: none;
  opacity: .52;
}

.mini-action {
  min-height: 32px;
  border-color: #cfdbe6 !important;
  background: #fff !important;
  color: #315f9d !important;
  font-weight: 620;
}

.mini-action:hover:not(:disabled) {
  border-color: #9fb6cf !important;
  background: #eff4fa !important;
  color: #234f87 !important;
}

.input,
.config-form input,
.config-form select,
.config-form textarea,
.toolbar input,
.toolbar select {
  border-color: #ccd8e3 !important;
  background-color: #fff !important;
  color: var(--color-text) !important;
  box-shadow: inset 0 1px 1px rgb(20 38 59 / 3%);
}

.input,
.config-form input,
.config-form select,
.toolbar input,
.toolbar select {
  min-height: 42px;
}

.input:hover:not(:disabled),
.config-form input:hover:not(:disabled),
.config-form select:hover:not(:disabled),
.config-form textarea:hover:not(:disabled) {
  border-color: #aebed0 !important;
}

.input:focus,
.config-form input:focus,
.config-form select:focus,
.config-form textarea:focus {
  border-color: var(--color-brand-500) !important;
  background: #fff !important;
  box-shadow: var(--focus-ring) !important;
}

input[readonly],
textarea[readonly] {
  background: #edf1f5 !important;
  color: #5d6b7a !important;
}

input:disabled,
select:disabled,
textarea:disabled {
  border-color: #dce3ea !important;
  background: #e9eef3 !important;
  color: #7c8794 !important;
}

.card,
.ow-panel {
  border: 1px solid var(--color-border) !important;
  border-radius: var(--radius-card) !important;
  background: var(--color-surface) !important;
  box-shadow: var(--shadow-card) !important;
}

.section-head h2,
.section.card > h2,
.card h2 {
  color: var(--color-text);
  letter-spacing: -.02em;
}

table {
  border-color: var(--color-border) !important;
  background: var(--color-surface) !important;
  box-shadow: none !important;
}

th {
  height: 46px;
  padding-block: 12px;
  background: #f0f4f8 !important;
  color: #617387 !important;
  font-size: 11px !important;
  font-weight: 720 !important;
  letter-spacing: .045em;
}

td {
  min-height: 50px;
  border-color: #e4eaf0 !important;
  color: #304357 !important;
  font-size: 13px;
  font-weight: 470;
}

tbody tr {
  transition: background .14s ease;
}

tbody tr:hover {
  background: #f4f7fa !important;
}

.tag,
.pc-status,
.oc-pay-status,
.oc-notify-status,
.oc-payout-status,
.bd-status,
.pi-status {
  border: 1px solid transparent;
  text-wrap: nowrap;
  font-weight: 680;
}

.tag.success {
  border-color: #bee5d8;
  background: #e8f6f1;
  color: var(--color-success);
}

.tag.pending {
  border-color: #efdbad;
  background: #fff5dd;
  color: var(--color-warning);
}

.tag.fail {
  border-color: #efc8cc;
  background: #fceff0;
  color: var(--color-danger);
}

.modal {
  background: rgb(7 18 33 / 62%);
  backdrop-filter: blur(4px);
}

.modal-card,
.modal-panel {
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 32px);
  border: 1px solid #d6e0e9 !important;
  border-radius: var(--radius-dialog);
  background: #fff;
  box-shadow: var(--shadow-overlay);
}

.profile-dropdown {
  border-color: #d6e0e9 !important;
  border-radius: 12px !important;
  box-shadow: var(--shadow-overlay) !important;
}

.empty {
  border-color: #cbd7e2;
  background: rgb(255 255 255 / 72%);
}

/* Toolbars must adapt to the real content width after the sidebar is deducted. */
.toolbar,
.order-filter-actions,
.pc-toolbar,
.pp-toolbar,
.bd-tools,
.prc-tools,
.mc-toolbar,
.bm-directory-tools,
.fp-settlement-toolbar {
  min-width: 0;
  max-width: 100%;
  flex-wrap: wrap !important;
}

.toolbar .input {
  flex: 1 1 220px;
  width: auto;
  min-width: min(210px, 100%);
  max-width: 100%;
}

.toolbar .button,
.order-filter-actions > button,
.order-filter-actions .button,
.order-tool-button {
  flex: 0 0 auto;
}

.order-filter-actions {
  box-sizing: border-box;
  width: 100%;
  overflow: visible !important;
}

.order-filter-actions > * {
  min-width: 0;
}

.order-filter-actions .order-filter-spacer {
  flex: 1 1 32px;
}

/* A wide business table scrolls inside its own card instead of being clipped. */
.table-scroll,
.table-wrap,
.merchant-list-card,
.merchant-wallet-table-wrap,
.order-center-table,
.oc-notification-table,
.pc-table-wrap,
.pp-table-wrap {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto !important;
  overscroll-behavior-inline: contain;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
}

.section.card:has(> table),
.ow-panel:has(> table) {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto !important;
  overscroll-behavior-inline: contain;
  touch-action: pan-x pan-y;
}

.section.card:has(> table) > table,
.ow-panel:has(> table) > table {
  min-width: max(100%, 860px);
}

.ow-page-countries .ow-panel,
.ow-page-users .ow-panel,
.ow-page-roles .ow-panel,
.ow-page-login-devices .ow-panel {
  overflow-x: auto !important;
  overscroll-behavior-inline: contain;
}

.ow-page-countries .ow-panel > table,
.ow-page-users .ow-panel > table,
.ow-page-roles .ow-panel > table,
.ow-page-login-devices .ow-panel > table {
  min-width: 960px;
}

.login-view {
  background:
    radial-gradient(circle at 12% 82%, rgb(21 148 125 / 12%) 0, transparent 28%),
    radial-gradient(circle at 84% 12%, rgb(61 120 242 / 14%) 0, transparent 31%),
    #f3f6f9 !important;
}

.login-card {
  border-color: #d5e0e9 !important;
  box-shadow: 0 30px 80px rgb(17 37 60 / 14%) !important;
}

.login-submit {
  background: var(--color-brand-600) !important;
  box-shadow: 0 10px 24px rgb(47 102 208 / 22%);
}

/* Operations workspace is the first real module using the new visual language. */
.ow-page {
  color: var(--color-text) !important;
}

.ow-hero {
  border-color: #1b3856 !important;
  background:
    radial-gradient(circle at 90% 10%, rgb(92 145 208 / 20%), transparent 28%),
    linear-gradient(125deg, #11243a 0%, #17314c 72%, #142a42 100%) !important;
  box-shadow: 0 18px 42px rgb(13 31 51 / 15%) !important;
}

.ow-hero::before {
  border-color: rgb(115 162 219 / 9%) !important;
}

.ow-hero::after {
  background: rgb(21 148 125 / 10%) !important;
}

.ow-kicker {
  color: #83adf6 !important;
}

body .ow-hero h2 {
  color: #f4f8fc !important;
  font-family: var(--font-display);
  font-weight: 710;
}

body .ow-hero p,
body .ow-hero .crumb {
  color: #a9b9ca !important;
}

.ow-hero-mark {
  border-color: rgb(170 199 231 / 16%) !important;
  background: rgb(255 255 255 / 7%) !important;
  box-shadow: none !important;
}

.ow-hero-mark b {
  color: #f1f6fb !important;
}

.ow-hero-mark small {
  color: #90a5bb !important;
}

.ow-context-nav,
.ow-boundary,
.ow-stat,
.ow-page .ow-toolbar {
  border-color: var(--color-border) !important;
  background: #fff !important;
  box-shadow: var(--shadow-card) !important;
}

.ow-context-nav button.active {
  background: #e7eef9 !important;
  box-shadow: inset 0 0 0 1px #cfdbeb !important;
  color: #245aa9 !important;
}

.ow-boundary > b {
  background: #e7eef7 !important;
  color: #315f93 !important;
}

.ow-stat::after {
  background: #e9eff6 !important;
}

.ow-stat span,
.ow-form label {
  color: var(--color-text-secondary) !important;
}

.ow-stat strong {
  color: var(--color-text) !important;
}

.pc-directory {
  max-width: 100%;
  overflow: hidden !important;
}

.pc-table-wrap {
  overflow-x: auto !important;
}

.oc-directory {
  max-width: 100%;
  overflow: hidden;
}

th,
td,
.stat-value,
[class*="amount"],
[class*="money"],
[class*="time"] {
  font-variant-numeric: tabular-nums;
}

@media (max-width: 1024px) {
  .shell {
    grid-template-columns: 228px minmax(0, 1fr) !important;
  }

  #page {
    padding-inline: var(--space-5);
  }
}

@media (max-width: 900px) {
  body.mobile-nav-open {
    overflow: hidden;
  }

  .shell {
    display: block !important;
  }

  .shell > main {
    width: 100%;
  }

  .side {
    position: fixed !important;
    z-index: 1001;
    inset: 0 auto 0 0;
    display: flex !important;
    width: min(86vw, 320px);
    min-height: 100dvh;
    max-height: 100dvh;
    padding: var(--space-5) var(--space-3);
    overflow-y: auto;
    border: 0 !important;
    box-shadow: var(--shadow-overlay) !important;
    transform: translateX(-104%);
    transition: transform .2s ease;
  }

  .mobile-nav-open .side {
    transform: translateX(0);
  }

  .side .brand {
    padding: 0 10px var(--space-5);
  }

  .side-footer {
    display: block !important;
  }

  .side nav {
    display: grid !important;
    flex: initial !important;
    overflow: visible !important;
  }

  .side .nav-group,
  .side .nav-group > button,
  .side .subnav button {
    width: 100%;
  }

  .side .nav-group > button {
    min-height: 44px;
  }

  .side .subnav {
    position: static !important;
    display: grid;
    min-width: 0;
    margin: 2px 0 6px 14px !important;
    border: 0;
    border-left: 1px solid rgb(163 190 219 / 15%) !important;
    border-radius: 0;
    box-shadow: none;
  }

  .side .subnav[hidden] {
    display: none !important;
  }

  .nav-backdrop {
    position: fixed;
    z-index: 1000;
    inset: 0 0 0 min(86vw, 320px);
    display: block;
    padding: 0;
    border: 0;
    background: rgb(5 14 25 / 52%);
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
  }

  .mobile-nav-open .nav-backdrop {
    opacity: 1;
    visibility: visible;
  }

  .mobile-nav-toggle {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    font-size: 18px;
  }

  .topbar {
    min-height: 72px;
    height: auto;
    padding: 12px var(--space-4);
  }

  .topbar > div:first-of-type {
    min-width: 0;
    flex: 1;
  }

  .topbar h1,
  .topbar .crumb {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .top-actions {
    gap: var(--space-2);
  }

  .page-tabs {
    padding-inline: 10px;
  }

  .order-filter-actions .order-filter-spacer {
    display: none;
  }

  #page {
    padding: var(--space-5) var(--space-4) 34px;
  }
}

@media (max-width: 430px) {
  .topbar {
    align-items: center;
  }

  .topbar .crumb {
    display: none;
  }

  .topbar h1 {
    font-size: 18px;
  }

  .top-actions .icon,
  .top-actions .avatar {
    width: 40px;
    min-width: 40px;
    height: 40px;
  }

  .top-actions #langToggle {
    width: auto;
    min-width: 50px;
  }

  #page {
    padding: var(--space-4) var(--space-3) 28px;
  }

  .form-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .form-actions > .button {
    width: 100%;
    min-height: 44px;
  }

  .toolbar > .button,
  .toolbar > button {
    flex: 1 1 auto;
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
