/* William Avery Command Center — calm, readable, no framework. */
:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f1efea;
  --text: #1d1c1a;
  --muted: #6b6862;
  --faint: #9a968f;
  --line: #e4e1da;
  --accent: #2f5d50;
  --accent-soft: #e3eee9;
  --good: #2e7d4f;
  --good-soft: #e2f2e8;
  --warn: #a96500;
  --warn-soft: #fbefd9;
  --bad: #b3261e;
  --bad-soft: #fbe4e1;
  --info-soft: #e6edf7;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 18, 14, 0.04), 0 1px 1px rgba(20, 18, 14, 0.03);
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141412;
    --surface: #1c1c19;
    --surface-2: #24241f;
    --text: #ecebe6;
    --muted: #a4a198;
    --faint: #7a776f;
    --line: #2f2f2a;
    --accent: #7fbfa9;
    --accent-soft: #1f3530;
    --good: #6fcf97;
    --good-soft: #17301f;
    --warn: #f2b25c;
    --warn-soft: #3a2b12;
    --bad: #f28b82;
    --bad-soft: #3b1b18;
    --info-soft: #1e2633;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; }
p { margin: 0.25rem 0 0.75rem; }
small, .muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); font-size: 0.85em; }

/* ---- shell ---- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1240px; margin: 0 auto; padding: 0.6rem 1.25rem;
  display: flex; align-items: center; gap: 1.25rem;
}
.brand { font-weight: 700; color: var(--text); white-space: nowrap; letter-spacing: -0.01em; }
.brand span { color: var(--muted); font-weight: 500; }
.nav { display: flex; gap: 0.15rem; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  color: var(--muted); padding: 0.35rem 0.7rem; border-radius: 8px; white-space: nowrap; font-size: 0.92rem;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.topbar form { margin: 0; }
main { max-width: 1240px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

/* ---- layout ---- */
.grid { display: grid; gap: 1rem; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
@media (max-width: 960px) {
  .cols-3, .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .cols-2, .cols-3, .cols-4 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  main { padding: 1rem 0.85rem 3rem; }
  .topbar-inner { padding: 0.5rem 0.85rem; gap: 0.75rem; }
  .brand span { display: none; }
}
.section { margin-top: 2rem; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 0.75rem;
}
.section-head h2 { font-size: 1.1rem; }
.section-head .meta { color: var(--muted); font-size: 0.85rem; }
.stack > * + * { margin-top: 0.75rem; }
.row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; box-shadow: var(--shadow); min-width: 0;
}
.card h3 { margin-bottom: 0.5rem; }
.card.flush { padding: 0; }
.card.flush > .card-head { padding: 0.9rem 1.2rem 0.4rem; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; margin-bottom: 0.4rem; }
.card-head h3 { margin: 0; }
.label { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }

/* ---- header / status ---- */
.hero { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr); gap: 1rem; }
@media (max-width: 860px) { .hero { grid-template-columns: minmax(0, 1fr); } }
.hero .goal { font-size: 1.3rem; font-weight: 600; letter-spacing: -0.01em; margin: 0.2rem 0 0.9rem; }
.hero .bottleneck { font-size: 1.02rem; margin-top: 0.2rem; }
.status-big { font-size: 1.5rem; font-weight: 700; margin: 0.25rem 0; }
details.edit { margin-top: 0.75rem; }
details.edit summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; list-style: none; }
details.edit summary::-webkit-details-marker { display: none; }
details.edit summary::before { content: "✎ "; }
details.edit[open] summary { margin-bottom: 0.6rem; }

/* ---- pills ---- */
.pill {
  display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.1rem 0.55rem; border-radius: 999px;
  font-size: 0.78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.pill.good, .pill.on_track, .pill.done, .pill.ready, .pill.ok { background: var(--good-soft); color: var(--good); }
.pill.warn, .pill.at_risk, .pill.in_progress, .pill.medium { background: var(--warn-soft); color: var(--warn); }
.pill.bad, .pill.off_track, .pill.error, .pill.high { background: var(--bad-soft); color: var(--bad); }
.pill.info, .pill.hot { background: var(--info-soft); color: var(--accent); }
.pill.low, .pill.not_started, .pill.never, .pill.not_configured { background: var(--surface-2); color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--faint); }
.dot.ok { background: var(--good); } .dot.error { background: var(--bad); } .dot.never { background: var(--warn); }

/* ---- numbers ---- */
.kpi .value { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.kpi .value small { font-size: 0.9rem; font-weight: 500; }
.kpi .name { color: var(--muted); font-size: 0.85rem; margin-top: 0.2rem; }
.kpi .sub { margin-top: 0.35rem; font-size: 0.82rem; color: var(--muted); display: flex; gap: 0.5rem; align-items: center; }
.delta { font-size: 0.8rem; font-weight: 650; white-space: nowrap; }
.delta.up { color: var(--good); } .delta.down { color: var(--bad); } .delta.flat { color: var(--faint); }
.spark { color: var(--accent); vertical-align: middle; }

/* ---- outcomes ---- */
.outcome .num { font-size: 0.8rem; color: var(--faint); font-weight: 700; }
.outcome .title { font-size: 1.05rem; font-weight: 650; margin: 0.15rem 0 0.6rem; }
.outcome.empty { border-style: dashed; color: var(--muted); }
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.progress.done > span { background: var(--good); }
.progress.at_risk > span { background: var(--warn); }
.progress.off_track > span { background: var(--bad); }
.meta-list { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; font-size: 0.85rem; color: var(--muted); margin-top: 0.6rem; }

/* ---- lists ---- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 0.55rem 0; border-top: 1px solid var(--line); display: flex; gap: 0.6rem; align-items: baseline; }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { overflow-wrap: anywhere; }
.list .sub { font-size: 0.82rem; color: var(--muted); }
.empty-note { color: var(--faint); font-size: 0.9rem; padding: 0.4rem 0; }
.group-label { margin: 0.9rem 0 0.2rem; }
.group-label:first-child { margin-top: 0; }

.banner {
  padding: 0.6rem 0.9rem; border-radius: 10px; font-size: 0.9rem; font-weight: 600; margin-bottom: 0.75rem;
}
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.good { background: var(--good-soft); color: var(--good); }
.notice { background: var(--accent-soft); color: var(--accent); padding: 0.55rem 0.9rem; border-radius: 10px; margin-bottom: 1rem; font-weight: 600; }

/* ---- attention ---- */
.attention li { align-items: flex-start; }
.attention .sev { width: 6px; align-self: stretch; border-radius: 3px; background: var(--faint); flex: none; }
.attention .sev.high { background: var(--bad); }
.attention .sev.medium { background: var(--warn); }
.attention .sev.low { background: var(--line); }
.attention .why { font-weight: 600; }
.attention .src { font-size: 0.75rem; color: var(--faint); white-space: nowrap; }

/* ---- funnel ---- */
.funnel { display: grid; gap: 0.45rem; }
.funnel .stage { display: grid; grid-template-columns: 8.5rem 1fr 3.5rem; gap: 0.6rem; align-items: center; font-size: 0.9rem; }
.funnel .bar { height: 22px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.funnel .bar > span { display: block; height: 100%; background: var(--accent); opacity: 0.85; border-radius: 6px; min-width: 2px; }
.funnel .val { text-align: right; font-weight: 650; }
.funnel .conv { grid-column: 2 / 4; font-size: 0.75rem; color: var(--muted); margin: -0.25rem 0 0; }
@media (max-width: 520px) { .funnel .stage { grid-template-columns: 6.5rem 1fr 2.8rem; } }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.55rem 0.6rem; border-top: 1px solid var(--line); vertical-align: top; }
thead th { border-top: 0; color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.problem td { background: color-mix(in srgb, var(--bad-soft) 45%, transparent); }

/* ---- calendar ---- */
.cal-day { margin-top: 0.8rem; }
.cal-day:first-child { margin-top: 0; }
.event { display: grid; grid-template-columns: 4.8rem 1fr; gap: 0.6rem; padding: 0.3rem 0; font-size: 0.9rem; }
.event .time { color: var(--muted); font-variant-numeric: tabular-nums; }
.event.discovery .what::before, .event.interview .what::before, .event.client .what::before, .event.focus .what::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 0.4rem; vertical-align: 1px;
}
.event.discovery .what::before { background: var(--accent); }
.event.interview .what::before { background: var(--warn); }
.event.client .what::before { background: var(--good); }
.event.focus .what::before { background: var(--faint); }
.hours { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.6rem; }

/* ---- forms ---- */
label { display: block; font-size: 0.82rem; color: var(--muted); font-weight: 600; margin-bottom: 0.25rem; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 0.5rem 0.65rem;
}
textarea { min-height: 4.5rem; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.field { margin-bottom: 0.8rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.checkbox { display: flex; gap: 0.45rem; align-items: center; font-weight: 500; color: var(--text); }
button, .button {
  font: inherit; font-weight: 600; font-size: 0.9rem; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: #fff; padding: 0.45rem 0.9rem; cursor: pointer; display: inline-block;
}
@media (prefers-color-scheme: dark) { button, .button { color: #0f1a17; } }
button.secondary, .button.secondary { background: transparent; color: var(--accent); }
button.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
button.small, .button.small { padding: 0.2rem 0.6rem; font-size: 0.8rem; }
button.danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.inline-form { display: inline; margin: 0; }

.ext::after { content: " ↗"; font-size: 0.8em; color: var(--faint); }
.tabs { display: flex; gap: 0.4rem; margin-bottom: 0.8rem; flex-wrap: wrap; }
.tabs a { padding: 0.25rem 0.7rem; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-size: 0.85rem; }
.tabs a.active { background: var(--accent); color: #fff; }
.login { max-width: 380px; margin: 12vh auto 0; }
.login h1 { font-size: 1.25rem; margin-bottom: 0.25rem; }
.integration { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; padding: 0.8rem 0; border-top: 1px solid var(--line); }
.integration:first-child { border-top: 0; }
.err { color: var(--bad); font-size: 0.82rem; overflow-wrap: anywhere; }
.scorecard td.spark-cell { width: 110px; }
.learning blockquote { margin: 0.2rem 0 0.3rem; font-size: 0.98rem; }
.footer { margin-top: 3rem; color: var(--faint); font-size: 0.8rem; text-align: center; }
.resource-row { display: grid; grid-template-columns: 2fr 3fr 1.2fr 0.6fr auto; gap: 0 0.6rem; align-items: end; }
.resource-row.new { grid-template-columns: 2fr 3fr 1.2fr auto; margin-top: 0.6rem; padding-top: 0.6rem; border-top: 1px solid var(--line); }
@media (max-width: 760px) {
  .resource-row, .resource-row.new { grid-template-columns: minmax(0, 1fr); padding-bottom: 0.6rem; border-bottom: 1px solid var(--line); }
}
