:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --ink: #1b2421;
  --ink-2: #4b5a55;
  --muted: #7d8a85;
  --line: #e3e0d9;
  --brand: #0e6b66;
  --brand-ink: #ffffff;
  --brand-soft: #e3f1ef;
  --brand-deep: #0a4f4b;
  --warn: #9a5b00;
  --warn-soft: #fbf0dc;
  --ok: #1f7a43;
  --ok-soft: #e4f4ea;
  --err: #b42318;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(20 30 28 / 6%), 0 4px 16px rgb(20 30 28 / 5%);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111615; --surface: #1a2120; --ink: #e8eeec; --ink-2: #b6c2be; --muted: #84928d;
    --line: #2a3331; --brand: #3fb3a9; --brand-ink: #062623; --brand-soft: #173431; --brand-deep: #7fd3ca;
    --warn: #f0b860; --warn-soft: #3a2c14; --ok: #6fd39a; --ok-soft: #173325; --err: #ff8a80;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px clamp(16px, 4vw, 40px); background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 18px; font-weight: 650; }
.brand p { margin: 0; color: var(--muted); font-size: 13px; }
.logo svg { width: 36px; height: 36px; display: block; }
.logo rect { fill: var(--brand); }
.logo path { stroke: var(--brand-ink); stroke-width: 3.5; stroke-linecap: round; fill: none; }
.pill { font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 999px; background: var(--line); color: var(--ink-2); white-space: nowrap; }
.pill.live { background: var(--ok-soft); color: var(--ok); }
.pill.demo { background: var(--warn-soft); color: var(--warn); }

/* ---------- layout ---------- */
.layout {
  display: grid; grid-template-columns: minmax(340px, 440px) 1fr; gap: 24px; align-items: start;
  max-width: 1240px; margin: 0 auto; padding: 24px clamp(16px, 4vw, 40px) 60px;
}
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.intake { display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.card-head, .staff summary { display: flex; align-items: center; gap: 10px; }
.card h2 { font-size: 15px; font-weight: 650; }
.step { width: 24px; height: 24px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-deep); font-size: 12px; font-weight: 700; display: grid; place-items: center; flex: none; }
.staff summary { cursor: pointer; list-style: none; }
.staff summary::-webkit-details-marker { display: none; }
.staff summary .muted { margin-left: auto; font-size: 13px; }
.staff[open] summary { margin-bottom: 4px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.span2 { grid-column: span 2; }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } .span2 { grid-column: auto; } }

label, legend { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 550; color: var(--ink-2); }
legend { padding: 0; margin-bottom: 5px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.opt { font-weight: 400; color: var(--muted); }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface);
  font-size: 14.5px; font-weight: 400; color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
input.invalid { border-color: var(--err); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 450; }
label.check input { width: auto; accent-color: var(--brand); }
.hint, .muted { color: var(--muted); font-size: 12.5px; margin: 0; }

.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 6px 4px; border-radius: 7px; font-size: 13.5px; font-weight: 550; color: var(--ink-2); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--brand-deep); box-shadow: 0 1px 3px rgb(0 0 0 / 12%); }

.btn { border: 1px solid transparent; border-radius: 10px; padding: 9px 16px; font-weight: 600; cursor: pointer; transition: background .15s, transform .05s; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: var(--brand-deep); }
@media (prefers-color-scheme: dark) { .btn.primary:hover { background: var(--brand); filter: brightness(1.1); } }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: var(--bg); }
.btn.big { padding: 12px 22px; font-size: 15.5px; }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.status { font-size: 13px; color: var(--muted); }
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }
.matches { display: flex; flex-direction: column; gap: 6px; }
.match { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; background: transparent; text-align: left; }
.match.on { border-color: var(--brand); background: var(--brand-soft); }

/* ---------- results ---------- */
.results { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.eyebrow { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--brand-deep); }

.best {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
  overflow: hidden; display: grid; grid-template-columns: 170px 1fr;
}
@media (max-width: 560px) { .best { grid-template-columns: 1fr; } }
.best .when { background: var(--brand); color: var(--brand-ink); padding: 22px 18px; display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.when .dow { font-size: 14px; font-weight: 600; opacity: .85; }
.when .day { font-size: 44px; font-weight: 700; line-height: 1; letter-spacing: -0.03em; }
.when .mon { font-size: 14px; font-weight: 600; opacity: .85; }
.when .time { margin-top: 10px; font-size: 22px; font-weight: 650; }
.best .info { padding: 20px 22px; display: flex; flex-direction: column; gap: 10px; }
.best h3 { font-size: 20px; font-weight: 650; }
.best .where { color: var(--ink-2); font-size: 14px; }
.best .rel { font-size: 13.5px; color: var(--ink-2); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-deep); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.best .actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }

.others { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.others-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.others-head h2 { font-size: 15px; }
.daygroup { display: grid; grid-template-columns: 92px 1fr; gap: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.daygroup:first-of-type { border-top: 0; padding-top: 0; }
.daylabel { font-weight: 650; font-size: 13.5px; }
.daylabel small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; }
.daylabel .past { color: var(--warn); }
.slots { display: flex; flex-wrap: wrap; gap: 8px; }
.slot {
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 7px 11px; cursor: pointer;
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-width: 128px; text-align: left;
  transition: border-color .15s, background .15s;
}
.slot:hover { border-color: var(--brand); background: var(--brand-soft); }
.slot b { font-size: 14px; }
.slot span { font-size: 12px; color: var(--muted); }
.slot.mine { border-color: color-mix(in srgb, var(--brand) 50%, var(--line)); }
@media (max-width: 560px) { .daygroup { grid-template-columns: 1fr; gap: 6px; } }

.empty, .loading { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 34px; text-align: center; color: var(--ink-2); }
.loading .bar { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--brand-soft), var(--brand), var(--brand-soft)); background-size: 200% 100%; animation: sh 1.1s linear infinite; margin-top: 14px; }
@keyframes sh { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .loading .bar { animation: none; } }

/* ---------- dialogs ---------- */
.dlg { border: 0; border-radius: 18px; padding: 24px; width: min(480px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgb(0 0 0 / 25%); }
.dlg::backdrop { background: rgb(15 25 23 / 45%); backdrop-filter: blur(2px); }
.dlg h2 { font-size: 19px; margin-bottom: 14px; }
.dlg dl { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; margin: 0 0 6px; font-size: 14px; }
.dlg dt { color: var(--muted); }
.dlg dd { margin: 0; font-weight: 550; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.error { color: var(--err); font-size: 13.5px; }
.done .check-mark { width: 52px; height: 52px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; margin-bottom: 12px; }
.done .check-mark svg { width: 28px; height: 28px; }
.conf { font-family: ui-monospace, Consolas, monospace; background: var(--bg); padding: 2px 8px; border-radius: 6px; }

.print-only { display: none; }
@media print {
  body > *:not(.print-only) { display: none !important; }
  .print-only { display: block; color: #000; font: 14pt/1.5 Georgia, serif; padding: 24px; }
  .print-only h1 { font-size: 22pt; margin-bottom: 12px; }
}
