/* ==================== EF DESIGN TOKENS ==================== */
:root {
    /* Typography */
    --ef-font: 'Inter', ui-sans-serif, system-ui, "Segoe UI", Roboto, Arial, sans-serif;
    --ef-mono: 'JetBrains Mono', ui-monospace, monospace;
    --ef-text-24: 24px;
    --ef-text-18: 18px;
    --ef-text-14: 14px;
    --ef-text-13: 13px;
    --ef-text-12: 12px;
    --ef-text-11: 11px;

    /* Spacing */
    --ef-space-4: 4px;
    --ef-space-8: 8px;
    --ef-space-12: 12px;
    --ef-space-16: 16px;
    --ef-space-24: 24px;
    --ef-space-32: 32px;

    /* Border Radius */
    --ef-radius-4: 4px;
    --ef-radius-6: 6px;
    --ef-radius-10: 10px;
    --ef-radius-14: 14px;

    /* Elevation */
    --ef-shadow-1: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --ef-shadow-2: 0 4px 12px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);

    /* Primary */
    --ef-color-primary: #2563eb;
    --ef-color-primary-hover: #1d4ed8;
    --ef-color-primary-bg: rgba(37,99,235,0.08);
    --ef-color-primary-light: rgba(37,99,235,0.25);
    --ef-color-focus: rgba(37,99,235,0.4);

    /* Danger */
    --ef-color-danger: #dc2626;
    --ef-color-danger-hover: #b91c1c;

    /* Semantic Colors */
    --ef-green: #16a34a;     --ef-green-bg: rgba(22,163,74,0.08);    --ef-green-text: #15803d;
    --ef-yellow: #d97706;    --ef-yellow-bg: rgba(217,119,6,0.08);   --ef-yellow-text: #b45309;
    --ef-red: #dc2626;       --ef-red-bg: rgba(220,38,38,0.08);      --ef-red-text: #b91c1c;
    --ef-blue: #2563eb;      --ef-blue-bg: rgba(37,99,235,0.08);     --ef-blue-text: #1d4ed8;
}

/* ==================== THEME VARIABLES ==================== */
:root[data-theme="light"] {
    --ef-bg: #f8f9fb;
    --ef-surface: #ffffff;
    --ef-surface-2: #f1f3f5;
    --ef-text: #1e293b;
    --ef-text-muted: #64748b;
    --ef-border: #e2e8f0;

    /* Backward-compat aliases */
    --primary: var(--ef-color-primary);
    --primary-light: var(--ef-color-primary-hover);
    --primary-dark: #1e40af;
    --accent: var(--ef-color-primary-hover);
    --bg-dark: var(--ef-surface);
    --bg-med: var(--ef-surface-2);
    --bg-light: #e8ecf1;
    --text-primary: var(--ef-text);
    --text-secondary: var(--ef-text-muted);
    --border: var(--ef-border);
    --success: var(--ef-green);
    --warning: var(--ef-yellow);
    --danger: var(--ef-red);
    --shadow: rgba(0, 0, 0, 0.06);
    --bg-gradient-start: var(--ef-bg);
    --bg-gradient-end: var(--ef-bg);
}

:root[data-theme="dark"] {
    --ef-bg: #0f172a;
    --ef-surface: #1e293b;
    --ef-surface-2: #253249;
    --ef-text: #e2e8f0;
    --ef-text-muted: #94a3b8;
    --ef-border: #334155;

    /* Backward-compat aliases */
    --primary: var(--ef-color-primary);
    --primary-light: #60a5fa;
    --primary-dark: #1e40af;
    --accent: #60a5fa;
    --bg-dark: var(--ef-surface);
    --bg-med: var(--ef-surface-2);
    --bg-light: #334155;
    --text-primary: var(--ef-text);
    --text-secondary: var(--ef-text-muted);
    --border: var(--ef-border);
    --success: var(--ef-green);
    --warning: var(--ef-yellow);
    --danger: var(--ef-red);
    --shadow: rgba(0, 0, 0, 0.3);
    --bg-gradient-start: var(--ef-bg);
    --bg-gradient-end: #0a1628;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--ef-font);
    background: var(--ef-bg);
    color: var(--ef-text);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
    transition: background 150ms, color 150ms;
}

.header {
    background: var(--ef-surface);
    border-bottom: 1px solid var(--ef-border);
    padding: var(--ef-space-12) var(--ef-space-24);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    height: 48px;
    display: flex;
    align-items: center;
    transition: background 150ms;
}

.header-content {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.header h1 {
    font-family: var(--ef-font);
    font-size: var(--ef-text-18);
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--ef-text);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: var(--ef-space-8);
    font-family: var(--ef-mono);
    font-size: var(--ef-text-12);
    color: var(--ef-text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: var(--ef-space-24);
}

.tabs {
    display: flex;
    gap: var(--ef-space-24);
    margin-bottom: var(--ef-space-24);
    border-bottom: 1px solid var(--ef-border);
    padding-bottom: 0;
}

.tab {
    padding: var(--ef-space-8) 0;
    background: transparent;
    border: none;
    color: var(--ef-text-muted);
    cursor: pointer;
    font-size: var(--ef-text-12);
    font-weight: 600;
    transition: all 150ms;
    position: relative;
    font-family: var(--ef-font);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    height: 38px;
}

.tab::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--ef-color-primary);
    transform: scaleX(0);
    transition: transform 150ms;
}

.tab:hover {
    color: var(--ef-text);
}

.tab.active {
    color: var(--ef-color-primary);
}

.tab.active::after {
    transform: scaleX(1);
}

.tab-content {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.report-section {
    background: var(--ef-surface);
    border: 1px solid var(--ef-border);
    border-radius: var(--ef-radius-10);
    padding: var(--ef-space-24);
    margin-bottom: var(--ef-space-24);
    box-shadow: var(--ef-shadow-1);
}

.section-title {
    font-size: var(--ef-text-18);
    font-weight: 700;
    margin-bottom: var(--ef-space-16);
    color: var(--ef-text);
    display: flex;
    align-items: center;
    gap: var(--ef-space-8);
}

.section-title::before {
    content: '';
    width: 3px;
    height: 20px;
    background: var(--ef-color-primary);
    border-radius: 2px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--ef-space-16);
    margin-bottom: var(--ef-space-16);
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: var(--ef-text-12);
    color: var(--ef-text-muted);
    margin-bottom: var(--ef-space-4);
    font-weight: 600;
}

.form-group input,
.form-group select {
    background: var(--ef-surface);
    border: 1px solid var(--ef-border);
    color: var(--ef-text);
    padding: 0 var(--ef-space-12);
    height: 34px;
    border-radius: var(--ef-radius-6);
    font-size: var(--ef-text-13);
    font-family: var(--ef-font);
    transition: border-color 150ms, box-shadow 150ms;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--ef-color-primary);
    box-shadow: 0 0 0 2px var(--ef-color-focus);
}

.button-group {
    display: flex;
    gap: var(--ef-space-8);
    margin-top: var(--ef-space-16);
}

.btn {
    padding: 0 var(--ef-space-12);
    height: 34px;
    border: none;
    border-radius: var(--ef-radius-6);
    font-size: var(--ef-text-13);
    font-weight: 600;
    cursor: pointer;
    transition: all 150ms;
    font-family: var(--ef-font);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn:focus-visible {
    outline: 2px solid var(--ef-color-focus);
    outline-offset: 2px;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-sm {
    height: 28px;
    padding: 0 var(--ef-space-8);
    font-size: var(--ef-text-12);
}

.btn-lg {
    height: 42px;
    padding: 0 var(--ef-space-16);
    font-size: var(--ef-text-14);
}

.btn-primary {
    background: var(--ef-color-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--ef-color-primary-hover);
}

.btn-secondary {
    background: var(--ef-surface);
    color: var(--ef-text);
    border: 1px solid var(--ef-border);
}

.btn-secondary:hover {
    background: var(--ef-surface-2);
}

.btn-danger {
    background: var(--ef-color-danger);
    color: #fff;
}

.btn-danger:hover {
    background: var(--ef-color-danger-hover);
}

.data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--ef-space-16);
    margin-top: var(--ef-space-16);
}

.data-card {
    background: var(--ef-surface);
    border: 1px solid var(--ef-border);
    border-radius: var(--ef-radius-10);
    padding: var(--ef-space-24);
    transition: border-color 150ms;
}

.data-card:hover {
    border-color: var(--ef-color-primary);
}

.data-card h4 {
    color: var(--ef-color-primary);
    margin-bottom: var(--ef-space-12);
    font-size: var(--ef-text-14);
    font-weight: 700;
}

.data-row {
    display: flex;
    justify-content: space-between;
    padding: var(--ef-space-8) 0;
    border-bottom: 1px solid var(--ef-border);
}

.data-row:last-child {
    border-bottom: none;
}

.data-label {
    color: var(--ef-text-muted);
    font-size: var(--ef-text-13);
}

.data-value {
    font-family: var(--ef-mono);
    font-weight: 600;
    color: var(--ef-text);
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--ef-border);
    border-top-color: var(--ef-color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100px);
    }
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    padding: var(--ef-space-8) var(--ef-space-12);
    text-align: left;
    color: var(--ef-text-muted);
    font-size: var(--ef-text-12);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: var(--ef-surface-2);
    border-bottom: 1px solid var(--ef-border);
}

td {
    padding: var(--ef-space-8) var(--ef-space-12);
    border-bottom: 1px solid var(--ef-border);
    font-size: var(--ef-text-13);
    height: 40px;
}

tr:hover {
    background: var(--ef-surface-2);
    cursor: pointer;
}

/* Design system utility classes */
.cr { text-align: right; }
.cm { color: var(--ef-text-muted); }

/* ==================== SORTABLE TABLE STYLES ==================== */
th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background-color 0.2s ease;
}

th.sortable:hover {
    background-color: var(--ef-surface-2);
}

.sort-indicator {
    font-size: var(--ef-text-11);
    margin-left: var(--ef-space-4);
    color: var(--ef-color-primary);
    display: inline-block;
    font-weight: bold;
}

/* ==================== INFO DROPDOWN STYLES ==================== */
.info-dropdown {
    position: relative;
}

.info-button {
    background: var(--ef-surface);
    border: 1px solid var(--ef-border);
    color: var(--ef-text);
    padding: var(--ef-space-8);
    border-radius: var(--ef-radius-6);
    cursor: pointer;
    transition: all 150ms;
    display: flex;
    align-items: center;
    justify-content: center;
}

.info-button:hover {
    border-color: var(--ef-color-primary);
    background: var(--ef-surface-2);
}

.info-button svg {
    width: 20px;
    height: 20px;
}

.info-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: var(--ef-space-4);
    background: var(--ef-surface);
    border: 1px solid var(--ef-border);
    border-radius: var(--ef-radius-6);
    box-shadow: var(--ef-shadow-2);
    min-width: 180px;
    z-index: 1000;
}

.info-menu.show {
    display: block;
}

.info-menu a {
    display: block;
    padding: var(--ef-space-8) var(--ef-space-12);
    color: var(--ef-text);
    text-decoration: none;
    font-size: var(--ef-text-13);
    font-family: var(--ef-font);
    transition: background 150ms;
    border-bottom: 1px solid var(--ef-border);
}

.info-menu a:last-child {
    border-bottom: none;
}

.info-menu a:hover {
    background: var(--ef-surface-2);
    color: var(--ef-color-primary);
}

/* ==================== THEME DROPDOWN STYLES ==================== */
.theme-dropdown {
    position: relative;
}

.theme-select {
    appearance: none;
    background: var(--ef-surface);
    border: 1px solid var(--ef-border);
    color: var(--ef-text);
    padding: 0 2rem 0 var(--ef-space-12);
    height: 34px;
    border-radius: var(--ef-radius-6);
    font-size: var(--ef-text-13);
    font-family: var(--ef-font);
    cursor: pointer;
    transition: border-color 150ms, box-shadow 150ms;
    font-weight: 600;
}

.theme-select:hover {
    border-color: var(--ef-color-primary);
}

.theme-select:focus {
    outline: none;
    border-color: var(--ef-color-primary);
    box-shadow: 0 0 0 2px var(--ef-color-focus);
}

.theme-dropdown::after {
    content: '▼';
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
    font-size: 0.7rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--ef-space-12);
}

/* ==================== NAVIGATION THEMES ==================== */
[data-nav="light"] {
    --nav-bg: #ffffff;
    --nav-text: var(--ef-text-muted);
    --nav-text-active: var(--ef-text);
    --nav-border: var(--ef-border);
    --nav-brand: var(--ef-text);
}

[data-nav="soft"] {
    --nav-bg: #f0f4f8;
    --nav-text: #64748b;
    --nav-text-active: #1e293b;
    --nav-border: #d5dce6;
    --nav-brand: #1e293b;
}

[data-nav="slate"] {
    --nav-bg: #1e293b;
    --nav-text: #94a3b8;
    --nav-text-active: #e2e8f0;
    --nav-border: #334155;
    --nav-brand: #e2e8f0;
}

[data-nav="dark"] {
    --nav-bg: #0f172a;
    --nav-text: #64748b;
    --nav-text-active: #e2e8f0;
    --nav-border: #1e293b;
    --nav-brand: #e2e8f0;
}

/* Apply nav theme to header */
[data-nav] .header {
    background: var(--nav-bg);
    border-bottom-color: var(--nav-border);
}

[data-nav] .header h1 {
    color: var(--nav-brand);
}

[data-nav] .header .info-button {
    background: transparent;
    border-color: var(--nav-border);
    color: var(--nav-text);
}

[data-nav] .header .info-button:hover {
    color: var(--nav-text-active);
    border-color: var(--nav-text);
}

/* ==================== THEME SWITCHER WIDGET ==================== */
.theme-toggle-btn {
    position: fixed;
    bottom: var(--ef-space-16);
    right: var(--ef-space-16);
    z-index: 9997;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--ef-surface);
    border: 1px solid var(--ef-border);
    box-shadow: var(--ef-shadow-2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ef-text-muted);
    cursor: pointer;
    transition: all 150ms;
}

.theme-toggle-btn:hover {
    background: var(--ef-surface-2);
    color: var(--ef-text);
}

.theme-panel {
    position: fixed;
    bottom: var(--ef-space-16);
    right: var(--ef-space-16);
    z-index: 9998;
    background: var(--ef-surface);
    border: 1px solid var(--ef-border);
    border-radius: var(--ef-radius-10);
    box-shadow: var(--ef-shadow-2);
    padding: var(--ef-space-12);
    width: 220px;
}

.theme-panel h4 {
    font-size: var(--ef-text-11);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ef-text-muted);
    margin-bottom: var(--ef-space-8);
}

.theme-group {
    margin-bottom: var(--ef-space-12);
}

.theme-group:last-child {
    margin-bottom: 0;
}

.theme-opt {
    display: flex;
    align-items: center;
    gap: var(--ef-space-8);
    padding: 5px 8px;
    border-radius: var(--ef-radius-6);
    cursor: pointer;
    font-size: var(--ef-text-12);
    color: var(--ef-text);
    transition: all 100ms;
    margin-bottom: 2px;
}

.theme-opt:hover {
    background: var(--ef-surface-2);
}

.theme-opt.active {
    background: var(--ef-color-primary-bg);
    color: var(--ef-color-primary);
    font-weight: 600;
}

.theme-swatch {
    width: 18px;
    height: 18px;
    border-radius: var(--ef-radius-4);
    border: 1px solid var(--ef-border);
    flex-shrink: 0;
}

/* ==================== MOBILE RESPONSIVE STYLES ==================== */
@media (max-width: 768px) {
    .header {
        padding: 1rem;
    }

    .header-content {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .header h1 {
        font-size: 1.2rem;
        text-align: center;
    }

    .header-right {
        flex-direction: column;
        gap: 1rem;
        width: 100%;
    }

    .theme-dropdown {
        width: 100%;
    }

    .theme-select {
        width: 100%;
        text-align: center;
    }

    .status-indicator {
        justify-content: center;
        font-size: 0.8rem;
    }

    .container {
        padding: 1rem;
    }

    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        scrollbar-width: thin;
    }

    .tab {
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
        white-space: nowrap;
    }

    .report-section {
        padding: 1rem;
        border-radius: 12px;
    }

    .section-title {
        font-size: 1.2rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .button-group {
        flex-direction: column;
        gap: 0.75rem;
    }

    .btn {
        width: 100%;
        padding: 0.75rem 1.5rem;
        font-size: 0.9rem;
    }

    .data-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .data-card {
        padding: 1rem;
    }

    table {
        font-size: 0.85rem;
    }

    th, td {
        padding: 0.75rem 0.5rem;
        font-size: 0.8rem;
    }

    th {
        position: sticky;
        top: 0;
        background: var(--bg-dark);
        z-index: 10;
    }

    /* Stack metric cards more efficiently on mobile */
    div[style*="grid-template-columns: repeat(auto-fit, minmax(280px, 1fr))"] {
        grid-template-columns: 1fr !important;
    }

    /* Make checkbox grids single column on mobile */
    div[style*="grid-template-columns: repeat(auto-fill, minmax(200px, 1fr))"] {
        grid-template-columns: 1fr 1fr !important;
    }

    /* Smaller modal on mobile */
    .modal-content {
        max-width: 95% !important;
        padding: 1rem !important;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1rem;
    }

    .tab {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    .section-title {
        font-size: 1rem;
    }

    th, td {
        padding: 0.5rem 0.25rem;
        font-size: 0.75rem;
    }

    .data-label,
    .data-value {
        font-size: 0.85rem;
    }

    /* Single column for checkbox grids on very small screens */
    div[style*="grid-template-columns: repeat(auto-fill, minmax(200px, 1fr))"] {
        grid-template-columns: 1fr !important;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .tab,
    .theme-select,
    select,
    input[type="checkbox"] {
        min-height: 44px; /* Apple's minimum touch target */
    }

    .data-card,
    tr {
        cursor: default;
    }

    /* Larger tap targets */
    .tab {
        padding: 1rem 1.5rem;
    }
}

/* ==== BULK_UPDATE_FEATURE: Selected Row Highlighting ==== */
.bcso-row-selected {
    background-color: rgba(15, 118, 110, 0.2) !important;
}

.bcso-row-selected:hover {
    background-color: rgba(15, 118, 110, 0.3) !important;
}

/* ==== BCSO COLUMN RESIZE ==== */
.column-resize-handle {
    position: absolute;
    top: 0;
    right: -3px;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    user-select: none;
    z-index: 15;
    background: transparent;
    transition: background 0.2s ease;
}

.column-resize-handle:hover {
    background: var(--primary);
    opacity: 0.5;
}

.column-resize-handle.resizing {
    background: var(--primary);
    opacity: 0.8;
}

.column-resize-active .column-resize-handle.resizing {
    box-shadow: 0 0 0 1px var(--primary);
}

.column-resize-active {
    user-select: none;
    cursor: col-resize;
}

.column-resize-active tr:hover {
    background: transparent !important;
}

/* BCSO Sticky Header */
#bcsoTable thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

#bcsoTable thead tr:first-child th {
    position: sticky;
    top: 0;
    background: var(--bg-dark);
    z-index: 11;
}

#bcsoTable thead tr:nth-child(2) th {
    position: sticky;
    top: 2.5rem; /* Adjust based on header row height */
    background: var(--bg-med);
    z-index: 11;
}

/* ==== PRODUCTIVITY METRICS: Sub-tabs ==== */
.sub-tabs {
    display: flex;
    gap: var(--ef-space-4);
    padding: var(--ef-space-4);
    background: var(--ef-surface-2);
    border: 1px solid var(--ef-border);
    border-radius: var(--ef-radius-6);
    width: fit-content;
}

.sub-tab {
    padding: var(--ef-space-8) var(--ef-space-16);
    border: none;
    border-radius: var(--ef-radius-4);
    background: transparent;
    color: var(--ef-text-muted);
    font-weight: 600;
    font-size: var(--ef-text-13);
    cursor: pointer;
    transition: all 150ms;
    font-family: var(--ef-font);
}

.sub-tab:hover {
    background: var(--ef-surface);
    color: var(--ef-text);
}

.sub-tab.active {
    background: var(--ef-color-primary);
    color: #fff;
}

/* ==== PRODUCTIVITY METRICS: View Containers ==== */
.productivity-view {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.productivity-view.active {
    display: block;
}

/* ==== PRODUCTIVITY METRICS: KPI Cards (5-column grid) ==== */
.kpi-grid-5 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--ef-space-16);
}

.kpi-card-mini {
    background: var(--ef-surface);
    border: 1px solid var(--ef-border);
    border-radius: var(--ef-radius-10);
    padding: var(--ef-space-16);
    transition: border-color 150ms;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.kpi-card-mini:hover {
    border-color: var(--ef-color-primary);
}

.kpi-label {
    font-size: var(--ef-text-12);
    color: var(--ef-text-muted);
    font-weight: 600;
    margin-bottom: var(--ef-space-4);
}

.kpi-value {
    font-family: var(--ef-mono);
    font-size: var(--ef-text-24);
    font-weight: 700;
    color: var(--ef-text);
    letter-spacing: -0.5px;
    margin-bottom: var(--ef-space-4);
}

.kpi-sub {
    font-size: var(--ef-text-11);
    color: var(--ef-text-muted);
    line-height: 1.3;
}

/* ==== PRODUCTIVITY METRICS: Chart Placeholders ==== */
.chart-placeholder {
    min-height: 250px;
    border: 2px dashed var(--border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    background: var(--bg-dark);
    transition: all 0.3s ease;
    padding: 1.5rem;
}

.chart-placeholder:hover {
    border-color: var(--primary);
    background: var(--bg-med);
}

/* ==== PRODUCTIVITY METRICS: Drawer ==== */
.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1001;
    display: none;
    align-items: stretch;
    justify-content: flex-end;
}

.drawer-backdrop.open {
    display: flex;
}

.drawer {
    width: min(560px, 90vw);
    height: 100vh;
    background: var(--ef-surface);
    border-left: 1px solid var(--ef-border);
    box-shadow: var(--ef-shadow-2);
    overflow-y: auto;
    padding: var(--ef-space-24);
    transform: translateX(100%);
    transition: transform 200ms ease-out;
}

.drawer-backdrop.open .drawer {
    transform: translateX(0);
}

/* ==== PRODUCTIVITY METRICS: Pill Badges ==== */
.pill {
    display: inline-block;
    padding: var(--ef-space-4) var(--ef-space-8);
    border-radius: var(--ef-radius-14);
    font-size: var(--ef-text-11);
    font-weight: 600;
    font-family: var(--ef-font);
    white-space: nowrap;
    height: 22px;
    line-height: 14px;
}

.pill.good {
    color: var(--ef-green-text);
    background: var(--ef-green-bg);
    border: 1px solid rgba(22,163,74,0.15);
}

.pill.warn {
    color: var(--ef-yellow-text);
    background: var(--ef-yellow-bg);
    border: 1px solid rgba(217,119,6,0.15);
}

.pill.bad {
    color: var(--ef-red-text);
    background: var(--ef-red-bg);
    border: 1px solid rgba(220,38,38,0.15);
}

.pill.na {
    color: var(--ef-text-muted);
    background: var(--ef-surface-2);
    border: 1px solid var(--ef-border);
}

/* ==== PRODUCTIVITY METRICS: Responsive Design ==== */
@media (max-width: 768px) {
    .kpi-grid-5 {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }

    .sub-tabs {
        width: 100%;
        flex-direction: column;
        border-radius: 12px;
    }

    .sub-tab {
        text-align: center;
        border-radius: 8px;
    }

    .drawer {
        width: 100vw;
        border-left: none;
    }

    .chart-placeholder {
        min-height: 200px;
    }
}

@media (max-width: 480px) {
    .kpi-grid-5 {
        grid-template-columns: 1fr;
    }

    .kpi-value {
        font-size: 1.5rem;
    }

    .productivity-view table {
        font-size: 0.75rem;
    }

    .productivity-view th,
    .productivity-view td {
        padding: 0.4rem 0.3rem;
    }
}

/* ==================== TABLE SORTING ==================== */
.sort-indicator {
    display: inline-block;
    margin-left: 0.3rem;
    font-size: 0.7rem;
    color: var(--text-secondary);
    opacity: 0.5;
}

.sort-indicator.active {
    opacity: 1;
    color: var(--primary-light);
}

.sort-indicator::before {
    content: '⇅';
}

.sort-indicator.asc::before {
    content: '↑';
}

.sort-indicator.desc::before {
    content: '↓';
}
