/* ==========================================================================
   VROOM Sandbox — Yunex Traffic Branded UI
   Consumes tokens from yunex-design-system.css
   ========================================================================== */

/* ==========================================================================
   1. Layout Architecture (Nav Rail + Main Content)
   ========================================================================== */

.app-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ─── Navigation Rail (flat black — authority surface) ─── */
.nav-rail {
    width: 80px;
    flex-shrink: 0;
    background-color: var(--yx-black);
    border-right: 1px solid rgba(255,255,255,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-5) 0;
    z-index: 50;
}

.nav-brand {
    margin-bottom: var(--space-7);
    padding: 0 8px;
}

.nav-brand img {
    width: 48px;
    height: auto;
    display: block;
}

.nav-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    width: 100%;
    padding: 0 var(--space-2);
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.45);
    height: 64px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--dur-base) var(--ease-out);
    gap: 4px;
}

.nav-btn:hover {
    color: var(--yx-white);
    background: rgba(255,255,255,0.08);
}

.nav-btn.active {
    color: var(--yx-white);
    background: rgba(30, 46, 217, 0.2);
    box-shadow: inset 3px 0 0 var(--yx-royal-blue);
}

.nav-icon {
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.nav-label {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.nav-version {
    font-family: var(--font-body);
    font-size: 10px;
    color: rgba(255,255,255,0.25);
}

/* ─── Main Content ─── */
.main-content {
    flex: 1;
    position: relative;
    overflow: hidden;
    background-color: var(--app-bg);
}

.app-view {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur-base) var(--ease-out);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

.app-view.active {
    opacity: 1;
    pointer-events: auto;
}

/* Glass Panel for Map Overlays */
.glass-panel {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: var(--shadow-lg);
}

/* ==========================================================================
   2. View Containers & Bento Grids
   ========================================================================== */

.view-container {
    max-width: 1800px;
    margin: 0 auto;
    padding: var(--space-7) var(--space-6);
    width: 100%;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: var(--space-6);
}

.view-title {
    font-family: var(--font-display);
    font-size: var(--fs-h3);
    font-weight: 700;
    letter-spacing: var(--tracking-tight);
    margin-bottom: var(--space-1);
    color: var(--app-fg);
}

.view-subtitle {
    font-size: var(--fs-small);
    color: var(--app-fg-muted);
}

.bento-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
    gap: var(--space-5);
}

/* ─── Data Cards (Engineers & Jobs) ─── */
.data-card {
    background: var(--app-card);
    border: 1px solid var(--app-border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    transition: box-shadow var(--dur-base) var(--ease-out);
    cursor: pointer;
}

.data-card:hover {
    box-shadow: var(--shadow-md);
}

.data-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
}

.data-card-title {
    font-family: var(--font-display);
    font-size: var(--fs-body);
    font-weight: 700;
}

.data-card-meta {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    font-size: 13px;
    color: var(--app-fg-muted);
}

.data-tag {
    display: inline-block;
    background: var(--app-bg-muted);
    color: var(--app-fg);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 500;
}

/* ==========================================================================
   3. Map & Floating UI
   ========================================================================== */

#map {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.glass-panel {
    background: rgba(222, 236, 255, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--app-border);
    box-shadow: var(--shadow-lg);
}

.results-summary {
    position: absolute;
    top: var(--space-4);
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-pill);
    background: rgba(239, 246, 255, 0.85); /* Exaggerated minimal background */
    border: none;
    box-shadow: var(--shadow-lg);
    width: max-content;
    max-width: 95vw;
}

.result-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-family: var(--font-display);
    font-size: clamp(0.9rem, 1.1vw, 1.4rem);
    font-weight: 900;
    letter-spacing: var(--tracking-tight);
    color: var(--color-primary);
}

.stat-label {
    font-size: 10px;
    color: var(--app-fg-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
}

@media (max-width: 768px) {
    .results-summary {
        flex-wrap: wrap;
        border-radius: var(--radius-md);
        gap: 4px 8px;
        padding: 6px 10px;
        top: 8px;
    }
    .stat-value {
        font-size: 0.8rem;
    }
    .stat-label {
        font-size: 8px;
    }
    .summary-select {
        font-size: 9px;
        padding: 2px 14px 2px 6px;
        background-size: 5px auto;
        min-width: auto;
    }
}

.fab-primary {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: var(--color-cta);
    color: var(--yx-white);
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-pill);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-xl);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all var(--dur-fast) var(--ease-out);
    white-space: nowrap;
}

.fab-primary:hover {
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 15px 25px rgba(249, 115, 22, 0.3);
    opacity: 0.95;
}

.fab-chat {
    position: absolute;
    bottom: var(--space-6);
    right: var(--space-6);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--yx-black);
    border: none;
    color: var(--yx-white);
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    transition: background var(--dur-fast) var(--ease-out);
}

.fab-chat:hover {
    background: var(--yx-royal-blue);
}

/* ==========================================================================
   4. Forms & Inputs
   ========================================================================== */

.form-group {
    margin-bottom: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}

.form-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--app-fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.form-input {
    width: 100%;
    background: var(--yx-white);
    border: 1px solid var(--app-border-strong);
    color: var(--app-fg);
    padding: 12px 14px;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: var(--fs-small);
    transition: border-color var(--dur-fast) var(--ease-out),
                box-shadow var(--dur-fast) var(--ease-out);
}

.form-input:focus {
    outline: none;
    border-color: var(--yx-royal-blue);
    box-shadow: var(--shadow-glow);
}

.form-input::placeholder {
    color: #9aa3a8;
}

.summary-select {
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    background: var(--yx-white);
    color: var(--app-fg);
    border: 1px solid var(--app-border-strong);
    border-radius: var(--radius-md);
    padding: 6px 24px 6px 10px;
    cursor: pointer;
    min-width: 120px;
    max-width: 200px;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23000000%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 8px top 50%;
    background-size: 8px auto;
}

.summary-select:focus {
    outline: none;
    border-color: var(--yx-royal-blue);
    box-shadow: var(--shadow-glow);
}

.form-hint {
    font-size: var(--fs-micro);
    color: var(--app-fg-soft);
}

.divider {
    border: none;
    border-top: 1px solid var(--app-border);
    margin: var(--space-5) 0;
}

/* File input */
.file-input {
    padding: 6px 12px;
    cursor: pointer;
}

.file-input::file-selector-button {
    background: var(--yx-white);
    color: var(--app-fg);
    border: 1px solid var(--app-border-strong);
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    font-family: var(--font-body);
    font-weight: 600;
    font-size: var(--fs-micro);
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-out);
    margin-right: 12px;
}

.file-input::file-selector-button:hover {
    background: var(--yx-black);
    color: var(--yx-white);
    border-color: var(--yx-black);
}

/* ==========================================================================
   5. Buttons
   ========================================================================== */

.btn-primary {
    background: var(--color-cta);
    color: var(--yx-white);
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-weight: 600;
    font-size: var(--fs-small);
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-out);
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-outline {
    background: var(--yx-white);
    color: var(--yx-black);
    border: 1px solid var(--yx-black);
    padding: 11px 20px;
    border-radius: var(--radius-pill);
    font-family: var(--font-body);
    font-weight: 600;
    font-size: var(--fs-small);
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-out);
}

.btn-outline:hover {
    background: var(--yx-black);
    color: var(--yx-white);
}

.btn-outline-sm {
    background: var(--yx-white);
    color: var(--app-fg-muted);
    border: 1px solid var(--app-border);
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    font-size: var(--fs-micro);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-out);
}

.btn-outline-sm:hover {
    border-color: var(--app-border-strong);
    color: var(--app-fg);
}

.btn-success {
    background: var(--app-success);
    color: var(--yx-black);
    border: none;
    padding: 11px 20px;
    border-radius: var(--radius-pill);
    font-family: var(--font-body);
    font-weight: 600;
    font-size: var(--fs-small);
    cursor: pointer;
    transition: opacity var(--dur-fast) var(--ease-out);
}

.btn-success:hover {
    opacity: 0.85;
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--app-fg-soft);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    transition: color var(--dur-fast) var(--ease-out);
}

.btn-close:hover {
    color: var(--app-fg);
}

.btn-close-sm {
    background: transparent;
    border: none;
    color: var(--app-fg-soft);
    font-size: 14px;
    cursor: pointer;
    padding: 2px;
    transition: color var(--dur-fast) var(--ease-out);
}

.btn-close-sm:hover {
    color: var(--app-danger);
}

/* ==========================================================================
   6. Modals
   ========================================================================== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(239, 246, 255, 0.6); /* --color-background with opacity */
    backdrop-filter: blur(8px);
    z-index: var(--z-modal-base); /* stack depth applied via modal.js */
    display: flex;
    align-items: stretch;
    justify-content: flex-end; /* Align to right for drawer effect */
    opacity: 0;
    animation: fadeIn var(--dur-base) var(--ease-out) forwards;
}

.modal-dialog {
    background: var(--yx-white);
    border-left: 1px solid var(--app-border);
    width: 90%;
    max-width: 600px;
    box-shadow: -10px 0 25px rgba(0,0,0,0.1);
    transform: translateX(100%);
    animation: slideInRight var(--dur-slow) var(--ease-out) forwards;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1600px; }

.modal-header {
    padding: var(--space-5);
    border-bottom: 1px solid var(--app-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2, .modal-header h3 {
    font-family: var(--font-display);
    font-size: var(--fs-h4);
    font-weight: 700;
    letter-spacing: var(--tracking-tight);
    margin: 0;
}

.modal-body {
    padding: var(--space-5);
    overflow-y: auto;
}

.modal-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--app-border);
    display: flex;
    align-items: center;
    background: var(--yx-white);
}

@keyframes fadeIn { to { opacity: 1; } }
@keyframes slideInRight { to { transform: translateX(0); } }

/* Settings Tabs */
.settings-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--app-fg-soft);
    cursor: pointer;
    font-family: var(--font-body);
    transition: color 0.2s, border-color 0.2s;
}
.settings-tab:hover { color: var(--app-fg); }
.settings-tab.active {
    color: var(--yx-amber);
    border-bottom-color: var(--yx-amber);
}

/* ==========================================================================
   7. Specialized Components
   ========================================================================== */

/* Preflight Config */
.preflight-grid {
    display: flex;
    gap: var(--space-5);
}

/* Rota Matrix Styles */
.rota-matrix-container {
    overflow-x: auto;
}

.rota-global-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--app-bg-subtle);
    border: 1px solid var(--app-border);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
}

.rota-global-row label {
    font-size: 12px;
    font-weight: 600;
    color: var(--app-fg-muted);
    white-space: nowrap;
}

.rota-global-row .rota-time-input {
    width: 80px;
}

.rota-global-row .btn-outline-sm {
    margin-left: auto;
}

.rota-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.rota-table thead th {
    padding: 8px 6px;
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 700;
    color: var(--app-fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: center;
    border-bottom: 2px solid var(--app-border);
    white-space: nowrap;
}

.rota-table thead th:first-child,
.rota-table thead th:nth-child(2) {
    text-align: left;
}

.rota-table tbody tr {
    transition: background var(--dur-fast) var(--ease-out);
}

.rota-table tbody tr:hover {
    background: rgba(30, 46, 217, 0.03);
}

.rota-table tbody td {
    padding: 10px 6px;
    border-bottom: 1px solid var(--app-border);
    vertical-align: middle;
}

.rota-eng-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--app-fg);
    white-space: nowrap;
}

.rota-route-select {
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    padding: 6px 10px;
    background: var(--app-bg-subtle);
    color: var(--app-fg);
    border: 1px solid var(--app-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    min-width: 90px;
}

.rota-day-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 72px;
}

.rota-day-cell input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--yx-royal-blue);
}

.rota-time-input {
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    padding: 6px 8px;
    width: 90px;
    background: var(--app-bg-subtle);
    color: var(--app-fg);
    border: 1px solid var(--app-border);
    border-radius: var(--radius-sm);
    text-align: center;
    transition: border-color var(--dur-fast) var(--ease-out);
}

.rota-time-input:focus {
    outline: none;
    border-color: var(--yx-royal-blue);
    box-shadow: 0 0 0 2px rgba(30, 46, 217, 0.12);
}

.rota-time-pair {
    display: flex;
    flex-direction: column;
    gap: 3px;
    align-items: center;
}

.rota-time-pair .rota-time-label {
    font-size: 9px;
    font-weight: 600;
    color: var(--app-fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.preflight-col {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.strategy-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

/* Strategy Option Overhaul for Minimalism */
.strategy-option {
    display: flex;
    align-items: center;
    padding: var(--space-4);
    border: 2px solid var(--app-border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-out);
    position: relative;
    background: var(--yx-white);
}

.strategy-option:hover {
    border-color: var(--app-border-strong);
}

.strategy-option.active {
    border-color: var(--yx-royal-blue);
    background: rgba(30, 46, 217, 0.06);
}

.strategy-info h4 {
    font-family: var(--font-display);
    font-size: var(--fs-small);
    font-weight: 700;
    margin: 0;
}
.strategy-info p {
    font-size: var(--fs-micro);
    color: var(--app-fg-soft);
    margin: 0;
}

.strategy-tag {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: var(--radius-pill);
    margin-left: auto;
}

.tag-free {
    background: var(--app-bg-muted);
    color: var(--app-fg-muted);
}

.tag-premium {
    background: var(--yx-royal-blue);
    color: var(--yx-white);
}

/* Cost Guide */
.cost-guide {
    background: var(--app-bg-subtle);
    border: 1px solid var(--app-border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin-top: var(--space-3);
}

.cost-guide-title {
    font-size: var(--fs-small);
    font-weight: 600;
    margin-bottom: var(--space-3);
    display: flex;
    align-items: center;
    gap: 8px;
}

.cost-guide-grid {
    display: flex;
    gap: var(--space-6);
}

.cost-metric {
    text-align: center;
}

.metric-value {
    font-family: var(--font-display);
    font-size: var(--fs-h4);
    font-weight: 700;
}

.metric-value.cost {
    color: var(--yx-royal-blue);
}

.metric-label {
    font-size: var(--fs-micro);
    color: var(--app-fg-soft);
    margin-top: 2px;
}

/* Rota Matrix */
.rota-matrix-container {
    border: 1px solid var(--app-border);
    border-radius: var(--radius-md);
    overflow-x: auto;
    overflow-y: auto;
    max-height: 400px;
}

.rota-row {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid var(--app-border);
    background: var(--yx-white);
}

.rota-row:last-child { border-bottom: none; }

.rota-name {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
}

.rota-time-inputs {
    display: flex;
    gap: 8px;
    align-items: center;
}

.rota-time-inputs input[type="time"] {
    background: var(--app-bg-subtle);
    border: 1px solid var(--app-border);
    color: var(--app-fg);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
}

/* History Layout */
.history-layout {
    display: flex;
    gap: var(--space-6);
    height: calc(100vh - 200px);
    min-height: 400px;
}

.history-list-container {
    flex: 1;
    border: 1px solid var(--app-border);
    border-radius: var(--radius-lg);
    background: var(--yx-white);
    overflow-y: auto;
}

.history-details-container {
    flex: 2;
    border-radius: var(--radius-lg);
    padding: var(--space-5);
}

.history-item {
    padding: var(--space-4);
    border-bottom: 1px solid var(--app-border);
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease-out);
}

.history-item:hover {
    background: var(--app-bg-subtle);
}

.status-text {
    font-size: 13px;
    color: var(--yx-orange);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Download Grid */
.download-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
}

.download-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--app-bg-subtle);
    border: 1px solid var(--app-border);
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    color: var(--app-fg);
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-out);
}

.download-btn:hover {
    border-color: var(--yx-royal-blue);
    color: var(--yx-royal-blue);
}

.dl-icon { font-size: 16px; }

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-7);
    color: var(--app-fg-soft);
    text-align: center;
}

.empty-icon {
    font-size: 48px;
    margin-bottom: var(--space-4);
    opacity: 0.3;
}

/* Map Controls for Light Mode */
.leaflet-container {
    background: #f2f2f2 !important;
}

.map-monochrome,
.map-monochrome .leaflet-tile,
img.map-monochrome {
    filter: grayscale(100%) !important;
    -webkit-filter: grayscale(100%) !important;
}

/* ==========================================================================
   AI Chat Panel
   ========================================================================== */

.chat-slide-panel {
    position: absolute;
    bottom: 96px;
    right: var(--space-6);
    width: 380px;
    max-width: calc(100vw - var(--space-6) * 2 - 80px); /* Avoid overlapping nav */
    height: 520px;
    max-height: calc(100vh - 120px);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
    background: var(--yx-white);
    border: 1px solid var(--app-border);
    box-shadow: var(--shadow-lg);
    animation: slideUp var(--dur-slow) var(--ease-out);
}

.chat-header {
    display: flex;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--app-border);
    background: var(--yx-black);
    color: var(--yx-white);
    font-weight: 600;
    font-size: var(--fs-small);
}

.chat-header-icon {
    margin-right: 8px;
    font-size: 18px;
}

.chat-header .btn-close-sm {
    margin-left: auto;
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    font-size: 16px;
    cursor: pointer;
    transition: color var(--dur-fast);
}

.chat-header .btn-close-sm:hover {
    color: var(--yx-white);
}

.chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--app-bg-subtle);
}

.chat-bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.4;
    word-wrap: break-word;
    animation: popIn 0.3s var(--ease-out);
}

.chat-bubble.bot {
    align-self: flex-start;
    background: var(--yx-white);
    border: 1px solid var(--app-border);
    color: var(--app-fg);
    border-bottom-left-radius: 4px;
}

.chat-bubble.user {
    align-self: flex-end;
    background: var(--yx-royal-blue);
    color: var(--yx-white);
    border-bottom-right-radius: 4px;
}

.typing-indicator {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    padding: 4px 8px;
}

.typing-dot {
    width: 4px;
    height: 4px;
    background: var(--app-fg-soft);
    border-radius: 50%;
    animation: typingBounce 1s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

@keyframes popIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--app-fg-soft);
    padding: 24px;
}

.chat-empty-icon {
    font-size: 36px;
    margin-bottom: 12px;
    opacity: 0.4;
    width: 56px;
    height: 56px;
    background: var(--app-bg-muted);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-empty p {
    font-size: 13px;
    margin-bottom: 24px;
}

.chat-quick-prompts {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.chat-quick-btn {
    background: var(--yx-white);
    border: 1px solid var(--app-border);
    color: var(--app-fg-muted);
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-out);
    text-align: left;
    display: flex;
    align-items: center;
}

.chat-quick-btn:hover {
    border-color: var(--yx-royal-blue);
    color: var(--yx-royal-blue);
}

.chat-input-bar {
    display: flex;
    padding: 12px;
    background: var(--yx-white);
    border-top: 1px solid var(--app-border);
    gap: 8px;
}

.chat-input {
    flex: 1;
    background: var(--app-bg-subtle);
    border: 1px solid var(--app-border);
    color: var(--app-fg);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 13px;
    outline: none;
    transition: border-color var(--dur-fast) var(--ease-out);
}

.chat-input:focus {
    border-color: var(--yx-royal-blue);
    box-shadow: var(--shadow-glow);
}

.chat-send-btn {
    background: var(--yx-black);
    color: var(--yx-white);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-pill);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: background var(--dur-fast) var(--ease-out);
}

.chat-send-btn:hover {
    background: var(--yx-royal-blue);
}

/* ==========================================================================
   AI Review Modal
   ========================================================================== */

.ai-review-body {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-4);
    max-height: 60vh;
}

.ai-review-meta {
    font-size: var(--fs-micro);
    color: var(--app-fg-soft);
}

/* ==========================================================================
   Scrollbar
   ========================================================================== */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--app-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--app-fg-soft); }

/* ==========================================================================
   Activity Overlay (Engineer Breakdown)
   ========================================================================== */

.activity-overlay {
    position: absolute;
    top: 80px;
    right: var(--space-4);
    width: 320px;
    max-height: calc(100vh - 100px);
    background: rgba(222, 236, 255, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--app-border);
    border-radius: var(--radius-xl);
    display: flex;
    flex-direction: column;
    z-index: 999;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.activity-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4);
    border-bottom: 1px solid var(--app-border);
}

.activity-header h4 {
    margin: 0;
    font-size: var(--fs-small);
    font-weight: 600;
    color: var(--app-fg);
}



.activity-log {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Roster rows (All Engineers mode) */
.roster-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 10px 12px;
    border-bottom: 1px solid var(--app-border);
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease-out);
    border-radius: var(--radius-md);
    margin-bottom: 2px;
}

.roster-row:last-child { border-bottom: none; }

.roster-row:hover {
    background: rgba(37, 99, 235, 0.08);
}

.roster-row .roster-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.roster-row .roster-name {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: var(--app-fg);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.roster-row .roster-stats {
    display: flex;
    gap: var(--space-3);
    font-size: 11px;
    color: var(--app-fg-muted);
    flex-shrink: 0;
}

.roster-row .roster-stat-val {
    font-weight: 700;
    color: var(--color-primary);
}

.roster-row.idle {
    opacity: 0.5;
}

.roster-row.highlighted {
    background: rgba(37, 99, 235, 0.12);
    box-shadow: inset 3px 0 0 var(--color-primary);
}

/* Global Breakdown Dashboard */
.dashboard-stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.dashboard-stat-card {
    background: var(--surface-bg);
    border: 1px solid var(--app-border);
    border-radius: var(--radius-md);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dashboard-stat-card h4 {
    font-size: 11px;
    color: var(--app-fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.dashboard-stat-card .val {
    font-size: 18px;
    font-weight: 700;
    color: var(--app-fg);
}

.dashboard-bar-chart {
    display: flex;
    height: 12px;
    border-radius: 6px;
    overflow: hidden;
    margin-top: 8px;
    background: var(--app-border);
}

.dashboard-bar-chart > div {
    height: 100%;
}

.dashboard-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.dashboard-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    padding: 8px;
    background: rgba(0,0,0,0.02);
    border-radius: var(--radius-sm);
    border: 1px solid var(--app-border);
}

.dashboard-list-item .name {
    font-weight: 600;
    color: var(--app-fg);
}

.dashboard-list-item .meta {
    color: var(--color-danger);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 4px;
}

.log-entry {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    position: relative;
    font-size: 13px;
}

.log-entry:not(:last-child)::before {
    content: '';
    position: absolute;
    left: 45px;
    top: 24px;
    bottom: -12px;
    width: 2px;
    background: var(--app-border);
    z-index: 0;
}

.log-time {
    font-variant-numeric: tabular-nums;
    color: var(--app-fg-muted);
    font-weight: 600;
    width: 36px;
    text-align: right;
    margin-top: 2px;
}

.log-icon {
    width: 20px;
    height: 20px;
    background: var(--surface-bg);
    border: 2px solid var(--app-border);
    border-radius: var(--radius-pill);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    font-size: 10px;
    margin-top: 2px;
}

.log-detail {
    flex: 1;
    background: var(--surface-bg);
    border: 1px solid var(--app-border);
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-3);
}

.log-desc {
    color: var(--app-fg);
    font-weight: 500;
    margin-bottom: 2px;
}

.log-meta {
    font-size: 11px;
    color: var(--app-fg-muted);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.traffic-badge {
    padding: 2px 6px;
    border-radius: var(--radius-pill);
    font-weight: 600;
    font-size: 10px;
}

.traffic-red { background: #ffebee; color: #d32f2f; }
.traffic-amber { background: #fff8e1; color: #ff8f00; }
.traffic-green { background: #e8f5e9; color: #2e7d32; }

/* ═══ Engineer Cards Modal ═══ */
.engineers-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-4);
    padding: var(--space-4);
}

.engineer-stat-card {
    background: var(--app-bg-subtle);
    border: 1px solid var(--app-border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.engineer-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-color);
}

.engineer-stat-card.idle {
    opacity: 0.7;
    background: var(--surface-bg);
}

.eng-card-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    border-bottom: 1px solid var(--app-border);
    padding-bottom: var(--space-3);
}

.eng-card-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 16px;
}

.eng-card-title {
    font-weight: 700;
    font-size: 16px;
    color: var(--app-fg);
}

.eng-card-subtitle {
    font-size: 12px;
    color: var(--app-fg-muted);
}

.eng-card-body {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.eng-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.eng-stat-label {
    color: var(--app-fg-muted);
    font-weight: 500;
}

.eng-stat-val {
    color: var(--app-fg);
    font-weight: 600;
}

.eng-stat-val.highlight {
    color: var(--primary-color);
}

/* ==========================================================================
   Responsive Adjustments (Laptops, Tablets, Ultrawides)
   ========================================================================== */

/* Ultrawides & Large Desktop */
@media (min-width: 1600px) {
    .bento-grid {
        grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    }
    
    .data-card {
        padding: var(--space-6);
    }
}

/* Laptops & Large Tablets */
@media (max-width: 1200px) {
    .view-container {
        padding: var(--space-5);
    }
    
    .chat-slide-panel {
        height: 480px;
        width: 340px;
    }
}

/* Standard Tablets & Small Laptops */
@media (max-width: 1024px) {
    .view-container {
        padding: var(--space-5) var(--space-4);
    }
    
    .history-layout {
        flex-direction: column;
        height: auto;
        min-height: auto;
    }

    .history-list-container {
        max-height: 400px;
    }
    
    .results-summary {
        width: max-content;
        max-width: calc(100vw - 120px);
        flex-wrap: wrap;
        justify-content: center;
        gap: var(--space-4);
        padding: var(--space-3) var(--space-5);
        top: 16px;
    }

    .activity-overlay {
        max-width: calc(100vw - 120px);
    }
}

/* Small Tablets / Portrait */
@media (max-width: 768px) {
    .nav-rail {
        width: 64px;
        padding: var(--space-4) 0;
    }
    
    .nav-brand img {
        width: 36px;
    }
    
    .nav-btn {
        height: 56px;
    }
    
    .view-title {
        font-size: var(--fs-h4);
    }
    
    .engineers-cards-grid {
        grid-template-columns: 1fr;
    }
    
    .bento-grid {
        grid-template-columns: 1fr;
    }
    
    .results-summary {
        max-width: calc(100vw - 80px);
    }
    
    .activity-overlay {
        max-width: calc(100vw - 80px);
    }
    
    .chat-slide-panel {
        max-width: calc(100vw - 80px);
    }
}
/* Journey Highlight */
.log-entry.highlighted {
    background: rgba(30, 46, 217, 0.1);
    border-left: 3px solid var(--yx-royal-blue);
    box-shadow: inset 0 0 10px rgba(30, 46, 217, 0.05);
}
.log-entry {
    transition: background 0.3s ease, border-left 0.3s ease, box-shadow 0.3s ease;
    border-left: 3px solid transparent;
}

/* ==========================================================================
   Auth Overlay
   ========================================================================== */

body.auth-pending {
    overflow: hidden;
}

.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: url('assets/bg-pattern.svg'), linear-gradient(135deg, #1A1A1A 0%, #000000 100%);
    background-size: cover;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: var(--space-6);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-xl);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    color: var(--yx-white);
}

.login-header {
    text-align: center;
    margin-bottom: var(--space-5);
}

.login-logo {
    height: 32px;
    margin-bottom: var(--space-4);
}

.login-header h2 {
    font-size: var(--fs-h3);
    margin-bottom: var(--space-2);
}

.login-header p {
    color: rgba(255,255,255,0.7);
    font-size: var(--fs-small);
}

.login-card .form-label {
    color: rgba(255,255,255,0.9);
}

.login-card .form-input {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
    color: var(--yx-white);
}

.login-card .form-input:focus {
    background: rgba(255,255,255,0.15);
    border-color: var(--yx-royal-blue);
}

.login-card .form-input::placeholder {
    color: rgba(255,255,255,0.4);
}

.login-card .btn-primary {
    margin-top: var(--space-2);
}

/* ==========================================================================
   Premium Project Dashboard UI
   ========================================================================== */

.project-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--app-bg-subtle);
    z-index: 9998; /* Just below auth-overlay */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.project-dashboard {
    width: 1000px;
    max-width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    padding: 48px;
    background: var(--app-card);
    border: 1px solid var(--app-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
}

.project-dashboard::-webkit-scrollbar {
    width: 6px;
}
.project-dashboard::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.1);
    border-radius: 6px;
}

.project-header h2 {
    font-family: var(--font-display);
    font-size: var(--fs-h2);
    font-weight: 600;
    letter-spacing: var(--tracking-tight);
    color: var(--app-fg);
}

.project-card {
    background: var(--app-card);
    border: 1px solid var(--app-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-out);
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.project-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(37, 99, 235, 0.02);
    opacity: 0;
    transition: opacity var(--dur-fast) var(--ease-out);
    z-index: 0;
}

.project-card:hover {
    transform: translateY(-4px);
    border-color: var(--yx-royal-blue);
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

.project-card:hover::before {
    opacity: 1;
}

.project-card > * {
    position: relative;
    z-index: 1;
}

.project-card-title {
    font-family: var(--font-display);
    font-size: var(--fs-h4);
    font-weight: 600;
    color: var(--app-fg);
    letter-spacing: var(--tracking-tight);
}

.project-card-desc {
    font-size: var(--fs-small);
    color: var(--app-fg-muted);
    line-height: var(--lh-relaxed);
}

.project-card-role {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
    color: var(--yx-royal-blue);
    margin-top: 16px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    background: rgba(37, 99, 235, 0.1);
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    width: fit-content;
}

.project-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, rgba(0,0,0,0.02) 0%, rgba(0,0,0,0) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 0;
}

.project-card:hover {
    transform: translateY(-4px) scale(1.01);
    background: rgba(255, 255, 255, 1);
    border-color: rgba(99, 102, 241, 0.5); /* Indigo accent */
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 0 20px rgba(99, 102, 241, 0.1);
}

.project-card:hover::before {
    opacity: 1;
}

.project-card > * {
    position: relative;
    z-index: 1;
}

.project-card-title {
    font-size: 18px;
    font-weight: 600;
    color: #0f172a;
    letter-spacing: -0.01em;
}

.project-card-desc {
    font-size: 14px;
    color: #475569;
    line-height: 1.5;
}

.project-card-role {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #818cf8;
    margin-top: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    background: rgba(99, 102, 241, 0.1);
    padding: 4px 10px;
    border-radius: 100px;
    width: fit-content;
}

/* ==========================================================================
   Navigation foundations (Sprint 1)
   Token-only — every value below references colors_and_type.css.
   ========================================================================== */

:root {
    --z-modal-base: 2000;
    --z-toast:      9000;
}

/* ─── Toast region (aria-live polite) ─── */
#toast-region {
    position: fixed;
    bottom: var(--space-5);
    right: var(--space-5);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    pointer-events: none;
    max-width: min(420px, calc(100vw - var(--space-7)));
}

.toast {
    pointer-events: auto;
    background: var(--yx-black);
    color: var(--fg-on-dark);
    font-family: var(--font-body);
    font-size: var(--fs-small);
    line-height: var(--lh-normal);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border-left: 3px solid var(--status-info);
    cursor: pointer;
    transform: translateX(0);
    opacity: 1;
    animation: toast-enter var(--dur-base) var(--ease-out);
    transition:
        transform var(--dur-base) var(--ease-out),
        opacity var(--dur-base) var(--ease-out);
}

.toast--info    { border-left-color: var(--status-info); }
.toast--success { border-left-color: var(--status-success); }
.toast--warning { border-left-color: var(--status-warning); }
/* Yunex brand has no red — danger maps to Royal Blue per colors_and_type.css */
.toast--error   { border-left-color: var(--status-danger); }

.toast--leaving {
    opacity: 0;
    transform: translateX(var(--space-6));
}

@keyframes toast-enter {
    from { opacity: 0; transform: translateX(var(--space-6)); }
    to   { opacity: 1; transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
    .toast {
        animation: none;
        transition: opacity var(--dur-fast) linear;
    }
}
