/* ============================================================================
 * NiT Digital Hub Design System — Source of Truth
 * Dark Mode (Default): Pro Titanium & Obsidian
 * Light Mode (body.light-mode): Apple Ceramic & Alabaster
 * ========================================================================== */

:root {
  /* Brand Signature Accents */
  --nit-blue: #0088cc;
  --nit-blue-bright: #38bdf8;
  --nit-orange: #e67425;
  --nit-orange-bright: #fb923c;

  /* Surfaces & Elevation (Dark Default) */
  --bg-canvas: #08090d;
  --surface-sidebar: rgba(12, 14, 19, 0.88);
  --surface-window: rgba(15, 17, 23, 0.82);
  --surface-header: rgba(15, 17, 23, 0.65);
  --surface-card: rgba(20, 23, 31, 0.72);
  --surface-card-hover: rgba(25, 29, 39, 0.88);
  --surface-nested: rgba(10, 12, 18, 0.62);
  --surface-table: rgba(14, 16, 22, 0.72);
  --surface-input: rgba(10, 12, 17, 0.85);
  --surface-subtle: rgba(148, 163, 184, 0.08);
  --surface-modal: #12151e;

  /* Borders & Specular Micro-Lines */
  --border-subtle: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.24);
  --specular-top: rgba(255, 255, 255, 0.09);

  /* Semantic Status Colors */
  --neon-green-text: #34d399;
  --neon-green-bg: rgba(52, 211, 153, 0.12);
  --neon-green-border: rgba(52, 211, 153, 0.26);

  --neon-red-text: #fb7185;
  --neon-red-bg: rgba(251, 113, 133, 0.12);
  --neon-red-border: rgba(251, 113, 133, 0.28);

  --warn-text: #fb923c;
  --warn-bg: rgba(251, 146, 60, 0.12);
  --warn-border: rgba(251, 146, 60, 0.28);

  --frozen-text: #38bdf8;
  --frozen-bg: rgba(56, 189, 248, 0.12);
  --frozen-border: rgba(56, 189, 248, 0.28);

  --archived-text: #94a3b8;
  --archived-bg: rgba(148, 163, 184, 0.12);
  --archived-border: rgba(148, 163, 184, 0.25);

  /* Typography Colors */
  --text-heading: #ffffff;
  --text-pure: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  /* Status & Accent Token Aliases */
  --accent-primary: var(--nit-blue);
  --status-active: var(--neon-green-text);
  --status-limit: var(--warn-text);
  --status-frozen: var(--frozen-text);
  --status-archived: var(--archived-text);

  /* Typography & Radii */
  --font-sans: 'Inter', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius-shell: 18px;
  --radius-card: 14px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --shadow-shell: 0 20px 50px rgba(0, 0, 0, 0.45);
  --shadow-card: 0 6px 24px rgba(0, 0, 0, 0.24);
  --backdrop-glass: blur(40px) saturate(150%);
}

/* Light Mode — Apple Ceramic & Alabaster */
/* Light Mode — Apple Ceramic & Alabaster (High-Contrast Depth) */
body.light-mode {
  --nit-blue: #0077b5;
  --nit-blue-bright: #0284c7;
  --nit-orange: #ea580c;
  --nit-orange-bright: #ea580c;

  --bg-canvas: #e2e8f0;
  --surface-sidebar: #ffffff;
  --surface-window: #f4f6fa;
  --surface-header: rgba(255, 255, 255, 0.92);
  --surface-card: #ffffff;
  --surface-card-hover: #ffffff;
  --surface-nested: #f8fafc;
  --surface-table: #ffffff;
  --surface-input: #ffffff;
  --surface-subtle: #e9eef5;
  --surface-modal: #ffffff;

  --border-subtle: rgba(15, 23, 42, 0.12);
  --border-strong: rgba(15, 23, 42, 0.22);
  --specular-top: rgba(255, 255, 255, 1);

  --neon-green-text: #059669;
  --neon-green-bg: rgba(5, 150, 105, 0.12);
  --neon-green-border: rgba(5, 150, 105, 0.28);

  --neon-red-text: #e11d48;
  --neon-red-bg: rgba(225, 29, 72, 0.12);
  --neon-red-border: rgba(225, 29, 72, 0.28);

  --warn-text: #ea580c;
  --warn-bg: rgba(234, 88, 12, 0.12);
  --warn-border: rgba(234, 88, 12, 0.28);

  --frozen-text: #0284c7;
  --frozen-bg: rgba(2, 132, 199, 0.12);
  --frozen-border: rgba(2, 132, 199, 0.28);

  --archived-text: #475569;
  --archived-bg: rgba(71, 85, 105, 0.12);
  --archived-border: rgba(71, 85, 105, 0.24);

  --text-heading: #0f172a;
  --text-pure: #1e293b;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --shadow-shell: 0 10px 30px rgba(15, 23, 42, 0.08);
  --shadow-card: 0 3px 12px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
}


/* ============================================================================
 * Base & Ambient Obsidian / Alabaster Canvas
 * ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-sans);
  color: var(--text-pure);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body {
  position: fixed;
  inset: 0;
  padding: 12px;
  overflow: hidden;
  background-color: var(--bg-canvas);
  background-image:
    radial-gradient(circle at 8% 10%, rgba(0, 136, 204, 0.14), transparent 36%),
    radial-gradient(circle at 92% 88%, rgba(230, 116, 37, 0.11), transparent 38%);
}

body.light-mode {
  background-image:
    radial-gradient(circle at 8% 10%, rgba(0, 119, 181, 0.07), transparent 36%),
    radial-gradient(circle at 92% 88%, rgba(234, 88, 12, 0.05), transparent 38%);
}

/* Minimal 5px Custom Scrollbars */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.3);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.5);
}

.hidden { display: none !important; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-pos { color: var(--neon-green-text); font-weight: 600; }
.text-neg { color: var(--neon-red-text); font-weight: 600; }
.text-warn { color: var(--warn-text); font-weight: 600; }
.mobile-only { display: none; }

/* ============================================================================
 * PIN Auth Screen
 * ========================================================================== */

.auth-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 40;
}

.auth-card {
  width: 100%;
  max-width: 410px;
  background: var(--surface-window);
  backdrop-filter: var(--backdrop-glass);
  -webkit-backdrop-filter: var(--backdrop-glass);
  border: 1px solid var(--border-subtle);
  border-top: 1px solid var(--specular-top);
  border-radius: var(--radius-shell);
  padding: 28px;
  box-shadow: var(--shadow-shell);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}

.auth-brand h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-heading);
}

.auth-sub {
  margin: 3px 0 0;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.auth-footer {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
}

/* ============================================================================
 * Floating Desktop Shell (> 768px)
 * ========================================================================== */

.app-shell {
  width: 100%;
  height: 100%;
  display: flex;
  gap: 12px;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface-sidebar);
  backdrop-filter: var(--backdrop-glass);
  -webkit-backdrop-filter: var(--backdrop-glass);
  border: 1px solid var(--border-subtle);
  border-top: 1px solid var(--specular-top);
  border-radius: var(--radius-shell);
  box-shadow: var(--shadow-shell);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-logo {
  min-height: 84px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 11px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-logo svg {
  width: 60px;
  height: auto;
}

.brand-meta {
  min-width: 0;
}

.brand-name {
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text-heading);
  line-height: 1.25;
}

.brand-tag {
  font-size: 0.65rem;
  color: var(--nit-blue-bright);
  letter-spacing: 0.04em;
  margin-top: 3px;
}

.sidebar-nav {
  flex: 1;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.nav-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  text-align: left;
}

.nav-btn:hover {
  background: var(--surface-subtle);
  color: var(--text-pure);
}

.nav-btn.active {
  background: linear-gradient(90deg, rgba(0, 136, 204, 0.16), rgba(230, 116, 37, 0.08));
  border-color: rgba(56, 189, 248, 0.26);
  color: var(--text-heading);
  font-weight: 600;
}

.nav-btn.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 3px;
  border-radius: 0 4px 4px 0;
  background: linear-gradient(180deg, var(--nit-blue-bright), var(--nit-orange));
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-icon svg {
  width: 17px;
  height: 17px;
}

.nav-btn.active .nav-icon {
  color: var(--nit-blue-bright);
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-subtle);
}

/* Main Workspace Area */
.content-area {
  flex: 1;
  min-width: 0;
  background: var(--surface-window);
  backdrop-filter: var(--backdrop-glass);
  -webkit-backdrop-filter: var(--backdrop-glass);
  border: 1px solid var(--border-subtle);
  border-top: 1px solid var(--specular-top);
  border-radius: var(--radius-shell);
  box-shadow: var(--shadow-shell);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.workspace-header {
  min-height: 66px;
  padding: 12px 24px;
  background: var(--surface-header);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex-wrap: wrap;
}

.header-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-heading);
  white-space: nowrap;
}

.header-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.info-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  background: var(--surface-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.pill-date svg {
  color: var(--nit-orange-bright);
}

.pill-wac strong {
  color: var(--nit-blue-bright);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.main-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding: 20px 24px;
}

/* Glitch-Free Safari/WebKit Fade (NO translateY on scrollable container) */
.tab-content {
  animation: fadeIn 0.16s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ============================================================================
 * Upgraded Card Placement Grids & KPI Components
 * ========================================================================== */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

/* Row 2: P&L Performance (2fr) + Frozen Guard (1fr) */
.overview-split {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
  gap: 14px;
  align-items: stretch;
}

.pnl-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.pnl-tile {
  background: var(--surface-nested);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: border-color 0.16s ease;
}

.pnl-tile:hover {
  border-color: var(--border-strong);
}

.pnl-tile-value {
  font-size: 1.24rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-top: 8px;
  line-height: 1.2;
}

.frozen-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.frozen-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.frozen-row {
  background: var(--surface-nested);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.frozen-row-label {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.frozen-row-val {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text-heading);
}

/* Row 3: Side-by-Side Currency Bank Columns (THB Left | MMK Right) */
.banks-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.bank-column {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-top: 1px solid var(--specular-top);
  border-radius: var(--radius-card);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
}

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

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.section-gap { margin-top: 18px; }

.card, .metric-card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-top: 1px solid var(--specular-top);
  border-radius: var(--radius-card);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
}

.metric-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.metric-card:hover {
  transform: translateY(-2px);
  border-color: rgba(56, 189, 248, 0.42);
  background: var(--surface-card-hover);
}

.metric-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.metric-label {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

.metric-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.metric-icon svg { width: 15px; height: 15px; }
.icon-blue { background: var(--frozen-bg); color: var(--nit-blue-bright); border: 1px solid var(--frozen-border); }
.icon-green { background: var(--neon-green-bg); color: var(--neon-green-text); border: 1px solid var(--neon-green-border); }
.icon-orange { background: var(--warn-bg); color: var(--nit-orange-bright); border: 1px solid var(--warn-border); }
.icon-red { background: var(--neon-red-bg); color: var(--neon-red-text); border: 1px solid var(--neon-red-border); }

.metric-value {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.035em;
  color: var(--text-heading);
  font-variant-numeric: tabular-nums;
  margin-top: 10px;
  line-height: 1.2;
}

.metric-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 6px;
}

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

.card-title, .section-title {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text-heading);
}

/* Bank Cards */
.bank-card {
  background: var(--surface-nested);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.bank-card.standalone {
  background: var(--surface-card);
  border-top: 1px solid var(--specular-top);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.bank-card:hover {
  border-color: rgba(56, 189, 248, 0.35);
}

.bank-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.bank-balance {
  font-size: 1.22rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-heading);
}

.progress-track {
  width: 100%;
  height: 6px;
  background: var(--surface-subtle);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--nit-blue), var(--nit-blue-bright));
  border-radius: 999px;
  transition: width 0.25s ease;
}

.progress-fill.warn { background: var(--nit-orange-bright); }
.progress-fill.full { background: var(--neon-red-text); }

/* ============================================================================
 * Badges & Pills
 * ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.69rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-dot::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.badge-ACTIVE {
  background: var(--neon-green-bg);
  color: var(--neon-green-text);
  border-color: var(--neon-green-border);
}

.badge-LIMIT_REACHED {
  background: var(--warn-bg);
  color: var(--warn-text);
  border-color: var(--warn-border);
}

.badge-FROZEN {
  background: var(--frozen-bg);
  color: var(--frozen-text);
  border-color: var(--frozen-border);
}

.badge-ARCHIVED {
  background: var(--archived-bg);
  color: var(--archived-text);
  border-color: var(--archived-border);
}

.badge-custody {
  background: var(--surface-subtle);
  color: var(--text-pure);
  border-color: var(--border-subtle);
}
.badge-custody::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--nit-orange-bright);
}

.fee-pill {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--neon-red-bg);
  color: var(--neon-red-text);
  border: 1px solid var(--neon-red-border);
}

/* ============================================================================
 * Forms, Inputs & Buttons (Including Theme Toggle Pill)
 * ========================================================================== */

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.field input,
.field select,
.field textarea,
.filter-input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface-input);
  color: var(--text-pure);
  font-family: inherit;
  font-size: 0.84rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field select option {
  background: var(--surface-modal);
  color: var(--text-pure);
}

.field input:focus,
.field select:focus,
.filter-input:focus {
  outline: none;
  border-color: var(--nit-blue-bright);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.16);
}

.filter-input {
  width: auto;
  min-width: 130px;
  padding: 6px 10px;
  font-size: 0.78rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--surface-subtle);
  color: var(--text-pure);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--border-strong);
  background: rgba(148, 163, 184, 0.16);
}

.btn-primary {
  background: var(--nit-blue);
  border-color: var(--nit-blue);
  color: #ffffff;
}
.btn-primary:hover {
  background: var(--nit-blue-bright);
  border-color: var(--nit-blue-bright);
  color: #08090d;
}

.btn-buy {
  background: rgba(52, 211, 153, 0.16);
  border-color: var(--neon-green-border);
  color: var(--neon-green-text);
}
.btn-buy:hover {
  background: rgba(52, 211, 153, 0.25);
}

.btn-orange {
  background: var(--nit-orange);
  border-color: var(--nit-orange);
  color: #ffffff;
}
.btn-orange:hover {
  opacity: 0.92;
}

.btn-danger {
  background: var(--neon-red-bg);
  border-color: var(--neon-red-border);
  color: var(--neon-red-text);
}
.btn-danger:hover {
  background: rgba(251, 113, 133, 0.22);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-subtle);
  color: var(--text-secondary);
}
.btn-ghost:hover {
  color: var(--text-pure);
  background: var(--surface-subtle);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.74rem;
}

.btn-block {
  width: 100%;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--surface-subtle);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.icon-btn:hover {
  color: var(--text-pure);
  border-color: var(--border-strong);
}

.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.73rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.theme-toggle-btn:hover {
  color: var(--text-pure);
  border-color: var(--nit-blue-bright);
  background: rgba(56, 189, 248, 0.1);
}
.theme-toggle-btn svg {
  width: 14px;
  height: 14px;
  color: var(--nit-orange-bright);
}

.preview-box {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.preview-box strong {
  color: var(--text-heading);
  margin-left: 4px;
}

.alert {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
}

.alert-warn {
  background: var(--warn-bg);
  color: var(--warn-text);
  border: 1px solid var(--warn-border);
}

/* ============================================================================
 * Data Tables (Sticky Header, Zero Row Transform for Safari Stability)
 * ========================================================================== */

.table-container {
  background: var(--surface-table);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  max-height: 460px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-modal);
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
  white-space: nowrap;
}

.data-table td {
  padding: 10px 12px;
  font-size: 0.82rem;
  letter-spacing: -0.011em;
  color: var(--text-pure);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

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

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

/* ============================================================================
 * Modals & Toast
 * ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-content {
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface-modal);
  border: 1px solid var(--border-strong);
  border-top: 1px solid var(--specular-top);
  border-radius: var(--radius-shell);
  padding: 22px 24px;
  box-shadow: var(--shadow-shell);
}

.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  max-width: 380px;
  background: var(--surface-modal);
  color: var(--text-heading);
  border: 1px solid var(--neon-green-border);
  border-left: 3px solid var(--neon-green-text);
  padding: 11px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-shell);
  font-size: 0.82rem;
  font-weight: 500;
  z-index: 120;
}

.toast.error {
  border-color: var(--neon-red-border);
  border-left-color: var(--neon-red-text);
}

.flex-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.space-between {
  justify-content: space-between;
}

.empty-state {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* ============================================================================
 * Responsive Breakpoints
 * ========================================================================== */

@media (max-width: 1200px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .overview-split {
    grid-template-columns: 1fr;
  }
  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1024px) {
  .banks-split,
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  body {
    padding: 0;
  }

  .desktop-only { display: none !important; }
  .mobile-only { display: inline-flex; }

  .app-shell {
    flex-direction: column;
    gap: 0;
  }

  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 64px;
    border-radius: 18px 18px 0 0;
    border-bottom: none;
    z-index: 90;
    flex-direction: row;
  }

  .sidebar-logo,
  .sidebar-footer {
    display: none;
  }

  .sidebar-nav {
    flex-direction: row;
    padding: 6px;
    gap: 2px;
    justify-content: space-around;
    align-items: center;
    overflow: hidden;
  }

  .nav-btn {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: 6px 4px;
    font-size: 0.65rem;
    text-align: center;
  }

  .nav-btn.active::before {
    left: 25%;
    right: 25%;
    top: 0;
    bottom: auto;
    width: auto;
    height: 2.5px;
    border-radius: 0 0 4px 4px;
  }

  .content-area {
    border-radius: 0;
    border: none;
    height: calc(100vh - 64px);
    height: calc(100dvh - 64px);
  }

  .workspace-header {
    padding: 10px 14px;
    min-height: 58px;
  }

  .main-content {
    padding: 14px;
  }

  .metric-value {
    font-size: 1.18rem;
  }

  .pnl-strip {
    grid-template-columns: 1fr;
  }

  .theme-toggle-btn .theme-label {
    display: none;
  }
  .theme-toggle-btn {
    padding: 0 9px;
  }

  .grid-3 {
    grid-template-columns: 1fr;
  }

  .toast {
    bottom: 76px;
    left: 14px;
    right: 14px;
    max-width: none;
  }
}

@media (max-width: 420px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}
/* ============================================================================
 * Clean Layout Additions (3-Col KPI, Sub-Tabs, Compact P&L & Frozen Banner)
 * ========================================================================== */

.kpi-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.today-pnl-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.frozen-banner {
  background: var(--frozen-bg);
  border: 1px solid var(--frozen-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.sub-tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  background: var(--surface-nested);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.sub-tab-btn {
  padding: 7px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.sub-tab-btn:hover {
  color: var(--text-pure);
}

.sub-tab-btn.active {
  background: var(--nit-blue);
  color: #ffffff;
}

@media (max-width: 900px) {
  .kpi-grid-3 {
    grid-template-columns: 1fr;
  }
}
/* Mobile-only brand logo visibility fix */
.mobile-only {
  display: none !important;
}

@media (max-width: 768px) {
  .mobile-only {
    display: inline-flex !important;
  }

  .mobile-brand-logo {
    display: block !important;
    flex-shrink: 0;
  }
}

/* ============================================================================
 * Mobile UX Polish (Safe-Area, No-Zoom Inputs, Touch Targets)
 * ========================================================================== */

@media (max-width: 768px) {
  .sidebar {
    height: calc(64px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .content-area {
    height: calc(100dvh - 64px - env(safe-area-inset-bottom, 0px));
  }

  .workspace-header {
    padding: 10px 12px;
    gap: 8px;
  }

  .header-left {
    gap: 8px;
  }

  .header-title {
    font-size: 0.96rem;
  }

  .main-content {
    padding: 12px 12px 24px;
  }

  .card,
  .metric-card,
  .bank-column {
    padding: 14px;
  }

  /* Prevent iOS Safari auto-zoom when focusing inputs */
  .field input,
  .field select,
  .field textarea,
  .filter-input {
    font-size: 16px;
    padding: 10px 12px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  /* Full-width touch-friendly sub-tabs */
  .sub-tabs {
    display: flex;
    width: 100%;
  }

  .sub-tab-btn {
    flex: 1;
    text-align: center;
    padding: 9px 8px;
    font-size: 0.78rem;
  }

  /* Stack filter bar cleanly on mobile */
  .filter-bar {
    width: 100%;
  }

  .filter-bar .filter-input {
    flex: 1 1 100%;
    min-width: 0;
  }

  .filter-bar .btn {
    width: 100%;
    padding: 10px;
  }

  .mobile-full-btn {
    width: 100%;
    padding: 11px 14px;
    font-size: 0.88rem;
  }

  .preview-box {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .today-pnl-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .bank-actions .btn {
    flex: 1 1 auto;
  }

  .modal-content {
    padding: 18px 16px;
    max-height: 86dvh;
  }

  .nav-btn .nav-label {
    font-size: 0.62rem;
    white-space: nowrap;
  }
}
/* Fix mobile bottom-nav overlap on scrollable forms and lists */
@media (max-width: 768px) {
  .content-area {
    height: 100%;
    min-height: 0;
  }

  .main-content {
    padding: 12px 12px calc(104px + env(safe-area-inset-bottom, 0px));
    -webkit-overflow-scrolling: touch;
  }
}
/* Fix iOS Safari datetime-local / date input overflow & alignment */
.field {
  min-width: 0;
}

@media (max-width: 768px) {
  .field input[type="datetime-local"],
  .field input[type="date"],
  .filter-bar input[type="date"] {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 42px;
    -webkit-appearance: none;
    appearance: none;
    text-align: left;
  }

  .field input[type="datetime-local"]::-webkit-date-and-time-value,
  .field input[type="date"]::-webkit-date-and-time-value {
    text-align: left;
  }
}
