:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1f2a37;
  --muted: #6b7280;
  --line: #e3e8ee;
  --in: #2563eb;
  --out: #d97706;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.04);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}
header {
  padding: 18px 20px 10px;
  max-width: 1000px;
  margin: 0 auto;
}
header h1 { margin: 0; font-size: 1.5rem; }
header .sub { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  max-width: 1000px;
  margin: 0 auto;
  padding: 8px 20px 0;
  border-bottom: 1px solid var(--line);
}
.tabs .spacer { flex: 1; }
.tabs button {
  border: 1px solid transparent;
  background: none;
  padding: 9px 14px;
  font-size: .92rem;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  color: var(--muted);
}
.tabs button:hover { background: #eef1f5; color: var(--ink); }
.tabs button.active { color: var(--ink); font-weight: 600; border-bottom: 2px solid var(--in); border-radius: 8px; }
.tabs button.mode { font-weight: 600; border-radius: 8px; color: #fff; }
.tabs button.mode-in { background: var(--in); }
.tabs button.mode-out { background: var(--out); }
.tabs button.mode:hover { filter: brightness(1.06); }

main { max-width: 1000px; margin: 0 auto; padding: 18px 20px 60px; }
.tab { display: none; }
.tab.active { display: block; }

.toolbar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  margin-bottom: 14px;
}
.toolbar input[type=search] {
  flex: 1; min-width: 180px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: .95rem;
}
label.inline { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .9rem; }
.num { width: 64px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; }

.summary { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.summary .pill { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; box-shadow: var(--shadow); font-size: .9rem; }
.summary .pill b { font-size: 1.15rem; display: block; }

table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: .92rem; vertical-align: top; }
th { background: #f8fafc; color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; white-space: nowrap; }
.atc { color: var(--muted); font-family: ui-monospace, "Cascadia Code", monospace; font-size: .82rem; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge.ok  { background: #dcfce7; color: #166534; }
.badge.warn{ background: #fef3c7; color: #92400e; }
.badge.bad { background: #fee2e2; color: #991b1b; }
.badge.muted { background: #eef1f5; color: var(--muted); }

.row-ok   td:first-child { box-shadow: inset 3px 0 0 var(--ok); }
.row-warn td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.row-bad  td:first-child { box-shadow: inset 3px 0 0 var(--bad); }

.muted { color: var(--muted); font-size: .85rem; }
.popis { color: var(--muted); font-size: .82rem; margin-top: 2px; }

.cards { display: grid; gap: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; box-shadow: var(--shadow); display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.card .qty { font-weight: 700; white-space: nowrap; }
.card.exp-bad { border-left: 4px solid var(--bad); }
.card.exp-warn { border-left: 4px solid var(--warn); }
.card.exp-ok { border-left: 4px solid var(--ok); }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; background: var(--card); border-radius: 10px; border: 1px dashed var(--line); }

/* formuláre */
.form { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; box-shadow: var(--shadow); max-width: 560px; }
.form label { display: block; margin-bottom: 12px; font-weight: 600; font-size: .9rem; }
.form .row { display: flex; gap: 12px; }
.form .row label { flex: 1; }
.form select, .form input { width: 100%; margin-top: 4px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: .95rem; font-weight: 400; }
.form .muted { font-weight: 400; }
.hint { font-size: .85rem; color: var(--muted); margin-bottom: 12px; min-height: 1.2em; }
.btn-in, .btn-out, .btn-ghost { border: none; padding: 10px 18px; border-radius: 8px; font-size: .95rem; font-weight: 600; cursor: pointer; }
.btn-in { background: var(--in); color: #fff; }
.btn-out { background: var(--out); color: #fff; }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: var(--ink); text-decoration: none; display: inline-block; }
.btn-in:hover, .btn-out:hover { filter: brightness(1.06); }
.btn-ghost:hover { background: #f1f5f9; }
.mode-title { margin-top: 0; }
.mode-title.in { color: var(--in); }
.mode-title.out { color: var(--out); }

.del { background: none; border: none; color: var(--bad); cursor: pointer; font-size: .85rem; padding: 2px 6px; border-radius: 6px; }
.del:hover { background: #fee2e2; }

.log-row { display: grid; grid-template-columns: 96px 80px 1fr auto; gap: 10px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin-bottom: 6px; font-size: .9rem; }
.log-row .typ-in { color: var(--in); font-weight: 600; }
.log-row .typ-out { color: var(--out); font-weight: 600; }
.log-row .when { color: var(--muted); font-size: .82rem; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: #111827; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: .9rem; opacity: 0; pointer-events: none; transition: all .25s; z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--bad); }

@media (max-width: 600px) {
  .log-row { grid-template-columns: 1fr auto; }
  .log-row .when { grid-column: 1 / -1; }
  th.hide-sm, td.hide-sm { display: none; }
}
