@font-face { font-family: "Inter"; src: url("fonts/inter-var.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Oswald"; src: url("fonts/oswald-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
:root {
  --green: #5BAD55; --green-dark: #3F8A3A; --green-tint: #EEF7ED;
  --black: #111; --ink: #1d1d1d; --gray: #6b6f73; --gray-2: #a5a7a9; --line: #dcdfe2; --bg: #f4f5f6; --white: #fff;
  --warn: #B86E00; --warn-bg: #FFF3DC; --danger: #C62828;
  --r: 14px; --tap: 52px;
  --sa-t: env(safe-area-inset-top, 0px); --sa-b: env(safe-area-inset-bottom, 0px);
  --sa-l: env(safe-area-inset-left, 0px); --sa-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; scroll-padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
body { margin: 0; font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; font-size: 17px; line-height: 1.45;
  color: var(--ink); background: var(--bg); overflow-x: hidden; -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(76px + var(--sa-b)); }
h1, h2, .card-id, .tb-val, .detail-head h1 { font-family: Oswald, "Arial Narrow", Arial, sans-serif; font-weight: 700; letter-spacing: .01em; }
h1 { font-size: 30px; margin: 0; line-height: 1.1; }
h2 { font-size: 21px; margin: 0 0 10px; }
a { color: var(--green-dark); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--gray); }
.count { color: var(--gray); font-family: Inter, Arial, sans-serif; font-weight: 500; font-size: .55em; vertical-align: middle; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--black); color: #fff; padding: calc(8px + var(--sa-t)) calc(16px + var(--sa-r)) 8px calc(16px + var(--sa-l)); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; min-height: 48px; }
.brand img { height: 44px; width: auto; }
.brand span { font-family: Oswald, Arial, sans-serif; font-weight: 700; font-size: 24px; letter-spacing: .02em; }
.topbtn { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 16px; border-radius: 999px;
  background: var(--green); color: #000; font-weight: 700; text-decoration: none; }
.topbtn svg, .tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* bottom tabs */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, 1fr);
  background: #fff; border-top: 1px solid var(--line); padding: 4px calc(4px + var(--sa-r)) calc(4px + var(--sa-b)) calc(4px + var(--sa-l)); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 60px;
  color: var(--gray); text-decoration: none; font-size: 13px; font-weight: 600; border-radius: 12px; }
.tabbar a.active { color: var(--black); background: var(--green-tint); }
.tabbar a.active svg { stroke: var(--green-dark); }
.tabbar .tab-add svg { background: var(--green); color: #000; border-radius: 50%; padding: 3px; width: 30px; height: 30px; }

.update-bar { display: flex; gap: 12px; align-items: center; justify-content: center; background: var(--green-tint); padding: 8px 16px; font-weight: 600; }
.update-bar[hidden] { display: none; }

/* layout */
main { outline: none; }
.page { max-width: 1040px; margin: 0 auto; padding: 18px calc(16px + var(--sa-r)) 24px calc(16px + var(--sa-l)); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }

/* buttons */
.btn { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: var(--tap); padding: 10px 20px;
  border-radius: 12px; border: 2px solid transparent; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; text-align: center;
  color: var(--black); background: #fff; -webkit-appearance: none; appearance: none; }
.btn small { font-weight: 500; font-size: 13px; opacity: .8; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--green); border-color: var(--green); color: #000; }
.btn-primary:active { background: var(--green-dark); }
.btn-outline { border-color: var(--black); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-outline { border-color: var(--danger); color: var(--danger); background: #fff; }
.btn-big { min-height: 58px; font-size: 18px; }
.btn-small { min-height: 44px; padding: 6px 14px; font-size: 15px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.btn-row > .btn { flex: 1 1 160px; }
.btn-row.center { justify-content: center; }
.btn-col { display: flex; flex-direction: column; gap: 10px; }
.icon-btn { width: 48px; height: 48px; border: 0; background: transparent; font-size: 30px; line-height: 1; cursor: pointer; color: var(--gray); border-radius: 50%; flex: none; }
.linkbtn { background: none; border: 0; padding: 4px 0; font: inherit; font-weight: 700; color: var(--green-dark); text-decoration: underline; cursor: pointer; min-height: 44px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 100px; }
:focus-visible { outline: 3px solid var(--green-dark); outline-offset: 2px; }

/* filters */
.filters { display: grid; gap: 10px; margin-bottom: 14px; }
.search input { width: 100%; }
input, select, textarea { font: inherit; font-size: 17px; color: var(--ink); background: #fff; border: 2px solid var(--line); border-radius: 12px;
  min-height: var(--tap); padding: 10px 14px; width: 100%; max-width: 100%; -webkit-appearance: none; appearance: none; }
select { background-image: linear-gradient(45deg, transparent 50%, #333 50%), linear-gradient(135deg, #333 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
input[type=date] { min-width: 0; display: block; }
input:focus, select:focus, textarea:focus { border-color: var(--green); outline: none; box-shadow: 0 0 0 3px rgba(91,173,85,.25); }
.seg { display: flex; background: #e6e8ea; border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; min-height: 46px; border: 0; border-radius: 9px; background: transparent; font: inherit; font-weight: 700; color: var(--gray); cursor: pointer; }
.seg button[aria-pressed=true] { background: #fff; color: var(--black); box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.filter-selects { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.filter-selects label span { display: block; font-size: 14px; font-weight: 700; color: var(--gray); margin-bottom: 4px; }
.select-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: var(--green-tint); border: 2px solid var(--green); padding: 10px; border-radius: var(--r); margin-bottom: 12px; position: sticky; top: 72px; z-index: 5; }
.select-bar span { font-weight: 700; margin-right: auto; }

/* cards */
.cards { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .cards { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1000px) { .cards { grid-template-columns: 1fr 1fr 1fr; } }
.card { position: relative; background: #fff; border: 2px solid var(--line); border-radius: var(--r); display: flex; flex-direction: column; overflow: hidden; }
.card.is-selected { border-color: var(--green); box-shadow: 0 0 0 3px rgba(91,173,85,.3); }
.card.is-retired { opacity: .7; }
.card-main { display: block; padding: 14px 16px 10px; color: inherit; text-decoration: none; flex: 1; }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-id { font-size: 32px; line-height: 1; }
.card-spec { font-size: 19px; font-weight: 700; margin-top: 6px; }
.card-spec .dot { color: var(--gray-2); margin: 0 6px; }
.card-tension { margin-top: 6px; font-size: 16px; }
.card-log { margin: 0 12px 12px; }
.check { position: absolute; top: 12px; right: 12px; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--gray-2); display: grid; place-items: center; font-weight: 900; background: #fff; }
.is-selected .check { background: var(--green); border-color: var(--green); }
.card .check ~ .card-top { padding-right: 40px; }
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.chip.ok { background: var(--green-tint); color: #24601f; }
.chip.warn, .chip.low { background: var(--warn-bg); color: #7a4800; }
.chip.off { background: #eceeef; color: #555; }
.chip.big { font-size: 15px; padding: 6px 14px; }
.empty { text-align: center; padding: 40px 16px; background: #fff; border-radius: var(--r); border: 2px dashed var(--line); }
.lead { font-size: 19px; font-weight: 600; }
.empty-filter { text-align: center; padding: 24px; }
.device-note { text-align: center; color: var(--gray); font-size: 14px; margin-top: 24px; }

/* forms */
.form-page { max-width: 720px; }
.field { margin-bottom: 18px; }
.field > label, .field .label { display: block; font-weight: 700; margin-bottom: 6px; font-size: 17px; }
.field em { font-style: normal; font-weight: 500; color: var(--gray); font-size: 14px; margin-left: 4px; }
.unit { font-weight: 500; color: var(--gray); }
.hint { color: var(--gray); font-size: 14.5px; margin: 6px 0 0; }
.err { color: var(--danger); font-weight: 700; font-size: 15px; margin: 6px 0 0; }
.err:empty { display: none; }
.picks { display: grid; gap: 8px; }
.picks-2 { grid-template-columns: 1fr 1fr; }
.picks-3 { grid-template-columns: repeat(3, 1fr); }
.picks-mesh { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 420px) { .picks-3 { grid-template-columns: 1fr; } }
.pick { min-height: 56px; border: 2px solid var(--line); background: #fff; border-radius: 12px; font: inherit; font-weight: 700; font-size: 18px; cursor: pointer; color: var(--black); padding: 6px; }
.picks-2 .pick { min-height: 64px; font-size: 21px; }
.pick[aria-pressed=true] { background: var(--green); border-color: var(--green-dark); color: #000; box-shadow: inset 0 0 0 2px var(--green-dark); }
.other-mesh { margin-top: 10px; }
.other-mesh[hidden] { display: none; }
.other-mesh label { font-weight: 600; display: block; margin-bottom: 4px; }
details.more { background: #fff; border: 2px solid var(--line); border-radius: var(--r); padding: 4px 16px; margin-bottom: 18px; }
details.more summary { min-height: 52px; display: flex; align-items: center; font-weight: 700; cursor: pointer; }
details.more[open] { padding-bottom: 8px; }
.sticky-actions { position: sticky; bottom: calc(76px + var(--sa-b)); background: linear-gradient(transparent, var(--bg) 22%); padding-top: 18px; margin-top: 0; z-index: 4; }
.danger-zone { margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--line); }
.input-big { font-size: 30px; min-height: 66px; font-weight: 700; }
.inline { display: flex; gap: 10px; align-items: center; }
.inline input { flex: 1; min-width: 0; }
.inline .btn { flex: none; }

/* detail */
.back { display: inline-flex; align-items: center; min-height: 44px; font-weight: 700; text-decoration: none; margin-bottom: 4px; }
.detail-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.detail-head h1 { font-size: 46px; }
.detail-spec { font-size: 22px; font-weight: 700; margin: 4px 0 14px; }
.tension-box { background: #fff; border: 2px solid var(--line); border-left: 8px solid var(--green); border-radius: var(--r); padding: 14px 18px; display: grid; grid-template-columns: auto 1fr; align-items: baseline; column-gap: 14px; }
.tension-box.low { border-left-color: #E2A23B; background: var(--warn-bg); }
.tb-label { grid-column: 1 / -1; color: var(--gray); font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: .05em; }
.tb-val { font-size: 44px; line-height: 1.1; }
.tb-val small { font-size: 20px; font-family: Inter, Arial, sans-serif; color: var(--gray); }
.tb-date { color: var(--gray); font-weight: 600; }
.tb-none { font-size: 20px; font-weight: 700; color: var(--gray); grid-column: 1 / -1; }
.tb-warn { grid-column: 1 / -1; margin: 6px 0 0; font-weight: 700; color: #7a4800; }
.actions-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin: 16px 0 22px; }
@media (max-width: 520px) { .actions-grid { grid-template-columns: 1fr 1fr; } .actions-grid > :first-child { grid-column: 1 / -1; } }
.detail-cols { display: grid; gap: 22px; }
@media (min-width: 760px) { .detail-cols { grid-template-columns: 1fr 1fr; } }
.kvs { margin: 0; background: #fff; border: 2px solid var(--line); border-radius: var(--r); }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv dt { color: var(--gray); font-weight: 600; }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.history { list-style: none; margin: 0; padding: 0; background: #fff; border: 2px solid var(--line); border-radius: var(--r); }
.history li { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 4px 12px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--line); }
.history li:last-child { border-bottom: 0; }
.h-val { font-weight: 800; font-size: 19px; }
.h-date { color: var(--gray); font-weight: 600; }
.h-note { grid-column: 1 / 3; grid-row: 2; color: var(--gray); font-size: 15px; }
.h-del { grid-row: 1 / span 2; grid-column: 3; }

/* modal */
.modal-open { overflow: hidden; }
.modal-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 640px) { .modal-wrap { align-items: center; padding: 20px; } }
.modal { background: #fff; width: 100%; max-width: 560px; max-height: 92vh; max-height: 92dvh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 6px 18px calc(18px + var(--sa-b)); }
@media (min-width: 640px) { .modal { border-radius: 20px; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; position: sticky; top: 0; background: #fff; padding-top: 10px; z-index: 1; }
.modal-head h2 { margin: 0; font-size: 24px; }
.label-tabs { margin: 8px 0 12px; }
.label-tabs button { font-size: 15px; }
.tape-previews { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; background: #f0f1f2; border-radius: 12px; padding: 12px; margin-top: 10px; overflow-x: auto; }
.tape-previews img { max-width: 100%; height: auto; border: 1px solid #ccc; image-rendering: pixelated; background: #fff; }
.label-preview { background: #f0f1f2; border-radius: 12px; padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 6px; overflow: hidden; }
.label-preview .slabel { box-shadow: 0 1px 4px rgba(0,0,0,.25); transform: scale(1.5); transform-origin: center; margin: 0.3in 0; }
@media (max-width: 400px) { .label-preview .slabel { transform: scale(1.2); margin: 0.12in 0; } }

/* scan */
.scan-page { max-width: 720px; }
.scan-box { position: relative; background: #000; border-radius: var(--r); overflow: hidden; aspect-ratio: 4 / 3; max-height: 60vh; width: 100%; }
.scan-box video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; inset: 18% 22%; border: 4px solid var(--green); border-radius: 16px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }
.scan-msg { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 14px; color: #fff; background: rgba(0,0,0,.65); font-weight: 600; text-align: center; }
.type-id { margin-top: 22px; background: #fff; border: 2px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.type-id label { display: block; font-weight: 700; margin-bottom: 8px; }

/* settings */
.settings { max-width: 720px; }
.panel { background: #fff; border: 2px solid var(--line); border-radius: var(--r); padding: 16px 18px; margin-bottom: 16px; }
.panel .field { margin: 12px 0 0; }
.callout { background: var(--green-tint); border-left: 6px solid var(--green); padding: 12px 14px; border-radius: 8px; margin-top: 0; }
.steps { padding-left: 22px; margin: 0; }
.steps li { margin-bottom: 6px; }

.toast { position: fixed; left: 50%; bottom: calc(90px + var(--sa-b)); transform: translate(-50%, 20px); background: var(--black); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60; max-width: calc(100% - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- labels (screen preview + print) ---------- */
.slabel { width: 2in; height: 1in; background: #fff; color: #000; display: flex; align-items: center; gap: 0.06in; padding: 0.06in 0.08in 0.06in 0.05in; overflow: hidden; font-family: Inter, Arial, sans-serif; }
.label-qr { width: 0.88in; height: 0.88in; flex: none; }
.label-qr svg { width: 100%; height: 100%; display: block; }
.label-text { min-width: 0; display: flex; flex-direction: column; justify-content: center; line-height: 1.05; }
.label-id { font-family: Oswald, "Arial Narrow", Arial, sans-serif; font-weight: 700; font-size: 26pt; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: clip; }
.label-spec { font-weight: 800; font-size: 10.5pt; margin-top: 2pt; white-space: nowrap; }
.label-id.id-l { font-size: 17pt; }
.label-id.id-xl { font-size: 11pt; }
.label-shop { font-size: 6pt; margin-top: 3pt; color: #333; white-space: nowrap; }
.slabel-2_25x1_25 { width: 2.25in; height: 1.25in; }
.slabel-2_25x1_25 .label-qr { width: 1.1in; height: 1.1in; }
.slabel-2_25x1_25 .label-id { font-size: 30pt; }
.slabel-2_25x1_25 .label-spec { font-size: 12pt; }
.slabel-2_25x1_25 .label-id.id-l { font-size: 20pt; }
.slabel-2_25x1_25 .label-id.id-xl { font-size: 13pt; }
.slabel-2_25x1_25 .label-shop { font-size: 6.5pt; }
#print-area { display: none; }
@media print {
  body.printing-labels { background: #fff; padding: 0; margin: 0; }
  body.printing-labels > *:not(#print-area) { display: none !important; }
  body.printing-labels #print-area { display: block; }
  #print-area .slabel { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-roll .slabel { break-after: page; page-break-after: always; }
  .print-roll .slabel:last-child { break-after: auto; page-break-after: auto; }
  .print-sheet .sheet-grid { display: flex; flex-wrap: wrap; gap: 0.12in; }
  .print-sheet .slabel { outline: 1px dashed #999; break-inside: avoid; page-break-inside: avoid; }
}
