/*
 * EnterpriseControl portal — "Tally" design system.
 * Navy ink on cool paper, a single typeface (Archivo; its width axis does the display work),
 * and broadcast tally-lamp colours used only for live/recording state.
 * Keep the tokens in sync with Theme/EcTheme.cs.
 */
:root {
    --ec-ink: #13213A;
    --ec-ink-2: #1D2E4D;
    --ec-slate: #5A6A80;
    --ec-paper: #F4F6F8;
    --ec-surface: #FFFFFF;
    --ec-rule: #D9DEE5;
    --ec-rule-soft: #EAEEF2;
    --ec-green: #0E8A5F;
    --ec-red: #D7263D;
    --ec-focus: #2B5CB8;

    --ec-radius-panel: 10px;
    --ec-radius-control: 6px;
    --ec-measure: 72ch;
}

html, body {
    font-family: "Archivo", "Segoe UI", system-ui, sans-serif;
    font-variation-settings: "wdth" 100;
    font-feature-settings: "tnum" 1;
    background: var(--ec-paper);
    color: var(--ec-ink);
    margin: 0;
    overflow-x: clip;
    max-width: 100vw;
    -webkit-font-smoothing: antialiased;
}

:focus-visible {
    outline: 2px solid var(--ec-focus);
    outline-offset: 2px;
}

.ec-shell {
    min-height: 100vh;
    background: var(--ec-paper);
    overflow-x: clip;
    max-width: 100vw;
}

/* ---------- Tally lamp: the one memorable element ---------- */
.ec-tally {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ec-slate);
    white-space: nowrap;
}
.ec-tally-lamp {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex: 0 0 auto;
    background: #B8C1CC;
    box-shadow: inset 0 -1px 1px rgba(0, 0, 0, 0.18);
}
.ec-tally-on { color: var(--ec-green); }
.ec-tally-on .ec-tally-lamp {
    background: var(--ec-green);
    box-shadow: 0 0 0 3px rgba(14, 138, 95, 0.16), 0 0 8px rgba(14, 138, 95, 0.55);
}
.ec-tally-view { color: var(--ec-focus); }
.ec-tally-view .ec-tally-lamp {
    background: var(--ec-focus);
    box-shadow: 0 0 0 3px rgba(43, 92, 184, 0.16), 0 0 8px rgba(43, 92, 184, 0.5);
}
.ec-tally-rec { color: var(--ec-red); }
.ec-tally-rec .ec-tally-lamp {
    background: var(--ec-red);
    box-shadow: 0 0 0 3px rgba(215, 38, 61, 0.18), 0 0 10px rgba(215, 38, 61, 0.65);
    animation: ec-rec 1.4s ease-in-out infinite;
}
@keyframes ec-rec { 50% { opacity: 0.45; } }

/* ---------- Sidebar ---------- */
.ec-drawer {
    background: var(--ec-ink) !important;
    color: #fff !important;
    border: none !important;
}
.ec-drawer .mud-drawer-content {
    display: flex !important;
    flex-direction: column;
    height: 100%;
    padding: 0 !important;
    overflow: hidden !important;
}
.ec-nav {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}
.ec-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 1.35rem 1.25rem 1.5rem;
    color: #fff;
    text-decoration: none;
    font-variation-settings: "wdth" 118;
    font-weight: 700;
    font-size: 1.05rem;
}
.ec-brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: var(--ec-ink-2);
    border: 1px solid rgba(255, 255, 255, 0.14);
    display: grid;
    place-items: center;
}
.ec-brand-mark .ec-tally-lamp {
    background: var(--ec-red);
    box-shadow: 0 0 8px rgba(215, 38, 61, 0.7);
}
.ec-nav-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 0 0.6rem 1rem;
}
.ec-nav-gap {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0.9rem 0.65rem;
}
.ec-nav-link {
    color: rgba(255, 255, 255, 0.78) !important;
    border-radius: var(--ec-radius-control) !important;
    margin: 0.1rem 0 !important;
    font-weight: 500 !important;
}
.ec-nav-link .mud-nav-link {
    padding: 0.55rem 0.75rem !important;
}
.ec-nav-link .mud-nav-link-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ec-nav-link .mud-nav-link:hover { background: rgba(255, 255, 255, 0.06) !important; }
.ec-nav-link .mud-nav-link.active {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #fff !important;
    box-shadow: inset 3px 0 0 #fff;
}
.ec-nav-link .mud-nav-link.active .mud-icon-root { color: #fff !important; }

/* ---------- Top bar ---------- */
.ec-topbar {
    background: var(--ec-paper) !important;
    color: var(--ec-ink) !important;
    border-bottom: 1px solid var(--ec-rule);
}
.ec-topbar-pill {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 0.25rem 0.6rem 0.25rem 0.25rem;
    cursor: pointer;
    font: inherit;
    color: inherit;
    text-align: left;
}
.ec-topbar-pill:hover { border-color: var(--ec-rule); background: var(--ec-surface); }
.ec-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--ec-ink);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.75rem;
}
.ec-user-meta span { display: block; line-height: 1.2; }
.ec-user-name { font-weight: 600; font-size: 0.875rem; }
.ec-user-role { font-size: 0.75rem; color: var(--ec-slate); }

/* ---------- Main + page frame ---------- */
.ec-main.mud-main-content {
    padding: calc(var(--mud-appbar-height) + 1.5rem) 2rem 2.5rem !important;
    background: var(--ec-paper);
    min-height: 100vh;
    width: auto !important;
    max-width: 100% !important;
}
.ec-page {
    max-width: 1240px;
}
.ec-page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.ec-page-header-text { min-width: 0; }
.ec-page-title {
    margin: 0;
    font-size: 1.75rem;
    line-height: 1.15;
    font-weight: 650;
    font-variation-settings: "wdth" 115;
    letter-spacing: -0.01em;
    color: var(--ec-ink);
}
.ec-page-subtitle {
    margin: 0.35rem 0 0;
    color: var(--ec-slate);
    max-width: var(--ec-measure);
}
.ec-page-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.ec-page-toolbar {
    margin-bottom: 1rem;
}
.ec-page-toolbar .mud-grid { margin: 0 !important; width: 100% !important; }

/* Panels: one surface style, border not shadow */
.ec-panel {
    background: var(--ec-surface);
    border: 1px solid var(--ec-rule);
    border-radius: var(--ec-radius-panel);
    padding: 1.1rem 1.25rem;
    max-width: 100%;
    min-width: 0;
}
.ec-page-panel { padding: 0; overflow: hidden; }
.ec-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.4rem;
}
.ec-panel-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 650;
    font-variation-settings: "wdth" 108;
}
.ec-panel-note { color: var(--ec-slate); margin: 0.5rem 0 0.25rem; max-width: 52ch; }
.ec-panel-fill { height: 100%; }

/* ---------- Dashboard hero: a sentence, not a stat grid ---------- */
.ec-hero { margin: 0.5rem 0 2rem; max-width: 900px; }
.ec-hero-line {
    margin: 0;
    font-size: clamp(1.9rem, 3.4vw, 2.75rem);
    line-height: 1.08;
    font-weight: 700;
    font-variation-settings: "wdth" 122;
    letter-spacing: -0.02em;
}
.ec-hero-sub {
    margin: 0.75rem 0 0;
    font-size: 1.05rem;
    color: var(--ec-slate);
    max-width: var(--ec-measure);
}
.ec-steps {
    margin: 1rem 0 1.5rem 1.2rem;
    padding: 0;
    line-height: 1.85;
    max-width: var(--ec-measure);
}
.ec-dash-grid {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    gap: 1.25rem;
    align-items: start;
}

/* ---------- Lists ---------- */
.ec-list-row {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.7rem 0.25rem;
    border-bottom: 1px solid var(--ec-rule-soft);
    color: inherit;
    text-decoration: none;
}
.ec-list-row:last-child { border-bottom: 0; }
.ec-list-row:hover .ec-person-name { text-decoration: underline; text-underline-offset: 3px; }
.ec-list-icon { color: var(--ec-slate) !important; }
.ec-list-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ec-list-main .ec-person-name,
.ec-list-main .ec-person-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ec-list-side { font-size: 0.85rem; color: var(--ec-slate); text-align: right; white-space: nowrap; }

/* ---------- Tables ---------- */
.ec-table { width: 100%; max-width: 100%; background: transparent !important; }
.ec-table .mud-table-container,
.ec-page-panel .mud-table-container { overflow-x: auto !important; max-width: 100%; }
.ec-page-panel .mud-table-root { height: auto !important; }
.ec-table .mud-table-head .mud-table-cell {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ec-slate);
    font-variation-settings: "wdth" 88;
    background: #F9FAFB;
    border-bottom: 1px solid var(--ec-rule);
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
}
.ec-table .mud-table-body .mud-table-cell {
    border-bottom: 1px solid var(--ec-rule-soft);
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    vertical-align: middle;
}
.ec-table .mud-table-body .mud-table-row:last-child .mud-table-cell { border-bottom: 0; }
.ec-table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--ec-rule);
}
.ec-search { max-width: 360px; flex: 1 1 240px; }
.ec-cell-wrap { white-space: normal !important; }
.ec-cell-clamp { max-width: 28ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ec-row-actions { display: flex; align-items: center; gap: 0.35rem; justify-content: flex-end; }
.ec-row-actions .mud-button-root, .ec-page-actions .mud-button-root, .ec-table .mud-button-root { white-space: nowrap; }

.ec-person { display: flex; align-items: center; gap: 0.7rem; }
.ec-person-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    background: var(--ec-rule-soft);
    color: var(--ec-ink);
    font-weight: 700;
    font-size: 0.75rem;
}
.ec-person-name { font-weight: 600; line-height: 1.3; }
.ec-person-sub { display: block; font-size: 0.8rem; color: var(--ec-slate); line-height: 1.4; }
.ec-muted { color: var(--ec-slate); font-size: 0.875rem; }

/* Live-updates indicator on Devices */
.ec-live {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ec-slate);
    margin-right: 0.5rem;
}
.ec-live.on { color: var(--ec-green); }
.ec-live.on .ec-tally-lamp {
    background: var(--ec-green);
    box-shadow: 0 0 0 3px rgba(14, 138, 95, 0.16);
}

/* ---------- Empty, loading ---------- */
.ec-empty {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
    padding: 2.25rem 1.5rem;
    max-width: 60ch;
}
.ec-empty-icon { color: var(--ec-slate) !important; font-size: 1.75rem !important; }
.ec-empty-title { font-weight: 650; font-size: 1.05rem; font-variation-settings: "wdth" 108; }
.ec-empty-message { color: var(--ec-slate); }
.ec-empty-actions { margin-top: 0.75rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }

.ec-skeleton { padding: 0.5rem 1rem; }
.ec-skeleton-row { display: flex; align-items: center; gap: 0.85rem; padding: 0.75rem 0; border-bottom: 1px solid var(--ec-rule-soft); }
.ec-skeleton-row:last-child { border-bottom: 0; }
.ec-skeleton-lines { flex: 1; display: flex; flex-direction: column; gap: 0.35rem; }

/* ---------- Device activity ---------- */
.ec-date-filters { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.ec-date-field { max-width: 220px; }

/* ---------- MudBlazor adjustments ---------- */
.mud-button-root { border-radius: var(--ec-radius-control) !important; }
.mud-button-filled.mud-button-filled-primary:hover { background: var(--ec-ink-2) !important; }
.mud-button-outlined { border-color: var(--ec-rule) !important; }
.mud-chip { border-radius: var(--ec-radius-control) !important; }
.mud-dialog { border-radius: var(--ec-radius-panel) !important; }
.mud-dialog .mud-dialog-title { font-variation-settings: "wdth" 110; }
.mud-snackbar { border-radius: var(--ec-radius-control) !important; font-weight: 500; }
.mud-alert { border-radius: var(--ec-radius-control) !important; }
.mud-input-outlined-border { border-radius: var(--ec-radius-control) !important; }

.mud-picker-dialog .mud-picker-calendar-container,
.mud-picker-dialog .mud-picker-calendar { width: 100%; min-width: 280px; overflow: visible !important; }
.mud-picker-calendar-header,
.mud-picker-calendar-header .mud-picker-calendar-header-day { overflow: visible !important; }
.mud-picker .mud-picker-calendar-day { width: 36px !important; height: 36px !important; margin: 0 !important; }
.mud-popover,
.mud-overlay,
.mud-dialog-container { overflow: visible !important; }

/* ---------- Sign-in ---------- */
.ec-auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background: var(--ec-ink);
}
.ec-auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--ec-surface);
    border-radius: var(--ec-radius-panel);
    padding: 2rem 2rem 2.25rem;
}
.ec-auth-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
    font-variation-settings: "wdth" 118;
    margin-bottom: 1.75rem;
}
.ec-auth-brand .ec-brand-mark { background: var(--ec-ink); }
.ec-auth-title {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 700;
    font-variation-settings: "wdth" 120;
    letter-spacing: -0.01em;
}
.ec-auth-sub { margin: 0.35rem 0 1.25rem; color: var(--ec-slate); }
.ec-auth-form { display: flex; flex-direction: column; gap: 0.35rem; }
.ec-auth-form label { font-size: 0.875rem; font-weight: 600; margin-top: 0.6rem; }
.ec-auth-form input {
    font: inherit;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--ec-rule);
    border-radius: var(--ec-radius-control);
    background: #fff;
    color: var(--ec-ink);
}
.ec-auth-form input:focus { outline: 2px solid var(--ec-focus); outline-offset: 0; border-color: transparent; }
.ec-auth-form button {
    margin-top: 1.4rem;
    padding: 0.75rem;
    border: 0;
    border-radius: var(--ec-radius-control);
    background: var(--ec-ink);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.ec-auth-form button:hover { background: var(--ec-ink-2); }
.ec-auth-error {
    background: #FDECEE;
    color: #A3192B;
    border-left: 3px solid var(--ec-red);
    border-radius: 4px;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

/* ---------- Connection-lost overlay (driven by js/portal.js) ---------- */
.ec-reconnect {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 12vh;
    background: rgba(19, 33, 58, 0.35);
}
.ec-reconnect.ec-reconnect-visible { display: flex; }
.ec-reconnect-card {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    background: var(--ec-surface);
    border: 1px solid var(--ec-rule);
    border-radius: var(--ec-radius-panel);
    padding: 1rem 1.25rem;
    max-width: 360px;
}
.ec-reconnect-title { font-weight: 650; }
.ec-reconnect-text { font-size: 0.9rem; color: var(--ec-slate); }
.ec-reconnect .ec-when-reconnecting,
.ec-reconnect .ec-when-reloading { display: none; }
.ec-reconnect[data-state="reconnecting"] .ec-when-reconnecting,
.ec-reconnect[data-state="reloading"] .ec-when-reloading { display: block; }
.ec-reconnect-spinner {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    flex: 0 0 auto;
    border: 3px solid var(--ec-rule);
    border-top-color: var(--ec-ink);
    animation: ec-spin 0.9s linear infinite;
}
@keyframes ec-spin { to { transform: rotate(360deg); } }

#blazor-error-ui { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .ec-dash-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
    .ec-main.mud-main-content {
        padding: calc(var(--mud-appbar-height) + 1rem) 1rem 1.5rem !important;
    }
    .ec-page-title { font-size: 1.45rem; }
    .ec-page-actions { width: 100%; }
    .ec-table-toolbar { padding: 0.75rem; }
    .ec-search { max-width: none; }
    .ec-cell-clamp { max-width: 18ch; }
}

@media (prefers-reduced-motion: reduce) {
    .ec-tally-rec .ec-tally-lamp,
    .ec-reconnect-spinner { animation: none; }
}
