/* ============================================================
   Hospital Management System — base theme
   Clean, responsive, intuitive. CSS variables for easy theming.
   ============================================================ */
:root {
    --primary: #0f766e;        /* teal */
    --primary-600: #0d655e;
    --primary-50: #ecfdf8;
    --accent: #2563eb;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --sidebar-w: 260px;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
    --font: 'Segoe UI', Roboto, system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
[hidden] { display: none !important; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.content { padding: 24px; flex: 1; }

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-w);
    background: #0b1324;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.brand {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 18px; font-weight: 700; color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.06);
    text-decoration: none;
}
a.brand:hover { background: rgba(255,255,255,.04); }
.brand-mark {
    background: var(--primary); color: #fff; font-weight: 800;
    width: 34px; height: 34px; border-radius: 9px;
    display: grid; place-items: center; font-size: 16px;
}
.brand-mark span { color: #5eead4; }
.brand-text { font-size: 14px; line-height: 1.1; }

.nav { padding: 10px 8px; }
.nav-group { margin-bottom: 2px; }
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 8px; color: #cbd5e1;
    cursor: pointer; font-weight: 500;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-ico {
    width: 18px; height: 18px; flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    color: #94a3b8;
}
.nav-link:hover .nav-ico, .nav-group.open .nav-ico { color: #5eead4; }
.nav-ico svg { width: 18px; height: 18px; }
.nav-label { flex: 1; }
.nav-caret { transition: transform .2s; opacity: .6; }
.nav-group.open > .nav-link .nav-caret { transform: rotate(90deg); }
.nav-sub { display: none; padding: 4px 0 6px 40px; }
.nav-group.open .nav-sub { display: block; }
.nav-sublink {
    display: block; padding: 7px 10px; border-radius: 6px;
    color: #94a3b8; font-size: 13px;
}
.nav-sublink:hover { color: #fff; background: rgba(255,255,255,.05); }
.nav-link.active { background: var(--primary); color: #fff; }
.nav-link.active .nav-ico { color: #fff; }
.nav-sublink.active { color: #5eead4; font-weight: 600; }

/* ---------- Topbar ---------- */
.topbar {
    height: 60px; background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 14px;
    padding: 0 20px; position: sticky; top: 0; z-index: 20;
}
.topbar-spacer { flex: 1; }
.icon-btn {
    background: none; border: none; cursor: pointer;
    font-size: 18px; color: var(--muted); padding: 6px 8px; border-radius: 8px;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; display: block; }
.brand-mark svg { width: 20px; height: 20px; }
.auth-brand .brand-mark svg { width: 26px; height: 26px; }
#menuToggle { display: inline-flex; }
body.sidebar-collapsed .sidebar { display: none; }
.sidebar-backdrop { display: none; }
.quick-links { display: flex; align-items: center; gap: 8px; margin-left: 6px; flex-wrap: wrap; min-width: 0; }
.quick-links .quick-label { font-size: 12px; }
.quick-link { font-size: 13px; padding: 4px 11px; border: 1px solid var(--border); border-radius: 999px; color: var(--text); text-decoration: none; background: #fff; white-space: nowrap; }
.quick-link:hover { background: var(--bg); border-color: var(--primary); }
@media (max-width: 760px) { .quick-links { display: none; } }

.lang-switch { display: flex; gap: 4px; }
.lang-link {
    padding: 4px 8px; border-radius: 6px; font-size: 12px;
    font-weight: 600; color: var(--muted);
}
.lang-link.active { background: var(--primary-50); color: var(--primary); }

.user-menu { display: flex; align-items: center; gap: 10px; }
.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--primary); color: #fff; font-weight: 700;
    display: grid; place-items: center;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.1; }
.user-name { font-weight: 600; font-size: 13px; }
.user-role { font-size: 11px; color: var(--muted); }

/* ---------- Page + cards ---------- */
.page-head { margin-bottom: 20px; }
.page-head h2 { margin: 0 0 4px; font-size: 22px; }
.card-grid {
    display: grid; gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.stat-card .stat-label { color: var(--muted); font-size: 13px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; margin: 6px 0; }
.stat-card .stat-foot { font-size: 12px; }

/* ---------- Buttons / forms ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px; padding: 10px 16px; border-radius: 8px; border: 1px solid transparent;
    font-weight: 600; cursor: pointer; font-size: 14px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-block { width: 100%; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; margin-bottom: 6px; color: var(--muted); }
.field input, .field select, .field textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border);
    border-radius: 8px; font-size: 14px; font-family: inherit; background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-50);
}

/* ---------- Alerts ---------- */
.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
.alert-error   { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0; }
.alert-info    { background: #eff6ff; color: var(--accent); border: 1px solid #bfdbfe; }

/* ---------- Guest / login ---------- */
.guest-body {
    background: linear-gradient(135deg, #0f766e, #0b1324);
    min-height: 100vh; display: grid; place-items: center; padding: 20px;
}
.auth-card {
    background: #fff; width: 100%; max-width: 380px;
    border-radius: 16px; padding: 32px; box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand .brand-mark { margin: 0 auto 12px; width: 48px; height: 48px; font-size: 22px; }
.auth-brand h1 { font-size: 18px; margin: 0; }
.auth-form .btn { margin-top: 6px; }
.auth-lang { text-align: center; margin-top: 18px; display: flex; gap: 14px; justify-content: center; }
.auth-lang a { font-size: 12px; color: var(--muted); }
.auth-lang a.active { color: var(--primary); font-weight: 700; }

/* ---------- Error pages ---------- */
.error-page { text-align: center; padding: 60px 20px; }
.error-page h1 { font-size: 64px; margin: 0; color: var(--primary); }

/* ---------- Toolbar / page head ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------- Buttons (variants) ---------- */
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn:not(.btn-primary):not(.btn-danger) { background: #fff; color: var(--text); border-color: var(--border); }
.inline { display: inline; }

/* ---------- Tables ---------- */
.table-card { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.table thead th { background: #f8fafc; color: var(--muted); font-weight: 600; white-space: nowrap; }
.table tbody tr:hover { background: #f8fafc; }
.table .empty { text-align: center; color: var(--muted); padding: 28px; }
.col-actions { white-space: nowrap; text-align: right; width: 1%; }
.col-actions .btn { margin-left: 4px; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-muted { background: #f1f5f9; color: #64748b; }
.badge-info { background: #dbeafe; color: #1d4ed8; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-danger { background: #fee2e2; color: #b91c1c; }

/* Triage acuity row tints (doctor waiting list) */
tr.lvl-emergency > td { background: #fef2f2; }
tr.lvl-emergency > td:first-child { box-shadow: inset 4px 0 0 #dc2626; }
tr.lvl-urgent > td { background: #fff7ed; }
tr.lvl-urgent > td:first-child { box-shadow: inset 4px 0 0 #d97706; }
tr.lvl-standard > td { background: #eff6ff; }
tr.lvl-non_urgent > td { background: #f0fdf4; }
.badge-danger { background: #fee2e2; color: #b91c1c; }

/* ---------- Forms (grid) ---------- */
.form-card { max-width: 720px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-grid .field { margin-bottom: 0; }
.form-grid .col-span-2 { grid-column: 1 / -1; }
.form-grid .form-actions { grid-column: 1 / -1; display: flex; gap: 10px; margin-top: 6px; }
.field.checkbox { display: flex; align-items: center; gap: 8px; }
.field.checkbox input { width: auto; }
.field.checkbox span { margin: 0; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* ---------- Checkbox grid (roles, etc.) ---------- */
.checkbox-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: #f8fafc;
}
.checkbox-grid .field { margin-bottom: 0; }

/* ---------- Settings ---------- */
.settings-section { margin-bottom: 24px; }
.settings-section h3 { margin: 0 0 12px; font-size: 15px; }

/* ---------- Numbers / filters / reports ---------- */
.num { text-align: right; white-space: nowrap; }
th.num { text-align: right; }
.filter-bar { padding: 12px 16px; margin-bottom: 16px; }
.filter-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filter-form select, .filter-form input {
    padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-family: inherit; font-size: 13px;
}
.report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.report-total td, .report-total th { font-weight: 700; background: #f8fafc; }
.report-head { text-align: center; margin-bottom: 16px; }
.report-head h2 { margin: 0; }
.report-head .sub { color: var(--muted); font-size: 13px; }
@media (max-width: 760px) { .report-grid { grid-template-columns: 1fr; } }

/* ---------- Printable documents ---------- */
.print-doc { max-width: 800px; margin: 0 auto; }
.doc-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--primary); padding-bottom: 14px; margin-bottom: 16px; }
.doc-brand { display: flex; gap: 14px; align-items: flex-start; }
.doc-logo { height: 60px; width: auto; max-width: 160px; object-fit: contain; }
.doc-contact { font-size: 12px; color: var(--muted); margin-top: 2px; }
.logo-preview img { height: 56px; width: auto; max-width: 200px; border: 1px solid var(--border); border-radius: 8px; padding: 4px; background: #fff; margin-bottom: 8px; display: block; }
.doc-hospital { font-size: 22px; margin: 0; color: var(--primary); }
.doc-type { text-transform: uppercase; letter-spacing: 1px; font-size: 12px; color: var(--muted); margin-top: 4px; }
.doc-meta { font-size: 13px; text-align: right; }
.doc-meta div { margin-bottom: 3px; }
.doc-table tfoot th { background: #f8fafc; }
.doc-narration { font-size: 13px; margin-top: 14px; }
.doc-foot { margin-top: 30px; padding-top: 12px; border-top: 1px dashed var(--border); text-align: center; font-size: 12px; color: var(--muted); }

@media print {
    .sidebar, .topbar, .no-print, .alert { display: none !important; }
    .content { padding: 0; }
    .card { box-shadow: none; border: none; }
    body { background: #fff; }
}

/* ---------- Triage / body diagram ---------- */
.triage-layout { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }
.body-card { text-align: center; }
.body-svg { width: 100%; max-width: 240px; height: auto; cursor: crosshair; touch-action: none; }
.body-actions { display: flex; gap: 8px; justify-content: center; margin-top: 8px; }
.small { font-size: 12px; }
@media (max-width: 820px) { .triage-layout { grid-template-columns: 1fr; } }

/* ---------- Doctor consultation ---------- */
.consult-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; align-items: start; }
.consult-main, .consult-side { min-width: 0; }
.consult-main .table-scroll { overflow-x: auto; }
.consult-main .card { margin-bottom: 16px; }
.consult-main h3 { margin: 0 0 12px; font-size: 15px; }
.kv { list-style: none; padding: 0; margin: 0 0 8px; }
.kv li { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.kv li span { color: var(--muted); }
.hist-item { display: block; padding: 8px 6px; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none; border-radius: 6px; transition: background .12s; }
a.hist-item:hover { background: #f1f5f9; }
.lab-search { width: 100%; max-width: 320px; padding: 8px 10px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.consult-actions { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.consult-actions .form-actions { margin: 0; }
.autosave-state { min-height: 18px; }
.lab-audit { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; }
.lab-audit-row td { background: #f8fafc; padding-top: 4px; padding-bottom: 4px; }
.lab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.lab-nohit { grid-column: 1 / -1; margin: 4px 0; }
.patient-strip { display: flex; flex-wrap: wrap; gap: 10px 28px; align-items: center; }
.patient-strip > div { display: flex; flex-direction: column; line-height: 1.3; }
.patient-strip .muted { font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
.patient-strip b { font-size: 14px; }
.lab-pick.lab-excluded { border-color: var(--warning); background: #fffbeb; }
.rx-excl { margin-top: 4px; }
.rx-stock { display: block; margin-top: 4px; }
.rx-stock-out { color: var(--danger); font-weight: 600; }
.lab-pick { display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #f8fafc; font-size: 13px; cursor: pointer; }
.lab-pick span { white-space: normal; word-break: break-word; }
.lab-pick input { margin-top: 2px; flex: none; }
.lab-pick.lab-ordered { justify-content: space-between; align-items: center; background: #eef2ff; border-color: #c7d2fe; }
.lab-pick.lab-ordered .badge { white-space: nowrap; }
.diag-cols { display: grid; grid-template-columns: 1fr; gap: 12px; }
.diag-block { border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.diag-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.diag-head h4 { margin: 0; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.diag-block .table td { padding: 6px 6px; border: none; }
@media (max-width: 900px) { .diag-cols { grid-template-columns: 1fr; } }
@media (max-width: 900px) { .consult-layout { grid-template-columns: 1fr; } }

/* ---------- Dashboard queue chips ---------- */
a.stat-card { display: block; transition: box-shadow .15s, transform .15s; }
a.stat-card:hover { box-shadow: 0 4px 14px rgba(15,23,42,.1); transform: translateY(-1px); }
.queue-chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.queue-chip { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border: 1px solid var(--border); border-radius: 999px; background: #f8fafc; }
.queue-chip span { color: var(--muted); font-size: 13px; }
.queue-chip b { font-size: 18px; color: var(--primary); }

/* ---------- Sticky save bar (bulk edit) ---------- */
.save-bar {
    position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 12px 16px; margin-top: 12px;
    background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 -2px 10px rgba(15,23,42,.06);
}
td input.price-in { font-weight: 600; }

/* ---------- Bed board ---------- */
.bed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.bed-tile { border: 1px solid var(--border); border-radius: 10px; padding: 14px; text-align: center; background: #fff; }
.bed-tile.bed-available { border-color: #bbf7d0; background: #f0fdf4; }
.bed-tile.bed-occupied { border-color: #fecaca; background: #fef2f2; }
.bed-tile.bed-maintenance { background: #f1f5f9; }
.bed-ward { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.bed-no { font-size: 20px; font-weight: 700; margin: 4px 0; }
.bed-patient { font-size: 13px; font-weight: 600; }
.bed-status { font-size: 12px; color: var(--success); }
.bed-link { font-size: 12px; color: var(--primary); display: inline-block; margin-top: 6px; }

/* ---------- Patient media + signature pad ---------- */
.media-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.media-col .field-label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.media-preview { display: block; max-height: 120px; max-width: 160px; border: 1px solid var(--border); border-radius: 8px; padding: 4px; background: #fff; margin-bottom: 8px; object-fit: contain; }
.media-preview.sig { max-width: 280px; }
.sig-pad { border: 1px dashed var(--border); border-radius: 8px; background: #fff; touch-action: none; max-width: 100%; cursor: crosshair; }
@media (max-width: 640px) { .media-grid { grid-template-columns: 1fr; } }

/* ---------- Registration card (ID-card style) ---------- */
.card-print-body { background: #f1f5f9; padding: 24px; font-family: var(--font); }
.id-card { width: 560px; max-width: 100%; margin: 0 auto; background: #fff; border-radius: 14px; overflow: hidden; box-shadow: 0 10px 30px rgba(15,23,42,.12); border: 1px solid var(--border); }
.id-band { background: linear-gradient(135deg, var(--primary), #0b1324); color: #fff; display: flex; align-items: center; gap: 14px; padding: 16px 20px; }
.id-logo { height: 52px; width: auto; max-width: 120px; object-fit: contain; background: #fff; border-radius: 8px; padding: 4px; }
.id-hospital { font-size: 20px; font-weight: 800; line-height: 1.1; }
.id-contact { font-size: 12px; opacity: .9; margin-top: 2px; }
.id-title { background: #0b1324; color: #5eead4; text-transform: uppercase; letter-spacing: 3px; font-size: 11px; text-align: center; padding: 6px; }
.id-body { display: flex; gap: 18px; padding: 20px; }
.id-photo img, .id-nophoto { width: 120px; height: 140px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); }
.id-nophoto { display: grid; place-items: center; color: var(--muted); background: #f8fafc; font-size: 12px; }
.id-info { flex: 1; }
.id-mrn { font-family: monospace; font-size: 22px; font-weight: 800; color: var(--primary); letter-spacing: 2px; }
.id-name { font-size: 18px; font-weight: 700; margin: 2px 0 10px; }
.id-kv { width: 100%; font-size: 13px; border-collapse: collapse; }
.id-kv td { padding: 4px 0; vertical-align: top; }
.id-kv td:first-child { color: var(--muted); width: 90px; }
.id-foot { display: flex; align-items: flex-end; justify-content: space-between; padding: 0 20px 14px; }
.id-sign img { height: 44px; display: block; }
.id-sign-line { border-top: 1px solid var(--text); font-size: 11px; color: var(--muted); padding-top: 2px; min-width: 160px; }
.id-issued { font-size: 12px; color: var(--muted); }
.id-brand { text-align: center; font-size: 11px; color: var(--muted); padding: 8px; border-top: 1px dashed var(--border); }
@media print { .card-print-body { background: #fff; padding: 0; } .id-card { box-shadow: none; border: none; } }

/* ---------- Price matrix ---------- */
.price-matrix th, .price-matrix td { white-space: nowrap; }
.price-matrix .sticky-col { position: sticky; left: 0; background: #fff; z-index: 1; min-width: 220px; white-space: normal; }
.price-matrix thead .sticky-col { background: #f8fafc; }
.price-matrix input.price-cell { width: 100px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; }
.price-cell.cell-saving { border-color: var(--warning); }
.price-cell.cell-ok { border-color: var(--success); box-shadow: 0 0 0 2px #dcfce7; }
.price-cell.cell-err { border-color: var(--danger); box-shadow: 0 0 0 2px #fee2e2; }
.excl-cell-td { text-align: center; }
td.excl-cell-td.cell-saving { background: #fef9c3; }
td.excl-cell-td.cell-ok { background: #dcfce7; }
td.excl-cell-td.cell-err { background: #fee2e2; }
.pager { display: flex; align-items: center; gap: 12px; justify-content: center; margin-top: 14px; }
.perm-row { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px; font-size: 13px; cursor: pointer; }
.perm-row:hover { background: #f8fafc; }
.perm-row.cell-ok { background: #dcfce7; }
.perm-row.cell-err { background: #fee2e2; }
select.perm-eff.cell-ok { border-color: var(--success); }
select.perm-eff.cell-err { border-color: var(--danger); }

/* ---------- Documentation ---------- */
.docs-search-card { margin-bottom: 18px; }
.docs-search { display: flex; align-items: center; gap: 10px; position: relative; }
.docs-search-ico { color: var(--muted); display: flex; }
.docs-search input { flex: 1; padding: 11px 14px; border: 1px solid var(--border);
    border-radius: 8px; font-size: 15px; font-family: inherit; background: #fff; }
.docs-search input:focus { outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-50); }

.docs-toc-grid { display: grid; gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.docs-toc-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.docs-toc-head h3 { margin: 0 0 2px; font-size: 16px; }
.docs-toc-head p { margin: 0; font-size: 13px; }
.docs-toc-ico { flex: 0 0 38px; height: 38px; border-radius: 10px;
    display: grid; place-items: center; background: var(--primary-50); color: var(--primary); }
.docs-toc-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.docs-toc-list li { border-bottom: 1px solid var(--border); }
.docs-toc-list a { display: block; padding: 9px 4px; font-size: 14px;
    color: var(--text); text-decoration: none; }
.docs-toc-list a:hover { color: var(--primary); padding-left: 8px; transition: padding .15s; }

.docs-result-list { list-style: none; margin: 0; padding: 0; }
.docs-result { display: block; padding: 12px; border: 1px solid var(--border);
    border-radius: 8px; margin-bottom: 10px; text-decoration: none; color: var(--text); }
.docs-result:hover { border-color: var(--primary); background: var(--primary-50); }
.docs-result strong { margin-right: 8px; }
.docs-snippet { display: block; margin-top: 5px; font-size: 13px; }
.docs-results-head { margin: 0 0 14px; font-size: 16px; }
.docs-back-link { margin: 14px 0 0; }

/* Article view */
.docs-layout { display: grid; grid-template-columns: 250px 1fr; gap: 18px; align-items: start; }
.docs-side { position: sticky; top: 16px; max-height: calc(100vh - 90px); overflow-y: auto; padding: 14px; }
.docs-side-group { margin-bottom: 16px; }
.docs-side-title { display: flex; align-items: center; gap: 7px; margin: 0 0 6px;
    font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.docs-side-ico { display: flex; color: var(--muted); }
.docs-side-ico svg { width: 14px; height: 14px; }
.docs-side ul { list-style: none; margin: 0; padding: 0; }
.docs-side li a { display: block; padding: 6px 10px; font-size: 13px; border-radius: 7px;
    color: var(--text); text-decoration: none; }
.docs-side li a:hover { background: var(--bg); }
.docs-side li a.active { background: var(--primary); color: #fff; font-weight: 600; }

.docs-crumb a { color: var(--primary); text-decoration: none; font-weight: 600; }
.docs-article-head { border-bottom: 1px solid var(--border); padding-bottom: 14px; margin-bottom: 18px; }
.docs-article-head h1 { margin: 10px 0 0; font-size: 24px; }

.docs-prose { font-size: 15px; line-height: 1.7; color: #1f2937; max-width: 760px; }
.docs-prose h2 { font-size: 18px; margin: 26px 0 10px; padding-top: 6px; }
.docs-prose h3 { font-size: 15px; margin: 20px 0 8px; }
.docs-prose p { margin: 0 0 12px; }
.docs-prose ul, .docs-prose ol { margin: 0 0 14px; padding-left: 22px; }
.docs-prose li { margin-bottom: 6px; }
.docs-prose code { background: #f1f5f9; padding: 1px 6px; border-radius: 5px;
    font-size: 13px; font-family: ui-monospace, Consolas, monospace; }
.docs-prose strong { color: var(--text); }
.docs-prose .docs-note { border-left: 3px solid var(--primary); background: var(--primary-50);
    padding: 10px 14px; border-radius: 0 8px 8px 0; margin: 0 0 14px; font-size: 14px; }
.docs-prose .docs-steps { counter-reset: step; list-style: none; padding-left: 0; }
.docs-prose .docs-steps li { position: relative; padding-left: 38px; margin-bottom: 12px; }
.docs-prose .docs-steps li::before { counter-increment: step; content: counter(step);
    position: absolute; left: 0; top: -2px; width: 26px; height: 26px; border-radius: 50%;
    background: var(--primary); color: #fff; font-size: 13px; font-weight: 700;
    display: grid; place-items: center; }

.docs-pager { display: flex; justify-content: space-between; gap: 12px;
    margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--border); }
.docs-pager-link { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px;
    border: 1px solid var(--border); border-radius: 8px; text-decoration: none;
    color: var(--text); max-width: 48%; }
.docs-pager-link:hover { border-color: var(--primary); background: var(--primary-50); }
.docs-pager-link.next { text-align: right; margin-left: auto; }
.docs-pager-link span { font-size: 12px; }

@media (max-width: 820px) {
    .docs-layout { grid-template-columns: 1fr; }
    .docs-side { position: static; max-height: none; order: 2; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .sidebar {
        position: fixed; left: 0; top: 0; z-index: 50;
        transform: translateX(-100%); transition: transform .25s;
    }
    body.sidebar-open .sidebar { transform: translateX(0); }
    /* On mobile the toggle always slides the off-canvas panel, never collapses. */
    body.sidebar-collapsed .sidebar { display: flex; }
    /* Tap-anywhere backdrop to close the open panel. */
    body.sidebar-open .sidebar-backdrop {
        display: block; position: fixed; inset: 0;
        background: rgba(0, 0, 0, .45); z-index: 40;
    }
}
@media (max-width: 640px) {
    .content { padding: 14px; }
    .topbar { padding: 0 12px; gap: 8px; }
    .page-head h2 { font-size: 19px; }
}
