/* Saldo — Moliyaviy boshqaruv tizimi
   Professional finance UI (Xero/QuickBooks-style) — light default + dark mode. */

/* ===== Theme tokens ===== */
:root,
:root[data-theme="light"] {
  --bg: #ffffff;
  --bg-2: #f8fafc;        /* slate-50 */
  --bg-3: #f1f5f9;        /* slate-100 */
  --bg-4: #e2e8f0;        /* slate-200 */
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;       /* slate-200 */
  --border-strong: #cbd5e1;

  --text: #0f172a;         /* slate-900 */
  --text-2: #475569;       /* slate-600 — muted */
  --text-3: #94a3b8;       /* slate-400 — subtle */

  --primary: #1e3a8a;       /* indigo-900 */
  --primary-hover: #1e40af; /* indigo-800 */
  --primary-soft: #eef2ff;  /* indigo-50 */
  --primary-ring: rgba(30, 58, 138, 0.18);

  --success: #047857;       /* emerald-700 */
  --success-soft: #ecfdf5;
  --danger: #b91c1c;        /* red-700 */
  --danger-soft: #fef2f2;
  --warning: #b45309;       /* amber-700 */
  --warning-soft: #fffbeb;
  --info: #0e7490;          /* cyan-700 */
  --info-soft: #ecfeff;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 10px 24px rgba(15, 23, 42, .08), 0 4px 8px rgba(15, 23, 42, .04);

  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;
  --gap: 16px;
}

:root[data-theme="dark"] {
  --bg: #0f172a;            /* slate-900 */
  --bg-2: #111827;
  --bg-3: #1f2937;          /* slate-800 */
  --bg-4: #334155;          /* slate-700 */
  --surface: #1e293b;       /* slate-800 */
  --surface-2: #111827;
  --border: #334155;        /* slate-700 */
  --border-strong: #475569;

  --text: #f1f5f9;
  --text-2: #cbd5e1;
  --text-3: #94a3b8;

  --primary: #6366f1;       /* indigo-500 */
  --primary-hover: #818cf8;
  --primary-soft: rgba(99, 102, 241, 0.15);
  --primary-ring: rgba(99, 102, 241, 0.35);

  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.15);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.15);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.15);
  --info: #06b6d4;
  --info-soft: rgba(6, 182, 212, 0.15);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 3px rgba(0, 0, 0, .35), 0 1px 2px rgba(0, 0, 0, .25);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55), 0 4px 12px rgba(0, 0, 0, .35);
}

/* ===== Base ===== */
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  color: var(--text);
  background: var(--bg-2);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body { min-height: 100vh; }

a { color: var(--primary); text-decoration: none; transition: color .15s; }
a:hover { color: var(--primary-hover); text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { margin: 0 0 12px; line-height: 1.25; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; font-weight: 600; }
.muted { color: var(--text-2); font-size: 13px; }
.hidden { display: none !important; }
.link { font-size: 13px; color: var(--primary); cursor: pointer; }

/* ===== AUTH PAGE ===== */
.auth-page {
  min-height: 100vh;
  display: grid; place-items: center;
  background: var(--bg-2);
  padding: 24px;
}
.auth-wrap {
  display: grid; grid-template-columns: 1fr 1fr;
  max-width: 1000px; width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--shadow-lg);
  min-height: 560px;
}
.auth-card { padding: 44px; }
.auth-side {
  background: linear-gradient(160deg, var(--primary) 0%, #2563eb 100%);
  color: #fff;
  padding: 44px;
  display: flex; align-items: center;
}
.auth-side-inner h2 { color: #fff; font-size: 24px; margin-bottom: 24px; }
.auth-side-inner ul { padding: 0; list-style: none; }
.auth-side-inner li {
  padding: 10px 0 10px 28px; position: relative;
  color: rgba(255, 255, 255, 0.9); font-size: 14px;
}
.auth-side-inner li::before {
  content: ""; position: absolute; left: 0; top: 16px;
  width: 18px; height: 2px; background: rgba(255, 255, 255, 0.6); border-radius: 2px;
}

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.brand-logo {
  width: 40px; height: 40px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 18px;
  letter-spacing: -0.02em;
}
.brand-title { font-weight: 700; font-size: 18px; color: var(--text); letter-spacing: -0.01em; }
.brand-subtitle { font-size: 12px; color: var(--text-2); margin-top: 2px; }

.tabs { display: flex; gap: 4px; margin: 20px 0 18px; padding: 3px; background: var(--bg-3); border-radius: 8px; }
.tab {
  flex: 1; background: transparent; border: none; padding: 9px 14px;
  cursor: pointer; color: var(--text-2); font-size: 14px; font-weight: 500;
  border-radius: 6px; transition: all .15s; font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

form label {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--text-2); margin: 14px 0 6px;
}
form input, form select, form textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit;
  background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
form input::placeholder { color: var(--text-3); }
form input:focus, form select:focus, form textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: all .15s; font-family: inherit;
}
.btn:hover { background: var(--bg-2); border-color: var(--border-strong); }
.btn.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 500;
}
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--bg-3); color: var(--text); }
.btn.danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger-soft); }
.btn.block { width: 100%; margin-top: 18px; }

/* Lang switch */
.lang-switch { display: inline-flex; gap: 2px; background: var(--bg-3); padding: 3px; border-radius: 6px; }
.lang-switch.top-right { position: absolute; top: 20px; right: 20px; }
.lang-switch button {
  border: none; background: transparent; padding: 5px 10px;
  border-radius: 4px; font-size: 12px; font-weight: 500; cursor: pointer;
  color: var(--text-2); transition: all .15s; font-family: inherit;
}
.lang-switch button:hover { color: var(--text); }
.lang-switch button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* Theme toggle */
.theme-switch {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.theme-switch:hover { background: var(--bg-4); color: var(--text); }
.theme-switch svg { width: 14px; height: 14px; }

.auth-msg { margin-top: 12px; padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px; display: none; border: 1px solid transparent; }
.auth-msg.error { display: block; background: var(--danger-soft); color: var(--danger); border-color: var(--danger-soft); }
.auth-msg.success { display: block; background: var(--success-soft); color: var(--success); border-color: var(--success-soft); }
.auth-msg.info { display: block; background: var(--primary-soft); color: var(--primary); border-color: var(--primary-soft); }
.auth-footer { margin-top: 22px; text-align: center; font-size: 13px; color: var(--text-2); }

/* ===== APP SHELL ===== */
.app-shell {
  display: grid; grid-template-columns: 240px 1fr;
  min-height: 100vh;
  background: var(--bg-2);
}
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  color: var(--text-2);
  padding: 20px 14px;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 16px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 14px;
  font-weight: 500;
  transition: all .12s;
  text-decoration: none;
}
.nav-item:hover {
  background: var(--bg-3);
  color: var(--text);
  text-decoration: none;
}
.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
}
.nav-item .ico {
  width: 18px; height: 18px;
  display: inline-grid; place-items: center;
  flex-shrink: 0;
}
.nav-item .ico svg { width: 16px; height: 16px; stroke-width: 1.75; }

.sidebar-footer {
  display: flex; flex-direction: column; gap: 10px;
  padding-top: 14px; border-top: 1px solid var(--border);
}
.sidebar-footer .footer-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.sidebar-footer .lang-switch { flex: 1; justify-content: center; }

.main { padding: 28px 32px; max-width: 100%; overflow-x: hidden; }
.topbar { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.topbar-actions { display: flex; gap: 8px; }
.select {
  padding: 8px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-size: 14px; cursor: pointer;
  font-family: inherit;
}
.select:hover { border-color: var(--border-strong); }
.select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }

.view { display: none; }
.view.active { display: block; }

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--gap);
}
.flex-between { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }

/* ===== KPI ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gap); margin-bottom: var(--gap); }
.kpi {
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s;
}
.kpi:hover { border-color: var(--border-strong); }
.kpi-label {
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 6px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}
.kpi-value {
  font-size: clamp(1.25rem, 3vw, 1.65rem);
  font-weight: 600;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1.2;
  word-break: break-word;
}
.kpi-value.income { color: var(--success); }
.kpi-value.expense { color: var(--danger); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.chart-wrap { position: relative; height: 280px; width: 100%; }
.chart-wrap canvas { position: absolute; top: 0; left: 0; width: 100% !important; height: 100% !important; }

.chart-loading {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(2px);
  border-radius: var(--radius);
  z-index: 2;
}
:root[data-theme="dark"] .chart-loading { background: rgba(15, 23, 42, 0.6); }
.chart-loading.hidden { display: none; }
.chart-spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: chart-spin .8s linear infinite;
}
.chart-loading-text {
  font-size: 12px; color: var(--text-2);
}
@keyframes chart-spin { to { transform: rotate(360deg); } }

/* ===== Tables ===== */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table thead th {
  text-align: left; padding: 10px 12px;
  background: var(--bg-2);
  color: var(--text-2); font-weight: 600;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.data-table tbody td { padding: 11px 12px; border-bottom: 1px solid var(--border); color: var(--text); }
.data-table tbody tr { transition: background .12s; }
.data-table tbody tr:nth-child(even) { background: var(--bg-2); }
.data-table tbody tr:hover { background: var(--primary-soft); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.data-table .num.income { color: var(--success); }
.data-table .num.expense { color: var(--danger); }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* Sortable column headers */
.sortable-table thead th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color .15s, background .15s;
}
.sortable-table thead th.sortable:hover {
  color: var(--text);
  background: var(--bg-3);
}
.sortable-table thead th.sortable .sort-arrow {
  display: inline-block;
  margin-left: 4px;
  width: 10px;
  opacity: 0.4;
  font-size: 10px;
}
.sortable-table thead th.sort-asc .sort-arrow::after { content: "▲"; opacity: 1; color: var(--primary); }
.sortable-table thead th.sort-desc .sort-arrow::after { content: "▼"; opacity: 1; color: var(--primary); }
.sortable-table thead th.sort-asc, .sortable-table thead th.sort-desc { color: var(--text); }

/* Pagination */
.tx-pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 4px; padding: 16px 0 4px; flex-wrap: wrap;
}
.tx-pagination button {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  cursor: pointer;
  padding: 6px 12px;
  font-size: 13px;
  font-family: inherit;
  min-width: 36px;
  transition: all .12s;
}
.tx-pagination button:hover:not(:disabled) {
  background: var(--bg-2);
  color: var(--text);
  border-color: var(--border-strong);
}
.tx-pagination button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.tx-pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.tx-pagination .page-info { color: var(--text-2); font-size: 13px; padding: 0 12px; }
.icon-btn {
  background: var(--surface); border: 1px solid var(--border);
  cursor: pointer; padding: 5px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 13px; transition: all .12s;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; min-height: 28px;
}
.icon-btn:hover { background: var(--bg-2); color: var(--text); border-color: var(--border-strong); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.icon-btn svg { width: 14px; height: 14px; stroke-width: 1.75; }

.empty { text-align: center; padding: 40px 20px; color: var(--text-2); }

/* ===== Forms ===== */
.form-card { max-width: 800px; }
.account-search { margin-bottom: 6px; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.grid-form .span-2 { grid-column: span 2; }
.grid-form .span-full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 12px; }

/* Filters */
.filters { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.filters input, .filters select {
  padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-size: 14px; font-family: inherit;
}
.filters input[type="search"] { min-width: 220px; }

/* Report table */
.report-scroll { overflow-x: auto; margin-top: 12px; }
.report-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 1000px; }
.report-table th, .report-table td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.report-table th:first-child, .report-table td:first-child {
  text-align: left; white-space: nowrap; color: var(--text);
}
.report-table thead th { background: var(--bg-2); font-weight: 600; color: var(--text-2); font-size: 12px; }
.report-table tr.section-header td {
  background: var(--primary);
  color: #fff; font-weight: 600;
  text-align: left;
  font-size: 12px;
  letter-spacing: 0.02em;
}
.report-table tr.subtotal td { background: var(--bg-3); font-weight: 600; color: var(--text); }
.report-table tr.total td { background: var(--primary-soft); font-weight: 700; color: var(--text); border-top: 2px solid var(--primary); }
.report-table td.income { color: var(--success); font-weight: 500; }
.report-table td.expense { color: var(--danger); font-weight: 500; }
.report-table td.muted { color: var(--text-2); font-style: normal; }
.report-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ===== Modal ===== */
.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.4); display: grid; place-items: center; z-index: 100; padding: 20px; backdrop-filter: blur(2px); }
.modal-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px;
  max-width: 540px; width: 100%; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-2);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  font-family: inherit;
  transition: all .12s;
  padding: 0;
  z-index: 2;
}
.modal-close:hover { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.confirm-card { max-width: 380px; }

/* ===== Badges ===== */
.badge {
  display: inline-block; padding: 2px 8px;
  border-radius: 4px; font-size: 11px; font-weight: 500;
  letter-spacing: 0.02em;
}
.badge.income { background: var(--success-soft); color: var(--success); }
.badge.expense { background: var(--danger-soft); color: var(--danger); }
.badge.flow-operating { background: var(--primary-soft); color: var(--primary); }
.badge.flow-financial { background: var(--warning-soft); color: var(--warning); }
.badge.flow-investment { background: var(--info-soft); color: var(--info); }
.badge.muted { background: var(--bg-3); color: var(--text-2); }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ===== Mobile bottom tabbar (hidden by default) ===== */
.mobile-tabbar { display: none; }

/* Responsive — Tablet */
@media (max-width: 980px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-form { grid-template-columns: 1fr 1fr; }
  .grid-form .span-2 { grid-column: span 2; }
  .main { padding: 20px; }
}

/* Responsive — Mobile (<=768px): sidebar yashirin, bottom tabbar */
@media (max-width: 768px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 14px 12px 88px 12px; }
  .topbar { flex-direction: column; align-items: stretch; gap: 10px; margin-bottom: 18px; }
  .topbar-actions { width: 100%; }
  .topbar-actions .select { flex: 1; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi { padding: 14px; }
  .kpi-label { font-size: 11px; }
  .card { padding: 16px; }
  .grid-form { grid-template-columns: 1fr; }
  .grid-form .span-2 { grid-column: auto; }
  .filters input[type="search"] { min-width: 100%; }
  .filters { flex-direction: column; align-items: stretch; }
  .data-table { font-size: 13px; }
  .data-table thead th, .data-table tbody td { padding: 8px 6px; }

  .mobile-tabbar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 50;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px)) 4px;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, .04);
  }
  .mtab {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px;
    padding: 8px 4px;
    text-decoration: none;
    color: var(--text-2);
    font-size: 10px;
    font-weight: 500;
    border-radius: 8px;
    transition: color .12s, background .12s;
    min-height: 48px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
  }
  .mtab .ico { font-size: 16px; line-height: 1; }
  .mtab .ico svg { width: 18px; height: 18px; stroke-width: 1.75; }
  .mtab:hover { color: var(--text); text-decoration: none; }
  .mtab.active {
    color: var(--primary);
    background: var(--primary-soft);
  }
}

/* Responsive — Small mobile (<=480px): 1 KPI per row */
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-value { font-size: clamp(1.4rem, 6vw, 1.8rem); }
}

/* Extra panel (collapsible) */
.extra-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  background: var(--bg-2);
}
.extra-panel > summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--text);
  user-select: none;
  padding: 2px 0;
  font-size: 14px;
}
.extra-panel[open] > summary { margin-bottom: 6px; }

/* Settings sub-tabs */
.subtabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.subtab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-2);
  padding: 9px 14px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  transition: all .12s;
  margin-bottom: -1px;
}
.subtab:hover { color: var(--text); }
.subtab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Wallet enable/disable list */
.wallets-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.wallet-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .12s;
}
.wallet-toggle:hover { border-color: var(--border-strong); }
.wallet-toggle input[type="checkbox"] {
  width: auto;
  margin: 0;
  cursor: pointer;
  accent-color: var(--primary);
}
.wallet-toggle.disabled { opacity: 0.5; }

/* Nav group labels */
.nav-group-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 14px 12px 6px 12px;
  margin-top: 4px;
}
.nav-group-label:first-child { margin-top: 0; padding-top: 4px; }

/* More menu (mobile overflow) */
.more-menu {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.more-menu.hidden { display: none; }
.more-menu-card {
  width: 100%;
  max-width: 600px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom, 0px)) 20px;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}
.more-menu-card h3 { margin: 0 0 16px 0; text-align: center; }
.more-close {
  position: absolute;
  top: 14px; right: 14px;
  background: transparent;
  border: none;
  color: var(--text-2);
  font-size: 26px;
  cursor: pointer;
  line-height: 1;
}
.more-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.more-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 6px;
  text-decoration: none;
  color: var(--text-2);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
  text-align: center;
  transition: all .12s;
  min-height: 70px;
}
.more-item:hover { border-color: var(--border-strong); color: var(--text); text-decoration: none; }
.more-item .ico { line-height: 1; }
.more-item .ico svg { width: 20px; height: 20px; stroke-width: 1.75; }
@media (max-width: 480px) {
  .more-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Phase 2/3: Modal overlay (consistent with existing) */
#plModal, #salModal, #dkModal, #faModal, #obModal, #whModal, #payAmountModal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  z-index: 80;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
#plModal.hidden, #salModal.hidden, #dkModal.hidden, #faModal.hidden,
#obModal.hidden, #whModal.hidden, #payAmountModal.hidden { display: none; }

/* Wider plan table needs horizontal scroll on small screens */
#plTable { min-width: 1500px; }

/* Balance widget */
.balance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.balance-item {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.balance-item .bal-label {
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 4px;
}
.balance-item .bal-value {
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
