/* ==========================================================================
   theme.css -- v19
   #13  Light / Dark mode for the whole application
   #1   Mobile-first responsive layout (phones & tablets)
   Loaded AFTER style.css so it only overrides; nothing here changes behavior.
   ========================================================================== */

/* --------------------------------------------------------------------------
   #13  LIGHT THEME
   style.css defines the dark palette on :root. Light mode simply re-points the
   same custom properties, so every component follows automatically.
   -------------------------------------------------------------------------- */
html[data-theme="light"] {
  --bg:#f4f6fb; --panel:#ffffff; --panel2:#eef2f8; --line:#d7dfea;
  --text:#0f172a; --muted:#5b6b82; --accent:#0284c7; --accent2:#0369a1;
  --green:#047857; --red:#b91c1c; --amber:#b45309; --purple:#6d28d9;
}
html[data-theme="light"] body { background:var(--bg); color:var(--text); }
html[data-theme="light"] .sidebar { background:#0f172a; }          /* keep rail dark */
html[data-theme="light"] .sidebar .nav a { color:#94a3b8; }
html[data-theme="light"] .sidebar .nav a:hover,
html[data-theme="light"] .sidebar .nav a.active { color:#fff; background:#1e293b; }
html[data-theme="light"] .card,
html[data-theme="light"] .panel { box-shadow:0 1px 2px rgba(15,23,42,.06); }
html[data-theme="light"] input,
html[data-theme="light"] select,
html[data-theme="light"] textarea { background:#fff; color:var(--text); }
html[data-theme="light"] tr:hover td { background:#f1f5f9; }
html[data-theme="light"] .btn { color:#04283b; }
html[data-theme="light"] .btn.sec { background:#eef2f8; color:var(--text); }
html[data-theme="light"] .msg.bot,
html[data-theme="light"] .chip { background:#eef2f8; }
html[data-theme="light"] .flash.error { background:#fee2e2; color:#991b1b; }
html[data-theme="light"] .flash.success { background:#dcfce7; color:#166534; }
html[data-theme="light"] .cal td.out { background:#e9eef6; opacity:1; }
html[data-theme="light"] .modal-backdrop { background:rgba(15,23,42,.45); }
html[data-theme="light"] .disclaimer { color:#64748b; }

/* theme toggle button */
.theme-btn{background:var(--panel2);border:1px solid var(--line);color:var(--text);
  border-radius:10px;padding:7px 11px;font-size:15px;cursor:pointer;line-height:1}
.theme-btn:hover{border-color:var(--accent)}
.theme-btn .t-label{font-size:12px;margin-left:6px;color:var(--muted)}

/* --------------------------------------------------------------------------
   #1  MOBILE / RESPONSIVE
   -------------------------------------------------------------------------- */
.nav-toggle{display:none;background:var(--panel2);border:1px solid var(--line);
  color:var(--text);border-radius:10px;padding:7px 12px;font-size:16px;cursor:pointer}
.sidebar-backdrop{display:none;position:fixed;inset:0;background:rgba(2,6,23,.55);z-index:49}
.sidebar-backdrop.open{display:block}

@media (max-width: 900px) {
  /* off-canvas sidebar instead of the squashed 64px rail */
  .sidebar{position:fixed;left:0;top:0;bottom:0;width:264px;max-width:84vw;z-index:50;
    transform:translateX(-105%);transition:transform .22s ease;box-shadow:0 0 40px rgba(0,0,0,.45)}
  .sidebar.open{transform:translateX(0)}
  .sidebar .brand small,
  .sidebar .nav a span,
  .sidebar .nav .group{display:block}          /* undo the icon-only collapse */
  .nav-toggle{display:inline-block}
  .main{padding:14px 12px;max-width:100%}
  .topnav{gap:8px;flex-wrap:wrap;justify-content:flex-start}
  .topbar{flex-direction:column;align-items:flex-start;gap:10px}
  .topbar h1{font-size:19px}
  .actionbar{gap:8px}

  /* tables scroll horizontally instead of overflowing the viewport */
  .panel table, .card table, table.wide{display:block;width:100%;overflow-x:auto;
    -webkit-overflow-scrolling:touch}
  th,td{white-space:nowrap}
  td .muted{white-space:normal}

  .form-row{grid-template-columns:1fr}
  .cards{grid-template-columns:repeat(auto-fill,minmax(150px,1fr))}
  .card .val{font-size:20px}

  /* comfortable tap targets */
  .btn{padding:11px 16px}
  .btn.sm{padding:8px 12px}
  input,select,textarea{font-size:16px;padding:11px}   /* 16px stops iOS zoom */

  .acct-ticker{margin-right:0;font-size:13px;padding:5px 10px}
  .bell-menu{width:calc(100vw - 24px);right:-8px}
  .ai-panel{right:8px;left:8px;width:auto;height:70vh}
  .ai-fab{right:14px;bottom:14px}
  .modal{width:100%;max-height:92vh}
  .chart-box{height:220px}
  .cal td{height:auto;min-height:64px;font-size:11px}
  .help-toc a{font-size:12px}
}

@media (max-width: 560px) {
  body{font-size:14.5px}
  .main{padding:12px 10px}
  .cards{grid-template-columns:1fr 1fr}
  .cal td{min-height:52px;padding:3px}
  .cal .daynum{font-size:11px}
  .ev{font-size:9.5px}
  .stat-strip .card{min-width:100%}
  .urow-actions{justify-content:flex-start}
  .modal-foot{flex-direction:column-reverse}
  .modal-foot .btn{width:100%}
}

/* landscape phones / small tablets: keep the 2-up card grid readable */
@media (min-width: 561px) and (max-width: 900px) {
  .cols-3{grid-template-columns:1fr 1fr}
}

/* print: hide chrome so the reports print cleanly */
@media print {
  .sidebar,.topnav,.ai-fab,.ai-panel,.nav-toggle,.theme-btn,.actionbar{display:none !important}
  .main{padding:0;max-width:100%}
  .panel,.card{border:1px solid #ccc;break-inside:avoid}
  body{background:#fff;color:#000}
}

/* --------------------------------------------------------------------------
   v19 shared bits: ledger, reconcile modal, maintenance progress bar
   -------------------------------------------------------------------------- */
.ledger-dir{font-size:11px;padding:1px 7px;border-radius:10px;font-weight:600}
.ledger-dir.in{background:#064e3b;color:#bbf7d0}
.ledger-dir.out{background:#7f1d1d;color:#fecaca}
html[data-theme="light"] .ledger-dir.in{background:#dcfce7;color:#166534}
html[data-theme="light"] .ledger-dir.out{background:#fee2e2;color:#991b1b}

.range-pills{display:flex;gap:6px;flex-wrap:wrap}
.range-pills a{background:var(--panel2);border:1px solid var(--line);border-radius:14px;
  padding:5px 12px;font-size:12.5px;color:var(--text);text-decoration:none}
.range-pills a.on{border-color:var(--accent);color:var(--accent);font-weight:600}

.progress-wrap{height:14px;background:var(--bg);border:1px solid var(--line);
  border-radius:8px;overflow:hidden;margin:10px 0 6px}
.progress-wrap > span{display:block;height:100%;width:0;background:var(--accent);
  transition:width .3s ease}
.progress-wrap.err > span{background:var(--red)}
.job-log{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11.5px;
  background:var(--bg);border:1px solid var(--line);border-radius:8px;padding:10px;
  max-height:220px;overflow:auto;white-space:pre-wrap}
.acct-link{color:var(--text);text-decoration:none;border-bottom:1px dotted var(--muted)}
.acct-link:hover{color:var(--accent);border-bottom-color:var(--accent);text-decoration:none}
