/* Phase A shell + shared component styles. Views built in later phases
 * reuse these classes rather than inventing per-screen CSS. */

* { box-sizing: border-box; }

/* A component class that sets its own `display` (.btn, .badge, etc.)
 * otherwise beats the browser's default `[hidden] { display: none }` —
 * both are specificity (0,1,0), and the later author rule wins. Toggle
 * visibility everywhere in this app via `el.hidden`, never `style.display`
 * directly, and this rule guarantees `hidden` always actually hides. */
[hidden] { display: none !important; }

/* Visible-on-focus skip link — lets keyboard/screen-reader users jump
 * past the top nav (and, on a hub page like Reports/Telephony/Admin, a
 * second sub-nav) straight to the page's actual content instead of
 * tabbing through every nav link on every single page load. */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 2000;
    padding: 0.6rem 1rem;
    background: var(--color-primary);
    color: var(--color-primary-text);
    border-radius: 0 0 6px 0;
}

.skip-link:focus {
    left: 0;
}

/* Visually hidden but still announced by screen readers — for content
 * (like a table's accessible name) that would be redundant/cluttering to
 * show sighted users who already have the page's heading for context. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* A consistent, visible focus indicator for every interactive element —
 * relied on over each browser's own default outline, which varies in
 * visibility (spec: keyboard navigation must have a clear, visible focus
 * indicator). */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

body {
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

a { color: var(--color-primary); }

h1 { font-size: 1.4rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 0.75rem; }

.muted { color: var(--color-text-muted); }

/* Dashboard "● live" — the theme's success green (dark in light mode, bright in dark mode); .muted takes over while paused. */
.live-indicator.live-on { color: var(--color-success); font-weight: 600; }

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

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.6rem 1rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    flex-wrap: wrap;
}

.brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--color-primary);
}

.main-nav {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    flex: 1;
}

.main-nav a {
    padding: 0.4rem 0.7rem;
    border-radius: 6px;
    color: var(--color-text-muted);
    text-decoration: none;
    font-weight: 500;
}

.main-nav a:hover,
.main-nav a.active {
    background: var(--color-muted-bg);
    color: var(--color-text);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-left: auto;
}

.view {
    flex: 1;
    /* Full width, lined up with the top bar's 1rem side padding. */
    padding: 1.25rem 1rem;
    max-width: none;
    width: 100%;
    min-width: 0;
    margin: 0 auto;
}

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

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.9rem;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
}

.btn:hover { background: var(--color-muted-bg); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-primary-text);
}

.btn-primary:hover { background: var(--color-primary-hover); }

.btn-danger { color: var(--color-danger); border-color: var(--color-danger); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 0.25rem 0.55rem; font-size: 0.8rem; }

.icon-btn {
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover { background: var(--color-muted-bg); }

/* ---- Forms ---- */

.app-form { max-width: 480px; }

.form-field { margin-bottom: 0.9rem; display: flex; flex-direction: column; gap: 0.3rem; }
.form-field label { font-weight: 600; font-size: 0.85rem; }

.form-field input,
.form-field select,
.form-field textarea {
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.9rem;
    font-family: inherit;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 1px;
}

.form-field-checkbox { flex-direction: row; align-items: center; }
.form-field-checkbox input { width: auto; }

.form-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }
.form-hint { font-size: 0.8rem; color: var(--color-text-muted); margin-top: -0.15rem; }

/* ---- Tables ---- */

.table-wrapper { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

.data-table th {
    background: var(--color-muted-bg);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-muted);
}

.data-table.compact th,
.data-table.compact td { padding: 0.4rem 0.55rem; font-size: 0.85rem; }
.data-table.compact th { font-size: 0.72rem; }

/* Row action buttons stay on one line instead of wrapping the row taller. */
.row-actions { display: flex; gap: 0.25rem; align-items: center; flex-wrap: nowrap; }

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--color-muted-bg); }

/* Column show/hide control above every table (see components/table.js). */
.table-tools { display: flex; justify-content: flex-end; margin-bottom: 0.4rem; }
.col-control { position: relative; }
.col-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 0.25rem);
    z-index: 30;
    min-width: 13rem;
    max-height: 60vh;
    overflow-y: auto;
    padding: 0.5rem 0.75rem;
    background: var(--color-surface-raised);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: var(--shadow-elevated);
}
.col-menu-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.2rem 0; font-size: 0.85rem; white-space: nowrap; cursor: pointer; }
.col-menu-item input:disabled { cursor: not-allowed; }
.col-menu-reset { margin-top: 0.4rem; width: 100%; }

.table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.pagination { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.75rem; }

/* ---- Badges ---- */

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-danger { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-info { background: var(--color-info-bg); color: var(--color-info); }
.badge-muted { background: var(--color-muted-bg); color: var(--color-text-muted); }

/* ---- Cards / dashboard ---- */

.stat-cards { display: flex; gap: 1rem; flex-wrap: wrap; }

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 1rem 1.5rem;
    min-width: 160px;
    box-shadow: var(--shadow-elevated);
}

.stat-card-body { display: flex; align-items: center; gap: 0.9rem; }
.stat-icon { width: 1.7rem; height: 1.7rem; flex-shrink: 0; color: var(--color-text-muted); }
.stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-label { color: var(--color-text-muted); font-size: 0.85rem; margin-top: 0.2rem; }
.stat-value-success { color: var(--color-success); }
.stat-value-danger { color: var(--color-danger); }
.stat-value-warning { color: var(--color-warning); }
.trunk-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0 1rem; }
.trunk-chip { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.3rem 0.6rem; border: 1px solid var(--color-border, #e4e7ec); border-radius: 999px; font-size: 0.85rem; }
.stat-value-muted { color: var(--color-text-muted); }

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

/* ---- Login page ---- */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    padding: 1rem;
}

.login-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 2rem;
    width: 100%;
    max-width: 340px;
    box-shadow: var(--shadow-elevated);
}

.login-card h1 { text-align: center; color: var(--color-primary); }

/* ---- Toasts ---- */

.toast-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 1000;
    max-width: calc(100vw - 2rem);
}

.toast {
    background: var(--color-surface-raised);
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-info);
    border-radius: 8px;
    padding: 0.65rem 1rem;
    box-shadow: var(--shadow-elevated);
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast-visible { opacity: 1; transform: translateY(0); }
.toast-danger { border-left-color: var(--color-danger); }
.toast-success { border-left-color: var(--color-success); }
.toast-warning { border-left-color: var(--color-warning); }

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

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 900;
    padding: 1rem;
}

.modal {
    background: var(--color-surface);
    border-radius: 10px;
    padding: 1.25rem;
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-elevated);
}

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }

/* ---- Responsive ---- */

@media (max-width: 640px) {
    .view { padding: 0.85rem; }
}

/* ---- Active Calls board ---- */

.call-board { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); }

.call-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-border);
    border-radius: 10px;
    padding: 0.85rem 1rem;
    box-shadow: var(--shadow-elevated);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    min-width: 0;
}
.call-card.state-success { border-left-color: var(--color-success); }
.call-card.state-warning { border-left-color: var(--color-warning); }
.call-card.state-info { border-left-color: var(--color-info); }

.call-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem; }
.call-card-who { min-width: 0; }
.call-card-number { font-size: 1.05rem; font-weight: 700; display: flex; align-items: center; gap: 0.4rem; overflow-wrap: anywhere; }
.call-card-direction { font-size: 0.7rem; font-weight: 600; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.call-card-client { color: var(--color-text-muted); font-size: 0.85rem; margin-top: 0.1rem; overflow-wrap: anywhere; }
.call-card-state { display: flex; flex-direction: column; align-items: flex-end; gap: 0.25rem; flex-shrink: 0; }
.call-card-timer { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 0.95rem; }

.call-card-people { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.person-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.8rem;
    background: var(--color-muted-bg);
    color: var(--color-text);
}
.person-chip::before { content: ""; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--color-text-muted); }
.person-chip.state-talking::before { background: var(--color-success); }
.person-chip.state-ringing::before { background: var(--color-info); }
.person-chip.state-on-hold::before { background: var(--color-warning); }
.person-chip-role { color: var(--color-text-muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; }

.call-card-meta { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; font-size: 0.8rem; color: var(--color-text-muted); }

.call-card-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; border-top: 1px solid var(--color-border); padding-top: 0.6rem; }
.call-card-actions .push-right { margin-left: auto; }

/* ---- Filter panels (Call Search) ---- */

.filter-panel .app-form {
    max-width: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr));
    gap: 0.25rem 0.9rem;
    align-items: end;
}
.filter-panel .form-field { margin-bottom: 0.5rem; min-width: 0; }
.filter-panel .form-field input,
.filter-panel .form-field select { width: 100%; box-sizing: border-box; }
.filter-panel .form-field.is-advanced { display: none; }
.filter-panel.show-advanced .form-field.is-advanced { display: flex; }
.filter-panel .form-actions { grid-column: 1 / -1; margin-top: 0.25rem; flex-wrap: wrap; align-items: center; }
.filter-panel .form-actions .push-right { margin-left: auto; }

.filter-presets { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin-bottom: 0.75rem; }
.filter-presets-label { font-size: 0.8rem; color: var(--color-text-muted); margin-right: 0.15rem; }
.chip-btn {
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    border-radius: 999px;
    padding: 0.2rem 0.7rem;
    font-size: 0.8rem;
    cursor: pointer;
    font-family: inherit;
}
.chip-btn:hover { background: var(--color-muted-bg); }
.chip-btn.is-active { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-primary-text); }

/* ---- Role-wise dashboard widgets (views/dashboard-widgets.js) ---- */
.dash-widgets { display: flex; flex-direction: column; gap: 1.25rem; margin-top: 1rem; }
.dash-widget { margin-bottom: 0; }
.dash-widget .table-toolbar { margin-bottom: 0.75rem; gap: 0.5rem; flex-wrap: wrap; }
.dash-tiles { gap: 0.75rem; margin-bottom: 0.75rem; }
/* Tiles stretch to fill each row, so a full-width page has no empty strip on the right. */
.dash-tiles .stat-card { padding: 0.65rem 1rem; min-width: 120px; flex: 1 1 150px; box-shadow: none; }
.dash-tiles .stat-value { font-size: 1.35rem; }
.dash-split { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.dash-facts { display: flex; flex-wrap: wrap; gap: 0.75rem 2rem; margin: 0; }
.dash-facts dt { color: var(--color-text-muted); font-size: 0.8rem; }
.dash-facts dd { margin: 0.15rem 0 0; font-weight: 600; }
.dash-alerts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.dash-alerts li { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }

/* ---- Dashboard editor (views/admin/dashboards.js) ---- */
.dash-editor { display: grid; grid-template-columns: minmax(220px, 280px) 1fr; gap: 1rem; align-items: start; }
.dash-editor-scopes button { display: flex; justify-content: space-between; width: 100%; text-align: left; margin-bottom: 0.35rem; }
.dash-editor-scopes button.is-active { border-color: var(--color-primary); color: var(--color-primary); }
.dash-editor-list { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.dash-editor-list li { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.75rem; border: 1px solid var(--color-border); border-radius: 8px; background: var(--color-surface); }
.dash-editor-list li .grow { flex: 1; min-width: 0; }
.dash-editor-list li small { display: block; color: var(--color-text-muted); }
@media (max-width: 760px) { .dash-editor { grid-template-columns: 1fr; } }
.agent-controls { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 0.85rem; }
.agent-warning { margin: 0.75rem 0 0; padding: 0.6rem 0.8rem; border-radius: 8px; background: var(--color-danger-bg); color: var(--color-danger); font-weight: 600; }

/* ---- Sidebar navigation ---- */

.topbar { position: sticky; top: 0; z-index: 30; flex-wrap: nowrap; }
.nav-toggle { display: none; font-size: 1.15rem; }
.shell-body { flex: 1; display: flex; min-height: 0; }

.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 49px;
    height: calc(100vh - 49px);
    overflow-y: auto;
    transition: width 0.15s ease;
}
.side-nav { flex: 1; padding: 0.6rem 0.5rem; display: flex; flex-direction: column; gap: 0.1rem; }

.side-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.6rem;
    border-radius: 6px;
    color: var(--color-text-muted);
    text-decoration: none;
    font-weight: 500;
    white-space: nowrap;
}
.side-link:hover { background: var(--color-muted-bg); color: var(--color-text); }
.side-link.active { background: var(--color-muted-bg); color: var(--color-primary); }
.side-icon { width: 18px; height: 18px; flex-shrink: 0; }
.side-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }

.side-caret {
    border: 0;
    background: none;
    color: inherit;
    cursor: pointer;
    padding: 0 0.2rem;
    font-size: 0.8rem;
    transition: transform 0.15s ease;
}
.side-group.open .side-caret { transform: rotate(90deg); }

.side-sub { display: none; flex-direction: column; margin: 0.1rem 0 0.3rem 1.55rem; border-left: 1px solid var(--color-border); }
.side-group.open .side-sub { display: flex; }
.side-sub a {
    padding: 0.28rem 0.7rem;
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 0.88rem;
    white-space: nowrap;
    border-radius: 0 6px 6px 0;
}
.side-sub a:hover { color: var(--color-text); background: var(--color-muted-bg); }
.side-sub a.active { color: var(--color-primary); font-weight: 600; }

.side-collapse {
    border: 0;
    border-top: 1px solid var(--color-border);
    background: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0.5rem;
    font-size: 1rem;
    text-align: right;
}
.side-collapse:hover { color: var(--color-text); }

/* Collapsed: icons only; hovering an icon shows its name (title). */
.nav-collapsed .sidebar { width: 56px; }
.nav-collapsed .side-label,
.nav-collapsed .side-caret,
.nav-collapsed .side-sub { display: none !important; }
.nav-collapsed .side-link { justify-content: center; padding: 0.5rem; }
.nav-collapsed .side-collapse { transform: scaleX(-1); text-align: left; }

.nav-backdrop { display: none; }

/* The sidebar lists each hub's pages, so the tab row at the top of the page isn't needed on wide screens. */
@media (min-width: 901px) {
    .hub-tabs { display: none !important; }
}

/* Narrow screens: the sidebar slides in from the ☰ button. */
@media (max-width: 900px) {
    .nav-toggle { display: inline-flex; }
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        z-index: 50;
        width: 240px;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }
    .nav-open .sidebar { transform: none; }
    .nav-open .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 40; }
    .side-collapse { display: none; }
    .nav-collapsed .sidebar { width: 240px; }
    .nav-collapsed .side-label, .nav-collapsed .side-caret { display: inline !important; }
    .nav-collapsed .side-group.open .side-sub { display: flex !important; }
    .nav-collapsed .side-link { justify-content: flex-start; padding: 0.45rem 0.6rem; }
}

/* Signed out (login page): no sidebar. */
.no-user .sidebar, .no-user .nav-toggle, .no-user .topbar-clock { display: none !important; }

/* Rows that open on click (renderTable onRowClick). */
.data-table tr.row-clickable { cursor: pointer; }
.data-table tr.row-clickable:hover td { background: var(--color-muted-bg); }
.inline-select { padding: 0.15rem 0.3rem; font-size: 0.85rem; width: auto; max-width: 11rem; }

/* ---- Top-bar status chip ---- */
.status-slot { position: relative; }
.has-status-chip #hotdesk-btn { display: none !important; }
.status-chip {
    display: inline-flex; align-items: center; gap: 0.45rem;
    border: 1px solid var(--color-border); border-radius: 999px;
    padding: 0.25rem 0.7rem; font: inherit; font-size: 0.85rem; font-weight: 600;
    cursor: pointer; white-space: nowrap; background: var(--color-muted-bg); color: var(--color-text);
}
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.status-caret { font-size: 0.7rem; opacity: 0.7; }
.status-success { background: var(--color-success-bg); color: var(--color-success); border-color: transparent; }
.status-warning { background: var(--color-warning-bg); color: var(--color-warning); border-color: transparent; }
.status-danger { background: var(--color-danger-bg); color: var(--color-danger); border-color: transparent; }
.status-info { background: var(--color-info-bg); color: var(--color-info); border-color: transparent; }
.status-muted { color: var(--color-text-muted); }
.status-menu {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 250px;
    background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15); padding: 0.7rem;
}
.status-menu-head { padding-bottom: 0.55rem; margin-bottom: 0.55rem; border-bottom: 1px solid var(--color-border); font-size: 0.85rem; }
.status-bad { color: var(--color-danger); }
.status-menu-actions { display: flex; flex-direction: column; gap: 0.4rem; }
.status-menu-actions .btn { width: 100%; justify-content: center; }
.status-row { display: flex; gap: 0.4rem; }
.status-row select { flex: 1; }
.status-row .btn { width: auto; }
.status-input { width: 100%; }
@media (max-width: 640px) {
    .status-text, .status-caret { display: none; }
    .status-chip { padding: 0.4rem; }
}
.topbar-clock { font-variant-numeric: tabular-nums; color: var(--color-text-muted); font-size: 0.85rem; white-space: nowrap; }
@media (max-width: 640px) { .topbar-clock { display: none; } }
.stat-sub { color: var(--color-text-muted); font-size: 0.75rem; margin-top: 0.1rem; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- Settings → System status ---- */
.status-banner { border-radius: 8px; padding: 0.7rem 1rem; margin: 0.75rem 0 1rem; font-weight: 600; }
.status-banner ul { margin: 0.3rem 0 0 1.2rem; font-weight: 400; }
.status-banner-ok { background: var(--color-success-bg); color: var(--color-success); }
.status-banner-bad { background: var(--color-danger-bg); color: var(--color-danger); }
.status-grid { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); margin-bottom: 1rem; }
.status-card { margin: 0; }
.status-card-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.status-dl { display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 0.75rem; margin: 0 0 0.4rem; font-size: 0.85rem; }
.status-dl dt { color: var(--color-text-muted); }
.status-dl dd { margin: 0; overflow-wrap: anywhere; }

/* ---- Phones and narrow screens ---- */
/* Name + Log out live in the sidebar footer on narrow screens (hidden on desktop). */
.side-user { display: none; }
@media (max-width: 900px) {
    /* One compact top-bar row: ☰  CCRM ........ [status] [Ext] ☀ */
    .topbar { flex-wrap: nowrap; padding: 0.5rem 0.75rem; gap: 0.5rem; }
    .topbar-actions { flex-wrap: nowrap; gap: 0.4rem; min-width: 0; }
    #current-user, #logout-btn { display: none !important; }
    #hotdesk-btn { white-space: nowrap; }
    .side-user {
        display: flex; flex-direction: column; gap: 0.4rem;
        padding: 0.7rem; border-top: 1px solid var(--color-border); font-size: 0.85rem;
    }
    .side-user-name { color: var(--color-text-muted); overflow-wrap: anywhere; }
    .side-user .btn { align-self: flex-start; }
}
@media (max-width: 640px) {
    /* Dashboard tiles two per row, full width. */
    .stat-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
    .stat-cards .stat-card { min-width: 0; padding: 0.65rem 0.75rem; }
    .stat-card-body { gap: 0.55rem; }
    .stat-value { font-size: 1.25rem; }
    .stat-label, .stat-sub { white-space: normal; }
    .table-toolbar { flex-wrap: wrap; gap: 0.5rem; }
}
