/* Layout: sticky two-row header (tabs + planning controls), then one working view at a time. */
:root {
  --bg: #eef3f4;
  --surface: #ffffff;
  --surface-2: #f6f9fa;
  --ink: #13262d;
  --muted: #55696f;
  --line: #d3dee1;
  --accent: #0f6c7a;
  --accent-ink: #ffffff;
  --amber: #c98a0b;
  --amber-soft: #fbefd2;
  --t-free: #2d7a4c;      --t-free-bg: #e0f1e6;
  --t-published: #0f6c7a; --t-published-bg: #dcefF2;
  --t-verify: #9a6a00;    --t-verify-bg: #fbefd2;
  --t-school: #6a4c9c;    --t-school-bg: #ece5f6;
  --t-quote: #5b6b71;     --t-quote-bg: #e6ecee;
  --t-quoted: #2459a8;    --t-quoted-bg: #e1eafa;
  --t-booked: #1f6b3d;    --t-booked-bg: #d4eedd;
  --danger: #b3261e;
  --shadow: 0 1px 2px rgba(19, 38, 45, .06), 0 4px 14px rgba(19, 38, 45, .06);
  --f-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-body: "Figtree", "Segoe UI", system-ui, -apple-system, sans-serif;
  --r: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d181c; --surface: #14232a; --surface-2: #192c33; --ink: #e3eef0; --muted: #94aab0; --line: #27404a;
    --accent: #4fb3c2; --accent-ink: #082126; --amber: #f0be4c; --amber-soft: #3a2f12;
    --t-free: #7fd3a0; --t-free-bg: #183526; --t-published: #7fd0dc; --t-published-bg: #133740;
    --t-verify: #f0c766; --t-verify-bg: #3a2f12; --t-school: #c3a8ef; --t-school-bg: #2c2340;
    --t-quote: #a9b9be; --t-quote-bg: #22343a; --t-quoted: #9cbcf5; --t-quoted-bg: #1d2c47;
    --t-booked: #8be0ab; --t-booked-bg: #163a25; --danger: #ff8a80;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d181c; --surface: #14232a; --surface-2: #192c33; --ink: #e3eef0; --muted: #94aab0; --line: #27404a;
  --accent: #4fb3c2; --accent-ink: #082126; --amber: #f0be4c; --amber-soft: #3a2f12;
  --t-free: #7fd3a0; --t-free-bg: #183526; --t-published: #7fd0dc; --t-published-bg: #133740;
  --t-verify: #f0c766; --t-verify-bg: #3a2f12; --t-school: #c3a8ef; --t-school-bg: #2c2340;
  --t-quote: #a9b9be; --t-quote-bg: #22343a; --t-quoted: #9cbcf5; --t-quoted-bg: #1d2c47;
  --t-booked: #8be0ab; --t-booked-bg: #163a25; --danger: #ff8a80;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 var(--f-body); font-variant-numeric: tabular-nums;
}
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--f-display); line-height: 1.15; text-wrap: balance; margin: 0; }
h1 { font-size: 1.9rem; font-weight: 700; }
h2 { font-size: 1.3rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--surface);
  border-bottom: 1px solid var(--line); box-shadow: var(--shadow);
}
.topbar-inner, .controls-inner, main {
  max-width: 1240px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.topbar-inner { display: flex; align-items: center; gap: 24px; padding-block: 10px 0; flex-wrap: wrap; }
@media (max-width: 640px) { .topbar { position: static; } }
td:first-child { min-width: 12em; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-family: var(--f-display); font-size: 1.15rem; padding-bottom: 10px; }
.brand strong { color: var(--accent); }
.brand-mark {
  width: 28px; height: 28px; border-radius: 7px; background: var(--accent); position: relative; flex: none;
}
.brand-mark::after {
  content: ""; position: absolute; left: 5px; right: 5px; bottom: 7px; height: 10px;
  border: 3px solid var(--amber); border-bottom: 0; border-radius: 12px 12px 0 0;
}
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1 1 auto; min-width: 0; }
.tabs a {
  white-space: nowrap; text-decoration: none; color: var(--muted); padding: 8px 12px 12px;
  border-bottom: 3px solid transparent; font-weight: 700; font-size: .95rem;
}
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.badge { display: inline-block; min-width: 1.4em; padding: 0 .4em; border-radius: 999px; background: var(--amber); color: #1d1500; font-size: .75rem; text-align: center; }
.controls-inner { display: flex; align-items: center; gap: 12px 24px; flex-wrap: wrap; padding-block: 8px; border-top: 1px solid var(--line); }
.ctl { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.ctl > span:first-child { font-weight: 700; letter-spacing: .02em; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 4px 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
#group-custom { width: 5.5em; }
.sync { margin-left: auto; font-size: .82rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.sync::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.sync[data-mode="server"]::before { background: var(--t-free); }
.sync[data-mode="local"]::before { background: var(--amber); }

input[type="text"], input[type="search"], input[type="number"], input[type="date"], input[type="month"], input[type="password"], select, textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; min-height: 36px; max-width: 100%;
}
textarea { min-height: 80px; width: 100%; resize: vertical; }

/* ---------- main ---------- */
main { padding-block: 24px 64px; display: grid; gap: 24px; }
main:focus { outline: none; }
.loading { color: var(--muted); }
.view-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; flex-wrap: wrap; }
.view-head p { max-width: 65ch; margin-top: 6px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface);
  border-radius: 8px; padding: 7px 14px; cursor: pointer; font-weight: 700; text-decoration: none; color: var(--ink); white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.small { padding: 3px 10px; font-size: .85rem; }
.btn.danger { color: var(--danger); }
.btn.link { border: 0; background: none; padding: 0; color: var(--accent); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; min-width: 0; }
.panel > h2, .panel > h3 { margin-bottom: 12px; }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 8px 12px; flex-wrap: wrap; align-items: center; }
.empty { padding: 28px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--r); }
.empty strong { display: block; color: var(--ink); font-family: var(--f-display); font-size: 1.1rem; margin-bottom: 4px; }

/* summary strip */
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; text-decoration: none; color: inherit; display: grid; gap: 2px; }
a.stat:hover { border-color: var(--accent); }
.stat b { font-family: var(--f-display); font-size: 1.7rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .9rem; }
.stat.attn b { color: var(--amber); }

/* filters */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters input[type="search"] { flex: 1 1 220px; }
.count { color: var(--muted); font-size: .9rem; }

/* chips */
.chip { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 1px 10px; font-size: .78rem; font-weight: 700; white-space: nowrap; background: var(--t-quote-bg); color: var(--t-quote); }
.chip.free { background: var(--t-free-bg); color: var(--t-free); }
.chip.published { background: var(--t-published-bg); color: var(--t-published); }
.chip.verify { background: var(--t-verify-bg); color: var(--t-verify); }
.chip.school { background: var(--t-school-bg); color: var(--t-school); }
.chip.quoted { background: var(--t-quoted-bg); color: var(--t-quoted); }
.chip.booked, .chip.done { background: var(--t-booked-bg); color: var(--t-booked); }
.chip.high { background: var(--amber-soft); color: var(--t-verify); }
.chip.outline { background: transparent; border: 1px solid var(--line); color: var(--muted); }

/* venue cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px;
  display: grid; grid-template-rows: auto auto 1fr auto; gap: 10px; text-decoration: none; color: inherit; min-width: 0;
}
.card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.card .meta { color: var(--muted); font-size: .85rem; }
.card .price { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.card .price b { font-family: var(--f-display); font-size: 1.45rem; }
.card .offer { font-size: .9rem; border-left: 3px solid var(--amber); padding-left: 10px; }
.card .foot { display: flex; gap: 6px; flex-wrap: wrap; }

/* venue page */
.crumbs { font-size: .9rem; }
.venue-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
@media (max-width: 960px) { .venue-grid { grid-template-columns: minmax(0, 1fr); } }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; font-size: .95rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.copy { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.callout { background: var(--surface-2); border-radius: 8px; padding: 12px 14px; border-left: 4px solid var(--accent); }
.callout.warn { border-left-color: var(--amber); }
.callout h3 { margin-bottom: 4px; }
.pre { white-space: pre-wrap; font-size: .9rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px; max-height: 340px; overflow: auto; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
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-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }

/* calendar */
.cal-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cal-head h2 { min-width: 9ch; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--line); gap: 1px; }
.cal .dow { background: var(--surface-2); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 6px 8px; }
.cal .day { background: var(--surface); min-height: 108px; padding: 6px; display: grid; align-content: start; gap: 3px; min-width: 0; }
.cal .day.out { background: var(--surface-2); color: var(--muted); }
.cal .day.today .dnum { background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 0 6px; }
.cal .day.weekend { background: color-mix(in srgb, var(--surface) 92%, var(--accent)); }
.cal .dnum { font-size: .8rem; font-weight: 700; justify-self: start; }
.ev {
  display: block; font-size: .76rem; line-height: 1.25; padding: 2px 6px; border-radius: 5px; text-decoration: none;
  background: var(--t-published-bg); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ev.high { background: var(--amber-soft); }
.ev.closure { background: transparent; border: 1px dashed var(--danger); color: var(--danger); }
.ev.cont { opacity: .7; }
.more { font-size: .74rem; color: var(--muted); }
@media (max-width: 720px) { .cal { display: none; } }
.agenda { display: grid; gap: 8px; }
.agenda-item { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.agenda-item .when { font-weight: 700; font-size: .9rem; }
@media (max-width: 560px) { .agenda-item { grid-template-columns: minmax(0, 1fr); gap: 6px; } }

/* planner */
.months { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.month { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: grid; gap: 10px; align-content: start; }
.month.now { border-color: var(--accent); }
.month header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.month .total { font-size: .85rem; color: var(--muted); }
.plan-item { border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; display: grid; gap: 4px; cursor: pointer; background: var(--surface-2); text-align: left; width: 100%; }
.plan-item:hover { border-color: var(--accent); }
.plan-item .t { font-weight: 700; }
.plan-item .m { font-size: .82rem; color: var(--muted); }
.balance { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 170px minmax(0, 1fr) 2.5em; gap: 10px; align-items: center; font-size: .88rem; }
.bar { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
@media (max-width: 560px) { .bar-row { grid-template-columns: 110px minmax(0, 1fr) 2em; } }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }

/* dialog + forms */
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 24px)); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(10, 25, 30, .45); }
.dlg-body { padding: 20px; display: grid; gap: 14px; max-height: 80vh; overflow: auto; }
.dlg-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.dlg-foot .spacer { flex: 1; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 520px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.field { display: grid; gap: 4px; font-size: .9rem; min-width: 0; }
.field > span { font-weight: 700; }
.field input, .field select { width: 100%; }
.calc { background: var(--surface-2); border-radius: 8px; padding: 12px; display: grid; gap: 10px; }
.calc .total-line { display: flex; justify-content: space-between; font-weight: 700; font-family: var(--f-display); font-size: 1.15rem; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 700; z-index: 50; box-shadow: var(--shadow); }
.toast.err { background: var(--danger); color: #fff; }

.find { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: start; }
@media (max-width: 560px) { .find { grid-template-columns: minmax(0, 1fr); } }

@media (prefers-reduced-motion: no-preference) {
  .card, .btn, .plan-item { transition: border-color .15s, box-shadow .15s; }
}
