/* =====================================================
   RESET & BASE
   ===================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
}

body {
    min-height: 100vh;
    overflow-x: hidden;
    font-family: 'Inter', -apple-system, sans-serif;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    transition: background 0.25s, color 0.25s;
}

/* =====================================================
   CSS VARIABLES
   ===================================================== */
:root {
    --accent: #5b73ff;
    --accent-2: #8b5cf6;
    --green: #10b981;
    --red: #f43f5e;
    --amber: #f59e0b;
    --cyan: #06b6d4;
    --orange: #fb923c;

    --green-dim: rgba(16, 185, 129, 0.12);
    --red-dim: rgba(244, 63, 94, 0.12);
    --amber-dim: rgba(245, 158, 11, 0.12);
    --accent-dim: rgba(91, 115, 255, 0.12);
    --orange-dim: rgba(251, 146, 60, 0.12);

    --bg: #0a0c12;
    --surface: #111318;
    --surface-2: #181b23;
    --surface-3: #1e2230;
    --border: #242840;
    --border-sub: #1a1d2e;
    --text: #e2e8f0;
    --text-sec: #94a3b8;
    --text-muted: #475569;
    --grid-clr: rgba(36, 40, 64, 0.9);
    --tick-clr: #475569;
}

[data-theme="light"] {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f5f9;
    --border: #e2e8f0;
    --border-sub: #e8edf5;
    --text: #0f172a;
    --text-sec: #475569;
    --text-muted: #94a3b8;
    --grid-clr: rgba(226, 232, 240, 0.9);
    --tick-clr: #94a3b8;
}

/* =====================================================
   LOADING OVERLAY
   ===================================================== */
.app-loading {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 12, 18, 0.55);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    opacity: 1;
    visibility: visible;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

[data-theme="light"] .app-loading {
    background: rgba(241, 245, 249, 0.75);
}

.app-loading.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.app-loading-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 32px 42px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.app-loading-ring {
    width: 42px;
    height: 42px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: app-loading-spin 0.8s linear infinite;
}

@keyframes app-loading-spin {
    to { transform: rotate(360deg); }
}

.app-loading-count {
    font-family: 'JetBrains Mono', monospace;
    font-size: 34px;
    font-weight: 700;
    letter-spacing: -1px;
    color: var(--text);
}

.app-loading-count::after {
    content: '%';
    font-size: 18px;
    font-weight: 600;
    color: var(--text-muted);
    margin-left: 2px;
}

.app-loading-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-sec);
}

.app-loading-bar-track {
    width: 180px;
    height: 5px;
    overflow: hidden;
    background: var(--surface-3);
    border-radius: 4px;
}

.app-loading-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    border-radius: 4px;
    transition: width 0.15s ease;
}

/* =====================================================
   HEADER
   ===================================================== */
.header {
    position: sticky;
    top: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 28px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--accent);
}

.logo svg {
    width: 15px;
    height: 15px;
}

.header-logo {
    flex-shrink: 0;
    height: 22px;
    width: auto;
}

.header-title {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.2px;
    white-space: nowrap;
}

.header-partner-logos {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    margin-left: 18px;
    padding-left: 18px;
    border-left: 1px solid var(--border-sub);
}

.header-partner-logos img {
    height: 18px;
    width: auto;
    object-fit: contain;
}

.logo-for-light {
    display: none;
}

[data-theme="light"] .logo-for-dark {
    display: none;
}

[data-theme="light"] .logo-for-light {
    display: inline;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 7px;
}

.header-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-sec);
    cursor: pointer;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 7px;
    transition: all 0.15s ease;
}

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

.header-btn.on {
    color: var(--accent);
    background: var(--accent-dim);
    border-color: var(--accent);
}

.btn-logout {
    color: var(--red);
    background: var(--red-dim);
    border-color: rgba(244, 63, 94, 0.3);
}

.btn-logout:hover {
    color: #fff;
    background: var(--red);
    border-color: var(--red);
}

.badge-live {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    color: var(--green);
    white-space: nowrap;
    cursor: pointer;
    background: var(--green-dim);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 6px;
    transition: opacity 0.15s ease;
}

.badge-live:hover {
    opacity: 0.8;
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* =====================================================
   MENU TABS
   ===================================================== */
.menu-tabs {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 28px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-sub);
}

.menu-tab {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: -1px;
    padding: 11px 18px;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    transition: all 0.15s ease;
}

.menu-tab:hover {
    color: var(--text-sec);
}

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

.menu-tab-icon {
    flex-shrink: 0;
    width: 15px;
    height: 15px;
}

/* =====================================================
   FILTER BAR
   ===================================================== */
.filter-bar,
.mtm-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
    padding: 10px 28px;
    min-height: 67px;
    box-sizing: border-box;
    background: var(--surface);
    border-bottom: 1px solid var(--border-sub);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-label {
    padding-left: 2px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.9px;
    color: var(--text-muted);
}

.filter-group-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-separator {
    width: 1px;
    height: 22px;
    margin: 0 2px;
    background: var(--border-sub);
}

.filter-bar select,
.mtm-filter-bar select,
.date-input {
    height: 30px;
    box-sizing: border-box;
    padding: 5px 28px 5px 10px;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    color: var(--text);
    cursor: pointer;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 7px;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2394a3b8'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 9px center;
    transition: border-color 0.15s ease;
}

.date-input {
    width: 130px;
    padding: 5px 10px;
    background-image: none;
}

.filter-bar select:hover,
.filter-bar select:focus,
.mtm-filter-bar select:hover,
.mtm-filter-bar select:focus,
.date-input:hover,
.date-input:focus {
    border-color: var(--accent);
}

.filter-bar select:disabled,
.mtm-filter-bar select:disabled,
.date-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.date-range-label {
    font-size: 11px;
    color: var(--text-muted);
}

.filter-date-error {
    display: none;
    padding-left: 2px;
    font-size: 10.5px;
    font-weight: 600;
    color: var(--red);
}

.filter-date-error.show {
    display: block;
}

.date-input.invalid {
    border-color: var(--red) !important;
}

.filter-reset {
    height: 30px;
    padding: 5px 12px;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 7px;
    transition: all 0.15s ease;
}

.filter-reset:hover {
    color: var(--red);
    border-color: var(--red);
}

.filter-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.download-dropdown {
    position: relative;
}

.filter-download {
    display: flex;
    align-items: center;
    height: 30px;
    gap: 6px;
    padding: 5px 12px;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 7px;
    transition: opacity 0.15s ease;
}

.filter-download:hover {
    opacity: 0.9;
}

.filter-download svg {
    flex-shrink: 0;
    width: 13px;
    height: 13px;
}

.download-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 50;
    display: none;
    flex-direction: column;
    min-width: 160px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 9px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

.download-menu.is-open {
    display: flex;
}

.download-menu-item {
    padding: 7px 10px;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 500;
    text-align: left;
    color: var(--text-sec);
    cursor: pointer;
    background: transparent;
    border: none;
    border-radius: 6px;
    transition: background 0.15s ease, color 0.15s ease;
}

.download-menu-item:hover {
    color: var(--accent);
    background: var(--accent-dim);
}

/* =====================================================
   MAIN LAYOUT
   ===================================================== */
.main {
    padding: 22px 28px 48px;
}

.menu-panel {
    display: none;
}

.menu-panel.active {
    display: block;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 7px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-sub);
}

.section-badge {
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: var(--accent);
    background: var(--accent-dim);
    border-radius: 4px;
}

/* =====================================================
   KPI GRID
   ===================================================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 24px;
}

.kpi-card {
    position: relative;
    padding: 16px 18px;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border-sub);
    border-radius: 11px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
    border-color: var(--border);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.kpi-bar {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 3px;
    border-radius: 11px 0 0 11px;
    background: var(--kpi-color, var(--accent));
}

.kpi-label {
    margin-bottom: 7px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
}

.kpi-value {
    margin-bottom: 5px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -1px;
    color: var(--kpi-color, var(--text));
}

.kpi-sub {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-muted);
}

.kpi-dot {
    flex-shrink: 0;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--kpi-color, var(--accent));
}

.kpi-delta {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-top: 5px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 700;
    border-radius: 4px;
}

.kpi-delta.up {
    color: var(--red);
    background: var(--red-dim);
}

.kpi-delta.down {
    color: var(--green);
    background: var(--green-dim);
}

.kpi-delta.neutral {
    color: var(--accent);
    background: var(--accent-dim);
}

.kpi-delta.up-good {
    color: var(--green);
    background: var(--green-dim);
}

.kpi-delta.down-bad {
    color: var(--red);
    background: var(--red-dim);
}

.kpi-compare {
    margin-top: 3px;
    font-size: 10px;
    color: var(--text-muted);
}

/* =====================================================
   ESCALATION PANEL
   ===================================================== */
.escalation-panel {
    margin-bottom: 24px;
    padding: 18px 20px;
    background: var(--surface);
    border: 1px solid var(--border-sub);
    border-radius: 11px;
}

.escalation-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-top: 14px;
}

.esc-card {
    min-width: 0;
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border-sub);
    border-radius: 8px;
}

.esc-card-label {
    margin-bottom: 5px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
}

.esc-card-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 22px;
    font-weight: 700;
}

.esc-card-sub {
    margin-top: 3px;
    font-size: 11px;
    color: var(--text-muted);
}

.esc-rows {
    display: flex;
    flex-direction: column;
    gap: 9px;
    margin-top: 14px;
}

.esc-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.esc-row-label {
    min-width: 90px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
}

.esc-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 5px;
}

.esc-active-detail {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border-sub);
}

.esc-active-title {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--orange);
}

.esc-active-title::before {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--orange);
    animation: pulse 2s infinite;
    content: '';
}

.esc-table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-sub);
    border-radius: 8px;
}

.esc-table {
    width: 100%;
    font-size: 12px;
    border-collapse: collapse;
}

.esc-table thead tr {
    background: var(--surface-3);
}

.esc-table th {
    padding: 9px 12px;
    font-size: 10px;
    font-weight: 700;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    white-space: nowrap;
    border-bottom: 1px solid var(--border-sub);
}

.esc-table td {
    padding: 10px 12px;
    vertical-align: middle;
    color: var(--text-sec);
    border-bottom: 1px solid var(--border-sub);
}

.esc-table tr:last-child td {
    border-bottom: none;
}

.esc-table tbody tr {
    transition: background 0.15s ease;
}

.esc-table tbody tr:hover {
    background: var(--surface-2);
}

.esc-client {
    max-width: 200px;
    font-weight: 600;
    color: var(--text);
}

.esc-client-full {
    margin-top: 2px;
    font-size: 11px;
    color: var(--text-muted);
}

.esc-problem {
    max-width: 260px;
    line-height: 1.4;
}

.esc-pri-badge {
    padding: 2px 7px;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
    border-radius: 4px;
}

.esc-prod-badge {
    padding: 2px 7px;
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
    border-radius: 4px;
}

.esc-date {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    white-space: nowrap;
}

/* =====================================================
   CHART GRID
   ===================================================== */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 12px;
}

.chart-wide {
    grid-column: 1 / -1;
}

.chart-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.chart-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 0px;
}

@media (max-width: 1300px) {
    .chart-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    .chart-grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

.chart-card {
    min-width: 0;
    padding: 18px 20px;
    background: var(--surface);
    border: 1px solid var(--border-sub);
    border-radius: 11px;
}

.chart-header {
    margin-bottom: 14px;
}

.chart-title {
    margin-bottom: 2px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.chart-subtitle {
    font-size: 11px;
    color: var(--text-muted);
}

.chart-wrapper {
    position: relative;
    width: 100%;
    height: 200px;
}

.chart-wrapper-md {
    position: relative;
    width: 100%;
    height: 230px;
}

.chart-wrapper-tall {
    position: relative;
    width: 100%;
    height: 260px;
}

.chart-wrapper canvas,
.chart-wrapper-md canvas,
.chart-wrapper-tall canvas {
    max-width: 100% !important;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    font-size: 11px;
    color: var(--text-sec);
    background: var(--surface-2);
    border-radius: 5px;
}

.legend-dot {
    flex-shrink: 0;
    width: 8px;
    height: 8px;
    border-radius: 2px;
}

/* =====================================================
   TREND COMPARISON
   ===================================================== */
.trend-comparison {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding-top: 11px;
    border-top: 1px solid var(--border-sub);
}

.trend-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 5px;
}

.trend-badge.up {
    color: var(--red);
    background: var(--red-dim);
}

.trend-badge.down {
    color: var(--green);
    background: var(--green-dim);
}

.trend-badge.flat {
    color: var(--accent);
    background: var(--accent-dim);
}

.trend-context {
    font-size: 11px;
    color: var(--text-muted);
}

/* =====================================================
   TASK SECTION
   ===================================================== */
.task-stats {
    grid-template-columns: repeat(4, 1fr);
    margin-bottom: 14px;
}

.task-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.task-search {
    width: 220px;
    padding: 6px 12px;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 7px;
    outline: none;
    transition: border-color 0.15s ease;
}

.task-search:focus {
    border-color: var(--accent);
}

.task-filters select {
    padding: 6px 28px 6px 10px;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    color: var(--text);
    cursor: pointer;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 7px;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2394a3b8'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 9px center;
    transition: border-color 0.15s ease;
}

.task-filters select:hover,
.task-filters select:focus {
    border-color: var(--accent);
}

.task-table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-sub);
    border-radius: 8px;
}

.task-table {
    width: 100%;
    font-size: 12px;
    border-collapse: collapse;
}

.task-table thead tr {
    background: var(--surface-3);
}

.task-table th {
    padding: 9px 12px;
    font-size: 10px;
    font-weight: 700;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    white-space: nowrap;
    border-bottom: 1px solid var(--border-sub);
}

.task-table td {
    padding: 9px 12px;
    vertical-align: middle;
    color: var(--text-sec);
    border-bottom: 1px solid var(--border-sub);
}

.task-table tr:last-child td {
    border-bottom: none;
}

.task-table tbody tr {
    transition: background 0.15s ease;
}

.task-table tbody tr:hover {
    background: var(--surface-2);
}

.task-name {
    max-width: 280px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text);
}

.task-staff-cell {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.task-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    font-size: 9px;
    font-weight: 700;
    color: #fff;
    background: var(--accent);
    border-radius: 50%;
}

.task-status-badge {
    padding: 3px 8px;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
    border-radius: 4px;
}

.task-tag {
    padding: 2px 7px;
    font-size: 10px;
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
    background: var(--accent-dim);
    border-radius: 4px;
}

.task-duration {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-sec);
    white-space: nowrap;
}

.task-date {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.task-empty {
    padding: 24px;
    font-size: 13px;
    text-align: center;
    color: var(--text-muted);
}

/* =====================================================
   PAGINATION
   ===================================================== */
.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 4px 2px;
}

.pagination-info {
    font-size: 11px;
    color: var(--text-muted);
}

.pagination-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination-btn {
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-sec);
    cursor: pointer;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    transition: all 0.15s ease;
}

.pagination-btn:hover:not(:disabled) {
    color: var(--accent);
    border-color: var(--accent);
}

.pagination-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.pagination-btn.active {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
}

.pagination-ellipsis {
    padding: 0 2px;
    font-size: 12px;
    color: var(--text-muted);
}

/* =====================================================
   TOP CLIENT TABLE
   ===================================================== */
.top-client-table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-sub);
    border-radius: 8px;
}

.top-client-table {
    width: 100%;
    font-size: 12px;
    border-collapse: collapse;
}

.top-client-table thead tr {
    background: var(--surface-3);
}

.top-client-table th {
    padding: 9px 12px;
    font-size: 10px;
    font-weight: 700;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    white-space: nowrap;
    border-bottom: 1px solid var(--border-sub);
}

.top-client-table td {
    padding: 9px 12px;
    vertical-align: middle;
    color: var(--text-sec);
    border-bottom: 1px solid var(--border-sub);
}

.top-client-table tr:last-child td {
    border-bottom: none;
}

.top-client-table tbody tr {
    cursor: pointer;
    transition: background 0.15s ease;
}

.top-client-table tbody tr:hover {
    background: var(--surface-2);
}

.top-client-table .tc-col-num {
    width: 36px;
    color: var(--text-muted);
    font-weight: 600;
}

.top-client-table td.tc-col-name {
    font-weight: 600;
    color: var(--text);
}

.top-client-table .tc-col-total {
    text-align: right;
}

.top-client-table td.tc-col-total {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    color: var(--text);
}

/* =====================================================
   FOOTER
   ===================================================== */
.footer {
    padding: 18px 28px;
    font-size: 11px;
    text-align: center;
    color: var(--text-muted);
    border-top: 1px solid var(--border-sub);
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 1100px) {
    .kpi-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .escalation-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 900px) {
    .chart-grid,
    .chart-grid-4,
    .chart-grid-3 {
        grid-template-columns: 1fr;
    }
    .chart-wide {
        grid-column: 1;
    }
    .mtm-filter-bar {
        margin: -22px -20px 22px;
    }
}

@media (max-width: 820px) {
    .header,
    .filter-bar {
        padding-right: 16px;
        padding-left: 16px;
    }
    .menu-tabs {
        padding: 0 16px;
    }
    .main {
        padding: 16px;
    }
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .task-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    .escalation-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    .mtm-filter-bar {
        margin: -16px -16px 22px;
    }
}

@media (max-width: 680px) {
    .header {
        flex-wrap: wrap;
        height: auto;
        row-gap: 8px;
        padding-top: 10px;
        padding-bottom: 10px;
    }
    .header-right {
        flex-wrap: wrap;
        row-gap: 6px;
    }
    .menu-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .menu-tabs::-webkit-scrollbar {
        display: none;
    }
    .menu-tab {
        flex-shrink: 0;
        padding: 11px 14px;
    }
    .incident-btn {
        margin-left: auto;
    }
    .filter-bar,
    .mtm-filter-bar {
        flex-direction: column;
        align-items: stretch;
        min-height: 0;
    }
    .filter-group-row {
        flex-wrap: wrap;
    }
    .filter-bar select,
    .mtm-filter-bar select,
    .date-input {
        flex: 1 1 120px;
    }
    .filter-separator {
        display: none;
    }
    .filter-reset {
        align-self: flex-start;
    }
    .filter-actions {
        width: 100%;
        margin-left: 0;
        justify-content: space-between;
    }
    .chart-grid {
        grid-template-columns: 1fr;
    }
    .escalation-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    .task-filters {
        flex-direction: column;
        align-items: stretch;
    }
    .task-search {
        width: 100%;
    }
    .task-filters select {
        width: 100%;
    }
    .pagination {
        flex-direction: column;
        align-items: flex-start;
    }
    .pagination-buttons {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .header-title {
        font-size: 13px;
    }
    .header-btn {
        padding: 5px 8px;
        font-size: 11px;
    }
    .kpi-grid,
    .task-stats {
        grid-template-columns: 1fr;
    }
    .escalation-stats {
        grid-template-columns: 1fr;
    }
    .esc-row {
        flex-direction: column;
        align-items: flex-start;
    }
    .esc-row-label {
        min-width: 0;
    }
    .chart-card {
        padding: 14px;
    }
    .chart-wrapper,
    .chart-wrapper-md,
    .chart-wrapper-tall {
        height: 200px;
    }
    .login-box {
        width: 90vw;
        padding: 28px 20px;
    }
    .esc-table th,
    .esc-table td,
    .task-table th,
    .task-table td,
    .mtm-table th,
    .mtm-table td {
        padding: 8px;
        font-size: 11px;
    }
    .footer {
        padding: 16px;
        font-size: 10.5px;
        line-height: 1.5;
    }
}

@media (max-width: 360px) {
    .filter-bar select,
    .mtm-filter-bar select,
    .date-input {
        flex-basis: 100%;
    }
    .date-range-label {
        display: block;
        text-align: center;
    }
}

/* =====================================================
   LOGIN SCREEN
   ===================================================== */
.login-screen {
    position: fixed;
    inset: 0;
    z-index: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.login-screen.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.login-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 320px;
    padding: 36px 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    margin-bottom: 4px;
    border-radius: 10px;
    background: var(--accent);
}

.login-logo svg {
    width: 20px;
    height: 20px;
}

.login-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.login-subtitle {
    margin-bottom: 10px;
    font-size: 12px;
    color: var(--text-sec);
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 100%;
}

.login-field label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
}

.login-field input {
    width: 100%;
    padding: 9px 12px;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.15s ease;
}

.login-field input:focus {
    border-color: var(--accent);
}

.login-error {
    min-height: 14px;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    color: var(--red);
}

.login-btn {
    width: 100%;
    padding: 10px;
    margin-top: 4px;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    transition: opacity 0.15s ease;
}

.login-btn:hover {
    opacity: 0.9;
}

/* =====================================================
   MONTH-TO-MONTH COMPARISON
   ===================================================== */
.mtm-filter-bar {
    margin: -22px -28px 22px;
}

.mtm-empty {
    padding: 48px 24px;
    font-size: 13px;
    text-align: center;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: 11px;
}

.mtm-table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-sub);
    border-radius: 8px;
}

.mtm-table {
    width: 100%;
    font-size: 12px;
    border-collapse: collapse;
}

.mtm-table thead tr {
    background: var(--surface-3);
}

.mtm-table th {
    padding: 9px 12px;
    font-size: 10px;
    font-weight: 700;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    white-space: nowrap;
    border-bottom: 1px solid var(--border-sub);
}

.mtm-table td {
    padding: 10px 12px;
    vertical-align: top;
    color: var(--text-sec);
    border-bottom: 1px solid var(--border-sub);
    white-space: nowrap;
}

.mtm-table tr:last-child td {
    border-bottom: none;
}

.mtm-row-label {
    font-weight: 600;
    color: var(--text);
}

.mtm-cell-value {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    color: var(--text);
}

.mtm-cell-delta {
    margin-top: 3px;
}

/* =====================================================
   MODAL — TOP CLIENT PROBLEM DETAIL
   ===================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(10, 12, 18, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

[data-theme="light"] .modal-overlay {
    background: rgba(15, 23, 42, 0.4);
}

.modal-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

.modal-box {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1280px;
    max-height: 80vh;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    transform: translateY(8px);
    transition: transform 0.2s ease;
}

.modal-overlay.is-open .modal-box {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-sub);
}

.modal-title {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.4;
    color: var(--text);
}

.modal-close {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    font-size: 18px;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 7px;
    transition: all 0.15s ease;
}

.modal-close:hover {
    color: var(--red);
    border-color: var(--red);
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px 18px;
    overflow-y: auto;
}

.modal-problem-item {
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border-sub);
    border-radius: 9px;
}

.modal-problem-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 7px;
}

.modal-problem-date {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-muted);
}

.modal-problem-sociomile {
    padding: 2px 7px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-dim);
    border-radius: 4px;
}

.modal-crm-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-left: auto;
    color: var(--text-muted);
    cursor: pointer;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 5px;
    transition: all 0.15s ease;
}

.modal-crm-link svg {
    width: 12px;
    height: 12px;
}

.modal-crm-link:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.modal-problem-text {
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-sec);
}

/* =====================================================
   AUTO SCROLL PANEL
   ===================================================== */
.autoscroll-panel {
    position: fixed;
    top: 50%;
    right: 14px;
    transform: translateY(-50%);
    z-index: 900;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 8px 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
    opacity: 0.9;
}

.autoscroll-panel.is-visible {
    display: flex;
}

.autoscroll-speeds {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.as-speed-bar {
    height: 5px;
    padding: 0;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.as-speed-bar:hover {
    border-color: var(--accent);
}

.as-speed-bar.active {
    background: var(--accent);
    border-color: var(--accent);
}

.as-speed-bar.as1 { width: 28px; }
.as-speed-bar.as2 { width: 22px; }
.as-speed-bar.as3 { width: 17px; }
.as-speed-bar.as4 { width: 12px; }
.as-speed-bar.as5 { width: 7px; }

.as-playstop-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-top: 2px;
    font-size: 10px;
    color: var(--accent);
    cursor: pointer;
    background: var(--accent-dim);
    border: 1px solid rgba(91, 115, 255, 0.3);
    border-radius: 6px;
    transition: all 0.15s ease;
}

.as-playstop-btn:hover {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
}

.as-playstop-btn.is-playing {
    color: var(--red);
    background: var(--red-dim);
    border-color: rgba(244, 63, 94, 0.3);
}

.as-playstop-btn.is-playing:hover {
    color: #fff;
    background: var(--red);
    border-color: var(--red);
}

/* =====================================================
   INCIDENT RECORD BUTTON
   ===================================================== */
.incident-btn {
    display: flex;
    align-items: center;
    align-self: center;
    height: 30px;
    gap: 7px;
    margin-left: auto;
    padding: 5px 12px;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 700;
    color: var(--red);
    cursor: pointer;
    background: var(--red-dim);
    border: 1px solid rgba(244, 63, 94, 0.35);
    border-radius: 8px;
    transition: all 0.15s ease;
}

.incident-btn:hover {
    background: var(--red);
    color: #fff;
}

.incident-btn:hover .incident-btn-dot {
    background: #fff;
}

.incident-btn-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--red);
    flex-shrink: 0;
}

.incident-btn.is-recording {
    color: #fff;
    background: var(--red);
    border-color: var(--red);
}

.incident-btn.is-recording .incident-btn-dot {
    background: #fff;
    animation: pulse 1s infinite;
}

.incident-btn-timer {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11.5px;
    font-weight: 700;
    padding-left: 6px;
    border-left: 1px solid rgba(255, 255, 255, 0.4);
}

/* =====================================================
   INCIDENT MODAL
   ===================================================== */
.incident-modal-box {
    max-width: 460px;
}

.incident-form-summary {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 14px;
    padding: 10px 12px;
    font-size: 12px;
    color: var(--text-sec);
    background: var(--surface-2);
    border: 1px solid var(--border-sub);
    border-radius: 8px;
}

.incident-form-summary strong {
    font-family: 'JetBrains Mono', monospace;
    color: var(--text);
}

#incidentForm .login-field {
    margin-bottom: 12px;
}

#incidentForm select,
#incidentForm textarea {
    width: 100%;
    padding: 9px 12px;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    resize: vertical;
    transition: border-color 0.15s ease;
}

#incidentForm select:focus,
#incidentForm textarea:focus {
    border-color: var(--accent);
}

.incident-form-error {
    min-height: 14px;
    margin-bottom: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--red);
}

.incident-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.incident-form-actions .login-btn {
    width: auto;
    margin-top: 0;
    padding: 9px 18px;
}