:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --line: #e3e9f1;
  --text: #0f1b2d;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-2: #1d4ed8;
  --soft: #eaf1ff;
  --ok: #059669;
  --warn: #d97706;
  --bad: #dc2626;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 400 15px/1.5 'Inter', system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { margin: 0; font-family: 'Plus Jakarta Sans', 'Inter', sans-serif; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 1.9rem; line-height: 1.15; }
h2 { font-size: 1.08rem; }
h3 { font-size: 0.8rem; margin: 22px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
small { display: block; color: var(--muted); font-size: 0.8rem; }
.muted { color: var(--muted); }
button { font: inherit; }

.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px; padding: 22px 16px; background: #0b1b3a; color: #fff; }
.logo { display: flex; align-items: center; gap: 10px; color: #fff; font: 700 1.3rem/1 'Plus Jakarta Sans', sans-serif; padding: 0 8px; }
.logo small { display: inline; color: #9fb4da; font: 500 0.95rem/1 'Inter', sans-serif; margin-left: -4px; }
.logo-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--primary); }
.logo-mark svg { width: 20px; height: 20px; fill: #fff; }
.nav { display: grid; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: #b7c5e0; font-weight: 500; }
.nav a svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.nav a.on { color: #fff; background: rgba(255, 255, 255, 0.12); }
.side-app { padding: 10px 12px; border: 1px dashed rgba(159, 180, 218, 0.6); border-radius: 10px; color: #cfe0ff; font-weight: 600; font-size: 0.9rem; }
.side-foot { margin-top: auto; display: grid; gap: 8px; padding: 0 8px; font-size: 0.82rem; }
.demo-badge { justify-self: start; padding: 4px 9px; border-radius: 999px; background: rgba(251, 191, 36, 0.16); color: #fbbf24; font-weight: 600; font-size: 0.75rem; }
.clock:empty { display: none; }
.clock { color: #9fb4da; font-size: 0.78rem; }
.linkish { justify-self: start; background: none; border: 0; padding: 0; color: #9fb4da; cursor: pointer; text-decoration: underline; }
.by { color: #9fb4da; }

.main { padding: 30px 34px 60px; min-width: 0; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.eyebrow { margin: 0 0 6px; color: var(--primary); font-size: 0.78rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 15px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--text); font-weight: 600; font-size: 0.88rem; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #c5d0de; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-2); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 11px; font-size: 0.8rem; }
.btn-block { width: 100%; margin-top: 18px; }
.btn-group { display: flex; gap: 6px; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; }
.kpi span { color: var(--muted); font-size: 0.82rem; }
.kpi strong { display: block; font: 700 1.9rem/1.15 'Plus Jakarta Sans', sans-serif; margin: 6px 0 2px; }
.kpi em { font-style: normal; color: var(--muted); font-size: 0.78rem; }
.kpi-warn strong { color: var(--warn); }

.docs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.doc { background: var(--panel); border: 1px solid var(--line); border-top: 4px solid var(--c); border-radius: 16px; padding: 14px 16px; }
.doc-top { display: flex; gap: 10px; align-items: center; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.doc-load { margin: 12px 0 8px; display: grid; gap: 4px; }
.doc-now { margin: 4px 0 0; font-size: 0.86rem; }
.bar { display: block; height: 7px; border-radius: 99px; background: #edf1f7; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: var(--c, var(--primary)); }

.grid2 { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); gap: 16px; }
.grid3 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.card-head a { font-size: 0.85rem; }
.count { display: inline-grid; place-items: center; min-width: 24px; height: 24px; margin-left: 6px; padding: 0 7px; border-radius: 99px; background: var(--soft); color: var(--primary); font-size: 0.8rem; }

.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.click { cursor: pointer; }
.row.click:hover, tr.click:hover { background: #f8fafd; }
.grow { flex: 1; min-width: 0; }
.grow strong { display: block; }
.time { min-width: 48px; color: var(--primary); font-weight: 600; font-variant-numeric: tabular-nums; }

.av { display: inline-grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 50%; font-weight: 600; font-size: 0.8rem; }
.av-f { background: #fde7f1; color: #be185d; }
.av-m { background: #e0ecff; color: #1d4ed8; }
.av.lg { width: 52px; height: 52px; font-size: 1.05rem; }
.chip { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 0.74rem; font-weight: 600; white-space: nowrap; background: #eef2f7; color: var(--muted); }
.chip-booked { background: var(--soft); color: var(--primary); }
.chip-arrived { background: #fff4e0; color: #b45309; }
.chip-in { background: #dcfce7; color: #047857; }
.chip-done { background: #eef2f7; color: #475569; }
.chip-noshow, .chip-cancelled { background: #fee2e2; color: var(--bad); }
.chip-online { background: #ede9fe; color: #6d28d9; }
.chip-allergy { background: #fee2e2; color: var(--bad); }
.alert { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; }

.chart { width: 100%; height: 170px; display: block; }
.chart rect { fill: var(--primary); opacity: 0.85; }
.chart rect:last-child { fill: #10b981; }
.chart-x { display: flex; margin-top: 6px; }
.chart-x span { flex: 1; text-align: center; color: var(--muted); font-size: 0.74rem; }

/* calendar */
.legend { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; font-size: 0.85rem; }
.cal-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; }
.cal { display: grid; grid-template-columns: 64px repeat(4, minmax(170px, 1fr)); min-width: 760px; position: relative; }
.cal-corner { grid-row: 1; grid-column: 1; border-bottom: 1px solid var(--line); }
.cal-doc { grid-row: 1; padding: 8px 10px; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); border-top: 3px solid var(--c); }
.cal-doc strong { display: block; font-size: 0.86rem; }
.cal-time { grid-column: 1; padding: 0 10px; font-size: 0.75rem; color: var(--muted); transform: translateY(-8px); }
.cal-free { margin: 2px 4px; border: 1px dashed transparent; border-radius: 8px; background: none; color: transparent; font-size: 0.75rem; cursor: pointer; }
.cal-free:hover, .cal-free:focus-visible { border-color: #b8c7de; color: var(--primary); background: #f5f8fd; }
.cal-free.is-past { cursor: default; background: repeating-linear-gradient(135deg, transparent 0 6px, #f6f8fb 6px 12px); }
.cal-lunch { grid-column: 2 / -1; display: grid; place-items: center; margin: 2px 4px; border-radius: 8px; background: repeating-linear-gradient(135deg, #f2f5f9 0 8px, #eaeff5 8px 16px); color: var(--muted); font-size: 0.8rem; font-weight: 600; }
.appt { position: relative; margin: 2px 4px; padding: 4px 9px; line-height: 1.3; border-radius: 9px; border: 0; border-left: 4px solid var(--c); background: color-mix(in srgb, var(--c) 14%, white); color: var(--text); text-align: left; cursor: pointer; overflow: hidden; }
.appt strong { display: block; font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt small { font-size: 0.72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt:hover { filter: brightness(0.97); box-shadow: 0 4px 12px rgba(15, 27, 45, 0.12); }
.appt.st-arrived { background: #fff4e0; border-left-color: #f59e0b; }
.appt.st-in { background: var(--c); color: #fff; }
.appt.st-in small { color: rgba(255, 255, 255, 0.85); }
.appt.st-done { background: #f1f4f8; border-left-color: #cbd5e1; color: #64748b; }
.appt.st-noshow { background: repeating-linear-gradient(135deg, #fff1f1 0 6px, #fde4e4 6px 12px); border-left-color: var(--bad); color: #9f1d1d; }

/* tables */
.toolbar { display: flex; gap: 12px; margin-bottom: 14px; }
.search { display: flex; flex: 1; }
.search input, .form input, .form select, .form textarea { width: 100%; padding: 11px 13px; border-radius: 11px; border: 1px solid var(--line); background: #fff; color: var(--text); font: inherit; }
.search input:focus, .form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid var(--primary); border-color: transparent; }
.table-card { padding: 4px 6px; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; color: var(--muted); font-size: 0.76rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; padding: 12px 12px 8px; }
.table td { padding: 11px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
.table .end { text-align: right; }
.who { display: flex; align-items: center; gap: 12px; }
.who strong { display: block; }

/* drawer */
.drawer { position: fixed; inset: 0; z-index: 50; }
.dr-back { position: absolute; inset: 0; background: rgba(15, 27, 45, 0.4); }
.dr-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(460px, 100%); overflow-y: auto; background: #fff; padding: 24px 24px 40px; box-shadow: -20px 0 50px rgba(15, 27, 45, 0.18); animation: slide 0.25s ease; }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.dr-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.dr-head h2 { font-size: 1.5rem; }
.x { border: 0; background: #eef2f7; color: var(--text); width: 34px; height: 34px; border-radius: 50%; font-size: 1.3rem; cursor: pointer; flex: none; }
.appt-card { margin: 14px 0; padding: 16px; border-radius: 14px; background: color-mix(in srgb, var(--c) 10%, white); border-left: 4px solid var(--c); }
.appt-card > div { display: flex; justify-content: space-between; font-size: 0.86rem; font-weight: 600; color: var(--muted); }
.appt-card strong { display: block; font: 700 1.3rem/1.2 'Plus Jakarta Sans', sans-serif; margin: 6px 0 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.notes { display: grid; grid-template-columns: 100px 1fr; gap: 8px 12px; margin: 0; }
.notes dt { color: var(--muted); font-size: 0.85rem; }
.notes dd { margin: 0; }
.unpaid { color: var(--bad); }
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 16px 6px; }
.timeline li::before { content: ''; position: absolute; left: -26px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--c, var(--primary)); }
.timeline span { font-size: 0.78rem; color: var(--muted); }
.timeline strong { display: block; }
.timeline p { margin: 2px 0 0; color: var(--muted); font-size: 0.88rem; }
.form { display: grid; gap: 14px; margin-top: 14px; }
.form label { display: grid; gap: 6px; font-weight: 600; font-size: 0.88rem; }
.results { margin-top: -6px; }
.newp summary { cursor: pointer; color: var(--primary); font-weight: 600; font-size: 0.88rem; }
.newp[open] { display: grid; gap: 10px; }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 60; transform: translateX(-50%); padding: 12px 18px; border-radius: 12px; background: #0f1b2d; color: #fff; box-shadow: 0 16px 40px rgba(15, 27, 45, 0.3); font-weight: 600; }
.toast-warn { background: #7c2d12; }

@media (max-width: 1150px) {
  .docs, .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; align-items: center; gap: 10px; padding: 10px 12px; overflow-x: auto; }
  .logo { font-size: 1.1rem; padding: 0; }
  .logo small { display: none; }
  .nav { display: flex; gap: 2px; }
  .nav a span { display: none; }
  .side-app, .side-foot { display: none; }
  .main { padding: 20px 16px 60px; }
  .grid2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .dr-panel { animation: none; } }
