/* Zatitude bath tracker. Colors are tokens; dark mode follows the system. Mobile first: the installer uses a phone. */
:root {
  --bg: #F3F4F6;
  --surface: #FFFFFF;
  --surface-2: #F8F9FB;
  --ink: #1F2933;
  --muted: #5B6472;
  --line: #E3E6EA;
  --brand: #1F2933;
  --brand-hover: #323E4D;
  --on-brand: #FFFFFF;
  --tint: #EEF1F5;
  --accent: #B5842A;
  --ok: #0E7A4D;
  --ok-bg: #E6F4EC;
  --info: #1D5FA8;
  --info-bg: #E8F0FA;
  --warn-ink: #8A4B00;
  --warn-bg: #FFF4DF;
  --danger: #B42318;
  --danger-bg: #FDE9E7;
  --focus: #2F6FD6;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1217; --surface: #171C24; --surface-2: #1C222C; --ink: #E6E9EE; --muted: #9AA4B2; --line: #2A313C;
    --brand: #D9DEE6; --brand-hover: #FFFFFF; --on-brand: #0F1217; --tint: #232B37; --accent: #E0B45A;
    --ok: #4CC38A; --ok-bg: #12301F; --info: #7AA5F0; --info-bg: #182539; --warn-ink: #F5C46B; --warn-bg: #2E2410;
    --danger: #F97066; --danger-bg: #3A1A17; --focus: #8DB4F5; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1217; --surface: #171C24; --surface-2: #1C222C; --ink: #E6E9EE; --muted: #9AA4B2; --line: #2A313C;
  --brand: #D9DEE6; --brand-hover: #FFFFFF; --on-brand: #0F1217; --tint: #232B37; --accent: #E0B45A;
  --ok: #4CC38A; --ok-bg: #12301F; --info: #7AA5F0; --info-bg: #182539; --warn-ink: #F5C46B; --warn-bg: #2E2410;
  --danger: #F97066; --danger-bg: #3A1A17; --focus: #8DB4F5; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  overflow-wrap: break-word; -webkit-tap-highlight-color: transparent;
}
a { color: var(--info); }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 24px; }
h2 { font-size: 17px; margin-bottom: 10px; }
h2 .chip { vertical-align: middle; margin-left: 6px; }
h2.section { margin: 22px 0 10px; }
p { margin: 0 0 12px; }
small { font-size: 60%; font-weight: 400; color: var(--muted); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.danger { color: var(--danger); }
.warn-ink { color: var(--warn-ink); }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.lead { font-size: 16px; }
.empty { padding: 12px 0; }
code { background: var(--tint); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.print-only { display: none; }

/* ---------- Header ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 14px; min-height: 58px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); flex: none; font-weight: 700; }
.brand img { height: 34px; width: auto; background: #fff; border-radius: 6px; padding: 2px 6px; }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav::-webkit-scrollbar { display: none; }
.nav a { padding: 8px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 600; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { color: var(--brand); background: var(--tint); }
.who { display: flex; align-items: center; gap: 8px; flex: none; font-size: 13px; color: var(--muted); }
.who .name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-weight: 600; }
.who form { margin: 0; }
@media (max-width: 720px) {
  .brand span { display: none; }
  .who .muted, .who .name { display: none; }
  .topbar-inner { gap: 8px; }
}

main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 64px; }
main.wide { max-width: 1400px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 .muted { font-weight: 400; font-size: 17px; }
.page-head p { margin: 2px 0 0; }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 7px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-hover); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.ghost { border-color: transparent; }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn.grow { flex: 1; }
.btn[disabled] { opacity: .5; cursor: default; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; min-height: 40px; max-width: 100%;
}
textarea { min-height: 60px; width: 100%; resize: vertical; }
input[type="checkbox"] { min-height: 0; width: 18px; height: 18px; vertical-align: middle; }
label { font-size: 14px; color: var(--muted); display: block; }
label > input, label > select, label > textarea { display: block; width: 100%; margin-top: 4px; color: var(--ink); }
label.check { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); }
label.span { grid-column: 1 / -1; }
.stack > * + * { margin-top: 10px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row label { display: inline-flex; align-items: center; gap: 6px; }
.row label > select, .row label > input { width: auto; margin-top: 0; }
.inline { display: inline; margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 14px; }
.form-grid fieldset { grid-column: 1 / -1; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px 12px; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 14px; }
.form-grid legend { color: var(--ink); font-weight: 600; padding: 0 6px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filters input[type="search"] { width: 110px; }
details.sub { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
details.sub > summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--muted); }
details.sub[open] > summary { margin-bottom: 8px; color: var(--ink); }
.copy { width: 100%; font-size: 13px; margin: 6px 0; }

/* ---------- Cards, tiles, tables ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; align-items: start; } }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.tile-label { font-size: 12px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); }
.tile-value { font-size: 28px; font-weight: 700; line-height: 1.2; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.tile-sub { font-size: 13px; min-height: 18px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.table.compact td, .table.compact th { padding: 5px 8px; }
.table tr.inactive { opacity: .6; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table-wrap .table td, .table-wrap .table th { white-space: nowrap; }
.table-wrap .table td:first-child { white-space: normal; }
.sel { width: 28px; }
.unit-link { font-weight: 700; font-size: 16px; text-decoration: none; }
.bath-cell { white-space: nowrap; }
.bar { display: inline-block; width: 90px; height: 8px; background: var(--tint); border-radius: 4px; vertical-align: middle; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--ok); }
.funnel-row { display: grid; grid-template-columns: 120px 1fr 40px; align-items: center; gap: 8px; padding: 3px 0; font-size: 14px; }
.funnel-bar { height: 12px; background: var(--tint); border-radius: 6px; overflow: hidden; }
.funnel-bar > span { display: block; height: 100%; background: var(--info); min-width: 2px; }
.funnel-n { text-align: right; font-variant-numeric: tabular-nums; }
.facts { display: grid; grid-template-columns: 140px 1fr; gap: 4px 10px; margin: 0 0 8px; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: 4px 0; }
.bulk { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px 14px; }
.bulk label { display: inline-flex; align-items: center; gap: 6px; }
.bulk label > select, .bulk label > input { width: auto; margin-top: 0; }

/* ---------- Chips ---------- */
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; line-height: 1.5; white-space: nowrap; background: var(--tint); color: var(--ink); }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.info { background: var(--info-bg); color: var(--info); }
.chip.warn { background: var(--warn-bg); color: var(--warn-ink); }
.chip.danger { background: var(--danger-bg); color: var(--danger); }
.chip.muted { color: var(--muted); }
.chip.work { background: var(--warn-bg); color: var(--warn-ink); }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.flash.error { background: var(--danger-bg); color: var(--danger); }

/* ---------- Unit page ---------- */
.card.access { border-left: 5px solid var(--muted); }
.card.access.open { border-left-color: var(--ok); }
.card.access.waiting { border-left-color: var(--info); }
.card.access.closed { border-left-color: var(--warn-ink); }
.card.access.blocked { border-left-color: var(--danger); }
.card.bath { border-left: 5px solid var(--line); }
.card.bath.blocked { border-left-color: var(--danger); }
.bath-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.scope { font-size: 14px; }
.steps { display: flex; gap: 4px; list-style: none; padding: 0; margin: 8px 0 12px; }
.steps li { flex: 1; height: 8px; border-radius: 4px; background: var(--tint); position: relative; }
.steps li span { position: absolute; left: 0; right: 0; top: 10px; font-size: 10px; text-align: center; color: var(--muted); }
.steps li.done { background: var(--ok); }
.steps li.current { background: var(--info); }
.stage-actions { margin: 18px 0 8px; flex-wrap: wrap; }
.bath-notes { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; font-size: 14px; margin: 8px 0 0; }
.notes .note { padding: 8px 0; border-bottom: 1px solid var(--line); }
.notes .note.staff { background: var(--warn-bg); border-radius: 6px; padding: 8px; }
.note-meta { font-size: 13px; }

/* ---------- Today ---------- */
.day-nav { flex-wrap: wrap; margin-bottom: 14px; }
.day-nav input[type="date"] { min-height: 40px; }
.today-list { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 900px) { .today-list { grid-template-columns: 1fr 1fr; } }
.today-item { margin: 0; border-left: 5px solid var(--ok); }
.today-item.waiting { border-left-color: var(--info); opacity: .9; }
.today-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.today-head h2 { margin: 0; font-size: 20px; }
.today-head a { text-decoration: none; color: var(--ink); }
.access-line, .pets, .req { margin-top: 6px; }
.today-bath { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.today-bath .pos { font-weight: 700; min-width: 56px; }
.today-bath form { margin-left: auto; }
ul.baths { margin-top: 8px; }

/* ---------- People ---------- */
.person-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 6px; }
.person-fields { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.person-fields input[type="text"] { width: 160px; }
.person-fields label.check { color: var(--muted); font-size: 13px; }
.table.people td { padding: 12px 4px; }

/* ---------- Auth pages (before signing in) ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth .card { width: 100%; max-width: 420px; padding: 28px; }
.auth .logo { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 18px; text-align: center; }
.auth .logo img { width: 180px; background: #fff; border-radius: 8px; padding: 6px; }
.auth .logo span { font-size: 13px; color: var(--muted); font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; }
.auth h1 { font-size: 22px; margin-bottom: 6px; }
.auth form { margin-top: 14px; }
.auth form label, .auth form input, .auth form button { width: 100%; }
.auth form button { margin-top: 10px; }
.msg { margin-top: 12px; font-size: 14px; min-height: 20px; }
.ok-text { color: var(--ok); }
.error-text { color: var(--danger); }
.dev-link { margin-top: 8px; font-weight: 700; }

@media print {
  .no-print, .topbar, .btn, form, .nav { display: none !important; }
}
