/* SafeVisit Monitor — calm, steady, institutional without being cold. */
:root {
  --ink: #1d2b3a;
  --ink-2: #4a5a69;
  --bg: #eef2f1;
  --surface: #ffffff;
  --line: #d3dcdd;
  --accent: #1d6b5a;
  --accent-ink: #ffffff;
  --accent-soft: #ddece7;
  --warn: #9a5b12;
  --warn-soft: #fbefd9;
  --danger: #a5281b;
  --danger-soft: #fbe3df;
  --info-soft: #e1ebf5;
  --focus: #2c6fb7;
  --serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e4ebea; --ink-2: #a5b3b6; --bg: #121a1f; --surface: #1a252c; --line: #2d3c44;
    --accent: #4fb39a; --accent-ink: #0e1a17; --accent-soft: #1f3a33;
    --warn: #e0a557; --warn-soft: #3a2c17; --danger: #f08072; --danger-soft: #3d201c; --info-soft: #1d2d3d;
    --focus: #7db4ee; color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.55 var(--sans); color: var(--ink); background: var(--bg); min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: 1.9rem; letter-spacing: -.01em; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; margin-top: 1.4em; }
h1 small { font-family: var(--sans); font-size: .95rem; font-weight: 400; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--ink-2); }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.print-only { display: none; }

/* ---------- Top bar ---------- */
.topbar { display: flex; align-items: center; gap: 1.5rem; padding: .7rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .55rem; color: var(--ink); text-decoration: none; font-family: var(--serif); font-weight: 600; font-size: 1.1rem; }
.mark { width: 30px; height: 30px; color: var(--accent); }
.mainnav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.mainnav a { padding: .45rem .8rem; border-radius: 6px; color: var(--ink-2); text-decoration: none; font-weight: 500; }
.mainnav a:hover { color: var(--ink); background: var(--bg); }
.mainnav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.userbox { display: flex; align-items: center; gap: .9rem; }
.userbox form { margin: 0; }
.who { display: flex; flex-direction: column; text-decoration: none; color: var(--ink); line-height: 1.2; text-align: right; }
.who small { color: var(--ink-2); }
.idle-warning { background: var(--warn-soft); color: var(--warn); text-align: center; padding: .6rem; font-weight: 600; }

.page { width: 100%; max-width: 1180px; margin: 0 auto; padding: 2rem 1.5rem 3rem; }
.foot { text-align: center; color: var(--ink-2); font-size: .85rem; padding: 1.5rem; }
.crumbs { margin-bottom: .4rem; font-size: .95rem; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.title-row h1, .title-row h2 { margin-bottom: .5em; }

/* ---------- Panels & grids ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1.4rem 1.5rem; margin-bottom: 1.25rem; }
.panel.narrow { max-width: 560px; }
.panel.live { border-left: 5px solid var(--accent); }
.panel.attn { border-left: 5px solid var(--warn); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.25rem; align-items: start; }
.grid-2 > .panel { margin-bottom: 0; }
.grid-2 + .panel, .grid-2 + section { margin-top: 1.25rem; }

details.create > summary, details.sub > summary { cursor: pointer; font-family: var(--serif); font-weight: 600; font-size: 1.1rem; list-style: none; display: flex; align-items: center; gap: .5rem; }
details.create > summary::-webkit-details-marker, details.sub > summary::-webkit-details-marker { display: none; }
details.create > summary::before, details.sub > summary::before { content: "+"; display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-family: var(--sans); }
details[open].create > summary::before, details[open].sub > summary::before { content: "−"; }
details[open] > summary { margin-bottom: 1rem; }
details.sub { margin-top: 1.2rem; }
details.sub > summary { font-size: 1rem; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); border: 1px solid var(--line); border-radius: 10px; background: var(--surface); margin-bottom: 1.5rem; overflow: hidden; }
.stat { padding: 1rem 1.2rem; border-right: 1px solid var(--line); color: var(--ink); text-decoration: none; display: flex; flex-direction: column; }
.stat:last-child { border-right: 0; }
.stat b { font-family: var(--serif); font-size: 2rem; font-weight: 600; line-height: 1.1; }
.stat span { color: var(--ink-2); font-size: .9rem; }
a.stat:hover { background: var(--bg); }
.stat-live b { color: var(--accent); }
.stat-attn b { color: var(--warn); }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 1rem; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem 1.25rem; }
.span-2 { grid-column: 1 / -1; }
.form-actions { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: .3rem; }
.field > span { font-weight: 600; font-size: .92rem; }
.field small { color: var(--ink-2); font-size: .84rem; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid #b7c3c6; border-radius: 6px; padding: .6rem .7rem; width: 100%; min-height: 44px; }
@media (prefers-color-scheme: dark) { input, select, textarea { border-color: #3d4f58; background: #142027; } }
textarea { resize: vertical; min-height: 0; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.filters { display: flex; gap: .8rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.filters .field { min-width: 170px; }
.inline-form { flex-direction: row; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { flex: 1; min-width: 200px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: 600 .95rem/1 var(--sans); padding: .7rem 1.1rem; min-height: 44px; border-radius: 6px; border: 1px solid #b7c3c6; background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-sm { min-height: 34px; padding: .4rem .7rem; font-size: .85rem; }
.btn-lg { padding: 1rem 1.6rem; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; }
.btn-row form { margin: 0; }
.end-visit { margin-top: 1.2rem; padding-top: 1.2rem; border-top: 1px dashed var(--line); }

/* ---------- Alerts & badges ---------- */
.alert { padding: .8rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid transparent; }
.alert-success { background: var(--accent-soft); border-color: var(--accent); }
.alert-error { background: var(--danger-soft); border-color: var(--danger); }
.alert-info { background: var(--info-soft); border-color: var(--focus); }
.badge { display: inline-block; font: 600 .78rem/1 var(--sans); padding: .35rem .55rem; border-radius: 999px; background: var(--bg); color: var(--ink-2); border: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.b-scheduled, .b-active { background: var(--info-soft); color: var(--ink); border-color: transparent; }
.b-in_progress { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.b-completed { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.b-requested, .b-on_hold, .b-medium { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.b-no_show, .b-high { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.b-critical { background: var(--danger); color: #fff; border-color: transparent; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .75rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .85rem; color: var(--ink-2); font-weight: 600; background: var(--bg); }
tbody tr:last-child td { border-bottom: 0; }
table.dense td { padding: .5rem .8rem; font-size: .9rem; }
.panel .table-wrap { border: 0; border-radius: 0; margin: 0 -1.5rem; }
.row-dim td { opacity: .55; }

/* ---------- Lists ---------- */
.plain { list-style: none; margin: 0; padding: 0; }
.plain li { padding: .55rem 0; border-bottom: 1px solid var(--line); }
.plain li:last-child { border-bottom: 0; }
.people { list-style: none; padding: 0; margin: 0 0 1rem; }
.people li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.people form { margin: 0; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.2rem; margin: 1rem 0; }
.facts dt { color: var(--ink-2); font-size: .92rem; }
.facts dd { margin: 0; }
.facts-wide { margin-top: 0; }

.visit-list { list-style: none; margin: 0; padding: 0; }
.visit-list a { display: grid; grid-template-columns: 8.5rem 1fr auto; gap: 1rem; align-items: center; padding: .85rem .5rem; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; border-radius: 6px; }
.visit-list li:last-child a { border-bottom: 0; }
.visit-list a:hover { background: var(--bg); }
.vl-when { display: flex; flex-direction: column; color: var(--ink-2); font-size: .9rem; }
.vl-when b { color: var(--ink); font-family: var(--serif); font-size: 1.15rem; }
.vl-what { display: flex; flex-direction: column; }
.vl-what small { color: var(--ink-2); }

/* ---------- Visit record ---------- */
.restrictions { background: var(--warn-soft); border-radius: 8px; padding: .9rem 1.1rem; margin-top: 1rem; }
.restrictions p { margin: .3rem 0 0; }
.restrictions-loud { border-left: 5px solid var(--warn); margin: 0 0 1.25rem; }
.action-panel h2 { margin-bottom: .4rem; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 5.5rem 1fr; gap: 1rem; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline time { font-family: var(--serif); font-weight: 600; color: var(--accent); }
.timeline p { margin: 0; }
.incident { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--warn); border-radius: 8px; padding: 1rem 1.2rem; margin-bottom: .9rem; }
.incident.sev-low { border-left-color: var(--line); }
.incident.sev-high, .incident.sev-critical { border-left-color: var(--danger); }
.incident header { display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; margin-bottom: .5rem; }
.incident p:last-child { margin-bottom: 0; }

/* ---------- Login ---------- */
body.auth { background: var(--bg); }
.auth-main { display: grid; place-items: center; padding: 2rem 1rem; }
.login-wrap { width: 100%; max-width: 440px; }
.login-intro { text-align: center; margin-bottom: 1.5rem; }
.login-mark .mark { width: 54px; height: 54px; }
.login-intro h1 { margin: .4rem 0 .2rem; }
.login-intro p { color: var(--ink-2); margin: 0; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1.75rem; display: flex; flex-direction: column; gap: 1rem; }
.login-card fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.login-card legend { font-weight: 600; font-size: .92rem; margin-bottom: .55rem; padding: 0; }
.fine { font-size: .85rem; color: var(--ink-2); text-align: center; margin: 0; }

/* The two doors: the one memorable element */
.doors { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.doors legend { grid-column: 1 / -1; }
.door { display: flex; flex-direction: column; justify-content: flex-end; min-height: 128px; padding: 1rem; cursor: pointer;
        border: 2px solid var(--line); border-radius: 64px 64px 10px 10px; background: var(--bg);
        transition: background-color .18s ease, border-color .18s ease, color .18s ease; }
.door strong { font-family: var(--serif); font-size: 1.35rem; font-weight: 600; }
.door span { font-size: .85rem; color: var(--ink-2); line-height: 1.3; }
.door:hover { border-color: var(--accent); }
#portal-client:checked ~ .doors .door-client,
#portal-staff:checked ~ .doors .door-staff { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
#portal-client:checked ~ .doors .door-client span,
#portal-staff:checked ~ .doors .door-staff span { color: var(--accent-ink); opacity: .85; }
#portal-client:focus-visible ~ .doors .door-client,
#portal-staff:focus-visible ~ .doors .door-staff { outline: 3px solid var(--focus); outline-offset: 3px; }

.staff-roles { display: none; }
#portal-staff:checked ~ .staff-roles { display: block; }
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 8px; padding: 4px; background: var(--bg); }
.seg label { text-align: center; padding: .6rem; border-radius: 6px; cursor: pointer; font-weight: 600; color: var(--ink-2); }
.seg input:checked + label { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.seg input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 1px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Small screens ---------- */
@media (max-width: 720px) {
  .topbar { padding: .7rem 1rem; gap: .7rem; }
  .mainnav { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .userbox { margin-left: auto; }
  .who small { display: none; }
  .page { padding: 1.25rem 1rem 2rem; }
  h1 { font-size: 1.5rem; }
  .panel { padding: 1.1rem; }
  .panel .table-wrap { margin: 0 -1.1rem; }
  .visit-list a { grid-template-columns: 1fr auto; }
  .vl-when { grid-column: 1 / -1; flex-direction: row; gap: .5rem; align-items: baseline; }
  .stat { border-right: 0; border-bottom: 1px solid var(--line); }
  .door { min-height: 110px; }
}

/* ---------- Print: clean report for court or file ---------- */
@media print {
  :root { --ink: #000; --ink-2: #444; --bg: #fff; --surface: #fff; --line: #bbb; }
  body { background: #fff; font-size: 11pt; }
  .topbar, .foot, .no-print, .btn, form, details, .idle-warning, .crumbs, .alert { display: none !important; }
  .print-only { display: block; }
  .page { max-width: none; padding: 0; }
  .panel { border: 0; padding: 0; margin-bottom: 1.2rem; break-inside: avoid; }
  .grid-2 { display: block; }
  .badge { border: 1px solid #000; background: none !important; color: #000 !important; }
  a { color: #000; text-decoration: none; }
}
