/* MILO - Manufacturing Internal Logistics Operations
   Mobile-friendly CSS Stylesheet */

:root {
    /* Action tokens */
    --primary:        #2563eb;
    --primary-dark:   #1d4ed8;
    --secondary:      #64748b;
    --success:        #22c55e;
    --warning:        #f59e0b;
    --danger:         #ef4444;
    --info:           #3b82f6;

    /* ── Dark mode is the CSS default — no JS required ── */

    /* Surface / structure */
    --bg:             #0f172a;
    --bg-app:         #0f172a;
    --bg-surface:     #162032;
    --bg-card:        #1e293b;
    --bg-card-header: #162032;

    /* Typography */
    --text:           #e2e8f0;
    --text-primary:   #e2e8f0;
    --text-secondary: #cbd5e1;
    --text-muted:     #94a3b8;
    --text-inverse:   #0f172a;

    /* Borders */
    --border:         #334155;
    --border-default: #334155;
    --border-muted:   #1e293b;

    /* Semantic accent aliases */
    --accent-primary: #3b82f6;
    --accent-success: #22c55e;
    --accent-warning: #f59e0b;
    --accent-danger:  #ef4444;

    /* Elevation / subtle surfaces */
    --bg-elevated:    #1a2844;
    --border-subtle:  #253047;
    --shadow-soft:    0 2px 8px rgba(0,0,0,0.35);
    --text-disabled:  #475569;

    --radius:    8px;
    --shadow:    0 1px 3px rgba(0,0,0,0.4);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.4);
    color-scheme: dark;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* =============================================
   App Shell Layout
   ============================================= */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    width: 220px;
    background: #0f172a;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 200;
    overflow-y: auto;
    transition: transform 0.25s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid #1e293b;
}

.sidebar-brand {
    font-size: 1.35rem;
    font-weight: 700;
    color: #60a5fa;
    text-decoration: none;
    letter-spacing: 0.5px;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.sidebar-nav {
    flex: 1;
    padding: 0.5rem 0;
}

.nav-group {
    margin-bottom: 0.25rem;
}

.nav-group-label {
    padding: 0.55rem 1rem 0.3rem;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #7a8fa8;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.42rem 1rem 0.42rem 1.6rem;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.82rem;
    border-left: 3px solid transparent;
    transition: all 0.15s;
}

.nav-item-icon {
    flex-shrink: 0;
    width: 1.2em;
    text-align: center;
    font-size: 0.9em;
}

.nav-item-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-item:hover {
    background: #1e293b;
    color: #e2e8f0;
}

.nav-item.active {
    background: #1e293b;
    color: #60a5fa;
    border-left-color: #3b82f6;
    font-weight: 600;
}

.nav-children {
    display: block;
    padding-left: 0.8rem;
}

.nav-item--child {
    padding-left: 2.4rem;
    font-size: 0.78rem;
}

/* --- Mobile overlay --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 190;
}

/* --- Shell main area --- */
.shell-main {
    flex: 1;
    margin-left: 220px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- Top bar --- */
.topbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 1rem;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 4px;
}

.topbar-menu-btn:hover { background: var(--bg); }

.menu-icon {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text);
    position: relative;
}
.menu-icon::before, .menu-icon::after {
    content: '';
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text);
    position: absolute;
    left: 0;
}
.menu-icon::before { top: -6px; }
.menu-icon::after { top: 6px; }

.topbar-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar-icon {
    position: relative;
    font-size: 1.2rem;
    text-decoration: none;
    color: var(--text);
}

.notif-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger);
    color: white;
    font-size: 0.6rem;
    padding: 1px 5px;
    border-radius: 10px;
    display: none;
}

.topbar-user {
    color: var(--text-muted);
    font-size: 0.82rem;
}

/* --- Main content --- */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
    width: 100%;
}

.main-content--unauthenticated {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
}

/* --- Responsive: tablet and below --- */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-close { display: block; }
    .sidebar-overlay.open { display: block; }
    .topbar-menu-btn { display: flex; }
    .shell-main { margin-left: 0; }
}

/* Legacy compat — old .navbar references in sub-templates */
.navbar { display: none; }
.nav-brand, .nav-links, .nav-user, .nav-icon, .user-name { display: none; }

/* Flash Messages */
.flash-messages {
    margin-bottom: 1rem;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #fef3c7; color: #92400e; }
.alert-info { background: #dbeafe; color: #1e40af; }

.alert-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: inherit;
    opacity: 1;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    gap: 0.5rem;
}

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

.btn-secondary { background: var(--secondary); color: white; }
.btn-secondary:hover { opacity: 0.9; }

.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-info { background: #17a2b8; color: white; }
.btn-info:hover { background: #138496; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { background: var(--bg); }

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn-block { width: 100%; }

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.card-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.card-body {
    padding: 1rem;
}

.card-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}

.stat-card.stat-warning { border-left: 4px solid var(--warning); }
.stat-card.stat-success { border-left: 4px solid var(--success); }
.stat-card.stat-info { border-left: 4px solid var(--info); }

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.stat-link {
    font-size: 0.75rem;
    color: var(--primary);
}

/* Clickable Stat Cards */
.clickable-card {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    display: block;
}

.clickable-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.clickable-card:active {
    transform: translateY(0);
}

/* Empty placeholder card */
.card-placeholder {
    min-height: 200px;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
}

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

.table th {
    background: var(--bg);
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    color: var(--text-muted);
}

.table tr:hover {
    background: var(--bg);
}

.table-sm th, .table-sm td {
    padding: 0.5rem;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
    background: var(--bg);
    color: var(--text-muted);
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: #f1f5f9; color: #475569; }

.badge-pendingapproval { background: #fef3c7; color: #92400e; }
.badge-open { background: #dbeafe; color: #1e40af; }
.badge-assigned { background: #e0e7ff; color: #3730a3; }
.badge-accepted { background: #d1fae5; color: #065f46; }
.badge-inprogress { background: #fef3c7; color: #92400e; }
.badge-completed { background: #dcfce7; color: #166534; }
.badge-canceled { background: #f1f5f9; color: #475569; }

.badge-critical { background: #fee2e2; color: #991b1b; }
.badge-high { background: #fef3c7; color: #92400e; }
.badge-normal { background: #dbeafe; color: #1e40af; }
.badge-low { background: #f1f5f9; color: #475569; }
.badge-emergency { background: #fee2e2; color: #991b1b; }

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9375rem;
    background: var(--bg-card);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.form-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.radio-group {
    display: flex;
    gap: 1rem;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: normal;
}

.inline-form {
    display: inline-block;
}

/* Quick Actions */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
}

.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    font-size: 0.875rem;
    transition: all 0.2s;
}

.quick-action-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.quick-action-btn .icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    justify-items: stretch;
    justify-content: start;
}

@media (min-width: 768px) {
    .quick-actions-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.quick-actions-grid .btn {
    text-align: center;
    white-space: nowrap;
}

/* Checklist */
.checklist {
    list-style: none;
    padding: 0;
    margin: 0;
}

.checklist li {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.checklist li:last-child {
    border-bottom: none;
}

.checklist li.completed {
    color: var(--success);
}

.checklist li.completed::before {
    content: "\2713 ";
    margin-right: 0.5rem;
}

/* Timeline */
.timeline-list {
    border-left: 2px solid var(--border);
    padding-left: 1rem;
    margin-left: 0.5rem;
}

.timeline-item {
    padding: 0.5rem 0;
    position: relative;
}

.timeline-item::before {
    content: "";
    position: absolute;
    left: -1.35rem;
    top: 0.75rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
}

.timeline-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
}

.timeline-event {
    font-weight: 500;
}

/* Detail Grid */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.detail-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* Pace Display */
.pace-display {
    text-align: center;
    padding: 2rem;
}

.pace-score {
    font-size: 3rem;
    font-weight: bold;
    color: var(--primary);
}

.pace-score .score-unit {
    font-size: 1.5rem;
}

/* Coming Soon */
.coming-soon {
    text-align: center;
    padding: 2rem;
}

.coming-soon ul {
    text-align: left;
    display: inline-block;
    margin-top: 1rem;
}

/* Quiz List */
.quiz-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.quiz-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.quiz-item:last-child {
    border-bottom: none;
}

/* Event List */
.event-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.event-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

.event-list li:last-child {
    border-bottom: none;
}

.event-time {
    color: var(--text-muted);
    margin-right: 0.5rem;
}

.event-type {
    font-weight: 500;
}

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

/* Task Cards */
.task-cards {
    display: grid;
    gap: 1rem;
}

.task-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
}

.task-card.priority-critical { border-left: 4px solid var(--danger); }
.task-card.priority-high { border-left: 4px solid var(--warning); }
.task-card.priority-normal { border-left: 4px solid var(--info); }

.task-card-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.task-card-body {
    padding: 1rem;
}

.task-card-body h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.task-card-actions {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
}

.task-id {
    font-weight: 600;
    color: var(--primary);
}

.task-locations {
    margin-top: 0.5rem;
}

.location-row {
    display: flex;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.location-row .label {
    font-weight: 600;
    color: var(--text-muted);
    min-width: 50px;
}

/* Kanban Board */
.kanban-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 1rem;
}

@media (max-width: 1024px) {
    .kanban-board {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .kanban-board {
        grid-template-columns: 1fr;
    }
}

.kanban-column {
    background: var(--bg);
    border-radius: var(--radius);
    min-height: 200px;
}

.column-header {
    padding: 0.75rem 1rem;
    border-radius: var(--radius) var(--radius) 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
}

.column-header.pending { background: #f59e0b; }
.column-header.open { background: #3b82f6; }
.column-header.assigned { background: #8b5cf6; }
.column-header.inprogress { background: #22c55e; }

.column-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
}

.column-header .count {
    background: rgba(255,255,255,0.2);
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
}

.column-body {
    padding: 0.5rem;
}

.kanban-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    font-size: 0.8125rem;
}

.kanban-card .card-id {
    font-weight: 600;
    color: var(--primary);
}

.kanban-card .card-category {
    font-weight: 500;
    margin: 0.25rem 0;
}

.kanban-card .card-locations {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.kanban-card .arrow {
    margin: 0 0.25rem;
}

.kanban-card .card-driver {
    color: var(--secondary);
    font-size: 0.75rem;
}

.kanban-card .card-time {
    color: var(--text-muted);
    font-size: 0.6875rem;
}

/* Approval Cards */
.approval-list {
    display: grid;
    gap: 1rem;
}

.approval-card {
    border-left: 4px solid var(--warning);
}

.task-details {
    margin-bottom: 1rem;
}

.detail-row {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.detail-row .label {
    font-weight: 600;
    min-width: 80px;
    color: var(--text-muted);
}

/* Upload Grid */
.upload-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.template-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

/* Map Editor */
.map-editor-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1rem;
}

@media (max-width: 768px) {
    .map-editor-layout {
        grid-template-columns: 1fr;
    }
}

.map-container, .map-image-container {
    position: relative;
    overflow: auto;
}

.map-image-container img {
    max-width: 100%;
    height: auto;
}

/* Responsive Map View for FIFO */
.map-view-body {
    padding: 0;
}

.map-container-responsive {
    position: relative;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.map-image-responsive {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
}

@media (max-width: 768px) {
    .map-container-responsive {
        overflow-x: scroll;
    }
    
    .map-image-responsive {
        min-width: 600px;
    }
}

.map-marker {
    position: absolute;
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius);
    font-size: 0.625rem;
    font-weight: 600;
    cursor: move;
    white-space: nowrap;
}

.map-pin {
    position: absolute;
    width: 30px;
    height: 30px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.6rem;
    font-weight: 600;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.task-marker {
    position: absolute;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.5rem;
    font-weight: 700;
    transform: translate(-50%, -50%);
}

.task-marker.pickup { background: var(--warning); color: white; }
.task-marker.dropoff { background: var(--success); color: white; }

.map-legend {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    font-size: 0.75rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-marker {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.legend-marker.pin { background: var(--primary); }
.legend-marker.pickup { background: var(--warning); }
.legend-marker.dropoff { background: var(--success); }

/* SOP Grid */
.sop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.sop-card .card-body {
    min-height: 80px;
}

.sop-area {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.sop-desc {
    font-size: 0.875rem;
    color: var(--text);
}

/* Quiz */
.quiz-list {
    display: grid;
    gap: 1rem;
}

.quiz-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    flex-wrap: wrap;
    gap: 0.75rem;
}

.quiz-info h3 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.quiz-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.question-block {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.question-block h3 {
    margin-bottom: 1rem;
}

.choices {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.choice-option {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.choice-option:hover {
    background: var(--bg);
}

.choice-option input {
    margin-top: 2px;
}

.result-card {
    text-align: center;
}

.result-score {
    font-size: 4rem;
    font-weight: 700;
}

.result-score.passed { color: var(--success); }
.result-score.failed { color: var(--danger); }

.review-question {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.review-question.correct { background: #dcfce7; }
.review-question.incorrect { background: #fee2e2; }

.review-question h3 {
    margin-bottom: 0.75rem;
    font-size: 0.9375rem;
}

.answer-review {
    font-size: 0.875rem;
}

/* Questions List (admin) */
.questions-list {
    margin-bottom: 1.5rem;
}

.question-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
}

.question-number {
    font-weight: 700;
    color: var(--primary);
}

.question-content .choices {
    flex-direction: row;
    flex-wrap: wrap;
    margin-top: 0.5rem;
    font-size: 0.8125rem;
}

.question-content .choices span {
    padding: 0.25rem 0.5rem;
    background: var(--bg);
    border-radius: var(--radius);
}

.question-content .choices span.correct {
    background: #dcfce7;
    font-weight: 600;
}

/* Board Gallery */
.board-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.board-card .board-image {
    height: 150px;
    overflow: hidden;
    border-radius: var(--radius) var(--radius) 0 0;
}

.board-card .board-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.board-card h3 {
    font-size: 0.9375rem;
}

.board-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Photo Grid */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
}

.photo-grid img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.photos-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

/* Profile */
.profile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.profile-item {
    padding: 1rem;
    background: var(--bg);
    border-radius: var(--radius);
}

.profile-item label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

/* Detail Grid */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.detail-item label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

/* Notifications */
.notification-list {
    max-height: 300px;
    overflow-y: auto;
}

.notification-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

.notification-item.unread {
    font-weight: 600;
}

.notification-list-full .notification-item-full {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
}

.notification-item-full.unread {
    border-left: 4px solid var(--primary);
    background: var(--bg);
}

.notif-content h3 {
    font-size: 0.9375rem;
    margin-bottom: 0.25rem;
}

.notif-content p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.notif-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Request Items */
.request-list {
    display: grid;
    gap: 0.75rem;
}

.request-item {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.request-item.priority-emergency,
.request-item.priority-critical {
    border-left: 4px solid var(--danger);
}

.request-item.priority-high {
    border-left: 4px solid var(--warning);
}

.request-item h3 {
    font-size: 0.9375rem;
    margin-top: 0.5rem;
}

.request-location {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Timeline */
.task-timeline {
    border-left: 2px solid var(--border);
    padding-left: 1rem;
    margin: 1rem 0;
}

.timeline-item {
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.event-timeline {
    font-size: 0.8125rem;
}

.event-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
    font-size: 0.875rem;
}

/* Filter Bar */
.filter-bar {
    margin-bottom: 1rem;
}

.filter-form {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.filter-form label {
    font-size: 0.875rem;
    font-weight: 500;
}

.filter-form select {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 1rem;
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.login-header {
    background: var(--bg);
    padding: 2rem;
    text-align: center;
}

.login-header h1 {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.login-form {
    padding: 2rem;
}

.login-form .form-group input {
    padding: 0.875rem;
    font-size: 1.125rem;
    text-align: center;
}

.login-footer {
    padding: 1rem 2rem 2rem;
    text-align: center;
}

.login-footer p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ── Semantic Utility Classes ── */
/* Text */
.text-primary    { color: var(--text); }
.text-secondary  { color: var(--text-secondary); }
.text-muted      { color: var(--text-muted); }
.text-disabled   { color: var(--text-disabled); opacity: 1; }
.text-success    { color: var(--success); }
.text-warning    { color: var(--warning); }
.text-danger     { color: var(--danger); }
.text-info       { color: var(--info); }
.text-center     { text-align: center; }
.text-right      { text-align: right; }

/* Section / card headings */
.section-title {
    font-size: 0.75rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--text-muted);
}
.card-title        { color: var(--text); font-weight: 600; }
.card-header-title { color: var(--text); font-weight: 700; font-size: 0.85rem; text-transform: uppercase; }
.table-heading     { color: var(--text-muted); font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.meta-text         { color: var(--text-muted); font-size: 0.8rem; }
.stat-label        { color: var(--text-muted); font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }
.nav-label         { color: var(--text-muted); font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }

/* Semantic badges */
.badge-neutral { background: var(--bg-surface); color: var(--text-secondary); }

/* Surface */
.bg-surface   { background: var(--bg-surface); }
.bg-card      { background: var(--bg-card); }
.bg-elevated  { background: var(--bg-elevated); }
.border-subtle { border-color: var(--border-subtle); }

.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }

.stat-inline {
    background: var(--bg);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
}

.help-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* Responsive */
@media (max-width: 640px) {
    .navbar {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .nav-links {
        width: 100%;
        overflow-x: auto;
        padding: 0.5rem 0;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .table {
        font-size: 0.8125rem;
    }
    
    .table th, .table td {
        padding: 0.5rem;
    }
}

/* Break Tracking Styles */
.break-buttons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.break-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 2rem !important;
    min-height: 100px;
    font-size: 1.25rem !important;
}

.break-btn .break-duration {
    font-size: 0.875rem;
    opacity: 0.8;
    margin-top: 0.25rem;
}

.btn-orange {
    background: #f97316;
    color: white;
    border-color: #ea580c;
}

.btn-orange:hover {
    background: #ea580c;
}

.break-active-card {
    border: 3px solid var(--warning);
}

.break-timer-display {
    padding: 1.5rem;
}

.timer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 1.125rem;
}

.timer-row:last-of-type {
    border-bottom: none;
}

.countdown-row {
    font-size: 1.5rem;
    font-weight: bold;
}

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

.timer-value {
    font-weight: 600;
}

.break-status-badge {
    display: inline-block;
    padding: 0.5rem 1.5rem;
    border-radius: 20px;
    font-size: 1rem;
    font-weight: 600;
    margin-top: 1rem;
}

.status-onbreak, .badge-onbreak {
    background: var(--warning);
    color: white;
}

.status-duesoon, .badge-duesoon {
    background: #f97316;
    color: white;
}

.status-overdue, .badge-overdue {
    background: var(--danger);
    color: white;
}

.status-returned, .badge-returned {
    background: var(--success);
    color: white;
}

.break-row.status-onbreak {
    background: rgba(245, 158, 11, 0.15);
    color: #1a1a1a;
}

.break-row.status-duesoon {
    background: rgba(249, 115, 22, 0.2);
    color: #1a1a1a;
}

.break-row.status-overdue {
    background: rgba(239, 68, 68, 0.2);
    color: #1a1a1a;
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.stat-orange {
    border-left: 4px solid #f97316;
}

.mb-3 {
    margin-bottom: 1rem;
}

/* Production Pace Styles */
.status-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.status-green, .status-green { background: #22c55e; }
.status-dot.status-yellow, .status-yellow { background: #eab308; }
.status-dot.status-red, .status-red { background: #ef4444; }

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.info-box {
    background: #f5f5f5;
    border-radius: var(--radius);
    padding: 1rem;
    margin: 1rem 0;
}

.info-box h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
}

.info-box ul {
    margin: 0;
    padding-left: 1.5rem;
}

.info-box li {
    margin: 0.25rem 0;
    font-size: 0.875rem;
}

.info-block {
    background: #f5f5f5;
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

.info-block p {
    margin: 0.25rem 0;
}

.info-card {
    margin-top: 1.5rem;
}

.info-card h3 {
    margin-top: 0;
    font-size: 1rem;
}

/* Grid layouts */
.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

/* Map preview cards */
.card-link {
    text-decoration: none;
    color: inherit;
}

.map-preview-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
}

.map-preview-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.map-thumbnail {
    width: 100%;
    height: 120px;
    object-fit: cover;
    background: #f0f0f0;
}

.map-placeholder {
    width: 100%;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.map-name {
    padding: 0.75rem;
    font-weight: 500;
    font-size: 0.9rem;
    text-align: center;
    border-top: 1px solid var(--border);
}

/* Map list page */
.map-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}

.map-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: box-shadow 0.2s;
}

.map-card:hover {
    box-shadow: var(--shadow-lg);
}

.map-card-image {
    width: 100%;
    height: 150px;
    object-fit: cover;
    background: #e0e0e0;
}

.map-card-body {
    padding: 1rem;
}

.map-card-title {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.map-card-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.map-card-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* =============================================
   Command Palette
   ============================================= */
.cmd-palette-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 900;
}
.cmd-palette-overlay.open { display: block; }

.cmd-palette {
    display: none;
    position: fixed;
    top: 12vh;
    left: 50%;
    transform: translateX(-50%);
    width: 94%;
    max-width: 520px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.18), 0 4px 12px rgba(0,0,0,0.08);
    z-index: 910;
    overflow: hidden;
}
.cmd-palette.open { display: block; }

.cmd-p-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}
.cmd-p-input-icon {
    color: var(--text-muted);
    font-size: 1.1rem;
    flex-shrink: 0;
}
.cmd-p-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 0.95rem;
    background: transparent;
    color: var(--text);
    font-family: inherit;
}
.cmd-p-input::placeholder { color: #94a3b8; }
.cmd-p-kbd {
    font-size: 0.65rem;
    padding: 0.15rem 0.4rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    color: var(--text-muted);
    background: #f9fafb;
    font-family: inherit;
    flex-shrink: 0;
}

.cmd-p-results {
    max-height: 360px;
    overflow-y: auto;
    padding: 0.35rem 0;
}

.cmd-p-group-label {
    padding: 0.5rem 1rem 0.25rem;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.cmd-p-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 1rem;
    text-decoration: none;
    color: var(--text);
    font-size: 0.85rem;
    transition: background 0.08s;
    cursor: pointer;
}
.cmd-p-item:hover,
.cmd-p-item.selected {
    background: #f1f5f9;
}
.cmd-p-item.selected {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
    border-radius: 4px;
}
.cmd-p-item-icon {
    flex-shrink: 0;
    width: 1.4rem;
    text-align: center;
    font-size: 0.95rem;
}
.cmd-p-item-text {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}
.cmd-p-item-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}
.cmd-p-item-group {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.cmd-p-item-type {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    flex-shrink: 0;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    background: #f1f5f9;
    font-weight: 600;
}
.cmd-p-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.topbar-search-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text-muted);
    font-size: 0.78rem;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
    white-space: nowrap;
}
.topbar-search-btn:hover {
    border-color: #94a3b8;
    box-shadow: var(--shadow);
}
.topbar-search-btn .search-icon { font-size: 0.85rem; }
.topbar-search-btn .search-text { color: #94a3b8; }
.topbar-search-btn kbd {
    font-size: 0.62rem;
    padding: 0.1rem 0.3rem;
    border: 1px solid #d1d5db;
    border-radius: 3px;
    background: #f9fafb;
    color: var(--text-muted);
    font-family: inherit;
}

@media (max-width: 768px) {
    .cmd-palette {
        top: 2vh;
        width: 96%;
        max-width: none;
        border-radius: 10px;
    }
    .cmd-p-results { max-height: 55vh; }
    .topbar-search-btn .search-text,
    .topbar-search-btn kbd { display: none; }
    .topbar-search-btn { padding: 0.35rem 0.5rem; }
}

/* =============================================
   Dark Mode — CSS default. Light mode requires data-theme="light" on <html>
   ============================================= */
html:not([data-theme="light"]) {
    --bg:             #0f172a;
    --bg-app:         #0f172a;
    --bg-surface:     #162032;
    --bg-card:        #1e293b;
    --bg-card-header: #162032;

    --text:           #e2e8f0;
    --text-primary:   #e2e8f0;
    --text-secondary: #cbd5e1;
    --text-muted:     #94a3b8;
    --text-inverse:   #0f172a;

    --border:         #334155;
    --border-default: #334155;
    --border-muted:   #1e293b;

    --accent-primary: #3b82f6;
    --accent-success: #22c55e;
    --accent-warning: #f59e0b;
    --accent-danger:  #ef4444;

    --shadow:    0 1px 3px rgba(0,0,0,0.4);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.4);
    color-scheme: dark;
}

/* Inputs / selects / textareas */
html:not([data-theme="light"]) input,
html:not([data-theme="light"]) select,
html:not([data-theme="light"]) textarea,
html:not([data-theme="light"]) .form-control {
    background: #1e293b;
    color: #e2e8f0;
    border-color: #334155;
}
html:not([data-theme="light"]) input::placeholder,
html:not([data-theme="light"]) textarea::placeholder { color: #64748b; }

/* Badges — remap to dark-friendly tones */
html:not([data-theme="light"]) .badge-success  { background: #14532d; color: #4ade80; }
html:not([data-theme="light"]) .badge-warning  { background: #713f12; color: #fbbf24; }
html:not([data-theme="light"]) .badge-danger   { background: #7f1d1d; color: #f87171; }
html:not([data-theme="light"]) .badge-info     { background: #1e3a8a; color: #93c5fd; }
html:not([data-theme="light"]) .badge-secondary{ background: #334155; color: #94a3b8; }

/* Task / alert severity badges */
html:not([data-theme="light"]) .badge-critical    { background: #7f1d1d; color: #f87171; }
html:not([data-theme="light"]) .badge-high        { background: #713f12; color: #fbbf24; }
html:not([data-theme="light"]) .badge-normal      { background: #1e3a8a; color: #93c5fd; }
html:not([data-theme="light"]) .badge-low         { background: #334155; color: #94a3b8; }
html:not([data-theme="light"]) .badge-emergency   { background: #7f1d1d; color: #f87171; }
html:not([data-theme="light"]) .badge-open        { background: #1e3a8a; color: #93c5fd; }
html:not([data-theme="light"]) .badge-assigned    { background: #312e81; color: #a5b4fc; }
html:not([data-theme="light"]) .badge-accepted    { background: #14532d; color: #4ade80; }
html:not([data-theme="light"]) .badge-inprogress  { background: #713f12; color: #fbbf24; }
html:not([data-theme="light"]) .badge-completed   { background: #14532d; color: #4ade80; }
html:not([data-theme="light"]) .badge-canceled    { background: #334155; color: #94a3b8; }
html:not([data-theme="light"]) .badge-pendingapproval { background: #713f12; color: #fbbf24; }

/* Break status badges */
html:not([data-theme="light"]) .badge-onbreak  { background: #1e3a8a; color: #93c5fd; }
html:not([data-theme="light"]) .badge-duesoon  { background: #713f12; color: #fbbf24; }
html:not([data-theme="light"]) .badge-overdue  { background: #7f1d1d; color: #f87171; }

/* Flash / alert messages */
html:not([data-theme="light"]) .alert-success { background: #14532d; color: #4ade80; border-color: #166534; }
html:not([data-theme="light"]) .alert-error   { background: #7f1d1d; color: #f87171; border-color: #991b1b; }
html:not([data-theme="light"]) .alert-warning { background: #713f12; color: #fbbf24; border-color: #92400e; }
html:not([data-theme="light"]) .alert-info    { background: #1e3a8a; color: #93c5fd; border-color: #1e40af; }

/* Misc overrides that use hardcoded white/light values */
html:not([data-theme="light"]) .btn-outline {
    border-color: #475569;
    color: #cbd5e1;
}
html:not([data-theme="light"]) .btn-outline:hover {
    background: #334155;
}
html:not([data-theme="light"]) .btn-secondary {
    background: #334155;
    color: #cbd5e1;
}
html:not([data-theme="light"]) .page-header {
    border-bottom-color: #334155;
}

/* Theme toggle button in topbar */
.theme-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.15rem;
    padding: 0.25rem 0.3rem;
    border-radius: 6px;
    color: var(--text);
    line-height: 1;
    transition: background 0.15s;
}
.theme-toggle-btn:hover { background: var(--border); }

/* =============================================
   Light Mode  (data-theme="light" on <html>)
   ============================================= */
[data-theme="light"] {
    --bg:             #f8fafc;
    --bg-app:         #f8fafc;
    --bg-surface:     #f1f5f9;
    --bg-card:        #ffffff;
    --bg-card-header: #f0f4ff;

    --text:           #1e293b;
    --text-primary:   #1e293b;
    --text-secondary: #334155;
    --text-muted:     #64748b;
    --text-inverse:   #ffffff;

    --border:         #e2e8f0;
    --border-default: #e2e8f0;
    --border-muted:   #f1f5f9;

    --accent-primary: #2563eb;
    --accent-success: #16a34a;
    --accent-warning: #d97706;
    --accent-danger:  #dc2626;

    --bg-elevated:    #ffffff;
    --border-subtle:  #e8edf5;
    --shadow-soft:    0 2px 8px rgba(0,0,0,0.08);
    --text-disabled:  #94a3b8;

    --shadow:    0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.1);
    color-scheme: light;
}

/* Light mode badge colours (restore originals) */
[data-theme="light"] .badge-success       { background: #dcfce7; color: #166534; }
[data-theme="light"] .badge-warning       { background: #fef3c7; color: #92400e; }
[data-theme="light"] .badge-danger        { background: #fee2e2; color: #991b1b; }
[data-theme="light"] .badge-info          { background: #dbeafe; color: #1e40af; }
[data-theme="light"] .badge-secondary     { background: #f1f5f9; color: #475569; }
[data-theme="light"] .badge-pendingapproval { background: #fef3c7; color: #92400e; }
[data-theme="light"] .badge-open          { background: #dbeafe; color: #1e40af; }
[data-theme="light"] .badge-assigned      { background: #e0e7ff; color: #3730a3; }
[data-theme="light"] .badge-accepted      { background: #d1fae5; color: #065f46; }
[data-theme="light"] .badge-inprogress    { background: #fef3c7; color: #92400e; }
[data-theme="light"] .badge-completed     { background: #dcfce7; color: #166534; }
[data-theme="light"] .badge-canceled      { background: #f1f5f9; color: #475569; }
[data-theme="light"] .badge-critical      { background: #fee2e2; color: #991b1b; }
[data-theme="light"] .badge-high          { background: #fef3c7; color: #92400e; }
[data-theme="light"] .badge-normal        { background: #dbeafe; color: #1e40af; }
[data-theme="light"] .badge-low           { background: #f1f5f9; color: #475569; }
[data-theme="light"] .badge-emergency     { background: #fee2e2; color: #991b1b; }
[data-theme="light"] .badge-onbreak       { background: #dbeafe; color: #1e40af; }
[data-theme="light"] .badge-duesoon       { background: #fef3c7; color: #92400e; }
[data-theme="light"] .badge-overdue       { background: #fee2e2; color: #991b1b; }

/* Light mode alert colours */
[data-theme="light"] .alert-success { background: #dcfce7; color: #166534; border-color: #166534; }
[data-theme="light"] .alert-error   { background: #fee2e2; color: #991b1b; border-color: #991b1b; }
[data-theme="light"] .alert-warning { background: #fef3c7; color: #92400e; border-color: #92400e; }
[data-theme="light"] .alert-info    { background: #dbeafe; color: #1e40af; border-color: #1e40af; }

/* Light mode misc overrides */
[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea,
[data-theme="light"] .form-control {
    background: #ffffff;
    color: #1e293b;
    border-color: #e2e8f0;
}
[data-theme="light"] .btn-outline      { border-color: #cbd5e1; color: #475569; }
[data-theme="light"] .btn-outline:hover { background: #f8fafc; }
[data-theme="light"] .btn-secondary    { background: #64748b; color: #ffffff; }

/* =============================================
   Dark Mode — Additional Contrast Fixes
   ============================================= */

/* Info / info-block boxes: light grey → dark navy */
html:not([data-theme="light"]) .info-box,
html:not([data-theme="light"]) .info-block {
    background: #1e293b;
    color: var(--text);
    border: 1px solid #334155;
}

/* Map thumbnails / placeholders: light grey → dark */
html:not([data-theme="light"]) .map-thumbnail,
html:not([data-theme="light"]) .map-placeholder,
html:not([data-theme="light"]) .map-card-image {
    background: #334155;
    color: var(--text-muted);
}

/* Safety quiz — correct / incorrect review highlights */
html:not([data-theme="light"]) .review-question.correct { background: #14532d; color: #4ade80; }
html:not([data-theme="light"]) .review-question.incorrect { background: #7f1d1d; color: #f87171; }
html:not([data-theme="light"]) .question-content .choices span.correct {
    background: #14532d;
    color: #4ade80;
}

/* Break supervisor rows: dark text on semi-transparent row → light text */
html:not([data-theme="light"]) .break-row.status-onbreak,
html:not([data-theme="light"]) .break-row.status-duesoon,
html:not([data-theme="light"]) .break-row.status-overdue {
    color: var(--text);
}

/* Command palette kbd chips & search button kbd: white chips → dark chips */
html:not([data-theme="light"]) .cmd-p-kbd,
html:not([data-theme="light"]) .topbar-search-btn kbd {
    background: #334155;
    border-color: #475569;
    color: #cbd5e1;
}

/* Command palette item hover & selected: light blue → dark hover */
html:not([data-theme="light"]) .cmd-p-item:hover,
html:not([data-theme="light"]) .cmd-p-item.selected {
    background: #1e293b;
    color: var(--text);
}

/* Command palette item-type pill: light → dark */
html:not([data-theme="light"]) .cmd-p-item-type {
    background: #334155;
    color: #94a3b8;
}

/* Kanban column headers: ensure text is visible */
html:not([data-theme="light"]) .column-header {
    color: #ffffff;
}

/* Page header border */
html:not([data-theme="light"]) .page-header {
    border-bottom-color: #334155;
}

/* Stat / KPI card accents that use hardcoded light greys */
html:not([data-theme="light"]) .stat-card,
html:not([data-theme="light"]) .kpi-card {
    background: var(--bg-card);
    color: var(--text);
}

/* Generic hardcoded light-grey sections */
html:not([data-theme="light"]) [style*="background: #f5f5f5"],
html:not([data-theme="light"]) [style*="background:#f5f5f5"],
html:not([data-theme="light"]) [style*="background: #f0f0f0"],
html:not([data-theme="light"]) [style*="background:#f0f0f0"],
html:not([data-theme="light"]) [style*="background: #f9fafb"],
html:not([data-theme="light"]) [style*="background:#f9fafb"],
html:not([data-theme="light"]) [style*="background: #f1f5f9"],
html:not([data-theme="light"]) [style*="background:#f1f5f9"] {
    background: #1e293b !important;
    color: var(--text) !important;
}

/* Any hardcoded dark text colour in inline styles */
html:not([data-theme="light"]) [style*="color: #1a1a1a"],
html:not([data-theme="light"]) [style*="color:#1a1a1a"],
html:not([data-theme="light"]) [style*="color: #333"],
html:not([data-theme="light"]) [style*="color:#333"],
html:not([data-theme="light"]) [style*="color: #000"],
html:not([data-theme="light"]) [style*="color:#000"] {
    color: var(--text) !important;
}

/* Restore light mode for those same elements */
[data-theme="light"] .info-box,
[data-theme="light"] .info-block      { background: #f5f5f5; border: none; }
[data-theme="light"] .map-thumbnail,
[data-theme="light"] .map-card-image  { background: #f0f0f0; }
[data-theme="light"] .map-placeholder { background: #f0f0f0; }
[data-theme="light"] .review-question.correct   { background: #dcfce7; color: inherit; }
[data-theme="light"] .review-question.incorrect { background: #fee2e2; color: inherit; }
[data-theme="light"] .question-content .choices span.correct { background: #dcfce7; color: inherit; }
[data-theme="light"] .break-row.status-onbreak,
[data-theme="light"] .break-row.status-duesoon,
[data-theme="light"] .break-row.status-overdue  { color: #1a1a1a; }
[data-theme="light"] .cmd-p-kbd,
[data-theme="light"] .topbar-search-btn kbd     { background: #f9fafb; border-color: #d1d5db; color: #64748b; }
[data-theme="light"] .cmd-p-item:hover,
[data-theme="light"] .cmd-p-item.selected       { background: #f1f5f9; }
[data-theme="light"] .cmd-p-item-type           { background: #f1f5f9; color: #475569; }

/* =============================================
   Dark Mode — Inline-style white background overrides
   Catches templates that hardcode light backgrounds in style="" attributes
   ============================================= */

/* White / near-white backgrounds — bg + text only, leave border-colors alone
   (border-left status indicators like green/red active markers must survive) */
html:not([data-theme="light"]) [style*="background: #fff"],
html:not([data-theme="light"]) [style*="background:#fff"],
html:not([data-theme="light"]) [style*="background: white"],
html:not([data-theme="light"]) [style*="background:white"],
html:not([data-theme="light"]) [style*="background: #f8f9fa"],
html:not([data-theme="light"]) [style*="background:#f8f9fa"],
html:not([data-theme="light"]) [style*="background: #fff3cd"],
html:not([data-theme="light"]) [style*="background:#fff3cd"],
html:not([data-theme="light"]) [style*="background: #fff5f5"],
html:not([data-theme="light"]) [style*="background:#fff5f5"],
html:not([data-theme="light"]) [style*="background: #f1f3f5"],
html:not([data-theme="light"]) [style*="background:#f1f3f5"] {
    background: #1e293b !important;
    color: var(--text) !important;
}

/* Light 1px borders on inline-styled containers → dark border */
html:not([data-theme="light"]) [style*="border: 1px solid #dee2e6"],
html:not([data-theme="light"]) [style*="border:1px solid #dee2e6"],
html:not([data-theme="light"]) [style*="border: 1px solid #ddd"] {
    border-color: #334155 !important;
}

/* Dark text on light/white backgrounds in inline styles */
html:not([data-theme="light"]) [style*="color: #6c757d"],
html:not([data-theme="light"]) [style*="color:#6c757d"],
html:not([data-theme="light"]) [style*="color: #664d03"],
html:not([data-theme="light"]) [style*="color:#664d03"],
html:not([data-theme="light"]) [style*="color: #999"],
html:not([data-theme="light"]) [style*="color:#999"] {
    color: #94a3b8 !important;
}

/* Table rows with hardcoded light backgrounds */
html:not([data-theme="light"]) tr[style*="background: #f8f9fa"],
html:not([data-theme="light"]) tr[style*="background:#f8f9fa"] {
    background: #1e293b !important;
    color: var(--text) !important;
}

/* Driver tool icon with yellow hardcoded bg */
html:not([data-theme="light"]) [style*="background:#fef3c7"],
html:not([data-theme="light"]) [style*="background: #fef3c7"] {
    background: #451a03 !important;
    color: #fbbf24 !important;
}

/* Weekly report focus-areas panel */
html:not([data-theme="light"]) [style*="background: #f0f4ff"],
html:not([data-theme="light"]) [style*="background:#f0f4ff"] {
    background: #1e2a4a !important;
    border-color: #3b5bdb !important;
    color: var(--text) !important;
}

/* select option background in dark mode (browser native) */
html:not([data-theme="light"]) select option {
    background: #1e293b;
    color: #e2e8f0;
}

/* =============================================
   Dark Mode — Weekly Operations Report overrides
   The report has an inline <style> block with light-mode
   hardcoded values; these rules override them via specificity.
   ============================================= */

/* Section cards: white box → dark card */
html:not([data-theme="light"]) .section-card {
    background: var(--bg-card) !important;
    border-color: var(--border) !important;
    color: var(--text);
}

/* Section titles: dark navy → light blue */
html:not([data-theme="light"]) .section-title {
    color: #93c5fd !important;
    border-bottom-color: var(--border) !important;
}

/* Metric rows: near-white divider → dark divider */
html:not([data-theme="light"]) .metric-row {
    border-bottom-color: var(--border) !important;
}

/* Metric labels/values: dark text → visible text */
html:not([data-theme="light"]) .metric-label {
    color: var(--text-muted) !important;
}
html:not([data-theme="light"]) .metric-value {
    color: var(--text) !important;
}

/* Report-specific severity badges (different from task badges) */
html:not([data-theme="light"]) .badge-sev.badge-high   { background: #7f1d1d !important; color: #f87171 !important; }
html:not([data-theme="light"]) .badge-sev.badge-medium { background: #713f12 !important; color: #fbbf24 !important; }
html:not([data-theme="light"]) .badge-sev.badge-low    { background: #14532d !important; color: #4ade80 !important; }

/* Focus items: near-white tinted background → dark tinted */
html:not([data-theme="light"]) .focus-item.focus-high   { background: #2a0f0f !important; }
html:not([data-theme="light"]) .focus-item.focus-medium { background: #261e0a !important; }

/* Mini table header row */
html:not([data-theme="light"]) .mini-table th {
    background: #0f172a !important;
    color: var(--text-muted) !important;
    border-bottom-color: var(--border) !important;
}
html:not([data-theme="light"]) .mini-table td {
    border-bottom-color: var(--border) !important;
    color: var(--text);
}

/* Inline dark-navy text colors used in the report header/titles */
html:not([data-theme="light"]) [style*="color: #1a3e72"],
html:not([data-theme="light"]) [style*="color:#1a3e72"],
html:not([data-theme="light"]) [style*="color: #0d47a1"],
html:not([data-theme="light"]) [style*="color:#0d47a1"],
html:not([data-theme="light"]) [style*="color: #495057"],
html:not([data-theme="light"]) [style*="color:#495057"] {
    color: var(--text) !important;
}

/* Date input in the week selector */
html:not([data-theme="light"]) input[type="date"] {
    background: var(--bg-card);
    color: var(--text);
    border-color: var(--border);
}

/* Light mode restore for weekly report classes */
[data-theme="light"] .section-card         { background: #fff; border-color: #dee2e6; }
[data-theme="light"] .section-title        { color: #1a3e72; border-bottom-color: #e9ecef; }
[data-theme="light"] .metric-row           { border-bottom-color: #f1f3f5; }
[data-theme="light"] .metric-label         { color: #495057; }
[data-theme="light"] .metric-value         { color: #333; }
[data-theme="light"] .badge-sev.badge-high   { background: #f8d7da; color: #721c24; }
[data-theme="light"] .badge-sev.badge-medium { background: #fff3cd; color: #856404; }
[data-theme="light"] .badge-sev.badge-low    { background: #d4edda; color: #155724; }
[data-theme="light"] .focus-item.focus-high  { background: #fff5f5; }
[data-theme="light"] .focus-item.focus-medium{ background: #fffbea; }
[data-theme="light"] .mini-table th        { background: #f8f9fa; color: #495057; border-bottom-color: #dee2e6; }
[data-theme="light"] .mini-table td        { border-bottom-color: #f1f3f5; }

/* ==============================================
   Dark Mode — Template-Level Class Overrides
   These target CSS classes defined inside per-template <style> blocks.
   Uses !important because template <style> tags load after style.css.
   ============================================== */

/* ── Info / notice banners (teal/cyan hardcoded in multiple templates) ── */
html:not([data-theme="light"]) [style*="background: #cff4fc"],
html:not([data-theme="light"]) [style*="background:#cff4fc"] {
    background: #0c2233 !important;
    border-color: #1e6a8a !important;
    color: #7dd3fc !important;
}
html:not([data-theme="light"]) [style*="color: #055160"],
html:not([data-theme="light"]) [style*="color:#055160"] {
    color: #7dd3fc !important;
}

/* ── Supervisor Dashboard ── */

/* Shift badge pill */
html:not([data-theme="light"]) .shift-badge {
    background: #1e3a8a !important;
    color: #93c5fd !important;
}

/* KPI sub-item chips */
html:not([data-theme="light"]) .kpi-sub-item {
    background: #334155 !important;
    color: #94a3b8 !important;
}

/* Panel header (cmd-panel-header uses #f8fafc) */
html:not([data-theme="light"]) .cmd-panel-header {
    background: var(--bg-surface) !important;
}

/* Line table row separator */
html:not([data-theme="light"]) .line-table td {
    border-bottom-color: var(--border-muted) !important;
}
html:not([data-theme="light"]) .line-table tr:hover td {
    background: var(--bg-surface) !important;
}

/* Status dots (idle / no-target grey dot) */
html:not([data-theme="light"]) .status-dot--idle::before,
html:not([data-theme="light"]) .status-dot--no-target::before {
    background: #475569 !important;
}

/* Risk badges */
html:not([data-theme="light"]) .risk-badge--high   { background: #7f1d1d !important; color: #f87171 !important; }
html:not([data-theme="light"]) .risk-badge--medium { background: #713f12 !important; color: #fbbf24 !important; }
html:not([data-theme="light"]) .risk-badge--low    { background: #14532d !important; color: #4ade80 !important; }
html:not([data-theme="light"]) .risk-badge--none   { background: #334155 !important; color: #94a3b8 !important; }

/* Priority queue item hover */
html:not([data-theme="light"]) .pq-item:hover {
    background: var(--bg-surface) !important;
}

/* Activity feed icon circles */
html:not([data-theme="light"]) .feed-icon--check {
    background: #14532d !important; color: #4ade80 !important;
}
html:not([data-theme="light"]) .feed-icon--clock {
    background: #713f12 !important; color: #fbbf24 !important;
}
html:not([data-theme="light"]) .feed-icon--play  {
    background: #1e3a8a !important; color: #93c5fd !important;
}
html:not([data-theme="light"]) .feed-icon--alert {
    background: #7f1d1d !important; color: #f87171 !important;
}

/* ── Operator Placements ── */
html:not([data-theme="light"]) .status-badge-optimal   { background: #14532d !important; color: #4ade80 !important; }
html:not([data-theme="light"]) .status-badge-suboptimal { background: #713f12 !important; color: #fbbf24 !important; }
html:not([data-theme="light"]) .status-badge-high_risk  { background: #7f1d1d !important; color: #f87171 !important; }
html:not([data-theme="light"]) .status-badge-no_data    { background: #334155 !important; color: #94a3b8 !important; }

/* ── Driver Dashboard — Badges ── */
html:not([data-theme="light"]) .dh-badge--urgent,
html:not([data-theme="light"]) .dh-badge--high          { background: #7f1d1d !important; color: #f87171 !important; }
html:not([data-theme="light"]) .dh-badge--normal,
html:not([data-theme="light"]) .dh-badge--medium        { background: #1e3a8a !important; color: #93c5fd !important; }
html:not([data-theme="light"]) .dh-badge--low           { background: #334155 !important; color: #94a3b8 !important; }

html:not([data-theme="light"]) .dh-badge--demand-urgent     { background: #7f1d1d !important; color: #f87171 !important; }
html:not([data-theme="light"]) .dh-badge--demand-needs_move { background: #713f12 !important; color: #fbbf24 !important; }
html:not([data-theme="light"]) .dh-badge--demand-watch      { background: #1e3a8a !important; color: #93c5fd !important; }
html:not([data-theme="light"]) .dh-badge--demand-stable     { background: #14532d !important; color: #4ade80 !important; }

/* ── Driver Dashboard — Tinted row backgrounds ── */
html:not([data-theme="light"]) .dh-demand-row--urgent   { background: #2a0f0f !important; }
html:not([data-theme="light"]) .dh-demand-row--needs_move { background: #261e0a !important; }
html:not([data-theme="light"]) .dh-demand-row--watch    { background: #0f1e3a !important; }

html:not([data-theme="light"]) .dh-move-row--urgent     { background: #2a0f0f !important; }
html:not([data-theme="light"]) .dh-move-row--needs_move { background: #261e0a !important; }
html:not([data-theme="light"]) .dh-move-row--watch      { background: #0f1e3a !important; }

/* Muted detail text */
html:not([data-theme="light"]) .dh-demand-row__detail,
html:not([data-theme="light"]) .dh-demand-row__time,
html:not([data-theme="light"]) .dh-move-row__reason     { color: var(--text-muted) !important; }

/* Level indicator bar track */
html:not([data-theme="light"]) .dh-level-bar           { background: #334155 !important; }

/* ── Driver Dashboard — Next Best Move card ── */
html:not([data-theme="light"]) .dh-next-move           { background: #0d2318 !important; border-color: #166534 !important; }
html:not([data-theme="light"]) .dh-next-move__header   { color: #4ade80 !important; }
html:not([data-theme="light"]) .dh-next-move__loc      { color: var(--text) !important; }
html:not([data-theme="light"]) .dh-next-move__detail   { color: var(--text-muted) !important; }
html:not([data-theme="light"]) .dh-next-move__reason   { color: var(--text-muted) !important; }

/* ── Driver Dashboard — Congestion ── */
html:not([data-theme="light"]) .dh-congestion-strip--watch     { background: #2d1e0a !important; color: #fbbf24 !important; border-left-color: #d97706 !important; }
html:not([data-theme="light"]) .dh-congestion-strip--congested { background: #2a1506 !important; color: #fb923c !important; border-left-color: #ea580c !important; }
html:not([data-theme="light"]) .dh-congestion-strip--blocked   { background: #2a0f0f !important; color: #f87171 !important; border-left-color: #dc2626 !important; }

html:not([data-theme="light"]) .dh-congestion-pill--watch     { background: #2d1e0a !important; color: #fbbf24 !important; }
html:not([data-theme="light"]) .dh-congestion-pill--congested { background: #2a1506 !important; color: #fb923c !important; }
html:not([data-theme="light"]) .dh-congestion-pill--blocked   { background: #2a0f0f !important; color: #f87171 !important; }

/* Remove opacity on congestion pill status text */
html:not([data-theme="light"]) .dh-congestion-pill__status { opacity: 1 !important; }

/* ── Driver Dashboard — Move leg icons ── */
html:not([data-theme="light"]) .dh-move-leg__icon--from { background: #1e3a8a !important; color: #93c5fd !important; }
html:not([data-theme="light"]) .dh-move-leg__icon--to   { background: #14532d !important; color: #4ade80 !important; }

/* ── Light mode — restore template-defined light values ── */
[data-theme="light"] .shift-badge          { background: #dbeafe; color: #1e40af; }
[data-theme="light"] .kpi-sub-item         { background: #f1f5f9; color: #475569; }
[data-theme="light"] .cmd-panel-header     { background: #f8fafc; }
[data-theme="light"] .risk-badge--high     { background: #fef2f2; color: #dc2626; }
[data-theme="light"] .risk-badge--medium   { background: #fffbeb; color: #b45309; }
[data-theme="light"] .risk-badge--low      { background: #f0fdf4; color: #15803d; }
[data-theme="light"] .risk-badge--none     { background: #f8fafc; color: #64748b; }
[data-theme="light"] .feed-icon--check     { background: #dcfce7; color: #16a34a; }
[data-theme="light"] .feed-icon--clock     { background: #fef3c7; color: #b45309; }
[data-theme="light"] .feed-icon--play      { background: #dbeafe; color: #2563eb; }
[data-theme="light"] .feed-icon--alert     { background: #fee2e2; color: #dc2626; }
[data-theme="light"] .dh-next-move         { background: #f0fdf4; border-color: #16a34a; }
[data-theme="light"] .dh-next-move__header { color: #15803d; }
[data-theme="light"] .dh-next-move__loc    { color: #0f172a; }
[data-theme="light"] .dh-congestion-strip--watch     { background: #fffbeb; color: #92400e; }
[data-theme="light"] .dh-congestion-strip--congested { background: #fff7ed; color: #9a3412; }
[data-theme="light"] .dh-congestion-strip--blocked   { background: #fef2f2; color: #7f1d1d; }
[data-theme="light"] .dh-congestion-pill--watch      { background: #fef3c7; color: #92400e; }
[data-theme="light"] .dh-congestion-pill--congested  { background: #ffedd5; color: #9a3412; }
[data-theme="light"] .dh-congestion-pill--blocked    { background: #fee2e2; color: #991b1b; }
[data-theme="light"] .dh-move-leg__icon--from        { background: #dbeafe; color: #1d4ed8; }
[data-theme="light"] .dh-move-leg__icon--to          { background: #dcfce7; color: #166534; }
[data-theme="light"] .status-badge-optimal  { background: #dcfce7; color: #166534; }
[data-theme="light"] .status-badge-suboptimal { background: #fef3c7; color: #92400e; }
[data-theme="light"] .status-badge-high_risk { background: #fee2e2; color: #991b1b; }
[data-theme="light"] .status-badge-no_data  { background: #f3f4f6; color: #374151; }

/* =================================================================
   GLOBAL DARK-MODE INLINE-STYLE OVERRIDES
   Catches ALL templates using style="color:#64748b" etc. without
   needing to touch each template individually.
   ================================================================= */

/* ── Hardcoded muted-gray text → semantic readable muted ── */
html:not([data-theme="light"]) [style*="color: #64748b"],
html:not([data-theme="light"]) [style*="color:#64748b"],
html:not([data-theme="light"]) [style*="color: #475569"],
html:not([data-theme="light"]) [style*="color:#475569"],
html:not([data-theme="light"]) [style*="color: #6c757d"],
html:not([data-theme="light"]) [style*="color:#6c757d"],
html:not([data-theme="light"]) [style*="color: #495057"],
html:not([data-theme="light"]) [style*="color:#495057"],
html:not([data-theme="light"]) [style*="color: #374151"],
html:not([data-theme="light"]) [style*="color:#374151"] {
    color: var(--text-muted) !important;
}

/* ── Hardcoded near-white backgrounds → dark surface ── */
html:not([data-theme="light"]) [style*="background: #f8fafc"],
html:not([data-theme="light"]) [style*="background:#f8fafc"],
html:not([data-theme="light"]) [style*="background-color: #f8fafc"],
html:not([data-theme="light"]) [style*="background-color:#f8fafc"] {
    background: var(--bg-surface) !important;
    color: var(--text) !important;
}

/* =================================================================
   EMPLOYEE DASHBOARD — Dark-Mode Colored States
   Template classes with semantic (green/amber/red) tinted backgrounds
   ================================================================= */

html:not([data-theme="light"]) .op-areanow--ok .op-areanow__focus {
    background: #0d2318 !important; border-top-color: #166534 !important; color: #4ade80 !important;
}
html:not([data-theme="light"]) .op-areanow--warn .op-areanow__focus {
    background: #261e0a !important; border-top-color: #d97706 !important; color: #fbbf24 !important;
}
html:not([data-theme="light"]) .op-areanow--danger .op-areanow__focus {
    background: #2a0f0f !important; border-top-color: #dc2626 !important; color: #f87171 !important;
}
html:not([data-theme="light"]) .op-scorecard__focus--warn {
    background: #261e0a !important; border-top-color: #d97706 !important; color: #fbbf24 !important;
}
html:not([data-theme="light"]) .op-scorecard__focus--danger {
    background: #2a0f0f !important; border-top-color: #dc2626 !important; color: #f87171 !important;
}
html:not([data-theme="light"]) .op-areanow__badge--ok     { background: #14532d !important; color: #4ade80 !important; }
html:not([data-theme="light"]) .op-areanow__badge--warn   { background: #713f12 !important; color: #fbbf24 !important; }
html:not([data-theme="light"]) .op-areanow__badge--danger { background: #7f1d1d !important; color: #f87171 !important; }
html:not([data-theme="light"]) .op-attention-item--quiz {
    background: #2a220a !important; border-color: #854d0e !important; color: #fbbf24 !important;
}
html:not([data-theme="light"]) .op-attention-item--sop {
    background: #0f1e3a !important; border-color: #2563eb !important; color: #93c5fd !important;
}
html:not([data-theme="light"]) .op-attention-item--flag {
    background: #2a0f0f !important; border-color: #dc2626 !important; color: #f87171 !important;
}

/* ── Light-mode restore for employee dashboard states ── */
[data-theme="light"] .op-areanow--ok .op-areanow__focus     { background: #f0fdf4 !important; border-top-color: #bbf7d0 !important; color: #166534 !important; }
[data-theme="light"] .op-areanow--warn .op-areanow__focus   { background: #fffbeb !important; border-top-color: #fde68a !important; color: #92400e !important; }
[data-theme="light"] .op-areanow--danger .op-areanow__focus { background: #fef2f2 !important; border-top-color: #fecaca !important; color: #991b1b !important; }
[data-theme="light"] .op-scorecard__focus--warn             { background: #fffbeb !important; border-top-color: #fde68a !important; color: #92400e !important; }
[data-theme="light"] .op-scorecard__focus--danger           { background: #fef2f2 !important; border-top-color: #fecaca !important; color: #991b1b !important; }
[data-theme="light"] .op-areanow__badge--ok     { background: #dcfce7 !important; color: #166534 !important; }
[data-theme="light"] .op-areanow__badge--warn   { background: #fef9c3 !important; color: #92400e !important; }
[data-theme="light"] .op-areanow__badge--danger { background: #fee2e2 !important; color: #991b1b !important; }
[data-theme="light"] .op-attention-item--quiz   { background: #fef9c3 !important; border-color: #fde68a !important; color: #92400e !important; }
[data-theme="light"] .op-attention-item--sop    { background: #eff6ff !important; border-color: #bfdbfe !important; color: #1e40af !important; }
[data-theme="light"] .op-attention-item--flag   { background: #fee2e2 !important; border-color: #fecaca !important; color: #991b1b !important; }
