:root {
  --indigo: #2a3189; --indigo-d: #1d2366; --blue: #0050a0; --blue-l: #e6eef8;
  --bg: #f2f4f9; --card: #ffffff; --ink: #1b1e24; --muted: #5f6670; --line: #d7dce6;
  --ok: #2e7d32; --warn: #ef8f00; --bad: #b71c1c;
  --radius: 12px; --shadow: 0 1px 2px rgba(20,25,60,.06), 0 2px 8px rgba(20,25,60,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 17px; line-height: 1.4; color: var(--ink); background: var(--bg); -webkit-tap-highlight-color: transparent; }
a { color: var(--blue); }
h1 { font-size: 1.45rem; margin: .2rem 0 .3rem; color: var(--indigo); }
h2 { font-size: 1.15rem; margin: 1.2rem 0 .5rem; color: var(--indigo); }
h3 { font-size: 1rem; margin: .8rem 0 .4rem; color: var(--indigo); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 14px; padding-top: max(8px, env(safe-area-inset-top)); background: var(--indigo); color: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 600; font-size: 1.05rem; min-width: 0; }
.brand img { height: 34px; background: #fff; border-radius: 6px; padding: 2px 4px; }
.brand span { white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn { display: inline-flex; width: 44px; height: 44px; align-items: center; justify-content: center; border-radius: 10px; color: #fff; }
.icon-btn svg { width: 26px; height: 26px; fill: currentColor; }
.icon-btn:active { background: rgba(255,255,255,.15); }
.sync-chip { border: 0; border-radius: 999px; padding: 7px 12px; font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; background: rgba(255,255,255,.15); color: #fff; white-space: nowrap; }
.sync-chip.offline { background: #6b6f80; }
.sync-chip.pending { background: var(--warn); }
.sync-chip.ok { background: rgba(46,125,50,.9); }
.sync-chip.err { background: var(--bad); }
.banner { background: #fff3cd; color: #6a4b00; padding: 10px 16px; font-size: .9rem; border-bottom: 1px solid #f0d58a; }
.banner button { margin-left: 8px; }

main { max-width: 980px; margin: 0 auto; padding: 14px 14px 110px; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 2px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin: 10px 0; }
.card.tight { padding: 0; overflow: hidden; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.row-link { display: flex; align-items: center; gap: 12px; padding: 13px 16px; color: inherit; text-decoration: none; min-height: 56px; }
.row-link:active { background: var(--blue-l); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; }
.row-sub { font-size: .85rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.chev { color: #9aa1ad; font-size: 1.4rem; }
.group-h { background: #eef1f8; padding: 7px 16px; font-size: .82rem; font-weight: 700; color: var(--indigo); text-transform: uppercase; letter-spacing: .03em; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 18px; border-radius: 10px; border: 1.5px solid var(--indigo); background: #fff; color: var(--indigo); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--indigo); color: #fff; }
.btn.blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.small { min-height: 38px; padding: 6px 12px; font-size: .9rem; }
.btn:disabled { opacity: .5; cursor: default; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.btn-row.end { justify-content: flex-end; }
.fab { position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 15; display: inline-flex; align-items: center; gap: 10px; padding: 16px 22px; border-radius: 999px; background: var(--blue); color: #fff; font-weight: 700; text-decoration: none; box-shadow: 0 6px 18px rgba(0,40,120,.35); border: 0; font-size: 1rem; }
.fab svg { width: 24px; height: 24px; fill: #fff; }

label.f { display: block; margin: 10px 0; }
label.f > span { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input[type=search], input[type=tel], input:not([type]), select, textarea {
  width: 100%; font: inherit; padding: 11px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); min-height: 48px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,80,160,.15); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 10px; }
@media (max-width: 620px) { .grid2, .grid3 { grid-template-columns: 1fr; } .grid4 { grid-template-columns: 1fr 1fr; } }
.check { display: flex; align-items: center; gap: 10px; margin: 10px 0; font-weight: 600; }
.check input { width: 24px; height: 24px; }
.seg { display: inline-flex; border: 1.5px solid var(--indigo); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: #fff; color: var(--indigo); font: inherit; font-weight: 600; padding: 10px 18px; min-height: 46px; cursor: pointer; }
.seg button.on { background: var(--indigo); color: #fff; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin: 12px 0 0; }
.tabs a { padding: 10px 16px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs a.on { color: var(--indigo); border-color: var(--indigo); }

.temp-input { font-size: 1.6rem !important; font-weight: 700; text-align: center; padding: 8px !important; }
.unit-wrap { position: relative; }
.unit-wrap::after { content: "\00B0" "C"; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; pointer-events: none; }

.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; color: #fff; white-space: nowrap; }
.chip.grey { background: #e3e6ee; color: var(--muted); }
.chip.outline { background: transparent; border: 1.5px solid var(--line); color: var(--muted); }
.type-ic { width: 38px; height: 38px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: .75rem; flex: none; }
.type-ic.iso { background: #fff1d6; color: #9a5b00; }
.type-ic.gbx { background: #e2ecff; color: #0b4aa2; }

.result { border-radius: var(--radius); padding: 14px 16px; color: #fff; margin: 12px 0; }
.result .big { font-size: 1.5rem; font-weight: 800; letter-spacing: .02em; }
.result ul { margin: 6px 0 0; padding-left: 20px; font-size: .92rem; }
.result.none { background: #e3e6ee; color: var(--muted); }
.prev-box { background: var(--blue-l); border-radius: 10px; padding: 10px 14px; font-size: .92rem; }

.photos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 620px) { .photos { grid-template-columns: 1fr; } }
.photo-slot { border: 2px dashed var(--line); border-radius: var(--radius); padding: 10px; text-align: center; background: #fafbfd; }
.photo-slot h4 { margin: 0 0 6px; color: var(--indigo); font-size: .9rem; }
.photo-slot img { width: 100%; max-height: 260px; object-fit: contain; border-radius: 8px; background: #111; }
.photo-slot .ph-empty { padding: 26px 0; color: var(--muted); font-size: .9rem; }
.photo-slot .btn-row { justify-content: center; margin: 8px 0 0; }
.photo-status { font-size: .75rem; color: var(--muted); margin-top: 4px; }

.progress { height: 10px; background: #e3e6ee; border-radius: 999px; overflow: hidden; margin: 8px 0; }
.progress > div { height: 100%; background: var(--ok); }
.stats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 4px 12px; font-size: .95rem; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th { text-align: left; background: #eef1f8; color: var(--indigo); padding: 7px 8px; font-size: .8rem; }
table.data td { padding: 7px 8px; border-top: 1px solid var(--line); }
.empty { text-align: center; color: var(--muted); padding: 24px 12px; }
.search { margin: 8px 0; }
.saved-ind { font-size: .8rem; color: var(--ok); font-weight: 600; min-height: 1.2em; }

.toast { position: fixed; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #1b1e24; color: #fff; padding: 12px 20px; border-radius: 10px; z-index: 50; font-size: .95rem; max-width: 90vw; box-shadow: 0 6px 20px rgba(0,0,0,.3); }
.toast.err { background: var(--bad); }

.login-wrap { max-width: 420px; margin: 7vh auto 0; }
.login-wrap .logo { display: block; width: 240px; margin: 0 auto 10px; }

.scan-wrap { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 3/4; max-height: 70vh; margin: 0 auto; }
.scan-wrap video { width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; inset: 18%; border: 3px solid rgba(255,255,255,.9); border-radius: 18px; box-shadow: 0 0 0 9999px rgba(0,0,0,.35); }

.qr-preview { display: flex; gap: 16px; align-items: center; }
.qr-preview svg { width: 120px; height: 120px; }
.label-pick { max-height: 50vh; overflow: auto; }
.label-pick .check { margin: 0; padding: 8px 12px; border-top: 1px solid var(--line); font-weight: 400; }

.thr-table td, .thr-table th { padding: 4px 6px; }
.thr-table input { min-height: 40px; padding: 6px 8px; text-align: center; }

/* ---------- print (labels) ---------- */
.print-area { display: none; }
@media print {
  body > *:not(.print-area) { display: none !important; }
  .print-area { display: block !important; }
  body { background: #fff; }
}
.lbl { overflow: hidden; page-break-after: always; break-after: page; display: flex; align-items: center; font-family: Arial, Helvetica, sans-serif; color: #000; background: #fff; }
.lbl:last-child { page-break-after: auto; break-after: auto; }
.lbl svg { display: block; }
.lbl .lt { flex: 1; min-width: 0; overflow: hidden; }
.lbl .lt img { display: block; }
.lbl .ref { font-weight: 800; line-height: 1.05; white-space: nowrap; }
.lbl .typ { font-weight: 700; text-transform: uppercase; line-height: 1.1; }
.lbl .loc { line-height: 1.15; overflow: hidden; }
@media (max-width: 520px) { .brand span { display: none; } .sync-chip { font-size: .72rem; padding: 6px 9px; } }
