/* ==========================================================================
   LUMI 流明 — Design System v1.0 (Direction A: Warm Professional)
   Replaces facility.css. Keep facility.css as fallback.

   Palette:
     Primary   #C8802A  warm amber
     Surface   #FAFAF8  warm off-white page bg
     Sidebar   #1C1410  deep warm dark
   ========================================================================== */

/* ── DESIGN TOKENS ─────────────────────────────────────────────────────── */
:root {
    /* Brand — clean indigo-blue, trusted by Chinese professional apps */
    --brand:            #4F6EF7;
    --brand-hover:      #3B58E8;
    --brand-light:      #EEF2FF;
    --brand-border:     #C7D2FE;

    /* Surfaces — pure and clean, no warmth bias */
    --bg-layout:        #F4F5F7;
    --bg-card:          #FFFFFF;
    --bg-subtle:        #F9FAFB;
    --bg-input:         #FFFFFF;

    /* Text */
    --text:             #111827;
    --text-muted:       #6B7280;
    --text-faint:       #9CA3AF;

    /* Borders */
    --border:           #E5E7EB;
    --border-light:     #F3F4F6;
    --border-dark:      #D1D5DB;

    /* Semantic */
    --ok:               #059669;  --ok-bg:    #ECFDF5;  --ok-bd:    #A7F3D0;
    --warn:             #D97706;  --warn-bg:  #FFFBEB;  --warn-bd:  #FDE68A;
    --danger:           #DC2626;  --danger-bg:#FEF2F2;  --danger-bd:#FECACA;
    --info:             #2563EB;  --info-bg:  #EFF6FF;  --info-bd:  #BFDBFE;

    /* Semantic aliases — used in JS template strings */
    --bg-success:       #ECFDF5;  --text-success:  #059669;  --border-success:  #A7F3D0;
    --bg-warning:       #FFFBEB;  --text-warning:  #D97706;  --border-warning:  #FDE68A;
    --bg-danger:        #FEF2F2;  --text-danger:   #DC2626;  --border-danger:   #FECACA;
    --bg-accent:        #EEF2FF;  --text-accent:   #4F6EF7;  --border-accent:   #C7D2FE;
    --fill-accent:      #4F6EF7;  --on-accent:     #FFFFFF;
    --surface-0:        #F4F5F7;
    --surface-1:        #F9FAFB;
    --surface-2:        #FFFFFF;

    /* Forgiving aliases — intuitive names that map to the canonical tokens
       above. Added so future code using natural names (--text-primary,
       --success, etc.) resolves correctly instead of silently failing.
       Always keep in sync with the canonical value they alias. */
    --text-primary:     #111827;  /* = --text */
    --text-secondary:   #6B7280;  /* = --text-muted */
    --success:          #059669;  /* = --ok */
    --success-bg:       #ECFDF5;  /* = --ok-bg */
    --border-strong:    #D1D5DB;  /* = --border-dark */
    --radius:           10px;     /* = --radius-md */
    --surface:          #FFFFFF;  /* = --surface-2 */

    /* Sidebar — deep navy, professional and calm */
    --sidebar-bg:       #0F172A;
    --sidebar-text:     rgba(148, 163, 184, 0.90);
    --sidebar-text-active: #F1F5F9;
    --sidebar-active-bg:   rgba(79, 110, 247, 0.15);
    --sidebar-hover-bg:    rgba(255, 255, 255, 0.06);

    /* Layout */
    --sidebar-w:        228px;
    --header-h:         58px;

    /* Radius */
    --radius-sm:        6px;
    --radius-md:        10px;
    --radius-lg:        14px;
    --radius-xl:        20px;
    --radius-full:      999px;

    /* Shadows */
    --shadow-sm:        0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:        0 4px 12px rgba(0,0,0,0.10), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg:        0 8px 24px rgba(0,0,0,0.12), 0 4px 8px rgba(0,0,0,0.04);
    --shadow-xl:        0 20px 60px rgba(0,0,0,0.18), 0 8px 16px rgba(0,0,0,0.06);
    --shadow-focus:     0 0 0 3px rgba(79,110,247,0.22);

    /* Motion */
    --motion-fast:      150ms ease;
    --motion-normal:    200ms ease;
    --motion-slow:      300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── RESET ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── UTILITY CLASSES ───────────────────────────────────────────────────────
   Extracted from repeated inline style="..." strings in facility.js.
   Only exact, byte-identical repeated patterns (3+ occurrences) were
   extracted — this is a conservative first pass, not a full audit.
   Add new utilities here rather than inlining a style string that already
   has an equivalent below. ────────────────────────────────────────────── */

/* Flex child that fills remaining space and can shrink below its content
   width (min-width:0 is required for text-overflow:ellipsis to work
   inside a flex item — without it flex items refuse to shrink). */
.u-flex-fill { flex: 1; min-width: 0; }

/* Error message block — used for network/fetch failure states. */
.u-error-block { color: var(--danger); padding: 20px; }

/* Empty state — centered muted message, large size. Used when a list or
   panel has no data to show and the panel itself is large. */
.u-empty-state { text-align: center; padding: 40px; color: var(--text-muted); }

/* Empty state — same idea, smaller padding for compact panels. */
.u-empty-state-sm { text-align: center; padding: 24px; color: var(--text-muted); font-size: 14px; }

/* Empty state — smallest variant, for inline/compact contexts. */
.u-empty-state-xs { text-align: center; padding: 20px 0; color: var(--text-muted); font-size: 13px; }

/* Secondary/muted small text — sub-labels, metadata lines. */
.u-text-sub { font-size: 12px; color: var(--text-muted); }

/* Secondary/muted text at the primary-text size — used for descriptive
   lines under a heading where 12px would read too small. */
.u-text-sub-md { font-size: 13px; color: var(--text-muted); }

/* Primary label text — section headers, field labels. */
.u-text-label { font-size: 14px; font-weight: 500; color: var(--text); }

/* Same as .u-text-label with bottom margin — used when another element
   follows directly below (e.g. a label above a value). */
.u-text-label-mb { font-size: 14px; font-weight: 500; color: var(--text); margin-bottom: 4px; }

/* Single-line text that truncates with an ellipsis instead of wrapping —
   used for names/titles in fixed-width rows and cards. Requires the
   parent to be a flex item with min-width:0 (see .u-flex-fill) or a
   block with a defined width for the ellipsis to actually trigger. */
.u-text-truncate { font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

body {
    font-family: system-ui, 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
    background: var(--bg-layout);
    color: var(--text);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    height: 100vh;
    overflow: hidden;
    display: flex;
}

/* ── SIDEBAR ────────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 10;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-header {
    height: var(--header-h);
    display: flex;
    align-items: center;
    padding: 0 20px;
    font-size: 17px;
    font-weight: 700;
    color: var(--sidebar-text-active);
    letter-spacing: 0.3px;
    white-space: nowrap;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
    /* Amber left accent line */
    border-left: 3px solid var(--brand);
}

.sidebar-menu {
    padding: 8px 0 16px;
    flex: 1;
}

.menu-section-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: rgba(245,237,216,0.35);
    padding: 16px 20px 5px;
    margin-top: 4px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 1px 10px;
    padding: 9px 14px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    transition: all var(--motion-normal);
    white-space: nowrap;
    color: var(--sidebar-text);
    border-left: 3px solid transparent;
}

.menu-item:hover {
    color: var(--sidebar-text-active);
    background: var(--sidebar-hover-bg);
}

.menu-item.active {
    background: var(--sidebar-active-bg);
    color: #F5D898;
    font-weight: 600;
    border-left-color: var(--brand);
}

.menu-item i {
    font-size: 16px;
    opacity: 0.75;
    flex-shrink: 0;
    transition: opacity var(--motion-fast);
}

.menu-item.active i,
.menu-item:hover i { opacity: 1; }

/* ── MAIN SHELL ─────────────────────────────────────────────────────────── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.top-header {
    height: var(--header-h);
    background: var(--bg-card);
    padding: 0 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.tenant-badge {
    background: var(--brand-light);
    color: var(--brand);
    border: 1px solid var(--brand-border);
    padding: 4px 14px;
    border-radius: var(--radius-full);
    font-size: 14px;
    font-weight: 600;
}

.workspace {
    flex: 1;
    padding: 28px 32px;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    min-height: 0;
}

/* body is overflow:hidden + display:flex (see above) — workspace handles its own scroll */

/* Panel transitions — slides up gently, not just appears */
.view-panel { display: none; }
.view-panel.active {
    display: block;
    animation: panel-in var(--motion-slow) both;
}

@keyframes panel-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0);   }
}

/* ── CARDS ──────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    margin-bottom: 20px;
    transition: box-shadow var(--motion-normal);
}

.card:hover { box-shadow: var(--shadow-md); }

/* Dashboard card — tighter padding, no hover lift, used for functional blocks */
.card-dash {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    border: 1px solid var(--border-light);
    margin-bottom: 12px;
}
.card-dash-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.card-dash-link {
    font-size: 13px;
    color: var(--brand);
    font-weight: 400;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text);
}

.section-header {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--brand);
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 8px;
    margin: 28px 0 18px;
}
.section-header:first-child { margin-top: 0; }

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 64px 0;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px dashed var(--border-dark);
    font-size: 15px;
}

/* ── GRID ───────────────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 24px; }

/* ── FORMS ──────────────────────────────────────────────────────────────── */
.input-group { margin-bottom: 20px; }

.input-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 9px 12px;
    font-size: 15px;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
}

input:focus, select:focus, textarea:focus {
    border-color: var(--brand);
    box-shadow: var(--shadow-focus);
    outline: none;
    background: #fff;
}

input::placeholder, textarea::placeholder {
    color: var(--text-faint);
}

textarea { min-height: 88px; resize: vertical; line-height: 1.6; }

/* ── SLIDERS ────────────────────────────────────────────────────────────── */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--brand);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform var(--motion-fast);
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }

.slider-group {
    margin-bottom: 18px;
    background: var(--bg-subtle);
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}
.slider-group .trait-label { font-weight: 600; text-align: center; margin-bottom: 10px; font-size: 14px; }
.slider-container { display: grid; grid-template-columns: 72px auto 72px; align-items: center; gap: 12px; }
.slider-container span { font-size: 13px; color: var(--text-muted); text-align: center; }

/* ── CHECKBOXES ─────────────────────────────────────────────────────────── */
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    font-size: 14px;
    transition: all var(--motion-fast);
}
.checkbox-item:hover { background: var(--brand-light); border-color: var(--brand-border); }
.checkbox-item input[type="checkbox"] {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    accent-color: var(--brand);
}

/* ── BUTTONS ────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 36px;
    padding: 0 18px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--motion-fast);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    letter-spacing: 0.01em;
}

/* Lift on hover, press on click */
.btn:hover  { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0) scale(0.98); box-shadow: none; }

.btn-primary {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
    box-shadow: 0 2px 8px rgba(79,110,247,0.30);
}
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-dark); background: var(--bg-subtle); }

.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger-bd);
}
.btn-danger:hover { background: var(--danger-bg); }

.btn.is-loading { pointer-events: none; opacity: 0.72; }

/* ── USER LIST TABLE ────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; }

th {
    background: var(--bg-subtle);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 10px 16px;
    text-align: left;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
    font-size: 15px;
    transition: background var(--motion-fast);
}

td.col-name   { white-space: nowrap; font-weight: 600; font-size: 15px; }
td.col-status { white-space: nowrap; }
td.col-ai     { white-space: nowrap; }

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--brand-light); }
tbody tr.row-suspended td { opacity: 0.5; }

/* ── TAGS & BADGES ──────────────────────────────────────────────────────── */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--bg-subtle);
    white-space: nowrap;
    margin: 2px 4px 2px 0;
    transition: all var(--motion-fast);
}
.tag.ok, .tag.success { background: var(--ok-bg);   border-color: var(--ok-bd);   color: var(--ok); }
.tag.warn             { background: var(--warn-bg);  border-color: var(--warn-bd); color: var(--warn); }
.tag.danger           { background: var(--danger-bg);border-color: var(--danger-bd);color: var(--danger); }
.tag.info             { background: var(--info-bg);  border-color: var(--info-bd); color: var(--info); }

.tag-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 500;
    margin: 2px 3px 2px 0;
    border: 1px solid var(--border);
    background: var(--bg-subtle);
    cursor: default;
    transition: all var(--motion-fast);
}
.tag-badge:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }

.pulse-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--warn);
    margin-right: 5px;
    animation: pulse 1.4s ease infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.5; transform: scale(0.8); }
}

/* ── DISPATCH / MATCH RESULTS ───────────────────────────────────────────── */
.report-block {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
    animation: card-in var(--motion-slow) both;
    transition: box-shadow var(--motion-normal), transform var(--motion-normal);
}
.report-block:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.report-block:nth-child(1) { animation-delay: 0s; }
.report-block:nth-child(2) { animation-delay: 0.07s; }
.report-block:nth-child(3) { animation-delay: 0.14s; }
.report-block:nth-child(4) { animation-delay: 0.21s; }
.report-block:nth-child(5) { animation-delay: 0.28s; }

@keyframes card-in {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.report-header {
    background: var(--bg-subtle);
    padding: 14px 24px;
    border-bottom: 1px solid var(--border-light);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    font-weight: 600;
    font-size: 15px;
    color: var(--text-muted);
}

.dispatch-row {
    display: grid;
    grid-template-columns: minmax(160px, 22%) minmax(200px, 30%) 1fr;
    gap: 28px;
    padding: 24px 28px;
    border-bottom: 1px solid var(--border-light);
    align-items: start;
}
.dispatch-row:last-child { border-bottom: none; }
.radar-container { width: 100%; height: clamp(160px, 20vw, 240px); position: relative; }

@media (max-width: 1100px) {
    .dispatch-row { grid-template-columns: 1fr 1fr; }
    .dispatch-row > .data-log { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
    .dispatch-row { grid-template-columns: 1fr; }
}

.data-log { font-size: 14px; line-height: 1.7; }
.data-log-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.log-item { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.log-icon.check { color: var(--ok); flex-shrink: 0; }
.log-icon.warn  { color: var(--danger); flex-shrink: 0; }

.badge-row { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.qual-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    border: 1px solid;
    width: fit-content;
}
.qual-badge.safe { background: var(--ok-bg);   color: var(--ok);   border-color: var(--ok-bd); }
.qual-badge.attn { background: var(--warn-bg);  color: var(--warn); border-color: var(--warn-bd); }

/* ── PROFILE PANEL (slide-in from right) ────────────────────────────────── */
#profile-panel-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(26,22,18,0.40);
    z-index: 100;
    backdrop-filter: blur(2px);
    animation: overlay-in var(--motion-slow) both;
}
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }

#profile-panel {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 580px;
    max-width: 92vw;
    background: var(--bg-card);
    z-index: 101;
    box-shadow: var(--shadow-xl);
    overflow-y: auto;
    animation: panel-slide-in var(--motion-slow) cubic-bezier(0.4, 0, 0.2, 1) both;
    border-left: 1px solid var(--border);
}
@keyframes panel-slide-in {
    from { transform: translateX(100%); opacity: 0.8; }
    to   { transform: translateX(0);   opacity: 1; }
}

#profile-panel-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 1;
}

#profile-panel-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

#profile-panel-content { padding: 24px; }

/* ── FOLLOWUP BADGE ─────────────────────────────────────────────────────── */
.followup-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-full);
    background: var(--warn-bg);
    border: 1px solid var(--warn-bd);
    color: var(--warn);
    cursor: pointer;
    transition: all var(--motion-fast);
}
.followup-badge:hover { background: var(--warn-bd); }

/* ── HEALTH DASHBOARD ───────────────────────────────────────────────────── */
.health-kpi {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--motion-normal), transform var(--motion-normal);
}
.health-kpi:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.health-kpi-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.health-kpi-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
    line-height: 1.1;
}
.health-kpi-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ── LOGIN SCREEN ───────────────────────────────────────────────────────── */
#login-view {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100vh;
    background: var(--bg-layout);
}

.login-card {
    width: 400px;
    max-width: 94vw;
    padding: 40px;
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    /* Amber top accent */
    border-top: 3px solid var(--brand);
}

.login-card h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}

.subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 28px;
}

/* ── CONVERSATIONAL ONBOARDING ──────────────────────────────────────────── */
.conv-bubble {
    position: relative;
    background: var(--bg-subtle);
    border: 1px solid var(--border-light);
    border-radius: 0 var(--radius-lg) var(--radius-lg) var(--radius-lg);
    padding: 14px 18px;
    font-size: 15px;
    line-height: 1.7;
    color: var(--text);
    margin-bottom: 16px;
    animation: bubble-in var(--motion-slow) both;
}
@keyframes bubble-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.conv-input-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    margin-top: 12px;
}

/* ── FLEET / SCHEDULE ───────────────────────────────────────────────────── */
.fleet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.fleet-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    transition: all var(--motion-normal);
    cursor: pointer;
}
.fleet-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--brand-border);
}

/* ── ONBOARDING STEP INDICATOR ─────────────────────────────────────────── */
.onboard-steps {
    display: flex;
    align-items: center;
    margin-bottom: 28px;
    padding: 18px 24px;
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
}

.onboard-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.step-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--motion-slow);
}

.step-label {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    font-weight: 500;
    transition: color var(--motion-slow);
}

.step-connector {
    flex: 1;
    height: 2px;
    background: var(--border-light);
    margin: 0 8px;
    margin-bottom: 18px;
    transition: background var(--motion-slow);
}

.onboard-step.active .step-circle {
    border-color: var(--brand);
    background: var(--brand);
    color: #fff;
    box-shadow: 0 0 0 3px rgba(79,110,247,0.18);
}
.onboard-step.active .step-label { color: var(--brand); font-weight: 600; }
.onboard-step.done .step-circle {
    border-color: var(--ok);
    background: var(--ok);
    color: #fff;
    font-size: 0;
}
.onboard-step.done .step-circle::after { content: '✓'; font-size: 15px; }
.onboard-step.done .step-label { color: var(--ok); }
.step-connector.done { background: var(--ok); }

/* ── PERSONALITY ASSESSMENT ─────────────────────────────────────────────── */
.pa-question-text {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text);
    border-left: 3px solid var(--brand);
    padding-left: 14px;
    margin-bottom: 14px;
}
.pa-alt-btn-row { margin-bottom: 14px; }
.pa-alt-btn {
    font-size: 13px;
    color: var(--text-muted);
    background: none;
    border: 1px dashed var(--border);
    border-radius: var(--radius-full);
    padding: 3px 12px;
    cursor: pointer;
    transition: all var(--motion-fast);
}
.pa-alt-btn:hover { color: var(--brand); border-color: var(--brand-border); background: var(--brand-light); }

.pa-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all var(--motion-fast);
    background: var(--bg-card);
    width: 100%;
    text-align: left;
    font-family: inherit;
}
.pa-option:hover { border-color: var(--brand-border); background: var(--brand-light); }
.pa-option.selected { border-color: var(--brand); background: var(--brand-light); }
.pa-option.selected .pa-letter {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}
.pa-letter {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
    color: var(--text-muted);
    background: var(--bg-subtle);
    transition: all var(--motion-fast);
}
.pa-option-text { font-size: 15px; line-height: 1.6; color: var(--text); padding-top: 2px; }
.pa-nav-row { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.pa-prev-btn { color: var(--text-muted); }
.pa-next-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.pa-complete-block {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--ok-bg);
    border: 1px solid var(--ok-bd);
    border-radius: var(--radius-md);
    color: var(--ok);
    font-size: 15px;
    font-weight: 500;
}
.pa-complete-block i { font-size: 20px; }

/* ── STAGE BLOCKS ────────────────────────────────────────────────────────── */
.stage-block { position: relative; margin-bottom: 24px; transition: opacity var(--motion-slow); }
.stage-block.locked { opacity: 0.4; pointer-events: none; user-select: none; }
.stage-block.locked .section-header { color: var(--text-muted); }
.stage-lock-overlay { display: none; }
.stage-block.locked .stage-lock-overlay {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 8px;
}
.stage-block.active { opacity: 1; pointer-events: all; }
.stage-next-btn { margin-top: 16px; width: 100%; height: 40px; }

/* ── PROFILE SUMMARY ────────────────────────────────────────────────────── */
.profile-summary-panel {
    margin-top: 24px;
    border: 1.5px solid var(--ok-bd);
    border-radius: var(--radius-lg);
    background: var(--ok-bg);
    overflow: hidden;
    animation: bubble-in var(--motion-slow) both;
}
.ps-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: var(--ok);
    gap: 12px;
}
.ps-ready-badge { display: flex; align-items: center; gap: 8px; color: #fff; font-size: 15px; font-weight: 600; }
.ps-ready-badge i { font-size: 18px; }
.ps-name { font-size: 16px; font-weight: 700; color: #fff; opacity: 0.9; }
.ps-body { display: grid; grid-template-columns: 240px 1fr; gap: 20px; padding: 20px; }
.ps-section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 10px; }
.ps-tags-section { min-width: 0; }
.ps-pending-msg { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-muted); font-style: italic; }
.ps-bio { font-size: 14px; line-height: 1.8; color: var(--text); background: var(--bg-card); border-radius: var(--radius-sm); padding: 12px 14px; border: 1px solid var(--border-light); max-height: 120px; overflow-y: auto; }

/* ── SKELETON LOADING ───────────────────────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, var(--border-light) 25%, var(--bg-subtle) 50%, var(--border-light) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.6s infinite;
    border-radius: var(--radius-sm);
}
@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── CONV PLACEHOLDER ───────────────────────────────────────────────────── */
.conv-placeholder {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px;
    color: var(--text-muted);
    font-size: 14px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px dashed var(--border);
}
.conv-placeholder i { font-size: 16px; flex-shrink: 0; }
.conv-placeholder strong { color: var(--brand); }

/* ── SCROLLBAR (webkit) ─────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ── DISPATCH HUB TABS ─────────────────────────────────────────────────── */
.hub-tab {
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--motion-fast);
    white-space: nowrap;
    font-family: inherit;
}
.hub-tab:hover { color: var(--text); }
.hub-tab.active {
    color: var(--brand);
    border-bottom-color: var(--brand);
    font-weight: 600;
}

/* ── PEOPLE CARD GRID ───────────────────────────────────────────────────── */
.people-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 14px;
    cursor: pointer;
    transition: all var(--motion-fast);
    position: relative;
}
.people-card:hover {
    border-color: var(--brand-border);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.people-card-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.people-card-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.people-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.people-card-status {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-weight: 500;
}
.people-card-ai {
    font-size: 12px;
    color: var(--text-faint);
}
.people-card.suspended { opacity: 0.5; }
/* ── HOME KPI ────────────────────────────────────────────────────────────── */
.home-kpi {
    background: var(--bg-subtle);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    transition: border-color var(--motion-fast);
}
.home-kpi:hover { border-color: var(--border-dark); }
.home-kpi-label {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.home-kpi-val {
    font-size: 24px;
    font-weight: 500;
    color: var(--text);
    line-height: 1.1;
}
/* ── FORM LAYOUT SYSTEM ──────────────────────────────────────────────────
   Feishu-inspired grouping + Apple-quality visual discipline.
   Use these classes instead of inline styles for all form layouts.

   Pattern:
     .form-section        — a named group of related fields
     .form-row            — horizontal arrangement of fields
     .f-field             — individual field wrapper (label + control)
     .f-fill              — field grows to fill remaining space
     .f-unit              — unit label sitting inline beside a number input
   Width modifiers (applied to .f-field):
     .f-w-xs   72px   day / short number
     .f-w-sm   96px   month / year / short code
     .f-w-md   148px  gender / role / status dropdowns
     .f-w-lg   220px  city / common selects
     .f-w-num  72px   numeric input with text-align center
   ──────────────────────────────────────────────────────────────────────── */

.form-section {
    margin-bottom: 24px;
}

.form-section-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    padding-bottom: 8px;
    margin-bottom: 14px;
    border-bottom: 1.5px solid var(--brand);
    display: block;
}

.form-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.f-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.f-field label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
    display: block;
}

/* Width modifiers — apply to .f-field */
.f-fill           { flex: 1; min-width: 120px; }
.f-fill input,
.f-fill select    { width: 100%; }

.f-w-xs           { flex-shrink: 0; }
.f-w-xs input,
.f-w-xs select    { width: 72px; }

.f-w-sm           { flex-shrink: 0; }
.f-w-sm input,
.f-w-sm select    { width: 96px; }

.f-w-md           { flex-shrink: 0; }
.f-w-md input,
.f-w-md select    { width: 148px; }

.f-w-lg           { flex-shrink: 0; }
.f-w-lg input,
.f-w-lg select    { width: 220px; }

/* Numeric input — centred text, no width override from global rule */
.f-w-num input {
    width: 80px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* Inline unit label (cm, kg, 年) */
.f-unit {
    font-size: 14px;
    color: var(--text-muted);
    padding-bottom: 9px;
    flex-shrink: 0;
    user-select: none;
}

/* DOB inline row — year · month · day without re-labelling every sub-select */
.f-dob-row {
    display: flex;
    align-items: flex-end;
    gap: 4px;
}
.f-dob-row select { flex-shrink: 0; }
.f-dob-row .f-unit { padding-bottom: 9px; }

/* Stacked select pair — province then city */
.f-select-stack {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.f-select-stack select { width: 100%; }

/* Form max-width container — keeps forms from stretching on wide screens */
.form-body {
    max-width: 580px;
}

/* ── LUMI LOADER ANIMATIONS ──────────────────────────────────────────────── */

/* 7-bar waveform — bars scale and fade in a wave pattern */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes lumi-wave {
    0%   { transform: scaleY(0.25); opacity: 0.35; }
    40%  { transform: scaleY(1);    opacity: 1; }
    80%  { transform: scaleY(0.45); opacity: 0.55; }
    100% { transform: scaleY(0.25); opacity: 0.35; }
}

/* Active step dot pulse */
@keyframes lumi-dot-pulse {
    0%, 100% { transform: scale(1);   opacity: 1; }
    50%       { transform: scale(1.7); opacity: 0.7; }
}

/* Legacy — kept for any remaining references */
@keyframes lumi-pulse {
    0%, 100% { opacity: 0.25; transform: scaleY(0.55); }
    50%       { opacity: 1;    transform: scaleY(1); }
}

/* ── LIST ROW CONSTRAINT ─────────────────────────────────────────────────
   Prevents flex rows from stretching across the full viewport width.
   Apply .list-rows to any container that holds data rows.          */
.list-rows { max-width: 640px; }
.list-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 0.5px solid var(--border);
    min-width: 0;
}
.list-row:last-child { border-bottom: none; }
.list-row-name {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── TOAST NOTIFICATION ──────────────────────────────────────────────────── */
@keyframes toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── VOICE (ASR/TTS) — push-to-talk mic + question play button ─────────────
   Note: the surrounding .conversation-input-row/.conv-question classes have
   no CSS defined anywhere in the codebase — pre-existing gap, out of scope
   here. These two rules only style the new voice controls added alongside
   them, not a redesign of the conversation UI as a whole. */
.btn-mic {
    width: 40px; height: 40px; flex-shrink: 0;
    border-radius: 50%; border: 0.5px solid var(--border);
    background: var(--surface-2); font-size: 16px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s, border-color 0.15s;
}
.btn-mic:hover { border-color: var(--border-accent); }
.btn-mic.recording {
    background: var(--bg-danger); border-color: var(--border-danger);
    animation: mic-pulse 1.2s ease-in-out infinite;
}
.btn-mic.loading { opacity: 0.5; cursor: wait; }
@keyframes mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.4); }
    50%      { box-shadow: 0 0 0 6px rgba(220,38,38,0); }
}

.btn-tts-play {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; flex-shrink: 0; margin-left: 8px;
    border-radius: 50%; border: 0.5px solid var(--border);
    background: var(--surface-2); font-size: 13px; cursor: pointer;
    vertical-align: middle;
}
.btn-tts-play:hover { border-color: var(--border-accent); }
.btn-tts-play.loading { opacity: 0.5; cursor: wait; }
/* ── CONVERSATIONAL ONBOARDING — question/answer bubbles + thinking indicator ──
   Fills the pre-existing styling gap noted above: .conv-question, .conv-answer,
   .conv-ack, .conv-complete, .conv-thinking, .conversation-log, and
   .conversation-input-row had no rules anywhere, so turns rendered as an
   unbroken wall of plain text and the "AI is thinking" dots were invisible. */
.conversation-log {
    display: flex; flex-direction: column; gap: 14px;
    max-height: 420px; overflow-y: auto;
    padding: 16px; margin-bottom: 12px;
    background: var(--bg-subtle); border: 0.5px solid var(--border);
    border-radius: var(--radius-lg);
}
.conv-question, .conv-answer, .conv-ack, .conv-complete {
    max-width: 78%; padding: 10px 14px; font-size: 14px; line-height: 1.6;
    border-radius: var(--radius-lg); word-wrap: break-word;
    animation: conv-in 0.25s ease;
}
@keyframes conv-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}
/* AI question — left-aligned, neutral card */
.conv-question {
    align-self: flex-start;
    background: var(--surface-2); border: 0.5px solid var(--border);
    border-bottom-left-radius: 4px;
    display: flex; align-items: flex-start; gap: 8px;
    color: var(--text);
}
/* Coordinator's typed/spoken answer — right-aligned, brand accent */
.conv-answer {
    align-self: flex-end;
    background: var(--brand); color: #FFFFFF;
    border-bottom-right-radius: 4px;
}
/* AI's brief acknowledgment / transition line — left-aligned, quieter than a full question */
.conv-ack {
    align-self: flex-start;
    background: transparent; border: none;
    color: var(--text-muted); font-size: 13px; font-style: italic;
    padding-left: 4px; max-width: 90%;
}
/* Final closing message when the conversation completes */
.conv-complete {
    align-self: center; max-width: 90%; text-align: center;
    background: var(--bg-accent); border: 0.5px solid var(--border-accent);
    color: var(--text-accent); font-weight: 600;
}

/* "AI is thinking" — three pulsing dots, shown while waiting for the next question */
.conv-thinking {
    align-self: flex-start;
    display: flex; align-items: center; gap: 5px;
    padding: 12px 16px;
    background: var(--surface-2); border: 0.5px solid var(--border);
    border-radius: var(--radius-lg); border-bottom-left-radius: 4px;
}
.conv-thinking span {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--text-faint);
    animation: conv-dot-bounce 1.2s infinite ease-in-out;
}
.conv-thinking span:nth-child(2) { animation-delay: 0.15s; }
.conv-thinking span:nth-child(3) { animation-delay: 0.3s; }
@keyframes conv-dot-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30%           { transform: translateY(-4px); opacity: 1; }
}

.conversation-input-row {
    display: flex; align-items: flex-end; gap: 8px;
}
.conversation-input-row textarea {
    flex: 1; resize: none; font-family: inherit; font-size: 14px;
    padding: 10px 12px; border: 0.5px solid var(--border);
    border-radius: var(--radius-md); background: var(--bg-input);
    color: var(--text);
}
.conversation-input-row textarea:focus {
    outline: none; border-color: var(--border-accent);
    box-shadow: var(--shadow-focus);
}

/* Mic button restyled as a single clean on/off toggle (still click-to-start /
   click-to-stop per message underneath — visual only, no behavior change) */
.btn-mic {
    color: var(--text-muted); font-size: 17px;
}
.btn-mic.recording {
    color: #FFFFFF;
}