/* ================================
   Clinic — SaaS-style UI
   ================================ */

:root {
    --c-bg:         #f5f7fb;
    --c-surface:    #ffffff;
    --c-border:     #e5e9f2;
    --c-text:       #121a30;
    --c-muted:      #3f4a63;
    --c-muted-soft: #5a657c;
    --c-primary:    #5b6cff;
    --c-primary-d:  #3a48c4;
    --c-primary-l:  #eef0ff;
    --c-accent:     #7c3aed;
    --c-success:    #0e7a38;
    --c-danger:     #c2292e;
    --c-danger-l:   #fde8e9;
    --c-warning:    #b86d00;
    --c-shadow:     0 4px 16px rgba(30, 41, 74, 0.08);
    --c-shadow-lg:  0 20px 50px rgba(30, 41, 74, 0.18);
    --radius:       10px;
    --radius-lg:    14px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--c-text);
    background: var(--c-bg);
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ------------- Checkbox (global) -------------
   Replaces the tiny browser-default widget with a clean rounded square that
   matches the rest of the UI. The .switch component (`.switch input`) hides
   its inner checkbox with opacity/width:0 and stays intact. */
input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    margin: 0;
    border: 1.5px solid #b6c0d3;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    vertical-align: middle;
    transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}
input[type="checkbox"]:hover:not(:disabled) { border-color: var(--c-primary); }
input[type="checkbox"]:checked {
    background: var(--c-primary);
    border-color: var(--c-primary);
}
input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
input[type="checkbox"]:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--c-primary-l);
}
input[type="checkbox"]:disabled { opacity: 0.55; cursor: not-allowed; }

/* ------------- Buttons ------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 17px;
    border: 1px solid var(--c-border);
    background: #fff;
    color: var(--c-text);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.15s;
}
.btn:hover:not(:disabled) { background: var(--c-primary-l); border-color: var(--c-primary); color: var(--c-primary-d); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
    background: var(--c-primary);
    border-color: var(--c-primary);
    color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--c-primary-d); border-color: var(--c-primary-d); color: #fff; }

.btn-danger { background: var(--c-danger); border-color: var(--c-danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #a11f23; border-color: #a11f23; color: #fff; }

.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--c-primary-l); color: var(--c-primary-d); }

.btn-block { width: 100%; padding: 12px 17px; font-size: 15px; }

.icon-btn {
    background: transparent; border: none; cursor: pointer;
    width: 32px; height: 32px; border-radius: 8px;
    font-size: 18px; color: var(--c-muted);
}
.icon-btn:hover { background: var(--c-primary-l); color: var(--c-primary-d); }

/* ------------- Auth ------------- */

.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #5b6cff 0%, #7c3aed 100%);
    padding: 20px;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--c-shadow-lg);
}
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.auth-logo {
    width: 48px; height: 48px; border-radius: 12px;
    background: linear-gradient(135deg, #5b6cff, #7c3aed);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 24px;
}
.auth-title { font-size: 22px; font-weight: 700; }
.auth-sub   { font-size: 13px; color: var(--c-muted); }

.auth-tabs { display: flex; gap: 4px; margin-bottom: 20px; background: #f1f3f9; padding: 4px; border-radius: 10px; }
.auth-tabs button {
    flex: 1; padding: 10px; border: none; background: transparent;
    border-radius: 7px; cursor: pointer; font-weight: 500; font-size: 14px; color: var(--c-muted);
}
.auth-tabs button.active { background: #fff; color: var(--c-text); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

.auth-form label { display: block; margin-bottom: 14px; }
.auth-form label span { display: block; font-size: 13px; font-weight: 500; color: var(--c-muted); margin-bottom: 6px; }
.auth-form input, .auth-form select {
    width: 100%; padding: 11px 13px; border: 1px solid var(--c-border);
    border-radius: 8px; font-size: 15px; background: #fff; color: var(--c-text);
}
.auth-form input:focus, .auth-form select:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-l); }
.auth-error { background: var(--c-danger-l); color: var(--c-danger); padding: 10px 13px; border-radius: 8px; font-size: 14px; margin-bottom: 12px; }
.auth-foot  { text-align: center; margin-top: 20px; font-size: 12px; color: var(--c-muted); }

/* ------------- Shell ------------- */

.shell { display: flex; height: 100vh; overflow: hidden; }

.side {
    width: 240px;
    background: #0f172a;
    color: #e2e8f0;
    padding: 18px 10px 18px 10px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 14px 10px; flex-shrink: 0; }
.side-user {
    display: flex; align-items: center; gap: 10px;
    padding: 10px; margin: 0 0 8px 0;
    background: rgba(255,255,255,0.05); border-radius: 10px;
    flex-shrink: 0;
}
.side-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, #5b6cff, #7c3aed); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 14px; text-transform: uppercase;
    flex-shrink: 0;
}
.side-user-meta { line-height: 1.2; min-width: 0; }
.side-user-name { font-size: 14px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-role { font-size: 12px; color: #94a3b8; }
.side-nav {
    flex: 1; overflow-y: auto; min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.side-nav::-webkit-scrollbar { width: 6px; }
.side-nav::-webkit-scrollbar-track { background: transparent; }
.side-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.12); border-radius: 3px;
}
.side-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }
.side-block { border-radius: 10px; padding: 4px 6px 8px; margin-bottom: 6px; }
.side-block-home    { background: rgba(91, 108, 255, 0.10); padding-top: 6px; }
.side-block-main    { background: rgba(16, 185, 129, 0.08); }
.side-block-finance { background: rgba(59, 130, 246, 0.10); }
.side-block-reports { background: rgba(234, 179, 8, 0.08); }
.side-block-refs    { background: rgba(236, 72, 153, 0.08); }
.side-block-system  { background: rgba(148, 163, 184, 0.08); }
.side-footer { flex-shrink: 0; padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.08); margin-top: 8px; }
.side-logout {
    width: 100%; display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: 8px;
    background: transparent; border: none; cursor: pointer;
    color: #e2e8f0; font-size: 14px; text-align: left;
    transition: background 0.15s;
}
.side-logout span { flex: 1; }
.side-logout:hover { background: rgba(239,68,68,0.15); color: #fca5a5; }
.side-logo {
    width: 36px; height: 36px; border-radius: 10px;
    background: linear-gradient(135deg, #5b6cff, #7c3aed);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 20px;
}
.side-name { font-size: 18px; font-weight: 700; color: #fff; }

.side-group {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
    color: #94a3b8; padding: 14px 12px 6px;
    font-weight: 600;
}
.side-group-toggle {
    width: 100%; display: flex; align-items: center; justify-content: space-between;
    background: transparent; border: none; cursor: pointer;
    text-align: left; font-family: inherit;
    color: #94a3b8;
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600;
}
.side-group-toggle:hover { color: #e2e8f0; }
.side-group-caret {
    transition: transform 0.15s; display: inline-block;
    font-size: 28px; color: #cbd5e1; line-height: 1;
}
.side-group-toggle.open .side-group-caret { transform: rotate(180deg); color: #fff; }
.side-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; margin: 2px 0; border-radius: 8px;
    color: #e2e8f0; font-size: 14px; cursor: pointer;
    transition: background 0.15s;
}
.side-link span { flex: 1; }
.side-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.side-link.router-link-exact-active { background: var(--c-primary); color: #fff; }
.side-link.disabled { opacity: 0.5; pointer-events: none; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100vh; overflow: hidden; }

.content { flex: 1; padding: 24px; overflow: auto; }

/* ------------- Home ------------- */

.home-hero {
    background: linear-gradient(135deg, #5b6cff 0%, #7c3aed 100%);
    color: #fff;
    padding: 28px;
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 20px;
}
.hero-welcome { font-size: 24px; font-weight: 700; }
.hero-sub     { font-size: 14px; opacity: 0.9; margin-top: 4px; }
.hero-stats   { display: flex; gap: 12px; flex-wrap: wrap; }
.stat         { background: rgba(255,255,255,0.15); padding: 12px 18px; border-radius: 10px; min-width: 110px; backdrop-filter: blur(8px); }
.stat-label   { font-size: 12px; opacity: 0.85; }
.stat-val     { font-size: 24px; font-weight: 700; margin-top: 2px; }

.home-group        { margin-bottom: 22px; }
.home-group-title  { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--c-muted); margin-bottom: 10px; font-weight: 600; }

.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}
.tile {
    position: relative;
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 20px 12px 16px;
    cursor: pointer;
    transition: all 0.18s;
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    font-family: inherit; color: var(--c-text);
    font-size: 14px;
}
.tile:hover:not(:disabled) {
    transform: translateY(-2px);
    border-color: var(--c-primary);
    box-shadow: var(--c-shadow);
}
.tile-icon  { font-size: 31px; line-height: 1; }
.tile-label { font-size: 14px; font-weight: 500; text-align: center; color: var(--c-text); }
.tile-disabled { opacity: 0.55; cursor: not-allowed; }
.tile-badge {
    position: absolute; top: 8px; right: 8px;
    background: #f1f3f9; color: var(--c-muted);
    font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
    padding: 2px 6px; border-radius: 4px;
}

/* Dashboard cards (stats + notifications) */
.dash-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr);
    gap: 18px;
    align-items: start;
}
@media (max-width: 900px) {
    .dash-grid { grid-template-columns: 1fr; }
}
.dash-card {
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: var(--c-shadow);
    overflow: hidden;
}
.dash-card-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--c-border);
}
.dash-card-title {
    font-size: 14px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--c-muted);
}
.btn-sm { padding: 4px 8px; font-size: 13px; }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1px;
    background: var(--c-border);
}
.kpi {
    background: #fff;
    padding: 16px 18px;
    display: flex; flex-direction: column; gap: 6px;
}
.kpi-label { font-size: 12px; color: var(--c-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-val   { font-size: 22px; font-weight: 700; color: var(--c-text); }

.notif-list { list-style: none; margin: 0; padding: 0; max-height: 480px; overflow: auto; }
.notif-item {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 12px 18px;
    border-bottom: 1px solid var(--c-border);
    cursor: pointer;
    transition: background 0.12s;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: #f7f9ff; }
.notif-icon { font-size: 18px; line-height: 1.2; }
.notif-body { flex: 1; min-width: 0; }
.notif-title { font-size: 14px; font-weight: 600; color: var(--c-text); }
.notif-sub   { font-size: 12px; color: var(--c-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }
.notif-task-overdue .notif-icon { color: var(--c-danger); }
.notif-task-overdue .notif-title { color: var(--c-danger); }
.notif-recall-overdue .notif-icon { color: var(--c-danger); }
.notif-recall-overdue .notif-title { color: var(--c-danger); }
.notif-actions {
    display: flex; gap: 4px; flex-shrink: 0;
}
.notif-actions .btn-sm { padding: 4px 8px; font-size: 12px; }
.notif-icon, .notif-body { cursor: pointer; }

/* ------------- Page / table ------------- */

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 18px; flex-wrap: wrap; }
.page-title { font-size: 24px; font-weight: 700; color: var(--c-text); }
.page-sub   { font-size: 14px; color: var(--c-muted); margin-top: 2px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.search  { flex: 1; padding: 10px 13px; border: 1px solid var(--c-border); border-radius: 8px; background: #fff; font-size: 14px; color: var(--c-text); font-family: inherit; }
.search:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-l); }
.count   { font-size: 13px; color: var(--c-muted); }

.card { background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--c-shadow); }

.grid { width: 100%; border-collapse: collapse; }
.grid th {
    text-align: left; font-size: 12px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--c-muted); padding: 12px 14px;
    background: #f8fafc; border-bottom: 1px solid var(--c-border);
}
.grid td { padding: 12px 14px; font-size: 14px; color: var(--c-text); border-bottom: 1px solid var(--c-border); }
/* Compact variant — used inside dialogs where the surrounding modal padding
   already gives breathing room and 12px row padding feels heavy. */
.grid.grid-compact td { padding: 6px 14px; }
.grid.grid-compact th { padding: 8px 14px; }
.grid tbody tr { cursor: pointer; transition: background 0.1s; }
.grid tbody tr:hover { background: #f8fafc; }
/* Selection indicator: a 2px primary-color frame drawn with inset box-shadow on
   each cell, so it sits ON TOP of any status-driven row background instead of
   replacing it. box-shadow doesn't affect layout, so the row doesn't jump. */
.grid tbody tr.selected td {
    box-shadow: inset 0 2px 0 0 var(--c-primary), inset 0 -2px 0 0 var(--c-primary);
}
.grid tbody tr.selected td:first-child {
    box-shadow: inset 2px 0 0 0 var(--c-primary), inset 0 2px 0 0 var(--c-primary), inset 0 -2px 0 0 var(--c-primary);
}
.grid tbody tr.selected td:last-child {
    box-shadow: inset -2px 0 0 0 var(--c-primary), inset 0 2px 0 0 var(--c-primary), inset 0 -2px 0 0 var(--c-primary);
}
.grid tbody tr:last-child td { border-bottom: none; }
.muted { color: var(--c-muted); text-align: center; padding: 28px 14px !important; font-size: 14px; }

/* Group separator rows in data grids */
.grid tbody tr.group-row,
.grid tbody tr.group-row:hover { background: #eef0ff; cursor: default; }
.grid tbody tr.group-row td {
    padding: 9px 14px;
    border-top: 1px solid var(--c-border);
    border-bottom: 1px solid var(--c-border);
}
.group-row-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--c-primary-d);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ------------- Modal ------------- */

.modal-backdrop {
    position: fixed; inset: 0; background: rgba(15, 23, 42, 0.6);
    display: flex; align-items: center; justify-content: center;
    padding: 24px; z-index: 1000;
    backdrop-filter: blur(2px);
}
.modal {
    background: #eef1f7; border-radius: var(--radius-lg);
    width: 100%; max-width: 560px;
    box-shadow: var(--c-shadow-lg);
    display: flex; flex-direction: column; max-height: 90vh;
    color: var(--c-text);
}
/* Header / footer keep the clean white surface; only the body and tabs sit
   on the slightly darker backdrop so white input fields stand out. */
.modal-head, .modal-foot { background: #fff; }
.modal-lg { max-width: 880px; }
.modal-md { max-width: 720px; }
/* Per-dialog width tweaks — narrower than modal-lg's 880px so dialogs
   feel right-sized for their content density. */
.modal-cash.modal-lg     { max-width: 492px; }   /* −30% then −20% */
.modal-uxod.modal-lg     { max-width: 748px; }   /* −15% */
.modal-client.modal-lg   { max-width: 660px; }   /* −25% */
.modal-proc.modal-lg     { max-width: 726px; }   /* −25% then +10% */
.modal-doctor.modal-lg   { max-width: 660px; }   /* −25% */
.modal-prod.modal-lg     { max-width: 660px; }   /* −25% */
.modal-contract.modal-lg { max-width: 660px; }   /* −25% */
.modal-room-time       { max-width: 336px; }   /* default 560px −40% */
/* Fixed-height variant — keeps the dialog from resizing when tabs switch. */
.modal-tall { height: 88vh; max-height: 88vh; }
.modal-body-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; }
.modal-tabs {
    display: flex; gap: 4px;
    padding: 10px 22px 0;
    border-bottom: 1px solid var(--c-border);
    background: #f8fafc;
}
.modal-tabs button {
    padding: 10px 17px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--c-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    font-family: inherit;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
    transition: background 0.15s, color 0.15s;
}
.modal-tabs button.active { color: var(--c-primary-d); border-bottom-color: var(--c-primary); }
.modal-tabs button:hover:not(.active) { color: var(--c-text); background: rgba(15, 23, 42, 0.04); }
/* Active-tab backgrounds keyed off the selected uxod status. Must mirror
   the palette documented in readme.md under "Uxod status colors". The bar
   itself stays neutral; only the selected tab carries the status tint so
   hovering an inactive tab doesn't repaint the whole strip. */
.modal-tabs.status-new       button.active { background: #f8fafc; }
.modal-tabs.status-booked    button.active { background: #fff7e0; }
.modal-tabs.status-progress  button.active { background: #e7f1ff; }
.modal-tabs.status-done      button.active { background: #e2f5ea; }
.modal-tabs.status-cancelled button.active { background: #fde8e9; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--c-border); }
.modal-title { font-weight: 700; font-size: 18px; color: var(--c-text); }
.modal-body { padding: 20px 22px; overflow: auto; font-size: 14px; color: var(--c-text); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--c-border); }

/* Inside modals: keep field backgrounds white and use a darker border so
   inputs stand out clearly against the slightly darker modal body. */
.modal .form-grid input[type="text"],
.modal .form-grid input[type="number"],
.modal .form-grid input[type="password"],
.modal .form-grid input[type="time"],
.modal .form-grid input[type="date"],
.modal .form-grid input[type="datetime-local"],
.modal .form-grid input[type="email"],
.modal .form-grid input[type="tel"],
.modal .form-grid input[type="url"],
.modal .form-grid input:not([type]),
.modal .form-grid select,
.modal .form-grid textarea,
.modal .anketa-input input,
.modal .anketa-input select,
.modal .ref-search input,
.modal .ref-chip,
.modal .calc-grid input,
.modal .calc-grid select {
    background: #fff;
    border-color: #b6c0d3;
}
.modal .seg-toggle { border-color: #b6c0d3; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-grid .col-span-2 { grid-column: 1 / -1; }
/* Inline row that packs 4 labeled fields into a single line while still
   living inside a .form-grid parent. Use together with .col-span-2. */
.form-grid .form-row-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}
.form-grid .form-row-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}
.form-grid .form-row-5 {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
}
.form-grid .form-row-6 {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 14px;
}
/* Specialised totals row for the Uxod edit dialog: shrink the small numeric
   inputs (qty, currency rate, discount %) while keeping the wider fields
   (sum, discount sum, currency toggle) at full width. */
.form-grid .form-row-uxod-totals {
    display: grid;
    grid-template-columns: 0.7fr 1fr 0.7fr 0.7fr 1fr 1fr;
    gap: 14px;
}
@media (max-width: 640px) {
    .form-grid .form-row-3,
    .form-grid .form-row-4,
    .form-grid .form-row-5,
    .form-grid .form-row-6,
    .form-grid .form-row-uxod-totals { grid-template-columns: repeat(2, 1fr); }
}
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 14px; color: var(--c-text); }
.form-grid label.check {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
}
.form-grid label.check > span { font-size: 14px; font-weight: 400; color: var(--c-text); }
.form-grid label.check > input[type="checkbox"] { margin: 0; flex: 0 0 auto; }
.form-grid span  { font-size: 13px; font-weight: 500; color: var(--c-muted); }
.form-grid input[type="text"],
.form-grid input[type="number"],
.form-grid input[type="password"],
.form-grid input[type="time"],
.form-grid input[type="date"],
.form-grid input[type="datetime-local"],
.form-grid input[type="email"],
.form-grid input[type="tel"],
.form-grid input[type="url"],
.form-grid input:not([type]),
.form-grid select,
.form-grid textarea {
    width: 100%;
    height: 40px;
    padding: 10px 12px;
    border: 1px solid var(--c-border);
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    color: var(--c-text);
    font-family: inherit;
    line-height: 1.3;
    box-sizing: border-box;
    color-scheme: light;
}
.form-grid textarea { height: auto; }
/* Selects render with platform chrome on Windows that disagrees with text
   inputs — strip native styling and paint our own caret so heights and
   trailing arrows match across OSes. */
.form-grid select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 36px;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23667085' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px 8px;
}
.form-grid select::-ms-expand { display: none; }
.form-grid input[type="date"],
.form-grid input[type="time"],
.form-grid input[type="datetime-local"] {
    /* browsers render these in a platform font by default — force ours */
    font-family: inherit;
    font-variant-numeric: tabular-nums;
}
.form-grid input[type="date"]::-webkit-calendar-picker-indicator,
.form-grid input[type="time"]::-webkit-calendar-picker-indicator,
.form-grid input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    opacity: 0.6;
    cursor: pointer;
    transition: opacity 0.15s;
}
.form-grid input[type="date"]::-webkit-calendar-picker-indicator:hover,
.form-grid input[type="time"]::-webkit-calendar-picker-indicator:hover,
.form-grid input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px var(--c-primary-l);
}
.form-grid textarea { resize: vertical; min-height: 78px; }
.form-error   { background: var(--c-danger-l); color: var(--c-danger); padding: 10px 13px; border-radius: 8px; font-size: 14px; margin-top: 14px; }
/* Bottom-of-modal banner — lives between the scrollable body and the
   sticky footer so it stays visible regardless of scroll position. */
.form-error-foot {
    margin: 0; border-radius: 0;
    border-top: 1px solid var(--c-danger);
    padding: 10px 18px;
}
/* Mark a required form-grid field that failed validation. Targets the
   label wrapper (or .ref-client wrapper for the chip-style picker). */
.form-grid label.invalid > span,
.form-grid .ref-client.invalid > .ref-label { color: var(--c-danger); }
.form-grid label.invalid input,
.form-grid label.invalid select,
.form-grid label.invalid textarea,
.form-grid .ref-client.invalid .ref-wrap,
.form-grid .ref-client.invalid input {
    border-color: var(--c-danger);
    box-shadow: 0 0 0 2px var(--c-danger-l);
}
.form-success { background: #e2f5ea;            color: var(--c-success); padding: 10px 13px; border-radius: 8px; font-size: 14px; margin-top: 14px; }
.text-danger  { color: var(--c-danger);  font-weight: 600; }
.text-success { color: var(--c-success); font-weight: 600; }

.times-block { margin-top: 20px; }
.times-title { font-size: 13px; font-weight: 700; color: var(--c-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }

/* ------------- Users ------------- */

/* Applied to the actual <td>. Keep native table-cell display so the row
   background fills the whole cell — using display:flex here let the row
   bg leak below the content because the td loses table-cell vertical
   alignment once it becomes a flex container. */
.user-name {
    vertical-align: middle;
    font-weight: 500;
    color: var(--c-text);
    line-height: 1.2;
}
.user-name .user-avatar { display: inline-flex; vertical-align: middle; margin-right: 10px; }
.user-name > span,
.user-name > div:not(.user-avatar) {
    display: inline-block;
    vertical-align: middle;
    line-height: 1.2;
}
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, #5b6cff, #7c3aed);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 13px; text-transform: uppercase;
    flex-shrink: 0;
    overflow: hidden;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.user-avatar-clickable { cursor: pointer; transition: transform 0.1s, box-shadow 0.1s; }
.user-avatar-clickable:hover { transform: scale(1.08); box-shadow: 0 0 0 2px var(--c-primary-l); }

.avatar-preview {
    width: 160px; height: 160px;
    margin: 8px auto 4px;
    border-radius: 50%;
    background: linear-gradient(135deg, #5b6cff, #7c3aed);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 64px; text-transform: uppercase;
    overflow: hidden;
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.role-tag {
    display: inline-block;
    padding: 3px 9px;
    margin: 0 4px 2px 0;
    background: var(--c-primary-l);
    color: var(--c-primary-d);
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
}

.roles-block { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--c-border); }
.roles-title { font-size: 13px; font-weight: 700; color: var(--c-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 10px; }
.roles-grid  { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.role-chip {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 13px;
    border: 1px solid var(--c-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.12s;
    background: #fff;
    font-size: 14px;
    color: var(--c-text);
}
.role-chip:hover { border-color: var(--c-primary); background: var(--c-primary-l); }
.role-chip input { cursor: pointer; }

.psw-field input { font-family: inherit; }
.psw-wrap { display: flex; gap: 6px; }
.psw-wrap input { flex: 1; }
.psw-toggle {
    padding: 0 13px;
    border: 1px solid var(--c-border);
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--c-muted);
    white-space: nowrap;
    font-family: inherit;
}
.psw-toggle:hover { border-color: var(--c-primary); color: var(--c-primary-d); }

/* ------------- Tab bar (page-level, e.g. Contras) ------------- */

.tab-bar {
    display: flex; gap: 2px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--c-border);
}
.tab-bar button {
    padding: 11px 19px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--c-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    font-family: inherit;
    transition: color 0.12s;
}
.tab-bar button:hover  { color: var(--c-text); }
.tab-bar button.active { color: var(--c-primary-d); border-bottom-color: var(--c-primary); font-weight: 600; }

/* ------------- Toolbar helpers ------------- */

.toolbar-chk {
    display: flex; align-items: center; gap: 6px;
    font-size: 13px; color: var(--c-muted);
    cursor: pointer; user-select: none;
}
.role-tag-muted { background: #f1f3f9; color: var(--c-muted); }
.muted-inline   { color: var(--c-muted); font-size: 12px; }

tr.inactive td { color: var(--c-muted-soft); opacity: 0.75; }

/* ------------- Link lists (doctor↔proc, doctor↔room, proc↔room) ------------- */

.sub-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.link-list {
    border: 1px solid var(--c-border); border-radius: var(--radius);
    max-height: 420px; overflow: auto; background: #fff;
}
.link-group-title {
    position: sticky; top: 0; z-index: 2;
    background: #f8fafc; padding: 9px 14px;
    font-size: 12px; font-weight: 700;
    color: var(--c-muted); text-transform: uppercase; letter-spacing: 0.06em;
    border-bottom: 1px solid var(--c-border);
}
.link-row {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 14px;
    border-bottom: 1px solid var(--c-border);
    cursor: pointer;
    font-size: 14px;
    color: var(--c-text);
}
.link-row:last-child { border-bottom: none; }
.link-row:hover { background: #f8fafc; }
.link-row input { cursor: pointer; }

/* ------------- Calc grid (procedure ingredients) ------------- */

.calc-grid td { padding: 6px 8px; }
.calc-grid td.center { text-align: center; }
.calc-grid td.right  { text-align: right; font-variant-numeric: tabular-nums; }
.calc-grid input, .calc-grid select {
    width: 100%;
    padding: 7px 9px;
    border: 1px solid var(--c-border);
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
    color: var(--c-text);
    font-family: inherit;
}
.calc-grid input:focus, .calc-grid select:focus { outline: none; border-color: var(--c-primary); }
.calc-grid td.right  > input { text-align: right;  }
.calc-grid td.center > input { text-align: center; }
/* Calc-grid inputs default to width:100%; restore intrinsic size for the
   custom checkbox so it doesn't stretch across the column. */
.calc-grid input[type="checkbox"] { width: 18px; padding: 0; }

/* ------------- Client: referral picker ------------- */

.ref-client { display: flex; flex-direction: column; gap: 5px; }
.ref-label  { font-size: 13px; font-weight: 500; color: var(--c-muted); }
.ref-wrap   { position: relative; }

/* Selected client chip — styled like a normal input field so it fits
   the form grid instead of looking like a pill. */
.ref-chip {
    display: flex; align-items: center; gap: 8px;
    width: 100%;
    min-height: 38px;
    padding: 6px 6px 6px 12px;
    border: 1px solid var(--c-border);
    border-radius: 8px;
    background: #fff;
    color: var(--c-text);
    font-size: 14px;
    box-sizing: border-box;
}
.ref-chip > :first-child { font-weight: 600; }
.ref-chip .icon-btn {
    margin-left: auto;
    width: 26px; height: 26px; font-size: 14px;
    color: var(--c-muted);
}
.ref-chip .icon-btn:hover { background: var(--c-primary-l); color: var(--c-primary-d); }

.ref-search input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--c-border);
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    color: var(--c-text);
    font-family: inherit;
    box-sizing: border-box;
}
.ref-search input:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-l); }

/* When the search field has a paired 🔍 dialog button. The input gets the
   remaining width via flex, the button keeps its natural square shape. */
.ref-search-with-btn { display: flex; gap: 6px; align-items: stretch; }
.ref-search-with-btn input { flex: 1 1 auto; }
.ref-search-btn { flex: 0 0 auto; padding: 0 12px; }
.client-search-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--c-border);
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    color: var(--c-text);
    font-family: inherit;
    box-sizing: border-box;
}
.client-search-input:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-l); }

/* Fixed-height results area so the dialog doesn't jump as the user types
   and the result count changes. Height is on the inner scroll region —
   the modal itself stays the same size whether 0 or 50 rows are shown. */
.client-search-modal { height: 70vh; max-height: 640px; }
.client-search-body  { display: flex; flex-direction: column; min-height: 0; }
.client-search-results {
    flex: 1 1 auto; min-height: 0; overflow: auto;
    border: 1px solid var(--c-border); border-radius: 8px;
    background: #fff;
}

.ref-results {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0;
    max-height: 260px; overflow: auto;
    background: #fff; border: 1px solid var(--c-border);
    border-radius: 8px;
    box-shadow: var(--c-shadow);
    z-index: 50;
}
.ref-item {
    padding: 9px 13px; cursor: pointer;
    border-bottom: 1px solid var(--c-border);
    font-size: 14px;
    color: var(--c-text);
}
.ref-item:last-child { border-bottom: none; }
.ref-item:hover      { background: var(--c-primary-l); }

/* ------------- Client: anketa editor ------------- */

.anketa-group       { margin-bottom: 18px; }
.anketa-group-title {
    font-size: 16px; font-weight: 800; color: var(--c-text);
    text-transform: uppercase; letter-spacing: 0.06em;
    text-align: center;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--c-border);
}
.anketa-row {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 12px;
    align-items: center;
    padding: 6px 0;
}
.anketa-label { font-size: 14px; color: var(--c-text); }
.anketa-label .req { color: var(--c-danger); margin-left: 3px; }
.anketa-input input,
.anketa-input select {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--c-border);
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    color: var(--c-text);
    font-family: inherit;
    box-sizing: border-box;
}
.anketa-input input:focus, .anketa-input select:focus {
    outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-l);
}
.anketa-input .yn {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 14px; cursor: pointer; color: var(--c-text);
}

/* Lat / Lng / map-button in one row on Client → Address tab. */
.gps-row {
    display: flex; gap: 14px; align-items: flex-end;
}
.gps-row label { flex: 1 1 0; min-width: 0; }
.gps-row .gps-pick {
    height: 38px; white-space: nowrap;
    flex-shrink: 0;
}

/* ------------- Toggle switch (Да / Нет etc.) ------------- */

.switch {
    display: inline-flex; align-items: center; gap: 10px;
    cursor: pointer; user-select: none; font-size: 14px; color: var(--c-text);
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.switch-track {
    position: relative;
    width: 44px; height: 24px;
    background: #d4d9e5;
    border-radius: 999px;
    transition: background 0.18s;
    flex-shrink: 0;
}
.switch-thumb {
    position: absolute; top: 2px; left: 2px;
    width: 20px; height: 20px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
    transition: transform 0.18s;
}
.switch input:checked + .switch-track { background: var(--c-primary); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(20px); }
.switch input:focus-visible + .switch-track {
    box-shadow: 0 0 0 3px var(--c-primary-l);
}
.switch-label {
    min-width: 30px;
    font-weight: 500;
    color: var(--c-muted);
}
.switch input:checked ~ .switch-label { color: var(--c-primary-d); }

/* ------------- Segmented toggle (e.g. UZS / USD) ------------- */

.seg-toggle {
    display: inline-flex;
    background: #eef1f7;
    border: 1px solid var(--c-border);
    border-radius: 8px;
    padding: 2px;
    height: 38px;
    box-sizing: border-box;
    width: 100%;
}
.seg-toggle button {
    flex: 1;
    padding: 6px 14px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--c-muted);
    border-radius: 6px;
    font-family: inherit;
    transition: background 0.12s, color 0.12s, box-shadow 0.12s;
}
.seg-toggle button.active {
    background: #fff;
    color: var(--c-primary-d);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}
.seg-toggle button:hover:not(.active) { color: var(--c-text); }

/* ------------- Map picker (Leaflet) ------------- */

.map-backdrop { z-index: 1100; }
.map-modal {
    width: 100%;
    max-width: 860px;
    height: 80vh;
    max-height: 80vh;
    display: flex; flex-direction: column;
}
.map-body {
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
    background: #e5e9f2;
}
.map-canvas { position: absolute; inset: 0; }
.map-info {
    padding: 10px 22px;
    border-top: 1px solid var(--c-border);
    font-size: 14px;
    background: #f8fafc;
    font-variant-numeric: tabular-nums;
}

/* ------------- Uxod (treatments) ------------- */

.uxod-toolbar {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 14px; flex-wrap: wrap;
}
.date-range {
    display: flex; align-items: center; gap: 6px;
    padding: 4px 8px;
    background: #fff; border: 1px solid var(--c-border); border-radius: 8px;
}
.date-range input[type="date"],
.date-range select {
    border: none; padding: 6px 4px; background: transparent;
    font-size: 14px; color: var(--c-text); font-family: inherit;
    font-variant-numeric: tabular-nums;
}
.date-range select {
    /* Strip the native chevron so the toolbar reads as one continuous pill;
       a small caret is appended via background-image instead. */
    appearance: none; -webkit-appearance: none; -moz-appearance: none;
    padding-right: 18px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\' width=\'10\' height=\'6\' viewBox=\'0 0 10 6\'%3E%3Cpath fill=\'none\' stroke=\'%2364748b\' stroke-width=\'1.5\' stroke-linecap=\'round\' stroke-linejoin=\'round\' d=\'M1 1l4 4 4-4\'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 4px center;
    cursor: pointer;
}
.date-range input[type="date"]:focus,
.date-range select:focus { outline: none; }
.date-range .icon-step {
    padding: 6px 10px; font-size: 12px; color: var(--c-muted);
}
.date-range.disabled { opacity: 0.5; cursor: not-allowed; }
.date-range.disabled input[type="date"],
.date-range.disabled select { cursor: not-allowed; }

.status-bar {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 10px 14px;
    background: #f8fafc; border: 1px solid var(--c-border);
    border-radius: var(--radius);
    margin-bottom: 14px;
}
.status-btn       { font-size: 13px; padding: 7px 12px; }
/* Button-only status palette. Scoped to <button> so divs/rows that carry a
   status-* class (e.g. .modal-tabs.status-done) aren't repainted. */
button.status-booked    { background: #fff7e0; border-color: #f0c36d; color: #7a5200; }
button.status-booked:hover:not(:disabled)    { background: #f0c36d; color: #3d2900; }
button.status-progress  { background: #e7f1ff; border-color: #6c9dff; color: #1e3f90; }
button.status-progress:hover:not(:disabled)  { background: #6c9dff; color: #fff; }
button.status-done      { background: #e2f5ea; border-color: #58b07a; color: #0e5a2b; }
button.status-done:hover:not(:disabled)      { background: #58b07a; color: #fff; }
button.status-cancelled { background: #fde8e9; border-color: #d9797c; color: #9f1f23; }
button.status-cancelled:hover:not(:disabled) { background: #d9797c; color: #fff; }

/* Row background tint by status — subtle */
.grid tbody tr.status-booked    td { background: #fffbef; }
.grid tbody tr.status-progress  td { background: #f2f7ff; }
.grid tbody tr.status-done      td { background: #f1faf4; }
.grid tbody tr.status-cancelled td { color: var(--c-muted-soft); background: #fcf3f4; }

.status-pill {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    background: #f1f3f9;
    color: var(--c-muted);
    white-space: nowrap;
}

/* Right-click context menu (Uxod page status switcher). The backdrop
   captures clicks to close; the menu itself stops propagation. */
.ctx-backdrop {
    position: fixed; inset: 0; z-index: 1200;
    background: transparent;
}
.ctx-menu {
    position: fixed;
    min-width: 180px;
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: 8px;
    box-shadow: var(--c-shadow-lg);
    padding: 6px;
    display: flex; flex-direction: column; gap: 2px;
}
.ctx-title {
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--c-muted);
    padding: 4px 10px 6px;
}
.ctx-item {
    text-align: left;
    padding: 8px 12px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    color: var(--c-text);
    transition: background 0.1s;
}
.ctx-item:hover { background: var(--c-primary-l); color: var(--c-primary-d); }
.status-pill.status-booked    { background: #fff0c9; color: #7a5200; }
.status-pill.status-progress  { background: #d9e6ff; color: #1e3f90; }
.status-pill.status-done      { background: #cbe9d7; color: #0e5a2b; }
.status-pill.status-cancelled { background: #f5cfd1; color: #9f1f23; }

.uxod-totals {
    display: flex; flex-wrap: wrap; gap: 18px;
    padding: 14px 16px;
    background: #f8fafc;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    margin-top: 18px;
}
.uxod-totals > div { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.uxod-totals b    { font-variant-numeric: tabular-nums; font-size: 15px; color: var(--c-text); }
.uxod-total-big   { margin-left: auto; font-size: 16px; }
.uxod-total-big b { font-size: 20px; color: var(--c-primary-d); }

.grid .right  { text-align: right;  font-variant-numeric: tabular-nums; }
.grid .center { text-align: center; font-variant-numeric: tabular-nums; }
.grid tfoot td {
    padding: 10px 14px; font-size: 14px;
    background: #f8fafc; border-top: 2px solid var(--c-border);
    color: var(--c-text);
}

/* ------------- Cash / payments ------------- */

.grid tbody tr.cash-in  td { background: #f1faf4; }
.grid tbody tr.cash-out td { background: #fcf3f4; }

/* Inline editable cells inside data grids (Budget page). */
.grid td > input.cell-input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 13px;
    background: transparent;
    color: var(--c-text);
    font-family: inherit;
    font-variant-numeric: tabular-nums;
    box-sizing: border-box;
}
.grid td > input.cell-input:hover { border-color: var(--c-border); background: #fff; }
.grid td > input.cell-input:focus {
    outline: none;
    border-color: var(--c-primary);
    background: #fff;
    box-shadow: 0 0 0 2px var(--c-primary-l);
}
.grid td.right  > input.cell-input { text-align: right;  }
.grid td.center > input.cell-input { text-align: center; }

/* Per-cell error highlight — used by Contract page when plan≠fact or out-of-plan uxod. */
.grid tbody td.cell-error,
.calc-grid tbody td.cell-error {
    background: var(--c-danger-l);
    color: var(--c-danger);
    font-weight: 700;
}

.cash-ost {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 14px;
    background: #eef0ff;
    border: 1px solid var(--c-primary);
    border-radius: 8px;
    font-size: 14px;
}
.cash-ost b {
    font-variant-numeric: tabular-nums;
    color: var(--c-primary-d);
    font-size: 15px;
}

.client-day-totals {
    margin-top: 6px;
    padding: 6px 10px;
    font-size: 13px;
    color: var(--c-muted);
    background: #f8fafc;
    border-radius: 6px;
    font-variant-numeric: tabular-nums;
}
.client-day-totals b { color: var(--c-text); }

/* ------------- Router transition helpers ------------- */

/* Pages are flex columns sized to the visible content area: the header /
   toolbars stay fixed in place and the table card (`.card` direct child)
   takes the remaining height and scrolls internally. Pages without `.page`
   (e.g. Home) keep the default `.content` scroll. */
.page { height: 100%; display: flex; flex-direction: column; min-height: 0; }

.page > .card {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

/* Sticky column headers / totals while rows scroll inside the card.
   `.grid` uses border-collapse: collapse, which clips the bottom border of
   sticky cells — redraw it via box-shadow. */
.page > .card .grid > thead > tr > th {
    position: sticky;
    top: 0;
    z-index: 1;
    box-shadow: inset 0 -1px 0 var(--c-border);
}
.page > .card .grid > tfoot > tr > td {
    position: sticky;
    bottom: 0;
    z-index: 1;
    box-shadow: inset 0 1px 0 var(--c-border);
}

/* ------------- Multi-check (val_type=5) ------------- */
.multi-check { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 4px 0; }
.multi-check-item {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px;
    border: 1px solid var(--c-border);
    border-radius: 999px;
    background: #fff;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}
.multi-check-item input { margin: 0; }
.multi-check-item:has(input:checked) {
    border-color: var(--c-primary);
    background: var(--c-primary-l);
    color: var(--c-primary-d);
}

/* ------------- Client photo protocol ------------- */
.form-grid .photo-upload-row {
    display: grid;
    grid-template-columns: 1fr 1fr 3fr;
    gap: 14px;
}
@media (max-width: 640px) {
    .form-grid .photo-upload-row { grid-template-columns: 1fr 1fr; }
    .form-grid .photo-upload-row > label:last-child { grid-column: 1 / -1; }
}
.photo-col { margin-bottom: 18px; }
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    padding: 6px 0;
}
.photo-card {
    display: flex; flex-direction: column; gap: 4px;
    border: 1px solid var(--c-border);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}
.photo-card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
    background: #f1f5f9;
}
.photo-card .photo-meta {
    padding: 4px 8px;
    font-size: 12px;
    display: flex; gap: 4px; align-items: baseline;
}
.photo-card .photo-actions {
    display: flex; gap: 4px; padding: 4px 6px 6px;
}
.photo-card .photo-actions .btn { padding: 3px 8px; font-size: 11px; }

/* ------------- Reception dashboard ------------- */
.reception { display: flex; flex-direction: column; gap: 14px; }
.reception-head {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius);
    padding: 14px 18px; box-shadow: var(--c-shadow);
}
.reception-title { font-size: 22px; font-weight: 700; color: var(--c-text); }
.reception-sub { font-size: 13px; color: var(--c-muted); margin-top: 2px; }
.reception-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.reception-toolbar {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius);
    padding: 10px 14px; box-shadow: var(--c-shadow);
}
.reception-toolbar .date-range { display: flex; align-items: center; gap: 6px; }
.reception-search { position: relative; flex: 1 1 260px; max-width: 400px; display: flex; gap: 6px; align-items: stretch; }
.reception-search input { flex: 1 1 auto; padding: 7px 10px; border: 1px solid var(--c-border); border-radius: 6px; font-size: 14px; }
.reception-search > .btn { flex: 0 0 auto; padding: 0 12px; }
.reception-search-results {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 5;
    margin-top: 4px;
    background: #fff; border: 1px solid var(--c-border); border-radius: 6px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
    max-height: 280px; overflow: auto;
}
.reception-search-item { padding: 8px 12px; cursor: pointer; }
.reception-search-item:hover { background: var(--c-primary-l); }

.reception-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-left: auto; }
.reception-stat {
    background: var(--c-primary-l); border-radius: 8px;
    padding: 8px 12px; min-width: 110px;
}
.reception-stat-label { font-size: 11px; color: var(--c-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.reception-stat-val   { font-size: 16px; font-weight: 700; color: var(--c-text); margin-top: 2px; }

.reception-grid-wrap { padding: 14px; }
.reception-grid-title { font-size: 15px; font-weight: 700; padding: 4px 6px 10px; }
.reception-grid-title .count {
    display: inline-block; margin-left: 8px;
    background: var(--c-primary-l); color: var(--c-primary-d);
    border-radius: 10px; padding: 1px 8px; font-size: 12px;
}
.reception-grid {
    width: 100%; border-collapse: separate; border-spacing: 4px;
    table-layout: fixed;
}
.reception-grid thead th {
    background: #f1f5f9; padding: 8px; font-size: 13px; font-weight: 600;
    color: var(--c-text); text-align: left; border-radius: 6px;
}
.reception-grid .time-col {
    width: 70px; text-align: center;
    font-weight: 600; color: var(--c-muted); font-size: 13px;
    background: #f8fafc; border-radius: 6px;
    padding: 8px;
}
.reception-cell {
    background: #fff; border: 1px dashed var(--c-border); border-radius: 6px;
    min-height: 56px; vertical-align: top; padding: 4px;
    cursor: pointer; transition: background 0.1s, border-color 0.1s;
}
.reception-cell:hover { background: #f8fafc; border-color: var(--c-primary); }
.reception-cell-empty {
    color: #c0c8d4; font-size: 22px; text-align: center; line-height: 48px;
    user-select: none;
}
.reception-booking {
    display: block; padding: 6px 8px; margin-bottom: 4px;
    border-radius: 6px; border: 1px solid var(--c-border); background: #fff;
    font-size: 12px; line-height: 1.3;
}
.reception-booking:last-child { margin-bottom: 0; }
.reception-booking.status-booked    { background: #fff7e0; border-color: #f0c36d; color: #5a3a00; }
.reception-booking.status-progress  { background: #e7f1ff; border-color: #6c9dff; color: #1e3f90; }
.reception-booking.status-done      { background: #e2f5ea; border-color: #58b07a; color: #0e5a2b; }
.reception-booking.status-cancelled { background: #fde8e9; border-color: #e29499; color: #6b1318; text-decoration: line-through; }
.reception-booking-name { font-weight: 600; }
.reception-booking-meta { font-size: 11px; opacity: 0.85; }

.reception-cols {
    display: grid; grid-template-columns: 3fr 2fr; gap: 14px;
}
.reception-day-card { padding: 14px; }
.reception-day-card .grid { border: 1px solid var(--c-border); border-radius: 8px; overflow: hidden; }
@media (max-width: 1100px) {
    .reception-cols { grid-template-columns: 1fr; }
}

/* ===== Dashboard panels (Home + Reception) ===== */

/* Reception summary row — 4 small cards above the day visits/payments. */
.reception-summary {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
    margin-bottom: 14px;
}
.reception-summary-card { padding: 14px; }
.reception-summary-card .reception-grid-title { margin-bottom: 10px; }
@media (max-width: 1100px) {
    .reception-summary { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
    .reception-summary { grid-template-columns: 1fr; }
}

/* Status tiles (visit-status block) — different from .status-pill (inline badge). */
.stat-tiles {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
    padding: 4px 4px 8px;
}
.stat-tile {
    display: flex; flex-direction: column; align-items: center;
    padding: 10px 8px; border-radius: 10px;
    background: #f1f3f9; color: var(--c-muted);
}
.stat-tile-label { font-size: 11px; font-weight: 600; opacity: 0.85; }
.stat-tile-val   { font-size: 22px; font-weight: 700; line-height: 1.1; margin-top: 2px; }
.stat-tile--booked    { background: #fff0c9; color: #7a5200; }
.stat-tile--progress  { background: #d9e6ff; color: #1e3f90; }
.stat-tile--done      { background: #cbe9d7; color: #0e5a2b; }
.stat-tile--cancelled { background: #f5cfd1; color: #9f1f23; }

/* Ranked lists (top doctors / procedures / debtors / doctor load / new clients). */
.rank-list {
    list-style: none; margin: 0; padding: 0;
}
.rank-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; padding: 8px 12px;
    border-bottom: 1px solid var(--c-border);
}
.rank-row:last-child { border-bottom: none; }
.rank-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-meta { color: var(--c-muted); font-size: 12px; white-space: nowrap; }
.rank-meta b { color: var(--c-text); font-weight: 600; }
.rank-debt b { color: #9f1f23; }

/* 7-day cash flow bar chart (Home). */
.cash-bars {
    display: grid; grid-template-columns: repeat(7, 1fr);
    gap: 6px; padding: 12px 14px 14px; align-items: end;
    min-height: 130px;
}
.cash-bar-col {
    display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
    gap: 4px; min-width: 0;
}
.cash-bar-val {
    font-size: 10px; color: var(--c-muted);
    height: 12px; line-height: 12px;
}
.cash-bar {
    width: 100%; max-width: 36px;
    background: linear-gradient(180deg, var(--c-primary) 0%, var(--c-primary-d, #1e3f90) 100%);
    border-radius: 4px 4px 0 0;
    min-height: 4px;
}
.cash-bar-day {
    font-size: 11px; color: var(--c-muted); font-weight: 600;
}
