/* Porchlight Operations: the owner's dashboard. Porchlight's colours, light and dark. */
:root {
  --bg: #efebe2; --surface: #ffffff; --oat: #f4f0e8; --line: #dad3c7; --line-strong: #cfc7b8;
  --ink: #1c2230; --ink-2: #4a505e; --ink-3: #585d6a;
  --primary: #26334d; --on-primary: #ffffff; --primary-tint: #e9ecf2;
  --bar: #3e5277; --bar-hover: #26334d; --grid: #e6e0d4;
  --ok: #3f7d5c; --ok-tint: #e5efe8; --warn: #9c6118; --warn-tint: #f8eddd; --stop: #b2433a; --stop-tint: #f7e3e0;
  --glow: #f4b740; --glow-tint: #fdf1d8;
  --shadow: 0 2px 6px rgba(24, 32, 38, .05), 0 12px 32px rgba(60, 45, 25, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121419; --surface: #1b1e25; --oat: #23262f; --line: #343843; --line-strong: #444a57;
    --ink: #eef0f4; --ink-2: #c3c7d0; --ink-3: #9aa0ac;
    --primary: #b9c6e4; --on-primary: #121419; --primary-tint: #262c3a;
    --bar: #8fa3cf; --bar-hover: #c4d1f0; --grid: #2a2e38;
    --ok: #7cc39c; --ok-tint: #1e2e25; --warn: #e6b36b; --warn-tint: #33291a; --stop: #f08a80; --stop-tint: #3a2220;
    --glow-tint: #3a3020;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.5rem; font-weight: 800; }
h2 { font-size: 1.1rem; font-weight: 750; }
.muted { color: var(--ink-3); }
.small { font-size: .85rem; }
.error { color: var(--stop); background: var(--stop-tint); border-radius: 10px; padding: 8px 12px; margin: 8px 0; }
.mono { font-family: var(--mono); font-size: .85em; }

/* ---------- Top and tabs ---------- */
.top { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1080px; margin: 0 auto; padding: 12px 20px 6px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.1rem; color: var(--ink); text-decoration: none; }
.brand-sub { font-weight: 500; color: var(--ink-3); }
.brand-mark { width: 26px; height: 26px; border-radius: 8px; background: var(--primary); position: relative; }
.brand-mark::after { content: ""; position: absolute; inset: 8px 10px 7px; border-radius: 3px; background: var(--glow); }
.env { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 3px 9px; border-radius: 99px; background: var(--glow-tint); color: var(--warn); }
.env.production { background: var(--stop-tint); color: var(--stop); }
.who { margin-left: auto; font-size: .85rem; color: var(--ink-3); }
/* Signs out of Cloudflare Access for this dashboard (its own /cdn-cgi/access/logout). */
.logout { font-size: .85rem; font-weight: 600; color: var(--ink-2); padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; white-space: nowrap; }
.logout:hover, .logout:focus-visible { color: var(--ink); border-color: var(--ink-3); }
.tabs { max-width: 1080px; margin: 0 auto; padding: 0 12px; display: flex; gap: 4px; overflow-x: auto; }
.tabs a { padding: 10px 12px; color: var(--ink-2); text-decoration: none; font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--primary); }
.main { max-width: 1080px; margin: 0 auto; padding: 24px 20px 64px; display: grid; gap: 20px; }

/* ---------- Cards, tiles, chips ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.card > h2 { margin-bottom: 4px; }
.card > .muted { margin: 0 0 14px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; }
.tile-n { font-size: 1.9rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile-l { color: var(--ink-2); font-size: .9rem; }
.tile-s { color: var(--ink-3); font-size: .8rem; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; font-size: .85rem; font-weight: 600; background: var(--oat); color: var(--ink-2); }
.chip.ok { background: var(--ok-tint); color: var(--ok); }
.chip.bad { background: var(--stop-tint); color: var(--stop); }
.chip.warn { background: var(--warn-tint); color: var(--warn); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }

/* ---------- Chart: families started per week ---------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis { fill: var(--ink-3); font-size: 11px; font-family: var(--font); }
.chart .bar { fill: var(--bar); pointer-events: none; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .bar.on { fill: var(--bar-hover); }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--bg); font-size: .8rem; padding: 6px 9px; border-radius: 8px; white-space: nowrap; transform: translate(-50%, -100%); }
details.table-view { margin-top: 8px; }
details.table-view summary { cursor: pointer; color: var(--ink-3); font-size: .85rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--ink-3); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.sub td { background: var(--oat); }
.status { font-weight: 700; font-size: .8rem; }
.status.active, .status.available, .status.applied { color: var(--ok); }
.status.revoked, .status.refused, .status.expired, .status.ended { color: var(--stop); }
.status.scheduled, .status.used_up { color: var(--warn); }

/* ---------- Forms and buttons ---------- */
form.fields { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
label.field { display: grid; gap: 4px; font-size: .85rem; font-weight: 600; color: var(--ink-2); }
input, select { font: inherit; font-size: .95rem; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); min-height: 40px; }
input:focus-visible, select:focus-visible, .btn:focus-visible, .tabs a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
input.wide { min-width: 280px; }
.btn { font: inherit; font-weight: 700; font-size: .9rem; padding: 9px 16px; min-height: 40px; border-radius: 99px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn.danger { color: var(--stop); border-color: var(--stop); }
.btn.small { padding: 5px 12px; min-height: 32px; font-size: .82rem; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
.row-end { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.codes { font-family: var(--mono); font-size: 1rem; background: var(--glow-tint); border-radius: 12px; padding: 14px 16px; white-space: pre-wrap; margin: 10px 0; }
.note { background: var(--glow-tint); border-radius: 12px; padding: 10px 14px; color: var(--ink); }

/* ---------- The confirm dialog ---------- */
.dialog { border: 1px solid var(--line); border-radius: 18px; padding: 22px; max-width: 460px; width: calc(100% - 32px); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(20, 22, 30, .45); }
.dialog .summary { font-size: 1.05rem; font-weight: 600; margin: 10px 0 6px; }

@media (max-width: 600px) {
  .who { margin-left: 0; width: 100%; }
  input.wide { min-width: 0; width: 100%; }
}

/* The families list */
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
a.chip { text-decoration: none; }
.chip.on { background: var(--primary); color: var(--on-primary); }
tr.click { cursor: pointer; }
tr.click:hover td, tr.click:focus-visible td { background: var(--oat); }
tr.click:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.status.trial { color: var(--warn); }
.status.pass { color: var(--ok); }
.status.none { color: var(--ink-3); }
.strong { font-weight: 700; color: var(--ink); }
