@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;500;600;700&display=swap');

:root {
    --bg-primary: #201E30;
    --bg-secondary: #2A2840;
    --bg-tertiary: #353250;
    --accent: #676986;
    --accent-light: #A8E8E2;
    --text-primary: #EDEEF2;
    --text-secondary: #9B9DB5;
    --text-muted: #6E6F85;
    --green: #5BBB9B;
    --amber: #F0C05A;
    --coral: #E06C5E;
    --terra: #A84B2F;
    --dark-teal: #3A6B6E;
    --border: #3A3752;
    --sidebar-width: 240px;
}

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

body {
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    display: block;
    margin-bottom: 8px;
}

.sidebar-logo img {
    height: 24px;
    width: auto;
}

.sidebar-header .subtitle {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.sidebar-nav {
    padding: 12px 0;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 400;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.sidebar-nav a.active {
    color: var(--accent-light);
    background: rgba(168, 232, 226, 0.08);
    border-left-color: var(--accent-light);
    font-weight: 500;
}

.sidebar-nav a .nav-icon {
    margin-right: 10px;
    width: 18px;
    text-align: center;
    font-size: 14px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-muted);
}

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
}

.top-bar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 12px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.top-bar .period-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.top-bar .period-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.top-bar select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
}

.top-bar .refresh-btn {
    background: var(--accent);
    border: none;
    color: white;
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.2s;
}

.top-bar .refresh-btn:hover { opacity: 0.85; }

.top-bar .last-updated {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 12px;
}

.page-content {
    padding: 24px 32px;
    max-width: 1400px;
}

.page-title {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.page-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: -16px;
    margin-bottom: 20px;
}

.error-banner {
    background: rgba(224, 108, 94, 0.15);
    border: 1px solid var(--coral);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
    font-size: 13px;
    color: var(--coral);
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    transition: border-color 0.2s;
}

.kpi-card:hover { border-color: var(--accent); }

.kpi-card .kpi-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.kpi-card .kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
}

.kpi-card .kpi-delta {
    font-size: 12px;
    margin-top: 6px;
    font-weight: 500;
}

.kpi-delta.positive { color: var(--green); }
.kpi-delta.negative { color: var(--coral); }
.kpi-delta.neutral { color: var(--text-secondary); }

.kpi-card.improving { border-left: 3px solid var(--green); }
.kpi-card.worsening { border-left: 3px solid var(--coral); }

.section-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 24px;
    margin-bottom: 20px;
}

.section-card h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

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

.data-table th {
    text-align: right;
    padding: 8px 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    white-space: nowrap;
}

.data-table th:first-child { text-align: left; }

.data-table td {
    padding: 8px 12px;
    text-align: right;
    border-bottom: 1px solid rgba(58, 55, 82, 0.5);
    color: var(--text-primary);
    white-space: nowrap;
}

.data-table td:first-child {
    text-align: left;
    font-weight: 400;
    color: var(--text-secondary);
}

.data-table tr.total-row td {
    font-weight: 600;
    color: var(--text-primary);
    border-top: 2px solid var(--border);
    border-bottom: 2px solid var(--border);
}

.data-table tr.total-row td:first-child { color: var(--text-primary); }

.data-table tr.separator-row td {
    border-bottom: none;
    padding: 4px;
}

.data-table .favorable { color: var(--green); }
.data-table .unfavorable { color: var(--coral); }

.chart-container {
    position: relative;
    height: 300px;
    margin: 16px 0;
}

.chart-container.tall { height: 400px; }

.commentary-panel {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-top: 16px;
}

.commentary-panel h4 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent-light);
    margin-bottom: 10px;
    font-weight: 600;
}

.commentary-field {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    resize: none;
    overflow: hidden;
    min-height: 60px;
    transition: border-color 0.2s;
}

.commentary-field:focus {
    outline: none;
    border-color: var(--accent-light);
}

.commentary-field::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

.traffic-light {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}

.traffic-light.on_track { background: var(--green); }
.traffic-light.at_risk { background: var(--amber); }
.traffic-light.off_track { background: var(--coral); }
.traffic-light.no_target { background: var(--text-muted); }

.trend-arrow { font-size: 14px; font-weight: 600; }
.trend-arrow.up { color: var(--green); }
.trend-arrow.down { color: var(--coral); }
.trend-arrow.flat { color: var(--text-secondary); }

.initiative-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
}

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

.initiative-card h4 { font-size: 15px; font-weight: 600; }

.initiative-card .initiative-target {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.5;
}

.status-select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-family: inherit;
}

.progress-bar-container {
    background: var(--bg-tertiary);
    border-radius: 8px;
    overflow: hidden;
    height: 24px;
    position: relative;
    margin: 12px 0;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 8px;
    transition: width 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: white;
}

.settings-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group { margin-bottom: 12px; }

.form-group label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    font-weight: 500;
}

.form-group input, .form-group select {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
}

.form-group input:focus { outline: none; border-color: var(--accent-light); }

.btn {
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: opacity 0.2s;
}

.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--accent); color: white; }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border); }

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

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

.burn-kpi {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.burn-kpi .burn-kpi-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.burn-kpi .burn-kpi-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.burn-kpi .burn-kpi-sub {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.mobile-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
}

.table-scroll { overflow-x: auto; }

.inline-commentary {
    margin-top: 8px;
}

.inline-commentary textarea {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 8px 10px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 12px;
    resize: vertical;
    min-height: 40px;
}

.inline-commentary textarea:focus {
    outline: none;
    border-color: var(--accent-light);
}

@media (max-width: 1024px) {
    .kpi-grid, .burn-kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .two-col { grid-template-columns: 1fr; }
    .settings-form { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .mobile-toggle { display: block; }
    .kpi-grid, .burn-kpi-grid { grid-template-columns: 1fr; }
    .page-content { padding: 16px; }
}

.cm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}
.cm-table th, .cm-table td {
    padding: 6px 10px;
    white-space: nowrap;
    text-align: right;
}
.cm-table th:first-child, .cm-table td:first-child {
    text-align: left;
}
.cm-group-header {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-weight: 600;
    text-align: center !important;
    border-bottom: 2px solid var(--accent);
    padding: 8px 10px;
}
.cm-header-sub th {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 12px;
    border-bottom: 1px solid var(--bg-tertiary);
    padding: 5px 10px;
}
.cm-group-spacer {
    width: 16px;
    min-width: 16px;
    border: none !important;
    background: transparent !important;
}
.cm-label {
    color: var(--text-secondary);
    padding-left: 16px !important;
}
.cm-bold {
    color: var(--text-primary) !important;
    font-weight: 600;
    padding-left: 10px !important;
}
.cm-val {
    color: var(--text-primary);
}
.cm-var {
    font-weight: 500;
}
.cm-neg {
    color: var(--coral);
}
.cm-pos {
    color: var(--accent-light);
}
.cm-total-row {
    border-top: 1px solid var(--bg-tertiary);
    font-weight: 600;
}
.cm-total-row td { padding-top: 8px; }
.cm-spacer-row td {
    height: 12px;
    border: none;
}
.cm-section-header td {
    border: none;
    padding-top: 14px;
    padding-bottom: 2px;
}
.cm-section-label {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left !important;
}
.cm-gm-row td, .cm-cm-row td {
    border-top: 1px solid var(--bg-tertiary);
}
.cm-cm-row {
    border-top: 2px solid var(--accent) !important;
}
.cm-cm-row td {
    font-weight: 600;
    padding-top: 8px;
    padding-bottom: 8px;
}
.cm-detail-note td {
    border: none;
    padding: 0 10px 4px 10px;
}
.cm-note {
    color: var(--text-secondary);
    font-size: 11px;
    font-style: italic;
    text-align: left !important;
}
.page-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin: -8px 0 20px 0;
}

.split-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    align-items: stretch;
}

.split-layout .table-side {
    min-width: 0;
}

.split-layout .commentary-side {
    position: sticky;
    top: 72px;
    max-height: calc(100vh - 90px);
    display: flex;
    flex-direction: column;
}

.split-layout .commentary-side .commentary-panel {
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
}

.split-layout .commentary-side .commentary-panel::-webkit-scrollbar {
    width: 6px;
}

.split-layout .commentary-side .commentary-panel::-webkit-scrollbar-track {
    background: transparent;
}

.split-layout .commentary-side .commentary-panel::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.split-layout .commentary-side .commentary-panel::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.commentary-side .commentary-block {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}

.commentary-side .commentary-block h4 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent-light);
    margin-bottom: 8px;
    font-weight: 600;
}

.commentary-side .commentary-field {
    min-height: 70px;
}

.data-table .toggle-row td:first-child {
    cursor: pointer;
    user-select: none;
}

.data-table .toggle-arrow {
    display: inline-block;
    width: 16px;
    font-size: 10px;
    color: var(--text-muted);
    transition: transform 0.2s;
    text-align: center;
}

.data-table .toggle-arrow.open {
    transform: rotate(90deg);
}

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

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

.data-table .detail-row td {
    color: var(--text-secondary);
    font-size: 12px;
    padding-top: 5px;
    padding-bottom: 5px;
}

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

.section-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
}

.section-tabs .tab-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    padding: 10px 20px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.section-tabs .tab-btn:hover {
    color: var(--text-primary);
}

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

.tab-panel {
    display: none;
}

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

.cm-cols-table .channel-header {
    text-align: center;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent-light);
    border-bottom: 2px solid var(--accent);
    padding: 12px 10px;
}
.cm-cols-table .total-header {
    color: var(--text-primary);
    border-bottom-color: var(--accent-light);
}
.cm-cols-table thead tr:nth-child(2) th {
    font-size: 11px;
    color: var(--text-secondary);
    padding: 10px 10px;
    white-space: nowrap;
}
.cm-cols-table td, .cm-cols-table th {
    text-align: right;
    padding: 14px 10px;
    font-size: 13px;
}
.cm-cols-table td:first-child {
    text-align: left;
}
.cm-cols-table .metric-label {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
}
.cm-cols-table .subtotal-row {
    background: var(--bg-tertiary);
    font-weight: 600;
}
.cm-cols-table .subtotal-row .metric-label {
    font-weight: 700;
}
.cm-cols-table .margin-pct-row td {
    border-bottom: 1px solid var(--bg-tertiary);
    padding: 6px 10px 10px;
}
.cm-cols-table td:nth-child(4),
.cm-cols-table td:nth-child(7),
.cm-cols-table th:nth-child(4),
.cm-cols-table th:nth-child(7) {
    border-right: 1px solid var(--accent);
}

@media (max-width: 1200px) {
    .split-layout {
        grid-template-columns: 1fr;
    }
    .split-layout .commentary-side {
        position: static;
        max-height: none;
    }
}
