:root {
    --plane: #0a0e1a;
    --surface: #1a1f2e;
    --raised: #242d3d;
    --ink: #EDEDEE;
    --ink-2: #8a92a8;
    --muted: #7a8496;
    --accent: #FF5252;
    --accent-dim: #C41C3B;
    --mint: #E63946;
    --critical: #F87171;
    --neon: #C6F24E;
    --line: rgba(237, 237, 238, 0.10);
    --line-soft: rgba(237, 237, 238, 0.055);
    --radius: 14px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

[hidden] {
    display: none !important;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--plane);
    color: var(--ink);
    font: 14px / 1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(1100px 620px at 12% -8%, rgba(150, 100, 200, 0.05), transparent 62%),
        radial-gradient(900px 520px at 88% 0%, rgba(100, 150, 255, 0.04), transparent 60%);
}

.container {
    position: relative;
    z-index: 2;
    max-width: 1620px;
    margin: 0 auto;
    padding: 0 22px 72px;
    animation: fadeInUp 0.6s ease-out;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes glowPulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(255, 82, 82, 0.2);
    }
    50% {
        box-shadow: 0 0 40px rgba(255, 82, 82, 0.3);
    }
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--surface) 0%, rgba(28, 42, 36, 0.95) 100%);
    color: var(--ink);
    padding: 28px 20px;
    border-bottom: 1px solid var(--line);
    margin: -24px -22px 30px -22px;
    animation: slideInDown 0.5s ease-out;
}

.header-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 40px;
    max-width: 1620px;
    margin: 0 auto;
}

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

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

.logo-badge {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--accent) 0%, #C41C3B 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    color: var(--plane);
    box-shadow: 0 4px 12px rgba(255, 82, 82, 0.15);
}

.header-titles {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.header-titles h1 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--ink);
    margin: 0;
}

.subtitle-with-sync {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.subtitle-with-sync p {
    font-size: 13px;
    color: var(--ink-2);
    margin: 0;
    font-weight: 400;
    letter-spacing: 0.01em;
}

.sync-info {
    font-size: 11px;
    color: var(--muted);
    font-weight: 400;
    letter-spacing: 0.3px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
    padding-right: 60px;
}

/* Period Controls */
.period-controls {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap;
}

/* Segment Button Group */
.seg {
    display: flex;
    gap: 3px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 11px;
    padding: 4px;
}

.period-btn {
    font: inherit;
    font-size: 12.5px;
    color: var(--ink-2);
    background: none;
    border: 0;
    padding: 6px 12px;
    border-radius: 7px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.18s, color 0.18s;
}

.period-btn:hover {
    background: rgba(237, 237, 238, 0.06);
    color: var(--ink);
}

.period-btn[aria-pressed="true"] {
    background: var(--accent);
    color: #12200F;
    font-weight: 620;
    box-shadow: 0 0 18px rgba(255, 82, 82, 0.28);
}

/* Stepper (Month Navigation) */
.stepper {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 11px;
    overflow: hidden;
}

.stepper button {
    font: inherit;
    font-size: 15px;
    line-height: 1;
    color: var(--ink-2);
    background: none;
    border: 0;
    padding: 9px 11px;
    cursor: pointer;
    transition: background 0.18s, color 0.18s;
}

.stepper button:hover:not(:disabled) {
    background: rgba(237, 237, 238, 0.07);
    color: var(--ink);
}

.stepper button:disabled {
    color: #4a5548;
    cursor: default;
}

.stepper select {
    font: inherit;
    font-size: 12.5px;
    color: var(--ink);
    background-color: var(--surface);
    border: 0;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    padding: 8px 10px;
    cursor: pointer;
    min-width: 190px;
    color-scheme: dark;
    -webkit-appearance: none;
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%),
                      linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
    background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 30px;
}

.stepper select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

select option, select optgroup {
    background-color: #172114;
    color: #EDEDEE;
}

/* Custom Date Range */
.custom-dates {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12.5px;
    color: var(--muted);
}

.custom-dates input {
    font: inherit;
    font-size: 12.5px;
    color: var(--ink);
    background-color: var(--surface);
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 7px 9px;
    color-scheme: dark;
}

.custom-dates input::-webkit-calendar-picker-indicator {
    filter: invert(1) brightness(1.6);
    opacity: 0.65;
    cursor: pointer;
}

.custom-dates input::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

.custom-dates input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

/* Home Button */
.home-btn {
    position: fixed;
    top: 18px;
    right: 20px;
    z-index: 100;
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex: none;
    border: 1px solid var(--line);
    background: var(--raised);
    color: var(--accent);
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
    transition: border-color 0.2s ease, transform 0.2s ease;
    text-decoration: none;
}

.home-btn svg {
    width: 20px;
    height: 20px;
    filter: drop-shadow(0 0 3px var(--accent));
    transition: filter 0.2s ease;
}

.home-btn:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}

.home-btn:hover svg {
    filter: drop-shadow(0 0 7px var(--accent)) drop-shadow(0 0 3px var(--accent));
}

.header-content h1 {
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin-bottom: 8px;
}

.header-content h2 {
    font-size: 20px;
    font-weight: 400;
    letter-spacing: -0.01em;
    color: var(--ink-2);
}

/* Insights Section */
.insights-section {
    margin-bottom: 30px;
    animation: fadeInUp 0.6s ease-out 0.05s both;
}

.insights-card {
    background: linear-gradient(135deg, var(--surface) 0%, var(--raised) 100%);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 25px;
    transition: var(--transition);
}

.insights-card:hover {
    border-color: rgba(255, 82, 82, 0.34);
    box-shadow: 0 20px 40px rgba(255, 82, 82, 0.1);
}

.insights-card h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.insights-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.insight-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 82, 82, 0.05);
    border-radius: 8px;
    border-left: 3px solid var(--accent);
    transition: var(--transition);
}

.insight-item:hover {
    background: rgba(255, 82, 82, 0.1);
    border-left-color: var(--accent);
}

.insight-icon {
    font-size: 18px;
    flex-shrink: 0;
    line-height: 1.5;
}

.insight-text {
    font-size: 13px;
    line-height: 1.6;
    color: var(--ink-2);
}

.insight-text strong {
    color: var(--ink);
    font-weight: 600;
}

/* KPI Section */
.kpi-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    padding: 0;
    margin-bottom: 30px;
    animation: fadeInUp 0.6s ease-out 0.1s both;
}

.kpi-card {
    background: linear-gradient(135deg, var(--surface) 0%, var(--raised) 100%);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 25px;
    text-align: center;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 82, 82, 0.1) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.kpi-card:hover {
    background: linear-gradient(135deg, var(--raised) 0%, #1C2A24 100%);
    border-color: rgba(255, 82, 82, 0.34);
    transform: translateY(-6px);
    box-shadow: 0 20px 40px rgba(255, 82, 82, 0.15);
}

.kpi-card:hover::before {
    opacity: 1;
}

.kpi-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    margin-bottom: 12px;
    font-weight: 600;
    transition: color 0.3s ease;
}

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

.kpi-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--accent);
    transition: color 0.3s ease;
}

.kpi-card:hover .kpi-value {
    color: var(--accent);
    text-shadow: 0 0 20px rgba(255, 82, 82, 0.4);
}

.kpi-value.stripe-color {
    color: #ff9d56;
}

.kpi-card:hover .kpi-value.stripe-color {
    color: #ffb07a;
    text-shadow: 0 0 20px rgba(255, 157, 86, 0.3);
}

.kpi-value.finance-color {
    color: #5b8def;
}

.kpi-card:hover .kpi-value.finance-color {
    color: #7da3f5;
    text-shadow: 0 0 20px rgba(91, 141, 239, 0.3);
}

.kpi-value.eft-color {
    color: #9b59b6;
}

.kpi-card:hover .kpi-value.eft-color {
    color: #b377d9;
    text-shadow: 0 0 20px rgba(155, 89, 182, 0.3);
}

/* Charts Section */
.charts-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
}

.chart-container {
    background: linear-gradient(135deg, var(--surface) 0%, var(--raised) 100%);
    border-radius: var(--radius);
    padding: 25px;
    border: 1px solid var(--line);
    transition: var(--transition);
    animation: fadeInUp 0.6s ease-out 0.2s both;
    position: relative;
    overflow: hidden;
}

.chart-container::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(600px circle at var(--gx, 50%) var(--gy, 50%),
        rgba(255, 82, 82, 0.08), transparent 80%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.chart-container:hover {
    border-color: rgba(255, 82, 82, 0.34);
    box-shadow: 0 20px 40px rgba(255, 82, 82, 0.1);
    transform: translateY(-4px);
}

.chart-container:hover::before {
    opacity: 1;
}

.chart-container h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
    transition: color 0.3s ease;
}

.chart-container:hover h3 {
    color: var(--accent);
}

.chart-container canvas {
    max-height: 400px;
}

/* Table Section */
.table-section {
    padding: 25px;
    background: linear-gradient(135deg, var(--surface) 0%, var(--raised) 100%);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 30px;
    transition: var(--transition);
    animation: fadeInUp 0.6s ease-out 0.3s both;
}

.table-section:hover {
    border-color: rgba(255, 82, 82, 0.34);
    box-shadow: 0 20px 40px rgba(255, 82, 82, 0.1);
}

.table-section h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

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

.data-table thead {
    background-color: var(--raised);
}

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

.data-table td {
    padding: 15px 12px;
    border-bottom: 1px solid var(--line-soft);
    color: var(--ink);
    transition: background-color 0.2s ease;
}

.data-table tbody tr:hover {
    background-color: rgba(255, 82, 82, 0.08);
}

.data-table tbody tr:hover td {
    color: var(--accent);
}

.data-table tbody tr:last-child td {
    border-bottom: 1px solid var(--line);
}

/* Collapsible Section */
.collapsible-header {
    cursor: pointer;
    user-select: none;
}

.collapsible-header h3 {
    cursor: pointer;
}

.collapsible-header:hover h3 {
    color: var(--accent);
}

.collapse-icon {
    display: inline-block;
    transition: transform 0.3s ease;
    font-size: 12px;
}

.collapsible-header.open .collapse-icon {
    transform: rotate(180deg);
}

.collapsible-content {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.collapsible-content.open {
    display: block !important;
}

/* Loading Message */
.loading-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
    font-size: 16px;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .header-wrapper {
        flex-direction: column;
        gap: 20px;
        align-items: flex-start;
    }

    .header-right {
        width: 100%;
    }

    .date-selector {
        width: 100%;
    }

    .month-selector {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 15px 72px;
    }

    .header-wrapper {
        flex-direction: column;
        gap: 16px;
        align-items: stretch;
    }

    .header-left {
        flex-direction: column;
        gap: 12px;
    }

    .sync-info {
        font-size: 10px;
    }

    .date-selector {
        gap: 8px;
        flex-wrap: wrap;
        padding: 6px 10px;
    }

    .date-label {
        font-size: 10px;
    }

    .date-selector {
        padding: 12px 10px;
        gap: 8px;
    }

    .date-selector input[type="date"] {
        font-size: 11px;
        padding: 6px 8px;
        flex: 1;
        min-width: 110px;
    }

    .date-separator {
        font-size: 11px;
        flex-basis: 100%;
    }

    .date-label {
        flex-basis: 100%;
    }

    .kpi-section {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 15px;
    }

    .kpi-card {
        padding: 15px;
    }

    .kpi-value {
        font-size: 24px;
    }

    .charts-section {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .chart-container {
        padding: 15px;
    }

    .table-section {
        padding: 15px;
    }

    .data-table {
        font-size: 12px;
    }

    .data-table th,
    .data-table td {
        padding: 10px 8px;
    }

    .header-titles h1 {
        font-size: 16px;
    }

    .header-titles p {
        font-size: 12px;
    }
}

@media (max-width: 768px) {
    .header-right {
        flex-direction: column;
    }

    .period-buttons {
        order: 1;
        width: 100%;
    }

    .date-selector {
        order: 2;
        width: 100%;
        margin-top: 12px;
    }
}

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

    .charts-section {
        grid-template-columns: 1fr;
    }

    .chart-container {
        padding: 12px;
    }

    .table-section {
        padding: 12px;
    }

    .home-btn {
        width: 36px;
        height: 36px;
    }

    .period-buttons {
        justify-content: space-between;
    }

    .period-btn {
        flex: 1;
        min-width: auto;
        padding: 8px 12px;
        font-size: 11px;
    }

    .date-selector {
        flex-direction: column;
        gap: 10px;
        padding: 10px 12px;
    }

    .date-label {
        width: 100%;
    }

    .date-separator {
        display: none;
    }

    .date-selector input[type="date"] {
        width: 100%;
    }
}
