/* ============================================================
   VERIDIAN — Quiet-Capital Finance · Ledger AI workspace skin
   ------------------------------------------------------------
   Loaded AFTER styles.css + ledger.css, so equal-specificity
   rules win by cascade order. Everything is scoped under
   #ledger-workspace (or body:has the ledger workspace) so the
   shared stylesheet — and the Relate workspace — are untouched.

   Contract preserved: every element ID, the JS display-toggle of
   #ledgerAuthGate / #ledgerOnboarding / #ledgerDashboard, the
   inline #ledger-workspace[style="display: grid"], onboarding
   .is-active/.is-done/.is-locked, and all global functions
   (refreshLedgerWorkspace, showLedgerSetup, clearLedgerCache) are
   left exactly as ledger.js expects. ledger.js is NOT touched.
   ============================================================ */

/* ---- Veridian tokens + retoken shared surfaces (scoped only) ---- */
#ledger-workspace {
  /* identity developed into a flowing gradient (jade → teal → cyan) */
  --accent: #2be8a5;          /* jade — brand anchor */
  --accent-2: #18c9c2;        /* teal                */
  --accent-3: #4de3ff;        /* cyan tail           */
  --accent-strong: #16b98a;
  --accent-ink: #04130d;
  --accent-soft: rgba(43, 232, 165, 0.12);
  --accent-line: rgba(43, 232, 165, 0.30);

  /* numbers & labels become a precise grotesque (ledger.css uses --mono) */
  --mono: "Space Grotesk", ui-monospace, "SF Mono", monospace;

  /* ink-teal "vault" surfaces */
  --panel: rgba(12, 28, 23, 0.55);
  --panel-soft: rgba(16, 34, 28, 0.42);
  --bg-elev: rgba(10, 22, 18, 0.5);
  --surface-glass: rgba(8, 18, 14, 0.62);
  --border: rgba(43, 232, 165, 0.14);
  --border-strong: rgba(43, 232, 165, 0.28);
  --text: #eaf6f1;
  --muted: #9fb9af;

  /* Veridian helpers */
  --v-faint: #6a8278;
  --v-platinum: #cdefe0;
  --v-glass: rgba(12, 28, 23, 0.55);
  --v-glass-2: rgba(16, 34, 28, 0.42);
  --v-hairline: rgba(43, 232, 165, 0.14);
  --v-hairline-2: rgba(255, 255, 255, 0.06);
  --v-inner: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  --v-income: #34e1ad;
  --v-expense: #ff9e8a;
  --v-radius: 18px;
  --v-radius-sm: 12px;
  --v-dur-micro: 180ms;
  --v-dur: 240ms;
  --v-enter: 320ms;
  --v-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --v-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --rail-w: 84px;

  position: relative;
  z-index: 1;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---- Page canvas: ink-teal vault + Capital Tide glow ---- */
body:has(#ledger-workspace[style*="display: grid"]) {
  background:
    radial-gradient(1000px 520px at 30% 118%, rgba(43, 232, 165, 0.07), transparent 64%),
    radial-gradient(900px 520px at 80% 122%, rgba(77, 227, 255, 0.05), transparent 62%),
    #06100d;
}
.ledger-tide {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 40vh;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(60% 100% at 30% 125%, rgba(43, 232, 165, 0.1), transparent 70%),
    radial-gradient(55% 100% at 78% 128%, rgba(77, 227, 255, 0.07), transparent 68%);
  filter: blur(16px);
  animation: v-tide 8s var(--v-ease) infinite alternate;
}
@keyframes v-tide {
  0%   { opacity: 0.7; transform: translateY(6px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   RAIL — section quick-nav (anchors; safe, additive)
   ============================================================ */
.ledger-rail {
  grid-column: 1;
  grid-row: 1 / -1;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 0 18px;
  background: linear-gradient(180deg, rgba(10, 24, 20, 0.85), rgba(6, 16, 13, 0.65));
  backdrop-filter: blur(18px) saturate(140%);
  border-right: 1px solid var(--v-hairline);
}
.ledger-rail-brand {
  width: 38px; height: 38px;
  border-radius: 12px;
  display: grid; place-items: center;
  margin-bottom: 14px;
  background: transparent;
  box-shadow: 0 10px 24px -10px rgba(43, 232, 165, 0.45);
  text-decoration: none;
  overflow: hidden;
  flex-shrink: 0;
}
.ledger-rail-brand-icon {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}
.ledger-rail .rail-item {
  position: relative;
  width: 64px; min-height: 56px;
  padding: 9px 4px 7px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  border: 1px solid transparent; border-radius: 14px;
  background: transparent; color: var(--muted);
  text-decoration: none; cursor: pointer;
  transition: color var(--v-dur-micro) var(--v-ease),
              background var(--v-dur-micro) var(--v-ease),
              border-color var(--v-dur-micro) var(--v-ease),
              transform var(--v-dur-micro) var(--v-spring);
}
.ledger-rail .rail-item svg { width: 21px; height: 21px; }
.ledger-rail .rail-item .lbl {
  font-size: 10px;
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  max-width: 58px;
  white-space: normal;
}
.ledger-rail .rail-item:hover { color: var(--text); background: rgba(43, 232, 165, 0.1); }
.ledger-rail .rail-item:active { transform: scale(0.94); }
.ledger-rail .rail-item.active {
  color: var(--text);
  background: var(--v-glass);
  border-color: var(--v-hairline);
  box-shadow: var(--v-inner), 0 8px 20px -12px rgba(43, 232, 165, 0.7);
}
.ledger-rail .rail-item.active svg { color: var(--accent); }
.ledger-rail-spacer { flex: 1; }

/* ============================================================
   CONTEXT BAR  (.ws-header, slimmed glass)
   ============================================================ */
#ledger-workspace .ws-header {
  grid-column: 2;
  grid-row: 1;
  min-height: 60px;
  padding: 0 28px;
  gap: 14px;
  background: linear-gradient(180deg, rgba(10, 24, 20, 0.82), rgba(6, 16, 13, 0.45));
  backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--v-hairline-2);
  box-shadow: none;
}
#ledger-workspace .ws-breadcrumb .sep { color: var(--v-faint); }
#ledger-workspace .lang-toggle {
  display: flex; gap: 2px; padding: 3px;
  border: 1px solid var(--v-hairline); border-radius: 9px; background: var(--v-glass-2);
}
#ledger-workspace .lang-toggle button {
  border: 0; background: transparent; color: var(--v-faint);
  font-size: 11.5px; font-weight: 600; padding: 4px 10px; border-radius: 6px; cursor: pointer; box-shadow: none;
  transition: color var(--v-dur-micro) var(--v-ease), background var(--v-dur-micro) var(--v-ease);
}
#ledger-workspace .lang-toggle button:hover { color: var(--text); filter: none; }
#ledger-workspace .lang-toggle button.active,
#ledger-workspace .lang-toggle button[aria-pressed="true"] { background: rgba(43, 232, 165, 0.16); color: var(--text); }
#ledger-workspace .ws-account-btn {
  border: 1px solid var(--v-hairline);
  background: var(--v-glass-2);
  color: var(--muted);
  border-radius: 10px;
  transition: border-color var(--v-dur) var(--v-ease), color var(--v-dur) var(--v-ease);
}
#ledger-workspace .ws-account-btn:hover { border-color: var(--border-strong); color: var(--text); filter: none; }

/* ============================================================
   STAGE  (.ledger-workspace-body)
   ============================================================ */
#ledger-workspace .ledger-workspace-body {
  grid-column: 2;
  grid-row: 2;
  max-width: 1160px;
  padding: 36px clamp(24px, 4vw, 52px) 90px;
}

/* Typography — Space Grotesk display + tabular numerals everywhere money lives */
#ledger-workspace .ledger-hero-copy h2,
#ledger-workspace .ledger-dash-head h3,
#ledger-workspace .ledger-collapsible-head h3,
#ledger-workspace .ledger-step h3,
#ledger-workspace .ledger-login-card h3,
#ledger-workspace .ledger-transaction-head h4,
#ledger-workspace .ledger-aging-head h4 {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  letter-spacing: -0.015em;
}
#ledger-workspace .ledger-dash-card .value,
#ledger-workspace .ledger-txn-amount,
#ledger-workspace .ledger-aging-bucket-amount,
#ledger-workspace .ledger-aging-item-amount,
#ledger-workspace .ledger-fin-table td {
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   GLASS SURFACES — cards, collapsibles, panels, login, steps
   ============================================================ */
#ledger-workspace .ledger-dash-card,
#ledger-workspace .ledger-step,
#ledger-workspace .ledger-login-card,
#ledger-workspace .ledger-collapsible-section,
#ledger-workspace .ledger-transaction-panel,
#ledger-workspace .ledger-aging-panel,
#ledger-workspace .ledger-monthly-report,
#ledger-workspace .ledger-empty-banner,
#ledger-workspace .ledger-report-bar,
#ledger-workspace .ledger-reset-panel,
#ledger-workspace .ledger-invoice-running-panel {
  border: 1px solid var(--v-hairline);
  border-radius: var(--v-radius);
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(43, 232, 165, 0.05), transparent 55%),
    var(--v-glass);
  backdrop-filter: blur(18px);
  box-shadow: var(--v-inner), 0 24px 50px -42px rgba(0, 0, 0, 0.9);
}

#ledger-workspace .ledger-tax-panel {
  border: 1px solid var(--v-hairline);
  border-radius: var(--v-radius);
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(77, 227, 255, 0.06), transparent 55%),
    var(--v-glass);
  backdrop-filter: blur(18px);
  box-shadow: var(--v-inner), 0 24px 50px -42px rgba(0, 0, 0, 0.9);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#ledger-workspace .ledger-tax-settings-block,
#ledger-workspace .ledger-tax-report-block {
  border: 1px solid var(--v-hairline);
  border-radius: var(--v-radius);
  background: rgba(8, 18, 14, 0.35);
}

#ledger-workspace .ledger-tax-settings-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#ledger-workspace .ledger-tax-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px 16px;
}

#ledger-workspace .ledger-tax-check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}

#ledger-workspace .ledger-tax-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

#ledger-workspace .ledger-tax-rate-field input {
  max-width: 120px;
}

#ledger-workspace .ledger-tax-report-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 14px;
}

#ledger-workspace .ledger-tax-custom-range {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

#ledger-workspace .ledger-tax-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

#ledger-workspace .ledger-tax-kpi {
  border: 1px solid var(--v-hairline);
  border-radius: 12px;
  padding: 12px 14px;
  background: rgba(43, 232, 165, 0.04);
}

#ledger-workspace .ledger-tax-kpi .label {
  font-size: 11px;
  color: var(--v-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

#ledger-workspace .ledger-tax-kpi .value {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-top: 4px;
  font-family: var(--mono, monospace);
}

#ledger-workspace .ledger-tax-warning {
  color: #f3c969;
  font-size: 13px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(243, 201, 105, 0.35);
  background: rgba(243, 201, 105, 0.08);
}

#ledger-workspace .ledger-tax-table-wrap {
  margin-bottom: 16px;
  overflow-x: auto;
}

#ledger-workspace .ledger-tax-table-wrap h5 {
  font-size: 13px;
  margin: 0 0 8px;
  color: var(--v-faint);
}

#ledger-workspace .ledger-tax-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

#ledger-workspace .ledger-tax-table th,
#ledger-workspace .ledger-tax-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--v-hairline);
  text-align: left;
}

#ledger-workspace .ledger-tax-table th {
  color: var(--v-faint);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

#ledger-workspace .ledger-tax-table td:last-child,
#ledger-workspace .ledger-tax-table th:last-child {
  text-align: right;
}

#ledger-workspace .ledger-tax-error {
  color: #ff9e8a;
  font-size: 13px;
  margin-top: 8px;
}

#ledger-workspace .ledger-tax-inline-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0 0 0 6px;
  text-decoration: underline;
}

#ledger-workspace .ledger-tax-disclaimer {
  font-size: 12px;
  margin-top: 10px;
}

#ledger-workspace .ledger-dash-card .ledger-tax-supplement {
  margin-top: 8px;
  font-size: 11px;
  color: var(--v-faint);
  line-height: 1.45;
}

#ledger-workspace .ledger-dash-card .ledger-tax-supplement strong {
  color: var(--text);
  font-weight: 600;
}

/* dash KPI cards — keep the jade top-rail, add premium hover glow + entrance */
#ledger-workspace .ledger-dash-card { animation: v-rise var(--v-enter) var(--v-ease) both; }
#ledger-workspace .ledger-dash-card::before {
  background: linear-gradient(90deg, var(--accent), var(--accent-3) 75%, transparent);
  opacity: 0.85; height: 2px;
}
#ledger-workspace .ledger-dash-card:hover {
  transform: translateY(-3px);
  border-color: rgba(43, 232, 165, 0.34);
  box-shadow: 0 26px 50px -30px rgba(43, 232, 165, 0.5);
}
#ledger-workspace .ledger-dash-card .value { font-size: 27px; }
#ledger-workspace .ledger-dash-card .label { color: var(--v-faint); }
/* staggered entrance for the KPI grid */
#ledger-workspace .ledger-dashboard-grid .ledger-dash-card:nth-child(1) { animation-delay: 0ms; }
#ledger-workspace .ledger-dashboard-grid .ledger-dash-card:nth-child(2) { animation-delay: 45ms; }
#ledger-workspace .ledger-dashboard-grid .ledger-dash-card:nth-child(3) { animation-delay: 90ms; }
#ledger-workspace .ledger-dashboard-grid .ledger-dash-card:nth-child(4) { animation-delay: 135ms; }
#ledger-workspace .ledger-dashboard-grid .ledger-dash-card:nth-child(5) { animation-delay: 180ms; }
#ledger-workspace .ledger-dashboard-grid .ledger-dash-card:nth-child(6) { animation-delay: 225ms; }
@keyframes v-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* collapsible summaries — glassy, premium hover */
#ledger-workspace .ledger-collapsible-summary { transition: background var(--v-dur) var(--v-ease); border-radius: var(--v-radius); }
#ledger-workspace .ledger-collapsible-summary:hover { background: rgba(43, 232, 165, 0.05); }
#ledger-workspace .ledger-collapsible-head h3 { font-size: 16px; }

/* transaction rows — income jade, expense coral */
#ledger-workspace .ledger-txn-item { transition: background var(--v-dur) var(--v-ease); }
#ledger-workspace .ledger-txn-item:hover { background: rgba(43, 232, 165, 0.05); }
#ledger-workspace .ledger-txn-item.income .ledger-txn-amount { color: var(--v-income); }
#ledger-workspace .ledger-txn-item.expense .ledger-txn-amount { color: var(--v-expense); }

/* onboarding steps keep their is-active emerald glow but on glass */
#ledger-workspace .ledger-step.is-active {
  border-color: rgba(43, 232, 165, 0.5);
  box-shadow: 0 0 0 1px rgba(43, 232, 165, 0.12), 0 16px 34px -20px rgba(43, 232, 165, 0.5), var(--v-inner);
}

/* ============================================================
   INPUTS + BUTTONS
   ============================================================ */
#ledger-workspace input[type="text"],
#ledger-workspace input[type="email"],
#ledger-workspace input[type="password"],
#ledger-workspace input[type="tel"],
#ledger-workspace input[type="number"],
#ledger-workspace select,
#ledger-workspace textarea {
  background: var(--v-glass-2);
  border: 1px solid var(--v-hairline);
  border-radius: var(--v-radius-sm);
  color: var(--text);
  transition: border-color var(--v-dur) var(--v-ease), box-shadow var(--v-dur) var(--v-ease);
}
#ledger-workspace input::placeholder,
#ledger-workspace textarea::placeholder { color: var(--v-faint); }
#ledger-workspace input:focus,
#ledger-workspace select:focus,
#ledger-workspace textarea:focus {
  outline: none;
  border-color: rgba(43, 232, 165, 0.45);
  box-shadow: 0 0 0 4px rgba(43, 232, 165, 0.1);
}

/* primary CTA → signature jade→cyan gradient */
#ledger-workspace .ledger-workspace-body .cta-primary,
#ledger-workspace .ledger-actions .cta-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  color: var(--accent-ink);
  border: 0;
  border-radius: 11px;
  font-weight: 600;
  box-shadow: 0 14px 30px -18px rgba(43, 232, 165, 0.85);
  transition: transform var(--v-dur-micro) var(--v-spring), filter var(--v-dur-micro) var(--v-ease);
}
#ledger-workspace .ledger-workspace-body .cta-primary:hover { filter: brightness(1.07); transform: translateY(-1px); }
#ledger-workspace .ledger-workspace-body .cta-primary:active { transform: scale(0.97); }
#ledger-workspace .cta-secondary {
  border: 1px solid var(--v-hairline);
  background: var(--v-glass-2);
  color: var(--text);
  border-radius: 11px;
  transition: border-color var(--v-dur) var(--v-ease), transform var(--v-dur-micro) var(--v-spring);
}
#ledger-workspace .cta-secondary:hover { border-color: var(--border-strong); filter: none; transform: translateY(-1px); }

/* ============================================================
   PAGED WORKSPACE — one focused page per rail item
   ------------------------------------------------------------
   The old dashboard was one tall scroll of every section. The rail
   now switches dash.dataset.view and we show ONLY that page's
   sections — bounded scroll, calm, "one intent per screen".
   CSS-only: the :not([style*="none"]) guard keeps ledger.js's
   display-toggle of #ledgerDashboard working; we never force-show
   a section ledger.js means to hide (we only hide off-page ones).
   ============================================================ */

/* Drop the marketing hero once inside the live dashboard */
.ledger-workspace-body:has(#ledgerDashboard:not([style*="none"])) .ledger-hero-copy {
  display: none;
}
/* Focused, centered reading width per page */
#ledger-workspace .ledger-workspace-body:has(#ledgerDashboard:not([style*="none"])) {
  max-width: 1080px;
}

/* Each page is a calm single column with generous rhythm */
#ledgerDashboard:not([style*="none"]) {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  animation: v-page-in var(--v-enter) var(--v-ease) both;
}
@keyframes v-page-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---- Per-view visibility: hide every direct child not in the page ---- */
#ledgerDashboard[data-view="ringkasan"] > :not(.ledger-dash-head):not(#ledgerEmptyBanner):not(#ledgerDashboardGrid):not(#ledgerChartsSection):not(#ledgerTransactionPanel):not(#ledgerAgingPanel):not(#ledgerPayableAgingPanel):not(.ledger-summary-text) { display: none !important; }
#ledgerDashboard[data-view="mutasi"]    > :not(#ledgerBankStatementSection) { display: none !important; }
#ledgerDashboard[data-view="kasir"]     > :not(#ledgerKasirSection) { display: none !important; }
#ledgerDashboard[data-view="stok"]      > :not(#ledgerInventorySection) { display: none !important; }
#ledgerDashboard[data-view="laporan"]   > :not(.ledger-report-bar):not(#ledgerBalanceSheetSection):not(#ledgerCashFlowSection):not(.ledger-report-columns) { display: none !important; }
#ledgerDashboard[data-view="pajak"]     > :not(#ledgerTaxSection) { display: none !important; }
#ledgerDashboard[data-view="pola"]      > :not(#ledgerBusinessInsightSection):not(#ledgerHealthExplainSection):not(#ledgerCapitalReadinessSection) { display: none !important; }
#ledgerDashboard[data-view="invoice"]   > :not(#ledgerInvoiceRunningSection) { display: none !important; }
#ledgerDashboard[data-view="cofounder"] > :not(#ledgerCoFounderSection) { display: none !important; }
#ledgerDashboard[data-view="asisten"]   > :not(#ledgerAssistantSection) { display: none !important; }
#ledgerDashboard[data-view="setelan"]   > :not(.ledger-actions):not(#ledgerResetPanel) { display: none !important; }

/* ---- Page header: quiet editorial eyebrow ----
   Scoped to the dashboard's TOP header only (direct child). The
   Monthly-Report / Business-Overview sections also use .ledger-dash-head
   for their real titles, so they must keep ledger.css's 22px heading. */
#ledgerDashboard > .ledger-dash-head {
  padding: 4px 2px 16px;
  border-bottom: 1px solid var(--v-hairline);
}
#ledgerDashboard > .ledger-dash-head h3 {
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--v-faint);
  font-family: "Inter", sans-serif;
  font-weight: 600;
}
/* Report/overview section titles: proper Space Grotesk headings */
#ledger-workspace .ledger-monthly-report > .ledger-dash-head h3 {
  font-family: "Space Grotesk", sans-serif;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text);
}
/* Standalone report cards (Monthly Report + Business Overview) became glass
   cards but kept ledger.css's bare padding-top:8px — give them real internal
   padding so content doesn't hug the border. Collapsibles excluded (they pad
   via .ledger-collapsible-summary/-body). */
#ledger-workspace .ledger-monthly-report:not(.ledger-collapsible-section) {
  padding: 24px 26px;
  border-top: 1px solid var(--v-hairline);
}
#ledger-workspace .ledger-monthly-report:not(.ledger-collapsible-section) > .ledger-dash-head { margin-bottom: 6px; }
/* breathing room between the stacked report sub-cards + their rows */
#ledger-workspace .ledger-monthly-section { padding: 18px 20px; }
#ledger-workspace .ledger-monthly-rows { gap: 4px 0; }
#ledger-workspace .ledger-monthly-rows dd { margin-bottom: 12px; }
#ledger-workspace .ledger-monthly-rows dd:last-child { margin-bottom: 0; }

/* ---- Ringkasan KPI band: four equal executive metrics ---- */
#ledger-workspace .ledger-dashboard-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 0;
}
#ledger-workspace .ledger-dashboard-grid .ledger-dash-card:first-child {
  grid-column: auto;
  padding: 20px;
  background:
    radial-gradient(120% 160% at 0% 0%, rgba(43, 232, 165, 0.12), transparent 55%),
    radial-gradient(120% 160% at 100% 0%, rgba(77, 227, 255, 0.08), transparent 52%),
    var(--v-glass);
}
#ledger-workspace .ledger-dashboard-grid .ledger-dash-card:first-child .value {
  font-size: clamp(22px, 2.1vw, 31px);
  letter-spacing: -0.02em;
  background: linear-gradient(110deg, var(--accent), var(--accent-3));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
@media (max-width: 1100px) {
  #ledger-workspace .ledger-dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  #ledger-workspace .ledger-dashboard-grid .ledger-dash-card:first-child { grid-column: 1 / -1; }
  #ledger-workspace .ledger-dashboard-grid { grid-template-columns: 1fr; }
}

/* ---- Finance-terminal modules: left accent + editorial header ---- */
#ledger-workspace .ledger-collapsible-section {
  position: relative;
  overflow: hidden;
  margin: 0;
}
#ledger-workspace .ledger-collapsible-section::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), var(--accent-3) 60%, transparent);
  opacity: 0.8;
}
#ledger-workspace .ledger-collapsible-summary { padding: 20px 22px; }
#ledger-workspace .ledger-collapsible-head h3 { font-size: 16px; }
#ledger-workspace .ledger-collapsible-head p { color: var(--v-faint); }

#ledger-workspace .ledger-report-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
}

/* ============================================================
   RESPONSIVE — rail collapses to a horizontal top strip
   ============================================================ */
@media (max-width: 980px) {
  .ledger-tide { height: 32vh; }
  #ledger-workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto 1fr;
    overflow-x: clip;
  }
  .ledger-rail {
    grid-column: 1; grid-row: 1;
    position: sticky; top: 0;
    height: auto;
    flex-direction: row; justify-content: flex-start;
    gap: 6px; padding: 8px 14px;
    overflow-x: auto; scrollbar-width: none;
    border-right: 0; border-bottom: 1px solid var(--v-hairline);
  }
  .ledger-rail::-webkit-scrollbar { display: none; }
  .ledger-rail-brand { margin-bottom: 0; flex: none; }
  .ledger-rail .rail-item { flex: 0 0 auto; min-height: 48px; width: 60px; }
  #ledger-workspace .ws-header { grid-column: 1; grid-row: 2; min-width: 0; }
  #ledger-workspace .ledger-workspace-body { grid-column: 1; grid-row: 3; min-width: 0; padding: 24px 16px 70px; }
}

/* ---- Charts panel (Ringkasan center) ---- */
#ledger-workspace .ledger-charts-panel--ringkasan {
  margin: 28px 0 26px;
}
#ledger-workspace .ledger-charts-panel--ringkasan .ledger-collapsible-details {
  background: var(--v-glass);
  border-color: var(--v-hairline);
  box-shadow: var(--v-inner);
}
#ledger-workspace .ledger-cofounder-sidebar,
#ledger-workspace .ledger-cofounder-main {
  background: var(--v-glass);
  border-color: var(--v-hairline);
  box-shadow: var(--v-inner);
}
#ledger-workspace .ledger-cofounder-bubble--user {
  background: rgba(43, 232, 165, 0.12);
  border-color: rgba(43, 232, 165, 0.24);
}
#ledger-workspace .ledger-cofounder-thread-item.is-active {
  border-color: rgba(43, 232, 165, 0.45);
}

#ledger-workspace .ledger-charts-panel--ringkasan .ledger-collapsible-head h3 {
  font-family: "Space Grotesk", sans-serif;
  font-size: 16px;
  letter-spacing: -0.01em;
}

#ledger-workspace .ledger-chart-card {
  background: var(--v-glass);
  border-color: var(--v-hairline);
  box-shadow: var(--v-inner);
}
#ledger-workspace .ledger-chart-head h4 {
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
}
#ledger-workspace .ledger-chart-canvas svg path[stroke] {
  filter: drop-shadow(0 0 6px rgba(43, 232, 165, 0.08));
}
#ledger-workspace .ledger-charts-panel .ledger-collapsible-badge {
  font-family: var(--mono);
  color: var(--v-platinum);
}

/* ============================================================
   MOBILE POLISH — phone-first refinements
   ------------------------------------------------------------
   Most Ledger users open the workspace on a phone. These rules
   fix the cramped, truncated reads seen on small screens. All
   scoped to #ledger-workspace so desktop + the Relate workspace
   are untouched; loaded last so equal-specificity rules win.
   ============================================================ */
@media (max-width: 640px) {
  /* --- 1. Collapsible section headers ---------------------------------
     On phones the status badge (e.g. "30 · Data belum cukup", nowrap) and
     the chevron squeezed the title/description into a ~140px column, so
     every few words wrapped onto their own line — a tall, unreadable ribbon.
     Switch the summary to a 2-row grid: title/description fill the top row
     beside the chevron; the badge drops to its own row at natural width. */
  #ledger-workspace .ledger-collapsible-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 8px 12px;
    padding: 16px;
  }
  #ledger-workspace .ledger-collapsible-head {
    grid-column: 1;
    grid-row: 1;
  }
  #ledger-workspace .ledger-collapsible-head h3 {
    font-size: 17px;
    line-height: 1.25;
  }
  #ledger-workspace .ledger-collapsible-chevron {
    grid-column: 2;
    grid-row: 1;
    width: 34px;
    height: 34px;
  }
  #ledger-workspace .ledger-collapsible-badge {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: start;   /* pill keeps its natural width, not stretched */
    max-width: 100%;
  }

  /* --- 2. Subscription pill -------------------------------------------
     The trial/status pill was capped at 42vw and clipped mid-word
     ("Langganan aktif · perpan…"). The wrapped header row has room for
     the full label. */
  #ledger-workspace .sub-banner {
    max-width: 100%;
    margin-right: 0;
  }

  /* --- 3. Form controls: 16px to stop iOS Safari auto-zoom on focus --- */
  #ledger-workspace input[type="text"],
  #ledger-workspace input[type="email"],
  #ledger-workspace input[type="password"],
  #ledger-workspace input[type="tel"],
  #ledger-workspace input[type="number"],
  #ledger-workspace select,
  #ledger-workspace textarea,
  #ledger-workspace .ledger-report-select {
    font-size: 16px;
  }

  /* --- 4. Long report strings never punch out of their card ---------- */
  #ledger-workspace .ledger-monthly-rows dd,
  #ledger-workspace .ledger-monthly-section {
    overflow-wrap: break-word;
  }

  /* --- 5. Tighter body gutter buys the content ~8px more width -------- */
  #ledger-workspace .ledger-workspace-body {
    padding-left: 14px;
    padding-right: 14px;
  }

  /* --- 6. Product table: keep columns legible and scroll cleanly ------
     Without a floor the 5 columns crushed on a phone — the meta line
     ("kg · HPP - · Jual -") broke onto 3 lines and the action buttons
     were clipped. Give it a min-width so the row stays readable and the
     wrapper scrolls horizontally with momentum, like the kasir table. */
  #ledger-workspace .ledger-inventory-table {
    min-width: 540px;
  }
  #ledger-workspace .ledger-inventory-table-wrap,
  #ledger-workspace .ledger-kasir-table-wrap,
  #ledger-workspace .ledger-bank-statement-preview,
  #ledger-workspace .ledger-tax-table-wrap {
    -webkit-overflow-scrolling: touch;
  }
  #ledger-workspace .ledger-tax-table {
    min-width: 520px;
  }

  /* --- 7. Kasir POS: phone checkout bar + sheet cart -------------------
     Product grid fills the viewport; cart slides up as a bottom sheet;
     history uses card rows instead of a wide table.

     Critical: glass `backdrop-filter` on .ledger-monthly-report (Kasir
     section) creates a containing block for position:fixed descendants.
     That trapped the keranjang sheet + mobile bar inside the panel so
     they stacked over products/history with transparent --panel-soft
     (ghost/overlap glitch) and swallowed taps. Strip the filter and
     force opaque sheet. Checkout bar stays ABOVE the sheet (z 1230). */
  #ledger-workspace #ledgerKasirSection {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    filter: none;
    transform: none;
    contain: none;
    background:
      radial-gradient(120% 140% at 0% 0%, rgba(43, 232, 165, 0.05), transparent 55%),
      rgba(8, 18, 14, 0.96);
  }
  #ledger-workspace #ledgerKasirSection .ledger-pos-search {
    font-size: 16px;
  }
  #ledger-workspace #ledgerKasirSection .ledger-pos-product-card {
    touch-action: manipulation;
  }
  #ledger-workspace #ledgerKasirSection .ledger-pos-cart-sheet {
    background: #0a1612;
    border-color: rgba(43, 232, 165, 0.22);
    box-shadow: 0 -16px 48px rgba(0, 0, 0, 0.6);
    /* Sit above the sticky checkout bar, not over it. */
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    z-index: 1220;
  }
  #ledger-workspace #ledgerKasirSection .ledger-pos-cart-sheet.is-open {
    pointer-events: auto;
  }
  #ledger-workspace #ledgerKasirSection .ledger-pos-mobile-bar.is-visible {
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1230;
    background: #0a1612;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-top-color: rgba(43, 232, 165, 0.2);
    touch-action: manipulation;
  }
  #ledger-workspace #ledgerKasirSection .ledger-pos-cart-backdrop.is-visible {
    background: rgba(0, 0, 0, 0.62);
    z-index: 1210;
    pointer-events: auto;
  }
}

/* Portaled POS chrome on body (see portalPosMobileChrome in ledger.js) */
body > .ledger-pos-cart-sheet.is-portaled {
  border-color: rgba(43, 232, 165, 0.22);
  box-shadow: 0 -16px 48px rgba(0, 0, 0, 0.6);
}
body > .ledger-pos-mobile-bar.is-portaled {
  border-top-color: rgba(43, 232, 165, 0.2);
}

/* ============================================================
   INSTALL (PWA) — header affordance + iOS instruction toast
   ------------------------------------------------------------
   The button is hidden by default and revealed by pwa.js only when
   the app is installable (Chromium beforeinstallprompt) or on iOS
   Safari. Given a subtle jade tint so it reads as a helpful action
   without competing with the primary CTAs.
   ============================================================ */
#ledger-workspace .ledger-install-btn {
  border-color: var(--border-strong);
  color: var(--v-platinum);
  background: rgba(43, 232, 165, 0.10);
}
#ledger-workspace .ledger-install-btn:hover {
  border-color: rgba(43, 232, 165, 0.5);
  color: var(--text);
  background: rgba(43, 232, 165, 0.16);
}
.ledger-install-hint {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 1300;
  width: min(440px, calc(100vw - 32px));
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(43, 232, 165, 0.3);
  background: rgba(10, 24, 20, 0.96);
  backdrop-filter: blur(12px);
  box-shadow: 0 18px 44px -18px rgba(0, 0, 0, 0.85);
  color: #eaf6f1;
  font-size: 14px;
  line-height: 1.5;
  animation: ledger-install-hint-in 240ms cubic-bezier(0.22, 0.61, 0.36, 1) both;
}
.ledger-install-hint > span { flex: 1; min-width: 0; }
@keyframes ledger-install-hint-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.ledger-install-hint-close {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #9fb9af;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.ledger-install-hint-close:hover { color: #eaf6f1; background: rgba(255, 255, 255, 0.08); }
@media (prefers-reduced-motion: reduce) {
  .ledger-install-hint { animation: none; }
}

/* ============================================================
   Reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .ledger-tide,
  #ledger-workspace *,
  #ledger-workspace *::before,
  #ledger-workspace *::after {
    animation: none !important;
    transition: none !important;
  }
}
