/*
  TnT Reporting dashboard - styling.

  Follows the FP Document Services look: black bar on top, white header, pure white ground
  without grey areas or shadows, 1px hairlines instead of tiles, right angles throughout
  (no border-radius), one accent colour (FP red), bold tightly set headings.

  System fonts only: the service runs inside the VPN, where web fonts are unreachable.
*/

:root {
  /* FP red, taken from the corporate site. White on red and red on white: 4.92:1 (WCAG AA). */
  --accent: #E1003C;
  --accent-dark: #C70036;        /* hover, 6.03:1 */

  --ground: #FFFFFF;
  --ink: #1A1A1A;                /* 17.4:1 */
  --ink-muted: #6B6B70;          /* 5.30:1 - do not lighten, small text would fall below AA */
  --ink-faint: #B4B4B8;          /* placeholder for empty cells only, not for information */
  --line: #E4E4E7;
  --track: #F0F0F2;
  --error-ground: #FFF5F7;

  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, Consolas, "Cascadia Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 15px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1, h2, .kpi-value { font-weight: 700; letter-spacing: -0.02em; }

code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--track);
  padding: 1px 5px;
}

.muted { color: var(--ink-muted); }
.small { font-size: 13px; }

/* ------------------------------------------------------------------ Header */
.top-bar { height: 34px; background: #000; }

.page-header {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 76px;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
}

.brand { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; white-space: nowrap; }
.brand-accent { color: var(--accent); }
.brand-rest { font-weight: 400; }

.divider { width: 1px; height: 34px; background: var(--line); }
.page-title { margin: 0; font-size: 16px; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }

/* ----------------------------------------------------------------- Buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 22px;
  border: 2px solid var(--accent);
  border-radius: 0;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.button:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.button:disabled { opacity: 0.5; cursor: default; }
.button-outline { background: transparent; color: var(--accent); }
.button-outline:hover { background: var(--accent); color: #fff; }
.button-small { padding: 7px 16px; font-size: 13px; }

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

main { max-width: 1440px; margin: 0 auto; padding: 36px 32px 64px; }

/* ----------------------------------------------------------------- Sign-in */
.sign-in {
  max-width: 420px;
  margin: 7vh auto;
  padding: 36px 34px 34px;
  border: 1px solid var(--line);
}
.sign-in .kicker { margin: 0 0 6px; font-size: 13px; font-weight: 700; color: var(--accent); }
.sign-in h1 { margin: 0 0 8px; font-size: 26px; line-height: 1.2; }
.sign-in p.muted { margin: 0 0 24px; font-size: 14px; }
.sign-in label { display: block; margin: 16px 0 6px; font-size: 13px; font-weight: 700; }
.sign-in input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  font: inherit;
}
.sign-in input:focus { outline: 0; border-color: var(--ink); }
.sign-in .button { width: 100%; margin-top: 26px; padding: 13px; }

.message { margin: 20px 0 0; padding: 12px 14px; font-size: 14px; }
.message-error { border-left: 4px solid var(--accent); background: var(--error-ground); }

.loading { margin: 0; padding: 60px 0; text-align: center; color: var(--ink-muted); }
.loading:empty { display: none; }

/* ---------------------------------------------------------------- KPIs
   Lines: the container draws top and right, each tile left and bottom. This is the only
   split that stays correct when the last row is not full. */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  margin-bottom: 32px;
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
}
.kpi { padding: 22px 24px 20px; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.kpi-value { font-size: 38px; line-height: 1.05; }
.kpi-label { margin-top: 8px; font-size: 14px; font-weight: 700; }
.kpi-hint { margin-top: 3px; font-size: 12.5px; line-height: 1.45; color: var(--ink-muted); }

/* ----------------------------------------------------------------- Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
}
.card { min-width: 0; padding: 26px 26px 28px; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.card-wide { grid-column: 1 / -1; }
.card h2 { margin: 0 0 5px; font-size: 18px; }
.card-marker { width: 34px; height: 4px; margin-bottom: 16px; background: var(--accent); }
.caption { margin: 0 0 20px; font-size: 13px; line-height: 1.5; color: var(--ink-muted); }
.empty { margin: 0; font-size: 13px; color: var(--ink-muted); }

/* ------------------------------------------------------------ Bar lists
   One colour for all bars: length carries the information, every bar is labelled. */
.bar-list { margin: 0; padding: 0; list-style: none; }
.bar { margin-bottom: 14px; }
.bar:last-child { margin-bottom: 0; }
.bar-label { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 6px; font-size: 14px; }
.bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-value { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-share { margin-left: 8px; font-weight: 400; color: var(--ink-muted); }
.bar-track { height: 10px; background: var(--track); }
.bar-fill { height: 100%; background: var(--accent); }

/* ---------------------------------------------------------- Daily chart */
.chart-scroll { overflow-x: auto; }
.chart-daily text { font: 10.5px var(--font); fill: var(--ink-muted); }
.chart-daily .grid-line { stroke: var(--track); }
.chart-daily .column { fill: var(--accent); }

/* ---------------------------------------------------------------- Table */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  padding: 0;
  border-bottom: 2px solid var(--ink);
  text-align: left;
  white-space: nowrap;
}
th button {
  width: 100%;
  padding: 9px 12px 8px;
  border: 0;
  background: none;
  color: var(--ink-muted);
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-align: left;
  text-transform: uppercase;
  cursor: pointer;
}
th button:hover, th[aria-sort] button { color: var(--ink); }
th[aria-sort="ascending"] button::after { content: " ▲"; }
th[aria-sort="descending"] button::after { content: " ▼"; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.nowrap { white-space: nowrap; font-variant-numeric: tabular-nums; }
td.mono {
  max-width: 300px;
  overflow: hidden;
  font-family: var(--mono);
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
td.no-rows { padding: 26px 2px; color: var(--ink-muted); }
.null { color: var(--ink-faint); }
.pill {
  display: inline-block;
  padding: 2px 9px;
  border: 1px solid var(--line);
  color: var(--ink-muted);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}
.pill:empty { display: none; }

.table-more {
  display: flex;
  justify-content: center;
  margin-top: 4px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

/* --------------------------------------------------------------- Filters */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
  margin-bottom: 32px;
  padding: 16px 18px;
  border: 1px solid var(--line);
}
.filter-bar-inline { margin: 0 0 18px; padding: 0 0 18px; border: 0; border-bottom: 1px solid var(--line); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.field input, .field select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}
.field input:focus, .field select:focus { outline: 0; border-color: var(--ink); }
.field .wide { min-width: 230px; }
.field-check { flex-direction: row; align-items: center; gap: 8px; padding-bottom: 9px; }
.field-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.field-check label { font-size: 14px; font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--ink); }
.filter-end { display: flex; align-items: flex-end; gap: 10px; margin-left: auto; }
.filter-end > span { padding-bottom: 9px; }

@media (max-width: 720px) {
  .page-header { gap: 14px; padding: 0 18px; }
  .page-header .divider, .page-title, #loadedAt { display: none; }
  main { padding: 24px 18px 48px; }
  .cards { grid-template-columns: 1fr; }
  .filter-end { margin-left: 0; flex-wrap: wrap; }
}
