/* ── ACD Executive Dashboard ─────────────────────────────────────────────── */

:root {
    --brand-orange: #FF8200;
    --brand-orange-light: #FFF3E6;
    --brand-gray: #999999;
    --brand-gray-light: #F5F5F5;
    --text-primary: #333333;
    --text-secondary: #666666;
    --positive: #2E7D32;
    --negative: #C62828;
    --border: #E0E0E0;
    --bg-white: #FFFFFF;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text-primary);
    background: var(--brand-gray-light);
    font-size: 14px;
    line-height: 1.4;
}

/* ── Header ──────────────────────────────────────────────────────────────── */

.header {
    background: var(--brand-orange);
    color: white;
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.home-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    opacity: 0.9;
    transition: opacity 0.15s;
}
.home-btn:hover { opacity: 1; }
.home-btn svg { width: 22px; height: 22px; }
.header h1 {
    font-size: 20px;
    font-weight: 600;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
}

.btn-primary {
    background: var(--brand-orange);
    color: white;
}
.btn-primary:hover { background: #E67300; }

.btn-secondary {
    background: white;
    color: var(--brand-orange);
    border: 1px solid var(--brand-orange);
}
.btn-secondary:hover { background: var(--brand-orange-light); }

.btn-preset {
    background: var(--bg-white);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 6px 12px;
    font-size: 12px;
}
.btn-preset:hover, .btn-preset.active {
    background: var(--brand-orange);
    color: white;
    border-color: var(--brand-orange);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 14px;
    background: var(--bg-white);
    border: 1px solid var(--border);
}
.btn-sm:hover { background: var(--brand-gray-light); }

/* ── Controls ────────────────────────────────────────────────────────────── */

.controls {
    background: var(--bg-white);
    padding: 12px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.store-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Store dropdown ──────────────────────────────────────────────────────── */

.dropdown-wrap {
    position: relative;
}

.dropdown-btn {
    border: 1px solid var(--border);
    background: var(--bg-white);
    color: var(--text-primary);
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.dropdown-btn:hover { background: var(--brand-gray-light); }

.dropdown-btn .caret {
    font-size: 8px;
    color: var(--text-secondary);
}

.dropdown-panel {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    z-index: 100;
    min-width: 260px;
    padding: 8px 0;
}

.dropdown-panel.right { left: auto; right: 0; }

.store-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 12px 6px;
    border-bottom: 1px solid var(--border);
}

.store-panel-header span {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.btn-clear-stores {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 11px;
    cursor: pointer;
    padding: 2px 4px;
}

.btn-clear-stores:hover { color: var(--negative); text-decoration: underline; }

.store-group {
    padding: 4px 12px;
}

.group-label {
    font-weight: 700;
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    display: block;
    margin-bottom: 2px;
}

.store-group-checks {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.store-checkbox {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    padding: 2px 0;
}

.store-checkbox input { cursor: pointer; }

/* ── Saved Views dropdown ─────────────────────────────────────────────── */

.views-panel {
    min-width: 220px;
}

.views-panel .view-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 12px;
    font-size: 12px;
}

.views-panel .view-item:hover { background: var(--brand-gray-light); }

.views-panel .view-item.active .view-item-name { color: var(--brand-orange); font-weight: 600; }

.view-item-name {
    flex: 1;
    cursor: pointer;
    padding: 2px 0;
}

.view-edit-btn {
    background: none;
    border: none;
    color: var(--brand-gray);
    font-size: 11px;
    cursor: pointer;
    padding: 2px 4px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.15s;
}

.view-item:hover .view-edit-btn { opacity: 0.7; }
.view-edit-btn:hover { opacity: 1 !important; color: var(--brand-orange); }

/* ── View Edit Modal ───────────────────────────────────────────────────── */

.view-edit-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.35);
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.view-edit-modal {
    background: var(--bg-white);
    border-radius: 8px;
    padding: 20px 24px;
    width: 340px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.view-edit-modal h4 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 14px;
}

.view-edit-field {
    margin-bottom: 12px;
}

.view-edit-field label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.view-edit-field input[type="text"] {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
}

.view-edit-field select {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
}

.ve-position-list {
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.ve-pos-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 10px;
    font-size: 12px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.ve-pos-row:last-child { border-bottom: none; }

.ve-pos-row.ve-pos-current {
    background: var(--brand-orange-light);
    color: var(--brand-orange);
    font-weight: 600;
}

.ve-pos-name { flex: 1; }

.ve-pos-arrows {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.ve-pos-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--text-secondary);
    font-size: 9px;
    cursor: pointer;
    padding: 1px 6px;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}

.ve-pos-btn:hover {
    background: var(--brand-orange);
    color: white;
    border-color: var(--brand-orange);
}

.view-edit-stores {
    max-height: 160px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 8px;
}

.view-edit-stores label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 400;
    color: var(--text-primary);
    text-transform: none;
    cursor: pointer;
    padding: 1px 0;
}

.view-edit-stores .ve-group-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-top: 4px;
    display: block;
}

.view-edit-stores .ve-group-label:first-child { margin-top: 0; }

.view-edit-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
}

.view-edit-actions .btn-save {
    background: var(--brand-orange);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 16px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
}

.view-edit-actions .btn-save:hover { background: #E67300; }

.view-edit-actions .btn-cancel {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
}

.view-edit-actions .btn-cancel:hover { background: var(--brand-gray-light); }

.view-edit-actions .btn-delete-view {
    background: none;
    border: none;
    color: var(--negative);
    font-size: 12px;
    cursor: pointer;
    padding: 6px 4px;
}

.view-edit-actions .btn-delete-view:hover { text-decoration: underline; }

.views-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

.view-save-item {
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    color: var(--brand-orange);
    font-weight: 500;
}

.view-save-item:hover { background: var(--brand-orange-light); }

.views-section-label {
    padding: 4px 12px 2px;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ve-scope-tag {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 3px;
    background: #e0f0ff;
    color: #1d6fa5;
    vertical-align: middle;
    margin-left: 6px;
}
.ve-scope-tag.ve-scope-private {
    background: #f3e8ff;
    color: #7c3aed;
}

.ve-visibility {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.ve-visibility label {
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}
.ve-vis-hint {
    font-size: 11px;
    color: var(--text-secondary);
}

.ve-pos-divider {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 8px 2px;
    border-top: 1px solid var(--border);
    margin-top: 2px;
}

.week-picker {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.week-picker label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.week-picker input[type="number"] {
    width: 64px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    text-align: center;
}

.week-picker input[type="date"] {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
}

.week-picker-sep {
    color: var(--border);
    font-size: 16px;
    margin: 0 2px;
}

.loading {
    color: var(--brand-orange);
    font-weight: 500;
    font-size: 13px;
    animation: pulse 1.2s infinite;
}

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

.hidden { display: none !important; }

/* ── Chart Toggle ───────────────────────────────────────────────────────── */

.chart-toggle {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 24px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
}

.chart-toggle-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.chart-toggle-group {
    display: flex;
    align-items: center;
    gap: 2px;
}

.chart-toggle-group-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-right: 4px;
}

.btn-toggle {
    border: 1px solid var(--border);
    background: var(--bg-white);
    color: var(--text-primary);
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-toggle:first-of-type { border-radius: 4px 0 0 4px; }
.btn-toggle:last-of-type { border-radius: 0 4px 4px 0; }
.btn-toggle:not(:first-of-type) { border-left: none; }

.btn-toggle:hover {
    background: var(--brand-orange-light);
}

.btn-toggle.active {
    background: var(--brand-orange);
    color: white;
    border-color: var(--brand-orange);
}

.btn-toggle.active + .btn-toggle {
    border-left: 1px solid var(--brand-orange);
}

/* ── Inline metric toggle (e.g. Payroll | Hours) ──────────────────────── */

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

.metric-header-row h3 {
    margin: 0;
}

.metric-toggle-group {
    display: inline-flex;
}

.metric-toggle-group .btn-toggle {
    padding: 2px 8px;
    font-size: 12px;
}

/* ── YoY Years Caret + Popover ──────────────────────────────────────────── */

.yoy-toggle-wrap {
    position: relative;
    display: inline-flex;
}

.yoy-toggle-wrap .btn-toggle {
    border-radius: 4px 0 0 4px;
}

.yoy-toggle-wrap + .btn-toggle {
    border-radius: 0 4px 4px 0;
    border-left: none;
}

.yoy-toggle-wrap .btn-toggle .caret-sm {
    font-size: 8px;
    margin-left: 2px;
    opacity: 0.75;
}

.yoy-years-popover {
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    padding: 10px 14px;
    z-index: 200;
    white-space: nowrap;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.yoy-years-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.yoy-years-stepper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stepper-btn {
    width: 26px;
    height: 26px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-white);
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.stepper-btn:hover {
    background: var(--brand-orange-light);
}

.stepper-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 18px;
    text-align: center;
}

/* ── Dashboard Content ───────────────────────────────────────────────────── */

.dashboard-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px 24px;
}

.error-message {
    background: #FFEBEE;
    color: var(--negative);
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 13px;
}

.page-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--brand-orange);
    margin-bottom: 4px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--brand-orange);
    display: flex;
    align-items: center;
    gap: 16px;
}

.p2-chart-toggle {
    display: inline-flex;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
    font-size: 12px;
    font-weight: 500;
}
.p2-chart-toggle .toggle-btn {
    padding: 3px 10px;
    border: none;
    background: #fff;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
}
.p2-chart-toggle .toggle-btn:not(:last-child) {
    border-right: 1px solid var(--border);
}
.p2-chart-toggle .toggle-btn.active {
    background: var(--brand-orange);
    color: #fff;
}

.meta-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* ── Metric Sections ─────────────────────────────────────────────────────── */

.metric-section {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 12px;
}

.metric-section h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
    cursor: pointer;
    display: inline-block;
}

.metric-section h3:hover {
    color: var(--brand-orange);
    text-decoration: underline;
}

/* ── Drill-down Modal ────────────────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-white);
    border-radius: 8px;
    padding: 20px 24px;
    max-width: 1100px;
    width: 95%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--brand-orange);
    cursor: default;
}

.modal-header h3:hover {
    color: var(--brand-orange);
    text-decoration: none;
}

.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0 4px;
}
.modal-close:hover { color: var(--text-primary); }

.drilldown-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.drilldown-table th,
.drilldown-table td {
    padding: 6px 10px;
    text-align: right;
    border-bottom: 1px solid var(--border);
}

.drilldown-table th {
    background: var(--brand-gray-light);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    position: sticky;
    z-index: 2;
}

.drilldown-table thead tr:first-child th {
    top: 0;
}

.drilldown-table thead tr:nth-child(2) th {
    top: 28px;
}

.drilldown-table .super-header th {
    text-align: center;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-primary);
}

.drilldown-table .sub-header th {
    text-align: right;
    font-size: 10px;
    border-bottom: 2px solid var(--brand-orange);
}

.drilldown-table th:first-child,
.drilldown-table td:first-child {
    text-align: left;
    white-space: nowrap;
    width: 1%;
}

.drilldown-table .total-row {
    font-weight: 700;
    border-top: 2px solid var(--brand-orange);
    background: var(--brand-orange-light);
}

#drilldown-body {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.drilldown-loading {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
}

.drilldown-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.drilldown-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 12px;
    border-bottom: 2px solid var(--border);
}

.drilldown-tab {
    background: none;
    border: none;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}

.drilldown-tab:hover {
    color: var(--text-primary);
}

.drilldown-tab.active {
    color: var(--brand-orange);
    border-bottom-color: var(--brand-orange);
    font-weight: 600;
}

.metric-row {
    display: flex;
    gap: 16px;
    align-items: center;
}

.metric-table-wrap {
    flex: 0 0 480px;
    min-width: 400px;
}

.metric-chart {
    flex: 1;
    min-width: 300px;
    height: 200px;
}

/* ── Tables ───────────────────────────────────────────────────────────────── */

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

.metric-table th,
.metric-table td {
    padding: 4px 8px;
    text-align: right;
    border-bottom: 1px solid var(--border);
}

.metric-table th {
    background: var(--brand-gray-light);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
}

.metric-table th:first-child,
.metric-table td:first-child {
    text-align: left;
}

.metric-table .row-label {
    font-weight: 500;
    color: var(--text-primary);
}

.metric-table .positive { color: var(--positive); font-weight: 600; }
.metric-table .negative { color: var(--negative); font-weight: 600; }
.metric-table .neutral  { color: var(--text-secondary); }
.metric-table .na       { color: #CCC; font-style: italic; }

/* ── Growth Pressure Section ──────────────────────────────────────────────── */

.growth-table {
    font-size: 12px;
    margin-bottom: 8px;
}

.growth-table th { font-size: 11px; }

.growth-table .super-header th {
    text-align: center;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-primary);
}

.growth-table .sub-header th {
    text-align: right;
    font-size: 10px;
    border-bottom: 2px solid var(--border);
}

.gp-charts-row {
    display: flex;
    gap: 16px;
    margin-top: 10px;
}

.gp-chart-col {
    flex: 1;
    min-width: 0;
}

.gp-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.gp-chart-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.gp-chart-link {
    cursor: pointer;
}

.gp-chart-link:hover {
    color: var(--brand-orange);
    text-decoration: underline;
}

.gp-chart {
    height: 200px;
}

/* ── PDF Package Banner ──────────────────────────────────────────────────── */

.pdf-package-banner {
    background: #FFF3E6;
    border: 1px solid var(--brand-orange);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.pdf-package-banner.hidden { display: none; }

/* ── Page Break for Print ────────────────────────────────────────────────── */

.page-break {
    height: 1px;
}

.print-header {
    display: none;
}

/* ── Print Styles ────────────────────────────────────────────────────────── */

@media print {
    @page { size: letter; margin: 0.25in; }

    .no-print { display: none !important; }

    body {
        background: white;
        margin: 0;
        padding: 0;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .header { padding: 4px 16px; }
    .header h1 { font-size: 14px; }
    .home-btn { display: none !important; }
    .header-right { display: none !important; }

    .dashboard-content {
        padding: 2px 12px;
        max-width: 100%;
    }

    .metric-section {
        padding: 2px 8px;
        margin-bottom: 2px;
        page-break-inside: avoid;
        border-width: 1px;
    }

    .metric-section h3 { font-size: 11px; margin-bottom: 1px; }
    .metric-chart { overflow: hidden; }
    .metric-row { gap: 8px; }
    .metric-table-wrap { flex: 0 0 auto; min-width: 280px; }

    .metric-table { font-size: 9px; }
    .metric-table th { font-size: 9px; text-transform: none; font-weight: 500; }
    .metric-table th, .metric-table td { padding: 1px 4px; }

    .growth-table th { font-size: 9px; }
    .growth-table .super-header th { padding: 1px 4px; }
    .growth-table .sub-header th { padding: 1px 4px; }

    .page-title { font-size: 13px; margin-bottom: 1px; padding-bottom: 2px; }
    .meta-subtitle { display: none; }

    .p2-chart-toggle { display: none; }

    .page-break { display: none; }

    .print-header {
        display: block;
        background: var(--brand-orange);
        color: white;
        padding: 4px 16px;
        page-break-before: always;
    }
    .print-header h1 {
        font-size: 14px;
        font-weight: 600;
    }

    .page-2 { page-break-before: avoid; }

    .print-header-1b { display: none !important; }

    /* By Store mode: force break before Enrollment/Attendance */
    .print-store-mode .print-header-1b {
        display: block !important;
        background: var(--brand-orange);
        color: white;
        padding: 4px 16px;
        page-break-before: always;
    }
    .print-store-mode .page-1b {
        page-break-before: avoid;
    }
}

/* ── Chat Widget ─────────────────────────────────────────────────────────── */

.chat-toggle-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--brand-orange);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.chat-toggle-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}

.chat-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 380px;
    height: 100vh;
    background: var(--bg-white);
    box-shadow: -4px 0 24px rgba(0,0,0,0.15);
    z-index: 950;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
}

.chat-panel.open {
    right: 0;
}

.chat-header {
    background: var(--brand-orange);
    color: white;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-header-title {
    font-weight: 600;
    font-size: 15px;
}

.chat-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.chat-close-btn:hover { opacity: 0.8; }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-msg {
    max-width: 92%;
}

.chat-msg-user {
    align-self: flex-end;
}

.chat-msg-assistant {
    align-self: flex-start;
}

.chat-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-msg-user .chat-bubble {
    background: var(--brand-orange);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-msg-assistant .chat-bubble {
    background: var(--brand-gray-light);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.chat-bubble.chat-error {
    background: #FFEBEE;
    color: var(--negative);
}

.chat-bubble h2, .chat-bubble h3, .chat-bubble h4 {
    font-size: 13px;
    font-weight: 700;
    margin: 8px 0 4px;
}

.chat-bubble code {
    background: rgba(0,0,0,0.06);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 12px;
}

.chat-bubble ul {
    margin: 4px 0;
    padding-left: 18px;
}

.chat-bubble li {
    margin-bottom: 2px;
}

.chat-bubble strong {
    font-weight: 600;
}

/* Typing indicator */
.chat-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 18px;
}

.chat-typing .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--brand-gray);
    animation: chatTyping 1.4s infinite ease-in-out;
}

.chat-typing .dot:nth-child(2) { animation-delay: 0.2s; }
.chat-typing .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatTyping {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Input bar */
.chat-input-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg-white);
}

.chat-input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: var(--brand-orange);
}

.chat-send-btn {
    background: var(--brand-orange);
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s;
}

.chat-send-btn:hover {
    background: #E67300;
}

/* Feedback */
.chat-feedback {
    display: flex;
    gap: 4px;
    margin-top: 4px;
}

.chat-fb-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s;
}

.chat-fb-btn:hover {
    background: var(--brand-gray-light);
}

.chat-fb-done {
    font-size: 11px;
    color: var(--text-secondary);
    padding: 2px 0;
}

/* Query result tables in chat */
.chat-qr-desc {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 8px;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.chat-qr-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    margin-bottom: 4px;
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.chat-qr-table th,
.chat-qr-table td {
    padding: 4px 8px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.chat-qr-table th {
    background: var(--brand-gray-light);
    font-weight: 600;
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.chat-qr-table tbody tr:hover {
    background: var(--brand-orange-light);
}

.chat-qr-info {
    font-size: 10px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.chat-chart-btn {
    font-size: 11px;
    color: var(--brand-orange);
    background: none;
    border: 1px solid var(--brand-orange);
    border-radius: 4px;
    padding: 2px 8px;
    cursor: pointer;
    margin: 4px 0;
}

.chat-chart-btn:hover {
    background: var(--brand-orange-light);
}

.chat-qr-chart {
    width: 100%;
    height: 220px;
    margin: 4px 0;
}

/* Command indicator */
.chat-cmd-indicator {
    text-align: center;
    font-size: 11px;
    color: var(--brand-orange);
    font-weight: 500;
    padding: 4px 8px;
    background: var(--brand-orange-light);
    border-radius: 8px;
    margin: 4px auto;
    max-width: 90%;
}
