/* Daily report subscriptions. Plain CSS; no build step in this project. */

:root {
  color-scheme: light dark;
  --ink: #111827; --ink-2: #4b5563; --muted: #9ca3af;
  --line: #e5e7eb; --surface: #fff; --surface-2: #f9fafb;
  --accent: #1d4ed8;
  --good-fg: #065f46; --good-bg: #d1fae5;
  --warn-fg: #92400e; --warn-bg: #fffbeb; --warn-line: #fde68a;
  --bad-fg: #b91c1c;  --bad-bg: #fef2f2;  --bad-line: #fecaca;
  --info-fg: #1e3a8a; --info-bg: #eff6ff; --info-line: #bfdbfe;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e5e7eb; --ink-2: #9ca3af; --muted: #6b7280;
    --line: #374151; --surface: #111827; --surface-2: #1f2937;
    --accent: #60a5fa;
    --good-fg: #d1fae5; --good-bg: #022c22;
    --warn-fg: #fef3c7; --warn-bg: #422006; --warn-line: #854d0e;
    --bad-fg: #fee2e2;  --bad-bg: #450a0a;  --bad-line: #991b1b;
    --info-fg: #dbeafe; --info-bg: #172554; --info-line: #1e40af;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0; color: var(--ink); background: var(--surface-2);
  font: 15px/1.55 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
[hidden] { display: none !important; }
.grow { flex: 1; }
.muted { color: var(--ink-2); }
.fine { font-size: 13px; }

.centred { max-width: 460px; margin: 16vh auto; padding: 0 24px; text-align: center; }
.centred h1 { font-size: 22px; margin: 0 0 6px; }

/* Sticky rather than fixed: it stays put while the page scrolls without
   leaving the flow, so no content has to be padded down by a hardcoded
   header height - the mistake that put the chat below the fold in the
   editor. */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 650; }
.topnav { display: flex; gap: 4px; }
.topnav a {
  padding: 6px 11px; border-radius: 7px; text-decoration: none;
  color: var(--ink-2); font-size: 14px;
}
.topnav a:hover { background: var(--surface-2); color: var(--ink); }
/* Current page carries weight and a rule, not colour alone. */
.topnav a.active, .topnav a[aria-current="page"] {
  color: var(--ink); font-weight: 650; background: var(--surface-2);
  box-shadow: inset 0 -2px 0 var(--accent);
}

/* Shared with /report so the content's left edge does not jump when you
   switch between them. Settings is a sidebar layout and is wider by nature;
   these two are single columns and should line up. */
.wrap { max-width: 1040px; margin: 0 auto; padding: 28px 20px 80px; }
h1 { font-size: 23px; margin: 0 0 4px; }
.sub { color: var(--ink-2); margin: 0 0 24px; max-width: 62ch; }
.section-h { font-size: 13px; text-transform: uppercase; letter-spacing: .06em;
             color: var(--ink-2); margin: 28px 0 4px; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 11px; padding: 15px 17px; margin-bottom: 12px;
}
.card h2 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-2); margin: 0 0 12px; font-weight: 650;
}

.delivery-row { display: flex; gap: 18px; align-items: flex-end; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--ink-2); }
.field select {
  padding: 7px 10px; font: inherit; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
}
.field select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
#delivery-note { margin: 12px 0 0; }

.reports { margin-top: 10px; }
.report { transition: border-color .12s; }
/* Selected state: a border and an inset rule, so it is not colour alone. */
.report.on { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }

.report-head {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  font-weight: 600;
}
.report-head input { width: 17px; height: 17px; accent-color: var(--accent); flex: 0 0 auto; }
.report-title { font-size: 15px; }
.report-desc { margin: 6px 0 0 27px; max-width: 70ch; }
.report-scope { margin: 8px 0 0 27px; }

.projects { margin: 10px 0 0 27px; }
.projects > summary {
  display: flex; align-items: baseline; gap: 8px; cursor: pointer;
  list-style: none; font-size: 13px; color: var(--ink-2);
  padding: 5px 9px; border: 1px solid var(--line); border-radius: 8px;
  width: fit-content;
}
.projects > summary::-webkit-details-marker { display: none; }
.projects > summary::before {
  content: "▸"; font-size: 10px; color: var(--muted);
}
.projects[open] > summary::before { content: "▾"; }
.projects > summary:hover { border-color: var(--accent); }
.projects-label { font-weight: 600; color: var(--ink); }
.projects-summary { color: var(--ink-2); }

.projects-list {
  margin-top: 8px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 9px; background: var(--surface-2);
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 4px;
}
.project-row {
  display: flex; align-items: baseline; gap: 8px; padding: 4px 5px;
  border-radius: 6px; cursor: pointer; font-size: 14px;
}
.project-row:hover { background: var(--surface); }
.project-row input { accent-color: var(--accent); }
.project-key { font-weight: 600; font-variant-numeric: tabular-nums; }
.project-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.actions {
  display: flex; align-items: center; gap: 10px; margin-top: 22px;
  padding-top: 18px; border-top: 1px solid var(--line);
}
.status { font-size: 13px; color: var(--ink-2); }
.status.ok { color: var(--good-fg); }
.status.err { color: var(--bad-fg); }

.btn {
  font: inherit; padding: 8px 15px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  text-decoration: none; display: inline-block;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}
@media (prefers-color-scheme: dark) { .btn.primary { color: #0b1220; } }
.btn.quiet { color: var(--ink-2); font-size: 14px; }

.notice { margin: 14px 20px 0; padding: 12px 15px; border-radius: 10px; font-size: 14px; }
.notice.info { background: var(--info-bg); border: 1px solid var(--info-line); color: var(--info-fg); }
.notice.warn { background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-fg); }
.notice.err  { background: var(--bad-bg);  border: 1px solid var(--bad-line);  color: var(--bad-fg); }

@media (max-width: 620px) {
  .topnav { overflow-x: auto; }
  .delivery-row { gap: 12px; }
  .report-desc, .report-scope, .projects { margin-left: 0; }
}


/* ---------- run a report ---------- */

.report-actions {
  display: flex; align-items: center; gap: .6rem;
  margin: 10px 0 0 27px;
}
.run-note { min-height: 1.2em; }

/* NO `display` here. A <dialog> is display:none while closed, and setting
   display unconditionally overrides that - the element then renders in
   normal page flow, permanently visible, and showModal() cannot position
   something that is already laid out inline. The symptom is the "modal"
   appearing as a panel at the bottom of the page with no backdrop. */
.run-dialog {
  width: min(1100px, 94vw); max-height: 86vh; padding: 0;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink);
  overflow: hidden;
}
/* Flex only once it is open, so the header stays put while the rows scroll -
   a 50-row report with its title scrolled away is one you cannot identify. */
.run-dialog[open] { display: flex; flex-direction: column; }

.run-dialog::backdrop { background: rgba(17, 24, 39, .45); }
.run-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--line); flex: 0 0 auto;
}
.run-head h2 { font-size: 17px; margin: 0 0 2px; }
.run-head p { margin: 0; max-width: 70ch; }
/* Between the header and the scroll area, so the box you are typing in does
   not scroll away with the rows it is filtering. */
.run-filter {
  flex: 0 0 auto; margin: 0;
  padding: 10px 18px; border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.run-filter .dt-search { background: var(--surface); }

.run-body { overflow: auto; padding: 0 18px 18px; flex: 1 1 auto; }

.run-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.run-table th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--ink-2); font-weight: 650;
  background: var(--surface); padding: 12px 10px 8px;
  border-bottom: 1px solid var(--line);
}
.run-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.run-table tr:hover td { background: var(--surface-2); }
.run-table .key { white-space: nowrap; font-variant-numeric: tabular-nums; }
.run-table .key a { color: var(--accent); text-decoration: none; font-weight: 600; }
.run-table .key a:hover { text-decoration: underline; }
.run-table .summary { width: 48%; }
.run-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.run-overdue td { background: var(--bad-bg); }
.run-overdue .due { color: var(--bad-fg); font-weight: 600; }
.run-empty { padding: 36px 10px; text-align: center; color: var(--ink-2); }
