/* ==========================================================================
   BOL Report Export — design tokens, 5 themes, sidebar shell
   ========================================================================== */

:root {
  /* Phetsarath OT first in every stack so Lao text (labels, branch/region
     names, Balance Sheet line items, exported period labels shown in the
     UI, etc.) renders in the standard Lao government/banking typeface
     everywhere, not just where explicitly marked as Lao. It carries Latin
     glyphs too, so English text in the same stack still looks consistent;
     browsers fall through to Inter/Fraunces/Plex Mono (then system fonts)
     wherever a client doesn't have Phetsarath OT installed. See
     static/fonts/README.md if you want to self-host it instead of relying
     on it being installed on staff PCs. */
  --font-lao: 'Phetsarath OT', 'Phetsarath', 'Noto Sans Lao', 'Saysettha OT';
  --font-display: var(--font-lao), 'Fraunces', Georgia, serif;
  --font-ui: var(--font-lao), 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: var(--font-lao), 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;

  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 7px;

  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 1px rgba(16, 24, 40, 0.04);
  --shadow-card-hover: 0 8px 24px rgba(16, 24, 40, 0.12), 0 2px 6px rgba(16, 24, 40, 0.06);

  --sidebar-width: 248px;
  --sidebar-width-collapsed: 68px;

  /* ---- Theme: Bank Green & Gold (default) ---- */
  --brand: #0F4C33;
  --brand-deep: #0A3323;
  --accent: #C9A227;
  --accent-soft: #EFE0AE;
  --ink: #14201A;
  --ink-muted: #4B5D54;
  --line: #DCE7DF;
  --bg: #F5F8F4;
  --surface: #FFFFFF;
  --success: #15803D;
  --danger: #B3261E;
  --warning: #B45309;
  --sidebar-text: rgba(255,255,255,0.72);
  --sidebar-text-active: #FFFFFF;
}

[data-theme="navy"] {
  --brand: #0B1F3A;
  --brand-deep: #071527;
  --accent: #B8892B;
  --accent-soft: #E8D9B5;
  --ink: #101828;
  --ink-muted: #475467;
  --line: #E2E5EA;
  --bg: #F6F7F9;
  --surface: #FFFFFF;
  --success: #1B7F4C;
  --danger: #B3261E;
  --warning: #B45309;
}

[data-theme="slate"] {
  --brand: #1E293B;
  --brand-deep: #0F172A;
  --accent: #14B8A6;
  --accent-soft: #B7EDE4;
  --ink: #0F172A;
  --ink-muted: #475569;
  --line: #E2E8F0;
  --bg: #F1F5F9;
  --surface: #FFFFFF;
  --success: #0F766E;
  --danger: #BE123C;
  --warning: #C2410C;
}

[data-theme="sand"] {
  --brand: #7C2D12;
  --brand-deep: #431407;
  --accent: #B45309;
  --accent-soft: #F3D2A4;
  --ink: #2B1D14;
  --ink-muted: #6B5847;
  --line: #E9DCC9;
  --bg: #FAF6F0;
  --surface: #FFFFFF;
  --success: #3F6212;
  --danger: #9F1239;
  --warning: #92400E;
}

[data-theme="midnight"] {
  --brand: #05070C;
  --brand-deep: #000000;
  --accent: #C9A227;
  --accent-soft: #E8D9B5;
  --ink: #E5E9F0;
  --ink-muted: #93A0B4;
  --line: #262C38;
  --bg: #0B0F17;
  --surface: #131A26;
  --success: #34D399;
  --danger: #F87171;
  --warning: #FBBF24;
  --sidebar-text: rgba(255,255,255,0.6);
}

/* Bootstrap variable overrides -> cascades through every .btn/.badge/.alert/.form-control */
:root, [data-theme] {
  --bs-primary: var(--brand);
  --bs-secondary: var(--ink-muted);
  --bs-success: var(--success);
  --bs-danger: var(--danger);
  --bs-warning: var(--warning);
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--ink);
  --bs-body-font-family: var(--font-ui);
  --bs-border-color: var(--line);
  --bs-link-color: var(--brand);
  --bs-link-hover-color: var(--accent);
  --bs-border-radius: var(--radius-sm);
}

* { box-sizing: border-box; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}

code, pre, .font-mono {
  font-family: var(--font-mono);
  word-break: break-all;
  white-space: pre-wrap;
}

a { color: var(--brand); }
a:hover { color: var(--accent); }

/* ==========================================================================
   App shell: collapsible left sidebar + main content
   ========================================================================== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-deep) 100%);
  border-right: 2px solid var(--accent);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.2s ease;
  z-index: 100;
}
.app-shell.collapsed .sidebar {
  width: var(--sidebar-width-collapsed);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1.1rem 1rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-brand .coin {
  width: 30px; height: 30px; flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; color: var(--accent);
  font-family: var(--font-display);
}
.app-shell.collapsed .sidebar-brand .label { display: none; }

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0.6rem;
}
.sidebar-nav .nav-section-label {
  text-transform: uppercase;
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.35);
  padding: 0.9rem 0.6rem 0.3rem;
  white-space: nowrap;
  overflow: hidden;
}
.app-shell.collapsed .sidebar-nav .nav-section-label { visibility: hidden; height: 0; padding: 0.4rem 0; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  margin-bottom: 0.15rem;
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-link i { font-size: 1.05rem; width: 20px; flex-shrink: 0; text-align: center; }
.sidebar-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-link.active { background: rgba(255,255,255,0.12); color: var(--sidebar-text-active); }
.sidebar-link.active::before {
  content: ''; position: absolute; left: 0; width: 3px; height: 20px;
  background: var(--accent); border-radius: 0 3px 3px 0;
}
.sidebar-link { position: relative; }
.app-shell.collapsed .sidebar-link .label { display: none; }
.app-shell.collapsed .sidebar-link { justify-content: center; }

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.sidebar-user {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  margin-bottom: 0.4rem;
}
.sidebar-user .avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); color: var(--brand-deep);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.78rem; font-family: var(--font-display);
}
.app-shell.collapsed .sidebar-user .meta { display: none; }

/* ---- Main content ---- */
.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
}
.sidebar-toggle-btn {
  background: none; border: 1px solid var(--line); border-radius: var(--radius-sm);
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  color: var(--ink-muted); cursor: pointer; transition: background 0.15s ease;
  flex-shrink: 0;
}
.sidebar-toggle-btn:hover { background: var(--bg); }
.topbar-env-badge {
  background: var(--accent); color: var(--brand-deep);
  font-size: 0.68rem; font-weight: 700; padding: 0.15rem 0.5rem;
  border-radius: 999px; letter-spacing: 0.04em;
}
.topbar-spacer { flex: 1; }

.content-area {
  padding: 1.25rem 1.5rem 2rem;
}

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-card-hover);
  }
  .app-shell:not(.collapsed) .sidebar { transform: translateX(0); width: var(--sidebar-width); }
  .app-shell.collapsed .sidebar { transform: translateX(-100%); }
}

/* ==========================================================================
   Theme picker
   ========================================================================== */
.theme-picker { position: relative; }
.theme-swatch-btn {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); cursor: pointer;
  background: linear-gradient(135deg, var(--brand) 50%, var(--accent) 50%);
}
.theme-menu {
  display: none;
  position: absolute; right: 0; top: 42px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-md); box-shadow: var(--shadow-card-hover);
  padding: 0.5rem; width: 190px; z-index: 200;
}
.theme-menu.open { display: block; }
.theme-option {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.45rem 0.5rem; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 0.85rem; color: var(--ink);
}
.theme-option:hover { background: var(--bg); }
.theme-option .dot {
  width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.08);
}
.theme-option.active { font-weight: 600; }
.theme-option.active::after { content: '\2713'; margin-left: auto; color: var(--accent); }

/* ==========================================================================
   Cards, ledger panel
   ========================================================================== */
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  background: var(--surface);
  color: var(--ink);
  transition: box-shadow 0.2s ease;
}
.card.bg-light { background: var(--bg) !important; }

.ledger-panel {
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow-card);
}
.ledger-panel h6 {
  font-family: var(--font-ui);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin-bottom: 0.5rem;
}
.ledger-panel code, .ledger-panel pre {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  color: var(--ink);
}

/* ==========================================================================
   Tables: rounded elevated card treatment, dynamic hover shadow, tabular nums
   ========================================================================== */
.table-responsive {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--line);
  transition: box-shadow 0.25s ease, transform 0.25s ease;
  background: var(--surface);
}
.table-responsive:hover {
  box-shadow: var(--shadow-card-hover);
}
.table {
  font-size: 0.9rem;
  margin-bottom: 0;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--ink);
}
.table thead th {
  font-family: var(--font-ui);
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border-bottom: 2px solid var(--accent);
  position: sticky;
  top: 0;
  z-index: 1;
}
.table td {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.87rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}
.table td:first-child, .table th:first-child { font-family: var(--font-ui); }
.table-striped > tbody > tr:nth-of-type(odd) > * {
  background-color: color-mix(in srgb, var(--brand) 3%, transparent);
}
.table > :not(caption) > * > * { background: transparent; }
.table-striped > tbody > tr:nth-of-type(odd) > * { background-color: color-mix(in srgb, var(--ink) 3%, var(--surface)); }
.table-hover > tbody > tr:hover > * { background-color: color-mix(in srgb, var(--accent) 8%, var(--surface)); }

/* ==========================================================================
   Buttons, badges
   ========================================================================== */
.btn {
  font-weight: 600;
  font-size: 0.88rem;
  border-radius: var(--radius-sm);
}
.btn-primary {
  --bs-btn-bg: var(--brand);
  --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: var(--brand-deep);
  --bs-btn-hover-border-color: var(--brand-deep);
}
.btn-outline-danger {
  --bs-btn-color: var(--danger);
  --bs-btn-border-color: var(--danger);
  --bs-btn-hover-bg: var(--danger);
}
.badge.bg-success { background-color: var(--success) !important; }
.badge.bg-danger  { background-color: var(--danger) !important; }
.badge.bg-secondary { background-color: var(--ink-muted) !important; }

.form-select, .form-control {
  background-color: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}
.form-select:focus, .form-control:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 15%, transparent);
}

/* ---------- Checkbox-list multi-select (branch/region assignment) ---------- */
.checklist {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  max-height: 140px;
  overflow-y: auto;
  padding: 0.3rem;
}
.checklist label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.35rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  cursor: pointer;
  margin-bottom: 0;
  white-space: nowrap;
}
.checklist label:hover { background: var(--bg); }
.checklist input[type="checkbox"] { flex-shrink: 0; cursor: pointer; }
.checklist-empty { padding: 0.5rem; font-size: 0.8rem; color: var(--ink-muted); }

/* ==========================================================================
   Dashboard status cards
   ========================================================================== */
.status-card {
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.status-card:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-2px); }
.status-card.ok { background: linear-gradient(135deg, #14532d, var(--success)); }
.status-card.down { background: linear-gradient(135deg, #7f1d1d, var(--danger)); }
.status-card .label {
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  opacity: 0.85;
}
.status-card .value {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin-top: 0.15rem;
}

/* ---------- status-card icon chip (Balance Sheet summary row) ---------- */
.status-card .icon-chip {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: rgba(255,255,255,0.16);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 0.6rem;
}
.status-card .icon-chip svg { width: 18px; height: 18px; }
.status-card .sub-value { font-size: 0.78rem; opacity: 0.8; margin-top: 0.1rem; }

/* ==========================================================================
   KPI cards (Bank Dashboard / Performance Analysis)
   ========================================================================== */
.kpi-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  padding: 1rem 1.1rem;
  height: 100%;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  position: relative;
  overflow: hidden;
}
.kpi-card:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-2px); }
.kpi-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--kpi-accent, var(--brand));
}
.kpi-card .kpi-top {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.5rem;
}
.kpi-card .kpi-icon {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--kpi-accent, var(--brand)) 14%, var(--surface));
  color: var(--kpi-accent, var(--brand));
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.kpi-card .kpi-icon svg { width: 16px; height: 16px; }
.kpi-card .kpi-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  font-weight: 600;
}
.kpi-card .kpi-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.15;
}
.kpi-card .kpi-delta {
  display: inline-flex; align-items: center; gap: 0.25rem;
  font-size: 0.76rem;
  font-weight: 600;
  margin-top: 0.4rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
}
.kpi-card .kpi-delta.up { color: var(--success); background: color-mix(in srgb, var(--success) 12%, transparent); }
.kpi-card .kpi-delta.down { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.kpi-card .kpi-delta.flat { color: var(--ink-muted); background: color-mix(in srgb, var(--ink-muted) 10%, transparent); }
.kpi-card .kpi-sub { font-size: 0.72rem; color: var(--ink-muted); margin-top: 0.3rem; }
.kpi-card .kpi-sparkline { display: block; width: 100% !important; height: 38px !important; }

/* Accent color variants -- set the icon/top-bar color per metric group */
.kpi-card.accent-blue   { --kpi-accent: #2563eb; }
.kpi-card.accent-green  { --kpi-accent: #16a34a; }
.kpi-card.accent-amber  { --kpi-accent: #d97706; }
.kpi-card.accent-purple { --kpi-accent: #7c3aed; }
.kpi-card.accent-teal   { --kpi-accent: #0d9488; }
.kpi-card.accent-rose   { --kpi-accent: #e11d48; }

.section-heading {
  display: flex; align-items: center; gap: 0.5rem;
  font-family: var(--font-display);
  font-weight: 600;
  margin: 1.75rem 0 0.75rem;
}
.section-heading .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  flex-shrink: 0;
}

/* ---------- Equal-size action button toolbar ---------- */
.btn-toolbar-equal {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.btn-toolbar-equal .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 168px;
  justify-content: center;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}
.btn-toolbar-equal .btn svg { width: 15px; height: 15px; flex-shrink: 0; }

/* ---------- Print-ready Statements: header card + pill tab bar ---------- */
.stmt-head-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  padding: 1.1rem 1.25rem 0.9rem;
  margin-bottom: 1.1rem;
}
.stmt-ccy-form select { min-width: 90px; }
.stmt-tabbar {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 0.45rem;
  padding: 0.15rem 0.15rem 0.4rem;
  margin: 0;
  border-top: 1px solid var(--line);
  padding-top: 0.85rem;
}
.stmt-tabbar::-webkit-scrollbar { height: 5px; }
.stmt-tabbar::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }
.stmt-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
  flex-shrink: 0;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink-muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.stmt-tab:hover { border-color: var(--brand); color: var(--brand); box-shadow: var(--shadow-card); text-decoration: none; }
.stmt-tab.active { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: var(--shadow-card-hover); }
.stmt-tab.pending { opacity: 0.6; }
.stmt-tab .badge { font-size: 0.62rem; font-weight: 600; }
.stmt-bank-edit {
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  background: var(--bg);
  margin-top: 0.75rem;
}

/* ==========================================================================
   Printable "official report" export (Performance Analysis, Ratio Analysis,
   and any future exportable page). Same convention as the Statements page's
   own local print CSS (window.print(), .no-print, .print-sheet /
   .print-page-break) but shared here so every page that adds a PDF export
   button gets it for free.

   Usage: wrap the normal interactive dashboard in <div class="report-screen-only">
   and the letterhead/summary-table/benchmark-notes version in
   <div class="report-print-only"> -- the screen shows only the first, a
   browser print (or "Save as PDF") shows only the second.
   ========================================================================== */
.report-print-only { display: none; }
.report-print-detail-heading { display: none; }
@media print {
  .sidebar, .topbar, .no-print, .alert { display: none !important; }
  .app-shell { display: block !important; min-height: 0 !important; }
  .main-area { display: block !important; }
  .app-shell, .main-area, .content-area { margin: 0 !important; padding: 0 !important; width: 100% !important; }
  body { background: #fff !important; }
  .report-screen-only { display: none !important; }
  .report-print-only { display: block !important; }
  .report-print-only .print-page-break { page-break-after: always; break-after: page; }
  /* Left/right kept a bit wider than the statements page's own print rule --
     this page's appendix (below) carries Bootstrap grid cards whose gutters
     bleed past their container on the sides (see the .row override further
     down), so a slightly bigger side margin keeps their edges, and any KPI
     card text that reaches its own edge, safely inside the printable area
     instead of running up against the paper's edge. */
  @page { size: A4 portrait; margin: 14mm 16mm; }

  /* "Export to PDF -- Detailed (with charts)" sets body.print-detailed
     right before calling window.print() (removed again on the browser's
     afterprint event) -- this additionally prints the live dashboard's own
     KPI cards + charts (as an appendix after the summary report above),
     while still hiding the filter form / buttons / on-screen Monthly Detail
     table via .no-print-detail (the print-only report already carries that
     same table). Plain "Export to PDF -- Summary" leaves body.print-detailed
     off, so only the letterhead summary report prints. */
  body.print-detailed .report-screen-only { display: block !important; }
  body.print-detailed .no-print-detail { display: none !important; }
  body.print-detailed .report-print-detail-heading {
    display: block !important; font-size: 1rem; font-weight: 700; color: #111;
    margin: 1.4rem 0 0.8rem; border-top: 2px solid #333; padding-top: 0.9rem;
  }
  body.print-detailed .card { border: 1px solid #ccc !important; box-shadow: none !important; break-inside: avoid; }
  body.print-detailed canvas { max-width: 100% !important; }

  /* Bootstrap's .row applies a negative left/right margin (offset by
     padding on its .col-* children) so cards can butt up against a
     container's own padding on screen. On screen .content-area supplies
     that padding; in print .content-area is forced to padding:0 above, so
     the row's negative margin was bleeding the first/last card in every
     row (and any full-width text inside .report-screen-only, e.g. the
     dashboard's own intro paragraph) past the @page margin and right to
     the paper's edge -- which is what was getting text/card borders cut
     off. Neutralizing the row's own negative margin and giving the whole
     appendix a small inner gutter instead fixes that without touching how
     these same rows look on screen. */
  body.print-detailed .report-screen-only { padding: 0 4mm !important; }
  body.print-detailed .report-screen-only .row { margin-left: 0 !important; margin-right: 0 !important; }
  body.print-detailed .report-screen-only .row > * { padding-left: 0.45rem !important; padding-right: 0.45rem !important; }
}

.report-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  border-bottom: 2px solid #333; padding-bottom: 0.5rem; margin-bottom: 0.75rem;
}
.report-header .rh-bank-lo { font-weight: 700; font-size: 1.05rem; color: #111; }
.report-header .rh-bank-en { font-size: 0.82rem; color: #444; }
.report-header .rh-meta { text-align: right; font-size: 0.78rem; color: #333; }
.report-title { text-align: center; margin: 0.5rem 0 1.1rem; }
.report-title h2 { font-size: 1.2rem; margin-bottom: 0.15rem; color: #111; }
.report-title .rh-sub { font-size: 0.82rem; color: #444; }
.report-table { width: 100%; border-collapse: collapse; font-size: 0.75rem; margin-bottom: 1.1rem; color: #111; }
.report-table th, .report-table td { border: 1px solid #999; padding: 0.22rem 0.4rem; }
.report-table thead th { background: #f1f1f1; text-align: center; font-weight: 600; }
.report-benchmark-box {
  border: 1px solid #999; border-radius: 4px; padding: 0.7rem 0.9rem;
  margin-bottom: 0.9rem; font-size: 0.76rem; background: #fafafa; color: #222;
}
.report-benchmark-box h6 { font-size: 0.85rem; margin-bottom: 0.4rem; color: #111; }
.report-benchmark-box ul { margin-bottom: 0.5rem; padding-left: 1.1rem; }
.report-benchmark-box li { margin-bottom: 0.3rem; }
.report-disclaimer {
  font-size: 0.72rem; color: #333; font-style: italic; border-top: 1px dashed #999;
  padding-top: 0.5rem; margin-top: 0.4rem;
}
.report-footer {
  margin-top: 1rem; font-size: 0.68rem; color: #555; text-align: center;
  border-top: 1px solid #ccc; padding-top: 0.4rem;
}

/* Line/Bar chart-type toggle used on Performance Analysis's per-metric
   trend widgets. */
.chart-type-toggle .btn.active { background: var(--brand, #2563eb); color: #fff; border-color: var(--brand, #2563eb); }

/* ---------- Financial Risk Analysis: risk-level pills + overall banner ---------- */
.risk-pill {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.2rem 0.65rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600;
}
.risk-pill.risk-low, .risk-pill.risk-improving { background: #dcfce7; color: #166534; }
.risk-pill.risk-moderate, .risk-pill.risk-stable { background: #fef3c7; color: #92400e; }
.risk-pill.risk-elevated, .risk-pill.risk-high, .risk-pill.risk-declining { background: #fee2e2; color: #991b1b; }
.risk-pill.risk-na { background: #f1f5f9; color: #64748b; }

.risk-banner {
  border-radius: var(--radius-lg, 12px); padding: 1.25rem 1.5rem; margin-bottom: 1.5rem;
  color: #fff; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem;
}
.risk-banner.risk-low { background: linear-gradient(135deg, #16a34a, #15803d); }
.risk-banner.risk-moderate { background: linear-gradient(135deg, #d97706, #b45309); }
.risk-banner.risk-elevated { background: linear-gradient(135deg, #e11d48, #9f1239); }
.risk-banner .rb-title { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.85; }
.risk-banner .rb-value { font-size: 1.6rem; font-weight: 700; }
.risk-banner .rb-sub { font-size: 0.82rem; opacity: 0.9; }

.risk-card { position: relative; border-radius: var(--radius-lg, 12px); padding: 1rem 1.1rem; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-card); height: 100%; }
.risk-card .risk-card-label { font-size: 0.8rem; color: var(--muted, #64748b); margin-bottom: 0.3rem; }
.risk-card .risk-card-value { font-size: 1.4rem; font-weight: 700; margin-bottom: 0.35rem; }
.risk-card .risk-card-note { font-size: 0.72rem; color: var(--muted, #64748b); margin-top: 0.4rem; }

/* ==========================================================================
   Login page
   ========================================================================== */
.login-shell {
  min-height: 100vh;
  display: flex;
  margin: -1.25rem -1.5rem;
}
.login-brand {
  flex: 1.1;
  background:
    radial-gradient(circle at 20% 20%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 45%),
    linear-gradient(160deg, var(--brand) 0%, var(--brand-deep) 100%);
  color: #fff;
  padding: 4rem 3.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100vh;
}
.login-brand .mark {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.login-brand .mark .coin {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  color: var(--accent);
  font-family: var(--font-display);
}
.login-brand h1 {
  color: #fff;
  font-size: 2.2rem;
  line-height: 1.15;
  max-width: 22ch;
  margin-top: 2.5rem;
}
.login-brand p.tagline {
  color: rgba(255,255,255,0.68);
  max-width: 42ch;
  font-size: 0.95rem;
}
.login-brand .foot {
  border-top: 1px solid rgba(255,255,255,0.15);
  padding-top: 1rem;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.55);
  font-family: var(--font-mono);
}
.login-form-side {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  padding: 2rem;
}
.login-card { width: 100%; max-width: 380px; }
.login-card .eyebrow {
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 0.4rem;
}
.login-card h2 { font-size: 1.5rem; margin-bottom: 0.25rem; }
.login-card .subtitle { color: var(--ink-muted); font-size: 0.9rem; margin-bottom: 1.75rem; }
.login-card .form-label { font-size: 0.82rem; font-weight: 600; color: var(--ink); }
.login-card .form-control { padding: 0.65rem 0.85rem; border-color: var(--line); }
.login-card .btn-primary { padding: 0.65rem; width: 100%; margin-top: 0.5rem; }
.login-mobile-switch { text-align: center; margin-top: 1.1rem; }
.login-mobile-switch a {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.8rem; color: var(--ink-muted); text-decoration: none;
}
.login-mobile-switch a:hover { color: var(--accent); text-decoration: underline; }
@media (max-width: 900px) {
  .login-brand { display: none; }
}

/* ==========================================================================
   Loading overlay (shown while a report request is blocked on Oracle)
   ========================================================================== */
.oracle-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: #fff;
  text-align: center;
}
.oracle-overlay.active { display: flex; }
.oracle-overlay .ring {
  width: 64px; height: 64px;
  border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
  margin-bottom: 1.5rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .oracle-overlay .ring { animation: none; border-top-color: color-mix(in srgb, var(--accent) 60%, transparent); }
}
.oracle-overlay h5 { color: #fff; font-size: 1.2rem; margin-bottom: 0.4rem; }
.oracle-overlay .elapsed {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 1rem;
  color: var(--accent-soft);
  margin-top: 0.75rem;
  letter-spacing: 0.04em;
}
.oracle-overlay .hint { color: rgba(255,255,255,0.6); font-size: 0.85rem; max-width: 34ch; margin-top: 1rem; }
.oracle-overlay .warn { color: rgba(255,255,255,0.4); font-size: 0.75rem; margin-top: 2rem; font-family: var(--font-mono); }

/* Success state -- swap the spinner ring for an animated checkmark (used by
   BOLOverlay.success(), e.g. after a download's bytes have actually landed,
   not just when the request was sent -- see static/js/app.js). */
.oracle-overlay .check {
  display: none;
  width: 64px; height: 64px;
  margin-bottom: 1.5rem;
}
.oracle-overlay.success .ring { display: none; }
.oracle-overlay.success .check { display: block; }
.oracle-overlay .check circle {
  stroke-dasharray: 151;
  stroke-dashoffset: 151;
  animation: check-circle 0.4s ease-out forwards;
}
.oracle-overlay .check path {
  stroke-dasharray: 36;
  stroke-dashoffset: 36;
  animation: check-mark 0.3s 0.35s ease-out forwards;
}
@keyframes check-circle { to { stroke-dashoffset: 0; } }
@keyframes check-mark { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) {
  .oracle-overlay .check circle, .oracle-overlay .check path { animation: none; stroke-dashoffset: 0; }
}

/* ---------- Raw Trial Balance tree view ---------- */
.raw-tree-group {
  border: 1px solid var(--bs-border-color, #dee2e6);
  border-radius: 0.4rem;
  margin-bottom: 0.5rem;
  overflow: hidden;
}
.raw-tree-sheet { border-color: #b6c4d6; }
.raw-tree-line { border-color: #e2e7ee; margin-left: 1rem; }
.raw-tree-lines { padding: 0.5rem 0.5rem 0.5rem 0; }
.raw-tree-group-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bs-tertiary-bg, #f4f6f8);
  border: none;
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-weight: 600;
  cursor: pointer;
}
.raw-tree-group-header:hover { background: var(--bs-secondary-bg, #e9ecef); }
.raw-tree-caret {
  display: inline-block;
  transition: transform 0.15s ease;
  color: var(--bs-secondary-color, #6c757d);
}
.raw-tree-group-header.open .raw-tree-caret { transform: rotate(90deg); }
.raw-tree-group-label { flex: 1 1 auto; }
.raw-tree-count { font-weight: 500; }
.raw-tree-totals {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--bs-secondary-color, #6c757d);
  white-space: nowrap;
}
.raw-tree-rows {
  max-height: 420px;
  overflow-y: auto;
  border-top: 1px solid var(--bs-border-color, #dee2e6);
}
.raw-tree-rows table thead th {
  position: sticky;
  top: 0;
  background: var(--bs-body-bg, #fff);
  z-index: 1;
}
