/* Layout: sticky top bar with tabs, one working panel below; calendar is a week grid of half-hour rows. */
:root {
  --bg: #faf8f4; --surface: #ffffff; --surface-2: #f4efe6; --line: #e7dfd1;
  --fg: #2a2620; --muted: #7a7166; --accent: #b0832f; --accent-ink: #ffffff; --accent-soft: #f6ecd9;
  --closed: transparent; --open: #e3ded6; --free: #a6dab3; --ok: #2f7d4f; --ok-soft: #e3f2e8; --bad: #b3412f; --bad-soft: #f8e4e0;
  --sched: #fbf3e2; --sched-line: #d5ad5d;
  --font: "Commissioner", "Segoe UI", system-ui, sans-serif;
  --r: 8px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #171512; --surface: #201d19; --surface-2: #2a2621; --line: #3a342c;
  --fg: #efe9df; --muted: #a59b8d; --accent: #d6a751; --accent-ink: #1b1813; --accent-soft: #3a2f1c;
  --closed: transparent; --open: #3b3630; --free: #2e6b43; --ok: #6cc28f; --ok-soft: #1f3327; --bad: #e98b79; --bad-soft: #3a2420;
  --sched: #33291a; --sched-line: #a9813b; color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #171512; --surface: #201d19; --surface-2: #2a2621; --line: #3a342c;
  --fg: #efe9df; --muted: #a59b8d; --accent: #d6a751; --accent-ink: #1b1813; --accent-soft: #3a2f1c;
  --closed: transparent; --open: #3b3630; --free: #2e6b43; --ok: #6cc28f; --ok-soft: #1f3327; --bad: #e98b79; --bad-soft: #3a2420;
  --sched: #33291a; --sched-line: #a9813b; color-scheme: dark }
* { box-sizing: border-box; }
body { background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 14px; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
button, input, select, textarea { font: inherit; color: inherit; }
.wrap { max-width: 1180px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
header.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding-block: 10px; }
.brand { font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; }
nav.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
nav.tabs button { border: 1px solid transparent; background: none; padding: 7px 12px; border-radius: 99px; cursor: pointer; color: var(--muted); font-weight: 600; }
nav.tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
nav.tabs button:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
main { padding-block: 18px 40px; display: grid; gap: 16px; }
.banner { background: var(--accent-soft); border: 1px solid var(--sched-line); border-radius: var(--r); padding: 8px 12px; font-size: 13px; }
.bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bar h2 { margin: 0 8px 0 0; font-size: 18px; text-wrap: balance; }
.spacer { flex: 1; }
.btn { border: 1px solid var(--line); background: var(--surface); padding: 7px 12px; border-radius: var(--r); cursor: pointer; font-weight: 600; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); }
.btn.danger.armed { background: var(--bad); border-color: var(--bad); color: #fff; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* Calendar */
.cal-scroll { overflow-x: auto; }
.cal { display: grid; grid-template-columns: 54px repeat(5, minmax(120px, 1fr)); min-width: 680px; }
.cal .head { padding: 8px 6px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 13px; }
.cal .head small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; }
.cal .head.today { color: var(--accent); }
.times { position: relative; }
.times div { height: var(--slot); font-size: 11px; color: var(--muted); text-align: right; padding-right: 6px; transform: translateY(-7px); font-variant-numeric: tabular-nums; }
.day { position: relative; border-left: 1px solid var(--line); cursor: copy; }
.day .slot { height: var(--slot); border-bottom: 1px dashed var(--line); }
.day .slot.hour { border-bottom-style: solid; }
.day .slot.closed { background: var(--closed); cursor: not-allowed; }
.day .slot.open { background: var(--open); border-bottom-color: var(--bg); }
.day .slot.open.free { background: var(--free); }
.day .slot.open:hover { background: var(--accent-soft); }
.appt { position: absolute; left: 3px; right: 3px; border-radius: 6px; padding: 3px 6px; font-size: 12px; line-height: 1.25; overflow: hidden; cursor: pointer; border-left: 3px solid var(--sched-line); background: var(--sched); }
.appt b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt span { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt.done { background: var(--ok-soft); border-left-color: var(--ok); }
.appt.tight { padding: 1px 6px; font-size: 11px; line-height: 1.2; }
.appt.tight span { display: none; }
.appt.cancelled { background: var(--surface-2); border-left-color: var(--muted); text-decoration: line-through; opacity: .75; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 600; background: var(--surface-2); }
td.r, th.r { text-align: right; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--accent-soft); }
tr.total td { font-weight: 700; border-top: 2px solid var(--accent); }
tr.profit td { font-weight: 700; color: var(--accent); font-size: 16px; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.pill.done { background: var(--ok-soft); color: var(--ok); }
.pill.scheduled { background: var(--sched); color: var(--accent); }
.pill.cancelled { background: var(--bad-soft); color: var(--bad); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.kpi { padding: 14px 16px; }
.kpi .l { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.kpi .v { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi.hl { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.kpi.hl .l { color: var(--accent-ink); opacity: .85; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.hours { display: flex; gap: 6px 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.hours b { color: var(--fg); font-weight: 600; }
input[type=text], input[type=tel], input[type=email], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
textarea { min-height: 64px; resize: vertical; }
label.f { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }

/* Modal */
.overlay { position: fixed; inset: 0; background: rgba(20,16,10,.45); z-index: 20; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.modal { width: min(520px, 100%); max-height: 100%; overflow: auto; background: var(--surface); border-radius: 12px; border: 1px solid var(--line); padding: 18px; display: grid; gap: 12px; }
.modal h3 { margin: 0; font-size: 17px; }
.modal .actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-top: 4px; }
.warn { font-size: 12px; color: var(--bad); }
.hist { font-size: 13px; display: grid; gap: 4px; max-height: 180px; overflow: auto; }
.hist div { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--line); padding: 4px 0; }
@media (prefers-reduced-motion: no-preference) { .overlay { animation: fade .12s ease-out; } @keyframes fade { from { opacity: 0 } } }

.who { display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--muted); }
.who a, .linkbtn { color: var(--accent); font-weight: 600; text-decoration: none; background: none; border: 0; padding: 0; cursor: pointer; font-size: 12px; }
.auth { max-width: 400px; margin: 10vh auto 0; padding: 24px; display: grid; gap: 14px; }
.auth h1 { margin: 0; font-size: 20px; }
.err { color: var(--bad); font-size: 13px; }
.okmsg { color: var(--ok); font-size: 13px; }
.page { max-width: 900px; margin: 0 auto; padding-block: 18px 40px; display: grid; gap: 16px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.inline { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.inline input { width: auto; min-width: 140px; }
