/* Paleta WNR / Winner: čierna, zlatá, biela. Zelená a červená len pre kladné / záporné hodnoty. */
:root {
  --gold: #d4a62a;
  --gold-light: #f2d36b;
  --gold-dark: #a87a12;
  --black: #0d0d0d;
  --accent: #c9a227;          /* zlatá – plochy, rámiky, tlačidlá */
  --accent-text: #8a6610;     /* tmavšia zlatá – text a odkazy na bielom (kontrast) */
  --accent-soft: #f7f0dc;
  --on-accent: #111111;       /* text na zlatom tlačidle */
  --bg: #f5f4f1;
  --surface: #ffffff;
  --surface-2: #f8f7f4;
  --border: #e4e1d9;
  --text: #141414;
  --muted: #6b6860;
  --pos: #12805c;
  --pos-soft: #e3f5ee;
  --neg: #c8372d;
  --neg-soft: #fbe8e6;
  --warn: #c76a0a;
  --warn-soft: #fdf0e1;
  --side: #0d0d0d;
  --side-text: #c9c6bd;
  --side-active: #1f1b10;
  --chart-1: #c9a227; --chart-2: #2e2e2e; --chart-3: #12805c; --chart-4: #8a6610; --chart-5: #9a9a9a; --chart-6: #e3c868; --chart-7: #c8372d; --chart-8: #5b5b5b;
  --shadow: 0 1px 2px rgba(20, 16, 4, .06), 0 1px 3px rgba(20, 16, 4, .08);
  --radius: 10px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0b0b; --surface: #161616; --surface-2: #1d1d1d; --border: #2b2b2b; --text: #f3f1ec; --muted: #a29e94;
    --accent: #d4a62a; --accent-text: #e2bd52; --accent-soft: #2a2310; --on-accent: #111111;
    --pos: #3cc58f; --pos-soft: #133227; --neg: #f0675c; --neg-soft: #3d1c1a; --warn: #f0a04b; --warn-soft: #3a2a15;
    --side: #050505; --side-active: #241e0e;
    --chart-1: #d4a62a; --chart-2: #e8e4da; --chart-3: #3cc58f; --chart-4: #f2d36b; --chart-5: #7d7a72; --chart-6: #a87a12; --chart-7: #f0675c; --chart-8: #b5b1a6;
    --shadow: 0 1px 3px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0b0b; --surface: #161616; --surface-2: #1d1d1d; --border: #2b2b2b; --text: #f3f1ec; --muted: #a29e94;
  --accent: #d4a62a; --accent-text: #e2bd52; --accent-soft: #2a2310; --on-accent: #111111;
  --pos: #3cc58f; --pos-soft: #133227; --neg: #f0675c; --neg-soft: #3d1c1a; --warn: #f0a04b; --warn-soft: #3a2a15;
  --side: #050505; --side-active: #241e0e;
  --chart-1: #d4a62a; --chart-2: #e8e4da; --chart-3: #3cc58f; --chart-4: #f2d36b; --chart-5: #7d7a72; --chart-6: #a87a12; --chart-7: #f0675c; --chart-8: #b5b1a6;
  --shadow: 0 1px 3px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); background: var(--bg); color: var(--text); }
a { color: var(--accent-text); text-decoration: none; }
h1 { font-size: 22px; margin: 0; font-weight: 650; }
h2 { font-size: 17px; margin: 0 0 12px; font-weight: 600; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.muted { color: var(--muted); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warn { color: var(--warn); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- Rozloženie ---------- */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: var(--side-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; font-weight: 700; font-size: 16px; }
.brand-logo { width: 40px; height: 28px; display: block; flex: none; }
.brand-logo { object-fit: contain; }
.brand-name { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name b { color: var(--gold); font-style: italic; font-weight: 800; letter-spacing: .08em; font-size: 17px; }
.brand-name span { color: #fff; font-weight: 500; font-size: 12px; letter-spacing: .22em; text-transform: uppercase; opacity: .85; }
.nav { padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow: auto; }
.nav a { display: flex; align-items: center; gap: 10px; color: var(--side-text); padding: 9px 12px; border-radius: 8px; font-weight: 500; }
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.active { background: var(--side-active); color: var(--gold-light); box-shadow: inset 3px 0 0 var(--gold); }
.nav a.active .ico { color: var(--gold); }
.nav a.disabled { opacity: .4; pointer-events: none; }
.nav .ico { width: 18px; text-align: center; opacity: .9; }
.nav-sub { display: flex; flex-direction: column; margin: 0 0 4px 28px; }
.nav-sub a { padding: 5px 10px; font-size: 13px; font-weight: 400; }
.side-foot { padding: 12px 16px; border-top: 1px solid rgba(255, 255, 255, .08); font-size: 12px; }
.side-foot .user { color: #fff; font-weight: 600; font-size: 13px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 28px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar .crumbs { flex: 1; color: var(--muted); }
.topbar .crumbs a { color: var(--muted); }
.topbar .crumbs b { color: var(--text); }
.content { padding: 24px 28px 60px; max-width: 1600px; width: 100%; }
.demo-banner { background: repeating-linear-gradient(45deg, #d4720c, #d4720c 12px, #c26508 12px, #c26508 24px); color: #fff; text-align: center; font-weight: 600; padding: 5px; font-size: 12.5px; letter-spacing: .02em; }
.menu-btn { display: none; }

@media (max-width: 1024px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -260px; width: 240px; z-index: 50; transition: left .2s; }
  .sidebar.open { left: 0; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
  .menu-btn { display: inline-flex; }
  .content { padding: 16px; }
  .topbar { padding: 10px 16px; }
}

/* ---------- Komponenty ---------- */
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { flex: 1; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 7px 13px; border-radius: 8px; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, var(--gold-light) -40%, var(--accent) 60%, var(--gold-dark) 160%); border-color: var(--gold-dark); color: var(--on-accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--neg); }
.btn.danger.solid { background: var(--neg); border-color: var(--neg); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px; }
@media (max-width: 1100px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 26px 22px; box-shadow: var(--shadow); color: var(--text);
  display: flex; flex-direction: column; gap: 10px; min-height: 180px; transition: transform .12s, border-color .12s; }
.tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.tile .t-ico { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; font-size: 24px; background: var(--accent-soft); }
.tile .t-title { font-size: 19px; font-weight: 650; }
.tile .t-desc { color: var(--muted); font-size: 13px; flex: 1; }
.tile.locked { opacity: .45; pointer-events: none; }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .k-label { color: var(--muted); font-size: 12.5px; }
.kpi .k-value { font-size: 21px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .k-delta { font-size: 12px; margin-top: 4px; }
.kpi.clickable { cursor: pointer; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--accent-text); border-color: var(--accent); }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.toolbar .grow { flex: 1; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label { font-size: 12px; color: var(--muted); font-weight: 500; }
.field .req { color: var(--neg); }
.field .err { color: var(--neg); font-size: 12px; }
.field .hint { color: var(--muted); font-size: 12px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input.invalid, select.invalid { border-color: var(--neg); }
input[type="checkbox"] { width: 16px; height: 16px; }
textarea { resize: vertical; min-height: 64px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 8px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .02em;
  padding: 9px 10px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; }
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--text); }
table.data td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover td { background: var(--surface-2); }
table.data tr.row-cancelled td { color: var(--muted); text-decoration: line-through; }
table.data tr.row-low td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
table.data tr.row-zero td:first-child { box-shadow: inset 3px 0 0 var(--neg); }
table.data tfoot td { font-weight: 600; background: var(--surface-2); }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; padding: 10px 0; color: var(--muted); font-size: 13px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.ok, .badge.approved { background: var(--pos-soft); color: var(--pos); border-color: transparent; }
.badge.low, .badge.sent, .badge.draft { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.sent { background: var(--accent-soft); color: var(--accent-text); }
.badge.zero, .badge.rejected, .badge.cancelled { background: var(--neg-soft); color: var(--neg); border-color: transparent; }
.badge.expired { background: var(--surface-2); color: var(--muted); }

.summary { display: flex; gap: 24px; flex-wrap: wrap; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; }
.summary .s-item .s-label { font-size: 12px; color: var(--muted); }
.summary .s-item .s-value { font-size: 16px; font-weight: 650; font-variant-numeric: tabular-nums; }

.period { display: flex; gap: 6px; align-items: end; flex-wrap: wrap; }
.period .quick { display: flex; gap: 4px; }

/* Modal */
.modal-back { position: fixed; inset: 0; background: rgba(10, 15, 25, .5); display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; z-index: 100; padding: 16px; }
.modal { min-width: 0; background: var(--surface); border-radius: 14px; width: min(760px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.modal.wide { width: min(1100px, 100%); }
.modal.narrow { width: min(460px, 100%); }
.modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { flex: 1; margin: 0; }
.modal-body { padding: 18px 20px; overflow: auto; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* Toast */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: #111; color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); max-width: 420px; border-left: 4px solid var(--accent); }
.toast.success { border-left-color: #3cc58f; }
.toast.error { border-left-color: #f0675c; }
.toast.warn { border-left-color: #f0a04b; }

/* Combobox */
.combo { position: relative; }
.combo input { width: 100%; }
.combo-list { position: absolute; left: 0; right: 0; top: calc(100% + 2px); background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  max-height: 260px; overflow: auto; z-index: 120; box-shadow: 0 10px 30px rgba(0, 0, 0, .18); }
.combo-list div { padding: 7px 10px; cursor: pointer; }
.combo-list div.hl, .combo-list div:hover { background: var(--accent-soft); }
.combo-list .sub { color: var(--muted); font-size: 12px; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(ellipse at 50% 0%, rgba(212, 166, 42, .18), transparent 60%), radial-gradient(ellipse at 50% 100%, #1c1c1c, #050505 70%); }
.login-logo { width: 72px; height: auto; display: block; }
.login { width: min(400px, 100%); background: var(--surface); border-radius: 16px; padding: 30px; box-shadow: 0 30px 60px rgba(0, 0, 0, .35); }
.login h1 { margin: 14px 0 4px; }
.login form { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }

.chart-box { position: relative; height: 320px; }
.chart-box.sm { height: 240px; }
.internal { border: 1px dashed var(--warn); background: var(--warn-soft); border-radius: var(--radius); padding: 14px 16px; }
.internal h3 { color: var(--warn); }
.totals-grid { display: grid; grid-template-columns: auto auto; gap: 4px 24px; justify-content: end; font-variant-numeric: tabular-nums; }
.totals-grid .big { font-size: 18px; font-weight: 700; }
.items-table input { width: 100%; padding: 5px 7px; }
.items-table td { padding: 5px 6px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: var(--accent-soft); color: var(--accent-text); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; display: inline-flex; gap: 6px; align-items: center; }
.chip button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0; font-size: 14px; }
.list-compact { list-style: none; margin: 0; padding: 0; }
.list-compact li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.list-compact li:last-child { border-bottom: 0; }
.list-compact li.clickable { cursor: pointer; }
.list-compact li.clickable:hover { color: var(--accent-text); }
.note-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 13px; color: var(--muted); }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.gold-text { color: var(--accent-text); font-style: italic; font-weight: 800; letter-spacing: .06em; }

/* Výber jazyka */
.lang-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 22px; }
.lang-btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 8px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; }
.lang-btn:hover { border-color: var(--accent); color: var(--text); }
.lang-btn.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.lang-btn .flag { font-size: 15px; line-height: 1; }
.lang-select { padding: 5px 8px; font-size: 13px; }
