/* ============================================================
   Asset Ledger — IT Inventory
   Visual direction: "inventory tag / scanner control room"
   Signature: asset cards rendered as physical tags with a
   barcode rail + monospace serials; animated scan line.
   Offline-safe system font stack (no font fetches).
   ============================================================ */

:root {
  /* type */
  --ui: "Segoe UI", Roboto, "Samsung One", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", "Roboto Mono", ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace;

  /* dark theme (default) */
  --bg: #0E1116;
  --bg-grad: radial-gradient(1200px 600px at 100% -10%, #12303033 0%, transparent 55%);
  --surface: #161B22;
  --surface-2: #1C232C;
  --surface-3: #232C37;
  --line: #2A323D;
  --line-soft: #20272F;
  --text: #E7ECF2;
  --muted: #8A97A6;
  --faint: #5C6675;
  --primary: #19C2B0;
  --primary-ink: #04221F;
  --primary-soft: #19c2b01f;
  --amber: #F5A623;
  --danger: #FF6363;
  --req: #FF5A5F;
  --success: #41D392;
  --shadow: 0 8px 28px -12px #00000080;
  --radius: 16px;
  --radius-sm: 11px;
  --tap: 44px;
}

[data-theme="light"] {
  --bg: #EEF1F5;
  --bg-grad: radial-gradient(1000px 520px at 100% -10%, #19c2b015 0%, transparent 55%);
  --surface: #FFFFFF;
  --surface-2: #F6F8FA;
  --surface-3: #EEF2F6;
  --line: #DCE2E9;
  --line-soft: #E7ECF1;
  --text: #10151B;
  --muted: #5A6573;
  --faint: #93A0AE;
  --primary: #0E9C8D;
  --primary-ink: #FFFFFF;
  --primary-soft: #0e9c8d14;
  --amber: #C77B05;
  --danger: #D63B3B;
  --req: #C62828;
  --success: #18A56B;
  --shadow: 0 10px 26px -16px #1a2a3855;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--ui);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100dvh;
  padding-top: calc(56px + env(safe-area-inset-top));
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
  transition: background-color .25s ease, color .25s ease;
}

::selection { background: var(--primary); color: var(--primary-ink); }

/* ---------- App bar ---------- */
.appbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  height: calc(56px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 14px 0;
  display: flex; align-items: center; justify-content: space-between;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid var(--line-soft);
}
.appbar__lead { display: flex; align-items: center; gap: 8px; min-width: 0; }
.appbar__actions { display: flex; align-items: center; gap: 4px; }

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand__mark {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  background: var(--primary);
  position: relative;
  box-shadow: inset 0 0 0 2px var(--bg), 0 0 0 1px var(--primary);
}
.brand__mark::before {
  content: ""; position: absolute; inset: 7px 6px;
  background-image: repeating-linear-gradient(90deg, var(--bg) 0 1.5px, transparent 1.5px 3px);
  border-radius: 1px;
}
.brand__name {
  font-weight: 700; font-size: 1.02rem; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.iconbtn {
  width: var(--tap); height: var(--tap); flex: none;
  display: grid; place-items: center;
  background: transparent; border: none; border-radius: 12px;
  color: var(--text); cursor: pointer; padding: 0;
  transition: background-color .15s ease;
}
.iconbtn:hover { background: var(--surface-2); }
.iconbtn:active { background: var(--surface-3); }
.iconbtn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.ico-sun { display: none; }
[data-theme="light"] .ico-moon { display: none; }
[data-theme="light"] .ico-sun { display: block; }

.net-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 25%, transparent);
  margin: 0 6px 0 2px;
}
.net-dot.off { background: var(--faint); box-shadow: 0 0 0 3px color-mix(in srgb, var(--faint) 25%, transparent); }

/* ---------- Layout ---------- */
.app { max-width: 720px; margin: 0 auto; padding: 16px 14px 24px; outline: none; }
.view { animation: rise .26s cubic-bezier(.2,.7,.3,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.page-head { margin: 4px 2px 16px; }
.eyebrow {
  font-family: var(--mono); font-size: .7rem; letter-spacing: .22em;
  text-transform: uppercase; color: var(--primary); margin: 0 0 4px;
}
.page-title { font-size: 1.55rem; font-weight: 750; letter-spacing: -.02em; margin: 0; }
.page-sub { color: var(--muted); font-size: .9rem; margin: 6px 0 0; }

/* ---------- Dashboard summary tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.tile {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 14px 14px;
  text-decoration: none; color: inherit;
  transition: transform .12s ease, border-color .15s ease;
}
.tile:active { transform: scale(.985); }
.tile--total {
  grid-column: 1 / -1;
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 16%, var(--surface)), var(--surface));
  border-color: color-mix(in srgb, var(--primary) 40%, var(--line));
}
.tile__rail {
  position: absolute; inset: 0 auto 0 0; width: 6px;
  background-image: repeating-linear-gradient(180deg, var(--primary) 0 4px, transparent 4px 8px);
  opacity: .5;
}
.tile__icon { font-size: 1.15rem; line-height: 1; }
.tile__num { font-family: var(--mono); font-size: 2.1rem; font-weight: 600; letter-spacing: -.02em; margin: 8px 0 0; }
.tile--total .tile__num { font-size: 2.7rem; color: var(--primary); }
.tile__label { color: var(--muted); font-size: .82rem; margin-top: 2px; }

/* ---------- Section title ---------- */
.section-row { display: flex; align-items: baseline; justify-content: space-between; margin: 26px 2px 12px; }
.section-row h2 { font-size: .82rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 0; }

/* ---------- Quick actions ---------- */
.quick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.quick__btn {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 13px 14px;
  color: inherit; text-decoration: none; font-weight: 600; font-size: .92rem;
  transition: border-color .15s ease, background-color .15s ease;
}
.quick__btn:active { background: var(--surface-2); }
.quick__btn .em { font-size: 1.1rem; }
.quick__btn--accent { border-color: color-mix(in srgb, var(--primary) 45%, var(--line)); color: var(--primary); }

/* ---------- Asset tag cards (signature element) ---------- */
.taglist { display: flex; flex-direction: column; gap: 11px; }
.tag {
  position: relative; display: block; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 14px 14px 14px 56px;
  overflow: hidden;
  transition: transform .12s ease, border-color .15s ease;
}
.tag:active { transform: scale(.99); }
/* barcode rail down the left edge = the "physical tag" cue */
.tag__rail {
  position: absolute; inset: 0 auto 0 0; width: 40px;
  background: var(--surface-2);
  border-right: 1px solid var(--line);
  display: grid; place-items: center;
}
.tag__rail::before {
  content: ""; width: 18px; height: 70%;
  background-image: repeating-linear-gradient(180deg, var(--text) 0 2px, transparent 2px 5px);
  opacity: .55;
}
.tag__top { display: flex; align-items: center; gap: 8px; }
.tag__type {
  font-family: var(--mono); font-size: .64rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--primary); border: 1px solid color-mix(in srgb, var(--primary) 40%, transparent);
  padding: 2px 7px; border-radius: 999px;
}
.tag__model { font-weight: 650; font-size: 1rem; margin: 7px 0 2px; }
.tag__serial { font-family: var(--mono); font-size: .82rem; color: var(--text); }
.tag__serial b { color: var(--faint); font-weight: 500; }
.tag__meta { color: var(--muted); font-size: .8rem; margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; }
.tag__meta span::after { content: "·"; margin-left: 6px; color: var(--faint); }
.tag__meta span:last-child::after { content: ""; }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: .82rem; font-weight: 600; color: var(--muted); }
.field .opt { color: var(--faint); font-weight: 500; }
.control { display: flex; gap: 8px; align-items: stretch; }
input, textarea, select {
  width: 100%; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 11px; padding: 12px 13px; min-height: var(--tap);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field--scan input { font-family: var(--mono); }
textarea { min-height: 80px; resize: vertical; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
input::placeholder, textarea::placeholder { color: var(--faint); }

.scanbtns { display: flex; gap: 6px; flex: none; }
.scanbtns button {
  width: var(--tap); min-height: var(--tap); flex: none;
  display: grid; place-items: center; gap: 0;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 11px; color: var(--text); cursor: pointer;
  font-size: 1.15rem;
}
.scanbtns button:active { background: var(--surface-3); }

/* photo field */
.photo-field { display: flex; align-items: center; gap: 12px; }
.photo-preview {
  width: 64px; height: 64px; flex: none; border-radius: 11px;
  background: var(--surface-2) center/cover no-repeat; border: 1px solid var(--line);
  display: grid; place-items: center; color: var(--faint); font-size: 1.4rem;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px; border-radius: 12px;
  font: inherit; font-weight: 650; cursor: pointer; border: 1px solid transparent;
  transition: transform .1s ease, filter .15s ease, background-color .15s ease;
}
.btn:active { transform: scale(.98); }
.btn--primary { background: var(--primary); color: var(--primary-ink); }
.btn--primary:hover { filter: brightness(1.06); }
.btn--ghost { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn--danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn--block { width: 100%; }
.btn--lg { min-height: 52px; font-size: 1rem; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }
.form-actions .btn { flex: 1; }

/* ---------- FAB ---------- */
.fab {
  position: fixed; right: 16px; z-index: 25;
  bottom: calc(78px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 18px;
  background: var(--primary); color: var(--primary-ink); border: none;
  display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 12px 26px -8px color-mix(in srgb, var(--primary) 70%, transparent);
}
.fab svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
[dir="rtl"] .fab { right: auto; left: 16px; }

/* ---------- Search ---------- */
.searchbar { position: relative; margin-bottom: 12px; }
.searchbar input { padding-left: 42px; }
.searchbar svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2; }
[dir="rtl"] .searchbar input { padding-left: 13px; padding-right: 42px; }
[dir="rtl"] .searchbar svg { left: auto; right: 12px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); border-radius: 999px; padding: 7px 14px;
  font-size: .82rem; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }

/* ---------- Cards / panels ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
}
.panel h3 { margin: 0 0 6px; font-size: 1rem; }
.panel p { margin: 0; color: var(--muted); font-size: .88rem; line-height: 1.5; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; margin-top: 8px; }
.kv dt { color: var(--muted); font-size: .85rem; }
.kv dd { margin: 0; font-family: var(--mono); font-size: .85rem; text-align: right; word-break: break-all; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty__mark { font-size: 2.4rem; opacity: .5; }
.empty h3 { color: var(--text); margin: 12px 0 4px; }
.empty p { margin: 0 0 16px; font-size: .9rem; }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 60;
  bottom: calc(84px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px; width: calc(100% - 32px); max-width: 420px;
  pointer-events: none;
}
.toast {
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--line); border-left: 3px solid var(--primary);
  border-radius: 12px; padding: 12px 14px; font-size: .9rem;
  box-shadow: var(--shadow); animation: rise .2s ease both;
}
.toast--error { border-left-color: var(--danger); }
.toast--warn { border-left-color: var(--amber); }

/* ---------- Bottom nav ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 28;
  height: calc(64px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px); border-top: 1px solid var(--line-soft);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--muted); font-size: .68rem; font-weight: 600;
}
.tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--primary); }

/* ---------- Scanner overlay ---------- */
.scanner {
  position: fixed; inset: 0; z-index: 80; background: #000;
  display: flex; flex-direction: column;
}
.scanner__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px; color: #fff; font-weight: 600;
}
.scanner__head .iconbtn { color: #fff; }
.scanner__stage { position: relative; flex: 1; overflow: hidden; }
.reader { width: 100%; height: 100%; }
.reader video { width: 100% !important; height: 100% !important; object-fit: cover; }
.scanner__frame {
  position: absolute; inset: 50% 0 auto; top: 50%; transform: translateY(-50%);
  width: min(74vw, 320px); height: min(74vw, 320px); margin: 0 auto;
  border: 2px solid #ffffffaa; border-radius: 18px; overflow: hidden;
  box-shadow: 0 0 0 100vmax #00000066;
}
.scanline {
  position: absolute; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  box-shadow: 0 0 12px 2px var(--primary);
  animation: scan 2.4s linear infinite;
}
@keyframes scan { 0% { top: 4%; } 50% { top: 96%; } 100% { top: 4%; } }
.scanner__hint { color: #cfd6de; text-align: center; padding: 14px 20px calc(env(safe-area-inset-bottom) + 18px); font-size: .9rem; margin: 0; }

/* ---------- Misc ---------- */
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, currentColor 35%, transparent);
  border-top-color: currentColor; animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.muted { color: var(--muted); }
.hidden, [hidden] { display: none !important; }
.dupe-warn { color: var(--amber); font-size: .8rem; }

@media (min-width: 560px) {
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .tile--total { grid-column: 1 / -1; }
  .quick { grid-template-columns: repeat(3, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  .scanline { display: none; }
}

/* ============================================================
   v2 additions: install pill, field tools, detection review
   ============================================================ */

/* Install button in the app bar */
.install-pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px 0 10px; margin-right: 4px;
  background: var(--primary); color: var(--primary-ink);
  border: none; border-radius: 999px; cursor: pointer;
  font: inherit; font-size: .82rem; font-weight: 700; white-space: nowrap;
}
.install-pill svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.install-pill:active { filter: brightness(1.05); transform: scale(.98); }
[dir="rtl"] .install-pill { margin-right: 0; margin-left: 4px; }

/* Field tool row (Barcode / OCR / Photo / Clear) under the input */
.fieldtools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.toolbtn {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 38px; padding: 0 11px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; color: var(--text); cursor: pointer;
  font: inherit; font-size: .8rem; font-weight: 600;
}
.toolbtn__i { font-size: 1.02rem; line-height: 1; }
.toolbtn:active { background: var(--surface-3); transform: scale(.98); }
.toolbtn--clear { color: var(--muted); }

/* Selectable result rows (shared by scanner overlay + review dialog) */
.pick {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border: 1px solid var(--line);
  border-radius: 11px; background: var(--surface); cursor: pointer;
  margin-bottom: 8px;
}
.pick:last-child { margin-bottom: 0; }
.pick input { width: 18px; height: 18px; min-height: 0; flex: none; accent-color: var(--primary); }
.pick__val { flex: 1; font-family: var(--mono); font-size: .9rem; word-break: break-all; }
.pick--on { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.pick--sug { border-color: color-mix(in srgb, var(--primary) 50%, var(--line)); }
.pick__badge {
  flex: none; font-size: .66rem; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--primary-ink); background: var(--primary);
  padding: 3px 7px; border-radius: 999px;
}
.pick__copy {
  flex: none; width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface-2);
  color: var(--muted); cursor: pointer; font-size: .95rem;
}
.pick__copy:active { background: var(--surface-3); }

/* Scanner overlay: detected list + action bar */
.scanner__found {
  max-height: 30vh; overflow-y: auto;
  padding: 4px 16px 0; -webkit-overflow-scrolling: touch;
}
.scanner__found .pick { background: #161b22; border-color: #2a323d; color: #fff; }
.scanner__found .pick__val { color: #fff; }
.scanner__actions {
  display: flex; gap: 10px; padding: 12px 16px calc(env(safe-area-inset-bottom) + 14px);
}
.scanner__actions .btn { flex: 1; }
.scanner__actions .btn--ghost { background: transparent; color: #fff; border-color: #3a434f; }

/* Review dialog (modal sheet) */
.review {
  position: fixed; inset: 0; z-index: 85;
  background: #00000088; display: flex; align-items: flex-end; justify-content: center;
}
@supports (backdrop-filter: blur(2px)) { .review { backdrop-filter: blur(2px); } }
.review__sheet {
  width: 100%; max-width: 520px; max-height: 86vh; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px 18px 0 0; padding: 16px 16px calc(env(safe-area-inset-bottom) + 14px);
  box-shadow: 0 -16px 40px -12px #00000066;
}
@media (min-width: 560px) {
  .review { align-items: center; }
  .review__sheet { border-radius: 18px; }
}
.review__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.review__head span { font-weight: 700; font-size: 1.02rem; }
.review__sub { color: var(--muted); font-size: .84rem; margin: 4px 0 12px; }
.review__body { overflow-y: auto; flex: 1; }
.review__group { margin-bottom: 14px; }
.review__group h4 {
  margin: 0 0 8px; font-size: .74rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}
.review__actions { display: flex; gap: 10px; padding-top: 12px; }
.review__actions .btn { flex: 1; }

/* ---------- PWA diagnostics ---------- */
.pwa-verdict { border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; border: 1px solid var(--line); background: var(--surface); }
.pwa-verdict__t { font-weight: 700; font-size: 1.02rem; }
.pwa-verdict__d { color: var(--muted); font-size: .88rem; margin-top: 4px; line-height: 1.45; }
.pwa-verdict--ok { border-color: color-mix(in srgb, var(--primary) 50%, var(--line)); background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 12%, var(--surface)), var(--surface)); }
.pwa-verdict--warn { border-color: color-mix(in srgb, var(--amber) 55%, var(--line)); }
.pwa-verdict--fail { border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); }

.pwa-list { display: flex; flex-direction: column; }
.pwa-row { display: flex; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line-soft); }
.pwa-row:last-child { border-bottom: none; }
.pwa-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; background: var(--muted); }
.pwa-row--ok .pwa-dot { background: var(--primary); }
.pwa-row--warn .pwa-dot { background: var(--amber); }
.pwa-row--fail .pwa-dot { background: var(--danger); }
.pwa-row--info .pwa-dot { background: var(--muted); }
.pwa-t { font-weight: 600; font-size: .9rem; }
.pwa-d { color: var(--muted); font-size: .82rem; margin-top: 2px; line-height: 1.4; word-break: break-word; }

/* ---------- LTR safeguard for code-like fields (fixes RTL delete/cursor) ---------- */
.field input[dir="ltr"] { direction: ltr; text-align: left; }

/* ---------- Crop / select-text overlay ---------- */
.cropper { position: fixed; inset: 0; z-index: 82; background: #000; display: flex; flex-direction: column; }
.cropper__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px; color: #fff; font-weight: 600;
}
.cropper__head .iconbtn { color: #fff; }
.cropper__stage {
  position: relative; flex: 1; overflow: hidden; touch-action: none;
  display: flex; align-items: center; justify-content: center; user-select: none;
}
.cropper__stage img { max-width: 100%; max-height: 100%; object-fit: contain; pointer-events: none; -webkit-user-drag: none; }
.cropper__sel {
  position: absolute; border: 2px solid var(--primary);
  background: color-mix(in srgb, var(--primary) 18%, transparent);
  box-shadow: 0 0 0 100vmax #00000070; border-radius: 4px; pointer-events: none;
}
.cropper__hint { color: #cfd6de; text-align: center; padding: 12px 20px 8px; font-size: .88rem; margin: 0; }
.cropper__actions { display: flex; gap: 10px; padding: 8px 16px calc(env(safe-area-inset-bottom) + 14px); }
.cropper__actions .btn { flex: 1; }
.cropper__actions .btn--ghost { background: transparent; color: #fff; border-color: #3a434f; }

/* ---------- Required (red) labels for Model & Serial Number ---------- */
.field label.lbl-req { color: var(--req); font-weight: 700; }
.field label.lbl-req .opt { color: var(--faint); font-weight: 500; }

/* ---------- Editable dropdown (combobox) for Location & Department ---------- */
.combo { position: relative; width: 100%; }
.combo input { width: 100%; padding-right: 38px; }
[dir="rtl"] .combo input { padding-right: 13px; padding-left: 38px; }
.combo__chev {
  position: absolute; top: 50%; right: 12px; transform: translateY(-50%);
  width: 18px; height: 18px; fill: none; stroke: var(--muted);
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none;
}
[dir="rtl"] .combo__chev { right: auto; left: 12px; }
/* hide the browser's native datalist arrow so only our chevron shows */
.combo input::-webkit-calendar-picker-indicator { opacity: 0; }

/* ---------- Scanner header buttons + flashlight ---------- */
.scanner__headbtns { display: flex; align-items: center; gap: 4px; }
#scanTorch.on { color: var(--primary); background: #ffffff1a; border-radius: 10px; }
/* keep the live scan box crisp */
#reader video { object-fit: cover; }

/* ---------- Visible back button in the app bar ---------- */
#backBtn { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
#backBtn:active { background: var(--surface-3); transform: scale(.96); }
[dir="rtl"] #backBtn svg { transform: scaleX(-1); }  /* arrow points the correct way in RTL */

/* ============================================================
   v9 — modern home + central Add + type picker
   ============================================================ */

/* Home layout (compact, no scrolling needed to add) */
.view--home { padding-top: 6px; }
.home-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.home-title { font-size: 1.55rem; font-weight: 800; margin: 3px 0 0; letter-spacing: -.01em; }
.home-total {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 78px; padding: 8px 12px; border: 1px solid var(--line);
  border-radius: 16px; background: var(--surface); text-decoration: none;
}
.home-total__n { font-size: 1.5rem; font-weight: 800; color: var(--primary); line-height: 1; }
.home-total__l { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; margin-top: 4px; }

.add-cta {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 9px;
  height: 54px; border: none; border-radius: 16px; cursor: pointer;
  background: var(--primary); color: var(--primary-ink);
  font: inherit; font-weight: 800; font-size: 1.02rem; margin-bottom: 18px;
  box-shadow: 0 12px 26px -12px var(--primary);
}
.add-cta svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.add-cta:active { transform: scale(.99); filter: brightness(1.03); }

.cat-grid { display: flex; flex-direction: column; gap: 10px; }
.cat {
  display: flex; align-items: center; gap: 13px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 15px; background: var(--surface);
  text-decoration: none; color: var(--text);
}
.cat:active { background: var(--surface-2); }
.cat__icon {
  width: 44px; height: 44px; flex: none; display: flex; align-items: center; justify-content: center;
  font-size: 1.35rem; background: var(--surface-2); border-radius: 12px;
}
.cat__meta { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.cat__name { font-weight: 700; font-size: 1rem; }
.cat__count { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.cat__chev { color: var(--faint); font-size: 1.5rem; line-height: 1; }
[dir="rtl"] .cat__chev { transform: scaleX(-1); }

.home-quick { display: flex; gap: 8px; margin-top: 18px; }
.hq {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 6px; border: 1px solid var(--line); border-radius: 13px;
  background: var(--surface); color: var(--text); text-decoration: none;
  font-size: .86rem; font-weight: 600;
}
.hq:active { background: var(--surface-2); }

/* Central Add button in the bottom nav */
.tab--add { background: none; border: none; cursor: pointer; font: inherit; color: var(--muted); position: relative; }
.tab__plus {
  width: 48px; height: 48px; margin-top: -16px; margin-bottom: 1px; border-radius: 50%;
  background: var(--primary); color: var(--primary-ink);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 18px -6px var(--primary); border: 3px solid var(--bg);
}
.tab__plus svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.8; stroke-linecap: round; }
.tab--add:active .tab__plus { transform: scale(.94); }

/* Type-picker bottom sheet */
.sheet { position: fixed; inset: 0; z-index: 86; background: #00000088; display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity .18s ease; }
@supports (backdrop-filter: blur(2px)) { .sheet { backdrop-filter: blur(2px); } }
.sheet--in { opacity: 1; }
.sheet__panel {
  width: 100%; max-width: 520px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px 20px 0 0; padding: 14px 16px calc(env(safe-area-inset-bottom) + 18px);
  transform: translateY(14px); transition: transform .18s ease;
  box-shadow: 0 -16px 40px -12px #00000066;
}
.sheet--in .sheet__panel { transform: translateY(0); }
@media (min-width: 560px) { .sheet { align-items: center; } .sheet__panel { border-radius: 20px; } }
.sheet__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet__head span { font-weight: 700; font-size: 1.05rem; }
.sheet__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pickcard {
  display: flex; flex-direction: column; align-items: center; gap: 9px; padding: 18px 8px;
  border: 1px solid var(--line); border-radius: 15px; background: var(--surface-2);
  color: var(--text); cursor: pointer; font: inherit; font-weight: 700; font-size: .92rem;
}
.pickcard__i { font-size: 1.7rem; }
.pickcard:active { background: var(--surface-3); transform: scale(.98); }
.pickcard:last-child:nth-child(odd) { grid-column: 1 / -1; }

/* ---------- Manage-list link + options manager ---------- */
.manage-link {
  margin-top: 8px; display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer; padding: 4px 2px;
  color: var(--primary); font: inherit; font-size: .82rem; font-weight: 600;
}
.manage-link:active { opacity: .7; }
.sheet__sub { color: var(--muted); font-size: .82rem; line-height: 1.5; margin: 0 0 14px; }
.optman__add { display: flex; gap: 8px; margin-bottom: 14px; }
.optman__add input {
  flex: 1; min-height: var(--tap, 44px); padding: 0 12px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; color: var(--text); font: inherit;
}
.optman__add .btn { flex: none; white-space: nowrap; }
.optman__list { display: flex; flex-direction: column; gap: 8px; max-height: 44vh; overflow-y: auto; }
.optrow {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2);
}
.optrow span { font-weight: 600; font-size: .92rem; word-break: break-word; }
.optrow__del {
  flex: none; width: 30px; height: 30px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--danger); font-size: .9rem;
}
.optrow__del:active { background: var(--surface-3); }

/* ---------- OCR overlay: manual-entry panel (type while viewing the photo) ---------- */
.cropper__panel { padding: 10px 16px calc(env(safe-area-inset-bottom) + 14px); background: #0b0e12; }
.cropper__manual { display: flex; gap: 8px; margin-bottom: 4px; }
.cropper__manual input {
  flex: 1; min-height: 46px; padding: 0 12px; font: inherit; font-size: 1rem;
  background: #161b22; border: 1px solid #2a323d; border-radius: 11px; color: #fff;
  direction: ltr; text-align: left;
}
.cropper__manual input::placeholder { color: #8a97a6; }
.cropper__manual .btn { flex: none; white-space: nowrap; }
.cropper__panel .cropper__hint { padding: 8px 4px 10px; }
.cropper__panel .cropper__actions { padding: 0; }

/* ---------- OCR overlay: zoom controls + transformable image ---------- */
.cropper__stage img { transform-origin: center center; will-change: transform; }
.cropper__zoom {
  position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column;
  border-radius: 12px; overflow: hidden; border: 1px solid #2a323d; background: #0b0e12cc; backdrop-filter: blur(6px);
}
[dir="rtl"] .cropper__zoom { right: auto; left: 12px; }
.cropper__zoom button {
  width: 44px; height: 44px; border: none; background: transparent; color: #fff;
  font-size: 1.3rem; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.cropper__zoom button:active { background: #ffffff1f; }
.cropper__zoom button + button { border-top: 1px solid #2a323d; }

/* ---------- OCR overlay: dual-field rows + wrapped read actions ---------- */
.cropper__fields { display: flex; flex-direction: column; gap: 10px; margin-bottom: 6px; }
.cropfield label { display: block; font-size: .78rem; font-weight: 700; color: #cfd6de; margin-bottom: 5px; }
.cropfield__row { display: flex; gap: 8px; }
.cropfield__input {
  flex: 1; min-height: 46px; padding: 0 12px; font: inherit; font-size: 1rem;
  background: #161b22; border: 1px solid #2a323d; border-radius: 11px; color: #fff;
  direction: ltr; text-align: left;
}
.cropfield__input::placeholder { color: #8a97a6; }
.cropfield__insert { flex: none; white-space: nowrap; }
.cropper__addsec { color: var(--primary); margin: 0 0 6px; }
.cropper__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.cropper__actions .btn { flex: 1 1 30%; min-width: 110px; font-size: .82rem; padding: 0 8px; }

/* ---------- Barcode chooser (when more than one barcode is found) ---------- */
.chooser { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; }
.chooser__item {
  display: flex; align-items: center; gap: 10px; padding: 14px 14px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); color: var(--text);
  font: inherit; font-family: var(--mono); font-size: .95rem; text-align: left; word-break: break-all;
}
.chooser__item::before { content: "▦"; color: var(--primary); flex: none; }
.chooser__item:active { background: var(--surface-3); }

/* ---------- OCR overlay: lock-to-select toggle ---------- */
.cropper__lock {
  position: absolute; left: 12px; top: 12px; z-index: 2;
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px;
  border-radius: 999px; border: 1px solid #2a323d; background: #0b0e12cc; backdrop-filter: blur(6px);
  color: #fff; font: inherit; font-size: .8rem; font-weight: 700; cursor: pointer;
}
[dir="rtl"] .cropper__lock { left: auto; right: 12px; }
.cropper__lock.is-on { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.cropper__lock:active { transform: scale(.97); }

/* ---------- OCR Insert button: confirmation (turns green when inserted) ---------- */
.cropfield__insert { transition: background-color .15s ease, color .15s ease; }
.cropfield__insert.is-done { background: var(--success); border-color: var(--success); color: #04130C; }
.cropfield__insert.is-done:active { transform: none; }

/* ---------- Unsaved-changes confirm dialog ---------- */
.confirm-actions { display: flex; gap: 10px; margin-top: 4px; }
.confirm-actions .btn { flex: 1; }

/* ---------- GPS field ---------- */
.gps-extra { margin-top: 8px; }
.gps-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--primary); text-decoration: none; font-weight: 600; font-size: .85rem;
}
.gps-link:active { opacity: .7; }

/* ---------- Live scanner: native video + static target (no moving bar) ---------- */
.scan-video { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }
#reader .scan-video { border-radius: inherit; }
/* remove the up/down scanning line; use a calm static target frame instead */
.scanner__frame .scanline { display: none !important; animation: none !important; }
.scanner__frame {
  border: 2px solid color-mix(in srgb, var(--primary) 80%, transparent);
  border-radius: 14px; box-shadow: 0 0 0 100vmax #00000055;
}
.scanner__frame::before, .scanner__frame::after,
.scanner__frame > .corner { content: ""; }
/* teal corner brackets for a clear, static aim target */
.scanner__frame::before, .scanner__frame::after {
  position: absolute; width: 26px; height: 26px; border: 3px solid var(--primary);
}
.scanner__frame::before { top: -2px; left: -2px; border-right: none; border-bottom: none; border-top-left-radius: 14px; }
.scanner__frame::after { bottom: -2px; right: -2px; border-left: none; border-top: none; border-bottom-right-radius: 14px; }

/* ---------- Field & section management ---------- */
.fldlist { display: flex; flex-direction: column; gap: 8px; }
.fldrow { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.fldrow.is-hidden { opacity: .55; }
.fldrow__main { flex: 1; min-width: 0; }
.fldrow__name { font-weight: 600; }
.fldrow__meta { font-size: .75rem; color: var(--muted); margin-top: 2px; }
.fldrow__btns { display: flex; gap: 4px; flex-shrink: 0; }
.fldrow__btns .iconbtn { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.ff { display: flex; flex-direction: column; gap: 6px; }
.ff__lbl { font-size: .8rem; color: var(--muted); margin-top: 6px; }
.ff input[type="text"], .ff textarea, .ff select { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit; }
.ff__chk { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: .9rem; }
.ff__chk input { width: 18px; height: 18px; }
.combo select { width: 100%; appearance: none; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit; }
