/* theme.css — the look toggle and the switch between looks, shared by the broker app and the admin dashboard.
   The colours themselves are tokens in each page's own stylesheet (dark values in :root, light under
   :root[data-theme="light"]). */
.theme-tog { display:inline-grid; place-items:center; width:44px; height:44px; border-radius:999px; border:0; background:var(--surface-2);
  color:var(--text); cursor:pointer; margin-left:6px; }
.theme-tog:hover { background:var(--border-strong); }
.theme-tog:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.theme-tog .tt-moon { display:none; }
:root[data-theme="light"] .theme-tog .tt-sun { display:none; }
:root[data-theme="light"] .theme-tog .tt-moon { display:block; }
::view-transition-old(root), ::view-transition-new(root) { animation:none; mix-blend-mode:normal; }
.theme-fading, .theme-fading * { transition:background-color .2s ease, color .2s ease, border-color .2s ease, fill .2s ease !important; }
@media (prefers-reduced-motion: reduce) { .theme-fading, .theme-fading * { transition:none !important; } }


/* ── LIQUID GLASS, TINTED (Ari, 2026-10-20) ── the page header, the tab bars and the sidebar: the page's own surface
   colour at 78% under a blur, so text on them always reads in both looks, with a soft light edge along the top.
   Without backdrop-filter the same bars are solid. */
:root { --lg-edge:rgba(255,255,255,.10); --lg-shadow:0 10px 30px -14px rgba(0,0,0,.65); }
:root[data-theme="light"] { --lg-edge:rgba(255,255,255,.85); --lg-shadow:0 10px 28px -14px rgba(0,0,0,.22); }
.main > .topbar, .tabbar, .app > .sidebar {
  background:rgba(var(--glass),.78);
  -webkit-backdrop-filter:blur(20px) saturate(180%); backdrop-filter:blur(20px) saturate(180%);
  box-shadow:inset 0 1px 0 var(--lg-edge);
}
@supports not ((backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px))) {
  .main > .topbar, .tabbar, .app > .sidebar { background:rgb(var(--glass)); }
}

/* ── LABELS ON HOVER (theme.js): a small bubble beside the control, never over it ── */
.fs-tip { position:fixed; z-index:1000; max-width:240px; padding:6px 10px; border-radius:8px; pointer-events:none;
  font:600 .8125rem/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, sans-serif;
  background:#f5f5f7; color:#1d1d1f; box-shadow:0 8px 24px -8px rgba(0,0,0,.5); }
:root[data-theme="light"] .fs-tip { background:#1d1d1f; color:#ffffff; }
.fs-tip[hidden] { display:none; }

/* ── NOT SHOWN YET (notyet.js): greyed and blurred, the reason on hover, keyboard focus or tap. The blur sits on the
   contents, so the box itself, its edge and the small ⓘ that invites a tap stay sharp. ── */
.not-yet { position:relative; cursor:help; }
.not-yet > * { filter:grayscale(1) blur(2.5px); opacity:.5; pointer-events:none; user-select:none; }
/* A line that is itself the reason ("No runs recorded yet…", wrapped in .ny-in by notyet.js) stays readable: greyed, never
   blurred, since blurring it would hide the very explanation (PM, 2026-10-26). */
.not-yet > .ny-in { filter:none; opacity:1; color:var(--text-dim); }
.not-yet::after { content:'i'; position:absolute; top:8px; right:8px; width:18px; height:18px; display:grid; place-items:center;
  border:1.5px solid var(--text-dim); border-radius:50%; color:var(--text-dim); font:700 11px/1 -apple-system, BlinkMacSystemFont, sans-serif; }
.not-yet:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }

/* ── THE FOUR TABS ON A PHONE (Ari's iPhone, 2026-10-20), one set of rules for the broker app and the admin ──
   In a browser tab Safari floats its own toolbar at the bottom and grows and shrinks it as you scroll; a fixed bar of
   ours down there jumped, floated mid-screen and sat on Safari's address capsule. So in a browser tab the tabs are a
   sticky glass bar right under the page header, and nothing of ours is pinned to the bottom. Opened from the
   Home Screen (display-mode: standalone) there is no Safari toolbar, and they become a bottom tab bar like an app. */
.tabbar { display:none; }
@media (max-width:767px) {
  .main > .topbar { position:static; }
  .tabbar { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:4px; position:sticky; top:calc(6px + env(safe-area-inset-top)); z-index:35;
    margin:6px 10px 0; padding:5px; border-radius:16px; box-shadow:inset 0 1px 0 var(--lg-edge), var(--lg-shadow); }
  .tab-link { display:flex; align-items:center; justify-content:center; min-height:44px; min-width:0; padding:0 4px; border:0; border-radius:12px;
    background:none; color:var(--text-dim); font:inherit; font-size:.875rem; font-weight:600; cursor:pointer; }
  .tab-link .ic { display:none; }
  .tab-link.active { background:var(--accent-soft); color:var(--text); font-weight:700; box-shadow:inset 0 0 0 1.5px var(--accent); }
  .tab-link:focus-visible { outline:2px solid var(--accent); outline-offset:-2px; }
}
@media (max-width:767px) and (display-mode: standalone) {
  /* full screen: the status bar (black-translucent) overlays the page, so keep the top clear and shade the strip */
  .main { padding-top:env(safe-area-inset-top); padding-bottom:calc(88px + env(safe-area-inset-bottom)); }
  body::before { content:''; position:fixed; top:0; left:0; right:0; height:env(safe-area-inset-top); background:var(--bg-0); z-index:60; }
  .tabbar { position:fixed; top:auto; left:12px; right:12px; bottom:calc(8px + env(safe-area-inset-bottom)); z-index:45; margin:0; gap:0;
    padding:6px 4px; border-radius:24px; }
  .tab-link { flex-direction:column; gap:3px; min-height:50px; border-radius:18px; color:var(--muted); font-size:.75rem; font-weight:500; }
  .tab-link .ic { display:inline-flex; }
  .tab-link .ic svg { width:22px; height:22px; }
  .tab-link.active { background:none; box-shadow:none; color:var(--accent); font-weight:600; }
  .toast { bottom:calc(96px + env(safe-area-inset-bottom)); }
}

/* ── NATIVE CONTROLS FOLLOW THE LOOK (Ari, 12 Nov: the state list opened white with grey text in dark) ──
   color-scheme tells the browser which look its own parts take: the popup a <select> opens, the date picker, the
   page's own scrollbar. Dark had none, so the browser drew them light. The option colours are for the browsers that
   draw the list themselves (Chromium on Windows and Linux); macOS and phones draw a native menu in the right look. */
:root { color-scheme:dark; --sb-thumb:rgba(255,255,255,.24); --sb-thumb-on:rgba(255,255,255,.40); --modal-dim:rgba(0,0,0,.62); }
:root[data-theme="light"] { color-scheme:light; --sb-thumb:rgba(0,0,0,.22); --sb-thumb-on:rgba(0,0,0,.38); --modal-dim:rgba(0,0,0,.38); }
select option, select optgroup { background-color:var(--bg-1); color:var(--text); }

/* ── ONE WAY FOR EVERY WINDOW (Ari, 12 Nov: "make it behave like a proper app") ──
   Every window over the page: a plain dim behind it (no blur), the panel centred, never taller than the screen, and it
   scrolls inside itself with a thin scrollbar in the look's colours; its header (and its buttons, where it has them)
   stay put while the rest scrolls under them, and the page behind does not scroll. On a phone the big ones (Compared
   with before, Getting started) are a full-screen sheet; the small ones stay a centred card. The side drawers on the
   admin (a row's detail, More data) stay drawers, with the same dim, scrollbar and lock. Popovers anchored to a button
   (Needs you, a day's numbers) are not windows: they only take the scrollbar. */
:root :is(.cxf, .modal-scrim, .ob-scrim, .fp-scrim, .cm-scrim, .obg) {
  display:flex; align-items:center; justify-content:center; padding:24px; overflow:hidden; overscroll-behavior:contain;
  -webkit-backdrop-filter:none; backdrop-filter:none; }
:root[data-theme] :is(.cxf, .modal-scrim, .ob-scrim, .fp-scrim, .cm-scrim, .obg) { background:var(--modal-dim); }
:root :is(.cxf, .modal-scrim, .ob-scrim, .fp-scrim, .cm-scrim, .obg)[hidden] { display:none; }
:root .drill-scrim { background:var(--modal-dim); -webkit-backdrop-filter:none; backdrop-filter:none; }
:root :is(.cxf-box, .modal-card, .ob-card, .fp-card, .obg-win) {
  max-width:100%; max-height:min(88vh, 900px); max-height:min(88dvh, 900px); overflow:auto; overscroll-behavior:contain; }
/* Call Mode keeps its own head and foot; only its middle scrolls. A centred card now, not a sheet stuck to the foot. */
:root .cm-card { max-height:min(88vh, 900px); max-height:min(88dvh, 900px); border-radius:18px; border-bottom-width:1px; box-shadow:0 30px 80px rgba(0,0,0,.45); }
/* Getting started was a see-through glass pane; on a plain dim it is a solid panel in the look's own colour. */
:root[data-theme] .obg-win { background:var(--bg-1); border-color:var(--border-strong); -webkit-backdrop-filter:none; backdrop-filter:none; }
:root[data-theme] .obg-body .obf-card { background:var(--surface-2); border-color:var(--border); }
/* The scrollbar: thin, in the look's colours, no white track. */
:root :is(.cxf-box, .modal-card, .ob-card, .fp-card, .obg-win, .cm-body, .drill-rows, .more-body, .np-box, .tlp-box) {
  scrollbar-width:thin; scrollbar-color:var(--sb-thumb) transparent; }
:root :is(.cxf-box, .modal-card, .ob-card, .fp-card, .obg-win, .cm-body, .drill-rows, .more-body, .np-box, .tlp-box)::-webkit-scrollbar { width:10px; height:10px; background:transparent; }
:root :is(.cxf-box, .modal-card, .ob-card, .fp-card, .obg-win, .cm-body, .drill-rows, .more-body, .np-box, .tlp-box)::-webkit-scrollbar-thumb {
  background:var(--sb-thumb); border-radius:999px; border:3px solid transparent; background-clip:padding-box; }
:root :is(.cxf-box, .modal-card, .ob-card, .fp-card, .obg-win, .cm-body, .drill-rows, .more-body, .np-box, .tlp-box)::-webkit-scrollbar-thumb:hover { background-color:var(--sb-thumb-on); }
/* The header stays put: it reaches the panel's edges (the panel's own padding, --mp-y / --mp-x) so nothing shows
   above or beside it as the rest scrolls under. A sticky item holds at the panel's padding edge, so it sits one
   padding higher (top: minus the padding) to meet the panel's own top. */
/* Each panel's padding and colour (--mp-y, --mp-x, --mp-bg) is set beside the panel, in its page's own stylesheet. */
:root :is(.cxf-body > .cx-top, .modal-card > .modal-title, .ob-card > h2, .obg-win > .obg-top) {
  position:sticky; top:calc(-1 * var(--mp-y)); z-index:3; margin-top:calc(-1 * var(--mp-y)); margin-left:calc(-1 * var(--mp-x)); margin-right:calc(-1 * var(--mp-x));
  padding-top:var(--mp-y); padding-left:var(--mp-x); padding-right:var(--mp-x); padding-bottom:10px; background:var(--mp-bg); }
:root .modal-card > .modal-actions { position:sticky; bottom:-18px; z-index:3; margin:4px -22px -18px; padding:12px 22px 18px; background:var(--mp-bg); }
/* The page behind stands still while a window or drawer is open. */
html:has(:is(.cxf, .modal-scrim, .ob-scrim, .fp-scrim, .cm-scrim, .obg, .drill):not([hidden])),
html:has(:is(.cxf, .modal-scrim, .ob-scrim, .fp-scrim, .cm-scrim, .obg, .drill):not([hidden])) body { overflow:hidden; }
@media (max-width:720px) {
  :root :is(.modal-scrim, .ob-scrim, .fp-scrim, .cm-scrim) { padding:12px; }
  :root :is(.modal-card, .ob-card, .fp-card, .cm-card) { max-height:calc(100vh - 24px); max-height:calc(100dvh - 24px); }
  :root .cxf { padding:0; align-items:stretch; }
  :root .cxf-box { max-height:none; height:100%; height:100dvh; border-radius:0; --mp-y:16px; --mp-x:16px; }
  :root .obg { padding:0; align-items:stretch; }
  :root .obg-win { max-height:none; height:100dvh; --mp-y:calc(14px + env(safe-area-inset-top)); --mp-x:18px; }
}
