:root {
    color-scheme: light;

    /* suprafete */
    --page: #f9f9f7;
    --surface: #fcfcfb;
    --border: rgba(11, 11, 11, 0.10);
    --border-strong: #e1e0d9;

    /* text */
    --fg: #0b0b0b;
    --fg-secondary: #52514e;
    --muted: #898781;

    /* serii de date (fix, niciodata reciclate) */
    --series-sales: #2a78d6;
    --series-sales-soft: rgba(42, 120, 214, 0.12);
    --series-expenses: #eb6834;
    --series-expenses-soft: rgba(235, 104, 52, 0.12);
    --series-profit: #1baf7a;
    --series-profit-soft: rgba(27, 175, 122, 0.12);

    /* status (polaritate profit) */
    --good: #006300;
    --critical: #d03b3b;

    /* legacy alias folosit inca in nav hover */
    --accent: #2a78d6;

    --radius: 12px;
    --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 4px 16px rgba(11, 11, 11, 0.05);
}

* {
    box-sizing: border-box;
}

html {
    -webkit-font-smoothing: antialiased;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--page);
    color: var(--fg);
    line-height: 1.5;
}

a {
    color: inherit;
}

/* ------------------------------------------------------------------ */
/* Sidebar (tema intunecata, separata de restul aplicatiei)            */
/* ------------------------------------------------------------------ */

.app-shell {
    display: flex;
    align-items: stretch;
    min-height: 100vh;
}

.sidebar {
    --sidebar-bg: #16213e;
    --sidebar-text: #f4f6fb;
    --sidebar-muted: #b7c0dc;
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --sidebar-active: rgba(255, 255, 255, 0.14);
    --sidebar-border: rgba(255, 255, 255, 0.10);

    width: 272px;
    flex: none;
    display: flex;
    flex-direction: column;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 1.5rem 1.25rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .55rem;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -.01em;
    color: var(--sidebar-text);
    margin-bottom: 1.5rem;
}

.brand-mark {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    background: linear-gradient(135deg, var(--series-sales), var(--series-profit));
    flex: none;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    margin-bottom: 1.75rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: .65rem;
    color: var(--sidebar-muted);
    text-decoration: none;
    font-size: .94rem;
    font-weight: 500;
    padding: .6rem .65rem;
    border-radius: 8px;
    transition: background .12s ease, color .12s ease;
}

.sidebar-nav a svg {
    width: 17px;
    height: 17px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    flex: none;
}

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

.sidebar-nav a.active {
    background: var(--sidebar-active);
    color: #fff;
}

.sidebar-section-title {
    margin: 0 0 1.1rem;
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--sidebar-muted);
}

.filter-group {
    margin-bottom: 1.4rem;
}

.filter-label {
    margin: 0 0 .5rem;
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--sidebar-muted);
}

.select-wrap {
    position: relative;
    display: block;
}

.filter-select {
    width: 100%;
    appearance: none;
    padding: .7rem 2.2rem .7rem .9rem;
    border-radius: 10px;
    border: none;
    background: #fff;
    font-size: .88rem;
    font-weight: 500;
    color: var(--fg);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.select-chevron {
    position: absolute;
    top: 50%;
    right: .8rem;
    width: 15px;
    height: 15px;
    transform: translateY(-50%);
    stroke: var(--muted);
    fill: none;
    stroke-width: 2;
    pointer-events: none;
}

.filter-reset {
    display: inline-block;
    font-size: .85rem;
    color: var(--sidebar-muted);
    text-decoration: underline;
}

.lang-switch {
    display: flex;
    gap: .4rem;
    max-width: 220px;
}

.lang-switch a {
    flex: 1;
    text-align: center;
    padding: .45rem .5rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--sidebar-muted);
    text-decoration: none;
    font-size: .82rem;
    font-weight: 700;
    letter-spacing: .03em;
}

.lang-switch a.active {
    background: #fff;
    color: var(--fg);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1.25rem;
    border-top: 1px solid var(--sidebar-border);
    font-size: .85rem;
    color: var(--sidebar-muted);
}

/* ------------------------------------------------------------------ */
/* Layout                                                              */
/* ------------------------------------------------------------------ */

.main {
    flex: 1;
    min-width: 0;
}

.content {
    max-width: 1180px;
    padding: 2rem 1.75rem 4rem;
}

.page-head {
    margin-bottom: 1.75rem;
}

.page-head h1 {
    margin: 0 0 .35rem;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -.01em;
}

.page-subtitle {
    margin: 0;
    color: var(--muted);
    font-size: .95rem;
}

.section {
    margin-bottom: 2rem;
}

.section-title {
    margin: 0 0 1rem;
    font-size: 1.05rem;
    font-weight: 600;
}

.two-col {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
    gap: 1.25rem;
    align-items: start;
    min-width: 0;
}

/* ------------------------------------------------------------------ */
/* Cards                                                                */
/* ------------------------------------------------------------------ */

.card {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem 1.4rem;
}

.card-title {
    margin: 0 0 1rem;
    font-size: .95rem;
    font-weight: 600;
    color: var(--fg);
}

/* ------------------------------------------------------------------ */
/* Bara de cautare (ex: pagina Produse)                                 */
/* ------------------------------------------------------------------ */

.search-row {
    position: relative;
    margin-bottom: 1rem;
    max-width: 360px;
}

.search-icon {
    position: absolute;
    top: 50%;
    left: .85rem;
    width: 16px;
    height: 16px;
    transform: translateY(-50%);
    stroke: var(--muted);
    fill: none;
    stroke-width: 2;
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: .65rem .9rem .65rem 2.4rem;
    border-radius: 10px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    font-size: .88rem;
    color: var(--fg);
    box-shadow: var(--shadow);
}

.search-input:focus {
    outline: none;
    border-color: var(--series-sales);
}

/* ------------------------------------------------------------------ */
/* KPI tiles                                                           */
/* ------------------------------------------------------------------ */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
    gap: 1rem;
}

.kpi-tile {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.1rem 1.25rem;
}

.kpi-label {
    margin: 0 0 .4rem;
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
}

.kpi-value {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.01em;
}

/* ------------------------------------------------------------------ */
/* Chart card                                                          */
/* ------------------------------------------------------------------ */

.chart-card {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem 1.4rem 1rem;
}

.chart-card .chart-wrap {
    position: relative;
    height: 300px;
}

.chart-card.chart-compact .chart-wrap {
    height: 220px;
}

.chart-card.chart-wide .chart-wrap {
    height: 340px;
}

/* ------------------------------------------------------------------ */
/* Hero stat - inlocuieste un grafic cu un singur punct de date         */
/* (ex: un an + o luna anume selectate, deci un singur rand posibil)    */
/* ------------------------------------------------------------------ */

.hero-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    min-height: 220px;
    text-align: center;
}

.hero-stat-label {
    margin: 0;
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
}

.hero-stat-value {
    margin: 0;
    font-size: clamp(1.9rem, 7vw, 3rem);
    font-weight: 700;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
}

.hero-stat-sub {
    margin: 0;
    font-size: .85rem;
    color: var(--muted);
}

/* ------------------------------------------------------------------ */
/* Data table                                                          */
/* ------------------------------------------------------------------ */

.table-scroll {
    overflow-x: auto;
    /* Umbra de scroll: semnaleaza vizual ca mai exista continut la dreapta,
       ca tabelele sa nu para "taiate" pe ecrane inguste. Dispare singura
       cand nu mai e nimic de scrollat (gradientul se suprapune pe fundal). */
    background:
        linear-gradient(to right, var(--surface) 50%, rgba(255, 255, 255, 0)) 0 0,
        linear-gradient(to left, var(--surface) 50%, rgba(255, 255, 255, 0)) 100% 0,
        linear-gradient(to right, rgba(11, 11, 11, .12), rgba(255, 255, 255, 0)) 0 0,
        linear-gradient(to left, rgba(11, 11, 11, .12), rgba(255, 255, 255, 0)) 100% 0;
    background-repeat: no-repeat;
    background-size: 24px 100%, 24px 100%, 10px 100%, 10px 100%;
    background-attachment: local, local, scroll, scroll;
}

.table-scroll.table-scroll-y {
    max-height: 520px;
    overflow-y: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}

.data-table caption {
    text-align: left;
    caption-side: top;
    font-weight: 600;
    padding-bottom: .75rem;
}

.data-table thead th {
    position: sticky;
    top: 0;
    background: var(--surface);
    text-align: right;
    color: var(--muted);
    font-weight: 600;
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    padding: .6rem .75rem;
    border-bottom: 1px solid var(--border-strong);
    white-space: nowrap;
}

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

.data-table tbody td,
.data-table tfoot td {
    padding: .6rem .75rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table tbody td:first-child,
.data-table tfoot td:first-child {
    font-variant-numeric: normal;
    white-space: normal;
    font-weight: 500;
}

.data-table tbody tr:nth-child(even) {
    background: rgba(11, 11, 11, 0.015);
}

.data-table tbody tr:hover {
    background: var(--series-sales-soft);
}

.data-table .muted-cell {
    color: var(--muted);
    font-weight: 400;
}

.data-table .text-cell {
    text-align: left;
    white-space: normal;
    font-variant-numeric: normal;
    font-weight: 500;
}

.trend-up {
    color: var(--good);
}

.trend-down {
    color: var(--critical);
}

.trend-up::before {
    content: "\25B2 ";
    font-size: .65em;
}

.trend-down::before {
    content: "\25BC ";
    font-size: .65em;
}

/* ------------------------------------------------------------------ */
/* Legend (custom, sub grafic)                                         */
/* ------------------------------------------------------------------ */

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: .75rem;
    padding-top: .75rem;
    border-top: 1px solid var(--border);
    font-size: .82rem;
    color: var(--fg-secondary);
}

.chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}

.chart-legend i {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    display: inline-block;
}

/* ------------------------------------------------------------------ */
/* Rezumat compact (ex: trimestrial, pe pagina Vanzari/Cheltuieli/Profit) */
/* ------------------------------------------------------------------ */

.summary-block {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px dashed var(--border-strong);
}

/* ------------------------------------------------------------------ */
/* Tabel pivot (ex: subcategorii x an) - acelasi stil ca orice alt      */
/* .data-table, doar cu accent tipografic (fara culori noi) pe totaluri */
/* ------------------------------------------------------------------ */

.pivot-table .pivot-total-col {
    font-weight: 700;
}

.pivot-grand-row td {
    font-weight: 700;
    border-top: 2px solid var(--border-strong);
}

/* ------------------------------------------------------------------ */
/* Responsive                                                          */
/* ------------------------------------------------------------------ */

@media (max-width: 900px) {
    .app-shell {
        flex-direction: column;
    }

    .sidebar {
        width: auto;
        height: auto;
        position: static;
        border-right: none;
        border-bottom: 1px solid var(--sidebar-border);
    }

    .sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
        padding-bottom: 1rem;
    }

    .sidebar-nav a span {
        display: none;
    }

    .sidebar-filters {
        display: flex;
        flex-wrap: wrap;
        gap: 1rem 1.5rem;
        align-items: flex-start;
    }

    .sidebar-filters .filter-group {
        flex: 1 1 150px;
        min-width: 130px;
        margin-bottom: 0;
    }

    .sidebar-filters .filter-reset {
        flex-basis: 100%;
    }

    .lang-switch {
        max-width: none;
    }

    .sidebar-footer {
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: none;
    }
}

/* Tableta: sidebar-ul ramane vertical, dar cardurile din .two-col au mai
   putin spatiu disponibil - fortam un singur rand de continut mai devreme. */
@media (max-width: 1080px) and (min-width: 901px) {
    .two-col {
        grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
    }
}

@media (max-width: 640px) {
    .content {
        padding: 1.5rem 1.1rem 3rem;
    }

    .page-head h1 {
        font-size: 1.35rem;
    }

    .chart-card .chart-wrap {
        height: 240px;
    }

    .chart-card.chart-compact .chart-wrap {
        height: 200px;
    }

    .chart-card.chart-wide .chart-wrap {
        height: 260px;
    }

    .kpi-value {
        font-size: 1.3rem;
    }

    .data-table {
        font-size: .82rem;
    }

    .data-table thead th,
    .data-table tbody td,
    .data-table tfoot td {
        padding: .5rem .6rem;
    }
}
