/* WDPL Hub -- a dense data screen, not a marketing page.
   Rows are the point, so the chrome stays quiet and the numbers get the ink. */

:root {
  --bg: #fbfbfa;
  --panel: #ffffff;
  --ink: #1c1b19;
  --ink-2: #55524c;
  --muted: #8a857c;
  --line: #e6e3dd;
  --line-2: #f0eeea;
  --accent: #7a1f2b;
  --accent-soft: #f6ecec;
  --good: #1f6b45;
  --warn: #8a5a12;
  --bad: #a02020;
  --row-hover: #f6f5f2;
  --header: #f4f2ee;
  --radius: 9px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17161a; --panel: #1e1d22; --ink: #eceae6; --ink-2: #b6b1a8;
    --muted: #857f76; --line: #302e34; --line-2: #26252a; --accent: #d98a95;
    --accent-soft: #2b2126; --good: #6cc295; --warn: #d6a44e; --bad: #e08585;
    --row-hover: #24232a; --header: #24232a;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }

/* ------------------------------------------------------------- sign in -- */
.centre {
  position: fixed; inset: 0; display: flex;
  align-items: center; justify-content: center; padding: 24px;
}
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 34px 32px; width: 100%; max-width: 380px;
}
.card h1 { margin: 0 0 2px; font-size: 20px; letter-spacing: -0.01em; }
.card .sub { margin: 0 0 26px; color: var(--muted); font-size: 13px; }
.card label {
  display: block; font-size: 12px; color: var(--ink-2);
  margin: 14px 0 5px; font-weight: 500;
}
.card input {
  width: 100%; padding: 9px 11px; font: inherit;
  border: 1px solid var(--line); border-radius: 7px;
  background: var(--bg); color: var(--ink);
}
.card input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.card button[type=submit] {
  width: 100%; margin-top: 22px; padding: 10px; font: inherit; font-weight: 500;
  background: var(--accent); color: #fff; border: 0;
  border-radius: 7px; cursor: pointer;
}
.card button[type=submit]:disabled { opacity: .55; cursor: default; }
.msg { margin: 14px 0 0; font-size: 13px; min-height: 1.4em; color: var(--bad); }
.msg.ok { color: var(--good); }

.spinner {
  width: 22px; height: 22px; border: 2px solid var(--line);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* -------------------------------------------------------------- chrome -- */
#app { display: flex; flex-direction: column; height: 100%; }
header {
  display: flex; align-items: center; gap: 14px;
  padding: 0 14px; height: 46px; flex: none;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.spacer { flex: 1; }

nav {
  display: flex; gap: 1px; overflow-x: auto; scrollbar-width: none;
  max-width: 60vw;
}
nav::-webkit-scrollbar { display: none; }
nav button {
  font: inherit; font-size: 13px; padding: 5px 11px; white-space: nowrap;
  background: transparent; border: 0; border-radius: 6px;
  color: var(--ink-2); cursor: pointer;
}
nav button:hover { background: var(--row-hover); color: var(--ink); }
nav button[aria-selected=true] {
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}

.freshness { font-size: 11.5px; color: var(--muted); text-align: right; line-height: 1.3; }
.freshness .stale { color: var(--warn); font-weight: 600; }

.menu { position: relative; }
.menu summary {
  list-style: none; cursor: pointer; font-size: 12.5px; color: var(--ink-2);
  padding: 5px 9px; border-radius: 6px; border: 1px solid var(--line);
}
.menu summary::-webkit-details-marker { display: none; }
.menu-body {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 9px; padding: 12px; min-width: 230px;
  box-shadow: 0 8px 24px rgba(0,0,0,.10);
}
.menu-body h4 { margin: 0 0 6px; font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em; }
.menu-body .grant { display: flex; justify-content: space-between; font-size: 12.5px; padding: 2px 0; }
.menu-body .grant span:last-child { color: var(--muted); font-family: var(--mono); font-size: 11px; }
.link {
  background: 0; border: 0; color: var(--accent); font: inherit; font-size: 13px;
  cursor: pointer; padding: 8px 0 0; margin-top: 8px;
  border-top: 1px solid var(--line-2); width: 100%; text-align: left;
}

/* ------------------------------------------------------------ toolbar -- */
.toolbar {
  display: flex; align-items: center; gap: 8px; flex: none;
  padding: 7px 14px; border-bottom: 1px solid var(--line);
  background: var(--panel); min-height: 44px; flex-wrap: wrap;
}
.toolbar input[type=search], .toolbar input[type=date], .toolbar select {
  font: inherit; font-size: 13px; padding: 5px 9px;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); color: var(--ink);
}
.toolbar input[type=search] { min-width: 210px; }
.btn {
  font: inherit; font-size: 13px; padding: 5px 11px; cursor: pointer;
  background: var(--panel); color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 6px;
}
.btn:hover { background: var(--row-hover); color: var(--ink); }
.btn.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.count { font-size: 12.5px; color: var(--muted); margin-left: auto; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- grid -- */
main { flex: 1; overflow: auto; position: relative; }
table { border-collapse: separate; border-spacing: 0; font-size: 13px; width: max-content; min-width: 100%; }
thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--header); border-bottom: 1px solid var(--line);
  padding: 7px 10px; text-align: left; font-weight: 600; font-size: 12px;
  color: var(--ink-2); white-space: nowrap; cursor: pointer; user-select: none;
}
thead th:hover { color: var(--ink); }
thead th .dir { color: var(--accent); margin-left: 3px; }
tbody td {
  padding: 5px 10px; border-bottom: 1px solid var(--line-2);
  white-space: nowrap; max-width: 340px; overflow: hidden; text-overflow: ellipsis;
}
tbody tr:hover { background: var(--row-hover); }
td.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12.5px; }
td.neg { color: var(--bad); }
td.code { font-family: var(--mono); font-size: 12px; cursor: pointer; }
td.code:hover { color: var(--accent); text-decoration: underline; }
.sev-HIGH   { color: var(--bad); font-weight: 600; }
.sev-MEDIUM { color: var(--warn); font-weight: 600; }
.sev-INFO   { color: var(--muted); }

.empty, .error {
  padding: 40px 20px; text-align: center; color: var(--muted); font-size: 14px;
}
.error { color: var(--bad); }
.status {
  flex: none; padding: 5px 14px; font-size: 12px; color: var(--muted);
  border-top: 1px solid var(--line); background: var(--panel);
  display: flex; gap: 14px; align-items: center;
}

/* -------------------------------------------------------------- detail -- */
.detail {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(680px, 94vw);
  background: var(--panel); border-left: 1px solid var(--line);
  box-shadow: -12px 0 32px rgba(0,0,0,.10); z-index: 60;
  overflow: auto; padding: 22px 26px 40px;
}
.detail .close {
  position: absolute; top: 12px; right: 14px; font-size: 22px; line-height: 1;
  background: 0; border: 0; color: var(--muted); cursor: pointer;
}
.detail h2 { margin: 0 0 2px; font-size: 17px; }
.detail .code-line { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-bottom: 18px; }
.detail section { margin-top: 22px; }
.detail section h3 {
  margin: 0 0 8px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted); font-weight: 600;
}
.detail table { font-size: 12.5px; width: 100%; }
.detail thead th { position: static; background: transparent; border-bottom: 1px solid var(--line); cursor: default; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }

/* A day with stock moving on it is worth spotting without reading the number. */
td.move { box-shadow: inset 2px 0 0 var(--line); }
td.num.neg { background: color-mix(in srgb, var(--bad) 9%, transparent); }

/* ------------------------------------------------ Excel-like presentation */
/* Gridlines on every cell, the way the workbook has them. A dense grid of
   numbers is far easier to read across when the eye has a rule to follow. */
:root { --grid: #d9d5cd; --zebra: #faf9f7; --sel: #e7eef8; --sel-line: #7ba3d9; }
@media (prefers-color-scheme: dark) {
  :root { --grid: #3a3840; --zebra: #1c1b21; --sel: #26303f; --sel-line: #4e6f9e; }
}

table { border-collapse: collapse; }
thead th {
  border: 1px solid var(--grid); background: var(--header);
  text-align: center; font-weight: 700; color: var(--ink);
}
thead th.day { font-weight: 600; font-size: 11px; }
tbody td { border: 1px solid var(--grid); }
tbody tr:nth-child(even) { background: var(--zebra); }
tbody tr:hover { background: var(--row-hover); }

/* A dragged range. !important because the zebra and hover rules would
   otherwise win and the selection would be invisible on half the rows. */
td.sel { background: var(--sel) !important; box-shadow: inset 0 0 0 1px var(--sel-line); }
.selinfo { color: var(--accent); font-weight: 500; margin-left: auto; }

/* A material that will not last a month at its normal rate of sale */
td.thin { color: var(--bad); font-weight: 700; }

/* The material column stays put while you scroll out into the dates -- the
   same pane the report freezes. */
tbody td:first-child, thead th:first-child {
  position: sticky; left: 0; z-index: 1; background: var(--panel);
}
tbody tr:nth-child(even) td:first-child { background: var(--zebra); }
thead th:first-child { z-index: 3; background: var(--header); }

/* ------------------------------------------------------ planner, flipped */
/* Materials across and days down, the way the report is laid out. The row
   labels take the place of the frozen first column. */
table.planner th.rowlab {
  position: sticky; left: 0; z-index: 2;
  background: var(--header); text-align: left; white-space: nowrap;
  font-weight: 600; font-size: 11.5px; padding: 4px 10px;
  border: 1px solid var(--grid); min-width: 210px;
}
table.planner th.rowlab.day {
  font-family: var(--mono); font-size: 11px; font-weight: 500; color: var(--ink-2);
}
table.planner thead th { min-width: 92px; font-family: var(--mono); font-size: 11px; }
table.planner thead th:first-child { z-index: 4; }
/* The information block reads as a header block, not as more data */
table.planner tr.inforow td { background: var(--zebra); font-size: 12px; }
table.planner tr.inforow:last-of-type th,
table.planner tr.inforow:last-of-type td { border-bottom: 2px solid var(--ink-2); }
table.planner tbody tr:nth-child(even) { background: transparent; }

/* A divider between one report's tabs and the next */
.tabsep {
  width: 1px; align-self: stretch; margin: 6px 5px;
  background: var(--line); flex: none;
}
/* Which report this screen replaces, above the freshness stamp */
.freshness .report { color: var(--ink-2); font-weight: 600; font-size: 11.5px; }
