:root {
  --bg: #f6f7f9; --panel: #ffffff; --ink: #1d2330; --muted: #5d6677; --line: #dde1e8; --accent: #1f5fbf;
  --ok: #1e7a46; --ok-bg: #e6f4ec; --warn: #9a5b00; --warn-bg: #fdf1dd; --bad: #b42318; --bad-bg: #fdecea;
  --chip: #eef1f6; --grid: #e8ebf0; --mark: #1f5fbf; --mark-hi: #3b7be0; --tip-bg: #1d2330; --tip-ink: #ffffff; font-size: 15px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14171c; --panel: #1c2027; --ink: #e6e9ef; --muted: #9aa3b2; --line: #2e343e; --accent: #6ea1ff;
          --ok: #5cc98a; --ok-bg: #16301f; --warn: #f0b45a; --warn-bg: #33270f; --bad: #ff8a80; --bad-bg: #3a1a18; --chip: #262b34;
          --grid: #262b34; --mark: #6ea1ff; --mark-hi: #9bbfff; --tip-bg: #e6e9ef; --tip-ink: #14171c; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: system-ui, -apple-system, "Segoe UI", sans-serif; line-height: 1.45; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
header { display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
header .brand { font-weight: 650; }
header .site { color: var(--muted); font-size: 13px; }
header .me { margin-left: auto; color: var(--muted); font-size: 13px; }
main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 60px; }
h1 { font-size: 22px; margin: 4px 0 4px; } h2 { font-size: 17px; margin: 26px 0 8px; } .sub { color: var(--muted); margin: 0 0 14px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; margin: 10px 0; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.wrap { overflow-x: auto; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 10px; background: var(--chip); font-size: 12px; white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); } .chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.flash { padding: 8px 12px; border-radius: 6px; margin: 8px 0; } .flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--bad-bg); color: var(--bad); }
button, .btn { font: inherit; padding: 6px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { border-color: var(--bad); color: var(--bad); }
button:disabled { opacity: .45; cursor: not-allowed; }
input[type=text], input[type=email], input[type=password], input[type=date], select, textarea {
  font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); max-width: 100%; }
.steps { counter-reset: s; }
.step { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.step:last-child { border-bottom: 0; }
.step .n { counter-increment: s; width: 24px; height: 24px; border-radius: 50%; background: var(--chip); display: grid; place-items: center; font-size: 12px; }
.step .n::before { content: counter(s); }
.step .t { font-weight: 600; } .step .d { color: var(--muted); font-size: 13.5px; } .step .meta { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.step .actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
pre.log { background: #0f1115; color: #d8dee9; padding: 12px; border-radius: 8px; max-height: 460px; overflow: auto; font-size: 12.5px; white-space: pre-wrap; }
.dec { border-left: 4px solid var(--line); } .dec.open { border-left-color: var(--warn); } .dec.confirmed { border-left-color: var(--ok); }
.dec .head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; } .dec .id { font-family: ui-monospace, monospace; font-size: 13px; color: var(--muted); }
.dec .q { margin: 6px 0 8px; } .dec ul.ev { margin: 4px 0 10px; padding-left: 18px; color: var(--muted); font-size: 13.5px; }
.dec .who { font-size: 12.5px; color: var(--muted); }
.form-row { display: flex; gap: 10px; align-items: center; margin: 6px 0; flex-wrap: wrap; } .form-row label { min-width: 230px; color: var(--muted); font-size: 13.5px; }
.opts label { display: block; margin: 3px 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0 4px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; }
.login { max-width: 380px; margin: 60px auto; }
.login input { width: 100%; margin: 4px 0 12px; }
details summary { cursor: pointer; color: var(--accent); }
@media (max-width: 640px) { .step { grid-template-columns: 24px 1fr; } .step .actions { grid-column: 2; justify-content: flex-start; } .form-row label { min-width: 0; } }

/* ---- header nav ---- */
header nav { display: flex; gap: 14px; font-size: 14px; }
header nav a { color: var(--muted); } header nav a[aria-current=page] { color: var(--ink); font-weight: 600; }

/* ---- dashboard: site cards ---- */
.sitecards { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 12px; margin-top: 14px; }
.sitecard { margin: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.sc-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.sc-name { font-weight: 650; font-size: 17px; } .sc-host { color: var(--muted); font-size: 12.5px; }
dl.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 4px 0; }
dl.kv div { min-width: 0; } dl.kv dt { color: var(--muted); font-size: 12.5px; } dl.kv dd { margin: 0; font-size: 20px; font-weight: 600; }
dl.kv small, .tile-sub, .sc-meta, .sc-note { color: var(--muted); font-size: 12.5px; font-weight: 400; }
.sc-meta, .sc-note { margin: 0; }
.sc-refresh { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.sc-refresh input { flex: 1 1 140px; min-width: 0; }
.linkish { border: 0; background: none; padding: 0; color: var(--accent); font-size: inherit; cursor: pointer; }
.errs ul { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.errs summary { list-style: none; } .errs summary::-webkit-details-marker { display: none; }
.sitecard .flash { margin: 0; font-size: 13px; }

/* ---- dashboard: procurement and payments ---- */
.fin-head { margin-bottom: 8px; } .fin-head .sub { margin-left: 6px; }
.fin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 18px; }
.tile { min-width: 0; }
.tile.muted, .sitecard.muted { opacity: .78; }
.tile-site { font-size: 13px; color: var(--muted); font-weight: 600; display: flex; gap: 6px; align-items: center; }
.hero { font-size: 28px; font-weight: 650; margin: 2px 0 0; letter-spacing: -.01em; }
.tile-empty { color: var(--muted); font-size: 13.5px; margin: 10px 0; }
svg.cols { width: 100%; height: auto; display: block; margin-top: 8px; overflow: visible; }
svg.cols .grid { stroke: var(--grid); stroke-width: 1; }
svg.cols .tick { fill: var(--muted); font-size: 9.5px; font-variant-numeric: tabular-nums; }
svg.cols .cap { fill: var(--ink); font-size: 10px; font-weight: 600; }
svg.cols .mark { fill: var(--mark); }
svg.cols .bar { cursor: default; outline: none; }
svg.cols .bar:hover .mark, svg.cols .bar:focus .mark { fill: var(--mark-hi); }
svg.cols .bar:focus-visible .hit { stroke: var(--accent); stroke-width: 1; }
ul.states { list-style: none; margin: 8px 0 0; padding: 0; font-size: 12.5px; display: grid; gap: 2px; }
ul.states li { display: flex; align-items: center; gap: 6px; } ul.states .num { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex: none; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
details.monthly { margin-top: 10px; font-size: 13px; }
.tip { position: fixed; z-index: 20; background: var(--tip-bg); color: var(--tip-ink); padding: 4px 8px; border-radius: 6px; font-size: 12.5px;
       pointer-events: none; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---- dashboard: matrices ---- */
.matrix .pin { color: var(--muted); font-size: 12px; font-family: ui-monospace, monospace; }
.matrix small { font-size: 12px; }
.steps-matrix th.c, .steps-matrix td.c { text-align: center; white-space: nowrap; }
.steps-matrix th.c { font-size: 11.5px; }
.st { display: inline-block; min-width: 46px; padding: 0 6px; border-radius: 4px; font-size: 11.5px; background: var(--chip); color: var(--muted); }
.st.ok { background: var(--ok-bg); color: var(--ok); } .st.warn { background: var(--warn-bg); color: var(--warn); } .st.bad { background: var(--bad-bg); color: var(--bad); }
.na { color: var(--line); font-size: 11.5px; }
.legend { display: inline-flex; gap: 4px; margin-left: 8px; }
details.bycompany summary { color: var(--ink); } details.bycompany table { margin-top: 8px; }
.defs dl { margin: 0; } .defs dt { font-weight: 600; margin-top: 8px; } .defs dt:first-child { margin-top: 0; }
.defs dd { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; max-width: 75ch; }
@media (max-width: 640px) { header { flex-wrap: wrap; } header .me { margin-left: 0; } .hero { font-size: 24px; } }
form.inline { display: inline; }
.sub.online { margin-top: 10px; }
.refreshbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 4px 0 0; }
.login label { display: block; color: var(--muted); font-size: 13.5px; }
