/* Mprint árkalkulátor - layout.
   Scale: 4/8/12/16/24 px spacing, 12/13/14/16/20 px type. One accent colour, status colours only for meaning. */
:root {
  --bg: #f2f4f7; --panel: #ffffff; --ink: #1b2430; --ink2: #334155; --muted: #64748b; --line: #d9e0e7; --line2: #edf1f5;
  --accent: #1f4e79; --accent-ink: #ffffff; --accent-soft: #e7eef6; --accent-line: #b9cde2;
  --ok: #15803d; --ok-soft: #e4f4e9; --warn: #a14a05; --warn-soft: #fff4e0; --bad: #b42318; --bad-soft: #fdecea;
  --radius: 8px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.06);
  --topbar-h: 56px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
html { scroll-padding-top: calc(var(--topbar-h) + 48px); scroll-padding-bottom: 90px; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
h1 { font-size: 20px; line-height: 1.3; margin: 0; }
h2 { font-size: 16px; margin: 0 0 8px; }
h3 { font-size: 13px; margin: 16px 0 8px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; }
h3:first-child { margin-top: 0; }
.boot { padding: 40px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.spacer { flex: 1; }

/* ---------------------------------------------------------------- top bar */
.topbar { background: var(--accent); color: var(--accent-ink); position: sticky; top: 0; z-index: 30; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.topbar-in { max-width: 1440px; margin: 0 auto; display: flex; align-items: center; gap: 20px; padding: 0 20px; min-height: var(--topbar-h); }
.topbar .brand { font-weight: 800; font-size: 18px; letter-spacing: .3px; white-space: nowrap; color: var(--accent-ink); text-decoration: none; }
.topbar .brand small { font-weight: 400; opacity: .75; font-size: 13px; margin-left: 6px; }
.topbar nav { display: flex; gap: 2px; flex: 1; min-width: 0; }
.topbar nav a { color: var(--accent-ink); text-decoration: none; padding: 8px 10px; border-radius: 6px; opacity: .82; white-space: nowrap; font-size: 14px; }
.topbar nav a:hover { background: rgba(255,255,255,.12); opacity: 1; }
.topbar nav a.active { background: rgba(255,255,255,.2); opacity: 1; font-weight: 600; }
.topbar nav a.cta { background: #fff; color: var(--accent); opacity: 1; font-weight: 700; margin-right: 6px; }
.topbar .who { display: flex; gap: 8px; align-items: center; font-size: 13px; white-space: nowrap; }
.topbar .who .role { opacity: .75; }
.topbar .who button { background: transparent; color: var(--accent-ink); border: 1px solid rgba(255,255,255,.45); min-height: 30px; padding: 3px 10px; }
.topbar .who button:hover { background: rgba(255,255,255,.12); }

/* ---------------------------------------------------------------- page */
.main { max-width: 1440px; margin: 0 auto; padding: 20px; }
.pagehead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.pagehead .sub { color: var(--muted); font-size: 13px; }
.pagehead .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.intro { color: var(--muted); font-size: 13px; margin: -6px 0 14px; max-width: 900px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.panel.flush { padding: 0; }
.panel.flush table.t thead th:first-child { border-top-left-radius: var(--radius); }
.panel.flush table.t thead th:last-child { border-top-right-radius: var(--radius); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin-bottom: 12px; box-shadow: var(--shadow); }
.toolbar .grow { flex: 1 1 260px; min-width: 0; }
.toolbar .count { margin-left: auto; color: var(--muted); font-size: 13px; white-space: nowrap; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > .grow { flex: 1; min-width: 180px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px; }
.formsec + .formsec { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line2); }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.empty strong { display: block; color: var(--ink2); font-size: 15px; margin-bottom: 6px; }
.empty button { margin-top: 12px; }

/* ---------------------------------------------------------------- forms */
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); min-width: 0; }
label.f > span { font-weight: 600; color: var(--ink2); }
label.chk { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--ink2); cursor: pointer; }
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid #c5ced8; border-radius: 6px; padding: 6px 9px; min-height: 36px; max-width: 100%; }
input[type=checkbox] { min-height: 0; width: 16px; height: 16px; accent-color: var(--accent); }
textarea { min-height: 64px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #a8c5e6; outline-offset: 0; border-color: var(--accent); }
input:disabled, select:disabled, textarea:disabled { background: #f4f6f8; color: var(--muted); }
input.num { text-align: right; width: 104px; }
input[readonly] { background: #f4f6f8; }
button { font: inherit; border: 1px solid #c5ced8; background: #fff; color: var(--ink); padding: 6px 14px; border-radius: 6px; cursor: pointer; min-height: 36px; white-space: nowrap; }
button:hover { background: #f3f6f9; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.primary:hover { filter: brightness(1.1); background: var(--accent); }
button.big { min-height: 42px; padding: 8px 22px; font-size: 15px; }
button.danger { color: var(--bad); border-color: #e9b8b2; }
button.danger:hover { background: var(--bad-soft); }
button.link { border: 0; background: none; color: var(--accent); padding: 4px 2px; min-height: 0; font-weight: 600; }
button.link:hover { text-decoration: underline; background: none; }
button.icon { padding: 2px 9px; min-height: 30px; }
button:disabled { opacity: .45; cursor: default; }

/* ---------------------------------------------------------------- tables */
.tablewrap { overflow-x: auto; }
@media (min-width: 900px) { .tablewrap.sticky { overflow: visible; } }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; background: #fff; }
table.t th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 700; border-bottom: 1px solid var(--line); padding: 9px 10px; background: #f7f9fb; white-space: nowrap; }
.tablewrap.sticky table.t thead th { position: sticky; top: var(--topbar-h); z-index: 5; }
table.t td { border-bottom: 1px solid var(--line2); padding: 8px 10px; vertical-align: top; }
table.t tbody tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #f4f8fc; }
table.t tr.inactive td { color: #9aa5b1; }
table.t td.num, table.t th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.t tr.cat td { background: var(--accent-soft); font-weight: 700; font-size: 12px; color: var(--accent); padding: 6px 10px; border-bottom: 1px solid var(--accent-line); letter-spacing: .2px; }
table.t tr.cat td .n { font-weight: 400; color: var(--muted); margin-left: 6px; }
.t .name { font-weight: 600; color: var(--ink); }
.t .code { font-size: 12px; color: var(--muted); }
.w-type { width: 190px; } .w-name { width: 22%; } .w-desc { width: 26%; } .w-size { width: 12%; } .w-unit { width: 48px; } .w-money { width: 92px; } .w-pct { width: 56px; } .w-stock { width: 96px; } .w-sup { width: 96px; }

/* ---------------------------------------------------------------- badges */
.badge { display: inline-block; font-size: 11px; line-height: 18px; padding: 0 8px; border-radius: 10px; background: var(--line2); color: var(--muted); white-space: nowrap; font-weight: 600; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.blue { background: var(--accent-soft); color: var(--accent); }
.badges { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.st-piszkozat { background: var(--line2); color: var(--muted); }
.st-elkuldve { background: var(--accent-soft); color: var(--accent); }
.st-elfogadva { background: var(--ok-soft); color: var(--ok); }
.st-elutasitva { background: var(--bad-soft); color: var(--bad); }
.st-lezarva { background: #e9edf1; color: #475569; }
.noprice { color: var(--bad); font-weight: 700; font-size: 12px; white-space: nowrap; }

/* ---------------------------------------------------------------- quote editor */
.qhead .qsec { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px 28px; }
.qhead .notes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin-top: 14px; }
.line { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; margin-bottom: 16px; box-shadow: var(--shadow); }
.line > .lh { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #f7f9fb; border-radius: var(--radius) var(--radius) 0 0; flex-wrap: wrap; }
.line > .lh .no { font-weight: 800; color: #fff; background: var(--accent); border-radius: 50%; width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; flex: none; }
.line > .lh .prod { flex: 1 1 300px; min-width: 0; font-weight: 600; }
.line > .lh .ttl { flex: 1 1 260px; min-width: 0; }
.line > .lh .tools { display: flex; gap: 4px; }
.line > .lb { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); gap: 0; }
.line > .lb > .cfg { padding: 14px 16px; min-width: 0; }
.line > .lb > .price { padding: 14px 16px; border-left: 1px solid var(--line2); background: #fafbfc; border-radius: 0 0 var(--radius) 0; min-width: 0; }
.line > .lb > .price > .sticky { position: sticky; top: calc(var(--topbar-h) + 12px); }
.line .pdesc { color: var(--muted); font-size: 12px; margin: -4px 0 10px; }
.block { border: 1px solid var(--line2); border-radius: 6px; padding: 10px 12px; margin-bottom: 12px; }
.block > h3 { margin: 0 0 8px; }
table.sizes { width: auto; }
table.sizes th { background: transparent; padding: 4px 6px; border-bottom: 1px solid var(--line); }
table.sizes td { padding: 4px 6px; border-bottom: 0; vertical-align: middle; }
table.sizes input { width: 92px; }
table.sizes td.unit { font-weight: 700; min-width: 86px; }
.opts { display: flex; flex-direction: column; }
.opt { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 4px 12px; align-items: start; padding: 7px 0; border-bottom: 1px solid var(--line2); }
.opt:last-child { border-bottom: 0; }
.opt > .ol { font-size: 13px; font-weight: 600; color: var(--ink2); padding-top: 7px; }
.opt.sub > .ol { padding-left: 14px; }
.opt .ctl { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.opt .ctl select { flex: 1 1 260px; min-width: 0; }
.opt .fixed { padding-top: 7px; }
.opt .waste { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.opt .waste select { flex: 0 1 260px; font-size: 13px; min-height: 32px; }
.opt .waste input { width: 86px; min-height: 32px; }
.grouphead { font-size: 12px; font-weight: 700; color: var(--accent); margin-top: 10px; padding: 6px 8px; background: var(--accent-soft); border-radius: 4px; }
.grouphead:first-child { margin-top: 0; }
.linefoot { display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 12px 16px; align-items: end; }
.result .big { font-size: 26px; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }
.result .netlbl { font-size: 12px; color: var(--muted); }
.result .kv { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; font-size: 13px; margin: 10px 0; padding: 8px 0; border-top: 1px solid var(--line2); border-bottom: 1px solid var(--line2); }
.result .kv .v { text-align: right; font-variant-numeric: tabular-nums; }
.result .kv .v.strong { font-weight: 700; }
.result table.bd { width: 100%; border-collapse: collapse; font-size: 12px; }
.result table.bd th { text-align: left; color: var(--muted); font-weight: 600; padding: 3px 4px; border-bottom: 1px solid var(--line); }
.result table.bd td { padding: 4px; border-bottom: 1px solid var(--line2); vertical-align: top; }
.result table.bd td.num, .result table.bd th.num { text-align: right; white-space: nowrap; }
.result table.bd tr.grp td { font-weight: 700; background: #f0f4f8; }
.warnings { margin: 8px 0; padding: 0; list-style: none; }
.warnings li { background: var(--warn-soft); color: var(--warn); padding: 5px 8px; border-radius: 4px; margin-bottom: 4px; font-size: 12px; border-left: 3px solid var(--warn); }
.breakdown summary { cursor: pointer; color: var(--accent); font-size: 12px; font-weight: 600; margin: 6px 0; }
.addline { display: flex; justify-content: center; padding: 14px; border: 2px dashed var(--line); border-radius: var(--radius); margin-bottom: 16px; }
.metaline { color: var(--muted); font-size: 12px; margin-bottom: 90px; }
.totalsbar { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -4px 12px rgba(0,0,0,.07); z-index: 20; }
.totalsbar-in { max-width: 1440px; margin: 0 auto; padding: 10px 20px; display: flex; gap: 10px; align-items: center; }
.tot { padding: 4px 16px; border-right: 1px solid var(--line2); }
.tot:first-child { padding-left: 0; }
.tot .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 700; }
.tot .v { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tot.gross .v { color: var(--accent); font-size: 23px; font-weight: 800; }
.tot.margin .v { font-size: 15px; color: var(--ok); }
.tot.margin { border-right: 0; }

/* ---------------------------------------------------------------- modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: flex-start; justify-content: center; padding: 32px 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 760px; box-shadow: 0 20px 50px rgba(0,0,0,.25); display: flex; flex-direction: column; }
.modal.wide { max-width: 1180px; }
.modal .mh { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.modal .mh h2 { margin: 0; flex: 1; font-size: 17px; }
.modal .mh .x { border: 0; font-size: 22px; line-height: 1; padding: 0 6px; min-height: 0; color: var(--muted); background: none; }
.modal .mb { padding: 16px 20px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 20px; border-top: 1px solid var(--line); background: #f7f9fb; border-radius: 0 0 10px 10px; position: sticky; bottom: 0; flex-wrap: wrap; }

/* ---------------------------------------------------------------- login, toast */
.login { max-width: 380px; margin: 12vh auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 28px; box-shadow: var(--shadow); }
.login .brand { font-size: 30px; font-weight: 800; color: var(--accent); }
.login form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.err { color: var(--bad); background: var(--bad-soft); padding: 8px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 12px; }
.toast { position: fixed; right: 16px; bottom: 90px; background: #1b2430; color: #fff; padding: 10px 14px; border-radius: 8px; z-index: 100; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 420px; }
.toast.bad { background: var(--bad); }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1180px) {
  .topbar-in { flex-wrap: wrap; gap: 0 12px; padding: 6px 16px 0; }
  .topbar nav { order: 3; flex-basis: 100%; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
  .topbar .who { margin-left: auto; }
  :root { --topbar-h: 96px; }
  .line > .lb { grid-template-columns: minmax(0, 1fr) 340px; }
}
@media (max-width: 900px) {
  .line > .lb { grid-template-columns: minmax(0, 1fr); }
  .line > .lb > .price { border-left: 0; border-top: 1px solid var(--line2); border-radius: 0 0 var(--radius) var(--radius); }
  .line > .lb > .price > .sticky { position: static; }
  .qhead .qsec, .qhead .notes { grid-template-columns: 1fr; }
  .hide-md { display: none; }
}
@media (max-width: 640px) {
  :root { --topbar-h: 92px; }
  .main { padding: 12px 12px; }
  .topbar-in { padding: 6px 12px 0; }
  .topbar .brand small, .topbar .who .uname { display: none; }
  .hide-sm { display: none; }
  .grid3 { grid-template-columns: 1fr; }
  .panel { padding: 12px; }
  .opt { grid-template-columns: minmax(0, 1fr); padding: 6px 0; }
  .opt .ctl select, .opt .waste select { flex: 1 1 100%; width: 100%; }
  .opt > .ol { padding-top: 0; }
  .opt.sub > .ol { padding-left: 0; }
  .line > .lh { padding: 8px 10px; gap: 6px; }
  .line > .lh .prod, .line > .lh .ttl { flex-basis: 100%; }
  .line > .lh .tools { margin-left: auto; }
  .line > .lb > .cfg, .line > .lb > .price { padding: 12px; }
  table.sizes input { width: 64px; padding: 6px; }
  table.sizes td.unit { min-width: 0; font-size: 12px; }
  .linefoot { grid-template-columns: 1fr 1fr; }
  .linefoot > :last-child { grid-column: 1 / -1; }
  .totalsbar-in { padding: 8px 12px; gap: 6px; flex-wrap: wrap; }
  .tot { padding: 0 8px; }
  .tot .v { font-size: 14px; }
  .tot.gross .v { font-size: 17px; }
  .tot.margin { display: none; }
  .totalsbar button.primary { margin-left: auto; }
  .metaline { margin-bottom: 80px; }
  .modal-bg { padding: 0; }
  .modal { border-radius: 0; min-height: 100%; }
  .modal .mb { padding: 12px; }
  .toolbar .count { margin-left: 0; }
  table.t th, table.t td { padding: 7px 8px; }
}
@media (min-width: 641px) {
  table.t.recipe { table-layout: fixed; }
  table.t.recipe th:nth-child(1) { width: 22%; } table.t.recipe th:nth-child(2) { width: 38%; }
  table.t.recipe th:nth-child(3) { width: 16%; } table.t.recipe th:nth-child(4) { width: 14%; } table.t.recipe th:nth-child(5) { width: 10%; }
}
/* recipe item editor: compact controls so 11 columns fit the wide dialog */
table.t.items td, table.t.items th { padding: 5px 4px; }
table.t.items select, table.t.items input { font-size: 13px; min-height: 32px; padding: 4px 6px; width: 100%; }
table.t.items input[type=checkbox] { width: 16px; }
table.t.items th:nth-child(1) { width: 96px; } table.t.items th:nth-child(2) { width: 130px; } table.t.items th:nth-child(3) { width: 150px; }
table.t.items th:nth-child(5) { width: 136px; } table.t.items th:nth-child(6) { width: 64px; } table.t.items th:nth-child(7) { width: 140px; }
table.t.items th:nth-child(8) { width: 60px; } table.t.items th:nth-child(9), table.t.items th:nth-child(10) { width: 58px; white-space: normal; } table.t.items th:nth-child(11) { width: 72px; }
.modal .mb .intro { margin: 10px 0 0; }
/* phones: each size row becomes a small card - qty / width / height on one line, extra quantity + unit price below */
@media (max-width: 640px) {
  .block .tablewrap:has(table.sizes) { overflow: visible; }
  table.sizes, table.sizes tbody { display: block; width: 100%; }
  table.sizes thead { display: none; }
  table.sizes tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 8px; padding: 8px 0; border-bottom: 1px solid var(--line2); position: relative; }
  table.sizes td { display: flex; flex-direction: column; gap: 2px; padding: 0; min-width: 0; }
  table.sizes td::before { content: attr(data-label); font-size: 11px; font-weight: 600; color: var(--muted); }
  table.sizes td.del::before { content: none; }
  table.sizes input, table.sizes input.num { width: 100%; }
  table.sizes td.man { grid-column: span 2; }
  table.sizes td.unit { grid-column: 3; text-align: right; font-size: 15px; justify-content: flex-end; }
  table.sizes td.del { grid-column: 1; justify-content: flex-end; align-items: flex-start; }
  table.sizes td.del:empty { display: none; }
}
