/* ============================================================
   Monthly Forecasting Dashboard — Adams Brand Theme
   Brand: Orange #EB7B36  |  Blue #386D8E
   Font:  Barlow + Barlow Condensed
   ============================================================ */

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

:root {
    /* === ADAMS BRAND PALETTE ===
       Orange: #EB7B36  (Pantone 158)
       Blue:   #386D8E  (Pantone 2160)
       ============================================= */
    --primary: #386D8E;           /* Adams Blue — header, table headers, dark surfaces */
    --primary-mid: #2b5570;       /* Darker blue — hover states on dark bg */
    --primary-light: #EB7B36;     /* Adams Orange — active tabs, borders, highlights */
    --primary-dark: #1e3d52;      /* Deepest blue — status bar, sidebar bg */
    --primary-subtle: #fdf2ea;    /* Light orange tint — hover rows, group backgrounds */
    --blue-lt: #eaf3f8;           /* Light blue tint — subtle blue backgrounds */
    --accent: #EB7B36;            /* Adams Orange (same as primary-light) */
    --accent-hover: #d96e2a;      /* Darker orange — button/link hover */
    --success: #2a9a65;
    --success-light: #e8f7f1;
    --danger: #c93232;
    --danger-light: #fdeaea;
    --warning: #c97a0a;
    --warning-light: #fef3c7;
    --bg: #f0f2f4;                /* Light grey page background */
    --surface: #ffffff;
    --surface-raised: #ffffff;
    --border: #dde2e7;
    --border-light: #f0f2f5;
    --border-mid: #c4cdd5;
    --text: #1a2a34;
    --text-secondary: #4a6474;
    --text-muted: #647d8e;
    --row-hover: #f8fafb;
    --row-alt: #f8fafb;
    --font: 'Barlow', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-cond: 'Barlow Condensed', 'Barlow', sans-serif;
    --mono: 'Cascadia Code', 'Consolas', 'JetBrains Mono', monospace;
    --radius: 4px;
    --radius-sm: 3px;
    --radius-lg: 6px;
    --radius-pill: 20px;
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.07);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.10);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
    --transition: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: var(--font);
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === HEADER === */
.app-header {
    background: var(--primary);
    color: white;
    height: 58px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0,0,0,0.22);
    z-index: 100;
    position: sticky;
    top: 0;
    overflow: hidden;
}

/* Header right edge covered by body::before orange stripe — no separate element needed */

/* Orange accent stripe down right edge of page (matches Resource Allocator) */
body::before {
    content: '';
    position: fixed;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    background: var(--accent);
    z-index: 200;
    flex-shrink: 0;
    pointer-events: none;
}

/* Logo area */
.logo-area {
    display: flex;
    align-items: center;
    padding-right: 18px;
    border-right: 1px solid rgba(255,255,255,0.15);
    height: 100%;
    flex-shrink: 0;
}
.logo-img {
    height: 26px;
    object-fit: contain;
    /* No filter — logo file is already the correct color (orange) */
}

.header-left {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 0 0 18px;
}

.app-header h1 {
    font-family: var(--font-cond);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    line-height: 1.2;
}

.header-sub {
    font-family: var(--font-cond);
    font-size: 0.6rem;
    font-weight: 400;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.38);
    margin-top: 1px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 30px 0 0; /* extra right padding for the accent bar */
    margin-left: auto;
}

.last-refresh {
    font-family: var(--font-cond);
    font-size: 0.62rem;
    font-weight: 600;
    color: rgba(255,255,255,0.45);
    letter-spacing: 0.04em;
}

/* === BUTTONS === */
.btn {
    font-family: var(--font-cond);
    padding: 6px 14px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: white;
    box-shadow: 0 1px 3px rgba(235,123,54,0.35);
}
.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 2px 6px rgba(235,123,54,0.45);
    transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

.btn-small {
    font-family: var(--font-cond);
    padding: 4px 10px;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
}
.btn-small:hover {
    background: var(--blue-lt);
    border-color: var(--primary);
    color: var(--primary);
}

/* === CRITERIA PANEL === */
.criteria-panel {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.criteria-toggle {
    padding: 10px 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    transition: background var(--transition);
}
.criteria-toggle:hover { background: var(--bg); }

.criteria-title {
    font-family: var(--font-cond);
    font-weight: 700;
    font-size: 0.65rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.1em;
}

.criteria-arrow {
    font-size: 10px;
    transition: transform var(--transition);
    color: var(--text-muted);
}
.criteria-arrow.collapsed { transform: rotate(-90deg); }

.criteria-body {
    padding: 0 24px 16px;
    display: block;
}
.criteria-body.hidden { display: none; }

.criteria-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
}

.criteria-field label {
    display: block;
    font-family: var(--font-cond);
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.criteria-field input[type="text"],
.criteria-field input[type="date"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--font);
    color: var(--text);
    background: var(--surface);
    transition: all var(--transition);
}
.criteria-field input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(235,123,54,0.15);
}

.criteria-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    cursor: pointer;
    color: var(--text-secondary);
}
.checkbox-label:hover { color: var(--text); }

.criteria-actions {
    margin-top: 14px;
    display: flex;
    justify-content: flex-end;
}

/* === TAB NAVIGATION === */
.tab-nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 6px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    overflow-x: auto;
    box-shadow: var(--shadow-xs);
    align-items: center;
}

/* --- Collapsible Tab Block (matches Resource Allocator .off-block) --- */
.tab-block {
    display: flex;
    align-items: center;
    gap: 0;
}

.tab-block-hdr {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    background: var(--primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    user-select: none;
    transition: background 0.13s;
    flex-shrink: 0;
}
.tab-block-hdr:hover {
    background: var(--primary-mid);
}

.tab-block-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}

.tab-block-name {
    font-family: var(--font-cond);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: white;
    white-space: nowrap;
}

.tab-block-chev {
    font-size: 0.52rem;
    color: rgba(255,255,255,0.45);
    transition: transform 0.2s;
    margin-left: 2px;
}

.tab-block-body {
    display: flex;
    align-items: center;
    padding-left: 2px;
    transition: opacity 0.15s;
}

/* Collapsed state */
.tab-block.collapsed .tab-block-body {
    display: none;
}
.tab-block.collapsed .tab-block-chev {
    transform: rotate(-90deg);
}

/* Tab buttons (inside blocks) */
.tab {
    font-family: var(--font-cond);
    padding: 7px 12px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
    white-space: nowrap;
    position: relative;
    border-radius: var(--radius-sm);
    margin: 0 1px;
}
.tab:hover {
    color: var(--accent);
    background: var(--primary-subtle);
}
.tab.active {
    color: var(--accent);
    background: var(--primary-subtle);
    border-bottom-color: var(--accent);
    font-weight: 700;
}

/* === TOOLBAR === */
.toolbar {
    padding: 8px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-box {
    padding: 5px 10px;
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    width: 220px;
    font-family: var(--font);
    transition: all var(--transition);
    background: var(--bg);
    color: var(--text);
}
.search-box:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(235,123,54,0.12);
    background: var(--surface);
}

/* === CONTENT === */
.content {
    flex: 1;
    padding: 20px 24px;
    overflow: auto;
    position: relative;
}

/* === LOADING === */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(30,61,82,.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 8000;
}
.loading-overlay.hidden { display: none; }

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,.15);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay p {
    margin-top: 12px;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-cond);
    letter-spacing: .06em;
}
.load-progress {
    margin-top: 14px;
    width: 280px;
    text-align: center;
}
.load-bar {
    height: 6px;
    background: rgba(255,255,255,.1);
    border-radius: 3px;
    overflow: hidden;
}
.load-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.2s ease;
}
.load-detail {
    display: block;
    margin-top: 6px;
    font-size: 11px;
    color: rgba(255,255,255,.35);
    font-family: var(--font-cond);
    letter-spacing: .04em;
    font-variant-numeric: tabular-nums;
}

/* === KPI CARDS === */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--accent);
    transition: all var(--transition);
}
.kpi-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.kpi-label {
    font-family: var(--font-cond);
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    margin-bottom: 6px;
}

.kpi-value {
    font-family: var(--font-cond);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.02em;
}

.kpi-value.positive { color: var(--success); }
.kpi-value.negative { color: var(--danger); }

.kpi-sub {
    font-family: var(--font-cond);
    font-size: 0.62rem;
    color: var(--text-muted);
    margin-top: 4px;
    letter-spacing: 0.02em;
}

/* === SECTION TITLES === */
.section-title {
    font-family: var(--font-cond);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text);
    margin: 20px 0 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--accent);
    display: inline-block;
}

.section-title:first-child { margin-top: 0; }

/* === COLLAPSIBLE SECTION BLOCKS (Resource Allocator .off-block style) === */
.section-block {
    margin-bottom: 16px;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}
.section-block-hdr {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--primary);
    color: #fff;
    padding: 10px 16px;
    cursor: pointer;
    user-select: none;
    transition: background 0.13s;
}
.section-block-hdr:hover { background: var(--primary-mid); }
.section-block-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}
.section-block-name {
    font-family: var(--font-cond);
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    flex: 1;
}
.section-block-meta {
    font-family: var(--font-cond);
    font-size: 0.62rem;
    font-weight: 600;
    color: rgba(255,255,255,0.45);
}
.section-block-chev {
    font-size: 0.58rem;
    color: rgba(255,255,255,0.4);
    transition: transform 0.2s;
    margin-left: 4px;
}
.section-block-body {
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    overflow: hidden;
}
.section-block.collapsed .section-block-hdr { border-radius: var(--radius); }
.section-block.collapsed .section-block-body { display: none; }
.section-block.collapsed .section-block-chev { transform: rotate(-90deg); }

/* Remove double borders/shadows when table-container is inside a section block */
.section-block-body .table-container {
    margin-bottom: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

/* === DATA TABLE === */
.table-container {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

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

.data-table thead th {
    background: var(--primary);
    color: white;
    padding: 10px 12px;
    text-align: left;
    font-family: var(--font-cond);
    font-weight: 700;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    position: sticky;
    top: 0;
    z-index: 10;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    border-right: 1px solid rgba(255,255,255,0.08);
}
.data-table thead th:last-child { border-right: none; }

.data-table thead th:hover {
    background: var(--primary-mid);
}

.data-table thead th .sort-indicator {
    margin-left: 4px;
    font-size: 9px;
    opacity: 0.4;
}
.data-table thead th .sort-indicator.active { opacity: 1; }

.data-table tbody tr {
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition);
}
.data-table tbody tr:nth-child(even) {
    background: var(--row-alt);
}
.data-table tbody tr:hover {
    background: var(--primary-subtle);
    border-left: 2px solid var(--accent);
}

.data-table tbody td {
    padding: 8px 12px;
    white-space: nowrap;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-table td.num {
    text-align: right;
    font-family: var(--font-cond);
    font-size: 0.78rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
}

.data-table td.positive { color: var(--success); font-weight: 600; }
.data-table td.negative { color: var(--danger); font-weight: 600; }

.data-table tfoot td {
    padding: 10px 12px;
    font-weight: 700;
    background: var(--primary-subtle);
    border-top: 2px solid var(--accent);
}

/* === GROUP ROW (expandable) === */
.group-row {
    cursor: pointer;
    font-weight: 600;
    background: var(--primary-subtle) !important;
    transition: background var(--transition);
}
.group-row:hover { background: #fde8d0 !important; }

.group-row td:first-child::before {
    content: '\25B6';
    display: inline-block;
    margin-right: 8px;
    font-size: 9px;
    transition: transform var(--transition);
    color: var(--accent);
}
.group-row.expanded td:first-child::before {
    transform: rotate(90deg);
}

.detail-row { display: none; }
.detail-row.visible { display: table-row; }

.detail-row td:first-child {
    padding-left: 32px;
    color: var(--text-secondary);
}

/* === SUMMARY GRID === */
.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 1200px) {
    .summary-grid { grid-template-columns: 1fr; }
}

/* === TEAM HEADER === */
.team-header {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.team-stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 22px;
    box-shadow: var(--shadow);
    min-width: 170px;
    border-top: 3px solid var(--accent);
    transition: all var(--transition);
}
.team-stat:hover {
    box-shadow: var(--shadow-md);
}

.team-stat-label {
    font-family: var(--font-cond);
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.1em;
}

.team-stat-value {
    font-family: var(--font-cond);
    font-size: 1.3rem;
    font-weight: 700;
    margin-top: 4px;
    letter-spacing: -0.02em;
}

/* === STATUS BAR === */
.status-bar {
    background: var(--primary-dark);
    color: rgba(255,255,255,0.5);
    padding: 4px 24px;
    font-family: var(--font-cond);
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    display: flex;
    justify-content: space-between;
}
.ver-tag {
    opacity: 0.85;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    color: #EB7B36;
}
.ver-link { cursor: pointer; transition: opacity 0.15s; }
.ver-link:hover { opacity: 1; text-decoration: underline; }

/* === CHANGELOG MODAL === */
.changelog-modal-overlay {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(0,0,0,0.45);
    display: flex; align-items: center; justify-content: center;
    animation: clFadeIn 0.15s ease;
}
@keyframes clFadeIn { from { opacity: 0; } to { opacity: 1; } }
.changelog-modal {
    background: #fff; border-radius: 10px; width: 460px; max-width: 92vw;
    max-height: 80vh; display: flex; flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: clSlideUp 0.2s ease;
}
@keyframes clSlideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.changelog-hdr {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px 12px; border-bottom: 1px solid #e5e7eb;
}
.changelog-hdr h3 {
    margin: 0; font-family: var(--font-cond, 'Barlow Condensed', sans-serif);
    font-size: 1rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.08em; color: #1a1a2e;
}
.changelog-close {
    background: none; border: none; font-size: 22px; cursor: pointer;
    color: #999; line-height: 1; padding: 0 4px; transition: color 0.15s;
}
.changelog-close:hover { color: #333; }
.changelog-body {
    overflow-y: auto; padding: 16px 20px 20px;
    font-size: 13px; color: #444; line-height: 1.6;
}
.changelog-ver { margin-bottom: 18px; }
.changelog-ver:last-child { margin-bottom: 0; }
.changelog-ver h4 {
    margin: 0 0 8px; font-size: 1.1rem; font-weight: 700; color: #EB7B36;
}
.changelog-date {
    font-weight: 400; font-size: 11px; color: #999; margin-left: 6px;
}
.changelog-section { margin-bottom: 8px; }
.changelog-section ul {
    margin: 4px 0 0 18px; padding: 0; list-style: disc;
}
.changelog-section li { margin-bottom: 3px; }
.changelog-tag {
    display: inline-block; font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    padding: 1px 8px; border-radius: 3px; margin-bottom: 4px;
}
.tag-added, .tag-new { background: #e6f4ea; color: #1e7e34; }
.tag-fixed    { background: #e3f0fc; color: #1a73e8; }
.tag-improved { background: #fff3e0; color: #e65100; }
.changelog-footer {
    padding: 10px 20px; border-top: 1px solid #e5e7eb;
    text-align: center; font-size: 10px; font-weight: 600;
    color: #bbb; letter-spacing: 0.08em; text-transform: uppercase;
}

/* === DATA AGE BADGE (header bar) === */
.data-age-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
    vertical-align: middle;
    margin-right: 8px;
}
.data-age-badge:empty { display: none; }
.age-current  { background: #e6f4ea; color: #1e7e34; }
.age-recent   { background: #e3f0fc; color: #1a73e8; }
.age-moderate { background: #fff3e0; color: #e65100; }
.age-stale    { background: #fce4ec; color: #c62828; }

/* === ERROR MESSAGE === */
.error-box {
    background: var(--danger-light);
    border: 1px solid #fca5a5;
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 16px;
    border-left: 4px solid var(--danger);
}

.error-box h3 {
    color: var(--danger);
    font-size: 14px;
    margin-bottom: 6px;
    font-weight: 700;
}

.error-box p {
    font-size: 12px;
    color: var(--text);
    line-height: 1.6;
}

.error-box code {
    background: #fecaca;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--mono);
    font-size: 11px;
}

/* === INFO MESSAGE === */
.info-box {
    background: var(--primary-subtle);
    border: 1px solid #fbb98a;
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 16px;
    border-left: 4px solid var(--accent);
}

.info-box h3 {
    color: var(--accent);
    font-size: 14px;
    margin-bottom: 6px;
    font-weight: 700;
}

.info-box p {
    font-size: 12px;
    line-height: 1.6;
}

/* === NO DATA === */
.no-data {
    text-align: center;
    padding: 48px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
}

/* === CHART AREA === */
.chart-area {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    position: relative;
}

/* === FILTER BAR (Slicer Replacement) === */
.filter-bar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-start;
}

.filter-clear-all {
    font-family: var(--font-cond);
    padding: 4px 12px;
    border: 1px solid var(--danger);
    border-radius: var(--radius-pill);
    background: var(--danger-light);
    color: var(--danger);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    white-space: nowrap;
    align-self: center;
    transition: all var(--transition);
}
.filter-clear-all:hover {
    background: var(--danger);
    color: white;
    box-shadow: 0 2px 4px rgba(239,68,68,0.3);
}

/* "Reset to Default" button — shown when user has a saved custom preset */
.filter-reset-preset {
    font-family: var(--font-cond);
    padding: 4px 12px;
    border: 1px solid var(--accent);
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--accent);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    white-space: nowrap;
    align-self: center;
    transition: all var(--transition);
    margin-left: 4px;
}
.filter-reset-preset:hover {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 4px rgba(235,123,54,0.3);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.filter-label {
    font-family: var(--font-cond);
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-count {
    color: var(--accent);
    font-weight: 700;
}

.filter-clear-btn {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 14px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    font-weight: 700;
    transition: color var(--transition);
}
.filter-clear-btn:hover { color: #dc2626; }

.filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.filter-pill {
    font-family: var(--font-cond);
    padding: 3px 10px;
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.filter-pill:hover {
    border-color: var(--primary);
    background: var(--blue-lt);
    color: var(--primary);
}
.filter-pill.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    font-weight: 700;
}

/* === FILTER DROPDOWNS (multi-select) === */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.filter-dropdown-wrap {
    position: relative;
    display: inline-block;
}

.filter-dropdown-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-cond);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.filter-dropdown-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--primary-subtle);
}
.filter-dropdown-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    font-weight: 600;
}
.filter-dropdown-btn.active:hover {
    background: var(--accent-hover);
}

.dd-label { flex: 1; }
.dd-arrow { font-size: 9px; opacity: 0.7; }
.filter-badge {
    background: rgba(255,255,255,0.3);
    border-radius: 10px;
    padding: 0 6px;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    text-align: center;
    line-height: 16px;
    height: 16px;
}
.filter-dropdown-btn:not(.active) .filter-badge {
    background: var(--accent);
    color: white;
}

.filter-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 500;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    max-width: 320px;
    overflow: hidden;
}
.filter-dropdown-menu.dd-open { display: block; }

.dd-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}
.dd-title {
    font-family: var(--font-cond);
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.1em;
}
.dd-clear-btn {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all var(--transition);
}
.dd-clear-btn:hover { background: var(--danger-light); }

.dd-search-wrap {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}
.dd-search {
    width: 100%;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: var(--font);
    background: var(--bg);
}
.dd-search:focus {
    outline: none;
    border-color: var(--accent);
}

.dd-items {
    max-height: 240px;
    overflow-y: auto;
    padding: 4px 0;
}

.dd-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text);
    transition: background var(--transition);
}
.dd-item:hover { background: var(--primary-subtle); }
.dd-item input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}
.dd-item span { flex: 1; }

.dd-select-all {
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

/* === THREE-LEVEL TABLE === */
.three-level-table { width: 100%; border-collapse: collapse; font-size: 12px; }

/* Level 1 — Project Partner */
.tl-l1 {
    background: var(--primary) !important;
    color: white;
    cursor: pointer;
    font-family: var(--font-cond);
    font-weight: 700;
    font-size: 0.82rem;
    letter-spacing: 0.04em;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.tl-l1:hover { background: var(--primary-mid) !important; }
.tl-l1 td { padding: 9px 12px; }

/* Level 2 (four-level table only) — Project Owner */
.tl-owner {
    background: #e3ecf4;
    cursor: pointer;
    font-weight: 500;
    border-bottom: 1px solid var(--border-light);
}
.tl-owner:hover { background: #d2e2f0 !important; }
.tl-owner td { padding: 7px 12px 7px 28px; }
.tl-owner.tl-hidden { display: none; }

/* Level 2 — Project */
.tl-l2 {
    background: var(--blue-lt);
    cursor: pointer;
    font-weight: 500;
    border-bottom: 1px solid var(--border-light);
}
.tl-l2:hover { background: #daeaf3 !important; }
.tl-l2 td { padding: 7px 12px 7px 28px; }
.tl-l2.tl-hidden { display: none; }

/* Level 3 — Workstage */
.tl-l3 {
    background: var(--surface);
    border-bottom: 1px solid var(--border-light);
}
.tl-l3:hover { background: var(--row-hover); }
.tl-l3 td { padding: 6px 12px; }
.tl-l3.tl-hidden { display: none; }
.tl-workstage { padding-left: 50px !important; color: var(--text-secondary); font-style: italic; }
/* Deeper indent for workstages in the four-level team table */
.tl-workstage-deep { padding-left: 68px !important; }

/* Arrow indicators */
.tl-arrow {
    display: inline-block;
    width: 14px;
    font-size: 10px;
    opacity: 0.8;
    transition: transform var(--transition);
}

/* Grand total row */
.tl-total {
    background: var(--primary-dark) !important;
    color: white;
    border-top: 2px solid var(--accent);
}
.tl-total td {
    padding: 9px 12px;
    font-family: var(--font-cond);
    font-size: 0.85rem;
    letter-spacing: 0.02em;
}

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .app-header { padding: 10px 16px; }
    .app-header h1 { font-size: 15px; }
    .criteria-grid { grid-template-columns: 1fr; }
    .tab-nav { padding: 4px 8px; gap: 4px; }
    .tab-block { flex-wrap: wrap; }
    .tab-block-hdr { padding: 5px 10px; }
    .tab { padding: 6px 8px; font-size: 0.68rem; }
    .content { padding: 12px 16px; }
    .kpi-row { grid-template-columns: repeat(2, 1fr); }
    .toolbar { flex-direction: column; gap: 8px; padding: 8px 16px; }
    .search-box { width: 100%; }
    .filter-bar { padding: 10px 14px; gap: 10px; }
    .filter-pills { gap: 4px; }
    .filter-pill { font-size: 10px; padding: 3px 10px; }
    .chart-area { min-height: 220px; }
}

/* === FILTER TAGS ROW (active selections shown below filter bar) === */
.filter-tags-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    padding: 8px 0 2px;
    border-top: 1px solid var(--border-light);
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 6px 2px 8px;
    background: var(--blue-lt);
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    font-family: var(--font-cond);
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    line-height: 1.4;
    letter-spacing: 0.02em;
}

.filter-tag strong {
    color: var(--primary);
    font-weight: 700;
}

.filter-tag-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    padding: 0;
    line-height: 1;
    transition: all var(--transition);
    flex-shrink: 0;
}
.filter-tag-remove:hover {
    background: var(--accent);
    color: white;
}

/* ============================================================
   ADMIN PANEL — Target Editor (embedded in dashboard)
   ============================================================ */
.admin-panel { display: none; }
.admin-panel.adm-open {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 5000;
    background: var(--bg);
    overflow-y: auto;
}

/* Overlay & error */
.adm-overlay {
    position: fixed; inset: 0; z-index: 5100;
    background: rgba(56,109,142,.65);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 15px; font-weight: 600;
    font-family: var(--font);
}
.adm-overlay.adm-hidden { display: none; }

.adm-error {
    position: fixed; inset: 0; z-index: 5050;
    background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    flex-direction: column; gap: 12px; text-align: center;
    font-family: var(--font);
}
.adm-error.adm-hidden { display: none; }
.adm-error h2 { color: var(--danger); font-size: 18px; }
.adm-error p  { color: var(--muted); font-size: 13px; max-width: 400px; }

/* Toast */
.adm-toast {
    position: fixed; bottom: 24px; right: 24px; z-index: 9999;
    background: var(--primary); color: #fff;
    padding: 10px 20px; border-radius: 6px;
    font-size: 13px; font-family: var(--font);
    box-shadow: 0 4px 16px rgba(0,0,0,.3);
    opacity: 0; transition: opacity .25s;
    pointer-events: none;
}
.adm-toast.adm-toast-show { opacity: 1; }
.adm-toast.adm-toast-success { background: var(--success); }
.adm-toast.adm-toast-error   { background: var(--danger); }

/* Page layout */
.adm-page { max-width: 1400px; margin: 0 auto; padding: 20px 20px 60px; }

/* Action bar (sticky) */
.adm-action-bar {
    position: sticky; top: 0; z-index: 100;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 16px;
    margin-bottom: 18px;
    display: flex; align-items: center; gap: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,.06);
    font-family: var(--font);
}
.adm-dirty-badge {
    background: var(--primary-subtle); color: var(--accent);
    border: 1px solid var(--accent);
    font-size: 11px; font-weight: 700;
    padding: 2px 8px; border-radius: 20px;
    display: none;
}
.adm-is-dirty .adm-dirty-badge { display: inline-block; }
.adm-saved-label { font-size: 11px; color: var(--muted); }
.adm-spacer { flex: 1; }

/* Admin buttons */
.adm-btn-danger {
    background: var(--danger-light); color: var(--danger);
    border: 1px solid #fca5a5;
}
.adm-btn-danger:hover { background: #fee2e2; }

/* Tab bar */
.adm-tab-bar {
    display: flex; border-bottom: 2px solid var(--border);
    margin-bottom: 20px; gap: 0;
}
.adm-tab-btn {
    padding: 10px 22px;
    font-size: 13px; font-weight: 600; font-family: var(--font);
    color: var(--muted);
    border: none; border-bottom: 3px solid transparent;
    background: none; cursor: pointer;
    margin-bottom: -2px;
    transition: color .15s, border-color .15s;
}
.adm-tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.adm-tab-btn:hover:not(.active) { color: var(--primary); }
.adm-tab-panel { display: none; }
.adm-tab-panel.adm-active { display: block; }

/* Section header */
.adm-section-header { margin-bottom: 14px; }
.adm-section-title { font-size: 14px; font-weight: 700; color: var(--primary); font-family: var(--font-cond); }
.adm-section-note  { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Filter bar */
.adm-filter-bar { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; }
.adm-filter-bar input[type="text"] {
    padding: 6px 10px; border: 1px solid var(--border); border-radius: 5px;
    font-size: 12px; width: 220px; font-family: var(--font);
}
.adm-filter-bar input[type="text"]:focus { outline: 2px solid var(--accent); }
.adm-count-label { font-size: 11px; color: var(--muted); }

/* LDF card */
.adm-ldf-card {
    display: flex; align-items: center; gap: 16px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 12px 18px; margin-bottom: 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
    font-family: var(--font);
}
.adm-ldf-sub { font-size: 11px; color: var(--muted); }
.adm-ldf-card input[type="number"] {
    width: 90px; padding: 5px 8px;
    border: 1px solid var(--border); border-radius: 4px;
    font-size: 13px; font-family: 'Courier New', monospace;
    text-align: right;
}
.adm-ldf-card input[type="number"]:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.adm-ldf-card input.adm-is-ov { background: #fff3e0; border-color: var(--accent); font-weight: 700; }
.adm-ldf-reset-btn {
    font-size: 11px; color: var(--danger);
    background: none; border: none; cursor: pointer; text-decoration: underline;
}

/* Tables */
.adm-tbl-wrap {
    overflow-x: auto; border-radius: var(--radius);
    border: 1px solid var(--border); background: var(--surface);
    box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.admin-panel table { width: 100%; border-collapse: collapse; }
.admin-panel thead th {
    background: var(--primary); color: #fff;
    padding: 9px 10px; text-align: left;
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
    white-space: nowrap; font-family: var(--font-cond);
    position: sticky; top: 0; z-index: 10;
}
.admin-panel thead th.num { text-align: right; }
.admin-panel tbody tr { border-bottom: 1px solid #eef1f4; transition: background .1s; }
.admin-panel tbody tr:nth-child(even) { background: #f7f9fb; }
.admin-panel tbody tr:hover { background: #f0f4f7; }
.admin-panel tbody tr.adm-has-ov { background: #fffbf5 !important; }
.admin-panel tbody td {
    padding: 5px 10px; vertical-align: middle;
    font-size: 12px; font-family: var(--font);
}
.admin-panel tbody td.num { text-align: right; font-family: 'Courier New', monospace; font-size: 11.5px; }
.adm-name-label { font-weight: 600; }
.adm-team-label { font-size: 10px; color: var(--muted); }

/* Editable inputs in table cells */
.admin-panel td input[type="number"],
.admin-panel td input[type="text"],
.admin-panel td select {
    width: 100%; padding: 4px 7px;
    border: 1px solid transparent; border-radius: 3px;
    background: transparent; font-size: 12px;
    font-family: inherit; color: inherit;
    transition: border-color .15s, background .15s;
}
.admin-panel td input[type="number"] { text-align: right; font-family: 'Courier New', monospace; }
.admin-panel td input:focus,
.admin-panel td select:focus {
    outline: 2px solid var(--accent); border-color: var(--accent);
    background: #fff; box-shadow: 0 0 0 3px rgba(235,123,54,.12);
}
.admin-panel td input.adm-is-ov,
.admin-panel td select.adm-is-ov {
    background: #fff3e0; border-color: var(--accent); font-weight: 700;
}
.adm-reset-cell {
    font-size: 10px; color: var(--danger);
    background: none; border: none; cursor: pointer;
    padding: 0; margin-left: 4px; opacity: .7;
}
.adm-reset-cell:hover { opacity: 1; }

/* Monthly target columns */
.adm-month-col { min-width: 96px; }
.adm-month-cell { padding: 4px 6px; }
.adm-monthly-tbl td input[type="number"] { width: 88px; }

/* === PRINT === */
/* ── Data protection: disable text selection on sensitive elements ───── */
.data-table, .kpi-cards, .summary-section, .admin-panel {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
/* Re-enable selection on inputs inside admin panel */
.admin-panel input, .admin-panel textarea, .admin-panel select,
.search-box, .criteria-field input { user-select: text; }

@media print {
    /* Block printing of dashboard data entirely */
    body::before {
        content: "Printing is disabled for data security.";
        display: block;
        text-align: center;
        font-size: 24px;
        padding: 100px 40px;
        color: #cc0000;
        font-family: sans-serif;
    }
    body > * { display: none !important; }
}

/* === VARIANCE TAB === */
.variance-controls {
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.variance-label {
    font-family: var(--font-cond);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: .06em;
    color: var(--text-muted);
}
.variance-select {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 13px;
    background: var(--surface);
    cursor: pointer;
}
.variance-select:hover {
    border-color: var(--accent);
}
