/* Cote de piata - stil dashboard.
   Culorile de serie vin din paleta categoriala validata (slot 1/2/3);
   ambele moduri sunt alese explicit, nu inversate automat. */

:root {
  color-scheme: light;
  --surface-0: #f6f5f2;
  --surface-1: #fcfcfb;
  --surface-2: #efeeea;
  --border:    #dedcd5;
  --border-soft: #e9e7e1;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #86847d;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --grid: #e6e4de;
  --up:   #0f7a4a;
  --down: #c0392b;
  --accent: #184f95;
  --radius: 10px;
  --status-warn: #eda100;
  --hl-bg: rgb(42 120 214 / 7%);
  --shadow: 0 1px 2px rgb(11 11 11 / 5%), 0 1px 8px rgb(11 11 11 / 4%);
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-0: #121211;
    --surface-1: #1a1a19;
    --surface-2: #232322;
    --border:    #34342f;
    --border-soft: #2a2a27;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #8d8c82;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --grid: #2e2e2a;
    --up:   #4caf7d;
    --down: #ef7568;
    --accent: #86b6ef;
    --status-warn: #c98500;
    --hl-bg: rgb(57 135 229 / 12%);
    --shadow: none;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #121211;
  --surface-1: #1a1a19;
  --surface-2: #232322;
  --border:    #34342f;
  --border-soft: #2a2a27;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #8d8c82;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --grid: #2e2e2a;
  --up:   #4caf7d;
  --down: #ef7568;
  --accent: #86b6ef;
  --status-warn: #c98500;
  --hl-bg: rgb(57 135 229 / 12%);
  --shadow: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* --- antet --- */
.topbar {
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  padding: 18px 0;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand .mark {
  width: 8px; height: 38px; border-radius: 4px;
  background: linear-gradient(var(--series-1), var(--accent));
  flex: none;
}
.topbar h1 { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -0.01em; }
.topbar .sub { margin: 2px 0 0; font-size: 13px; color: var(--text-secondary); }

/* --- segmente (VP / LCV) --- */
.segments { display: flex; gap: 0; padding-top: 18px; border-bottom: 1px solid var(--border); }
.seg-tab {
  display: flex; flex-direction: column; gap: 1px;
  padding: 10px 20px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 15px; font-weight: 600;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.seg-tab small { font-size: 11px; font-weight: 500; color: var(--text-muted); }
.seg-tab:hover { color: var(--text-primary); }
.seg-tab.on { color: var(--text-primary); border-bottom-color: var(--series-1); }

/* --- filtre --- */
.filters {
  display: flex; flex-wrap: wrap; gap: 14px;
  padding-top: 18px; padding-bottom: 4px;
}
.filters label { display: flex; flex-direction: column; gap: 5px; min-width: 168px; }
.filters label.hidden { display: none; }
.filters label.dim { opacity: 0.55; }
.filters span { font-size: 12px; font-weight: 600; color: var(--text-secondary); letter-spacing: 0.02em; }
.filters small { font-size: 11px; color: var(--text-muted); }
.filters select {
  font: inherit; font-size: 14px;
  padding: 8px 10px;
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.filters select:focus-visible { outline: 2px solid var(--series-1); outline-offset: 1px; }
.filters .apply-wrap { min-width: auto; justify-content: flex-end; }
.filters .apply-wrap[hidden] { display: none; }
.filters .apply {
  font: inherit; font-size: 14px; font-weight: 620;
  padding: 8px 18px; border: 0; border-radius: 8px; cursor: pointer;
  color: #fff; background: var(--series-1);
}
.filters .apply:hover { background: var(--accent); }

/* --- taburi --- */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 16px; }
.tab {
  display: flex; flex-direction: column; gap: 2px;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px; font-weight: 600;
  transition: border-color .12s, color .12s;
}
.tab b { font-size: 17px; font-weight: 680; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.tab:hover { border-color: var(--text-muted); }
.tab.on { border-color: var(--series-1); box-shadow: inset 0 0 0 1px var(--series-1); color: var(--text-primary); }

main { padding-top: 8px; padding-bottom: 40px; }

.context { font-size: 13px; color: var(--text-secondary); margin: 16px 0 12px; }
.context .logout { float: right; color: var(--text-muted); text-decoration: none; font-size: 12px; }
.context .logout:hover { color: var(--text-primary); text-decoration: underline; }

/* --- pagina de autentificare --- */
.loginpage { display: grid; place-items: center; min-height: 100vh; }
.loginbox {
  width: min(380px, calc(100vw - 40px));
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 26px 26px 28px;
  box-shadow: var(--shadow);
}
.loginbox .brand { margin-bottom: 22px; }
.loginbox h1 { margin: 0; font-size: 18px; font-weight: 650; }
.loginbox .sub { margin: 2px 0 0; font-size: 12.5px; color: var(--text-secondary); }
.loginbox label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.loginbox label span { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.loginbox input {
  font: inherit; font-size: 15px; padding: 10px 12px;
  color: var(--text-primary); background: var(--surface-0);
  border: 1px solid var(--border); border-radius: 8px;
}
.loginbox input:focus-visible { outline: 2px solid var(--series-1); outline-offset: 1px; }
.loginbox button {
  width: 100%; font: inherit; font-size: 15px; font-weight: 620;
  padding: 10px 12px; border: 0; border-radius: 8px; cursor: pointer;
  color: #fff; background: var(--series-1);
}
.loginbox button:hover { background: var(--accent); }
.loginbox button:disabled { opacity: .5; cursor: not-allowed; }
.loginerr {
  font-size: 13px; color: var(--text-primary);
  background: var(--surface-2);
  border-left: 3px solid var(--down);
  border-radius: 0 6px 6px 0;
  padding: 9px 12px; margin: 0 0 18px;
}

/* --- KPI --- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi {
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.kpi .k { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.kpi .v {
  display: block; margin: 4px 0 2px;
  font-size: 27px; font-weight: 660; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.kpi .n { font-size: 12px; color: var(--text-muted); }
.up { color: var(--up); }
.down { color: var(--down); }
.muted { color: var(--text-muted); }

/* --- carduri --- */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px 18px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 12px; font-size: 15px; font-weight: 650; }
.card h3 { margin: 22px 0 10px; font-size: 14px; font-weight: 640; }
.cols { display: grid; grid-template-columns: 1.15fr 1fr; gap: 16px; align-items: start; }
.note { font-size: 12px; color: var(--text-muted); margin: 10px 0 0; }
.empty { font-size: 13px; color: var(--text-muted); margin: 8px 0; }
.warn {
  font-size: 12.5px; color: var(--text-secondary);
  background: var(--surface-2);
  border-left: 3px solid var(--status-warn);
  border-radius: 0 6px 6px 0;
  padding: 8px 12px; margin: 0 0 12px;
}

/* --- bara compozita --- */
.mixbar {
  display: flex; gap: 2px;              /* 2px de suprafata intre segmente */
  height: 30px; margin: 6px 0 10px;
  border-radius: 6px; overflow: hidden;
}
.seg { min-width: 2px; }
.seg-nou, .seg-pf  { background: var(--series-1); }
.seg-uzat, .seg-co { background: var(--series-2); }
.seg-reinm, .seg-alt { background: var(--series-3); }

.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 20px; margin: 0; padding: 0; font-size: 13px; color: var(--text-secondary); }
.legend li { display: flex; align-items: center; gap: 7px; }
.legend i { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.legend strong { color: var(--text-primary); font-variant-numeric: tabular-nums; }

/* --- grafic --- */
.chart { margin: 0; position: relative; }
.chart svg { width: 100%; height: 240px; display: block; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axisline { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--text-muted); font-size: 11px; font-family: inherit; }
.chart .bar { fill: var(--series-1); opacity: .38; transition: opacity .1s; }
.chart .bar.on { opacity: 1; }
.chart .bar:hover { opacity: .85; }
.chart .bar.on:hover { opacity: 1; }
.chart .tip {
  position: absolute; pointer-events: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 10px;
  font-size: 12px; line-height: 1.4;
  box-shadow: var(--shadow);
  transform: translate(-50%, -100%);
  white-space: nowrap;
}
.chart .tip b { display: block; font-variant-numeric: tabular-nums; font-size: 14px; }

/* --- tabele --- */
table.rank { width: 100%; border-collapse: collapse; font-size: 14px; }
table.rank th {
  text-align: left; font-size: 11px; font-weight: 640; letter-spacing: 0.03em;
  text-transform: uppercase; color: var(--text-muted);
  padding: 0 8px 7px; border-bottom: 1px solid var(--border);
}
table.rank td { padding: 6px 8px; border-bottom: 1px solid var(--border-soft); }
table.rank tr:last-child td { border-bottom: 0; }
table.rank .num { text-align: right; font-variant-numeric: tabular-nums; }
table.rank .strong { font-weight: 640; }
table.rank .brand { font-weight: 560; }
table.rank td.bar, table.rank th.bar { width: 90px; padding-right: 0; }
table.rank td.bar span {
  display: block; height: 7px; border-radius: 4px;
  background: var(--series-1); opacity: .55; min-width: 2px;
}

/* --- mărcile urmărite (Dacia, Renault) ---
   Evidențierea nu se bazează doar pe culoare: rândul are și o bară în margine
   și denumirea îngroșată, ca să se distingă și la daltonism sau la tipărire. */
table.rank tr.hl td { background: var(--hl-bg); }
table.rank tr.hl td.brand { font-weight: 680; box-shadow: inset 3px 0 0 var(--series-1); padding-left: 12px; }
table.rank tr.hl.total td { font-weight: 640; border-top: 1px solid var(--border); }
table.rank.tail { margin-top: 6px; border-top: 1px dashed var(--border); }

.kpi.focus { border-color: var(--series-1); }
.focus-card { border-color: var(--border); }
.focus-card h2::before {
  content: ""; display: inline-block;
  width: 8px; height: 8px; border-radius: 2px;
  background: var(--series-1); margin-right: 8px; vertical-align: 1px;
}

.method ul { margin: 0; padding-left: 18px; font-size: 13px; color: var(--text-secondary); }
.method li { margin-bottom: 6px; }
.method strong { color: var(--text-primary); }

.foot { padding: 0 20px 32px; font-size: 12px; color: var(--text-muted); }
.foot p { margin: 0; }

/* Semnătura: prezentă, dar fără să concureze cu datele. */
.topbar .by {
  margin-left: 6px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 550;
  white-space: nowrap;
}
.foot .by-foot { margin-top: 4px; font-weight: 550; color: var(--text-secondary); }

@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .cols { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .kpis { grid-template-columns: 1fr; }
  .filters label { min-width: 100%; }
  table.rank td.bar, table.rank th.bar { display: none; }
}
