/*
  CS Dental PRO — the desktop application's look for the browser version.
  Loaded after bootstrap.css and app-shell.css: same colours, sidebar, cards, controls and fonts as the WPF theme
  (src/CSDentalPro.Desktop/Themes/Theme.xaml).
*/

:root {
    --dp-primary: var(--cs-p);
    --dp-primary-hover: var(--cs-p-hover);
    --dp-primary-soft: var(--cs-p-soft);
    --dp-accent: var(--cs-p2);
    --dp-gradient: linear-gradient(135deg, var(--cs-p) 0%, var(--cs-p2) 100%);
    --dp-gradient-hover: linear-gradient(135deg, var(--cs-p-hover) 0%, var(--cs-p2-hover) 100%);
    --dp-sidebar: linear-gradient(170deg, #0A1424 0%, #0B2230 65%, #0B2B33 100%);
    --dp-sidebar-text: #9FB0C3;
    --dp-sidebar-hover: rgba(255, 255, 255, 0.086);
    --dp-sidebar-active: linear-gradient(90deg, rgba(var(--cs-p-light-rgb), 0.2) 0%, rgba(var(--cs-p2-light-rgb), 0.063) 100%);
    --dp-sidebar-card: rgba(255, 255, 255, 0.07);
    --dp-bg: linear-gradient(135deg, #F6F8FC 0%, #F1F6F8 100%);
    --dp-surface: #FFFFFF;
    --dp-surface-alt: #F7F9FC;
    --dp-border: #E7ECF3;
    --dp-border-strong: #D3DCE7;
    --dp-text: #0B1324;
    --dp-muted: #64748B;
    --dp-danger: #E11D48;
    --dp-danger-soft: #FFE4E6;
    --dp-warning: #B45309;
    --dp-warning-soft: #FEF3C7;
    --dp-success: #059669;
    --dp-success-soft: #D1FAE5;
    --dp-info: #2563EB;
    --dp-info-soft: #DBEAFE;
    --dp-selection: var(--cs-p-softer);
    --dp-hover: #F2F6FA;
    --dp-shadow-soft: 0 3px 22px rgba(11, 19, 36, 0.07);
    --dp-shadow-raised: 0 8px 34px rgba(11, 19, 36, 0.16);
    --dp-font: "Segoe UI Variable Text", "Segoe UI", "Noto Sans Armenian", "Noto Sans", system-ui, sans-serif;
    --dp-font-display: "Segoe UI Variable Display", "Segoe UI", "Noto Sans Armenian", "Noto Sans", system-ui, sans-serif;

    /* the older variables used across the pages */
    --color-primary: var(--dp-primary);
    --color-dark: #0B2230;
    --color-bg: #F4F7FA;
    --color-card: var(--dp-surface);
    --color-success: var(--dp-success);
    --color-warning: var(--dp-warning);
    --color-info: var(--dp-info);
    --color-danger: var(--dp-danger);
    --color-muted: var(--dp-muted);
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-soft: var(--dp-shadow-soft);

    /* Bootstrap */
    --bs-primary: var(--cs-p);
    --bs-primary-rgb: var(--cs-p-rgb);
    --bs-link-color: var(--cs-p);
    --bs-link-color-rgb: var(--cs-p-rgb);
    --bs-link-hover-color: var(--cs-p-hover);
    --bs-body-font-family: var(--dp-font);
    --bs-body-color: var(--dp-text);
    --bs-border-color: var(--dp-border);
    --bs-border-radius: 8px;
    --bs-focus-ring-color: rgba(var(--cs-p-rgb), 0.25);
}

html,
body {
    background: var(--dp-bg);
    color: var(--dp-text);
    font-family: var(--dp-font);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 {
    font-family: var(--dp-font-display);
    color: var(--dp-text);
    letter-spacing: -0.01em;
}

a { color: var(--dp-primary); }
a:hover { color: var(--dp-primary-hover); }

::selection { background: var(--dp-primary-soft); }

/* ---------- Shell ---------- */

.app-shell,
.patient-portal-shell {
    background: var(--dp-bg);
    grid-template-columns: 264px 1fr;
}

.app-sidebar {
    background: var(--dp-sidebar);
    color: var(--dp-sidebar-text);
    padding: 20px 12px 14px;
    box-shadow: 1px 0 0 rgba(255, 255, 255, 0.04);
}

.sidebar-brand {
    background: transparent;
    padding: 6px 8px 18px;
    margin-bottom: 6px;
    gap: 12px;
}

.sidebar-logo,
.sidebar-logo-fallback {
    width: 42px;
    height: 42px;
    min-height: 42px;
    border-radius: 13px;
    background: var(--dp-gradient);
    box-shadow: 0 0 18px rgba(var(--cs-p-light-rgb), 0.45);
    padding: 6px;
    color: #fff;
}

.sidebar-brand-text strong {
    color: #fff;
    font-family: var(--dp-font-display);
    font-size: 16px;
    font-weight: 700;
}

.sidebar-brand-text span { color: var(--dp-sidebar-text); font-size: 11.5px; }

.sidebar-section-title {
    color: #5F7389;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 14px 14px 6px;
}

.app-sidebar.collapsed .sidebar-section-title { display: none; }

.sidebar-nav { gap: 2px; }

.sidebar-link {
    position: relative;
    color: var(--dp-sidebar-text);
    border-radius: 10px;
    padding: 10px 14px;
    min-height: 42px;
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
    background: transparent;
    border: 0;
    transition: background 0.16s ease, color 0.16s ease;
}

.sidebar-link:hover {
    background: var(--dp-sidebar-hover);
    color: #fff;
}

.sidebar-link.active {
    background: var(--dp-sidebar-active);
    color: #fff;
    font-weight: 600;
    box-shadow: none;
}

.sidebar-link.active::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 9px;
    bottom: 9px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--cs-p-glow);
    box-shadow: 0 0 10px rgba(var(--cs-p-glow-rgb), 0.7);
}

.sidebar-icon {
    width: 22px;
    font-size: 16px;
    color: inherit;
    opacity: 0.9;
    text-align: center;
}

.sidebar-link.active .sidebar-icon { color: var(--cs-p-mid); opacity: 1; }

/* ---------- Top bar ---------- */

.app-topbar {
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--dp-border);
    box-shadow: none;
}

.topbar-left h1 {
    font-family: var(--dp-font-display);
    font-size: 22px;
    font-weight: 700;
    color: var(--dp-text);
}

.topbar-left p { color: var(--dp-muted); }

.icon-button,
.language-chip,
.user-chip,
.topbar-search-launch {
    background: var(--dp-surface);
    border: 1px solid var(--dp-border);
    border-radius: 10px;
    color: var(--dp-text);
    box-shadow: none;
}

.icon-button:hover,
.topbar-search-launch:hover,
.user-chip:hover {
    background: var(--dp-hover);
    border-color: var(--dp-border-strong);
}

.avatar {
    background: var(--dp-gradient);
    color: #fff;
}

.clock { color: var(--dp-muted); }

/* ---------- Workspace tabs (as the desktop tab strip) ---------- */

.workspace-tabbar {
    background: transparent;
    border-bottom: 1px solid var(--dp-border);
}

.workspace-tab {
    background: transparent;
    border: 1px solid transparent;
    border-bottom: 0;
    border-radius: 9px 9px 0 0;
    color: var(--dp-muted);
    font-size: 12.5px;
    margin-bottom: -1px;
    box-shadow: none;
}

.workspace-tab:hover { background: var(--dp-hover); }

.workspace-tab.active {
    background: var(--dp-surface);
    border-color: var(--dp-border);
    color: var(--dp-text);
    font-weight: 600;
}

.workspace-tab-close:hover {
    background: var(--dp-danger-soft);
    color: var(--dp-danger);
}

.workspace-statusbar {
    background: var(--dp-surface);
    border-top: 1px solid var(--dp-border);
    color: var(--dp-muted);
}

.workspace-context-menu,
.workspace-search-dialog,
.command-palette-card {
    background: var(--dp-surface);
    border: 1px solid var(--dp-border-strong);
    border-radius: 10px;
    box-shadow: var(--dp-shadow-raised);
}

.workspace-context-menu button,
.command-result {
    border-radius: 6px;
}

.workspace-context-menu button:hover:not(:disabled),
.command-result:hover,
.workspace-search-result:hover {
    background: var(--dp-hover);
}

/* ---------- Cards and panels ---------- */

.card,
.dashboard-panel,
.kpi-card,
.notification-card,
.patients-card-grid > *,
.odontogram-panel,
.admin-table-wrap {
    background: var(--dp-surface);
    border: 1px solid var(--dp-border);
    border-radius: 14px;
    box-shadow: var(--dp-shadow-soft);
}

.card-header,
.dashboard-panel-head {
    background: transparent;
    border-bottom: 1px solid var(--dp-border);
}

.card-title,
.dashboard-panel-head h2 {
    font-family: var(--dp-font-display);
    font-size: 16px;
    font-weight: 700;
}

.dashboard-panel-head p,
.text-muted,
.form-text,
small {
    color: var(--dp-muted) !important;
}

.kpi-card.is-clickable:hover {
    box-shadow: var(--dp-shadow-raised);
    transform: translateY(-2px);
}

.kpi-meta h3 { color: var(--dp-muted); font-size: 12.5px; font-weight: 600; }
.kpi-meta strong { font-family: var(--dp-font-display); font-size: 24px; font-weight: 700; color: var(--dp-text); }

.kpi-icon {
    border-radius: 12px;
    background: var(--dp-primary-soft);
    color: var(--dp-primary);
}

/* ---------- Buttons ---------- */

.btn {
    --bs-btn-border-radius: 8px;
    --bs-btn-font-weight: 600;
    --bs-btn-padding-y: 0.45rem;
    --bs-btn-padding-x: 1rem;
    --bs-btn-font-size: 13.5px;
    font-family: var(--dp-font);
    transition: background 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.btn-sm { --bs-btn-padding-y: 0.3rem; --bs-btn-padding-x: 0.7rem; --bs-btn-font-size: 12.5px; }

.btn-primary,
.auth-submit,
.patients-action {
    --bs-btn-bg: var(--cs-p);
    --bs-btn-border-color: transparent;
    --bs-btn-hover-bg: var(--cs-p-hover);
    --bs-btn-hover-border-color: transparent;
    --bs-btn-active-bg: var(--cs-p-hover);
    --bs-btn-disabled-bg: var(--cs-p);
    --bs-btn-disabled-border-color: transparent;
    background: var(--dp-gradient);
    border: 0;
    color: #fff;
    box-shadow: 0 4px 14px rgba(var(--cs-p-rgb), 0.25);
}

.btn-primary:hover,
.auth-submit:hover:not(:disabled),
.patients-action:hover {
    background: var(--dp-gradient-hover);
    color: #fff;
}

.btn-outline-primary {
    --bs-btn-color: var(--cs-p);
    --bs-btn-border-color: var(--cs-p);
    --bs-btn-hover-bg: var(--cs-p-softer);
    --bs-btn-hover-color: var(--cs-p-hover);
    --bs-btn-hover-border-color: var(--cs-p);
    --bs-btn-active-bg: var(--cs-p-soft);
    --bs-btn-active-color: var(--cs-p-hover);
}

.btn-secondary,
.btn-light,
.btn-outline-secondary {
    --bs-btn-bg: #FFFFFF;
    --bs-btn-color: var(--dp-text);
    --bs-btn-border-color: var(--dp-border-strong);
    --bs-btn-hover-bg: var(--dp-hover);
    --bs-btn-hover-color: var(--dp-text);
    --bs-btn-hover-border-color: var(--dp-border-strong);
    --bs-btn-active-bg: var(--dp-hover);
    --bs-btn-active-color: var(--dp-text);
}

.btn-danger {
    --bs-btn-bg: #FFFFFF;
    --bs-btn-color: var(--dp-danger);
    --bs-btn-border-color: #FECDD3;
    --bs-btn-hover-bg: var(--dp-danger-soft);
    --bs-btn-hover-color: var(--dp-danger);
    --bs-btn-hover-border-color: #FDA4AF;
}

.btn-success { --bs-btn-bg: var(--dp-success); --bs-btn-border-color: var(--dp-success); --bs-btn-hover-bg: #047857; --bs-btn-hover-border-color: #047857; }
.btn-warning { --bs-btn-bg: #F59E0B; --bs-btn-border-color: #F59E0B; --bs-btn-color: #fff; --bs-btn-hover-bg: #D97706; --bs-btn-hover-border-color: #D97706; --bs-btn-hover-color: #fff; }

.btn:focus-visible,
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    border-color: var(--dp-primary);
    box-shadow: 0 0 0 3px rgba(var(--cs-p-rgb), 0.18);
}

/* ---------- Inputs ---------- */

.form-control,
.form-select,
.patients-search,
.patients-filter,
.patients-form-grid input,
.patients-form-grid select,
.patients-form-grid textarea,
.clinical-inline-form input,
.clinical-inline-form select,
.clinical-inline-form textarea,
.odontogram-panel select,
.odontogram-panel textarea,
.workspace-search-dialog input,
.command-palette-input,
.auth-field input {
    background: var(--dp-surface);
    border: 1px solid var(--dp-border-strong);
    border-radius: 8px;
    color: var(--dp-text);
    font-family: var(--dp-font);
    font-size: 13.5px;
    min-height: 36px;
    box-shadow: none;
}

.form-control:hover,
.form-select:hover,
.auth-field input:hover { border-color: #B8C4D3; }

.auth-field input:focus,
.patients-search:focus,
.patients-form-grid input:focus,
.patients-form-grid select:focus,
.patients-form-grid textarea:focus {
    outline: none;
    border-color: var(--dp-primary);
    box-shadow: 0 0 0 3px rgba(var(--cs-p-rgb), 0.18);
}

.form-label,
.auth-field label,
.patients-form-grid label {
    color: var(--dp-muted);
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
}

.form-check-input:checked {
    background-color: var(--dp-primary);
    border-color: var(--dp-primary);
}

/* ---------- Tables (as the desktop data grids) ---------- */

.table,
.admin-table {
    --bs-table-bg: transparent;
    --bs-table-striped-bg: #FAFBFD;
    --bs-table-hover-bg: var(--dp-hover);
    color: var(--dp-text);
    font-size: 13.5px;
    margin-bottom: 0;
}

.table > thead th,
.admin-table th {
    background: var(--dp-surface-alt);
    color: var(--dp-muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: none;
    border-bottom: 1px solid var(--dp-border) !important;
    padding: 10px 12px;
    white-space: nowrap;
}

.table > tbody td,
.admin-table td {
    border-color: var(--dp-border);
    padding: 10px 12px;
    vertical-align: middle;
}

.table > tbody tr:hover > td,
.admin-table tbody tr:hover td {
    background: var(--dp-hover);
}

/* ---------- Badges, alerts, segmented tabs ---------- */

.status-badge,
.badge,
.clinical-chip {
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    padding: 3px 10px;
    background: var(--dp-hover);
    color: var(--dp-muted);
}

.status-primary, .badge.bg-primary { background: var(--dp-selection) !important; color: var(--dp-primary-hover) !important; }
.status-success, .badge.bg-success { background: var(--dp-success-soft) !important; color: var(--dp-success) !important; }
.status-warning, .badge.bg-warning { background: var(--dp-warning-soft) !important; color: var(--dp-warning) !important; }
.status-danger, .badge.bg-danger { background: var(--dp-danger-soft) !important; color: var(--dp-danger) !important; }

.alert {
    border: 0;
    border-radius: 10px;
    font-size: 13.5px;
}

.alert-danger, .auth-error { background: var(--dp-danger-soft); color: #9F1239; }
.alert-success { background: var(--dp-success-soft); color: #065F46; }
.alert-warning { background: var(--dp-warning-soft); color: #92400E; }
.alert-info { background: var(--dp-info-soft); color: #1E40AF; }

.nav-tabs,
.patients-tabs {
    display: inline-flex;
    gap: 2px;
    padding: 4px;
    background: #EEF2F7;
    border: 0;
    border-radius: 11px;
}

.nav-tabs .nav-link,
.patients-tabs button,
.patients-tabs a {
    border: 0;
    border-radius: 8px;
    color: var(--dp-muted);
    font-weight: 600;
    font-size: 13px;
    padding: 7px 14px;
    background: transparent;
}

.nav-tabs .nav-link.active,
.patients-tabs .active {
    background: var(--dp-surface);
    color: var(--dp-primary-hover);
    box-shadow: 0 1px 4px rgba(11, 19, 36, 0.08);
}

.empty-state { color: var(--dp-muted); }
.empty-state-icon { background: var(--dp-selection); color: var(--dp-primary); border-radius: 16px; }

/* ---------- Sign-in (as the desktop sign-in window) ---------- */

.auth-layout {
    background:
        radial-gradient(900px 500px at 0% 0%, rgba(var(--cs-p-light-rgb), 0.18), transparent 60%),
        radial-gradient(800px 600px at 100% 100%, rgba(var(--cs-p2-rgb), 0.16), transparent 60%),
        #0A1424;
}

.auth-card {
    border-radius: 18px;
    border: 0;
    overflow: hidden;
    background: var(--dp-surface);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

.auth-brand {
    background: var(--dp-sidebar);
    color: #fff;
}

.auth-brand-logo {
    background: var(--dp-gradient);
    border-radius: 16px;
    padding: 8px;
    box-shadow: 0 0 22px rgba(var(--cs-p-light-rgb), 0.5);
}

.auth-brand-text h1 { color: #fff; font-weight: 700; }
.auth-brand-text p { color: var(--dp-sidebar-text); }

.auth-form-wrap h2 { font-family: var(--dp-font-display); font-weight: 700; color: var(--dp-text); }
.auth-form-wrap p { color: var(--dp-muted); }

.auth-submit {
    border-radius: 10px;
    min-height: 42px;
    font-weight: 600;
    font-size: 14px;
}

.auth-submit:disabled { opacity: 0.6; }

.app-loading-screen { background: #0A1424; color: var(--dp-sidebar-text); }

/* ---------- Scrollbars (thin, as in the desktop app) ---------- */

* {
    scrollbar-width: thin;
    scrollbar-color: #C9D3DF transparent;
}

.app-sidebar * { scrollbar-color: rgba(255, 255, 255, 0.15) transparent; }

/* Small charts on the KPI cards in the desktop's teal, and no focus frame on the page title after navigation. */
.kpi-sparkline { background: linear-gradient(90deg, rgba(var(--cs-p-rgb), 0.16), rgba(var(--cs-p2-rgb), 0.22)); }
h1:focus, h1:focus-visible, [tabindex="-1"]:focus { outline: none; box-shadow: none; }

/* Icons: the same Segoe MDL2 Assets glyphs as the desktop program (built into Windows 10/11; Segoe Fluent Icons on Windows 11). */
.sidebar-icon.mdl2,
.workspace-tab-icon {
    font-family: "Segoe Fluent Icons", "Segoe MDL2 Assets", "Segoe UI Symbol", sans-serif;
    font-style: normal;
    font-weight: normal;
    line-height: 1;
    -webkit-font-smoothing: antialiased;
}
.sidebar-icon.mdl2 { font-size: 15px; width: 18px; text-align: center; }
.workspace-tab-icon { font-size: 13px; opacity: 0.85; }

/* Devices page */
.devices-page { display: grid; gap: 16px; max-width: 880px; }
.devices-hint { color: var(--dp-muted, #64748B); margin: 0 0 12px; line-height: 1.5; }
.devices-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 12px; }
.devices-field { display: flex; flex-direction: column; gap: 4px; min-width: 220px; flex: 1 1 220px; font-size: 13px; font-weight: 600; color: var(--dp-text, #0B1324); }
.devices-field.narrow { flex: 0 1 170px; min-width: 150px; }
.devices-field.wide { flex-basis: 100%; margin-top: 4px; }
.devices-status { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; margin: 4px 0; }
.devices-status.success { background: var(--cs-p-softer); color: var(--cs-p-hover); }
.devices-status.warning { background: #FEF3C7; color: #92400E; }
.devices-status.danger { background: #FFE4E6; color: #BE123C; }
.devices-status.muted { background: #F2F6FA; color: #64748B; }
@media (max-width: 600px) {
    .devices-field, .devices-field.narrow { flex-basis: 100%; min-width: 0; }
}

/* ---------- Layout fixes found by checking every page ---------- */

/* MDL2 glyphs wherever an icon is shown (KPI cards, empty states, tab strip). */
.mdl2,
.kpi-icon.mdl2,
.analytics-kpi-icon.mdl2,
.empty-state-icon.mdl2 {
    font-family: "Segoe Fluent Icons", "Segoe MDL2 Assets", "Segoe UI Symbol", sans-serif;
    font-style: normal;
    font-weight: normal;
    line-height: 1;
}

.kpi-icon.mdl2 { display: inline-flex; align-items: center; justify-content: center; font-size: 20px; }
.kpi-card { align-items: center; }

/* Buttons with words in them: as wide as their text, never squeezed into a 38px square. */
.icon-button {
    width: auto;
    min-width: 38px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    flex: 0 0 auto;
}

a.icon-button:hover { color: var(--dp-text); }

.workspace-tab-scroll { width: 32px; min-width: 32px; padding: 0; }
.workspace-tab-search-button.icon-button { width: auto; padding: 0 10px; height: 32px; }

.auth-submit,
.patients-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 16px;
    min-height: 38px;
    white-space: nowrap;
    text-decoration: none;
    border-radius: 9px;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
}

a.auth-submit:hover,
a.patients-action:hover { color: #fff; }

/* Row buttons inside tables stay on one line; the table scrolls instead of overlapping them. */
.admin-table td .icon-button,
.table td .icon-button { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.admin-table td.patients-actions,
.admin-table td .patients-actions,
.table td .patients-actions { display: flex; flex-wrap: nowrap; gap: 6px; }
.admin-table td.patients-actions { display: table-cell; white-space: nowrap; }
.admin-table td.patients-actions > * + * { margin-left: 6px; }
.admin-table td { white-space: normal; }

.patients-actions { flex-wrap: wrap; align-items: center; }

/* Filter bars: every control the same height, labels above their selector, checkboxes centred. */
.patients-toolbar { align-items: flex-end; row-gap: 10px; }
.patients-toolbar > label,
.patients-toolbar label:has(> input[type="checkbox"]) {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 38px;
    margin: 0;
    color: var(--dp-text);
    font-size: 13px;
}
.patients-search,
.patients-filter { background: var(--dp-surface); font-size: 13.5px; }
.patients-toolbar .patients-search { flex: 1 1 260px; }

.selector-box { display: flex; flex-direction: column; gap: 4px; min-width: 200px; }
.selector-box > label { color: var(--dp-muted); font-size: 12px; font-weight: 600; margin: 0; }
.selector-row { display: flex; gap: 6px; }
.selector-row .patients-search { min-width: 0; flex: 1 1 auto; }

/* Label / value lists (dashboard summary, waiting list): label column wide enough for Armenian words. */
.activity-list li { grid-template-columns: minmax(96px, max-content) 1fr; align-items: baseline; }
.activity-list li .activity-text { font-weight: 600; }

/* Empty states: a small round icon, not a full-width bar. */
.empty-state-icon {
    width: 44px;
    height: 44px;
    margin: 0 auto 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

/* Analytics KPI cards (had no style of their own). */
.analytics-kpi-grid,
.analytics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 14px; }
.analytics-kpi-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--dp-surface);
    border: 1px solid var(--dp-border);
    border-radius: 14px;
    box-shadow: var(--dp-shadow-soft);
}
.analytics-kpi-icon {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    background: var(--dp-primary-soft);
    color: var(--dp-primary);
}
.analytics-kpi-card p { margin: 0; color: var(--dp-muted); font-size: 12.5px; font-weight: 600; }
.analytics-kpi-card strong { display: block; font-family: var(--dp-font-display); font-size: 20px; font-weight: 700; color: var(--dp-text); }
.analytics-kpi-card span { color: var(--dp-muted); font-size: 12px; }

/* Summary tiles (patients-card-grid) */
.patients-card-grid > * { padding: 14px 16px; min-width: 0; }
.patients-card-grid > * strong { display: block; color: var(--dp-text); }
.patients-card-grid > * p { color: var(--dp-muted); overflow-wrap: anywhere; }

/* Tables with no rows: a visible note instead of an empty strip. */
.admin-table tbody:empty::after {
    content: "Տվյալներ չկան";
    display: block;
    padding: 14px 12px;
    color: var(--dp-muted);
}

/* Keep the phone/desktop-only buttons hidden where they do not belong. */
.icon-button.mobile-only { display: none; }
@media (max-width: 860px) {
    .icon-button.desktop-only { display: none; }
    .icon-button.mobile-only { display: inline-flex; }
}

/* Selectors in filter bars: label on top, search box and list side by side. */
.selector-box { flex-direction: row; flex-wrap: wrap; align-items: center; column-gap: 6px; row-gap: 4px; }
.selector-box > label { flex-basis: 100%; }
.selector-box .selector-row .patients-search { width: 150px; min-width: 120px; }
.selector-box > .patients-filter { flex: 1 1 180px; }

/* Checkboxes in forms: a normal-size box with its text beside it. */
.patients-form-grid label:has(> input[type="checkbox"]),
.clinical-inline-form label:has(> input[type="checkbox"]) {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    align-self: end;
    min-height: 38px;
}
input[type="checkbox"] {
    width: 16px !important;
    height: 16px !important;
    min-height: 0 !important;
    min-width: 16px;
    padding: 0 !important;
    margin: 0;
    accent-color: var(--dp-primary);
    flex: 0 0 16px;
}

.status-badge, .badge, .clinical-chip { white-space: nowrap; display: inline-block; }

/* The workspace as a column, so the optional section tabs fit between the tab strip and the page. */
.workspace-shell { display: flex; flex-direction: column; }
.workspace-shell > .workspace-tabbar,
.workspace-shell > .workspace-statusbar,
.workspace-shell > .section-tabs { flex: 0 0 auto; }
.workspace-shell > .workspace-content { flex: 1 1 auto; min-height: 0; }

/* Section tabs (the pages of Finance, Insurance, Payroll, Lab, Reports) */
.section-tabs {
    display: flex;
    gap: 2px;
    padding: 8px 16px 0;
    overflow-x: auto;
    scrollbar-width: none;
    border-bottom: 1px solid var(--dp-border);
}
.section-tab {
    padding: 8px 14px;
    color: var(--dp-muted);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.section-tab:hover { color: var(--dp-text); background: var(--dp-hover); border-radius: 8px 8px 0 0; }
.section-tab.active { color: var(--dp-primary-hover); border-bottom-color: var(--dp-primary); }

.admin-table td:first-child { white-space: nowrap; }

/* Inline add/edit forms: label beside its field, several fields per row (was one full-width row per field). */
.clinical-inline-form {
    grid-template-columns: repeat(3, max-content minmax(150px, 1fr));
    align-items: center;
    column-gap: 10px;
    row-gap: 10px;
    padding: 14px 16px;
    margin-bottom: 14px;
    background: var(--dp-surface-alt);
    border: 1px solid var(--dp-border);
    border-radius: 12px;
}
.clinical-inline-form > label { margin: 0; color: var(--dp-muted); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.clinical-inline-form > label:has(input, select, textarea) { grid-column: span 2; display: flex; align-items: center; gap: 8px; color: var(--dp-text); white-space: normal; }
.clinical-inline-form > label:has(input:not([type="checkbox"]), select, textarea) { display: grid; grid-template-columns: max-content 1fr; }
.clinical-inline-form > textarea,
.clinical-inline-form > label:has(textarea) { grid-column: span 5; }
.clinical-inline-form > button,
.clinical-inline-form > .patients-actions,
.clinical-inline-form > div:has(> button) { grid-column: 1 / -1; justify-self: start; }
.clinical-inline-form > h3,
.clinical-inline-form > h4,
.clinical-inline-form > strong,
.clinical-inline-form > p { grid-column: 1 / -1; margin: 0; }
.clinical-inline-form input,
.clinical-inline-form select,
.clinical-inline-form textarea { min-height: 36px; background: var(--dp-surface); }
@media (max-width: 1200px) {
    .clinical-inline-form { grid-template-columns: repeat(2, max-content minmax(150px, 1fr)); }
    .clinical-inline-form > textarea, .clinical-inline-form > label:has(textarea) { grid-column: span 3; }
}
@media (max-width: 760px) {
    .clinical-inline-form { grid-template-columns: max-content minmax(0, 1fr); }
    .clinical-inline-form > textarea, .clinical-inline-form > label:has(textarea) { grid-column: span 1; }
}

/* Roles: list of roles on the left, the chosen role's permissions by module on the right (as the desktop Control Panel). */
.role-matrix { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
.role-list { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; }
.role-list-item {
    display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
    text-align: left; padding: 10px 12px; border-radius: 10px;
    border: 1px solid transparent; background: transparent; color: var(--dp-text); cursor: pointer;
}
.role-list-item span { color: var(--dp-muted); font-size: 12px; }
.role-list-item:hover { background: var(--dp-hover); }
.role-list-item.active { background: var(--dp-selection); border-color: var(--cs-p-border); }
.role-card { border: 1px solid var(--dp-border); border-radius: 14px; background: var(--dp-surface); overflow: hidden; }
.role-card-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; background: var(--dp-surface-alt); border-bottom: 1px solid var(--dp-border); }
.role-module { padding: 12px 16px; border-bottom: 1px solid var(--dp-border); }
.role-module:last-child { border-bottom: 0; }
.role-module-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.module-actions { display: flex; gap: 6px; }
.permission-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 14px; }
.permission-checkbox { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; cursor: pointer; }
@media (max-width: 900px) { .role-matrix { grid-template-columns: 1fr; } .role-list { position: static; flex-direction: row; overflow-x: auto; } }

/* Cards with buttons (Control Panel): wider cards, buttons may wrap their text instead of sticking out. */
.patients-card-grid:has(.icon-button) { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.patients-card-grid > * { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.patients-card-grid > * p { margin: 0 0 4px; }
.patients-card-grid .icon-button { white-space: normal; text-align: left; height: auto; min-height: 32px; padding: 6px 12px; max-width: 100%; }
.patients-card-grid > * > .patients-actions { margin-top: auto; }

/* Tables that already say why they are empty do not get the generic note too. */
.admin-table:has(+ p) tbody:empty::after { display: none; }

/* Analytics charts in the desktop's teal, with small points. */
.analytics-chart, .analytics-line-chart { color: var(--dp-primary); width: 100%; max-height: 220px; }
.analytics-line-chart circle { r: 0.8; fill: var(--dp-primary); }
.analytics-bar-fill { background: var(--dp-gradient); }

/* ---------- Phones and tablets (checked for Safari on iPhone/iPad) ---------- */

/* Safari counts the address bar in 100vh, so the bottom of the page was cut off: use the visible height. */
@supports (height: 100dvh) {
    .app-shell, .patient-portal-shell, .app-main-wrap { min-height: 100dvh; }
    .app-sidebar { height: 100dvh; }
}
.app-topbar { -webkit-backdrop-filter: blur(10px); }
.admin-table-wrap, .table-responsive, .section-tabs, .patients-tabs, .workspace-tabs { -webkit-overflow-scrolling: touch; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

@media (max-width: 860px) {
    /* The desktop column for the menu must not stay on a phone: the page used only part of the screen. */
    .app-shell, .patient-portal-shell { grid-template-columns: minmax(0, 1fr); }
    .app-sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 280px; max-width: 85vw; z-index: 40; }
    .app-main-wrap { width: 100%; min-width: 0; }

    .app-topbar { padding: 10px 12px; gap: 8px; padding-top: max(10px, env(safe-area-inset-top)); }
    .topbar-left { gap: 8px; min-width: 0; flex: 1 1 auto; }
    .topbar-left > div { min-width: 0; }
    .topbar-left h1 { font-size: 16px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .topbar-left p { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .topbar-logo, .topbar-logo-fallback { display: none; }
    .topbar-right { gap: 6px; flex: 0 0 auto; }
    .clock, .topbar-search-launch, .language-chip { display: none !important; }
    .user-chip { padding: 0 6px; }
    .user-chip span:not(.avatar) { display: none; }

    .workspace-tabbar { padding: 6px 8px 0; gap: 6px; }
    .workspace-statusbar { display: none; }
    .workspace-content { padding: 10px 10px calc(14px + env(safe-area-inset-bottom)); }
    .section-tabs { padding: 4px 8px 0; }

    .dashboard-panel, .card { border-radius: 12px; }
    .dashboard-panel-head { padding: 12px 14px; }
    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .kpi-card { padding: 12px; grid-template-columns: 1fr; gap: 6px; }
    .kpi-icon.mdl2 { width: 36px; height: 36px; font-size: 17px; }
    .kpi-meta strong { font-size: 20px; }

    /* Filter bars and forms: one control per row, full width. */
    .patients-toolbar { flex-direction: column; align-items: stretch; }
    .patients-toolbar > *, .patients-search, .patients-filter, .selector-box { width: 100%; min-width: 0; flex: 0 0 auto; }
    .patients-toolbar .patients-search { flex-basis: auto; }
    .selector-box > .patients-filter, .selector-row { width: 100%; }
    .clinical-inline-form { grid-template-columns: minmax(0, 1fr) !important; }
    .clinical-inline-form > *, .clinical-inline-form > label:has(input, select, textarea) { grid-column: 1 / -1 !important; }
    .clinical-inline-form > label { white-space: normal; }
    .clinical-inline-form > label:has(input:not([type="checkbox"]), select, textarea) { grid-template-columns: 1fr; }
    .patients-form-grid { grid-template-columns: minmax(0, 1fr); }
    .patients-card-grid, .patients-card-grid:has(.icon-button) { grid-template-columns: minmax(0, 1fr); }
    .row > [class*="col-"] { width: 100%; }

    .role-matrix { grid-template-columns: minmax(0, 1fr); }
    .role-list { position: static; flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
    .role-list-item { flex: 0 0 auto; }
    .permission-grid { grid-template-columns: minmax(0, 1fr); }

    /* Tables scroll sideways inside their card instead of widening the page. */
    .admin-table-wrap, .table-responsive { overflow-x: auto; max-width: 100%; }
    .admin-table, .table { min-width: 560px; }
    .admin-table th, .admin-table td { padding: 9px 10px; }
}

/* Safari on iPhone zooms into any field with text smaller than 16px and does not zoom back. */
@media (max-width: 860px) and (hover: none) {
    input, select, textarea,
    .form-control, .form-select, .patients-search, .patients-filter { font-size: 16px !important; }
}

@media (max-width: 420px) {
    .kpi-grid { grid-template-columns: minmax(0, 1fr); }
    .kpi-card { grid-template-columns: auto 1fr; }
}

/* Icons (Glyph component): the MDL2 font on Windows, drawn SVG elsewhere. */
.glyph { display: inline-flex; align-items: center; justify-content: center; width: 1.15em; height: 1.15em; line-height: 1; vertical-align: -0.15em; }
.glyph-font {
    font-family: "Segoe Fluent Icons", "Segoe MDL2 Assets", sans-serif;
    font-style: normal; font-weight: normal; line-height: 1;
}
.glyph-svg { display: none; width: 1.15em; height: 1.15em; }
html.no-mdl2 .glyph-font { display: none; }
html.no-mdl2 .glyph-svg { display: block; }
.icon-button .glyph { font-size: 16px; }
.kpi-icon .glyph, .analytics-kpi-icon .glyph, .empty-state-icon .glyph { font-size: inherit; }

.patients-tabs button, .patients-tabs a, .nav-tabs .nav-link { white-space: nowrap; flex: 0 0 auto; }
@media (max-width: 860px) {
    /* Rows of action buttons only (patient card): two per row instead of a long single column. */
    .patients-toolbar:not(:has(input, select, textarea)),
    .patients-actions:not(td) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .patients-toolbar:not(:has(input, select, textarea)) > *,
    .patients-actions:not(td) > * { width: 100%; white-space: normal; text-align: center; min-height: 38px; height: auto; }
}
