:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --neutral-50: #f9fafb;
    --neutral-100: #f3f4f6;
    --neutral-200: #e5e7eb;
    --neutral-300: #d1d5db;
    --neutral-400: #9ca3af;
    --neutral-500: #6b7280;
    --neutral-600: #4b5563;
    --neutral-700: #374151;
    --neutral-800: #1f2937;
    --neutral-900: #111827;
    --bg-body: #f0f4f8;
    --bg-card: #ffffff;
    --bg-sidebar: #1e293b;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --transition: all 0.3s ease;
    --sidebar-width: 260px;
}

[data-theme="dark"] {
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --bg-sidebar: #0f172a;
    --bg-input: #0f172a;
    --bg-table-stripe: #243044;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --neutral-100: #1e293b;
    --neutral-200: #334155;
    --neutral-300: #475569;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4);
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    margin: 0;
    transition: var(--transition);
}

.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo { font-size: 1.75rem; color: var(--primary); }
.sidebar-title { font-size: 1.25rem; font-weight: 700; }

.sidebar-nav { list-style: none; padding: 1rem 0; margin: 0; flex: 1; }
.sidebar-nav li { margin: 0.25rem 0.75rem; }
.sidebar-nav .nav-link {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.75rem 1rem; color: rgba(255,255,255,0.7);
    text-decoration: none; border-radius: 0.5rem;
    transition: var(--transition);
}
.sidebar-nav .nav-link:hover, .sidebar-nav .nav-link.active {
    background: rgba(37,99,235,0.2); color: #fff;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}
.user-info { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; }
.user-name { display: block; font-weight: 600; }
.user-role { display: block; opacity: 0.7; font-size: 0.75rem; }

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-bar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.page-title { font-size: 1.25rem; font-weight: 600; margin: 0; flex: 1; }
.sidebar-toggle { color: var(--text-primary); font-size: 1.25rem; }

.content-area { padding: 1.5rem; flex: 1; }

.login-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e293b 0%, #2563eb 100%);
}

.login-container { width: 100%; max-width: 420px; padding: 1rem; }
.login-card {
    background: var(--bg-card);
    border-radius: 1rem;
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
}

.login-header { text-align: center; margin-bottom: 2rem; }
.login-icon { font-size: 3rem; color: var(--primary); margin-bottom: 0.5rem; }
.demo-accounts { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }

.stat-card {
    background: var(--bg-card);
    border-radius: 0.75rem;
    padding: 1.25rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card .stat-icon {
    width: 48px; height: 48px; border-radius: 0.75rem;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem; margin-bottom: 0.75rem;
}
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label { color: var(--text-secondary); font-size: 0.85rem; margin-top: 0.25rem; }

.icon-blue { background: rgba(37,99,235,0.1); color: var(--primary); }
.icon-green { background: rgba(16,185,129,0.1); color: var(--success); }
.icon-amber { background: rgba(245,158,11,0.1); color: var(--warning); }
.icon-red { background: rgba(239,68,68,0.1); color: var(--danger); }

.chart-card {
    background: var(--bg-card);
    border-radius: 0.75rem;
    padding: 1.25rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}
.chart-card h5 { font-size: 0.95rem; font-weight: 600; margin-bottom: 1rem; }
.chart-container { position: relative; height: 280px; }

.request-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 1rem;
    transition: var(--transition);
}
.request-card:hover { box-shadow: var(--shadow-lg); border-color: var(--primary); }
.request-card.urgent-highlight { border-left: 4px solid var(--danger); }
.card-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }
.request-id { font-weight: 600; }
.card-body-row .detail { font-size: 0.875rem; margin-bottom: 0.25rem; color: var(--text-secondary); }
.card-body-row .detail strong { color: var(--text-primary); }
.card-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--border-color); }

.badge-stat { background: var(--danger) !important; color: #fff; }
.badge-urgent { background: var(--warning) !important; color: #fff; }
.badge-routine { background: var(--neutral-400) !important; color: #fff; }
.badge-pending { background: #6366f1 !important; color: #fff; }
.badge-progress { background: var(--primary) !important; color: #fff; }
.badge-completed { background: var(--success) !important; color: #fff; }
.badge-cancelled { background: var(--neutral-500) !important; color: #fff; }

.ai-score {
    display: inline-block; padding: 0.15rem 0.5rem;
    border-radius: 1rem; font-weight: 600; font-size: 0.8rem;
    background: rgba(37,99,235,0.15); color: var(--primary);
}

.ai-narrative {
    background: linear-gradient(135deg, rgba(37,99,235,0.05), rgba(16,185,129,0.05));
    border: 1px solid rgba(37,99,235,0.2);
    border-radius: 0.75rem;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.form-steps { display: flex; gap: 0; margin-bottom: 2rem; }
.form-step {
    flex: 1; text-align: center; padding: 0.75rem;
    background: var(--neutral-100); border-bottom: 3px solid var(--neutral-300);
    font-size: 0.85rem; font-weight: 500; color: var(--text-secondary);
    transition: var(--transition);
}
.form-step.active { border-bottom-color: var(--primary); color: var(--primary); background: rgba(37,99,235,0.05); }
.form-step.completed { border-bottom-color: var(--success); color: var(--success); }

.form-panel { display: none; }
.form-panel.active { display: block; animation: fadeIn 0.3s ease; }

.stain-suggestion {
    padding: 0.5rem 0.75rem; border-radius: 0.5rem;
    background: rgba(37,99,235,0.08); border: 1px solid rgba(37,99,235,0.2);
    margin-bottom: 0.5rem; cursor: pointer; transition: var(--transition);
    display: flex; justify-content: space-between; align-items: center;
}
.stain-suggestion:hover { background: rgba(37,99,235,0.15); }

.timeline { position: relative; padding-left: 2rem; }
.timeline::before {
    content: ''; position: absolute; left: 0.5rem; top: 0; bottom: 0;
    width: 2px; background: var(--border-color);
}
.timeline-item { position: relative; margin-bottom: 1.25rem; }
.timeline-item::before {
    content: ''; position: absolute; left: -1.65rem; top: 0.25rem;
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--primary); border: 2px solid var(--bg-card);
}

.timeline-special::before { background: #14b8a6; }
.timeline-special .timeline-item::before { background: #0d9488; }
.timeline-ihc::before { background: #3b82f6; }
.timeline-ihc .timeline-item::before { background: #2563eb; }

.timeline-card-header.timeline-special {
    border-left: 4px solid #0d9488;
    padding-left: calc(1rem - 4px);
}
.timeline-card-header.timeline-ihc {
    border-left: 4px solid #2563eb;
    padding-left: calc(1rem - 4px);
}
.timeline-stain-label {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
    margin-bottom: 0.15rem;
}
.timeline-stain-list .badge { font-weight: 500; }

.chat-widget { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 1050; }
.chat-toggle {
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--primary); color: #fff; border: none;
    font-size: 1.5rem; cursor: pointer;
    box-shadow: var(--shadow-lg); transition: var(--transition);
}
.chat-toggle:hover { transform: scale(1.1); background: var(--primary-dark); }
.chat-panel {
    display: none; position: absolute; bottom: 70px; right: 0;
    width: 350px; height: 450px;
    background: var(--bg-card); border-radius: 1rem;
    box-shadow: var(--shadow-lg); border: 1px solid var(--border-color);
    flex-direction: column; overflow: hidden;
}
.chat-panel.open { display: flex; }
.chat-header {
    background: var(--primary); color: #fff;
    padding: 0.75rem 1rem; display: flex;
    align-items: center; justify-content: space-between;
    font-weight: 600;
}
.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.chat-msg.typing {
    opacity: 0.75;
    font-style: italic;
}
.chat-messages { flex: 1; overflow-y: auto; padding: 1rem; }
.chat-msg { padding: 0.5rem 0.75rem; border-radius: 0.75rem; margin-bottom: 0.5rem; font-size: 0.875rem; max-width: 85%; }
.chat-msg.bot { background: var(--neutral-100); margin-right: auto; }
.chat-msg.user { background: var(--primary); color: #fff; margin-left: auto; }
.chat-input { display: flex; gap: 0.5rem; padding: 0.75rem; border-top: 1px solid var(--border-color); }

.heatmap-grid { display: grid; grid-template-columns: auto repeat(24, 1fr); gap: 2px; font-size: 0.65rem; }
.heatmap-cell { aspect-ratio: 1; border-radius: 2px; min-width: 12px; }
.heatmap-label { display: flex; align-items: center; padding-right: 4px; color: var(--text-secondary); }

.fade-in { animation: fadeIn 0.4s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.spinner-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.3);
    display: flex; align-items: center; justify-content: center; z-index: 9999;
}

.filters-bar {
    background: var(--bg-card); border-radius: 0.75rem;
    padding: 1rem; margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
}

.filter-tab-panel {
    margin-bottom: 1rem;
}

.filter-tab-panel-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0.45rem;
    padding-left: 0.15rem;
}

.path-filter-tabs,
.stain-category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.4rem;
    background: color-mix(in srgb, var(--neutral-200) 45%, var(--bg-card));
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.path-filter-tab,
.stain-category-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.95rem;
    border-radius: 0.75rem;
    border: 1px solid transparent;
    background: transparent;
    font-size: 0.84rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    color: var(--text-secondary);
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.stain-category-tab i {
    width: 1.65rem;
    height: 1.65rem;
    border-radius: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    background: color-mix(in srgb, var(--category-color, var(--primary)) 12%, transparent);
    color: var(--category-color, var(--primary));
    transition: background 0.2s ease, color 0.2s ease;
}

.stain-category-tab-special { --category-color: #0891b2; }
.stain-category-tab-ihc { --category-color: #2563eb; }

.path-filter-tab {
    --path-color: var(--primary);
    color: color-mix(in srgb, var(--path-color) 72%, var(--text-secondary));
}

.path-filter-tab::before {
    content: '';
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 999px;
    background: var(--path-color);
    opacity: 0.55;
    flex-shrink: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.path-filter-tab:hover,
.stain-category-tab:hover {
    color: var(--category-color, var(--path-color, var(--primary)));
    background: color-mix(in srgb, var(--category-color, var(--path-color, var(--primary))) 8%, var(--bg-card));
    transform: translateY(-1px);
}

.path-filter-tab:hover::before {
    opacity: 0.85;
}

.path-filter-tab.active,
.stain-category-tab.active {
    background: var(--bg-card);
    color: var(--category-color, var(--path-color, var(--primary)));
    border-color: color-mix(in srgb, var(--category-color, var(--path-color, var(--primary))) 22%, var(--border-color));
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 6px 18px color-mix(in srgb, var(--category-color, var(--path-color, var(--primary))) 12%, transparent);
}

.path-filter-tab.active::before {
    opacity: 1;
    transform: scale(1.15);
}

.stain-category-tab.active i {
    background: var(--category-color, var(--primary));
    color: #fff;
}

.path-filter-counts,
.stain-category-count {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--category-color, var(--path-color, var(--primary))) 10%, var(--bg-card));
    color: color-mix(in srgb, var(--category-color, var(--path-color, var(--primary))) 80%, var(--text-secondary));
}

.path-filter-tab.active .path-filter-counts,
.stain-category-tab.active .stain-category-count {
    background: color-mix(in srgb, var(--category-color, var(--path-color, var(--primary))) 14%, var(--bg-card));
    color: var(--category-color, var(--path-color, var(--primary)));
}

.workload-period-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1rem 1.1rem;
    height: 100%;
}

.workload-period-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
    color: var(--text-primary);
}

.workload-period-head span {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.workload-period-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.workload-period-stats strong {
    display: block;
    font-size: 1.35rem;
    line-height: 1.1;
    color: var(--text-primary);
}

.workload-period-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin-bottom: 0.2rem;
}

.workload-label-special,
.workload-col-special {
    color: #0891b2;
}

.workload-label-ihc,
.workload-col-ihc {
    color: #2563eb;
}

.workload-table .workload-group-head {
    background: rgba(37, 99, 235, 0.08);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.workload-table .workload-path-col {
    min-width: 10rem;
    white-space: nowrap;
}

.workload-table thead th {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.workload-table tbody tr:nth-child(even) {
    background: rgba(148, 163, 184, 0.06);
}

.workload-total-row th {
    background: rgba(37, 99, 235, 0.08);
    border-top: 2px solid var(--border-color);
}

[data-theme="dark"] .workload-period-card {
    background: var(--bg-card);
    border-color: var(--border-color);
}

[data-theme="dark"] .workload-table .workload-group-head,
[data-theme="dark"] .workload-total-row th {
    background: rgba(37, 99, 235, 0.15);
}

.queue-table .priority-stat { background: rgba(239,68,68,0.08); }
.queue-table .priority-urgent { background: rgba(245,158,11,0.08); }

.report-content {
    background: var(--bg-card); border-radius: 0.75rem;
    padding: 2rem; border: 1px solid var(--border-color);
    white-space: pre-wrap; line-height: 1.7;
}

.draft-box {
    background: var(--neutral-100);
    border: 1px solid var(--border-color);
}

.batch-bar {
    display: none; position: sticky; bottom: 0;
    background: var(--bg-card); border-top: 2px solid var(--primary);
    padding: 0.75rem 1rem; gap: 0.75rem; align-items: center;
    flex-wrap: wrap;
    z-index: 50; box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
}
.batch-bar-divider {
    width: 1px;
    align-self: stretch;
    min-height: 1.75rem;
    background: var(--border-color);
    margin: 0 0.25rem;
}
.label-printer-select { min-width: 11rem; max-width: 16rem; }

.btn-print-labels {
    --bs-btn-bg: #0891b2;
    --bs-btn-border-color: #0891b2;
    --bs-btn-hover-bg: #0e7490;
    --bs-btn-hover-border-color: #0e7490;
    --bs-btn-active-bg: #155e75;
    --bs-btn-active-border-color: #155e75;
    --bs-btn-color: #fff;
    --bs-btn-hover-color: #fff;
    --bs-btn-active-color: #fff;
    background-color: #0891b2;
    border-color: #0891b2;
    color: #fff;
}

.btn-print-labels:hover,
.btn-print-labels:focus {
    background-color: #0e7490;
    border-color: #0e7490;
    color: #fff;
}

/* Stain tag multi-select */
.stain-tag-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.stain-filter-btn {
    border: 2px solid transparent;
    cursor: pointer;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.stain-filter-btn:hover {
    transform: translateY(-1px);
}

.stain-filter-btn.stain-filter-active {
    box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px rgba(255, 255, 255, 0.85);
}

.stain-filter-btn.stain-tag-special.stain-filter-active {
    box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px #14b8a6;
}

.stain-filter-btn.stain-tag-ihc.stain-filter-active {
    box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px #3b82f6;
}

.stain-picker-combobox {
    position: relative;
}

.stain-suggestion-list {
    position: absolute;
    z-index: 20;
    top: calc(100% + 0.25rem);
    left: 0;
    right: 0;
    max-height: 240px;
    overflow-y: auto;
    margin: 0;
    padding: 0.35rem 0;
    list-style: none;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
}

.stain-suggestion-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.85rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-primary);
    border-left: 3px solid transparent;
}

.stain-suggestion-item.stain-tag-special {
    border-left-color: #14b8a6;
}

.stain-suggestion-item.stain-tag-ihc {
    border-left-color: #3b82f6;
}

.stain-suggestion-item:hover {
    background: var(--neutral-100);
}

.stain-suggestion-empty,
.stain-suggestion-more {
    padding: 0.65rem 0.85rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-style: italic;
}

.stain-tags-field .form-label {
    margin-bottom: 0.35rem;
}

.stain-tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    min-height: 52px;
    padding: 0.65rem 0.75rem;
    border: 1px dashed var(--border-color);
    border-radius: 0.5rem;
    background: var(--neutral-100);
}

.stain-tags-placeholder {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-style: italic;
}

.stain-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.2;
    color: #fff;
    white-space: nowrap;
}

.stain-tag-static {
    cursor: default;
    font-size: 0.75rem;
    opacity: 0.95;
}

.stain-tag-special {
    background: linear-gradient(135deg, #0d9488, #14b8a6);
    box-shadow: 0 1px 2px rgba(13, 148, 136, 0.35);
}

.stain-tag-ihc {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.35);
}

.stain-tag-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-left: 0.15rem;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease;
}

.stain-tag-remove:hover {
    background: rgba(255, 255, 255, 0.45);
}

.confirm-table td .stain-tag {
    margin: 0.15rem 0.25rem 0.15rem 0;
}

.selected-stain-summary {
    padding: 0.5rem 0.75rem;
    background: rgba(37, 99, 235, 0.08);
    border-radius: 0.5rem;
    border: 1px solid rgba(37, 99, 235, 0.2);
    color: var(--text-primary);
}

.confirm-table th {
    color: var(--text-secondary);
    vertical-align: top;
}

.batch-stains-list .list-group-item {
    background: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .chat-panel { width: calc(100vw - 2rem); right: -0.5rem; }
    .form-steps { flex-direction: column; }
}

@media print {
    .sidebar, .top-bar, .chat-widget, .filters-bar { display: none !important; }
    .main-content { margin-left: 0; }
}

/* Panel cards (Bootstrap card replacements) */
.panel-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.panel-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
}
.panel-card-header h5 { color: var(--text-primary); margin: 0; }
.panel-card-body { padding: 1.25rem; }

.stain-category-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stain-category-toolbar .stain-category-btn {
    flex: 1 1 12rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    font-weight: 600;
    border-width: 2px;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
}

.stain-category-toolbar .stain-category-btn-special {
    --bs-btn-bg: #0891b2;
    --bs-btn-border-color: #0891b2;
    --bs-btn-hover-bg: #0e7490;
    --bs-btn-hover-border-color: #0e7490;
    --bs-btn-active-bg: #155e75;
    --bs-btn-active-border-color: #155e75;
    --bs-btn-color: #fff;
    --bs-btn-hover-color: #fff;
    --bs-btn-active-color: #fff;
    background-color: #0891b2 !important;
    border-color: #0891b2 !important;
    color: #fff !important;
}

.stain-category-toolbar .stain-category-btn-special:hover,
.stain-category-toolbar .stain-category-btn-special:focus {
    background-color: #0e7490 !important;
    border-color: #0e7490 !important;
    color: #fff !important;
}

.stain-category-toolbar .stain-category-btn-ihc {
    --bs-btn-bg: #2563eb;
    --bs-btn-border-color: #2563eb;
    --bs-btn-hover-bg: #1d4ed8;
    --bs-btn-hover-border-color: #1d4ed8;
    --bs-btn-active-bg: #1e40af;
    --bs-btn-active-border-color: #1e40af;
    background-color: #2563eb !important;
    border-color: #2563eb !important;
    color: #fff !important;
}

.stain-category-toolbar .stain-category-btn-ihc:hover,
.stain-category-toolbar .stain-category-btn-ihc:focus {
    background-color: #1d4ed8 !important;
    border-color: #1d4ed8 !important;
    color: #fff !important;
}

.stain-category-toolbar .stain-category-btn[aria-expanded="true"] {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35), 0 4px 14px rgba(15, 23, 42, 0.18);
}

.stain-category-toolbar .stain-category-btn-special[aria-expanded="true"] {
    border-color: #67e8f9 !important;
}

.stain-category-toolbar .stain-category-btn-ihc[aria-expanded="true"] {
    border-color: #93c5fd !important;
}

.stain-category-btn-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.65rem;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.22);
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.2;
}

.stain-category-panel .table thead th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
    background: transparent;
}

.stain-category-empty {
    padding: 1rem 1.15rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ---- Dark mode: Bootstrap & component overrides ---- */
[data-theme="dark"] .card,
[data-theme="dark"] .panel-card {
    background: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .card-header,
[data-theme="dark"] .panel-card-header {
    background: rgba(0,0,0,0.15);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .card-body,
[data-theme="dark"] .panel-card-body {
    color: var(--text-primary);
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] .input-group-text {
    background-color: var(--bg-input);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background-color: var(--bg-input);
    border-color: var(--primary);
    color: var(--text-primary);
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.25);
}

[data-theme="dark"] .form-control::placeholder {
    color: var(--text-muted);
}

[data-theme="dark"] .form-label,
[data-theme="dark"] .form-check-label {
    color: var(--text-primary);
}

[data-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
    --bs-table-border-color: var(--border-color);
    --bs-table-striped-bg: var(--bg-table-stripe);
    --bs-table-striped-color: var(--text-primary);
    --bs-table-hover-bg: rgba(37, 99, 235, 0.08);
    --bs-table-hover-color: var(--text-primary);
    color: var(--text-primary);
}

[data-theme="dark"] .table thead th {
    background: rgba(0,0,0,0.2);
    color: var(--text-secondary);
    border-color: var(--border-color);
}

[data-theme="dark"] .table td,
[data-theme="dark"] .table th {
    border-color: var(--border-color);
}

[data-theme="dark"] .queue-table .priority-stat {
    background: rgba(239, 68, 68, 0.12);
}

[data-theme="dark"] .queue-table .priority-urgent {
    background: rgba(245, 158, 11, 0.12);
}

[data-theme="dark"] .dropdown-menu {
    background: var(--bg-card);
    border-color: var(--border-color);
}

[data-theme="dark"] .dropdown-item {
    color: var(--text-primary);
}

[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus {
    background: rgba(37, 99, 235, 0.15);
    color: var(--text-primary);
}

[data-theme="dark"] .pagination .page-link {
    background: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .pagination .page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
}

[data-theme="dark"] .pagination .page-item.disabled .page-link {
    background: var(--bg-card);
    color: var(--text-muted);
}

[data-theme="dark"] .text-muted {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .draft-box,
[data-theme="dark"] .bg-light {
    background-color: var(--neutral-100) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] pre {
    color: var(--text-primary);
}

[data-theme="dark"] .ai-narrative {
    background: linear-gradient(135deg, rgba(37,99,235,0.12), rgba(16,185,129,0.08));
    border-color: rgba(37,99,235,0.3);
    color: var(--text-primary);
}

[data-theme="dark"] .form-step {
    background: var(--neutral-100);
    border-bottom-color: var(--neutral-300);
    color: var(--text-secondary);
}

[data-theme="dark"] .form-step.active {
    background: rgba(37,99,235,0.12);
    color: var(--primary);
}

[data-theme="dark"] .stain-suggestion {
    background: rgba(37,99,235,0.12);
    border-color: rgba(37,99,235,0.3);
    color: var(--text-primary);
}

[data-theme="dark"] .stain-suggestion small {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .chat-msg.bot {
    background: var(--neutral-200);
    color: var(--text-primary);
}

[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

[data-theme="dark"] .btn-link,
[data-theme="dark"] .sidebar-toggle {
    color: var(--text-primary);
}

[data-theme="dark"] .btn-outline-primary {
    color: #60a5fa;
    border-color: #60a5fa;
}

[data-theme="dark"] .btn-outline-primary:hover {
    background: var(--primary);
    color: #fff;
}

[data-theme="dark"] .btn-outline-secondary {
    color: var(--text-secondary);
    border-color: var(--border-color);
}

[data-theme="dark"] .btn-outline-secondary:hover {
    background: var(--neutral-200);
    color: var(--text-primary);
}

[data-theme="dark"] .alert-warning {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.4);
    color: #fcd34d;
}

[data-theme="dark"] .alert-info {
    background: rgba(37, 99, 235, 0.15);
    border-color: rgba(37, 99, 235, 0.4);
    color: #93c5fd;
}

[data-theme="dark"] .alert-danger {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
    color: #fca5a5;
}

[data-theme="dark"] .alert-success {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.4);
    color: #6ee7b7;
}

[data-theme="dark"] .report-content:not(:has(.ai-report)) {
    background: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .batch-bar {
    background: var(--bg-card);
    box-shadow: 0 -4px 12px rgba(0,0,0,0.3);
}

[data-theme="dark"] .theme-toggle .form-check-input {
    background-color: var(--neutral-200);
    border-color: var(--border-color);
}

[data-theme="dark"] .theme-toggle .form-check-input:checked {
    background-color: var(--primary);
}

/* DataTables dark mode */
[data-theme="dark"] .dataTables_wrapper .dataTables_length,
[data-theme="dark"] .dataTables_wrapper .dataTables_filter,
[data-theme="dark"] .dataTables_wrapper .dataTables_info,
[data-theme="dark"] .dataTables_wrapper .dataTables_paginate {
    color: var(--text-secondary);
}

[data-theme="dark"] .dataTables_wrapper .dataTables_filter input,
[data-theme="dark"] .dataTables_wrapper .dataTables_length select {
    background: var(--bg-input);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] table.dataTable thead th {
    border-bottom-color: var(--border-color) !important;
}

[data-theme="dark"] table.dataTable.no-footer {
    border-bottom-color: var(--border-color);
}

[data-theme="dark"] .card.border-0.shadow-sm {
    background: var(--bg-card) !important;
    box-shadow: var(--shadow) !important;
}

[data-theme="dark"] code {
    color: #f472b6;
    background: rgba(0,0,0,0.3);
    padding: 0.1em 0.35em;
    border-radius: 0.25rem;
}

[data-theme="dark"] .path-filter-tabs,
[data-theme="dark"] .stain-category-tabs {
    background: color-mix(in srgb, var(--neutral-200) 70%, var(--bg-card));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

[data-theme="dark"] .path-filter-tab.active,
[data-theme="dark"] .stain-category-tab.active {
    background: color-mix(in srgb, var(--bg-card) 92%, #fff 8%);
}

[data-theme="dark"] .stain-category-btn[aria-expanded="true"] {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.12), 0 4px 14px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .stain-category-toolbar .stain-category-btn-special {
    background-color: #0891b2 !important;
    border-color: #0891b2 !important;
    color: #fff !important;
}

[data-theme="dark"] .stain-category-toolbar .stain-category-btn-ihc {
    background-color: #2563eb !important;
    border-color: #2563eb !important;
    color: #fff !important;
}

[data-theme="dark"] .login-card {
    background: var(--bg-card);
}

[data-theme="dark"] .login-card .text-muted {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] h1, [data-theme="dark"] h2, [data-theme="dark"] h3,
[data-theme="dark"] h4, [data-theme="dark"] h5, [data-theme="dark"] h6 {
    color: var(--text-primary);
}

[data-theme="dark"] .chart-card h5,
[data-theme="dark"] .page-title {
    color: var(--text-primary);
}

[data-theme="dark"] .stat-card .stat-value {
    color: var(--text-primary);
}

[data-theme="dark"] .request-id,
[data-theme="dark"] .card-body-row .detail strong {
    color: var(--text-primary);
}

[data-theme="dark"] .ai-score {
    background: rgba(37, 99, 235, 0.25);
    color: #93c5fd;
}

[data-theme="dark"] .badge-routine {
    background: var(--neutral-500) !important;
}

[data-theme="dark"] .stain-tags-container {
    background: rgba(0, 0, 0, 0.2);
    border-color: var(--border-color);
}

[data-theme="dark"] .stain-tag-special {
    background: linear-gradient(135deg, #0f766e, #0d9488);
}

[data-theme="dark"] .stain-tag-ihc {
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
}

[data-theme="dark"] .selected-stain-summary {
    background: rgba(37, 99, 235, 0.15);
    border-color: rgba(37, 99, 235, 0.35);
}

[data-theme="dark"] .list-group-item.active {
    background: var(--primary);
    border-color: var(--primary);
}

[data-theme="dark"] .batch-stains-list .list-group-item:not(.active):hover {
    background: rgba(37, 99, 235, 0.1);
}

[data-theme="dark"] a:not(.btn):not(.nav-link):not(.alert-link) {
    color: #60a5fa;
}

[data-theme="dark"] .alert-link {
    color: #93c5fd;
}

