@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

:root {
  /* Design Tokens — Archival Financial System */
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  color: #0f172a;
  background-color: #f8fafc;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  /* Neutrals (Graphite / Slate) */
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-recessed: #e2e8f0;
  --bg-dark: #0f172a;

  /* Borders & Hairlines */
  --border-light: #e2e8f0;
  --border-subtle: #f1f5f9;
  --border-focus: #2563eb;
  --border-dark: rgba(255, 255, 255, 0.12);

  /* Typography Roles */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #f8fafc;

  /* Accent (Single restrained navy/indigo) */
  --accent: #1e40af;
  --accent-hover: #1d4ed8;
  --accent-subtle: #eff6ff;

  /* Semantics */
  --green: #047857;
  --green-bg: #ecfdf5;
  --green-border: #a7f3d0;

  --amber: #b45309;
  --amber-bg: #fffbeb;
  --amber-border: #fde68a;

  --rose: #b91c1c;
  --rose-bg: #fef2f2;
  --rose-border: #fecaca;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.03);
  --shadow-modal: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.05);

  /* Nested Radii */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.5;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: transparent;
  border: none;
}

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

a {
  color: inherit;
  text-decoration: none;
}

.hidden {
  display: none !important;
}

/* Base Shell */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  width: 256px;
  flex: 0 0 256px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-light);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 24px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.brand-logo {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  background: var(--bg-dark);
  border-radius: var(--radius-md);
  color: #ffffff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-size: 16px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.brand-logo span {
  color: #93c5fd;
}

.side-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  padding: 16px 12px 6px;
  text-transform: none;
}

.nav-link {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  border-radius: var(--radius-md);
  background: transparent;
  text-align: left;
  padding: 0 12px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background-color 120ms ease, color 120ms ease;
}

.nav-link:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.nav-link.active {
  color: var(--text-primary);
  background: var(--bg-subtle);
  font-weight: 600;
  box-shadow: inset 2px 0 0 0 var(--accent);
}

.nav-link svg {
  height: 16px;
  width: 16px;
  stroke-width: 1.5;
  color: var(--text-muted);
}

.nav-link.active svg {
  color: var(--accent);
}

.side-bottom {
  margin-top: auto;
  padding-top: 16px;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 11px;
  padding: 4px 12px 12px;
}

.status-circle {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

.status-circle.offline {
  background: var(--amber);
}

.side-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 8px 0;
  border-top: 1px solid var(--border-light);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border-light);
}

.side-profile strong {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  display: block;
}

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

.side-profile .round-btn {
  margin-left: auto;
}

/* Main Content & Topbar */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 32px 40px 96px;
  max-width: 1440px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
  height: 48px;
  margin-bottom: 28px;
}

.searchbox {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 320px;
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  height: 36px;
  padding: 0 12px;
  color: var(--text-muted);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.searchbox:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.searchbox input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  font-size: 12px;
  color: var(--text-primary);
}

.searchbox input::placeholder {
  color: var(--text-muted);
}

.key-mini {
  display: flex;
  align-items: center;
}

.kbd {
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 1px 5px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-family: ui-monospace, monospace;
  font-size: 10px;
  font-weight: 500;
}

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

.round-btn {
  height: 36px;
  width: 36px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  position: relative;
  transition: border-color 120ms ease, color 120ms ease, background-color 120ms ease;
}

.round-btn:hover {
  border-color: var(--border-focus);
  color: var(--text-primary);
  background: var(--bg-subtle);
}

.round-btn svg, .btn svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.5;
}

/* Buttons */
.btn {
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  transition: background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.btn:hover {
  background: var(--bg-subtle);
  border-color: #cbd5e1;
}

.btn.primary-btn {
  background: var(--bg-dark);
  color: #ffffff;
  border-color: var(--bg-dark);
}

.btn.primary-btn:hover {
  background: #1e293b;
  border-color: #1e293b;
}

.btn.small {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  gap: 6px;
}

.btn.small svg {
  width: 14px;
  height: 14px;
}

.link-btn {
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 6px;
  border-radius: var(--radius-xs);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.link-btn:hover {
  text-decoration: underline;
}

.mobile-menu {
  display: none;
}

/* Page Headers */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.eyebrow {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
  margin-bottom: 4px;
}

.page-head h1 {
  font-size: 24px;
  letter-spacing: -0.015em;
  margin: 0 0 4px;
  font-weight: 600;
  color: var(--text-primary);
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.head-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Cards & Surfaces */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.card-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.muted {
  color: var(--text-muted);
}

.tiny {
  font-size: 11px;
}

.small-text {
  font-size: 12px;
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi {
  min-height: 128px;
  padding: 20px;
  position: relative;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.kpi .label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.kpi h2 {
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 12px 0 4px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--text-primary);
}

.kpi p {
  font-size: 11px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.4;
}

.kpi-icon {
  position: absolute;
  right: 18px;
  top: 18px;
  height: 32px;
  width: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.kpi-icon svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.5;
}

/* Hero KPI (Matte Dark Slate Archival Surface) */
.kpi.hero {
  background: var(--bg-dark);
  border-color: #1e293b;
  color: #ffffff;
  box-shadow: var(--shadow-md);
}

.kpi.hero .label {
  color: #cbd5e1;
}

.kpi.hero h2 {
  color: #ffffff;
}

.kpi.hero p {
  color: #94a3b8;
}

.kpi.hero .kpi-icon {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

/* Main Grid & Chart */
.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.mini-chart {
  height: 180px;
  width: 100%;
  display: flex;
  align-items: flex-end;
  padding: 8px 0 4px;
}

.mini-chart svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.legend {
  display: flex;
  gap: 16px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  margin-top: 12px;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.bar-track {
  height: 8px;
  display: flex;
  overflow: hidden;
  background: var(--bg-subtle);
  border-radius: var(--radius-xs);
  margin: 16px 0 16px;
}

.bar-track span {
  height: 100%;
}

.breakdown {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.break-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.break-row strong {
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.break-dot {
  width: 8px;
  height: 8px;
  display: inline-block;
  border-radius: 2px;
  margin-right: 8px;
}

/* List Rows */
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.list-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.list-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}

.list-icon svg {
  height: 16px;
  width: 16px;
  stroke-width: 1.5;
}

.list-row strong {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.list-row small {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.list-value {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right;
  color: var(--text-primary);
}

/* Chips & Badges */
.chip {
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.chip.good {
  background: var(--green-bg);
  border-color: var(--green-border);
  color: var(--green);
}

.chip.warn {
  background: var(--amber-bg);
  border-color: var(--amber-border);
  color: var(--amber);
}

.chip.blue {
  background: var(--accent-subtle);
  border-color: #bfdbfe;
  color: var(--accent);
}

/* Empty States */
.empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-secondary);
  font-size: 12px;
}

.empty svg {
  height: 24px;
  width: 24px;
  stroke-width: 1.5;
  margin-bottom: 8px;
  color: var(--text-muted);
}

/* Accounts & Wallet Cards */
.section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.wallet-card {
  min-height: 140px;
  padding: 20px;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: border-color 120ms ease;
}

.wallet-card:hover {
  border-color: #cbd5e1;
}

.wallet-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.wallet-symbol {
  height: 32px;
  width: 32px;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 13px;
}

.wallet-card h2 {
  font-size: 22px;
  letter-spacing: -0.015em;
  margin: 14px 0 4px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.wallet-card .provider {
  color: var(--text-muted);
  font-size: 11px;
}

.wallet-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.wallet-type {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
}

.wallet-open {
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 6px;
  display: grid;
  place-items: center;
  transition: color 120ms ease, background-color 120ms ease;
}

.wallet-open:hover {
  color: var(--text-primary);
  background: #e2e8f0;
}

/* Stat Strip */
.stat-strip {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 12px;
  box-shadow: var(--shadow-sm);
}

.stat-pill strong {
  color: var(--text-primary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stat-pill svg {
  width: 14px;
  height: 14px;
  stroke-width: 1.5;
  color: var(--text-muted);
}

/* Tables */
.table-scroll {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  white-space: nowrap;
}

.data-table thead {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
}

.data-table th {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
}

.data-table td {
  padding: 12px 12px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: var(--bg-subtle);
}

.row-inline {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mini-avatar {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 11px;
}

/* Forms & Inputs */
.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.input, .select, textarea.input {
  height: 36px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: 0 12px;
  outline: none;
  min-width: 0;
  width: 100%;
  font-size: 13px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.input:focus, .select:focus, textarea.input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.field-hint {
  font-size: 11px;
  color: var(--text-muted);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.field.full {
  grid-column: 1 / -1;
}

.field select {
  appearance: auto;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  z-index: 85;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade 120ms ease-out;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  width: min(100%, 540px);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-modal);
  animation: appear 150ms ease-out;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-head h2 {
  font-size: 17px;
  margin: 0;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.modal-body {
  padding: 16px 24px 24px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

.modal-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0 0 16px;
}

/* Notices */
.notice {
  padding: 12px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
}

.notice.warning {
  border-color: var(--amber-border);
  background: var(--amber-bg);
  color: var(--amber);
}

.notice.good {
  border-color: var(--green-border);
  background: var(--green-bg);
  color: var(--green);
}

/* Auth / Sign In */
.auth-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-surface);
}

.auth-art {
  background: var(--bg-dark);
  padding: 64px 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #ffffff;
  position: relative;
  border-right: 1px solid #1e293b;
}

.auth-art h1 {
  font-size: 32px;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0 0 16px;
  font-weight: 600;
  color: #ffffff;
}

.auth-art p {
  line-height: 1.6;
  color: #94a3b8;
  font-size: 14px;
  margin: 0;
}

.auth-circle {
  display: none;
}

.auth-main {
  display: grid;
  place-items: center;
  padding: 40px;
}

.auth-box {
  max-width: 360px;
  width: 100%;
}

.auth-box .brand {
  padding: 0 0 32px;
}

.auth-box h2 {
  font-size: 22px;
  letter-spacing: -0.015em;
  margin: 0 0 8px;
  font-weight: 600;
  color: var(--text-primary);
}

.auth-box p {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
  margin: 0 0 24px;
}

.auth-box form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-box .btn {
  width: 100%;
  height: 40px;
}

.footer-note {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 24px;
}

/* Boot Screen */
.boot {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}

.boot-logo {
  font-size: 36px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: ui-monospace, monospace;
}

.boot-logo span {
  color: var(--accent);
}

.boot-loader {
  width: 64px;
  height: 2px;
  border-radius: var(--radius-xs);
  background: var(--accent);
  opacity: 0.8;
  animation: pulse 1s infinite alternate;
}

/* Toasts */
#toasts {
  position: fixed;
  right: 24px;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 130;
}

.toast {
  max-width: 380px;
  background: var(--bg-dark);
  color: #ffffff;
  font-size: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border: 1px solid #1e293b;
  animation: appear 150ms ease-out;
}

.toast.error {
  background: #7f1d1d;
  border-color: #991b1b;
}

.toast-undo {
  display: inline-block;
  margin-left: 12px;
  border: none;
  background: transparent;
  color: #93c5fd;
  text-decoration: underline;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.notification-dot {
  width: 6px;
  height: 6px;
  position: absolute;
  right: 6px;
  top: 6px;
  border-radius: 50%;
  background: var(--amber);
}

/* Spot Banner */
.spot-banner {
  border-radius: var(--radius-lg);
  padding: 24px;
  background: #1e293b;
  color: #ffffff;
  margin-bottom: 24px;
  border: 1px solid #334155;
}

.spot-banner h2 {
  margin: 8px 0 6px;
  font-size: 20px;
  letter-spacing: -0.015em;
  font-weight: 600;
}

.spot-banner p {
  font-size: 12px;
  color: #94a3b8;
  margin: 0;
}

.spot-banner .chip {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.report-version {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 12px;
}

.report-version h3 {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 8px;
}

.report-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.report-stats span {
  font-size: 11px;
  color: var(--text-muted);
}

.report-stats strong {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

/* DPS & Transactions */
#quick-fields {
  grid-column: 1 / -1;
}

#quick-fields > .form-grid {
  grid-template-columns: 1fr 1fr;
}

.dps-opening-area {
  grid-column: 1 / -1;
  min-width: 0;
  margin-top: 4px;
  padding: 16px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
}

.dps-confirm {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
  font-weight: 500;
  cursor: pointer;
}

.dps-confirm input {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  accent-color: var(--accent);
  margin-top: 2px;
}

.dps-estimate-preview {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
  background: var(--bg-subtle);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}

.dps-estimate-preview svg {
  flex: none;
  margin-top: 2px;
  color: var(--accent);
}

.dps-list-item {
  display: flex;
  align-items: center;
  text-align: left;
  gap: 12px;
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  background: transparent;
  padding: 14px 0;
  color: var(--text-primary);
  transition: background-color 120ms ease;
}

.dps-list-item:hover {
  background: var(--bg-subtle);
}

.dps-list-item:last-child {
  border-bottom: none;
}

.dps-list-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  flex: none;
}

.dps-list-info {
  flex: 1;
  min-width: 0;
}

.dps-list-info > strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.dps-list-info > small {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 11px;
}

.dps-status {
  display: inline-flex;
  margin-top: 4px;
  color: var(--green);
  font-size: 11px;
  font-weight: 500;
}

.dps-status.due {
  color: var(--amber);
}

.dps-list-amount {
  text-align: right;
  margin-left: auto;
  white-space: nowrap;
}

.dps-list-amount strong {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  display: block;
}

.dps-list-amount small {
  color: var(--text-muted);
  font-size: 11px;
}

.simple-reserve {
  background: var(--bg-subtle);
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}

.simple-reserve h2 {
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin: 6px 0 0;
  color: var(--text-primary);
}

.mature-alert {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.mature-alert svg {
  flex: none;
}

.dps-detail {
  width: min(100%, 560px);
}

.dps-detail-balance {
  padding: 20px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
}

.dps-detail-balance span, .payout-summary span {
  display: block;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
}

.dps-detail-balance h2 {
  margin: 6px 0 2px;
  font-size: 26px;
  letter-spacing: -0.015em;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.dps-detail-balance small, .payout-summary small {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}

.dps-detail-metas {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0 16px;
}

.dps-detail-metas > div {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  min-width: 0;
  background: var(--bg-surface);
}

.dps-detail-metas small {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
}

.dps-detail-metas strong {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
  display: block;
  overflow-wrap: anywhere;
}

.dps-close-actions {
  display: flex;
  gap: 8px;
}

.dps-close-actions > .btn {
  flex: 1;
}

.dps-mini-tx {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border-subtle);
  padding: 12px 0;
}

.dps-mini-tx:last-child {
  border-bottom: none;
}

.dps-mini-tx > div {
  min-width: 0;
}

.dps-mini-tx strong {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.dps-mini-tx small {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  display: block;
  overflow-wrap: anywhere;
}

.dps-tx-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.payout-summary {
  padding: 14px 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
}

.payout-summary strong {
  display: block;
  margin: 4px 0 2px;
  font-size: 13px;
  font-weight: 600;
}

/* Activity / Journal Rows */
.tx-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border-bottom: 1px solid var(--border-subtle);
  padding: 14px 0;
}

.tx-row:last-child {
  border-bottom: none;
}

.tx-icon {
  flex: 0 0 32px;
  height: 32px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  color: var(--text-secondary);
}

.tx-icon svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.5;
}

.tx-main {
  flex: 1;
  min-width: 0;
}

.tx-main > strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.tx-description {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-secondary);
}

.tx-legs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.transaction-line {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.transaction-line.in {
  color: var(--green);
}

.transaction-line.out {
  color: var(--rose);
}

.transaction-account {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 2px;
}

.tx-arrow {
  font-size: 11px;
  color: var(--text-muted);
}

.tx-id {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  font-family: ui-monospace, SFMono-Regular, monospace;
}

.tx-copy {
  flex: none;
}

.activity-more {
  text-align: center;
  padding: 16px;
}

.recent-amount {
  margin-left: auto;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  text-align: right;
  font-size: 12px;
  max-width: 220px;
  line-height: 1.4;
}

.transaction-short-id {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 10px;
  color: var(--text-muted);
}

.dps-legacy-tools {
  margin: 16px 0 12px;
  padding: 12px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
}

.dps-legacy-tools summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.dps-projection {
  border: 1px solid var(--border-light);
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin: 0 0 16px;
}

.dps-projection-head {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 2px 0;
}

.dps-projection-head span {
  font-size: 12px;
  color: var(--text-secondary);
  flex: 1;
}

.dps-projection-head strong {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.dps-projection > small {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 6px;
  line-height: 1.5;
}

/* Animations */
@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes appear {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  to { opacity: 0.35; }
}

/* Floating Action Button */
.float-add {
  display: none;
}

.mobile-overlay {
  display: none;
}

/* Responsive Media Queries */
@media (max-width: 1160px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .sidebar {
    width: 220px;
    flex-basis: 220px;
  }
  .main-content {
    padding: 24px 24px 80px;
  }
}

@media (max-width: 830px) {
  .sidebar {
    position: fixed;
    transform: translateX(-100%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .mobile-overlay.show {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 39;
  }
  .mobile-menu {
    display: grid;
  }
  .main-grid, .two-col {
    grid-template-columns: 1fr;
  }
  .topbar {
    margin-bottom: 20px;
  }
  .searchbox {
    max-width: 220px;
  }
  .main-content {
    padding: 20px 16px 80px;
  }
}

@media (max-width: 540px) {
  .page-head h1 {
    font-size: 20px;
  }
  .page-head {
    align-items: flex-start;
  }
  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .card {
    padding: 16px;
    border-radius: var(--radius-md);
  }
  .kpi {
    padding: 16px;
    min-height: 112px;
  }
  .kpi h2 {
    font-size: 20px;
  }
  .kpi-icon {
    right: 14px;
    top: 14px;
  }
  .topbar .head-create {
    display: none;
  }
  .searchbox {
    max-width: none;
  }
  .section-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .auth-layout {
    grid-template-columns: 1fr;
  }
  .auth-art {
    display: none;
  }
  .auth-main {
    min-height: 100vh;
  }
  .float-add {
    display: grid;
    place-items: center;
    position: fixed;
    bottom: 24px;
    right: 20px;
    background: var(--bg-dark);
    color: #ffffff;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 30;
  }
  .float-add svg {
    width: 20px;
    height: 20px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .dps-detail-metas {
    grid-template-columns: 1fr;
  }
  .dps-close-actions {
    flex-direction: column;
  }
}

/* ==========================================================================
   Business & Customer Ledger Management Refactor
   ========================================================================== */

.modal.modal-lg {
  width: min(100%, 840px);
}

.modal.modal-xl {
  width: min(100%, 980px);
}

/* Business Sub-Navigation */
.biz-subnav {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 20px;
  padding-bottom: 8px;
  overflow-x: auto;
}

.biz-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.biz-tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.biz-tab-btn.active {
  color: var(--text-primary);
  background: var(--bg-surface);
  border-color: var(--border-light);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.biz-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  background: var(--subtle-bg);
  color: var(--text-secondary);
}

.biz-tab-btn.active .biz-tab-badge {
  background: var(--border-light);
  color: var(--text-primary);
}

/* Customer Balance Hero Card */
.customer-balance-hero {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.customer-balance-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.customer-balance-large {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 6px 0 16px;
  font-variant-numeric: tabular-nums;
}

.customer-balance-large.credit {
  color: #16a34a;
}

.customer-balance-large.due {
  color: #ea580c;
}

.customer-balance-large.settled {
  color: var(--text-secondary);
}

.balance-stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}

.balance-stat-item {
  background: var(--subtle-bg);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.balance-stat-item span {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 2px;
}

.balance-stat-item strong {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* Customer Primary Action Bar */
.customer-action-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 24px;
}

.customer-action-bar .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 500;
}

/* Status Chips */
.chip.credit {
  background: rgba(22, 163, 74, 0.1);
  color: #16a34a;
  border-color: rgba(22, 163, 74, 0.2);
}

.chip.due {
  background: rgba(234, 88, 12, 0.1);
  color: #ea580c;
  border-color: rgba(234, 88, 12, 0.2);
}

.chip.settled {
  background: var(--subtle-bg);
  color: var(--text-secondary);
  border-color: var(--border-subtle);
}

/* Statement & Memo Presentation */
.memo-print-area {
  background: #ffffff;
  color: #0f172a;
  padding: 32px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.memo-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 24px;
  margin-bottom: 24px;
  border-bottom: 2px solid #e2e8f0;
}

.memo-brand h1 {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 4px;
  color: #0f172a;
}

.memo-brand p {
  margin: 0;
  font-size: 13px;
  color: #64748b;
}

.memo-meta {
  text-align: right;
  font-size: 13px;
  color: #475569;
}

.memo-meta strong {
  display: block;
  font-size: 16px;
  color: #0f172a;
  margin-bottom: 4px;
}

.memo-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 28px;
  padding: 16px 20px;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.memo-party h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin: 0 0 6px;
}

.memo-party strong {
  font-size: 16px;
  color: #0f172a;
  display: block;
}

.memo-party p {
  font-size: 13px;
  color: #475569;
  margin: 2px 0 0;
}

.memo-summary-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.memo-card-box {
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
}

.memo-card-box span {
  font-size: 11px;
  text-transform: uppercase;
  color: #64748b;
  display: block;
  margin-bottom: 4px;
}

.memo-card-box strong {
  font-size: 17px;
  font-weight: 700;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}

.memo-card-box.highlight {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.memo-card-box.highlight-due {
  background: #fff7ed;
  border-color: #fed7aa;
}

.memo-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 24px;
}

.memo-table th {
  text-align: left;
  padding: 10px 12px;
  background: #f1f5f9;
  color: #475569;
  font-weight: 600;
  border-bottom: 2px solid #cbd5e1;
}

.memo-table td {
  padding: 12px;
  border-bottom: 1px solid #e2e8f0;
  color: #334155;
}

.memo-table tr:hover td {
  background: #f8fafc;
}

.memo-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.memo-footer {
  padding-top: 20px;
  border-top: 1px solid #e2e8f0;
  font-size: 12px;
  color: #64748b;
  text-align: center;
}

/* Native Print Styles */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  body * {
    visibility: hidden;
  }
  #portal, #portal *, .memo-print-area, .memo-print-area * {
    visibility: visible;
  }
  #portal {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
  }
  .modal-backdrop {
    position: static !important;
    background: transparent !important;
    padding: 0 !important;
    display: block !important;
  }
  .modal {
    width: 100% !important;
    max-width: 100% !important;
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    animation: none !important;
  }
  .memo-print-area {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
  .no-print {
    display: none !important;
  }
}
