:root {
  color-scheme: light;
  --bg: #f6f6f4;
  --surface: #ffffff;
  --line: #e7e6e2;
  --line-strong: #d4d3ce;
  --text: #191919;
  --text-2: #5f5f5b;
  --text-3: #8d8c87;
  --accent: #257de0;
  --accent-soft: #e8f1fc;
  --good: #1d7a33;
  --good-soft: #e7f4ea;
  --warn: #a15c00;
  --warn-soft: #fdf1df;
  --bad: #c2362f;
  --bad-soft: #fbe9e8;
  --series-1: #257de0;
  --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #141414;
    --surface: #1c1c1c;
    --line: #2c2c2a;
    --line-strong: #3a3a37;
    --text: #efefef;
    --text-2: #b0afaa;
    --text-3: #8a8984;
    --accent: #338ced;
    --accent-soft: #1b2a3d;
    --good: #4cc26a;
    --good-soft: #17301d;
    --warn: #e0a24a;
    --warn-soft: #34270f;
    --bad: #ef6b64;
    --bad-soft: #3a1b19;
    --series-1: #338ced;
  }
}
* { box-sizing: border-box; }
body { margin: 0; }
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 22px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 13px; font-weight: 600; margin: 18px 0 8px; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.err { color: var(--bad); min-height: 1em; }

/* Išdėstymas */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { font-weight: 700; font-size: 16px; padding: 0 10px 18px; }
.brand span { display: block; font-weight: 400; font-size: 12px; color: var(--text-2); margin-top: 2px; }
nav a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--text-2); margin-bottom: 2px; }
nav a:hover { background: var(--bg); color: var(--text); }
nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-foot { margin-top: auto; font-size: 12px; color: var(--text-3); padding: 0 10px; }
.main { padding: 28px 32px 60px; max-width: 1400px; width: 100%; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Valdikliai */
.btn { border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); padding: 7px 12px; border-radius: 6px; font: inherit; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--text-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 6px; padding: 7px 10px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 6px 11px; font: inherit; color: var(--text-2); cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--text); color: var(--surface); }
label.chk { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }

/* Kortelės */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .l { color: var(--text-2); font-size: 12px; }
.kpi .v { font-size: 22px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.kpi .d { font-size: 12px; margin-top: 2px; color: var(--text-3); }
.up { color: var(--good); }
.down { color: var(--bad); }

/* Lentelės */
.tbl-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--text-2); font-size: 12px; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; white-space: nowrap; }
th.sort { cursor: pointer; user-select: none; }
th.sort:hover { color: var(--text); }
th.num { text-align: right; }
td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--bg); }
.card table td, .card table th { padding-left: 0; }
.sub { color: var(--text-3); font-size: 12px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: var(--bg); color: var(--text-2); white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--accent-soft); color: var(--accent); }
.empty { padding: 24px; text-align: center; color: var(--text-3); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; color: var(--text-2); }

/* Diagrama */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: 220px; overflow: visible; }
.chart .grid line { stroke: var(--line); }
.chart text { fill: var(--text-3); font-size: 11px; }
.chart .bar { fill: var(--series-1); }
.chart .bar.dim { opacity: .45; }
.tip { position: fixed; z-index: 50; background: var(--text); color: var(--surface); padding: 6px 9px; border-radius: 6px; font-size: 12px; pointer-events: none; white-space: nowrap; }

/* Šoninis langas */
.drawer-bg { position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100%); background: var(--surface); z-index: 21; overflow: auto; border-left: 1px solid var(--line); box-shadow: -8px 0 30px rgba(0,0,0,.08); }
.drawer-head { position: sticky; top: 0; background: var(--surface); padding: 20px 24px 0; border-bottom: 1px solid var(--line); z-index: 1; }
.drawer-body { padding: 20px 24px 40px; }
.tabs { display: flex; gap: 18px; margin-top: 14px; }
.tabs button { background: none; border: 0; padding: 8px 0 10px; font: inherit; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--text); border-bottom-color: var(--text); font-weight: 600; }
.close { position: absolute; right: 18px; top: 16px; }
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.field input, .field select, .field textarea { width: 100%; }
.field .hint { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.stats-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.stats-row div { background: var(--bg); border-radius: 6px; padding: 10px 12px; }
.stats-row b { display: block; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stats-row span { font-size: 12px; color: var(--text-2); }
.stock-box { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; background: var(--bg); padding: 14px; border-radius: 8px; }
.stock-box .big { font-size: 30px; font-weight: 600; margin-right: 18px; font-variant-numeric: tabular-nums; }

.banner { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
.banner.info { background: var(--accent-soft); color: var(--accent); }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.bad { background: var(--bad-soft); color: var(--bad); }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 8px; z-index: 60; }
.login { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); }
.login-box { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 32px; width: 320px; display: grid; gap: 10px; }

@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  .brand { padding: 0 10px 0 4px; }
  nav { display: flex; flex-wrap: wrap; }
  .side-foot { display: none; }
  .main { padding: 18px 14px; }
  .kpis, .g2, .g3, .form, .stats-row { grid-template-columns: 1fr 1fr; }
}
