/* Reset + scrollbars (dark theme, Firefox + WebKit) */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: var(--border) var(--bg-secondary);
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 6px;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 6px;
    border: 2px solid var(--bg-secondary);
}

::-webkit-scrollbar-thumb:hover {
    background: #3f4254;
}

::-webkit-scrollbar-corner {
    background: var(--bg-secondary);
}

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #1e2130;
    --border: #2a2d3e;
    --text-primary: #e4e4e7;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --green: #22c55e;
    --red: #ef4444;
    --yellow: #eab308;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --mono: 'JetBrains Mono', 'Fira Code', monospace;
    --surface: #252838;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 0 1.5rem 1.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
}

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

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s;
}

.sidebar-nav a:hover { color: var(--text-primary); background: rgba(99, 102, 241, 0.08); }
.sidebar-nav a.active { color: var(--accent); background: rgba(99, 102, 241, 0.12); }

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Main content */
.main {
    margin-left: 240px;
    flex: 1;
    padding: 2rem;
    max-width: 1400px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.page-subtitle {
    font-size: 0.85rem;
    margin-bottom: 1.25rem;
    line-height: 1.4;
}

.section-note {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.02);
    border-left: 3px solid var(--border);
    border-radius: 0 0.25rem 0.25rem 0;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.25rem;
}

.card-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.card-value {
    font-size: 1.75rem;
    font-weight: 700;
    font-family: var(--mono);
}

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

/* Table */
.table-container { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

thead th {
    text-align: left;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tbody td {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid rgba(42, 45, 62, 0.5);
    font-family: var(--mono);
    font-size: 0.8125rem;
}

tbody tr:hover { background: rgba(99, 102, 241, 0.04); }

/* Utility */
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-muted { color: var(--text-muted); }
.text-mono { font-family: var(--mono); }
.text-bold { font-weight: 600; }

.table-wrapper {
    overflow-x: auto;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
}

.table-wrapper table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

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

.table-wrapper th {
    background: var(--surface);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    color: var(--text-muted);
    position: sticky;
    top: 0;
    z-index: 1;
}

.table-wrapper tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-open { background: rgba(34, 197, 94, 0.15); color: var(--green); }
.badge-closed { background: rgba(113, 113, 122, 0.15); color: var(--text-muted); }
.badge-resolved { background: rgba(99, 102, 241, 0.15); color: var(--accent); }
.badge-stopped { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.tab-bar { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; align-items: center; }
.dust-toggle { margin-left: auto; font-size: 0.8125rem; color: var(--text-muted); cursor: pointer; display: flex; align-items: center; gap: 0.375rem; padding: 0 0.5rem; }
.dust-toggle input { cursor: pointer; accent-color: var(--accent); }
.text-nowrap { white-space: nowrap; }
.stat-positive { color: var(--success) !important; }
.stat-negative { color: var(--danger) !important; }

.btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.15s;
}

.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger:hover { border-color: var(--red); color: var(--red); }

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-muted);
}

.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 0.5rem;
    padding: 1rem;
    color: var(--red);
    margin-bottom: 1rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.tab-btn {
    padding: 0.625rem 1.25rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    letter-spacing: 0.02em;
}

.tab-btn:hover {
    color: var(--text-secondary);
    background: rgba(99, 102, 241, 0.04);
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Tooltip */
.tooltip {
    position: relative;
    cursor: help;
    border-bottom: 1px dotted var(--text-muted);
}

.tooltip::after {
    content: attr(data-tip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 400;
    white-space: normal;
    width: max-content;
    max-width: 300px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    line-height: 1.4;
    text-transform: none;
    letter-spacing: normal;
}

.tooltip:hover::after {
    opacity: 1;
}

/* Progress bar */
.progress-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 0.25rem;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s;
}

.progress-fill.good { background: var(--green); }
.progress-fill.warn { background: var(--yellow); }
.progress-fill.bad { background: var(--red); }

/* Section divider */
.section-gap { margin-top: 1.5rem; }

/* City group header */
.city-group-header {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

/* Mini stats inside card */
.mini-stat {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.mini-stat-label {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.mini-stat-value {
    font-family: var(--mono);
    font-size: 1.125rem;
    font-weight: 700;
}

/* Filter bar */
.filter-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 0.25rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 9999px;
    background: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
}

.filter-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.filter-btn.active {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--accent);
    color: var(--accent);
}

/* Summary row inside table */
.summary-row td {
    background: var(--surface);
    font-weight: 600;
    border-top: 2px solid var(--border);
}

/* Progress bar (ML Workers) */
.progress-bar-container {
    position: relative;
    width: 100%;
    min-width: 80px;
    height: 20px;
    background: var(--surface-alt, #1a1a2e);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.3s;
}

.progress-bar-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-primary);
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.dismiss-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1;
    width: 1.5rem;
    height: 1.5rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    padding: 0;
}

.dismiss-btn:hover {
    border-color: var(--red);
    color: var(--red);
    background: rgba(239, 68, 68, 0.1);
}
