/* GESTBAL raportare – stiluri */
:root {
  --bg: #f4f5f3; --surface: #fcfcfb; --surface-2: #f0f1ee; --line: #e2e3df;
  --text: #1b1b1a; --text-2: #52514e; --muted: #7a7974;
  --accent: #1c5cab; --accent-soft: #e3eefc;
  --pos: #0f7a45; --neg: #c03a39; --warn-bg: #fff6e0; --warn: #8a5a00; --err-bg: #fdeceb; --ok-bg: #e8f6ee;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #86b6ef; --s6: #e87ba4; --s7: #6250d6; --s8: #e34948;
  --grid: #e7e7e3;
  --radius: 10px; --side-w: 232px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121211; --surface: #1a1a19; --surface-2: #22221f; --line: #33332f;
    --text: #f0efec; --text-2: #c3c2b7; --muted: #8f8e86;
    --accent: #86b6ef; --accent-soft: #1f2d40;
    --pos: #3fbf7f; --neg: #ef7a7a; --warn-bg: #3a2e12; --warn: #f0c46a; --err-bg: #3d1d1c; --ok-bg: #16301f;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #1c5cab; --s6: #d55181; --s7: #9085e9; --s8: #e66767;
    --grid: #2c2c29;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; margin: 0 0 .8rem; font-weight: 600; }
small, .small { font-size: .82em; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .92em; }
.b { font-weight: 600; }
.nowrap { white-space: nowrap; }
.neg { color: var(--neg); }

/* ---- topbar */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--line); min-height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand small { font-weight: 400; color: var(--muted); }
.logo { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 800; }
.selectors { display: flex; gap: 8px; flex: 1; min-width: 0; }
.selectors select { max-width: 340px; min-width: 0; width: auto; flex: 0 1 200px; }
.selectors select:first-child { flex: 1 1 260px; }
.user { display: flex; gap: 12px; align-items: center; white-space: nowrap; margin-left: auto; }
.menu-btn { display: none; background: none; border: 0; padding: 6px; cursor: pointer; color: var(--text); }
.menu-btn svg { width: 24px; height: 24px; fill: currentColor; }

/* ---- shell */
.shell { display: flex; min-height: calc(100vh - 56px); }
.side { width: var(--side-w); flex: none; padding: 14px 10px; background: var(--surface); border-right: 1px solid var(--line); position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; }
.side a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
.side a svg { width: 18px; height: 18px; fill: currentColor; opacity: .75; flex: none; }
.side a:hover { background: var(--surface-2); text-decoration: none; }
.side a.active { background: var(--accent-soft); color: var(--accent); }
.side-h { margin: 18px 12px 6px; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.content { flex: 1; min-width: 0; padding: 20px 24px 40px; }
.foot { margin-top: 32px; color: var(--muted); font-size: .8rem; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .sub { color: var(--text-2); margin-top: 4px; }

/* ---- cards & grids */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; min-width: 0; }
.card.p0 { padding: 0; overflow: hidden; }
.pad { padding: 16px 18px 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid2 > .card { margin-bottom: 0; }
.grid2 + .card, .card + .grid2, .grid2 + .grid2 { margin-top: 16px; }
.more { display: inline-block; margin-top: 10px; font-weight: 500; }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpis-3 .kpi { background: var(--surface-2); border: 0; }
.kpi-t { color: var(--text-2); font-size: .82rem; }
.kpi-v { font-size: 1.5rem; font-weight: 700; margin: 4px 0 2px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-v small { font-size: .8rem; font-weight: 500; color: var(--muted); }
.kpi-s { font-size: .8rem; color: var(--muted); }
.kpi-s b { color: var(--text-2); }
.chip { display: inline-block; padding: 1px 7px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--text-2); }
.chip.up { background: var(--ok-bg); color: var(--pos); }
.chip.down { background: var(--err-bg); color: var(--neg); }

.chart { position: relative; height: 300px; }
.chart-sm { height: 260px; }
.chart-lg { height: 380px; }

/* ---- tables */
.tbl-wrap { overflow: auto; -webkit-overflow-scrolling: touch; }
.tbl-wrap.tall { max-height: 70vh; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl thead th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; font-size: .8rem; color: var(--text-2); white-space: nowrap; z-index: 2; }
.tbl thead tr:nth-child(2) th { top: 31px; }
.tbl th.grp { text-align: center; border-left: 1px solid var(--line); }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl tr.tot td, .tbl tfoot td { font-weight: 700; background: var(--surface-2); }
.tbl tr.virt td { color: var(--muted); }
.tbl .sticky { position: sticky; left: 0; background: var(--surface); z-index: 1; }
.tbl thead .sticky { z-index: 3; background: var(--surface-2); }
.tbl tr.tot .sticky { background: var(--surface-2); }
.tbl.bal td.den { min-width: 220px; }
.tbl.bal td, .tbl.bal th { font-size: .86rem; padding: 5px 8px; }
.report tr.lvl1 td { font-weight: 600; }
.report tr.lvl2 td { font-weight: 700; background: var(--surface-2); }
.report tr.lvl3 td { font-weight: 700; background: var(--accent-soft); }
.tbl tr.lvl1 td[colspan] { background: var(--surface-2); font-weight: 600; color: var(--text-2); }
.report td:first-child { min-width: 230px; }
.tbl td.pos { color: var(--pos); }
.tbl td.neg { color: var(--neg); }
.tbl-filter { margin-bottom: 10px; max-width: 320px; }

/* ---- forms */
input, select, button, textarea { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=radio]), select { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); min-height: 38px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.form label, .login-box label { display: block; margin-bottom: 12px; color: var(--text-2); font-size: .88rem; }
.form label input, .form label select, .login-box label input { margin-top: 4px; color: var(--text); }
label.chk { display: flex; gap: 8px; align-items: center; color: var(--text); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; font-weight: 500; min-height: 38px; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.1); }
.btn-danger { color: var(--neg); }
.btn-sm { padding: 4px 10px; min-height: 30px; font-size: .82rem; }
.btn-block { width: 100%; }
form.inline { display: inline; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters input[type=search], .filters select { width: auto; flex: 1 1 180px; max-width: 320px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg a, .seg button { padding: 7px 14px; border: 0; background: none; cursor: pointer; color: var(--text-2); font-weight: 500; }
.seg a:hover { text-decoration: none; background: var(--surface-2); }
.seg .on { background: var(--accent); color: #fff; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.dl dt { color: var(--text-2); }
.dl dd { margin: 0; }
.code-big { font-family: ui-monospace, Consolas, monospace; font-size: 1.15rem; font-weight: 700; letter-spacing: .04em; word-break: break-all; }
.pick-list { max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin-top: 6px; }
.pick-list label { display: flex; gap: 8px; align-items: baseline; padding: 3px 0; margin: 0; color: var(--text); }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid transparent; }
.alert.m { margin: 12px 18px 16px; }
.alert-ok { background: var(--ok-bg); color: var(--pos); }
.alert-warn { background: var(--warn-bg); color: var(--warn); }
.alert-err { background: var(--err-bg); color: var(--neg); }
.empty { text-align: center; padding: 60px 20px; color: var(--text-2); }

/* ---- login */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; background: linear-gradient(160deg, var(--accent-soft), var(--bg) 60%); }
.login-box { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: 0 10px 40px rgba(0,0,0,.06); }
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; }
.login-brand b { display: block; font-size: 1.2rem; }
.login-brand small { color: var(--muted); }

/* ---- responsive */
@media (max-width: 1100px) {
  .grid2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .menu-btn { display: block; }
  .side { position: fixed; left: 0; top: 56px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .side { transform: none; box-shadow: 4px 0 20px rgba(0,0,0,.15); }
  .content { padding: 16px; }
  .brand-t { display: none; }
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .user .logout { display: none; }
  .user a:first-child { max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
  .selectors { order: 5; flex-basis: 100%; }
  .selectors select { max-width: none; flex: 1 1 40%; }
  .selectors select:first-child { flex: 1 1 55%; }
  .shell { min-height: calc(100vh - 100px); }
  .side { top: 100px; height: calc(100vh - 100px); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpis-3 { grid-template-columns: minmax(0, 1fr); }
  .kpi { padding: 12px; }
  .kpi-v { font-size: 1.2rem; }
  .chart { height: 260px; }
  .chart-lg { height: 320px; }
  .report td:first-child { min-width: 170px; }
  h1 { font-size: 1.2rem; }
}
@media print {
  .topbar, .side, .foot, .filters, .btn { display: none !important; }
  .content { padding: 0; }
  .card { break-inside: avoid; }
}

/* ---- panouri extensibile (dashboard A-D) */
.panels { display: grid; gap: 10px; margin-top: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 14px 44px 14px 18px; position: relative; font-weight: 600; font-size: 1rem; user-select: none; }
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary::after { content: ""; position: absolute; right: 20px; top: 21px; width: 9px; height: 9px; border-right: 2px solid var(--text-2); border-bottom: 2px solid var(--text-2); transform: rotate(45deg); transition: transform .15s; flex: none; }
.panel[open] > summary::after { transform: rotate(-135deg); }
.panel > summary:hover { background: var(--surface-2); }
.panel > summary small { font-weight: 400; color: var(--muted); }
.panel .pl { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--accent-soft); color: var(--accent); font-weight: 700; flex: none; }
.panel[open] .pl { background: var(--accent); color: #fff; }
.panel[open] > summary { border-bottom: 1px solid var(--line); }
.panel-body { padding: 16px 18px; }
.panel-body.p0 { padding: 0; }
.tbl td.ind { padding-left: 28px; color: var(--text-2); }
.tbl tr.ctrl td { background: var(--surface-2); color: var(--text-2); font-size: .85rem; border-top: 2px solid var(--line); }
.tbl tr.zero td { color: var(--muted); }
.tbl tr.info td { font-style: italic; }
.oficial td:first-child { min-width: 320px; }
.pad-b { padding: 8px 18px 14px; margin: 0; }
.pad-t { padding-top: 10px; margin: 0; }
.tva-kpi { margin-bottom: 14px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); }
@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .oficial td:first-child { min-width: 220px; }
  .panel > summary { padding: 12px 40px 12px 14px; font-size: .95rem; flex-wrap: wrap; }
  .panel > summary::after { right: 16px; top: 20px; }
  .panel > summary small { flex-basis: 100%; padding-left: 40px; margin-top: -6px; }
}
.tbl.tva tr.lvl2 td { font-weight: 600; background: var(--surface-2); }
.tbl.tva tr.lvl3 td { font-weight: 700; background: var(--accent-soft); }

/* ---- culori carduri KPI */
:root { --kpi-pos-bg: #eaf6ef; --kpi-pos-line: #cde9d8; --kpi-neg-bg: #fdf0ef; --kpi-neg-line: #f4d6d4;
        --fr-bg: #eef5fd; --fr-line: #cfe0f6; --as-bg: #f3f0fc; --as-line: #ddd6f5; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --kpi-pos-bg: #15291e; --kpi-pos-line: #224331; --kpi-neg-bg: #2e1a19; --kpi-neg-line: #4a2726;
        --fr-bg: #172334; --fr-line: #24395a; --as-bg: #211d33; --as-line: #352e56; }
}
.kpi.t-pos { background: var(--kpi-pos-bg); border-color: var(--kpi-pos-line); }
.kpi.t-neg { background: var(--kpi-neg-bg); border-color: var(--kpi-neg-line); }

/* ---- hint (fereastra la hover / atingere) */
.kpi { position: relative; }
.kpi.has-hint { cursor: help; outline: none; }
.kpi .i { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; border: 1px solid currentColor; font-size: 10px; font-weight: 700; font-style: italic; opacity: .6; vertical-align: 1px; margin-left: 2px; }
.kpi .hint { position: absolute; z-index: 20; left: 12px; top: calc(100% - 6px); min-width: 230px; background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.14); padding: 10px 12px; font-size: .85rem;
  opacity: 0; visibility: hidden; transform: translateY(4px); transition: opacity .12s, transform .12s; pointer-events: none; }
.kpi.has-hint:hover .hint, .kpi.has-hint:focus .hint, .kpi.has-hint:focus-within .hint { opacity: 1; visibility: visible; transform: none; }
.hint-t { font-weight: 600; margin-bottom: 6px; color: var(--text-2); }
.hint-r { display: flex; justify-content: space-between; gap: 16px; padding: 3px 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.hint-r:first-of-type { border-top: 0; }
@media (max-width: 900px) { .kpi:nth-child(even) .hint { left: auto; right: 8px; } .kpi .hint { min-width: 210px; } }

/* ---- latime maxima pt. tabele-raport (nu se intind pe ecrane mari) */
.narrow { max-width: 940px; }

/* ---- SIG: culori diferite pe metoda */
.card.m-fr { background: var(--fr-bg); border-color: var(--fr-line); }
.card.m-as { background: var(--as-bg); border-color: var(--as-line); }
.card.m-fr .tbl .sticky, .card.m-as .tbl .sticky { background: inherit; }
.card.m-fr h3.pad, .card.m-as h3.pad { display: flex; align-items: center; gap: 10px; padding-bottom: 12px; margin: 0; }
.m-tag { font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 2px 8px; border-radius: 99px; color: #fff; }
.m-fr .m-tag { background: #2a78d6; }
.m-as .m-tag { background: #6250d6; }
.m-end { padding: 8px 18px 12px; font-size: .78rem; color: var(--muted); text-align: right; }
@media (min-width: 1280px) { .kpis.k12 { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.m-as .report tr.lvl3 td { background: #e4ddfa; }
.m-as .report tr.lvl2 td { background: #ece7fb; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .m-as .report tr.lvl3 td { background: #2c2548; } :root:not([data-theme="light"]) .m-as .report tr.lvl2 td { background: #262040; } }
.unit-bar { margin: -4px 0 16px; }
label.unit-toggle { display: inline-flex; gap: 8px; align-items: center; font-size: .88rem; color: var(--text-2); cursor: pointer; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; }
.unit-toggle input { width: 16px; height: 16px; accent-color: var(--accent); }
.page-head.narrow { max-width: 940px; }
.grid2 > .span2 { grid-column: 1 / -1; }
.hint-n { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); font-size: .78rem; color: var(--muted); max-width: 300px; }
.kpi .hint { min-width: 260px; }
.tbl td.neg .amt, .tbl td.neg, .kpi-v.neg, .hint b.neg { color: var(--neg); }
.tbl td.ind-ok { color: var(--pos); background: var(--kpi-pos-bg); }
.tbl td.ind-nok { color: var(--neg); background: var(--kpi-neg-bg); }
.hint-r.txt { display: block; color: var(--muted); font-size: .8rem; line-height: 1.4; }
.hint-r.txt span { display: block; font-weight: 600; color: var(--text-2); margin-bottom: 2px; }
.kpi .hint { max-width: 340px; }
.logo-img { height: 32px; width: auto; display: block; }
.login-brand .logo-img { height: 40px; }
.ph-t { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); margin-bottom: 2px; }
.page-head h1.ph-firma { font-size: 1.5rem; letter-spacing: -.01em; }
@media (max-width: 900px) { .page-head h1.ph-firma { font-size: 1.2rem; } }
.hint-r.tot { font-weight: 600; background: var(--surface-2); margin: 4px -6px 0; padding: 3px 6px; border-radius: 4px; border-top: 0; }
.hint-r.det { padding-left: 12px; font-size: .8rem; color: var(--text-2); }
.hint-r.det b { font-weight: 500; }
.head-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.seg.lang a { min-width: 44px; text-align: center; }
.side .dis { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--muted); opacity: .55; cursor: not-allowed; font-weight: 500; }
.side .dis svg { width: 18px; height: 18px; fill: currentColor; flex: none; }
.side .dis small { margin-left: auto; font-size: .62rem; font-weight: 700; letter-spacing: .05em; border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; }
/* explicatii sub grafice */
.expl { margin-top: 12px; padding: 10px 12px; background: var(--surface-2); border-radius: 8px; font-size: .84rem; color: var(--text-2); line-height: 1.5; }
.expl p { margin: 6px 0 0; }
.expl .lg { display: inline-flex; align-items: center; gap: 6px; margin-right: 16px; font-size: .8rem; }
.expl .lg i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.expl .lg i.c-s1 { background: var(--s1); } .expl .lg i.c-pos { background: var(--pos); } .expl .lg i.c-neg { background: var(--neg); }
.expl .lg i.c-s5 { background: var(--s5); } .expl .lg i.c-s2 { background: var(--s2); }
.kpis-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0 0 14px; }
@media (max-width: 900px) { .kpis-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* TVA: randurile cu valoare 0 ascunse implicit */
.tva-ascuns tr.zero { display: none; }
.tva-det-chk { display: inline-flex; margin: 4px 0 10px; font-size: .85rem; color: var(--text-2); }
