:root {
  --bg: #eef1f6; --card: #ffffff; --fg: #18202c; --muted: #5d6878; --line: #e2e6ed; --grid: rgba(0,0,0,.07);
  --head: #1e3557; --head-fg: #ffffff; --acc: #e8701a;
  --c-ach: #f4b183; --c-dif: #e8701a; --c-dif-a1: rgba(232,112,26,.35); --c-dif-a0: rgba(232,112,26,.02);
  --up: #1b8a4a; --down: #c62828; --row: #f6f8fb;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11161e; --card: #1a212c; --fg: #e8ecf2; --muted: #9aa6b6; --line: #2b3442; --grid: rgba(255,255,255,.07);
    --head: #0d1420; --c-ach: #d99a6c; --row: #1f2733; --up: #4cc27f; --down: #ef6b6b;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--head); color: var(--head-fg); }
.logo { height: 30px; border-radius: 4px; background: #fff; padding: 2px 4px; }
.top-txt { flex: 1; min-width: 0; }
.title { font-weight: 600; font-size: 16px; }
.sub { font-size: 12px; opacity: .8; }
.sub.stale { color: #ffcf6b; opacity: 1; }
.sub.stale::after { content: " - date mai vechi de 3 ore"; }
.out { color: var(--head-fg); opacity: .8; font-size: 13px; text-decoration: none; border: 1px solid rgba(255,255,255,.35);
  padding: 5px 10px; border-radius: 6px; }

main { max-width: 1200px; margin: 0 auto; padding: 12px 16px 40px; display: grid; gap: 14px; }
@media (min-width: 1000px) { main { grid-template-columns: 1fr 1fr; } .note, .kpi { grid-column: 1 / -1; } }
.note { margin: 0; color: var(--muted); font-size: 13px; }

.card { background: var(--card); border-radius: 12px; padding: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.08); min-width: 0; }
.card h2 { margin: 0 0 10px; font-size: 16px; font-weight: 600; }
.card-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.card-h h2 { margin: 0; }

.kpi { background: var(--head); color: var(--head-fg); }
.kpi h2 { text-align: center; font-weight: 500; opacity: .9; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.kpis .v { display: block; font-size: clamp(17px, 4.6vw, 32px); font-weight: 600; font-variant-numeric: tabular-nums; }
.kpis .v.acc { color: #ffb070; }
.kpis .l { display: block; font-size: 12px; opacity: .8; }
.cmp { margin-top: 10px; text-align: center; font-size: 13px; opacity: .95; }
.cmp .up { color: #7be3a5; } .cmp .down { color: #ff9b9b; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: transparent; color: var(--fg); padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.seg button.on { background: var(--acc); color: #fff; }

.chart { position: relative; height: 260px; }

.tbl-wrap { overflow-x: auto; margin-top: 10px; max-height: 480px; overflow-y: auto; }
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
.tbl th { position: sticky; top: 0; background: var(--card); color: var(--muted); font-weight: 500; font-size: 12px;
  text-align: right; padding: 6px 8px; border-bottom: 2px solid var(--line); white-space: nowrap; }
.tbl td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl tbody tr:nth-child(even) td { background: var(--row); }
.tbl tfoot td { position: sticky; bottom: 0; background: var(--card); font-weight: 700; border-top: 2px solid var(--line); border-bottom: 0; }
.tbl tr.yr td { font-weight: 700; cursor: pointer; }
.tbl tr.mo td:first-child { padding-left: 26px; color: var(--muted); }
.tw { display: inline-block; width: 18px; color: var(--acc); }
@media (max-width: 520px) {
  .tbl { font-size: 13px; }
  .tbl th, .tbl td { padding: 6px 4px; }
  #tDays th:nth-child(5), #tDays td:nth-child(5), #tMonths th:nth-child(5), #tMonths td:nth-child(5) { display: none; }
  #tMonths { font-size: 12px; }
  .tbl tr.mo td:first-child { padding-left: 18px; }
  .tw { width: 14px; }
}
.empty { text-align: center !important; color: var(--muted); padding: 18px !important; }

/* login */
body.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--head); }
.login-card { width: 100%; max-width: 360px; background: var(--card); border-radius: 14px; padding: 24px; display: grid; gap: 12px; }
.login-logo { height: 44px; justify-self: center; }
.login-card h1 { margin: 0; text-align: center; font-size: 18px; font-weight: 600; }
.login-card label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.login-card input[type=text], .login-card input:not([type]), .login-card input[type=password] {
  font: inherit; font-size: 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--fg); }
.login-card .chk { display: flex; align-items: center; gap: 8px; }
.login-card button { font: inherit; font-size: 16px; padding: 11px; border: 0; border-radius: 8px; background: var(--acc); color: #fff; cursor: pointer; }
.err { background: #fdecea; color: #b3261e; padding: 8px 10px; border-radius: 8px; font-size: 14px; }
