/* ══════════════════════════════════════════════════════════════
   nusa.id Analytics — Executive Dashboard
   Light premium theme with glassmorphism & wow effects
   ══════════════════════════════════════════════════════════════ */

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

:root {
    /* ── nusa.id brand ── */
    --brand-red: #DC2626;
    --brand-red-hover: #B91C1C;
    --brand-red-soft: #FEE2E2;

    /* ── Light palette ── */
    --bg-body: #F3F4F8;
    --bg-card: #ffffff;
    --bg-card-alt: #FAFBFC;
    --bg-glass: rgba(255, 255, 255, 0.72);
    --bg-glass-hover: rgba(255, 255, 255, 0.9);
    --border: rgba(0, 0, 0, 0.06);
    --border-hover: rgba(0, 0, 0, 0.12);
    --text-primary: #111827;
    --text-secondary: #4B5563;
    --text-muted: #9CA3AF;

    /* ── Accents ── */
    --accent-red: #DC2626;
    --accent-orange: #F97316;
    --accent-amber: #F59E0B;
    --accent-teal: #14B8A6;
    --accent-sky: #0EA5E9;
    --accent-green: #059669;
    --accent-rose: #F43F5E;

    /* ── Gradients ── */
    --gradient-brand: linear-gradient(135deg, #DC2626 0%, #F97316 100%);
    --gradient-warm: linear-gradient(135deg, #F97316 0%, #FBBF24 100%);
    --gradient-cool: linear-gradient(135deg, #0EA5E9 0%, #14B8A6 100%);
    --gradient-muted: linear-gradient(135deg, #6B7280 0%, #9CA3AF 100%);
    --gradient-hero: linear-gradient(135deg, #DC2626 0%, #F97316 50%, #FBBF24 100%);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.08);
    --shadow-glow: 0 0 40px rgba(220, 38, 38, 0.08);
    --radius: 16px;
    --radius-sm: 10px;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Hero glow background ── */
body::before {
    content: '';
    position: fixed;
    top: -20%;
    left: 10%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(220, 38, 38, 0.06) 0%, transparent 70%);
    z-index: 0;
    pointer-events: none;
}

body::after {
    content: '';
    position: fixed;
    bottom: -10%;
    right: 5%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(249, 115, 22, 0.05) 0%, transparent 70%);
    z-index: 0;
    pointer-events: none;
}

/* ── Header ── */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(20px) saturate(1.8);
    -webkit-backdrop-filter: blur(20px) saturate(1.8);
    border-bottom: 1px solid var(--border);
    padding: 0 32px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
    padding-left: 20px;
    border-left: 1px solid var(--border);
}

.nav-link {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 6px;
    transition: all 0.2s;
    letter-spacing: 0.01em;
}

.nav-link:hover {
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.04);
}

.nav-link.active {
    color: var(--text-primary);
    font-weight: 600;
    background: rgba(0, 0, 0, 0.05);
}

.logo {
    font-weight: 800;
    font-size: 20px;
    letter-spacing: -0.5px;
}

.logo span {
    color: var(--brand-red);
}

.header-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--brand-red-soft);
    color: var(--accent-red);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

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

/* ── Period Selector ── */
.period-selector {
    display: flex;
    background: var(--bg-body);
    border-radius: 10px;
    padding: 3px;
    border: 1px solid var(--border);
}

.period-btn {
    padding: 7px 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.period-btn:hover {
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.03);
}

.period-btn.active {
    background: var(--gradient-brand);
    color: white;
    box-shadow: 0 2px 12px rgba(220, 38, 38, 0.25);
}

.refresh-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 16px;
}

.refresh-btn:hover {
    border-color: var(--accent-red);
    color: var(--accent-red);
    box-shadow: var(--shadow-sm);
}

.refresh-btn.loading {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.last-updated {
    font-size: 12px;
    color: var(--text-muted);
}

/* ── Custom Date Range ── */
.custom-range {
    display: flex;
    align-items: center;
    gap: 8px;
}

.date-input {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 12px;
    color: var(--text-primary);
    background: var(--bg-card);
    outline: none;
    cursor: pointer;
}

.date-input:focus {
    border-color: var(--accent-red);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.date-sep {
    color: var(--text-muted);
    font-size: 14px;
}

.apply-btn {
    padding: 6px 14px;
    border: none;
    border-radius: 8px;
    background: var(--gradient-brand);
    color: white;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.apply-btn:hover {
    box-shadow: 0 2px 12px rgba(220, 38, 38, 0.3);
    transform: translateY(-1px);
}

/* ── Sync Button ── */
.sync-btn {
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s;
}

.sync-btn:hover {
    border-color: var(--accent-red);
    color: var(--accent-red);
    box-shadow: var(--shadow-sm);
}

.sync-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}

/* ── Main Content ── */
.main {
    position: relative;
    z-index: 1;
    max-width: 1440px;
    margin: 0 auto;
    padding: 28px 48px 56px;
}

/* ── Generic Grid ── */
.grid {
    display: grid;
    gap: 20px;
    margin-bottom: 32px;
}

.grid-2 {
    grid-template-columns: 1fr 1fr;
}

.grid-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

/* ── KPI Cards ── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius) var(--radius) 0 0;
}

.kpi-card:nth-child(1)::before {
    background: var(--gradient-brand);
}

.kpi-card:nth-child(2)::before {
    background: var(--gradient-warm);
}

.kpi-card:nth-child(3)::before {
    background: var(--gradient-cool);
}

.kpi-card:nth-child(4)::before {
    background: var(--gradient-muted);
}

.kpi-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.kpi-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.kpi-tooltip {
    position: relative;
    display: inline-flex;
    cursor: help;
}

.kpi-tooltip .tooltip-icon {
    font-size: 11px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.kpi-tooltip:hover .tooltip-icon {
    opacity: 1;
}

.kpi-tooltip .tooltip-text {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1F2937;
    color: #F9FAFB;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    line-height: 1.5;
    white-space: normal;
    width: 220px;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
}

.kpi-tooltip .tooltip-text::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-bottom-color: #1F2937;
}

.kpi-tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

.kpi-value {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -1px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.kpi-change {
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 6px;
}

.kpi-change.up {
    color: var(--accent-green);
    background: rgba(5, 150, 105, 0.08);
}

.kpi-change.down {
    color: var(--accent-red);
    background: rgba(220, 38, 38, 0.08);
}

.kpi-change.neutral {
    color: var(--text-muted);
    background: rgba(156, 163, 175, 0.1);
}

/* ── Section Headers ── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    margin-bottom: 20px;
}

.section-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── Chart Panels ── */
.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    transition: all 0.3s;
    box-shadow: var(--shadow-sm);
}

.chart-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow);
}

.chart-card.full-width {
    grid-column: 1 / -1;
}

.chart-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

/* ── Three Column Grid ── */
.chart-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

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

.data-table thead th {
    text-align: left;
    padding: 10px 12px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.data-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.data-table tbody tr:hover td {
    background: rgba(0, 0, 0, 0.015);
    color: var(--text-primary);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.page-path {
    color: var(--accent-red);
    font-weight: 500;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
}

.badge-green {
    background: rgba(5, 150, 105, 0.1);
    color: var(--accent-green);
}

.badge-red {
    background: rgba(220, 38, 38, 0.1);
    color: var(--accent-red);
}

.badge-blue {
    background: rgba(14, 165, 233, 0.1);
    color: var(--accent-sky);
}

.badge-orange {
    background: rgba(249, 115, 22, 0.1);
    color: var(--accent-orange);
}

.badge-amber {
    background: rgba(245, 158, 11, 0.1);
    color: var(--accent-amber);
}

/* ── Skeleton Loading ── */
.skeleton {
    background: linear-gradient(90deg, #E5E7EB 25%, #F9FAFB 50%, #E5E7EB 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 8px;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 20px;
    width: 60%;
    margin-bottom: 8px;
}

.skeleton-value {
    height: 36px;
    width: 40%;
}

/* ── Pillar Distribution ── */
.pillar-bar {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin: 8px 0;
    background: var(--bg-body);
}

.pillar-segment {
    height: 100%;
    transition: width 0.5s ease;
}

.pillar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 8px;
}

.pillar-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.pillar-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* ── Horizontal Bar ── */
.h-bar-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
}

.h-bar-label {
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 120px;
    text-align: right;
}

.h-bar-track {
    flex: 1;
    height: 22px;
    background: var(--bg-body);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.h-bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.6s ease;
    display: flex;
    align-items: center;
    padding-left: 8px;
    font-size: 11px;
    font-weight: 600;
    color: white;
    min-width: fit-content;
}

.h-bar-value {
    font-size: 12px;
    color: var(--text-muted);
    min-width: 50px;
    text-align: right;
}

/* ── Animations ── */
.fade-in {
    animation: fadeInUp 0.4s ease-out both;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chart-grid> :nth-child(1) {
    animation-delay: 0.05s;
}

.chart-grid> :nth-child(2) {
    animation-delay: 0.1s;
}

.chart-grid> :nth-child(3) {
    animation-delay: 0.15s;
}

.chart-grid-3> :nth-child(1) {
    animation-delay: 0.05s;
}

.chart-grid-3> :nth-child(2) {
    animation-delay: 0.1s;
}

.chart-grid-3> :nth-child(3) {
    animation-delay: 0.15s;
}

/* ── Responsive ── */
@media (max-width: 1200px) {
    .chart-grid-3 {
        grid-template-columns: 1fr 1fr;
    }
}

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

    .chart-grid {
        grid-template-columns: 1fr;
    }

    .chart-grid-3 {
        grid-template-columns: 1fr;
    }

    .main {
        padding: 16px;
    }
}

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

    .header {
        padding: 0 16px;
    }

    .period-selector {
        display: none;
    }
}


/* ═══════════════════════════════════════════════════════════════
   Auth UI: Group selector, User menu, No-access overlay
   ═══════════════════════════════════════════════════════════════ */

/* ── Group selector dropdown ── */
.group-selector {
    display: flex;
    align-items: center;
    margin-right: 8px;
}

.group-select {
    padding: 6px 28px 6px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='3'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    transition: border-color 0.2s;
}

.group-select:hover {
    border-color: var(--accent-primary);
}

/* ── User menu ── */
.user-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 12px;
    padding-left: 12px;
    border-left: 1px solid var(--border);
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}

.user-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logout-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 14px;
    transition: all 0.2s;
}

.logout-btn:hover {
    border-color: var(--accent-red);
    color: var(--accent-red);
    background: rgba(220, 38, 38, 0.06);
}

/* ── No-access overlay ── */
.no-access-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.no-access-card {
    background: white;
    border-radius: 20px;
    padding: 48px 40px;
    text-align: center;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.no-access-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.no-access-card h2 {
    font-size: 22px;
    font-weight: 700;
    color: #1F2937;
    margin-bottom: 12px;
}

.no-access-card p {
    font-size: 14px;
    color: #6B7280;
    line-height: 1.6;
}

.google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 12px 20px;
    border: 2px solid #E5E7EB;
    border-radius: 12px;
    background: white;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
}

.google-btn:hover {
    border-color: #DC2626;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.1);
}

/* ══════════════════════════════════════════════════════════════
   Trend & Insights
   ══════════════════════════════════════════════════════════════ */

.section-badge {
    display: inline-block;
    padding: 4px 14px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    letter-spacing: 0.02em;
}

.chart-card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.03em;
    text-transform: uppercase;
    margin-bottom: 8px;
}

/* ── AI Narrative ── */

.narrative-card {
    border-left: 3px solid var(--brand-red);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(254, 226, 226, 0.08) 100%);
    padding: 24px 28px 24px 32px;
}

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

.narrative-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.narrative-refresh {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.narrative-refresh:hover {
    color: var(--brand-red);
    border-color: var(--brand-red);
    transform: rotate(45deg);
}

.narrative-text {
    font-size: 14px;
    line-height: 1.75;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.narrative-loading {
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
    padding: 12px 0;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

.narrative-sections {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.narrative-col-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid transparent;
}

.highlight-title {
    color: #059669;
    border-color: #D1FAE5;
}

.alert-title {
    color: #D97706;
    border-color: #FEF3C7;
}

.rec-title {
    color: #2563EB;
    border-color: #DBEAFE;
}

.narrative-list {
    list-style: none;
    padding: 0;
}

.narrative-list li {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
    padding: 6px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

.narrative-list li:last-child {
    border-bottom: none;
}

/* ── MoM / QoQ Tables ── */

.mom-card {
    padding: 20px;
}

.mom-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.02em;
    text-transform: uppercase;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border);
}

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

.mom-table thead th {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 6px 8px 10px;
    text-align: right;
    border-bottom: 1px solid var(--border);
}

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

.mom-table td {
    padding: 7px 8px;
    text-align: right;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

.mom-metric {
    text-align: left !important;
    color: var(--text-secondary);
    font-weight: 500 !important;
}

.mom-pos {
    color: #059669;
    font-weight: 600 !important;
}

.mom-neg {
    color: #DC2626;
    font-weight: 600 !important;
}

.mom-flat {
    color: var(--text-muted);
}

.mom-na {
    color: var(--text-muted);
    font-weight: 400 !important;
}

.mom-val {
    color: var(--text-primary);
    font-weight: 600 !important;
    font-variant-numeric: tabular-nums;
}

.mom-vs {
    display: block;
    font-size: 10px;
    font-weight: 400 !important;
    color: var(--text-muted);
    margin-top: 1px;
}

@media (max-width: 768px) {
    .narrative-sections {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

/* ── Memos Page ── */

.memo-main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 28px 48px 48px;
}

.memo-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.memo-page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

.memo-generate-btn {
    padding: 9px 22px;
    font-size: 14px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    border: none;
    border-radius: 8px;
    background: var(--brand-red);
    color: white;
    cursor: pointer;
    transition: all .2s;
}

.memo-generate-btn:hover {
    background: var(--brand-red-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.2);
}

.memo-generate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.memo-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 24px;
}

.memo-tab {
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all .2s;
}

.memo-tab:hover {
    background: var(--bg-card-alt);
    border-color: var(--border-hover);
}

.memo-tab.active {
    background: var(--brand-red);
    border-color: var(--brand-red);
    color: white;
}

/* Two-column layout */
.memo-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 24px;
    align-items: start;
}

.memo-content-col {
    min-width: 0;
}

/* Memo cards */
.memo-card {
    padding: 28px 32px;
    margin-bottom: 16px;
}

.memo-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 14px;
}

.memo-summary {
    color: var(--text-secondary);
    line-height: 1.75;
    margin: 0;
    font-size: 14.5px;
}

.memo-meta {
    margin-top: 14px;
    font-size: 12px;
    color: var(--text-muted);
}

.memo-sections-grid {
    display: grid;
    gap: 16px;
    margin-bottom: 16px;
}

.memo-section-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 12px;
}

.memo-list {
    margin: 0;
    padding-left: 20px;
    line-height: 1.85;
    color: var(--text-secondary);
    font-size: 14px;
}

.memo-alerts-card {
    border-left: 4px solid var(--danger);
}

/* History Sidebar */
.memo-sidebar {
    position: sticky;
    top: 80px;
}

.memo-sidebar-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.memo-sidebar-title {
    font-size: 14px;
    font-weight: 700;
    margin: 0 0 16px;
    color: var(--text-primary);
}

.memo-history-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 500px;
    overflow-y: auto;
}

.memo-history-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all .2s;
    background: transparent;
}

.memo-history-item:hover {
    border-color: var(--brand-red);
    background: var(--brand-red-soft);
}

.memo-history-item.active {
    border-color: var(--brand-red);
    background: var(--brand-red-soft);
    box-shadow: inset 3px 0 0 var(--brand-red);
}

.memo-history-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.memo-history-date {
    font-size: 11px;
    color: var(--text-muted);
}

.memo-history-empty {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    padding: 20px 0;
}

/* Responsive */
@media (max-width: 900px) {
    .memo-main {
        padding: 20px 20px 40px;
    }

    .memo-layout {
        grid-template-columns: 1fr;
    }

    .memo-sidebar {
        position: static;
    }

    .memo-card {
        padding: 20px;
    }
}