/* ============================================================
   SALDO — účetnictví & fakturace
   Brand: moderní, svěží fintech. Světlé téma, emerald akcent.
   ============================================================ */

:root {
  /* ---- Surfaces & ink ---- */
  --bg:          oklch(98.6% 0.004 140);
  --surface:     oklch(100% 0 0);
  --surface-2:   oklch(97.3% 0.005 150);
  --surface-3:   oklch(95.2% 0.008 155);
  --ink:         oklch(25% 0.018 175);
  --ink-2:       oklch(47% 0.014 172);
  --ink-3:       oklch(62% 0.011 170);
  --line:        oklch(92.4% 0.006 160);
  --line-2:      oklch(88% 0.009 160);

  /* ---- Brand (emerald) ---- */
  --brand:        oklch(57% 0.118 165);
  --brand-strong: oklch(50% 0.12 166);
  --brand-press:  oklch(45% 0.11 166);
  --brand-ink:    oklch(99% 0.01 165);
  --brand-soft:   oklch(95.5% 0.035 165);
  --brand-soft-2: oklch(92% 0.05 165);
  --brand-line:   oklch(85% 0.06 165);

  /* ---- Semantic ---- */
  --positive:      oklch(56% 0.13 162);
  --positive-soft: oklch(95% 0.04 162);
  --warning:       oklch(64% 0.13 70);
  --warning-soft:  oklch(95.5% 0.05 80);
  --warning-line:  oklch(83% 0.09 75);
  --danger:        oklch(56% 0.2 27);
  --danger-soft:   oklch(95.5% 0.035 25);
  --danger-line:   oklch(83% 0.1 27);
  --info:          oklch(57% 0.12 248);
  --info-soft:     oklch(95.5% 0.03 248);
  --info-line:     oklch(82% 0.07 248);
  --violet:        oklch(56% 0.16 295);

  /* ---- Type ---- */
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-sans:    'Hanken Grotesk', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, monospace;

  /* ---- Radii ---- */
  --r-sm: 8px;
  --r-md: 11px;
  --r-lg: 15px;
  --r-xl: 22px;
  --r-pill: 999px;

  /* ---- Shadows ---- */
  --sh-xs: 0 1px 2px oklch(30% 0.05 165 / 0.05);
  --sh-sm: 0 1px 3px oklch(30% 0.05 165 / 0.07), 0 1px 2px oklch(30% 0.05 165 / 0.04);
  --sh-md: 0 8px 24px -10px oklch(30% 0.05 165 / 0.16);
  --sh-pop: 0 18px 44px -14px oklch(28% 0.06 165 / 0.26);

  /* ---- Layout ---- */
  --sidebar-w: 248px;
  --topbar-h: 60px;
  --content-max: 1320px;

  /* ---- Density (tweakable) ---- */
  --row-py: 13px;
  --card-pad: 22px;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-variant-numeric: tabular-nums;
}

#root { height: 100%; }

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; margin: 0; color: var(--ink); }

button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: var(--ink); }

::selection { background: var(--brand-soft-2); }

.mono { font-family: var(--font-mono); font-feature-settings: "tnum"; letter-spacing: -0.02em; }
.tnum { font-variant-numeric: tabular-nums; }
.dim { color: var(--ink-2); }
.faint { color: var(--ink-3); }

/* ============================================================
   APP SHELL
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100%;
  background: var(--bg);
}

/* ---- Sidebar ---- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  z-index: 20;
}
.sidebar-brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.logo-mark {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: linear-gradient(150deg, var(--brand) 0%, var(--brand-strong) 100%);
  display: grid; place-items: center;
  color: var(--brand-ink);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  box-shadow: inset 0 1px 0 oklch(100% 0 0 / 0.25), var(--sh-xs);
  flex-shrink: 0;
}
.logo-word {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.logo-word b { color: var(--brand); }

.sidebar-scroll { flex: 1; overflow-y: auto; padding: 14px 12px; }
.nav-group { margin-bottom: 18px; }
.nav-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 0 12px 7px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 12px;
  border-radius: var(--r-md);
  color: var(--ink-2);
  font-weight: 500;
  font-size: 13.5px;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background var(--ease) .14s, color var(--ease) .14s;
  position: relative;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; }
.nav-item.active svg { color: var(--brand); }
.nav-item svg { color: var(--ink-3); flex-shrink: 0; transition: color var(--ease) .14s; }
.nav-item .nav-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--ink-2);
  border-radius: var(--r-pill);
  padding: 1px 7px;
  min-width: 20px;
  text-align: center;
}
.nav-item.active .nav-count { background: var(--brand-soft-2); color: var(--brand-strong); }
.nav-item .nav-count.warn { background: var(--warning-soft); color: oklch(48% 0.12 60); }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--line); flex-shrink: 0; }
.org-card {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--r-md);
  cursor: pointer; transition: background var(--ease) .14s;
}
.org-card:hover { background: var(--surface-2); }
.org-logo {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--surface-3); color: var(--ink);
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
  font-family: var(--font-display); flex-shrink: 0;
  border: 1px solid var(--line);
}
.org-meta { flex: 1; min-width: 0; }
.org-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.org-sub { font-size: 11px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- Main ---- */
.main { display: flex; flex-direction: column; height: 100%; overflow: hidden; min-width: 0; }

.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
  background: oklch(100% 0 0 / 0.8);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 15;
}
.search {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 7px 12px;
  width: 320px; max-width: 38vw;
  color: var(--ink-3);
  cursor: text;
  transition: border-color var(--ease) .14s, background var(--ease) .14s;
}
.search:hover { border-color: var(--line-2); }
.search input { border: none; background: none; outline: none; flex: 1; font-size: 13.5px; color: var(--ink); }
.search .kbd {
  font-family: var(--font-mono); font-size: 11px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 5px; padding: 1px 5px; color: var(--ink-3);
}
.topbar-spacer { flex: 1; }

.period-pick {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface);
  font-weight: 500; font-size: 13px; cursor: pointer; color: var(--ink);
  transition: background var(--ease) .14s;
}
.period-pick:hover { background: var(--surface-2); }

.icon-btn {
  width: 38px; height: 38px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; cursor: pointer; color: var(--ink-2);
  transition: background var(--ease) .14s, color var(--ease) .14s;
  position: relative;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn .dot {
  position: absolute; top: 8px; right: 9px; width: 7px; height: 7px;
  background: var(--danger); border-radius: 50%; border: 1.5px solid var(--surface);
}
.user-chip {
  display: flex; align-items: center; gap: 9px; cursor: pointer;
  padding: 4px 4px 4px 4px; border-radius: var(--r-pill);
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(140deg, var(--brand-soft-2), var(--brand-soft));
  color: var(--brand-strong); display: grid; place-items: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
  border: 1px solid var(--brand-line);
}

.content { flex: 1; overflow-y: auto; }
.content-inner { max-width: var(--content-max); margin: 0 auto; padding: 26px 26px 80px; }

/* ---- Page header ---- */
.page-head { display: flex; align-items: flex-start; gap: 18px; margin-bottom: 22px; }
.page-head .ph-text { flex: 1; min-width: 0; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--brand); margin-bottom: 6px; }
.page-title { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.page-sub { color: var(--ink-2); margin-top: 4px; font-size: 14px; }
.page-actions { display: flex; gap: 10px; align-items: center; flex-shrink: 0; }

/* ============================================================
   PRIMITIVES
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  border-radius: var(--r-md); padding: 9px 15px; font-weight: 600; font-size: 13.5px;
  cursor: pointer; border: 1px solid transparent; white-space: nowrap;
  transition: background var(--ease) .14s, border-color var(--ease) .14s, transform .08s var(--ease), box-shadow var(--ease) .14s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: var(--brand-ink); box-shadow: var(--sh-xs); }
.btn-primary:hover { background: var(--brand-strong); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); }
.btn-danger:hover { background: oklch(92% 0.06 25); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn-lg { padding: 12px 20px; font-size: 15px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-xs);
}
.card-pad { padding: var(--card-pad); }
.card-head { display: flex; align-items: center; gap: 12px; padding: 16px var(--card-pad); border-bottom: 1px solid var(--line); }
.card-head h3 { font-size: 15px; font-weight: 600; }
.card-head .card-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600; padding: 3px 9px;
  border-radius: var(--r-pill); border: 1px solid transparent; white-space: nowrap;
  line-height: 1.4;
}
.badge .bd-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.paid    { background: var(--positive-soft); color: var(--positive); }
.badge.sent    { background: var(--info-soft); color: var(--info); }
.badge.draft   { background: var(--surface-3); color: var(--ink-2); }
.badge.due     { background: var(--warning-soft); color: oklch(46% 0.1 62); }
.badge.overdue { background: var(--danger-soft); color: var(--danger); }
.badge.partial { background: oklch(95% 0.04 295); color: var(--violet); }
.badge.neutral { background: var(--surface-3); color: var(--ink-2); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 500; padding: 5px 10px;
  border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); cursor: pointer; transition: all var(--ease) .14s;
}
.chip:hover { background: var(--surface-2); border-color: var(--line-2); }
.chip.on { background: var(--brand-soft); color: var(--brand-strong); border-color: var(--brand-line); }

/* ---- Forms ---- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 11.5px; color: var(--ink-3); }
.input, .select, textarea.input {
  border: 1px solid var(--line-2); background: var(--surface);
  border-radius: var(--r-md); padding: 9px 12px; font-size: 13.5px; color: var(--ink);
  width: 100%; outline: none; transition: border-color var(--ease) .14s, box-shadow var(--ease) .14s;
}
.input:focus, .select:focus, textarea.input:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.input::placeholder { color: var(--ink-3); }
.input-affix { position: relative; display: flex; align-items: center; }
.input-affix .suffix { position: absolute; right: 12px; color: var(--ink-3); font-size: 13px; pointer-events: none; }

/* ---- Tables ---- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--ink-3); padding: 0 16px 10px; white-space: nowrap;
}
.tbl th.num, .tbl td.num { text-align: right; }
.tbl td { padding: var(--row-py) 16px; border-top: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr { transition: background var(--ease) .12s; cursor: pointer; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr.sel { background: var(--brand-soft); }
.tbl .amt { font-weight: 600; font-variant-numeric: tabular-nums; }
.tbl .amt.pos { color: var(--positive); }
.tbl .amt.neg { color: var(--danger); }

.cell-strong { font-weight: 600; color: var(--ink); line-height: 1.3; }
.cell-2 { display: flex; flex-direction: column; gap: 2px; }
.cell-2 .c2-sub { font-size: 12px; color: var(--ink-3); }

/* ---- KPI / Stat ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 18px; box-shadow: var(--sh-xs); position: relative; overflow: hidden;
}
.kpi-label { font-size: 12.5px; color: var(--ink-2); font-weight: 500; display: flex; align-items: center; gap: 7px; }
.kpi-val { font-family: var(--font-display); font-size: 27px; font-weight: 600; letter-spacing: -0.02em; margin-top: 9px; color: var(--ink); }
.kpi-val .cur { font-size: 16px; color: var(--ink-3); font-weight: 500; }
.kpi-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12.5px; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; }
.delta.up { color: var(--positive); }
.delta.down { color: var(--danger); }
.kpi-spark { position: absolute; right: 16px; top: 16px; opacity: .9; }

/* ---- Misc ---- */
.divider { height: 1px; background: var(--line); border: none; margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-10 { gap: 10px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }

.seg {
  display: inline-flex; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 3px;
}
.seg button {
  border: none; background: none; padding: 6px 14px; border-radius: 8px;
  font-weight: 600; font-size: 13px; color: var(--ink-2); cursor: pointer;
  transition: all var(--ease) .14s;
}
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--sh-xs); }

.progress { height: 7px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.progress > div { height: 100%; border-radius: var(--r-pill); background: var(--brand); transition: width .5s var(--ease); }

.avatar-sm { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 11px; flex-shrink: 0; }

.empty { text-align: center; padding: 60px 20px; color: var(--ink-3); }
.empty svg { color: var(--line-2); margin-bottom: 12px; }

/* scrollbar */
.content::-webkit-scrollbar, .sidebar-scroll::-webkit-scrollbar { width: 10px; }
.content::-webkit-scrollbar-thumb, .sidebar-scroll::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid var(--bg); }
.sidebar-scroll::-webkit-scrollbar-thumb { border-color: var(--surface); }

/* No screen-level entrance animation: keeps content reliably visible in
   frozen-frame contexts (screenshot capture, PDF, print). Micro-interactions
   (hover, drawer slide, toasts) remain. */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.screen { opacity: 1; }

/* density variant */
.app[data-density="compact"] { --row-py: 8px; --card-pad: 16px; }
.app[data-density="spacious"] { --row-py: 17px; --card-pad: 26px; }

@media (max-width: 1100px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
