/* Layout: fixed client rail on the left, client workspace on the right; stacks on phones */
:root {
  --bg: #f4f6f5; --surface: #ffffff; --raised: #eef2f0; --fg: #18211f; --muted: #5d6b67; --line: #d8dfdc;
  --accent: #0f6b5c; --accent-soft: #dff0eb;
  --ok: #2c7a3f; --ok-soft: #e1f2e5; --warn: #9a5a0c; --warn-soft: #fbeedd; --bad: #a3302a; --bad-soft: #f8e2e0;
  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --body: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111715; --surface: #19211f; --raised: #212b28; --fg: #e3eae7; --muted: #98a7a2; --line: #2d3936;
    --accent: #5cc3ad; --accent-soft: #1b3530;
    --ok: #7fcf93; --ok-soft: #1c3223; --warn: #e6a35a; --warn-soft: #39291a; --bad: #ef8a83; --bad-soft: #3b201f;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 16px/1.5 var(--body); }
code { font-family: var(--mono); font-size: .85em; background: var(--raised); padding: 1px 5px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--display); margin: 0; line-height: 1.2; text-wrap: balance; }
button { font: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--surface); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand b { font-family: var(--display); font-size: 1.2rem; }
.brand .sub { color: var(--muted); font-size: .85rem; }
.mark { width: 22px; height: 22px; border-radius: 6px; background: conic-gradient(var(--accent) 0 70%, var(--accent-soft) 0); }
.config { display: flex; gap: 8px; flex-wrap: wrap; }

.layout { display: grid; grid-template-columns: 260px 1fr; min-height: calc(100vh - 58px); }
aside { border-right: 1px solid var(--line); padding: 20px 16px; display: flex; flex-direction: column; gap: 12px; }
.label { font-family: var(--mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.clients { display: flex; flex-direction: column; gap: 6px; }
.client-link { text-align: left; border: 1px solid transparent; background: none; color: var(--fg); padding: 10px 12px; border-radius: 8px; display: grid; gap: 2px; }
.client-link:hover { background: var(--raised); }
.client-link.active { background: var(--surface); border-color: var(--line); }
.client-link .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.client-link .name { font-weight: 600; }
.client-link .meta { font-size: .8rem; color: var(--muted); font-family: var(--mono); }
.hint { font-size: .82rem; color: var(--muted); margin: 8px 0 0; }

main { padding: 24px clamp(16px, 3vw, 36px) 60px; min-width: 0; display: flex; flex-direction: column; gap: 22px; }
.empty { color: var(--muted); }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.head h1 { font-size: 1.8rem; }
.head .domain { color: var(--muted); font-family: var(--mono); font-size: .85rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { border: 1px solid var(--line); background: var(--surface); color: var(--fg); padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: .92rem; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.btn[disabled] { opacity: .55; cursor: progress; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stat .k { font-family: var(--mono); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.stat .v { font-family: var(--display); font-size: 2rem; font-variant-numeric: tabular-nums; }
.stat .s { font-size: .85rem; color: var(--muted); }
.spark { width: 100%; height: 36px; display: block; }
.spark path.area { fill: var(--accent-soft); }
.spark path.line { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.spark circle { fill: var(--accent); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.tab.active { color: var(--fg); border-bottom-color: var(--accent); }
.tab .count { font-family: var(--mono); font-size: .75rem; margin-left: 4px; }

.panel { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.tbl { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-family: var(--mono); font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 500; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num { font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: .85rem; white-space: nowrap; }
td .fix { color: var(--muted); font-size: .85rem; display: block; margin-top: 2px; }

.pill { display: inline-block; font-family: var(--mono); font-size: .72rem; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.pill.green, .pill.yes { background: var(--ok-soft); color: var(--ok); }
.pill.amber, .pill.medium { background: var(--warn-soft); color: var(--warn); }
.pill.red, .pill.critical, .pill.high { background: var(--bad-soft); color: var(--bad); }
.pill.low, .pill.no, .pill.off { background: var(--raised); color: var(--muted); }
.pill.on { background: var(--accent-soft); color: var(--accent); }
.pill.run { background: var(--accent-soft); color: var(--accent); }

details.answer summary { cursor: pointer; color: var(--accent); font-size: .85rem; }
details.answer p { white-space: pre-wrap; font-size: .88rem; margin: 6px 0 0; color: var(--muted); max-width: 75ch; }

.bars { display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.bar { display: grid; grid-template-columns: minmax(120px, 220px) 1fr 32px; gap: 10px; align-items: center; font-size: .88rem; }
.bar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .track { background: var(--raised); height: 8px; border-radius: 4px; overflow: hidden; }
.bar .fill { background: var(--accent); height: 100%; }
.bar .fill.own { background: var(--ok); }
.bar .n { font-family: var(--mono); font-size: .8rem; text-align: right; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.two h3 { font-size: 1rem; margin-bottom: 8px; }

.report { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px 22px; max-width: 80ch; }
.report h1 { font-size: 1.3rem; margin-bottom: 10px; }
.report h2 { font-size: 1.05rem; margin: 16px 0 6px; }
.report ul { margin: 4px 0; padding-left: 1.2em; }
.report p { margin: 6px 0; }
.report-list { display: flex; gap: 6px; flex-wrap: wrap; }

.note { background: var(--raised); border-radius: 10px; padding: 14px 16px; font-size: .92rem; }
.note ol, .note ul { margin: 6px 0 0; padding-left: 1.2em; }

.toast { position: fixed; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); right: 16px; background: var(--fg); color: var(--bg); padding: 10px 14px; border-radius: 8px; font-size: .9rem; max-width: calc(100vw - 32px); }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  aside { border-right: 0; border-bottom: 1px solid var(--line); }
  .clients { flex-direction: row; overflow-x: auto; }
  .client-link { min-width: 200px; }
}
@media (prefers-reduced-motion: no-preference) { .bar .fill { transition: width .4s ease; } }

/* ---------- accounts, issues, blog, settings ---------- */
.group { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.client-link.disabled { opacity: .55; }
.client-link .due { color: var(--warn); font-weight: 600; }
.stat .v small { font-size: .95rem; color: var(--muted); font-weight: 400; }

.filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--muted); padding: 5px 12px; border-radius: 999px; font-size: .85rem; font-weight: 600; }
.chip.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.filters .hint { margin: 0 0 0 6px; }
tr.is-done td { color: var(--muted); }
tr.is-done td:last-child { text-decoration: line-through; text-decoration-color: var(--line); }
td input[type="checkbox"], .check input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.warn-line { display: block; margin-top: 4px; font-size: .82rem; color: var(--warn); text-decoration: none; }
.link { background: none; border: 0; color: var(--accent); padding: 0; text-decoration: underline; font-size: inherit; }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form input { flex: 1 1 240px; }
input, select, textarea { font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0; }
textarea { resize: vertical; font-size: .92rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.topics { display: flex; flex-direction: column; gap: 10px; }
.topic { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.topic.open { border-color: var(--accent); }
.topic-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.topic-head > div:first-child { min-width: 0; flex: 1 1 320px; display: flex; flex-direction: column; gap: 4px; }
.topic h3 { font-size: 1.05rem; }
.muted { color: var(--muted); font-size: .88rem; margin: 0; }
.err { color: var(--bad); font-size: .88rem; margin: 0; }
.pill.st-idea { background: var(--raised); color: var(--muted); }
.pill.st-drafting { background: var(--accent-soft); color: var(--accent); }
.pill.st-review { background: var(--warn-soft); color: var(--warn); }
.pill.st-published { background: var(--ok-soft); color: var(--ok); }
.pill.st-rejected { background: var(--bad-soft); color: var(--bad); }
.pill { align-self: flex-start; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: var(--surface); }

.draft { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 12px; }
.meta-list { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; font-size: .9rem; }
.meta-list dt { color: var(--muted); }
.meta-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.confirm { background: var(--warn-soft); border-radius: 8px; padding: 10px 14px; font-size: .9rem; }
.confirm ul { margin: 6px 0 0; padding-left: 1.2em; }
.preview { max-width: 72ch; font-size: .98rem; }
.preview h2 { font-size: 1.2rem; margin: 18px 0 6px; }
.preview h3 { font-size: 1rem; margin: 14px 0 4px; }
.preview p { margin: 0 0 10px; }
.preview table { margin: 8px 0; }
.preview td, .preview th { border: 1px solid var(--line); }

.settings { display: flex; flex-direction: column; gap: 16px; }
fieldset { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 14px 16px 16px; margin: 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
legend { font-family: var(--display); font-weight: 600; padding: 0 6px; }
.settings label { display: flex; flex-direction: column; gap: 4px; font-size: .88rem; color: var(--muted); font-weight: 600; min-width: 0; }
.settings label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--fg); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px 14px; }
.actions.sticky { position: sticky; bottom: env(safe-area-inset-bottom, 0px); background: var(--bg); padding: 10px 0; }

.config { align-items: center; }
.user { font-size: .88rem; color: var(--muted); font-weight: 600; }

.btn.warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.ok-line { color: var(--ok); font-size: .9rem; margin: 0; font-weight: 600; }
.settings label .pill { margin-left: 6px; }
