:root {
  --ground: #F5F4F0;
  --card: #FFFFFF;
  --line: #E3E1DA;
  --line-soft: #EEECE6;
  --ink: #17181A;
  --ink-2: #4A4D55;
  --muted: #5B5E66;
  --label: #6B6E75;
  --accent: #1D5FD1;
  --accent-ink: #1A4FB0;
  --accent-soft: #E4ECFB;
  --warn: #C2570F;
  --warn-ink: #9A430A;
  --warn-soft: #FCEBDC;
  --warn-wash: #FDF4EC;
  --ok: #1E8E5A;
  --off: #8A8D94;
  --off-soft: #ECEBE7;
  --radius: 20px;
  --head: 'Space Grotesk', Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--ground);
  color: var(--ink);
  font: 15px/1.45 Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
a:hover { color: #16489F; }
h1, h2 { font-family: var(--head); letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 500; }
.center { text-align: center; }
[hidden] { display: none !important; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 12px;
  border: 1px solid #D8D5CC; background: var(--card); color: var(--ink);
  font: 500 14px Inter, sans-serif; text-decoration: none; cursor: pointer;
}
.btn:hover { background: #FAF9F6; color: var(--ink); }
.btn:focus-visible, .filter:focus-visible, input:focus-visible { outline: 3px solid #9DB9EE; outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #1852B6; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.dark:hover { background: #2B2D31; color: #fff; }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #fff; font-weight: 600; }
.btn.warn:hover { background: #A84B0C; color: #fff; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn.block { width: 100%; }

/* Layout */
.wrap { max-width: 1280px; margin: 0 auto; padding: 28px 24px 64px; display: flex; flex-direction: column; gap: 28px; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 14px; }
.mark { width: 40px; height: 40px; border-radius: 12px; background: var(--accent); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.brand-name { font-family: var(--head); font-weight: 700; font-size: 20px; }
.brand-sub { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 4px; background: var(--off); display: inline-block; }
.dot.up { background: var(--ok); }
.dot.down { background: var(--warn); }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.top-actions form { margin: 0; }
.today { font-size: 14px; color: var(--muted); margin-right: 6px; }

.hero { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 20px; }
.hero h1 { margin: 0; font-weight: 600; font-size: 40px; line-height: 1.1; letter-spacing: -0.02em; }
.lede { margin: 8px 0 0; font-size: 17px; color: var(--ink-2); }
.tiles { display: flex; gap: 12px; flex-wrap: wrap; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 18px; min-width: 120px; }
.label { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--label); }
.value { font-family: var(--head); font-size: 28px; font-weight: 600; }
.value.warn { color: var(--warn-ink); }

/* Agent cards */
.cards { display: flex; flex-wrap: wrap; gap: 20px; }
.card {
  flex: 1 1 340px; min-width: 0; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px; display: flex; flex-direction: column; gap: 20px;
}
.card.state-needs { border: 2px solid #E9A46C; padding: 23px; }
.card.state-offline { background: #FBFAF8; }
.card.state-offline .avatar { filter: grayscale(0.7); opacity: 0.75; }
.card-head { display: flex; align-items: center; gap: 16px; }
.avatar { width: 72px; height: 72px; border-radius: 50%; flex: 0 0 auto; }
.avatar.initials { display: inline-flex; align-items: center; justify-content: center; background: var(--off-soft); font-family: var(--head); font-size: 28px; font-weight: 600; color: var(--ink-2); }
.who { flex: 1 1 auto; min-width: 0; }
.who h2 { margin: 0; font-size: 24px; font-weight: 600; }
.role { font-size: 14px; color: var(--muted); }
.pill { align-self: flex-start; padding: 5px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.pill-dot { width: 7px; height: 7px; border-radius: 4px; background: currentColor; }
.pill.working { background: var(--accent-soft); color: var(--accent-ink); }
.pill.needs { background: var(--warn-soft); color: var(--warn-ink); }
.pill.idle { background: var(--off-soft); color: var(--ink-2); }
.pill.offline { background: var(--off-soft); color: var(--muted); }

.now { background: var(--ground); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.now.needs { background: var(--warn-wash); }
.now.needs .label { color: #8A3C09; }
.now-text { font-weight: 500; overflow-wrap: anywhere; }
.now-sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.busy { height: 4px; border-radius: 2px; background: #DCE5F5; overflow: hidden; position: relative; margin-top: 4px; }
.busy span { position: absolute; inset: 0 auto 0 0; width: 35%; background: var(--accent); border-radius: 2px; animation: busy 1.6s ease-in-out infinite; }
@keyframes busy { 0% { left: -35%; } 100% { left: 100%; } }
@media (prefers-reduced-motion: reduce) { .busy span { animation: none; width: 100%; } }

.facts { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; font-size: 14px; }
.facts dt { color: var(--label); font-size: 13px; }
.facts dd { margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; }
.facts dd.muted { font-weight: 400; }
.tools { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 4px 10px; border-radius: 8px; border: 1px solid var(--line); font-size: 12px; color: var(--ink-2); }
.card-actions { display: flex; gap: 10px; margin-top: auto; flex-wrap: wrap; }
.card-actions .btn { flex: 1 1 auto; }

/* Lower panels */
.lower { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; min-width: 0; }
.panel.needs { flex: 1 1 420px; }
.panel.activity { flex: 1.4 1 480px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 20px; font-weight: 600; }
.empty { color: var(--muted); padding: 14px 0 0; border-top: 1px solid var(--line-soft); margin: 0; list-style: none; }
.need { display: flex; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line-soft); align-items: center; flex-wrap: wrap; }
.need:last-child { padding-bottom: 0; }
.need-text { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
.mini { width: 36px; height: 36px; border-radius: 18px; background: var(--off-soft); color: var(--ink-2); font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.mini.earl { background: #D6E4F7; color: #1A4FB0; }
.mini.simon { background: #DCEBD8; color: #2E4535; }
.mini.gary { background: #F7DFCB; color: #8A3C09; }

.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filter { min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: 500 13px Inter, sans-serif; cursor: pointer; }
.filter.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line-soft); }
.feed li:last-child { padding-bottom: 0; }
.when { flex: 0 0 84px; font-size: 13px; color: var(--label); font-variant-numeric: tabular-nums; }
.tick { flex: 0 0 auto; width: 10px; height: 10px; margin-top: 5px; border-radius: 5px; background: var(--off); }
.tick.earl { background: #1D5FD1; }
.tick.simon { background: #1E8E5A; }
.tick.gary { background: #D9691C; }
.what { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.what strong { font-weight: 600; }
.kind-needs_you .what { color: var(--warn-ink); }

.alert { background: #FDECEC; color: #8F1D1D; border-radius: 12px; padding: 12px 14px; margin: 0; }
.notice { background: #E5F4EC; color: #145C3B; border-radius: 12px; padding: 12px 14px; margin: 0 0 16px; }

/* Auth pages */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 32px 28px; }
.auth-brand { display: flex; align-items: center; gap: 12px; font-family: var(--head); font-weight: 700; font-size: 18px; margin-bottom: 24px; }
.auth-card h1 { margin: 0 0 4px; font-size: 28px; font-weight: 600; }
.auth-card h2 { margin: 8px 0 0; font-size: 18px; }
.auth-card > .muted { margin: 0 0 20px; }
.form { display: flex; flex-direction: column; gap: 8px; margin: 0; }
.form.split { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line-soft); }
.form.split p { margin: 0 0 4px; }
.form label { font-size: 14px; font-weight: 500; margin-top: 8px; }
.form input[type=email], .form input[type=password] {
  min-height: 46px; padding: 0 14px; border-radius: 12px; border: 1px solid #CFCCC2;
  font: 16px Inter, sans-serif; color: var(--ink); background: #fff;
}
.form .btn { margin-top: 16px; }

@media (max-width: 600px) {
  .wrap { padding: 20px 16px 48px; gap: 22px; }
  .hero h1 { font-size: 32px; }
  .tiles { width: 100%; }
  .tile { flex: 1 1 0; min-width: 0; padding: 10px 12px; }
  .card { padding: 20px; }
  .card.state-needs { padding: 19px; }
  .avatar { width: 60px; height: 60px; }
  .when { flex-basis: 64px; }
  .today { display: none; }
}

/* Nav */
.nav-link { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 12px; color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 14px; }
.nav-link:hover { background: #ECEAE4; color: var(--ink); }
.nav-link.on { background: var(--ink); color: #fff; }
.count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--warn); color: #fff; font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }

/* Status badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; vertical-align: 2px; text-decoration: none; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 3px; background: currentColor; }
.badge.ok { background: #E5F4EC; color: #145C3B; }
.badge.watch { background: #FBF1D6; color: #7A5300; }
.badge.action { background: var(--warn-soft); color: var(--warn-ink); }
.badge.handled { background: var(--off-soft); color: var(--muted); }
a.badge:hover { filter: brightness(0.96); }
.done-line { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.done-line a { color: var(--ink); text-decoration: none; }
.done-line a:hover { text-decoration: underline; }
.feed .report-link { margin-left: 6px; font-size: 13px; white-space: nowrap; }
.kind-done.st-action .what { color: var(--warn-ink); }

/* Reports list */
.panel .panel-head .filters + .filters { margin-left: auto; }
.reports { list-style: none; margin: 8px 0 0; padding: 0; }
.report-row a { display: flex; gap: 14px; align-items: flex-start; padding: 14px 8px; margin: 0 -8px; border-top: 1px solid var(--line-soft); color: var(--ink); text-decoration: none; border-radius: 10px; }
.report-row a:hover { background: #FAF9F6; }
.report-row.flagged a { background: var(--warn-wash); }
.report-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto; overflow-wrap: anywhere; }
.report-title { font-weight: 600; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.report-headline { color: var(--ink-2); }
a.filter { display: inline-flex; align-items: center; text-decoration: none; }

/* Report page */
.report { max-width: 860px; }
.report.flagged { border: 2px solid #E9A46C; padding: 23px; }
.report-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.report-who { display: flex; gap: 14px; align-items: center; }
.report-who h1 { margin: 0; font-size: 28px; font-weight: 600; }
.avatar.small-av { width: 48px; height: 48px; }
.report-summary { font-size: 17px; font-weight: 500; margin: 0 0 16px; }
.resolve { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; justify-content: space-between; background: var(--warn-wash); border-radius: 14px; padding: 14px 16px; margin: 0 0 20px; }
.resolve .btn { flex: 0 0 auto; }
.prose { overflow-wrap: anywhere; }
.prose h2 { font-size: 20px; margin: 24px 0 8px; }
.prose h3, .prose h4 { font-size: 16px; margin: 18px 0 6px; }
.prose p, .prose ul, .prose ol { margin: 0 0 12px; }
.prose li { margin: 4px 0; }
.prose code { background: var(--ground); padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.prose pre { background: var(--ground); padding: 12px 14px; border-radius: 10px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose hr { border: 0; border-top: 1px solid var(--line-soft); margin: 20px 0; }
@media (max-width: 600px) {
  .report-who h1 { font-size: 22px; }
  .nav-link { padding: 0 10px; }
}
.prose li.sub { margin-left: 22px; list-style-type: circle; }
.prose ol > li.sub { list-style-type: disc; }
.card .seen { margin-top: -8px; }

/* Schedule */
.sched { display: flex; flex-direction: column; gap: 8px; }
.sched-who { display: flex; align-items: center; gap: 14px; }
.sched-who h2 { margin: 0; font-size: 20px; font-weight: 600; }
.jobs { list-style: none; margin: 0; padding: 0; }
.job { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; padding: 14px 0; border-top: 1px solid var(--line-soft); }
.job:last-child { padding-bottom: 0; }
.job.paused { opacity: 0.6; }
.job-main { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.job-title { font-weight: 600; font-size: 16px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.job-when { color: var(--ink-2); }
.run-state { color: var(--accent-ink); font-weight: 600; }
.job-report { display: inline-flex; gap: 8px; align-items: center; color: var(--ink-2); text-decoration: none; font-size: 14px; margin-top: 4px; overflow-wrap: anywhere; }
.job-report:hover span { text-decoration: underline; }
.job form { margin: 0; }
.job .btn { min-width: 120px; }
.lede code, .muted code { background: var(--off-soft); padding: 1px 5px; border-radius: 5px; font-size: 13px; }

/* Activity page */
.search { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.search input[type=search] { flex: 1 1 240px; min-width: 0; min-height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid #CFCCC2; font: 16px Inter, sans-serif; color: var(--ink); background: #fff; }
.search input[type=search]:focus-visible { outline: 3px solid #9DB9EE; outline-offset: 2px; }
.filters-row { gap: 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.feed mark { background: #FBF1D6; color: inherit; border-radius: 3px; padding: 0; box-shadow: 0 0 0 2px #FBF1D6; }
.feed .when { flex-basis: 110px; }
.pager { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; }
.view-all { display: inline-block; margin-top: 14px; font-weight: 500; text-decoration: none; }
.view-all:hover { text-decoration: underline; }
@media (max-width: 600px) { .feed .when { flex-basis: 76px; } }
.mini.sophie { background: #E6DEF5; color: #4B2F96; }
.tick.sophie { background: #6E4FC4; }

/* One-click actions */
.actions-box { background: var(--ground); border-radius: 14px; padding: 16px; margin: 0 0 20px; display: flex; flex-direction: column; gap: 4px; }
.actions-box h2 { margin: 0 0 6px; font-size: 16px; }
.act { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line); }
.act:first-of-type { border-top: 0; }
.act-text { flex: 1 1 260px; min-width: 0; overflow-wrap: anywhere; }
.act-buttons { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
.act-buttons .btn { min-height: 40px; }
.act-result { color: var(--ink-2); margin-top: 2px; }
.state-failed .act-result { color: var(--warn-ink); }
.act-row .need-text a { color: inherit; }
