:root {
    --safat-green: #007d42;
    --safat-green-2: #009b55;
    --safat-green-soft: #e9f5ef;
    --safat-gold: #d9ad45;
    --safat-gold-soft: #fbf5e7;
    --navy: #182535;
    --navy-2: #202f40;
    --ink: #17212b;
    --muted: #687582;
    --canvas: #f3f6f5;
    --panel: #ffffff;
    --line: #e2e8e5;
    --positive: #07834b;
    --negative: #c63d45;
    --shadow: 0 12px 32px rgba(25, 48, 41, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: "Segoe UI", Arial, Helvetica, sans-serif;
    background: var(--canvas);
    color: var(--ink);
}

button, select { font: inherit; }
button { cursor: pointer; }
.portal-shell { min-height: 100vh; display: grid; grid-template-columns: 270px minmax(0, 1fr); }

.portal-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    color: #fff;
    background:
        radial-gradient(circle at 10% 0%, rgba(217,173,69,.18), transparent 27%),
        linear-gradient(180deg, var(--navy), #13202d);
    padding: 26px 20px 20px;
    z-index: 30;
}

.brand-block { display: flex; align-items: center; gap: 13px; padding-bottom: 24px; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand-logo { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; background: var(--safat-green-2); border: 2px solid var(--safat-gold); font-weight: 800; letter-spacing: .5px; }
.brand-copy strong, .brand-copy span { display: block; }
.brand-copy strong { font-size: 16px; letter-spacing: .7px; }
.brand-copy span { font-size: 9px; color: #cbd5dc; margin-top: 4px; letter-spacing: .8px; }
.sidebar-close { display: none; margin-left: auto; border: 0; background: transparent; color: #fff; font-size: 28px; }

.report-period { margin: 24px 0 16px; padding: 15px; border-radius: 12px; background: rgba(255,255,255,.06); border-left: 3px solid var(--safat-gold); }
.report-period span, .report-period strong { display: block; }
.report-period span { color: #b9c5ce; font-size: 9px; letter-spacing: 1.1px; }
.report-period strong { margin-top: 7px; font-size: 16px; }

.portal-nav { display: grid; gap: 7px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 13px; border: 0; border-radius: 9px; background: transparent; color: #dce4e9; text-align: left; transition: .18s ease; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { color: #fff; background: linear-gradient(90deg, var(--safat-green), var(--safat-green-2)); box-shadow: 0 8px 20px rgba(0,125,66,.22); }
.nav-icon { width: 22px; text-align: center; color: var(--safat-gold); font-weight: 700; }
.nav-item.active .nav-icon { color: #fff2bf; }

.sidebar-bottom { margin-top: auto; border-top: 1px solid rgba(255,255,255,.11); padding-top: 18px; }
.admin-link { display: flex; gap: 10px; align-items: center; color: #e8edf0; font-size: 13px; padding: 10px 0; text-decoration: none; }
.sidebar-bottom p { color: #7f909d; font-size: 10px; }

.portal-main { min-width: 0; }
.portal-header { position: sticky; top: 0; z-index: 20; min-height: 91px; padding: 16px 28px; background: rgba(255,255,255,.96); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 22px; align-items: center; }
.header-left { display: flex; align-items: center; gap: 14px; }
.header-kicker { margin: 0 0 5px; color: var(--safat-green); font-size: 10px; font-weight: 700; letter-spacing: 1.1px; }
.portal-header h1 { margin: 0; font-size: 23px; font-weight: 650; }
.menu-button { display: none; border: 0; background: var(--navy); color: #fff; border-radius: 8px; padding: 9px 11px; }
.header-actions { display: flex; align-items: end; gap: 10px; }
.control-group label { display: block; margin: 0 0 5px; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; }
.control-group select { min-width: 155px; height: 40px; padding: 0 34px 0 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
.print-button { height: 40px; padding: 0 16px; border: 0; border-radius: 8px; color: #fff; background: var(--navy); font-weight: 600; }

.report-canvas { padding: 26px 28px 38px; }
.report-banner { position: relative; overflow: hidden; display: flex; justify-content: space-between; align-items: center; gap: 24px; min-height: 155px; padding: 30px 34px; color: #fff; border-radius: 17px; background: linear-gradient(120deg, #006c39, var(--safat-green-2)); box-shadow: var(--shadow); }
.report-banner::after { content: ""; position: absolute; width: 270px; height: 270px; border: 1px solid rgba(255,255,255,.2); transform: rotate(45deg); right: -120px; top: -78px; }
.banner-label, .banner-period span, .section-eyebrow { font-size: 9px; font-weight: 750; letter-spacing: 1.2px; }
.banner-label { color: #f5d77f; }
.report-banner h2 { margin: 8px 0 7px; font-size: 29px; }
.report-banner p { margin: 0; max-width: 700px; color: #dcefe5; line-height: 1.5; }
.banner-period { min-width: 170px; padding: 18px 20px; border-radius: 12px; background: rgba(13,39,28,.22); border: 1px solid rgba(255,255,255,.17); position: relative; z-index: 1; }
.banner-period span, .banner-period strong { display: block; }
.banner-period span { color: #cde8da; }
.banner-period strong { margin-top: 7px; font-size: 19px; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 15px; margin-top: 18px; }
.kpi-card, .dashboard-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 8px 24px rgba(24,45,38,.045); }
.kpi-card { position: relative; overflow: hidden; padding: 19px 20px 17px; }
.kpi-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--safat-green); }
.kpi-top { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12px; }
.market-tag { color: var(--safat-green); background: var(--safat-green-soft); border-radius: 99px; padding: 3px 7px; font-size: 8px; font-weight: 750; }
.market-tag.gold { color: #8a6515; background: var(--safat-gold-soft); }
.kpi-card > strong { display: block; margin: 14px 0 8px; font-size: 24px; }
.kpi-change { display: inline-block; padding: 4px 7px; border-radius: 6px; font-size: 11px; font-weight: 650; }
.kpi-change.positive { color: var(--positive); background: #e8f6ef; }
.kpi-change.negative { color: var(--negative); background: #fdecee; }
.kpi-card small { display: block; margin-top: 10px; color: #89949d; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(310px, .8fr); gap: 17px; margin-top: 17px; }
.dashboard-panel { padding: 20px; }
.panel-heading { display: flex; justify-content: space-between; gap: 15px; align-items: center; margin-bottom: 17px; }
.panel-heading.compact { margin-bottom: 10px; }
.section-eyebrow { color: var(--safat-green); }
.panel-heading h3 { margin: 5px 0 0; font-size: 17px; }
.data-note { color: var(--muted); font-size: 11px; }
.chart-wrap { position: relative; height: 310px; }
.summary-list { display: grid; gap: 4px; }
.summary-item { display: grid; grid-template-columns: 35px 1fr; gap: 11px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.summary-item:last-child { border-bottom: 0; }
.summary-rank { color: var(--safat-gold); font-size: 12px; font-weight: 750; }
.summary-item strong, .summary-item small { display: block; }
.summary-item strong { font-size: 13px; }
.summary-item small { margin-top: 5px; color: var(--muted); line-height: 1.45; }

.table-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 17px; margin-top: 17px; }
.positive-pill, .negative-pill { padding: 5px 8px; border-radius: 99px; font-size: 9px; font-weight: 700; }
.positive-pill { color: var(--positive); background: #e8f6ef; }
.negative-pill { color: var(--negative); background: #fdecee; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { padding: 10px 12px; background: #f7f9f8; color: var(--muted); font-size: 10px; text-align: left; text-transform: uppercase; letter-spacing: .5px; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
.positive-text { color: var(--positive); font-weight: 650; }
.negative-text { color: var(--negative); font-weight: 650; }
.market-table-panel { margin-top: 17px; }
.market-table td:first-child { font-weight: 650; }

.portal-footer { display: flex; justify-content: space-between; gap: 15px; padding: 18px 28px 25px; color: var(--muted); font-size: 10px; }
.sidebar-overlay { display: none; }

@media (max-width: 1180px) {
    .kpi-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .content-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .portal-shell { display: block; }
    .portal-sidebar { position: fixed; left: -290px; width: 270px; transition: left .22s ease; }
    .portal-sidebar.open { left: 0; }
    .sidebar-close, .menu-button { display: block; }
    .sidebar-overlay { position: fixed; inset: 0; background: rgba(10,20,28,.48); z-index: 25; }
    .sidebar-overlay.show { display: block; }
    .portal-header { align-items: flex-start; }
    .header-actions { flex-wrap: wrap; justify-content: flex-end; }
}

@media (max-width: 680px) {
    .portal-header { position: relative; padding: 15px 16px; display: block; }
    .header-left { margin-bottom: 15px; }
    .portal-header h1 { font-size: 19px; }
    .header-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .control-group select { width: 100%; min-width: 0; }
    .print-button { grid-column: 1 / -1; }
    .report-canvas { padding: 16px; }
    .report-banner { display: block; padding: 24px; }
    .report-banner h2 { font-size: 24px; }
    .banner-period { margin-top: 20px; width: 100%; }
    .kpi-grid, .table-grid { grid-template-columns: 1fr; }
    .chart-wrap { height: 250px; }
    .portal-footer { display: block; padding: 14px 16px 22px; }
    .portal-footer span { display: block; margin-top: 5px; }
}

@media print {
    .portal-sidebar, .portal-header, .portal-footer { display: none !important; }
    .portal-shell { display: block; }
    .report-canvas { padding: 0; }
    .dashboard-panel, .kpi-card, .report-banner { box-shadow: none; break-inside: avoid; }
    body { background: #fff; }
}
