/* MedIntake design layer (2026-11-05): calm medical teal, sidebar app shell, refined components.
   Loaded after app.css; overrides tokens + component look. System fonts only (CSP: font-src 'self', no external font hosts). */
:root {
  --bg: #f2f6f8;
  --panel: #ffffff;
  --ink: #0f2e3d;
  --ink-soft: #4a6572;
  --line: #dde7ec;
  --line-strong: #c3d3db;
  --accent: #0b7a8f;
  --accent-dark: #075e70;
  --accent-soft: #e2f3f6;
  --accent-ink: #ffffff;
  --ok: #067a55;
  --ok-soft: #dcf3ea;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #8a5a00;
  --warn-soft: #fdf1d6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 46, 61, .05), 0 4px 14px rgba(15, 46, 61, .05);
  --ring: 0 0 0 3px rgba(11, 122, 143, .28);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
h1 { font-size: 1.55rem; line-height: 1.25; letter-spacing: -.01em; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 650; letter-spacing: -.005em; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-dark); }
.muted { color: var(--ink-soft); }

/* ── App shell ─────────────────────────────────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }
.side {
  flex: 0 0 252px; width: 252px; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.side .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; padding: 4px 10px 18px; color: var(--ink); text-decoration: none; }
.side .brand img { width: 28px; height: 28px; }
.side .nav-label { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); padding: 16px 12px 6px; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 9px; color: var(--ink-soft);
  text-decoration: none; font-size: .93rem; font-weight: 500; min-height: 42px; transition: background .15s, color .15s;
}
.side nav a svg { width: 18px; height: 18px; flex: 0 0 18px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.side nav a:hover { background: var(--bg); color: var(--ink); }
.side nav a.active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 650; }
.side .side-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.side .practice-chip { font-size: .8rem; color: var(--ink-soft); padding: 0 6px; line-height: 1.35; }
.side .practice-chip strong { display: block; color: var(--ink); font-size: .88rem; }
.lang-links { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 4px; }
.lang-links a, .lang-links strong { font-size: .74rem; padding: 3px 7px; border-radius: 6px; text-decoration: none; }
.lang-links a { color: var(--ink-soft); border: 1px solid var(--line); }
.lang-links a:hover { background: var(--bg); color: var(--ink); }
.lang-links strong { background: var(--accent); color: #fff; }
.main { flex: 1 1 auto; min-width: 0; padding: 32px 36px 56px; }
.main-inner { max-width: 1040px; margin: 0 auto; }
.main .wrap { max-width: none; padding: 0; }

/* ── Cards, headings ───────────────────────────────────────────────────────────────────────── */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px 26px; margin-bottom: 20px; }
.panel > h1:first-child, .panel > h2:first-child { margin-top: 0; }
.page-head { margin-bottom: 22px; }
.page-head h1 { margin-bottom: 2px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }

/* ── Buttons ───────────────────────────────────────────────────────────────────────────────── */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 18px; min-height: 40px; border-radius: 9px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); font: inherit; font-size: .92rem; font-weight: 600;
  line-height: 1.2; cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, box-shadow .15s;
}
button:hover, .btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn-secondary, button.btn-secondary { background: #fff; color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover, button.btn-secondary:hover { background: var(--bg); border-color: var(--ink-soft); color: var(--ink); }
.btn-danger, button.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #8f1c12; border-color: #8f1c12; }
.btn-sm { padding: 5px 12px; min-height: 34px; font-size: .84rem; }
button:focus-visible, .btn:focus-visible, a:focus-visible, summary:focus-visible { outline: none; box-shadow: var(--ring); }
button:disabled { opacity: .55; cursor: not-allowed; }

/* ── Forms ─────────────────────────────────────────────────────────────────────────────────── */
label { font-size: .86rem; font-weight: 600; color: var(--ink); margin: 16px 0 5px; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number], input[type=date], select, textarea {
  min-height: 42px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 9px; font: inherit; font-size: .95rem; background: #fff; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 110px; line-height: 1.5; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-soft); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
input:disabled { background: var(--bg); color: var(--ink-soft); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
.field-row { gap: 14px; align-items: flex-end; }

/* ── Tables ────────────────────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table.data, table { border-collapse: separate; border-spacing: 0; width: 100%; }
table.data th, th { background: #f7fafb; color: var(--ink-soft); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 11px 14px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.data td, td { padding: 13px 14px; border-bottom: 1px solid var(--line); font-size: .92rem; vertical-align: middle; }
table.data tbody tr:last-child td, tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #f9fcfd; }
.panel > table { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }

/* ── Badges, chips, alerts ─────────────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 650; background: var(--bg); color: var(--ink-soft); border: 1px solid var(--line); }
.badge-completed { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge-draft { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-archived { background: #eceff1; color: var(--ink-soft); border-color: transparent; }
.chip { background: var(--accent-soft); color: var(--accent-dark); }
.alert { border-radius: 10px; padding: 12px 16px; margin: 0 0 18px; font-size: .92rem; border: 1px solid transparent; }
.alert-ok { background: var(--ok-soft); color: #064e38; border-color: #b5e4d1; }
.alert-error { background: var(--danger-soft); color: #7a1c14; border-color: #f4c0ba; }
.alert-warn { background: var(--warn-soft); color: #5e3d00; border-color: #f0d9a0; }
code { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: .85em; }

/* ── Stats, icons, empty states, steps ─────────────────────────────────────────────────────── */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; display: flex; gap: 14px; align-items: center; }
.stat-card .label { font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.stat-card .value { font-size: 1.35rem; font-weight: 700; color: var(--ink); line-height: 1.25; }
.stat-card a { font-size: .8rem; }
.icon-badge { width: 40px; height: 40px; border-radius: 11px; background: var(--accent-soft); display: grid; place-items: center; flex: 0 0 auto; }
.icon-badge svg { width: 20px; height: 20px; stroke: var(--accent-dark); fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.empty-state { padding: 44px 20px; }
.start-panel { background: linear-gradient(135deg, #f1fafc 0%, #ffffff 70%); border-color: #bfe3ea; }
.start-list li { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; align-items: center; }
.start-list li.is-done { background: #f6fcf9; border-color: #c6ebdb; }
.start-state { background: var(--warn-soft); color: var(--warn); }
.start-list li.is-done .start-state { background: var(--ok-soft); color: var(--ok); }
.start-list a { text-decoration: none; color: var(--ink); }
.start-list a:hover strong { color: var(--accent-dark); text-decoration: underline; }
.link-box input { background: #fff; }
.actions { gap: 8px; }
.confirm-inline > summary { cursor: pointer; }

/* ── Patient form + standalone pages polish ────────────────────────────────────────────────── */
.consent-box { background: var(--accent-soft); border-color: #bfe3ea; border-radius: 10px; }
.sig-pad { border: 1.5px dashed var(--line-strong); border-radius: 10px; }
fieldset.choice-group legend { color: var(--ink); }
label.choice { border-radius: 8px; }
label.choice:hover { background: var(--bg); }

/* ── Legacy top bar (admin pages) ──────────────────────────────────────────────────────────── */
.topbar { background: var(--panel); border-bottom: 1px solid var(--line); box-shadow: 0 1px 0 rgba(15, 46, 61, .03); }

/* ── Mobile: sidebar collapses to a top strip ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .app { flex-direction: column; }
  .side { position: static; flex: none; width: 100%; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line); overflow: visible; }
  .side .brand { padding: 0 6px 0 0; }
  .side .nav-label, .side .practice-chip { display: none; }
  .side nav { order: 3; flex: 1 0 100%; flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 4px; scrollbar-width: thin; }
  .side nav a { flex: 0 0 auto; white-space: nowrap; min-height: 44px; }
  .side .side-foot { margin: 0 0 0 auto; padding: 0; border: 0; display: flex; align-items: center; gap: 8px; }
  .main { padding: 18px 14px 40px; }
  .panel { padding: 18px 16px; }
}
@media (max-width: 480px) { h1 { font-size: 1.3rem; } .stat-row { grid-template-columns: 1fr 1fr; } .stat-card { flex-direction: column; align-items: flex-start; gap: 8px; } }

@media (max-width: 720px) { .start-list li { align-items: flex-start; } .start-state { align-self: flex-start; } .panel-head .actions, .panel-head > .btn { width: 100%; } .page-head h1 { word-break: break-word; } }

/* ── Admin-only polish (scoped: the practice dashboard shares this file) ───────────────────── */
.admin .table-wrap table { min-width: 560px; }
.admin input[type=search], .admin select { font: inherit; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; min-height: 40px; }
[hidden] { display: none !important; }
