:root {
  --green: #43892C;
  --green-dark: #2E6B1F;
  --green-soft: #EEF4EB;
  --green-line: #C9D9C2;
  --ink: #1E2220;
  --ink-2: #4A514C;
  --muted: #6E766F;
  --bg: #F4F6F3;
  --card: #FFFFFF;
  --line: #DDE3DA;
  --warn: #B7791F;
  --warn-soft: #FDF3DC;
  --danger: #B42318;
  --danger-soft: #FDECEA;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(30, 34, 32, .06), 0 2px 8px rgba(30, 34, 32, .05);
  font-family: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); font-size: 15px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
a { color: var(--green-dark); }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 22px 0 10px; }
h3 { font-size: 15px; margin: 16px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- rozvržení ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
.top .logo { height: 26px; display: block; }
.top .app-name { font-weight: 700; color: var(--green-dark); font-size: 15px; white-space: nowrap; }
.top .spacer { flex: 1; }
.top .who { font-size: 13px; color: var(--muted); text-align: right; line-height: 1.2; }
.menu-btn { display: none; }
.layout { display: flex; min-height: calc(100vh - 47px); }
nav.side {
  width: 210px; flex: none; padding: 14px 10px; background: var(--card); border-right: 1px solid var(--line);
}
nav.side a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; margin-bottom: 2px;
  border-radius: 8px; color: var(--ink-2); text-decoration: none; font-weight: 500;
}
nav.side a:hover { background: var(--green-soft); }
nav.side a.on { background: var(--green); color: #fff; }
nav.side .grp { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 12px 12px 4px; }
nav.side .grp:first-child { padding-top: 2px; }
nav.side .sep { height: 1px; background: var(--line); margin: 10px 6px; }
main { flex: 1; min-width: 0; padding: 20px 24px 60px; max-width: 1200px; }
.demo-bar { background: var(--warn-soft); color: #6B4A10; padding: 6px 16px; font-size: 13px; text-align: center; border-bottom: 1px solid #F1DDB0; }

@media (max-width: 820px) {
  .menu-btn { display: inline-flex; }
  nav.side {
    position: fixed; top: 47px; left: 0; bottom: 0; z-index: 30; transform: translateX(-100%);
    transition: transform .18s ease; box-shadow: var(--shadow);
  }
  nav.side.open { transform: none; }
  main { padding: 16px 16px 60px; }
  .top .who { display: none; }
  .top .app-name { display: none; }
}

/* ---------- karty, mřížky ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { min-width: 0; }
.grow { flex: 1 1 220px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 14px 0; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.tile .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile.warn { border-color: #EBCB8B; background: var(--warn-soft); }
.tile .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }

/* ---------- formuláře ---------- */
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-2); font-weight: 500; }
input, select, textarea {
  font: inherit; color: var(--ink); background: #fff;
  border: 1px solid #C8D0C5; border-radius: 8px; padding: 9px 10px; min-height: 40px; width: 100%;
}
textarea { min-height: 64px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(67, 137, 44, .35); border-color: var(--green); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; accent-color: var(--green); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
input.qty { width: 90px; text-align: right; }

button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 8px; padding: 9px 16px; min-height: 40px;
  border: 1px solid var(--green); background: var(--green); color: #fff; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
button:hover, .btn:hover { background: var(--green-dark); border-color: var(--green-dark); }
button.sec, .btn.sec { background: #fff; color: var(--green-dark); border-color: var(--green-line); }
button.sec:hover, .btn.sec:hover { background: var(--green-soft); }
button.ghost { background: transparent; border-color: transparent; color: var(--ink-2); padding: 6px 10px; min-height: 32px; }
button.ghost:hover { background: var(--green-soft); }
button.danger { background: #fff; color: var(--danger); border-color: #EBC1BC; }
button.danger:hover { background: var(--danger-soft); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.big { min-height: 48px; font-size: 16px; padding: 10px 22px; }

/* ---------- tabulky ---------- */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table.t { border-collapse: collapse; width: 100%; font-size: 14px; }
table.t th {
  background: var(--green-dark); color: #fff; font-weight: 600; text-align: left;
  padding: 8px 10px; position: sticky; top: 0; white-space: nowrap;
}
table.t td { padding: 7px 10px; border-top: 1px solid #E6ECE3; vertical-align: middle; }
table.t tbody tr:nth-child(even) td { background: var(--green-soft); }
table.t tr.grp td { background: #fff !important; color: var(--green-dark); font-weight: 700; padding-top: 14px; border-top: 2px solid var(--green-line); }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #E2EDDD; }
table.t tr.off td { color: var(--muted); }
table.t tr.storno td { color: var(--muted); text-decoration: line-through; }
table.t tfoot td { font-weight: 700; background: #E7EEE4; border-top: 2px solid var(--green-line); }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--green-soft); color: var(--green-dark); white-space: nowrap; }
.badge.warn { background: var(--warn-soft); color: #8A5A0B; }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.grey { background: #ECEEEB; color: var(--ink-2); }
.b-prijem { background: #E3F0FB; color: #1F5A8A; }
.b-vydej { background: var(--green-soft); color: var(--green-dark); }
.b-inventura { background: #F1E9FA; color: #5B3A8A; }
.b-storno { background: var(--danger-soft); color: var(--danger); }

.alert { padding: 10px 12px; border-radius: 8px; font-size: 14px; margin: 8px 0; }
.alert.warn { background: var(--warn-soft); color: #6B4A10; }
.alert.err { background: var(--danger-soft); color: var(--danger); }
.alert.ok { background: var(--green-soft); color: var(--green-dark); }

/* ---------- výběr ze seznamu ---------- */
.picker { position: relative; }
.picker .list {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 15; margin-top: 4px; max-height: 320px; overflow-y: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow);
}
.picker .opt { padding: 9px 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; border-top: 1px solid #F0F3EF; }
.picker .opt:first-child { border-top: 0; }
.picker .opt:hover, .picker .opt.act { background: var(--green-soft); }
.picker .opt .r { color: var(--muted); font-size: 13px; white-space: nowrap; }

.person { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border-radius: 8px; background: var(--green-soft); }
.person .n { font-weight: 700; font-size: 17px; }

/* ---------- podpis ---------- */
.sig-wrap { border: 1px dashed #9DB394; border-radius: 10px; background: #fff; position: relative; touch-action: none; }
.sig-wrap canvas { display: block; width: 100%; height: 180px; touch-action: none; }
.sig-wrap .hint { position: absolute; left: 14px; bottom: 10px; color: #9AA59A; font-size: 13px; pointer-events: none; }
.sig-img { max-width: 320px; width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

/* ---------- oprávnění ---------- */
table.perm td, table.perm th { text-align: center; }
table.perm td:first-child, table.perm th:first-child { text-align: left; }
table.perm th { font-size: 12px; white-space: normal; min-width: 70px; }

/* ---------- přihlášení ---------- */
.login { max-width: 380px; margin: 9vh auto; padding: 0 16px; }
.login .card { padding: 24px; }
.login img { height: 34px; margin-bottom: 18px; }

/* ---------- toast ---------- */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); font-size: 14px; animation: tin .2s ease; }
.toast.ok { background: var(--green-dark); }
.toast.err { background: var(--danger); }
@keyframes tin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #B9C2B6; }
.live.on::before { background: var(--green); box-shadow: 0 0 0 3px rgba(67, 137, 44, .18); }

/* ---------- tisk ---------- */
.print-only { display: none; }
@media print {
  .top, nav.side, .demo-bar, .no-print, #toasts { display: none !important; }
  .print-only { display: block; }
  body { background: #fff; font-size: 12px; }
  main { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .tbl-wrap { border: 0; overflow: visible; }
  table.t th { background: #fff; color: #000; border-bottom: 2px solid #000; position: static; }
  table.t tbody tr:nth-child(even) td { background: #fff; }
  table.t td { border-top: 1px solid #999; }
  .sig-img { max-width: 140px; border: 0; }
}
