:root {
  --bg: #f6f9fc;
  --surface: #ffffff;
  --surface-soft: #f0f4fb;
  --sidebar: #ffffff;
  --text: #1f2c73;
  --muted: #7184ad;
  --line: #e8edf6;
  --primary: #613de6;
  --primary-dark: #4b2ec4;
  --success: #36b37e;
  --warning: #ffab00;
  --danger: #ff5630;
  --info: #00a6d6;
  --teal: #2ca07a;
  --blue: #346aa9;
  --shadow: 0 18px 40px rgba(31, 66, 135, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--muted);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

body.dark {
  --bg: #10172a;
  --surface: #17213a;
  --surface-soft: #202c49;
  --sidebar: #121b31;
  --text: #eef3ff;
  --muted: #a8b4d1;
  --line: #2d3a59;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 18px 12px;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
}

.brand {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: inherit;
  text-decoration: none;
}

.brand-mark,
.merchant-logo,
.avatar {
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.brand-mark {
  width: 36px;
  height: 36px;
  box-shadow: 0 14px 24px rgba(97, 61, 230, 0.24);
}

.side-nav {
  width: 100%;
  display: grid;
  gap: 7px;
  overflow-y: auto;
  padding-bottom: 6px;
}

.nav-item,
.icon-button {
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #8394bd;
  background: transparent;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.nav-item {
  width: 100%;
  min-height: 54px;
  grid-template-rows: 22px auto;
  gap: 3px;
}

.nav-item span {
  max-width: 64px;
  overflow: hidden;
  color: currentColor;
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item:hover,
.nav-item.active,
.icon-button:hover {
  color: var(--primary);
  background: rgba(97, 61, 230, 0.1);
}

.nav-item.active {
  box-shadow: inset 0 0 0 1px rgba(97, 61, 230, 0.12);
}

.main {
  min-width: 0;
  padding-bottom: 36px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 32px;
  background: rgba(246, 249, 252, 0.84);
  border-bottom: 1px solid rgba(232, 237, 246, 0.8);
  backdrop-filter: blur(16px);
}

body.dark .topbar {
  background: rgba(16, 23, 42, 0.86);
  border-color: rgba(45, 58, 89, 0.8);
}

.search-box {
  width: min(460px, 100%);
  height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.search-box svg {
  color: var(--muted);
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-button {
  width: 44px;
  height: 44px;
}

.notification {
  position: relative;
}

.notification span {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--surface);
}

.profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 6px;
}

.avatar {
  width: 36px;
  height: 36px;
  background: #1f2c73;
  font-size: 12px;
}

body.dark .avatar {
  background: var(--primary);
}

.profile strong,
.profile small {
  display: block;
  white-space: nowrap;
}

.profile strong {
  color: var(--text);
  font-size: 13px;
}

.profile small {
  color: var(--muted);
  font-size: 11px;
}

.view {
  display: none;
  padding: 28px 32px 0;
}

.view.active {
  display: block;
}

.page-title,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.page-title p,
.section-head p {
  margin: 0;
}

.page-title strong,
.section-head h1,
.card h1,
.card h2,
.metric-card strong,
.chain-tile strong,
.risk-panel strong,
.wallet-widget h2,
.phase-card strong {
  color: var(--text);
}

.section-head p {
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.section-head h1 {
  margin: 2px 0 0;
  font-size: 24px;
  line-height: 1.35;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 9px 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(31, 66, 135, 0.1);
}

.button.primary {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.button.primary:hover {
  background: var(--primary-dark);
}

.button.ghost {
  color: var(--primary);
  background: rgba(97, 61, 230, 0.08);
  border-color: rgba(97, 61, 230, 0.16);
}

.button.small {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 13px;
}

.button.full {
  width: 100%;
}

.dashboard-layout,
.two-column,
.transfer-layout,
.reconcile-grid,
.checkout-builder {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.left-rail,
.content-grid,
.trade-grid,
.chain-config-grid {
  display: grid;
  gap: 22px;
}

.content-grid,
.chain-config-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

.content-grid > .card,
.chain-config-grid > .card {
  grid-column: span 6;
}

.content-grid > .wide,
.content-grid > .metric-grid,
.chain-config-grid > .wide {
  grid-column: 1 / -1;
}

.trade-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 22px;
}

.card,
.metric-card,
.risk-panel,
.phase-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.card-header {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px 0;
}

.card-header h2 {
  margin: 0;
  font-size: 16px;
}

.card-body {
  padding: 20px;
}

.welcome-card .card-body {
  display: grid;
  gap: 14px;
}

.merchant-logo {
  width: 56px;
  height: 56px;
}

.welcome-card h1 {
  margin: 0;
  font-size: 22px;
}

.welcome-card p {
  margin: 0;
}

.check-list,
.balance-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.check-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 600;
}

.check-list span,
.status {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-radius: 50%;
}

.check-list .ok,
.status.live {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(54, 179, 126, 0.13);
}

.check-list .pending,
.status.planned {
  background: var(--warning);
  box-shadow: 0 0 0 4px rgba(255, 171, 0, 0.16);
}

.form-stack {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: var(--surface);
  outline: 0;
}

input:focus,
select:focus {
  border-color: rgba(97, 61, 230, 0.55);
  box-shadow: 0 0 0 3px rgba(97, 61, 230, 0.12);
}

.toggle-row {
  grid-template-columns: 18px 1fr;
  align-items: center;
}

.toggle-row input {
  width: 18px;
  min-height: 18px;
}

.metric-grid,
.wallet-widget-grid,
.risk-grid,
.phase-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}

.risk-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-card {
  min-height: 118px;
  display: grid;
  gap: 8px;
  padding: 18px;
}

.metric-card span,
.metric-card small,
.wallet-widget span,
.phase-card small {
  color: var(--muted);
}

.metric-card strong {
  font-size: 24px;
  line-height: 1.1;
}

.up,
.text-success {
  color: var(--success) !important;
}

.down,
.text-danger {
  color: var(--danger) !important;
}

.chart-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.chart-summary div {
  padding: 12px;
  background: var(--surface-soft);
  border-radius: 8px;
}

.chart-summary span,
.chart-summary strong {
  display: block;
}

.chart-summary span {
  color: var(--muted);
  font-size: 12px;
}

.chart-summary strong {
  margin-top: 4px;
  color: var(--text);
}

.chart {
  min-height: 260px;
  display: grid;
  grid-template-columns: repeat(14, minmax(16px, 1fr));
  align-items: end;
  gap: 10px;
  padding: 26px 12px 10px;
  border-radius: 8px;
  background:
    linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 100% 25%,
    var(--surface-soft);
}

.bar {
  position: relative;
  min-height: 20px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, #6f54ea, #2ca07a);
}

.bar::after {
  content: attr(data-label);
  position: absolute;
  left: 50%;
  bottom: -22px;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 10px;
}

.split-balance {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.donut {
  position: relative;
  width: 150px;
  height: 150px;
  margin: auto;
  border-radius: 50%;
  background: conic-gradient(var(--teal) 0 57%, var(--blue) 57% 78%, var(--warning) 78% 90%, var(--primary) 90% 100%);
}

.donut::after {
  content: "$853K";
  position: absolute;
  inset: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--text);
  background: var(--surface);
  font-weight: 800;
}

.balance-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.balance-list li:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.balance-list span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.balance-list strong {
  color: var(--text);
  text-align: right;
  white-space: nowrap;
}

.coin {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
}

.coin.usdt {
  background: rgba(44, 160, 122, 0.18);
}

.coin.usdc {
  background: rgba(52, 106, 169, 0.18);
}

.coin.trx {
  background: rgba(255, 86, 48, 0.16);
}

.coin.evm {
  background: rgba(97, 61, 230, 0.16);
}

.coin::before {
  color: var(--text);
  font-size: 10px;
  font-weight: 900;
}

.coin.usdt::before {
  content: "T";
}

.coin.usdc::before {
  content: "C";
}

.coin.trx::before {
  content: "R";
}

.coin.evm::before {
  content: "E";
}

.chain-grid {
  display: grid;
  gap: 12px;
}

.chain-tile {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.chain-tile small {
  grid-column: 2;
}

.chain-tile.muted {
  opacity: 0.78;
}

.table-card {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  color: var(--text);
  font-size: 12px;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  color: var(--muted);
}

td strong {
  color: var(--text);
}

tbody tr:hover {
  background: rgba(97, 61, 230, 0.04);
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.pill.success {
  color: #166849;
  background: rgba(54, 179, 126, 0.15);
}

.pill.warning {
  color: #8a5f00;
  background: rgba(255, 171, 0, 0.18);
}

.pill.danger {
  color: #9b2c16;
  background: rgba(255, 86, 48, 0.16);
}

.pill.info {
  color: #075f79;
  background: rgba(0, 184, 217, 0.16);
}

body.dark .pill.success {
  color: #68dfad;
}

body.dark .pill.warning {
  color: #ffd773;
}

body.dark .pill.danger {
  color: #ff987e;
}

body.dark .pill.info {
  color: #77ddf1;
}

.row-actions {
  display: inline-flex;
  gap: 6px;
}

.row-actions button {
  min-width: 32px;
  min-height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--primary);
  background: rgba(97, 61, 230, 0.1);
  cursor: pointer;
}

.row-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.row-actions svg {
  width: 16px;
  height: 16px;
}

.address {
  display: inline-block;
  max-width: 156px;
  overflow: hidden;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.risk-panel {
  min-height: 132px;
  display: grid;
  gap: 6px;
  padding: 20px;
  border-top-width: 4px;
}

.risk-panel.high {
  border-top-color: var(--danger);
}

.risk-panel.medium {
  border-top-color: var(--warning);
}

.risk-panel.low {
  border-top-color: var(--success);
}

.risk-panel span,
.risk-panel small {
  color: var(--muted);
}

.risk-panel strong {
  font-size: 30px;
}

.wallet-widget {
  min-height: 112px;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 18px;
}

.wallet-widget h2 {
  margin: 0;
  font-size: 24px;
}

.timeline {
  display: grid;
  gap: 16px;
}

.timeline div {
  position: relative;
  display: grid;
  gap: 4px;
  padding-left: 22px;
}

.timeline div::before {
  content: "";
  position: absolute;
  top: 7px;
  left: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px rgba(97, 61, 230, 0.12);
}

.timeline strong {
  color: var(--text);
}

.fund-bars {
  display: grid;
  gap: 18px;
}

.fund-bars div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
}

.fund-bars span,
.fund-bars strong {
  color: var(--text);
}

.fund-bars i {
  grid-column: 1 / -1;
  height: 10px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--primary) var(--w), var(--surface-soft) var(--w));
}

.phase-card {
  min-height: 136px;
  display: grid;
  gap: 8px;
  padding: 20px;
  border-top: 4px solid var(--line);
}

.phase-card.active {
  border-top-color: var(--primary);
}

.phase-card span {
  color: var(--primary);
  font-weight: 900;
}

.checkout-preview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  overflow: hidden;
}

.checkout-main {
  padding: 36px;
}

.mini-brand {
  display: inline-flex;
  margin-bottom: 16px;
  color: var(--primary);
  font-weight: 800;
}

.checkout-main h2 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 24px;
}

.checkout-main p {
  max-width: 520px;
  margin: 0 0 24px;
}

.qr {
  width: 180px;
  height: 180px;
  display: grid;
  place-items: center;
  margin-bottom: 24px;
  border-radius: 8px;
  color: var(--text);
  font-weight: 900;
  background:
    linear-gradient(90deg, var(--text) 10px, transparent 10px) 0 0 / 30px 30px,
    linear-gradient(var(--text) 10px, transparent 10px) 0 0 / 30px 30px,
    var(--surface-soft);
}

dl {
  display: grid;
  gap: 12px;
  margin: 0;
}

dl div {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-weight: 800;
}

.checkout-side {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 36px 28px;
  background: var(--surface-soft);
  color: var(--text);
}

.checkout-side strong {
  margin-bottom: 6px;
}

.checkout-side span {
  min-height: 34px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 80;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: 8px;
  color: #fff;
  background: #1f2c73;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.16);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1180px) {
  .dashboard-layout,
  .two-column,
  .transfer-layout,
  .reconcile-grid,
  .checkout-builder {
    grid-template-columns: 1fr;
  }

  .left-rail,
  .trade-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-grid,
  .wallet-widget-grid,
  .phase-grid,
  .chart-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    height: 74px;
    flex-direction: row;
    justify-content: center;
    padding: 8px 12px;
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  .brand {
    display: none;
  }

  .side-nav {
    grid-auto-flow: column;
    grid-auto-columns: 68px;
    overflow-x: auto;
    overflow-y: hidden;
    width: 100%;
  }

  .nav-item {
    min-height: 54px;
  }

  .main {
    padding-bottom: 92px;
  }

  .topbar {
    padding: 12px 18px;
  }

  .profile div {
    display: none;
  }

  .view {
    padding: 22px 18px 0;
  }

  .page-title,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .left-rail,
  .content-grid,
  .trade-grid,
  .risk-grid,
  .chain-config-grid {
    grid-template-columns: 1fr;
  }

  .content-grid > .card,
  .chain-config-grid > .card {
    grid-column: 1 / -1;
  }

  .checkout-preview {
    grid-template-columns: 1fr;
  }

  .checkout-side {
    padding-top: 24px;
  }
}

@media (max-width: 620px) {
  .topbar {
    gap: 10px;
  }

  .search-box {
    height: 40px;
  }

  .top-actions {
    gap: 6px;
  }

  .icon-button {
    width: 38px;
    height: 38px;
  }

  .metric-grid,
  .wallet-widget-grid,
  .phase-grid,
  .chart-summary,
  .split-balance {
    grid-template-columns: 1fr;
  }

  .card-body,
  .checkout-main {
    padding: 16px;
  }

  .card-header {
    padding: 16px 16px 0;
  }

  .chart {
    min-height: 210px;
    gap: 6px;
    overflow-x: auto;
  }

  .qr {
    width: 150px;
    height: 150px;
  }
}
