/* Reset, type, the app shell (top bar, page, phone tab bar) and small utilities. Components are in
   components.css; each view's own rules are in css/views/<view>.css. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--text-base)/1.5 var(--font);
  font-variant-numeric: tabular-nums;     /* every figure lines up */
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.01em; line-height: 1.25; font-weight: 600; }
h1 { font-size: var(--text-xl); letter-spacing: -0.02em; }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-md); }
p { margin: 0 0 var(--space-3); }
ul, ol { margin: 0; padding-left: 20px; }
a { color: var(--info); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
img, svg { display: block; max-width: 100%; }
svg.icon { display: inline-block; flex: none; vertical-align: -0.15em; }
button, input, select, textarea { font: inherit; color: inherit; }
table { border-collapse: collapse; width: 100%; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
:focus:not(:focus-visible) { outline: none; }
/* A heading the app moves focus to (after navigation, or when the button that was focused went away) is not a
   control: no ring around it. */
:is(h1, h2, h3)[tabindex="-1"]:focus { outline: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important;
                           transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* ---------- utilities ---------- */
.sr-only { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
           clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.small { font-size: var(--text-sm); }
.tiny { font-size: var(--text-xs); }
.num { font-variant-numeric: tabular-nums; font-weight: var(--weight-num); white-space: nowrap; }
.gain { color: var(--gain); }
.loss { color: var(--loss); }
.warn { color: var(--watch); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.stack > * + * { margin-top: var(--space-3); }
.grow { flex: 1 1 auto; min-width: 0; }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: var(--space-2); } .mt-3 { margin-top: var(--space-3); } .mt-4 { margin-top: var(--space-4); }

/* ---------- skip link ---------- */
.skip-link { position: absolute; left: 8px; top: -80px; z-index: 100; background: var(--bg); color: var(--text);
             padding: 10px 14px; border-radius: var(--radius-sm); }
.skip-link:focus { top: 8px; box-shadow: var(--shadow-pop); }

/* a disclosure: <summary>Label ${icon('chevron-down', {cls: 'chev'})}</summary> turns its chevron when open */
summary { cursor: pointer; }
summary::-webkit-details-marker { display: none; }
summary { list-style: none; }
details > summary .chev { transition: transform .15s ease; margin-left: 4px; color: var(--muted); }
details[open] > summary .chev { transform: rotate(180deg); }

/* ---------- the shell ---------- */
.top { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--border); }
.top-inner { max-width: var(--page-max); margin: 0 auto; padding: 0 var(--gutter); height: var(--top-h);
             display: flex; align-items: center; gap: var(--space-5); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none;
         font-weight: 700; font-size: 17px; letter-spacing: -0.02em; min-height: var(--tap); min-width: 0; }
.brand img { border-radius: 8px; flex: none; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }   /* the word gives way before a button */
.topnav { display: flex; align-items: stretch; gap: var(--space-1); height: 100%; }
.topnav a { display: inline-flex; align-items: center; padding: 0 12px; color: var(--muted); text-decoration: none;
            font-weight: 500; font-size: var(--text-base); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.topnav a:hover { color: var(--text); }
.topnav a[aria-current="page"] { color: var(--text); font-weight: 600; border-bottom-color: var(--text); }
.top-tools { margin-left: auto; display: flex; align-items: center; gap: var(--space-1); }
.icon-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; flex: none;
            width: var(--tap); height: var(--tap); border-radius: var(--radius-pill); border: 0; background: none;
            color: var(--muted); cursor: pointer; text-decoration: none; }
.icon-btn:hover, .icon-btn[aria-current="page"] { color: var(--text); background: var(--surface); }
.icon-btn .badge { position: absolute; top: 6px; right: 4px; }
.badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--radius-pill); background: var(--loss);
         color: #FFFFFF; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
:root[data-theme="dark"] .badge { color: #0D1117; }
/* signed out: Sign in, except on the sign-in page itself */
.top-link { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 12px; border-radius: var(--radius-pill);
            color: var(--text); font-weight: 600; text-decoration: none; }
.top-link:hover { text-decoration: underline; }
.top-link[aria-current="page"] { display: none; }

.main { max-width: var(--page-max); margin: 0 auto; padding: var(--space-5) var(--gutter) var(--space-7); outline: none; }
.main:focus { outline: none; }

/* the front page: the page behind it and the top bar take its navy (tokens.css, data-front), from the loading line
   on, and the container gives up its width and padding to the bands */
:root[data-front] body, :root[data-front] .top { background: var(--fp-band-0); }
:root[data-front] .top { border-bottom-color: transparent; }
:root[data-front] .brand, :root[data-front] .top-link { color: var(--fp-text); }
:root[data-front] .boot .muted { color: var(--fp-muted); }
:root[data-front] .main { max-width: none; padding: 0; }
:root[data-front] .top :focus-visible, :root[data-front] .skip-link:focus-visible { outline: 3px solid var(--fp-focus); outline-offset: 3px; }

.tabbar { display: none; }
@media (max-width: 719px) {
  :root { --top-h: 56px; }
  .topnav { display: none; }
  .top-inner { gap: var(--space-2); }
  .top-tools { gap: 0; }   /* 44px buttons already space their icons */
  .main { padding-top: var(--space-4); padding-bottom: calc(var(--tabbar-h) + var(--space-6) + env(safe-area-inset-bottom)); }
  .tabbar:not([hidden]) { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0;
            z-index: 20; background: var(--bg); border-top: 1px solid var(--border);
            padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
              min-height: var(--tabbar-h); color: var(--muted); text-decoration: none; font-size: 11.5px; font-weight: 500; }
  .tabbar a[aria-current="page"] { color: var(--text); font-weight: 600; }
}

/* ---------- page head ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap;
             margin-bottom: var(--space-5); }
.page-head h1 { font-size: var(--text-xl); }
.page-head p { margin: 4px 0 0; color: var(--muted); max-width: 64ch; }
.section-title { font-size: var(--text-xs); font-weight: 600; color: var(--muted); text-transform: uppercase;
                 letter-spacing: .06em; margin: 0 0 var(--space-2); }

.boot { padding: var(--space-7) 0; text-align: center; }
