:root {
  color-scheme: light dark;
  --bg: #0f172a;
  --card: #1e293b;
  --accent: #0ea5e9;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
}

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

header h1 {
  margin: 0 0 8px;
}

header p {
  margin: 0 0 24px;
  color: var(--muted);
}

.config,
.search,
.source {
  background: var(--card);
  padding: 16px;
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  margin-bottom: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

label {
  font-weight: 600;
}

input,
select,
button {
  border-radius: var(--radius);
  border: 1px solid #1f2937;
  padding: 12px;
  font-size: 16px;
}

input {
  background: #0b1224;
  color: var(--text);
}

select {
  background: #0b1224;
  color: var(--text);
}

.config > summary {
  cursor: pointer;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

.config[open] > summary {
  margin-bottom: 16px;
}

button {
  background: var(--accent);
  color: #041221;
  cursor: pointer;
  font-weight: 700;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(14, 165, 233, 0.4);
}

.search-row {
  gap: 8px;
}

.search-controls {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
}

#mic {
  width: 52px;
  text-align: center;
}

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.dodak-list {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.dodak-card {
  border: 1px solid rgba(148,163,184,0.25);
  border-radius: 12px;
  padding: 10px;
  background: rgba(15,23,42,0.35);
}

.dodak-card img {
  width: 100%;
  height: auto;
  border-radius: 10px;
  display: block;
}

.dodak-meta {
  margin-top: 8px;
  font-size: 12px;
  color: rgba(226,232,240,0.9);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(148,163,184,0.35);
  color: rgba(226,232,240,0.95);
}

.badge.ok {
  border-color: rgba(34,197,94,0.55);
}

.badge.pending {
  border-color: rgba(251,191,36,0.55);
}

#status {
  min-height: 24px;
  margin: 12px 0;
}

.results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.product {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid #1f2937;
  display: flex;
  flex-direction: column;
}

.product img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: #0b1224;
}

.product .body {
  padding: 12px;
}

.product h3 {
  margin: 0 0 6px;
}

.product p {
  margin: 0;
  color: var(--muted);
}

/* Etapa 2: sklad (šarže) */
.stock {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #1f2937;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stock-line,
.day-line {
  font-size: 14px;
  color: var(--text);
}

.batches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.batch {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid #1f2937;
  background: #0b1224;
  color: var(--muted);
}

/* Etapa 4.1 – farebná logika expirácie (rovnaká norma ako WP)
   Triedy: exp-ok, exp-3, exp-2, exp-1, exp-today, exp-minus-1, exp-minus-2 */

.batch.exp-ok {
  /* >3 dni */
}

.batch.exp-3 {
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.6);
  color: var(--text);
}

.batch.exp-2 {
  background: rgba(59, 130, 246, 0.14);
  border-color: rgba(59, 130, 246, 0.65);
  color: var(--text);
}

.batch.exp-1 {
  background: rgba(248, 113, 113, 0.14);
  border-color: rgba(248, 113, 113, 0.65);
  color: var(--text);
}

.batch.exp-today {
  background: rgba(220, 38, 38, 0.2);
  border-color: rgba(220, 38, 38, 0.85);
  color: #ffffff;
}

.batch.exp-minus-1 {
  background: rgba(153, 27, 27, 0.35);
  border-color: rgba(153, 27, 27, 0.9);
  color: #ffffff;
}

.batch.exp-minus-2 {
  background: rgba(88, 28, 28, 0.55);
  border-color: rgba(88, 28, 28, 0.95);
  color: rgba(253, 224, 71, 0.95);
  font-weight: 700;
}

.btnrow {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.btnrow .btn {
  padding: 10px;
  font-size: 14px;
}

@media (max-width: 600px) {
  .search-controls {
    grid-template-columns: 1fr 52px;
    grid-template-rows: auto auto;
  }

  #search-btn {
    grid-column: 1 / span 2;
  }
}

.stock-debug {
  opacity: 0.7;
  font-size: 12px;
  margin: 4px 0;
}

/* Etapa 2.1: rýchle +/- + exp voľby */
.quickwrap {
  margin-top: 6px;
  padding: 10px;
  border: 1px dashed rgba(148,163,184,0.35);
  border-radius: 10px;
  background: rgba(11,18,36,0.55);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stock-debug {
  font-size: 12px;
  color: var(--muted);
}

.exp-label {
  font-size: 13px;
  color: var(--text);
}

.exp-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.quick-title {
  font-size: 12px;
  color: var(--muted);
  min-width: 92px;
}

.btn.sm {
  padding: 8px 10px;
  font-size: 14px;
  border-radius: 10px;
}

/* -----------------------------
   Etapa 3.1 – Dodák: klikací príjem
------------------------------ */
.dodak-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: none;
  padding: 14px;
  z-index: 9999;
}
.dodak-overlay.open { display: block; }

.dodak-modal {
  max-width: 1100px;
  margin: 0 auto;
  background: rgba(11,18,36,0.96);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  overflow: hidden;
}

.dodak-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.dodak-modal-title { font-weight: 700; }
.dodak-modal-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.dodak-modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.dodak-modal-left {
  padding: 12px;
  border-right: 1px solid rgba(255,255,255,0.08);
}

.dodak-modal-left img {
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
  background: rgba(0,0,0,0.2);
  border-radius: 12px;
}

.dodak-modal-right {
  padding: 12px;
}

.dodak-search-results {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 32vh;
  overflow: auto;
  padding-right: 4px;
}

.dodak-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(11,18,36,0.55);
  border-radius: 12px;
  padding: 10px;
}

.dodak-r-name { font-weight: 650; }
.dodak-r-sku { font-size: 12px; color: var(--muted); }

.dodak-result-right {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.dodak-entries {
  margin-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 12px;
}

.dodak-entries-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.dodak-entries-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 24vh;
  overflow: auto;
  padding-right: 4px;
}

.dodak-entry {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(11,18,36,0.55);
  border-radius: 12px;
}

.dodak-entry-meta {
  grid-column: 1 / 2;
  font-size: 12px;
  color: var(--muted);
}

.dodak-entry-qty {
  grid-row: 1 / 3;
  grid-column: 2 / 3;
  align-self: center;
  font-weight: 800;
}

@media (max-width: 900px) {
  .dodak-modal-grid { grid-template-columns: 1fr; }
  .dodak-modal-left { border-right: none; border-bottom: 1px solid rgba(255,255,255,0.08); }
  .dodak-modal-left img { max-height: 46vh; }
}


/* -----------------------------
   Etapa 4.3: Edit modal (oprava dnešných pohybov)
------------------------------ */
.btn.ghost { background: transparent; border-color: rgba(148,163,184,.35); color: var(--text); }
.btn.warn { border-color: rgba(252,165,165,.6); color: #fca5a5; background: rgba(252,165,165,.08); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  z-index: 9999;
}
.modal-overlay.hidden { display: none; }

.modal {
  width: min(720px, 100%);
  background: var(--card);
  border: 1px solid rgba(148,163,184,.25);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0,0,0,.35);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(148,163,184,.18);
}
.modal-title { font-weight: 700; letter-spacing: .2px; }
.modal-body { padding: 12px 14px; }
.modal-sub { color: var(--muted); margin-bottom: 10px; }

.mv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 560px) {
  .mv-grid { grid-template-columns: 1fr; }
}

.mv-block {
  border: 1px solid rgba(148,163,184,.18);
  border-radius: 12px;
  padding: 10px;
  background: rgba(15, 23, 42, 0.35);
}
.mv-h { font-weight: 700; margin-bottom: 8px; }
.mv-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; flex-wrap: wrap; }
.mv-lbl { width: 72px; color: var(--muted); }
.mv-ctrl { display: flex; align-items: center; gap: 8px; }
.mv-val { min-width: 24px; display: inline-block; font-weight: 700; }
.mv-val.mono, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }
.mv-input { width: 140px; padding: 6px 8px; border-radius: 10px; border: 1px solid rgba(148,163,184,.25); background: rgba(2, 6, 23, 0.25); color: var(--text); }

.mv-reason { margin-top: 10px; border-top: 1px dashed rgba(148,163,184,.22); padding-top: 10px; }
.mv-text { width: 100%; padding: 8px 10px; border-radius: 12px; border: 1px solid rgba(148,163,184,.25); background: rgba(2, 6, 23, 0.25); color: var(--text); }

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }
.modal-foot { margin-top: 8px; color: var(--muted); font-size: 12px; }

