/* Farebná identita OOBraider: čierna #171717, mätová #67D7CF, biela.
   Mätová je pozadie a akcent; na svetlom pozadí sa ako text nepoužíva (malý kontrast),
   tam slúži tmavší odtieň --mint-ink. */
:root {
  --ink: #171717;
  --ink-soft: #3d4443;
  --muted: #5f6b6a;
  --white: #ffffff;
  --bg: #f4f7f7;
  --card: #ffffff;
  --soft: #eef3f3;
  --line: #dde6e5;
  --field-border: #c3d0cf;
  --mint: #67D7CF;
  --mint-hover: #4fc8bf;
  --mint-soft: #e3f7f5;
  --mint-ink: #12726b;
  --danger: #c62828;
  --danger-soft: #fdecea;
  --radius: 14px;
  --tap: 48px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
h2 { font-size: 1.3rem; line-height: 1.3; margin: 0 0 .4rem; }
h3 { font-size: 1.05rem; margin: 1.4rem 0 .6rem; }
p { margin: .4rem 0; }
.small { font-size: .875rem; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* hlavička */
.topbar {
  background: var(--ink);
  color: var(--white);
  position: sticky;
  top: 0;
  z-index: 10;
  padding-top: env(safe-area-inset-top);
  border-bottom: 3px solid var(--mint);
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 12px;
  flex-wrap: wrap;
}
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.logo { height: 32px; width: auto; align-self: center; }
.logo-text { font-weight: 800; letter-spacing: .04em; font-size: 1.2rem; color: var(--mint); }
.app-name { font-size: .95rem; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs, .lang { display: flex; gap: 4px; background: rgba(255, 255, 255, .1); border-radius: 999px; padding: 3px; }
.tabs button, .lang button {
  border: 0; background: transparent; color: var(--white); font: inherit; font-size: .9rem;
  padding: 8px 14px; border-radius: 999px; min-height: 40px; cursor: pointer;
}
.lang button { padding: 8px 12px; font-weight: 700; letter-spacing: .03em; min-width: 44px; }
.tabs button.active, .lang button.on { background: var(--mint); color: var(--ink); font-weight: 700; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 16px calc(40px + env(safe-area-inset-bottom));
}

/* karty a polia */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.help { color: var(--ink-soft); font-size: .92rem; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.row > .field { flex: 1 1 160px; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; min-width: 0; }
.field.grow { flex: 2 1 220px; }
.field.currency { flex: 0 0 110px; }
.label { font-size: .88rem; font-weight: 600; color: var(--ink-soft); }
input[type="text"], input[type="search"], select {
  font: inherit;
  font-size: 16px; /* iOS bez priblíženia */
  min-height: var(--tap);
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--field-border);
  border-radius: 10px;
  background: var(--white);
  color: var(--ink);
}
input::placeholder { color: #8b9695; font-size: 15px; opacity: 1; }
input:focus, select:focus { outline: 3px solid var(--mint-soft); border-color: var(--mint-ink); }
.input-unit { display: flex; align-items: stretch; }
.input-unit input { border-radius: 10px 0 0 10px; text-align: right; }
.input-unit input:placeholder-shown { text-align: left; }
.unit {
  display: flex; align-items: center; padding: 0 12px; min-width: 48px; justify-content: center;
  background: var(--soft); border: 1px solid var(--field-border); border-left: 0; border-radius: 0 10px 10px 0;
  color: var(--muted); font-size: .92rem; white-space: nowrap;
}
input.invalid, select.invalid { border-color: var(--danger); background: #fffafa; }
.input-unit input.invalid + .unit { border-color: var(--danger); }
.field-msg { color: var(--danger); font-size: .86rem; font-weight: 600; line-height: 1.35; }
.field-msg .btn { margin-top: 6px; }
.divider { height: 1px; background: var(--line); margin: 16px 0 6px; }
.field.tax { max-width: 260px; }

/* tlačidlá */
.btn {
  font: inherit; font-weight: 600; min-height: var(--tap); padding: 10px 18px; border-radius: 10px;
  border: 1px solid var(--ink); background: var(--ink); color: var(--white); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-align: center;
}
.btn.primary, .btn.accent { background: var(--mint); border-color: var(--mint); color: var(--ink); font-weight: 700; }
.btn.primary:hover, .btn.accent:hover { background: var(--mint-hover); border-color: var(--mint-hover); }
.btn.ghost { background: var(--white); color: var(--ink); border-color: var(--field-border); }
.btn.ghost:hover { border-color: var(--ink); }
.btn.danger { background: var(--white); color: var(--danger); border-color: var(--danger); }
.btn.small { min-height: 40px; padding: 6px 12px; font-size: .88rem; }
.btn.block { width: 100%; margin: 10px 0 4px; }
.link {
  background: none; border: 0; padding: 8px 4px; font: inherit; color: var(--ink);
  text-decoration: underline; text-decoration-color: var(--mint); text-decoration-thickness: 2px;
  text-underline-offset: 3px; cursor: pointer; min-height: 40px;
}
.link.danger { color: var(--danger); text-decoration-color: currentColor; text-decoration-thickness: 1px; }
.icon-btn {
  width: var(--tap); height: var(--tap); flex: 0 0 var(--tap); border-radius: 10px; border: 1px solid var(--field-border);
  background: var(--white); font-size: 1.4rem; line-height: 1; color: var(--muted); cursor: pointer; margin-top: 34px;
}
.icon-btn:hover { color: var(--danger); border-color: var(--danger); }
.file-btn { position: relative; overflow: hidden; }
.file-btn input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }

/* súhrny a chyby */
.kv {
  display: flex; justify-content: space-between; gap: 12px; padding: 8px 0;
  border-bottom: 1px dashed var(--line); font-size: .95rem;
}
.highlight { background: var(--ink); color: var(--white); border-radius: 12px; padding: 14px 16px; margin-top: 12px; }
.highlight .muted { color: rgba(255, 255, 255, .72); }
.hl-label { display: block; font-size: .85rem; font-weight: 600; color: var(--mint); }
.hl-value { display: block; font-size: 1.6rem; font-weight: 800; margin: 2px 0 4px; color: var(--mint); }
.errors {
  list-style: none; margin: 12px 0 0; padding: 10px 14px; border-radius: 10px;
  background: var(--danger-soft); color: var(--danger); font-size: .92rem; font-weight: 600;
}
.errors li + li { margin-top: 6px; }
.errors .btn { margin-left: 4px; }
.errors-inline { color: var(--danger); font-weight: 600; }
.notice { background: var(--soft); border-radius: 10px; padding: 10px 14px; font-size: .92rem; }
.notice.warn { background: var(--danger-soft); color: var(--danger); }
.banner {
  position: sticky; top: 76px; z-index: 5; display: flex; gap: 12px; align-items: center; justify-content: space-between;
  flex-wrap: wrap; background: var(--mint-soft); border: 2px solid var(--mint); border-radius: 12px;
  padding: 10px 14px; margin-bottom: 16px; font-weight: 600;
}

/* sprievodca */
.wizard { max-width: 680px; margin: 0 auto; }
.intro { font-size: 1.05rem; margin: 4px 0 14px; }
.progress-wrap { margin-bottom: 12px; }
.step-label { font-size: .85rem; font-weight: 600; color: var(--muted); }
.progress { height: 6px; background: var(--line); border-radius: 99px; margin-top: 6px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--mint); }
.wizard-nav { display: flex; justify-content: space-between; gap: 12px; margin: 8px 0 24px; }
.wizard-nav .btn { min-width: 120px; }

/* nastavenia */
.settings { max-width: 760px; margin: 0 auto; }
.cost-row.custom { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.cost-row.custom .amount { flex: 1 1 140px; }
.segmented { display: inline-flex; border: 1px solid var(--field-border); border-radius: 10px; overflow: hidden; margin: 8px 0; flex-wrap: wrap; }
.segmented button {
  font: inherit; border: 0; background: var(--white); color: var(--ink); padding: 10px 16px; min-height: 44px; cursor: pointer;
}
.segmented button + button { border-left: 1px solid var(--field-border); }
.segmented button.on { background: var(--mint); color: var(--ink); font-weight: 700; }
.material { border: 1px solid var(--line); border-radius: 12px; padding: 4px 14px 10px; margin: 12px 0; background: #fbfdfd; scroll-margin-top: 140px; }
.material.focus { border: 2px solid var(--mint); box-shadow: 0 0 0 4px var(--mint-soft); background: var(--white); }
.material.new { border: 2px dashed var(--mint); background: var(--white); }
.material.new h3 { margin-top: 12px; }
.material-head { display: flex; gap: 10px; align-items: flex-start; }
.material-head .link { margin-top: 30px; }
.row.three > .field { flex: 1 1 150px; }
.per100 strong { min-height: var(--tap); display: flex; align-items: center; font-size: 1.05rem; }

/* kalkulačka */
.calc-layout { display: grid; grid-template-columns: 360px 1fr; gap: 16px; align-items: start; }
.catalog { position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow: auto; }
.search { margin-top: 6px; }
.cat-heading { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 0 6px; }
.cat-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; font: inherit; color: inherit;
  background: var(--white); border: 2px solid transparent; border-radius: 12px; padding: 6px; cursor: pointer; margin-bottom: 4px;
}
.cat-item:hover { background: var(--soft); }
.cat-item.selected { border-color: var(--mint); background: var(--mint-soft); }
.cat-item img { width: 72px; height: 72px; border-radius: 10px; object-fit: cover; flex: 0 0 72px; background: var(--soft); }
.cat-text { display: flex; flex-direction: column; min-width: 0; }
.cat-name { font-weight: 700; overflow-wrap: anywhere; }
.cat-meta { font-size: .82rem; color: var(--muted); }

.empty { color: var(--muted); text-align: center; padding: 48px 20px; }
.ed-head { display: flex; gap: 18px; align-items: flex-start; }
.ed-photo { display: flex; flex-direction: column; gap: 8px; align-items: stretch; flex: 0 0 150px; }
.ed-photo img { width: 150px; height: 150px; object-fit: cover; border-radius: 12px; background: var(--soft); }
.ed-title { flex: 1; min-width: 0; }
.unsaved { color: var(--mint-ink); font-weight: 700; }
.time-row > .field { flex: 1 1 140px; max-width: 220px; }
.editor, .result { scroll-margin-top: 120px; }
.line { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; border-bottom: 1px dashed var(--line); }
.line .grams { flex: 0 1 190px; }
.line-cost { min-width: 80px; text-align: right; font-weight: 700; margin-top: 44px; color: var(--ink-soft); }
.note { margin-top: 10px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 22px 0 8px; }

.result { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 16px; margin-top: 16px; }
.res-main {
  background: var(--ink); color: var(--white); border-radius: var(--radius); padding: 20px;
  display: flex; flex-direction: column; gap: 4px; justify-content: center;
}
.res-main .muted { color: rgba(255, 255, 255, .72); }
.res-label { font-size: .9rem; opacity: .85; }
.res-total { font-size: 2.4rem; font-weight: 800; line-height: 1.1; color: var(--mint); }
.res-rec { font-size: 1.1rem; margin-top: 6px; }
.res-rec strong { color: var(--mint); font-size: 1.3rem; }
.receipt {
  background: var(--white); border: 1px dashed #b7c8c6; border-radius: 6px; padding: 16px 18px;
  font-variant-numeric: tabular-nums;
}
.rc-head { font-size: .85rem; color: var(--muted); margin-bottom: 8px; }
.rc-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dotted var(--line); }
.rc-row span:last-child { white-space: nowrap; }
.rc-row.total { border-top: 3px solid var(--mint); border-bottom: 0; margin-top: 6px; padding-top: 10px; font-weight: 800; font-size: 1.1rem; }
.rc-row.total.neg { color: var(--danger); }
.custom { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 4px; }
.custom .field { max-width: 280px; }
.small-receipt { max-width: 460px; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: min(92vw, 520px); padding: 12px 18px; border-radius: 12px; background: var(--ink); color: var(--white);
  border-left: 6px solid var(--mint); font-weight: 600; box-shadow: 0 6px 24px rgba(0, 0, 0, .2);
  opacity: 0; pointer-events: none; z-index: 50;
}
.toast.show { opacity: 1; }
.toast.error { background: var(--danger); border-left-color: #8e1b1b; }

@media (max-width: 859px) {
  .calc-layout { grid-template-columns: 1fr; }
  .catalog { position: static; max-height: none; }
  .cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .cat-grid .cat-item { flex-direction: column; align-items: stretch; text-align: left; margin: 0; padding: 6px 6px 10px; border-color: var(--line); }
  .cat-grid .cat-item.selected { border-color: var(--mint); }
  .cat-grid .cat-item img { width: 100%; height: auto; aspect-ratio: 1; flex: none; }
  .cat-grid .cat-text { padding: 0 4px; }
  .result { grid-template-columns: 1fr; }
  .banner { top: 110px; }
}

@media (max-width: 520px) {
  .card { padding: 16px; }
  .app-name { display: none; }
  .topbar-inner { padding: 8px 12px; }
  .topbar-right { display: contents; }
  .lang { order: 1; }
  .tabs { order: 2; width: 100%; }
  .tabs button { padding: 8px 12px; flex: 1; }
  .banner { top: 104px; }
  .ed-head { flex-direction: column; }
  .ed-photo { flex-direction: row; align-items: center; flex: none; }
  .ed-photo img { width: 96px; height: 96px; }
  .actions .btn { flex: 1 1 calc(50% - 10px); }
  .res-total { font-size: 2rem; }
  .wizard-nav .btn { flex: 1; min-width: 0; }
  .time-row > .field { max-width: none; }
}
