/* Investor portal.
 *
 * Ground and structure follow the internal terminal language: neutral warm
 * paper in light, cool near-black in dark, sharp 3px corners, tabular figures,
 * one restrained accent. The accent is the brand teal, validated against both
 * surfaces (light #0097A7, dark #21A5B5: lightness band, chroma and contrast
 * all pass). Semantic pos/neg carry meaning only and always ship with an arrow
 * and a word, never colour alone.
 */

/* Palette taken from the public site (css/theme.css): its default colourway is
   deep teal, its light one warm paper. Two accent roles, not one:

     --accent        chart marks. Needs 3:1 against the surface and must sit in
                     the dark lightness band, so the brand cyan (L 0.885) is
                     too light here and a mid step of the same hue is used.
     --accent-solid  filled buttons and active states. Needs 4.5:1 for the text
                     it carries, which the site's own teal-on-white does not
                     reach, so buttons use a deeper step.
*/

:root {
  color-scheme: light;
  --page:           #f6f8f7;
  --surface:        #ffffff;
  --surface-head:   #ecf1f0;
  --surface-sunken: #ecf1f0;
  --ink:            #06273a;
  --ink-2:          #3d5563;
  --muted:          #6b8290;
  --border:         rgba(6, 39, 58, 0.16);
  --border-strong:  rgba(6, 39, 58, 0.28);

  --accent:           #0097a7;
  --accent-wash:      rgba(0, 151, 167, 0.10);
  --accent-solid:     #007f8d;
  --accent-solid-ink: #ffffff;
  --accent-hover:     #016b76;

  --pos:  #0f7a53;
  --neg:  #c0392b;
  --grid: rgba(6, 39, 58, 0.10);
  --axis: rgba(6, 39, 58, 0.22);

  --bar:       #006e7b;
  --bar-ink:   #ffffff;
  --bar-ink-2: rgba(255, 255, 255, 0.72);
  --bar-line:  rgba(255, 255, 255, 0.16);
  --bar-mark:  #8febf3;

  --radius:  4px;
  --fs-xs:   0.6875rem;
  --font:    "Roboto", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-num: ui-monospace, "SF Mono", "IBM Plex Mono", "Roboto Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page:           #03343a;
    --surface:        #054149;
    --surface-head:   #02535c;
    --surface-sunken: #022a2f;
    --ink:            #f0fbfc;
    --ink-2:          #c5e6e9;
    --muted:          #8dbfc4;
    --border:         rgba(143, 235, 243, 0.18);
    --border-strong:  rgba(143, 235, 243, 0.30);

    --accent:           #21a5b5;
    --accent-wash:      rgba(143, 235, 243, 0.12);
    --accent-solid:     #8febf3;
    --accent-solid-ink: #03343a;
    --accent-hover:     #a5f0f6;

    --pos:  #7be0b0;
    --neg:  #ffb09b;
    --grid: rgba(143, 235, 243, 0.10);
    --axis: rgba(143, 235, 243, 0.22);

    --bar:       #006e7b;
    --bar-ink:   #ffffff;
    --bar-ink-2: rgba(255, 255, 255, 0.72);
    --bar-line:  rgba(143, 235, 243, 0.20);
    --bar-mark:  #8febf3;
  }
}

:root[data-theme="dark"] {
color-scheme: dark;
  --page:           #03343a;
  --surface:        #054149;
  --surface-head:   #02535c;
  --surface-sunken: #022a2f;
  --ink:            #f0fbfc;
  --ink-2:          #c5e6e9;
  --muted:          #8dbfc4;
  --border:         rgba(143, 235, 243, 0.18);
  --border-strong:  rgba(143, 235, 243, 0.30);

  --accent:           #21a5b5;
  --accent-wash:      rgba(143, 235, 243, 0.12);
  --accent-solid:     #8febf3;
  --accent-solid-ink: #03343a;
  --accent-hover:     #a5f0f6;

  --pos:  #7be0b0;
  --neg:  #ffb09b;
  --grid: rgba(143, 235, 243, 0.10);
  --axis: rgba(143, 235, 243, 0.22);

  --bar:       #006e7b;
  --bar-ink:   #ffffff;
  --bar-ink-2: rgba(255, 255, 255, 0.72);
  --bar-line:  rgba(143, 235, 243, 0.20);
  --bar-mark:  #8febf3;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  -webkit-text-size-adjust: 100%;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }

/* ----------------------------------------------------------------- top bar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  height: 52px;
  background: var(--bar);
  color: var(--bar-ink);
  border-bottom: 1px solid var(--bar-line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.logo {
  width: 22px;
  height: 22px;
  flex: none;
  color: var(--bar-mark);
}

.topbar-right { display: flex; align-items: center; gap: 6px; }

.who {
  color: var(--bar-ink-2);
  font-size: 12px;
  margin-right: 6px;
  padding-right: 12px;
  border-right: 1px solid var(--bar-line);
}

.topbar button {
  font: inherit;
  font-size: 12px;
  color: var(--bar-ink-2);
  background: transparent;
  border: 1px solid var(--bar-line);
  border-radius: var(--radius);
  padding: 5px 10px;
  cursor: pointer;
}

.topbar button:hover {
  color: var(--bar-ink);
  border-color: rgba(255, 255, 255, 0.3);
}

.topbar form { display: contents; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

main { max-width: 1140px; margin: 0 auto; padding: 24px 20px 56px; }

/* -------------------------------------------------------------------- hero */

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.label {
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hero-value {
  font-family: var(--font-num);
  font-size: 46px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 6px 0 4px;
}

.hero-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.delta {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.delta.up { color: var(--pos); }
.delta.down { color: var(--neg); }
.delta.flat { color: var(--ink-2); }
.delta .arrow { margin-right: 4px; }
.delta .cap { font-family: var(--font); font-weight: 400; color: var(--ink-2); margin-left: 6px; }
.asof { color: var(--muted); font-size: 12px; }

.hero-right { text-align: right; }
.hero-right .basis { color: var(--ink-2); font-size: 12px; margin-top: 4px; }

/* ------------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--surface-head);
  border-bottom: 1px solid var(--border);
}

.card-title { font-size: 12px; font-weight: 600; letter-spacing: 0.01em; }
.card-sub { color: var(--muted); font-size: var(--fs-xs); margin-top: 1px; }
.card-body { padding: 16px; }

/* Filter row: one row, above the content it scopes. */
.ranges { display: flex; gap: 0; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; }

.ranges button {
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--surface);
  border: none;
  border-right: 1px solid var(--border);
  padding: 5px 11px;
  cursor: pointer;
}

.ranges button:last-child { border-right: none; }
.ranges button:hover { color: var(--ink); background: var(--surface-sunken); }

.ranges button[aria-pressed="true"] {
  color: var(--accent-solid-ink);
  background: var(--accent-solid);
}

/* ------------------------------------------------------------------- tiles */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}

.tile { background: var(--surface); padding: 12px 14px; }

.tile-value {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-top: 3px;
}

/* ------------------------------------------------------------------- chart */

.chart-wrap { position: relative; padding: 8px 4px 0; }

svg.chart { display: block; width: 100%; height: 300px; touch-action: pan-y; }

.gridline { stroke: var(--grid); stroke-width: 1; }
.axisline { stroke: var(--axis); stroke-width: 1; }

.tick {
  fill: var(--muted);
  font-size: 10px;
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
}

.serieline {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.seriearea { fill: var(--accent-wash); stroke: none; }

.endlabel {
  fill: var(--ink);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
}

.crosshair { stroke: var(--axis); stroke-width: 1; }
.endmark, .cursormark { stroke: var(--surface); stroke-width: 2; fill: var(--accent); }

.tip {
  position: absolute;
  pointer-events: none;
  min-width: 128px;
  padding: 7px 9px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px -8px rgba(6, 39, 58, 0.35);
  font-size: 11px;
}

.tip[hidden] { display: none; }
.tip-date { color: var(--muted); margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 7px; }

.tip-key { width: 12px; height: 2px; background: var(--accent); flex: none; }

.tip-value {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ink);
}

.tip-name { color: var(--ink-2); }

/* ------------------------------------------------------------------- table */

.table-scroll { overflow-x: auto; }

table { border-collapse: separate; border-spacing: 0; width: 100%; }

th, td {
  text-align: right;
  padding: 7px 14px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--surface-head);
  border-bottom: 1px solid var(--border-strong);
}

td {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}

td:first-child { color: var(--ink); font-family: var(--font); }
th:first-child, td:first-child { text-align: left; }
tbody tr:hover td { background: var(--surface-sunken); }
tbody tr:last-child td { border-bottom: none; }

/* ------------------------------------------------------------------- login */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--page);
}

.login-card {
  width: 100%;
  max-width: 352px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.login-head {
  padding: 16px 26px;
  background: var(--bar);
  color: var(--bar-ink);
}

.login-body { padding: 26px; }

.login-body h1 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 3px;
}

.login-body p.sub { color: var(--muted); margin: 0 0 20px; font-size: 12px; }

label {
  display: block;
  color: var(--ink-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 5px;
}

input[type="text"], input[type="password"] {
  font: inherit;
  font-size: 13px;
  width: 100%;
  padding: 9px 11px;
  margin-bottom: 14px;
  color: var(--ink);
  background: var(--surface-sunken);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-wash); }

.submit {
  font: inherit;
  width: 100%;
  padding: 10px;
  margin-top: 6px;
  color: var(--accent-solid-ink);
  background: var(--accent-solid);
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.submit:hover { background: var(--accent-hover); }

.error {
  padding: 9px 11px;
  margin-bottom: 16px;
  color: var(--neg);
  background: var(--surface-sunken);
  border-left: 2px solid var(--neg);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 12px;
}

.empty { padding: 48px 20px; text-align: center; color: var(--muted); font-size: 12px; }

.footnote {
  color: var(--muted);
  font-size: var(--fs-xs);
  line-height: 1.6;
  margin-top: 22px;
}

.login-body .footnote { margin-top: 20px; }

@media (max-width: 640px) {
  .hero-value { font-size: 34px; }
  .hero-right { text-align: left; }
  main { padding: 18px 14px 44px; }
  .topbar { padding: 0 14px; }
  .who { display: none; }
  svg.chart { height: 240px; }
}

/* ------------------------------------------------- export button & pager */

.btn-export {
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 5px 11px;
  text-decoration: none;
  white-space: nowrap;
}

.btn-export:hover { color: var(--ink); border-color: var(--accent); background: var(--accent-wash); }

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-head);
}

.pager[hidden] { display: none; }

.pager button {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 5px 12px;
}

.pager button:disabled { opacity: 0.4; cursor: default; }
.pager button:disabled:hover { background: transparent; color: var(--ink-2); }

.pager-state {
  color: var(--muted);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

/* --------------------------------------------------------------- phones */

/* Many readers open this on a phone, so the layout below is the primary
   target rather than a fallback. */
@media (max-width: 720px) {
  body { font-size: 14px; }

  .topbar {
    height: auto;
    padding: 10px 14px;
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }

  .brand { font-size: 13px; }
  .logo { width: 20px; height: 20px; }
  .who { display: none; }

  /* Touch targets, not mouse targets. */
  .topbar button, .pager button, .btn-export {
    min-height: 36px;
    padding: 8px 12px;
  }

  .ranges button { min-height: 36px; padding: 8px 12px; font-size: 12px; }

  main {
    padding: 16px 14px 40px;
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }

  .hero {
    display: block;
    padding-bottom: 16px;
    margin-bottom: 16px;
  }

  .hero-value { font-size: 38px; }

  .hero-right {
    text-align: left;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
  }

  .card-head { padding: 10px 14px; }
  .card-body { padding: 14px; }

  /* The range picker gets its own line rather than squeezing the title. */
  .card-head > div:first-child { flex: 1 1 100%; }
  .ranges { flex: 1 1 100%; }
  .ranges button { flex: 1; }

  svg.chart { height: 230px; }
  .chart-wrap { padding: 6px 0 0; }

  .tiles { grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); }
  .tile { padding: 11px 12px; }
  .tile-value { font-size: 17px; }

  th, td { padding: 8px 10px; }

  /* The date column stays put while the numbers scroll under the thumb. */
  td:first-child, th:first-child {
    position: sticky;
    left: 0;
    background: var(--surface);
    box-shadow: 1px 0 0 var(--border);
  }
  th:first-child { background: var(--surface-head); }
  tbody tr:hover td:first-child { background: var(--surface-sunken); }

  .pager { padding: 10px 14px; }
  .tip { min-width: 116px; font-size: 11px; }
}

@media (max-width: 380px) {
  .hero-value { font-size: 32px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
}

/* ------------------------------------------------------- administration */

.tag {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--bar-mark);
  border: 1px solid var(--bar-line);
  border-radius: var(--radius);
  padding: 2px 6px;
  margin-left: 4px;
}

.navlink {
  color: var(--bar-ink-2);
  font-size: 12px;
  text-decoration: none;
  padding: 5px 8px;
  border-radius: var(--radius);
}

.navlink:hover { color: var(--bar-ink); background: rgba(255, 255, 255, 0.08); }
main .navlink { color: var(--accent); }

.card.narrow { max-width: 460px; }

.flash {
  padding: 9px 14px;
  margin-bottom: 14px;
  color: var(--ink);
  background: var(--accent-wash);
  border-left: 2px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 12px;
}

.state { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.state.on { color: var(--pos); }
.state.off { color: var(--neg); }

td.actions { text-align: left; white-space: normal; min-width: 210px; }

td.actions form { display: inline-flex; gap: 4px; flex-wrap: wrap; }
td.actions form.stack { display: flex; margin-top: 6px; }
td.actions button { font-size: var(--fs-xs); padding: 4px 8px; }
td.actions input[type="text"] { margin: 0; padding: 4px 8px; font-size: 12px; }

button.danger { color: var(--neg); border-color: var(--neg); }
button.danger:hover { background: var(--neg); color: var(--surface); }

details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 6px;
}

details[open] summary { color: var(--ink-2); }

dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0 0 18px; }
dl.kv dt { color: var(--muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; }
dl.kv dd { margin: 0; }

.secret {
  padding: 14px 16px;
  background: var(--surface-sunken);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

.secret-value {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-top: 4px;
  user-select: all;
  word-break: break-all;
}

.warn { color: var(--neg); font-size: 12px; margin: 14px 0 0; }
.hint { color: var(--muted); font-size: var(--fs-xs); margin: -8px 0 14px; }
.hint code { font-family: var(--font-num); }

.ev { font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.03em; }
.ev-login, .ev-admin_login { color: var(--pos); }
.ev-login_failed, .ev-admin_login_failed { color: var(--neg); }
.ev-admin_action { color: var(--accent); }
.ev-export { color: var(--ink); }

body.admin main { max-width: 1400px; }

/* The recording time is context, not the figure being read. */
td.muted-cell { color: var(--muted); }
