/* Layout: a pale fairway ground with white scorecards; the leaderboard is the one deep-green board, with name plates like a tournament scoreboard. */
:root {
  --ground: #f2f4ef;
  --surface: #ffffff;
  --surface-2: #f0f3ed;
  --ink: #102017;
  --ink-2: #46554b;
  --muted: #74817a;
  --line: #dfe4dc;
  --line-strong: #c9d1c6;
  --accent: #1f5f3c;
  --accent-hover: #174c30;
  --accent-ink: #ffffff;
  --accent-wash: #e2eee5;
  --focus: #2f7de1;

  --board: #123d27;
  --board-ink: #f4f8f3;
  --board-muted: #9fbda9;
  --board-line: rgba(255, 255, 255, 0.16);
  --plate: #fbfcf8;
  --plate-ink: #13251a;
  --plate-muted: #6f7d74;
  --plate-up: #1b7a39;
  --plate-down: #b42318;
  --plate-track: #d6ddd3;

  --gold: #d99a00;
  --star-track: #dde3da;
  --good: #1a7f37;
  --good-wash: #e3f2e7;
  --warn: #93600a;
  --warn-wash: #faefd8;
  --bad: #b3261e;
  --bad-wash: #fbe8e6;
  --neutral: #5d6a62;
  --neutral-wash: #edf0eb;
  --danger: #b3261e;
  --live: #22a355;

  --shadow-lg: 0 10px 40px rgba(16, 32, 23, 0.16), 0 2px 6px rgba(16, 32, 23, 0.08);
  --backdrop: rgba(8, 20, 13, 0.45);
  --font-display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
  --font-body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #0b110d;
    --surface: #131b16;
    --surface-2: #1a241e;
    --ink: #e8efe9;
    --ink-2: #b1bfb5;
    --muted: #84928a;
    --line: #243029;
    --line-strong: #34433a;
    --accent: #52b47e;
    --accent-hover: #63c48e;
    --accent-ink: #06140c;
    --accent-wash: #173324;
    --focus: #6aa8ff;
    --board: #0f2c1d;
    --board-ink: #eef5ef;
    --board-muted: #8fae99;
    --board-line: rgba(255, 255, 255, 0.14);
    --plate: #e4ebe3;
    --plate-ink: #10221a;
    --plate-muted: #5f6d64;
    --plate-up: #17702f;
    --plate-down: #a91f15;
    --plate-track: #c2cbc0;
    --gold: #f2b631;
    --star-track: #2d3a32;
    --good: #5cc98a;
    --good-wash: #14301f;
    --warn: #e6ae4c;
    --warn-wash: #33270f;
    --bad: #f28b81;
    --bad-wash: #3a1916;
    --neutral: #a3b0a8;
    --neutral-wash: #1e2822;
    --danger: #c9372c;
    --live: #4fd083;
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
    --backdrop: rgba(0, 0, 0, 0.6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #0b110d;
  --surface: #131b16;
  --surface-2: #1a241e;
  --ink: #e8efe9;
  --ink-2: #b1bfb5;
  --muted: #84928a;
  --line: #243029;
  --line-strong: #34433a;
  --accent: #52b47e;
  --accent-hover: #63c48e;
  --accent-ink: #06140c;
  --accent-wash: #173324;
  --focus: #6aa8ff;
  --board: #0f2c1d;
  --board-ink: #eef5ef;
  --board-muted: #8fae99;
  --board-line: rgba(255, 255, 255, 0.14);
  --plate: #e4ebe3;
  --plate-ink: #10221a;
  --plate-muted: #5f6d64;
  --plate-up: #17702f;
  --plate-down: #a91f15;
  --plate-track: #c2cbc0;
  --gold: #f2b631;
  --star-track: #2d3a32;
  --good: #5cc98a;
  --good-wash: #14301f;
  --warn: #e6ae4c;
  --warn-wash: #33270f;
  --bad: #f28b81;
  --bad-wash: #3a1916;
  --neutral: #a3b0a8;
  --neutral-wash: #1e2822;
  --danger: #c9372c;
  --live: #4fd083;
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
  --backdrop: rgba(0, 0, 0, 0.6);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--ground);
  color: var(--ink);
  font: 15px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
body.modal-open { overflow: hidden; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.ico { width: 18px; height: 18px; flex: none; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.1; margin: 0; text-wrap: balance; letter-spacing: 0.01em; }
h1 { font-size: clamp(1.9rem, 1.4rem + 1.6vw, 2.6rem); }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
p { margin: 0; }
.eyebrow { margin-bottom: 4px; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.booting { padding: 40px 20px; color: var(--muted); text-align: center; }

/* ---------- tones (status always pairs with an icon + label) ---------- */
.tone-good { --tone: var(--good); --tone-wash: var(--good-wash); }
.tone-warn { --tone: var(--warn); --tone-wash: var(--warn-wash); }
.tone-bad { --tone: var(--bad); --tone-wash: var(--bad-wash); }
.tone-neutral { --tone: var(--neutral); --tone-wash: var(--neutral-wash); }

.chip, .flag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px 3px 7px; border-radius: 999px;
  background: var(--tone-wash); color: var(--tone);
  font-size: 0.78rem; font-weight: 600; white-space: nowrap; line-height: 1.4;
}
.chip .ico, .flag .ico { width: 14px; height: 14px; }
.badge {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--tone-wash); color: var(--tone);
}

/* ---------- stars ---------- */
.stars { display: block; flex: none; }
.st-track { fill: var(--star-track); }
.st-fill { fill: var(--gold); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1240px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 20px;
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  text-decoration: none; color: var(--accent);
  font-family: var(--font-display); font-weight: 700; font-size: 1.3rem;
  letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap;
}
.brand .ico { width: 22px; height: 22px; }
.nav { display: flex; gap: 2px; }
.nav-link { text-decoration: none; padding: 7px 12px; border-radius: 8px; color: var(--ink-2); font-weight: 500; }
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link[aria-current="page"] { background: var(--accent-wash); color: var(--accent); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.demo-chip {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--warn); background: var(--warn-wash); padding: 4px 8px; border-radius: 6px; white-space: nowrap;
}
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.live.on { color: var(--good); }
.live.on i { background: var(--live); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 50%, transparent); } 50% { box-shadow: 0 0 0 5px transparent; } }

.usermenu { position: relative; }
.usermenu summary {
  list-style: none; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: var(--accent-wash); color: var(--accent); font-weight: 700; font-size: 0.8rem;
}
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu-pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; width: 230px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 8px;
}
.usermenu-name { font-weight: 600; padding: 6px 10px 0; }
.usermenu-role { font-size: 0.8rem; color: var(--muted); padding: 0 10px 8px; border-bottom: 1px solid var(--line); margin-bottom: 6px; overflow-wrap: anywhere; }
.usermenu-pop button { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 8px; background: none; border: 0; }
.usermenu-pop button:hover { background: var(--surface-2); }

@media (max-width: 760px) {
  .topbar-inner { padding: 8px 16px; gap: 6px 12px; }
  .nav { order: 3; width: 100%; margin: 0 -12px; }
}
@media (max-width: 560px) {
  .btn-label, .demo-chip { display: none; }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 14px; border-radius: 9px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 0.9rem; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost-danger { background: transparent; border-color: transparent; color: var(--bad); }
.btn-ghost-danger:hover { background: var(--bad-wash); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #ffffff; }
.btn-danger:hover { background: var(--danger); filter: brightness(1.08); }
.btn-small { height: 30px; padding: 0 10px; font-size: 0.8rem; }
.btn-block { width: 100%; height: 44px; }
.btn:disabled { opacity: 0.6; cursor: progress; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 1.3rem; line-height: 1;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.danger:hover { background: var(--bad-wash); color: var(--bad); }

/* ---------- page frame ---------- */
.main {
  max-width: 1240px; margin: 0 auto; padding: 24px 20px 72px;
  display: flex; flex-direction: column; gap: 20px;
}
@media (max-width: 760px) { .main { padding: 18px 16px 56px; gap: 16px; } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; min-width: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 12px; }
.card-sub { font-size: 0.82rem; color: var(--muted); }
.empty { color: var(--muted); padding: 6px 0; }
.back { display: inline-flex; align-items: center; gap: 2px; width: fit-content; text-decoration: none; color: var(--ink-2); font-weight: 500; margin-bottom: -6px; }
.back:hover { color: var(--ink); }

/* ---------- stat tiles ---------- */
.section-label { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: -8px; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 960px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; min-width: 0; }
.tile-label { font-size: 0.82rem; font-weight: 600; color: var(--ink-2); }
.tile-value {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin: 6px 0 4px;
  font-family: var(--font-display); font-weight: 600; font-size: 2.5rem; line-height: 1;
}
.tile-note { font-size: 0.8rem; color: var(--muted); }
.delta { font-weight: 600; white-space: nowrap; }
.delta.good { color: var(--good); }
.delta.bad { color: var(--bad); }

/* ---------- dashboard ---------- */
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1000px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } }

/* the leaderboard */
.board { background: var(--board); color: var(--board-ink); border-radius: 16px; padding: 20px 18px 14px; min-width: 0; }
.board-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 12px 16px; padding: 0 2px; }
.board h2 { font-size: 2.2rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; line-height: 1; }
.board-sub { margin-top: 4px; font-size: 0.78rem; color: var(--board-muted); }
.board-tabs { display: flex; gap: 6px; overflow-x: auto; max-width: 100%; scrollbar-width: none; padding: 2px; }
.board-tab {
  font: 600 0.8rem/1 var(--font-display); letter-spacing: 0.1em; text-transform: uppercase; white-space: nowrap;
  color: var(--board-muted); background: transparent; border: 1px solid var(--board-line); padding: 7px 11px; border-radius: 999px;
}
.board-tab:hover { color: var(--board-ink); }
.board-tab[aria-selected="true"] { background: var(--board-ink); color: var(--board); border-color: var(--board-ink); }
.board-table { width: 100%; border-collapse: separate; border-spacing: 3px 5px; margin-top: 12px; }
.board-table th {
  font: 600 0.7rem/1 var(--font-display); letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--board-muted); text-align: left; padding: 2px 12px;
}
.board-table th.c, .board-table td.c { text-align: center; }
.board-table td { height: 42px; padding: 0; vertical-align: middle; }
.board-table .pos { width: 44px; text-align: center; font: 700 1.25rem/1 var(--font-display); color: var(--board-ink); white-space: nowrap; }
.plate {
  background: var(--plate); color: var(--plate-ink); border-radius: 3px; padding: 0 12px !important;
  font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; letter-spacing: 0.05em;
  text-transform: uppercase; white-space: nowrap;
}
.plate.name { width: 100%; max-width: 0; }
.plate.name a { display: block; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }
.plate.name a:hover { text-decoration: underline; }
.board-table .dept { color: var(--board-muted); font-size: 0.78rem; letter-spacing: 0.04em; padding: 0 8px; white-space: nowrap; }
.board-rating { display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.plate .st-track { fill: var(--plate-track); }
.chg { font-variant-numeric: tabular-nums; }
.chg.up { color: var(--plate-up); }
.chg.down { color: var(--plate-down); }
.chg.even { color: var(--plate-muted); }
.board-foot { margin-top: 6px; padding: 0 4px; font-size: 0.75rem; color: var(--board-muted); }
.board-empty { padding: 16px 4px 8px; color: var(--board-muted); }
@media (max-width: 680px) {
  .board-table .dept { display: none; }
  .board-stars { display: none; }
  .board h2 { font-size: 1.9rem; }
}

/* activity feed */
.feed-list { list-style: none; margin: 0; padding: 0; }
.feed-item { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.feed-item:first-child { border-top: 0; padding-top: 0; }
.feed-item.fresh { animation: fresh 2.5s ease-out; }
@keyframes fresh { from { background: var(--accent-wash); } to { background: transparent; } }
.feed-line a { font-weight: 600; text-decoration: none; }
.feed-line a:hover { text-decoration: underline; }
.feed-what { color: var(--ink-2); }
.feed-notes { margin-top: 2px; color: var(--ink-2); font-size: 0.9rem; overflow-wrap: anywhere; }
.feed-meta { margin-top: 4px; font-size: 0.78rem; color: var(--muted); }

/* needs attention */
.attn-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 10px; }
.attn-row {
  display: flex; align-items: center; gap: 12px; height: 100%;
  padding: 12px; border: 1px solid var(--line); border-radius: 12px; text-decoration: none;
}
.attn-row:hover { border-color: var(--line-strong); background: var(--surface-2); }
.attn-who { display: flex; flex-direction: column; min-width: 0; }
.attn-who span { font-size: 0.8rem; color: var(--muted); }
.attn-flags { margin-left: auto; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }

.avatar {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-wash); color: var(--accent); font-weight: 700; font-size: 0.8rem; letter-spacing: 0.02em;
}
.avatar-lg { width: 64px; height: 64px; font: 600 1.5rem/1 var(--font-display); letter-spacing: 0.04em; }

/* ---------- staff list ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; }
.search {
  flex: 1 1 260px; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--muted);
}
.search:focus-within { outline: 2px solid var(--focus); outline-offset: 1px; }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 1rem; }
.select {
  height: 40px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface); color: var(--ink); font-size: 0.95rem; max-width: 100%;
}
.table-card { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }
.staff-table { width: 100%; border-collapse: collapse; }
.staff-table th {
  text-align: left; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.staff-table td { padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.staff-table tbody tr { cursor: pointer; }
.staff-table tbody tr:hover { background: var(--surface-2); }
.staff-table tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.person { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.person a { font-weight: 600; text-decoration: none; }
.person a:hover { text-decoration: underline; }
.person small { display: block; color: var(--muted); font-size: 0.8rem; }
.rating-cell { display: flex; align-items: center; gap: 8px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ov-mark { color: var(--muted); display: inline-flex; }
.ov-mark .ico { width: 15px; height: 15px; }
.hot { color: var(--bad); font-weight: 700; }
.last-cell { color: var(--ink-2); font-size: 0.88rem; white-space: nowrap; }
@media (max-width: 760px) { .col-dept, .col-last { display: none; } }

/* ---------- profile ---------- */
.profile-head {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "av who rating" "actions actions actions";
  align-items: center; gap: 16px 18px; padding: 22px;
}
.profile-head .avatar-lg { grid-area: av; }
.profile-who { grid-area: who; min-width: 0; }
.profile-who p { margin-top: 4px; color: var(--ink-2); }
.profile-rating { grid-area: rating; text-align: right; }
.rating-row { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.rating-num { font: 600 2.1rem/1 var(--font-display); font-variant-numeric: tabular-nums; }
.rating-sub { margin-top: 6px; font-size: 0.82rem; color: var(--muted); }
.override-note { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 8px; font-size: 0.82rem; color: var(--muted); }
.override-reason { margin: 6px 0 0 auto; max-width: 360px; font-size: 0.88rem; color: var(--ink-2); overflow-wrap: anywhere; }
.profile-actions { grid-area: actions; display: flex; flex-wrap: wrap; gap: 8px; padding-top: 16px; border-top: 1px solid var(--line); }
@media (max-width: 760px) {
  .profile-head { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "av who" "rating rating" "actions actions"; padding: 18px; }
  .profile-rating { text-align: left; }
  .rating-row, .override-note { justify-content: flex-start; }
  .override-reason { margin-left: 0; }
}
.profile-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 20px; align-items: start; }
@media (max-width: 900px) { .profile-grid { grid-template-columns: minmax(0, 1fr); } }

.breakdown { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.breakdown td { padding: 7px 0; border-bottom: 1px solid var(--line); }
.breakdown td + td { padding-left: 12px; }
.breakdown .base td { color: var(--ink-2); }
.breakdown .total td { font-weight: 700; border-bottom: 0; border-top: 2px solid var(--ink); }
.pts.good { color: var(--good); }
.pts.bad { color: var(--bad); }
.fine { margin-top: 12px; font-size: 0.8rem; color: var(--muted); }

.chart { position: relative; min-height: 220px; }
.trend { display: block; overflow: visible; }
.trend .grid { stroke: var(--line); stroke-width: 1; }
.trend .baseline { stroke: var(--line-strong); stroke-width: 1; }
.trend .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.trend .area { fill: var(--accent); opacity: 0.1; }
.trend .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trend .end-dot, .trend .cross-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.trend .cross-line { stroke: var(--ink-2); stroke-width: 1; }
.trend .end-label { fill: var(--ink); font-size: 12px; font-weight: 700; }
.trend:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; border-radius: 4px; }
.tip {
  position: absolute; pointer-events: none; z-index: 2;
  background: var(--ink); color: var(--surface); padding: 6px 10px; border-radius: 8px;
  font-size: 0.8rem; white-space: nowrap; box-shadow: var(--shadow-lg);
}
.tip b { font-size: 1rem; margin-right: 6px; }

/* scorecard: positives circled, issues boxed, like birdies and bogeys */
.scorecard { width: 100%; min-width: 660px; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.scorecard th, .scorecard td { border: 1px solid var(--line-strong); text-align: center; padding: 5px 4px; font-size: 0.85rem; height: 38px; }
.scorecard thead th { font: 600 0.85rem/1 var(--font-display); letter-spacing: 0.04em; background: var(--surface-2); color: var(--ink-2); }
.scorecard tbody th { text-align: left; font-weight: 600; font-size: 0.82rem; padding: 5px 10px; white-space: nowrap; background: var(--surface-2); }
.scorecard .tot { font-weight: 700; background: var(--surface-2); }
.mark {
  display: inline-grid; place-items: center; width: 26px; height: 26px;
  border: 1.5px solid var(--tone); color: var(--tone); background: var(--tone-wash); font-weight: 700;
}
.mark.circle { border-radius: 50%; }
.mark.square { border-radius: 3px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.tl-item { display: grid; grid-template-columns: 70px minmax(0, 1fr) auto; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); align-items: start; }
.tl-item:first-child { border-top: 0; padding-top: 0; }
.tl-date { font: 600 1rem/1.6 var(--font-display); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tl-body .feed-notes { margin-top: 6px; }

/* ---------- settings ---------- */
.settings-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 900px) { .settings-grid { grid-template-columns: minmax(0, 1fr); } }
.mgr-list, .dept-list { list-style: none; margin: 0; padding: 0; }
.mgr-list li { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.mgr-list li:first-child { border-top: 0; }
.mgr-who { display: flex; flex-direction: column; flex: 1; min-width: 140px; }
.mgr-who span { font-size: 0.8rem; color: var(--muted); overflow-wrap: anywhere; }
.mgr-actions { display: flex; gap: 6px; }
.dept-list li { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 0; border-top: 1px solid var(--line); }
.dept-list li:first-child { border-top: 0; }
.dept-list li > span:first-child { flex: 1; font-weight: 500; }

/* ---------- forms ---------- */
.stack-form { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.inline-form .input { flex: 1 1 180px; width: auto; }
.inline-form .form-error { flex-basis: 100%; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; font-size: 0.85rem; font-weight: 600; color: var(--ink-2); }
.field legend { padding: 0; margin-bottom: 6px; }
.optional { font-weight: 400; color: var(--muted); }
.input {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: 9px;
  background: var(--surface); color: var(--ink); font-size: 1rem; font-weight: 400;
}
textarea.input { resize: vertical; min-height: 76px; }
.form-error { color: var(--bad); font-size: 0.86rem; font-weight: 500; }

.type-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 520px) { .type-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.type-tile { position: relative; display: block; }
.type-tile input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.type-tile span {
  display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%;
  padding: 12px 6px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface); color: var(--ink-2); font-size: 0.8rem; font-weight: 600; text-align: center;
}
.type-tile .ico { width: 22px; height: 22px; color: var(--tone); }
.type-tile:hover span { border-color: var(--tone); }
.type-tile input:checked + span { border-color: var(--tone); background: var(--tone-wash); color: var(--ink); box-shadow: inset 0 0 0 1px var(--tone); }
.type-tile input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { display: inline-block; padding: 7px 13px; border: 1px solid var(--line-strong); border-radius: 999px; font-weight: 500; font-size: 0.86rem; color: var(--ink); cursor: pointer; }
.seg input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

.star-picker { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px; background: var(--surface-2); border-radius: 12px; }
.star-picker output { display: flex; align-items: center; gap: 12px; }
.star-picker input[type="range"] { width: 100%; max-width: 320px; accent-color: var(--accent); }
.modal-lead { color: var(--ink-2); }

/* ---------- modal & confirm ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; background: var(--backdrop);
  display: grid; place-items: center; padding: 16px; overflow-y: auto;
}
.modal {
  width: min(580px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column;
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg);
}
.modal.small { width: min(420px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 18px 20px 20px; overflow-y: auto; }
.modal-form { display: flex; flex-direction: column; gap: 16px; }
.modal-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.modal-actions .spacer { flex: 1; }
@media (max-width: 560px) {
  .modal-backdrop { place-items: end center; padding: 0; }
  .modal { border-radius: 16px 16px 0 0; max-height: 92dvh; }
}

/* ---------- toasts ---------- */
#toasts {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 70;
  width: min(460px, calc(100% - 32px)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 8px; max-width: 100%;
  background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 10px;
  font-weight: 500; font-size: 0.9rem; box-shadow: var(--shadow-lg);
  animation: toast-in 0.2s ease-out; transition: opacity 0.3s, transform 0.3s;
}
.toast.out { opacity: 0; transform: translateY(6px); }
.toast-bad { background: var(--danger); color: #ffffff; }
.toast-live::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--live); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- sign-in ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; background: linear-gradient(var(--board) 0 38%, var(--ground) 38% 100%); }
.auth-card {
  width: min(410px, 100%); display: flex; flex-direction: column; gap: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow-lg);
}
.auth-card .brand { margin-bottom: 6px; }
.auth-lead { color: var(--ink-2); margin-top: -4px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
