/* ============================================================
   סמלון — ניהול צל״ם
   Design tokens taken verbatim from the Armory Prototype
   (Claude Design project "Equipment tracking app design").
   ============================================================ */

:root {
  --color-bg: #14170f;
  --color-surface: #212517;
  --color-surface-hi: #2c311e;
  --color-sunken: #1a1d13;
  --color-sheet: #1b1f14;
  --color-text: #ecebe0;
  --color-divider: rgba(236, 235, 224, 0.14);
  --color-accent: #8a9e56;
  --color-accent-300: #cbd9a4;
  --color-accent-400: #a8bd73;
  --color-accent-700: #4f5c2e;
  --color-neutral-400: #b8b9a6;
  --color-neutral-500: #999b86;
  --color-neutral-600: #7b7d69;
  --color-neutral-800: #414534;
  --color-neutral-900: #262a1b;
  --color-gold: #d4b03c;
  --color-gold-300: #ecd68c;
  --color-gold-700: #6b5618;

  --red: oklch(0.72 0.14 25);
  --red-ring: oklch(0.58 0.13 25);

  --accent-wash: rgba(138, 158, 86, 0.14);
  --accent-wash-hi: rgba(138, 158, 86, 0.24);
  --accent-wash-lo: rgba(138, 158, 86, 0.12);
  --avatar-bg: rgba(138, 158, 86, 0.16);
  --gold-wash: rgba(212, 176, 60, 0.16);

  --shadow-lg: 0 18px 46px rgba(0, 0, 0, 0.55);
  --radius: 8px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { -webkit-tap-highlight-color: transparent; }

/* Reserve the glyph box so tap targets never collapse if the icon font
   fails to load (offline, blocked CDN). */
i.ph, i[class^="ph "], i[class*=" ph-"] {
  display: inline-block;
  min-width: 1em;
  min-height: 1em;
  font-style: normal;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: "Heebo", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body { display: flex; justify-content: center; }

a { color: var(--color-accent-400); text-decoration: none; }
a:hover { color: var(--color-accent-300); }
input, button, textarea, select { font-family: inherit; }
button { border: 0; background: none; padding: 0; color: inherit; cursor: pointer; }

.app {
  width: 100%;
  max-width: 460px;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  position: relative;
  overflow: hidden;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

@media (min-width: 560px) {
  body { align-items: center; }
  .app {
    height: min(100dvh, 900px);
    border-radius: 18px;
    box-shadow: 0 0 0 1px var(--color-neutral-800), var(--shadow-lg);
  }
}

/* ---------- screen scaffold ---------- */

.screen { height: 100%; display: flex; flex-direction: column; min-height: 0; }

.hd {
  padding: 10px 14px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--color-divider);
  flex: none;
}
.hd__back {
  width: 38px; height: 38px;
  border-radius: var(--radius);
  display: grid; place-items: center;
  flex: none;
}
.hd__back i { font-size: 19px; color: var(--color-neutral-400); line-height: 1; }
.hd__back:hover { background: var(--color-surface-hi); }
.hd__mid { flex: 1; min-width: 0; }
.hd__title { font-size: 17px; font-weight: 500; }
.hd__sub { font-size: 11.5px; color: var(--color-neutral-400); margin-top: 1px; }

.body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; min-height: 0; }
.pad { padding: 14px 18px 18px; }

.foot {
  padding: 12px 18px calc(10px + var(--safe-bottom));
  border-top: 1px solid var(--color-divider);
  display: flex;
  gap: 8px;
  flex: none;
}

.eyebrow {
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-neutral-600);
  padding: 4px 0 8px;
}
.eyebrow--gap { padding-top: 20px; }

.stack { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; }
.empty { font-size: 13px; color: var(--color-neutral-400); padding: 22px 2px; text-align: center; text-wrap: pretty; }
.mono { direction: ltr; unicode-bidi: isolate; }

/* ---------- cards & rows ---------- */

.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: 0 0 0 1px var(--color-neutral-800);
}
.card--tap { cursor: pointer; }
.card--tap:hover { background: var(--color-surface-hi); }
.card--alert { box-shadow: 0 0 0 1px var(--red-ring); }
.card--ok { box-shadow: 0 0 0 1px var(--color-accent-700); }

.row { display: flex; align-items: center; gap: 12px; }
.row__main { flex: 1; min-width: 0; }
.row__name { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.row__title { font-size: 14.5px; font-weight: 500; }
.row__meta { font-size: 11.5px; color: var(--color-neutral-400); margin-top: 3px; text-wrap: pretty; }
.row__meta--bad { color: var(--red); }
.caret { font-size: 15px; color: var(--color-neutral-500); line-height: 1; flex: none; }

.avatar {
  width: 36px; height: 36px; flex: none;
  border-radius: var(--radius);
  background: var(--avatar-bg);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
  color: var(--color-gold-300);
}
.avatar--lg { width: 38px; height: 38px; font-size: 13px; }
.avatar--sm { width: 28px; height: 28px; border-radius: 6px; font-size: 10.5px; }

.tag {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--gold-wash);
  color: var(--color-gold-300);
  white-space: nowrap;
}

.chip {
  min-width: 34px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  padding: 5px 7px;
  border-radius: 6px;
  background: var(--color-sunken);
  border: 1px solid var(--color-neutral-800);
  color: var(--color-neutral-400);
}
.chip--gold { border-color: var(--color-gold-700); color: var(--color-gold-300); }

/* ---------- buttons ---------- */

.btn {
  flex: 1;
  text-align: center;
  padding: 13px 0;
  border-radius: var(--radius);
  border: 1px solid var(--color-neutral-800);
  font-size: 14.5px;
  color: var(--color-neutral-400);
  display: flex; align-items: center; justify-content: center; gap: 7px;
  cursor: pointer;
}
.btn:hover { background: var(--color-surface-hi); }
.btn i { font-size: 17px; line-height: 1; }
.btn--primary {
  border-color: var(--color-accent-700);
  background: var(--accent-wash);
  font-weight: 500;
  color: var(--color-accent-300);
}
.btn--primary:hover { background: var(--accent-wash-hi); }
.btn--tall { padding: 14px 0; font-size: 15px; }
.btn--narrow { flex: none; padding-inline: 18px; }
.btn[disabled] { opacity: .4; pointer-events: none; }
a.btn { text-decoration: none; }

.pill {
  padding: 6px 11px;
  border-radius: 20px;
  border: 1px solid var(--color-neutral-800);
  background: transparent;
  font-size: 12.5px;
  color: var(--color-neutral-400);
  cursor: pointer;
}
.pill:hover { background: var(--gold-wash); }
.pill.is-on {
  border-color: var(--color-accent-700);
  background: var(--gold-wash);
  color: var(--color-accent-300);
}

.tabs { display: flex; gap: 6px; padding: 12px 18px 0; flex: none; }
.tab {
  flex: 1; text-align: center; padding: 9px 0;
  border-radius: 6px;
  border: 1px solid var(--color-neutral-800);
  background: transparent;
  font-size: 13px; font-weight: 500;
  color: var(--color-neutral-400);
  cursor: pointer;
}
.tab.is-on { border-color: var(--color-accent-700); background: var(--gold-wash); color: var(--color-accent-300); }

/* ---------- inputs ---------- */

.input {
  width: 100%;
  box-sizing: border-box;
  background: var(--color-sunken);
  border: 1px solid var(--color-neutral-800);
  border-radius: var(--radius);
  padding: 12px 13px;
  font-size: 14px;
  color: var(--color-text);
}
.input:focus { outline: none; border-color: var(--color-accent-700); }
.input--serial { direction: ltr; text-align: right; border-radius: 6px; padding: 9px 11px; font-size: 13.5px; margin-top: 10px; }
.input--bad { border-color: var(--red-ring); }

.qty { display: flex; align-items: center; gap: 4px; flex: none; }
.qty__btn {
  width: 30px; height: 30px;
  border-radius: 6px;
  border: 1px solid var(--color-neutral-800);
  display: grid; place-items: center;
  color: var(--color-neutral-400);
  font-size: 16px;
  cursor: pointer;
}
.qty__btn:hover { background: var(--color-surface-hi); }
.qty__val { min-width: 26px; text-align: center; font-size: 14.5px; font-weight: 500; }

.check { font-size: 20px; color: var(--color-accent-400); line-height: 1; flex: none; }
.check--off { color: var(--color-neutral-600); }
.check--bad { color: var(--red); }

/* ---------- home ---------- */

.home__head { padding: 12px 18px 14px; flex: none; }
.home__unit { font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-accent); }
.home__h1 { font-size: 22px; font-weight: 500; letter-spacing: -0.015em; margin-top: 2px; }

.alert {
  margin: 0 18px 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--accent-wash-lo);
  box-shadow: 0 0 0 1px var(--red-ring);
  display: flex; align-items: center; gap: 11px;
  cursor: pointer;
}
.alert i.lead { font-size: 20px; color: var(--red); line-height: 1; }

.tiles { padding: 0 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  grid-column: auto;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px var(--color-neutral-800);
  padding: 16px 14px;
  min-height: 116px;
  display: flex; flex-direction: column; justify-content: space-between;
  cursor: pointer;
  text-align: start;
}
.tile:hover { background: var(--color-surface-hi); box-shadow: 0 0 0 1px var(--color-accent-700); }
.tile--wide { grid-column: span 2; }
.tile i { font-size: 26px; color: var(--color-accent-400); line-height: 1; align-self: flex-start; }
.tile__title { font-size: 15px; font-weight: 500; }
.tile__sub { font-size: 11px; color: var(--color-neutral-500); margin-top: 3px; }

.logrow {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--color-divider);
}
.logrow__t { font-size: 12.5px; color: var(--color-accent-400); width: 42px; flex: none; }
.logrow__x { flex: 1; font-size: 12.5px; color: var(--color-neutral-400); text-wrap: pretty; }

.statusbar {
  padding: 12px 18px calc(8px + var(--safe-bottom));
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 11px; color: var(--color-neutral-600);
  border-top: 1px solid var(--color-divider);
  flex: none;
}
.statusbar button { color: var(--color-accent-400); font-size: 11px; }

/* ---------- stat trio ---------- */

.stats { display: flex; gap: 8px; padding-bottom: 16px; }
.stat {
  flex: 1;
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 12px 13px;
  box-shadow: 0 0 0 1px var(--color-neutral-800);
}
.stat--bad { box-shadow: 0 0 0 1px var(--red-ring); }
.stat__n { font-size: 20px; font-weight: 500; line-height: 1; }
.stat__n--bad { color: var(--red); }
.stat__l { font-size: 11px; color: var(--color-neutral-500); margin-top: 4px; }

/* ---------- grenades ---------- */

.gren-head {
  margin: 14px 18px 0;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--color-surface);
  box-shadow: 0 0 0 1px var(--color-neutral-800);
  flex: none;
}
.gren-head--bad { box-shadow: 0 0 0 1px var(--red-ring); }
.gren-head__num { font-size: 30px; font-weight: 500; line-height: 1; letter-spacing: -0.02em; }
.gren-head__den { font-size: 15px; color: var(--color-neutral-400); }
.gren-head__lab { font-size: 11px; color: var(--color-neutral-400); margin-top: 5px; }
.gren-head__msg { flex: 1; font-size: 12.5px; color: var(--color-neutral-400); line-height: 1.5; text-wrap: pretty; }
.gren-head__msg--bad { color: var(--red); }
.bar { margin-top: 12px; height: 5px; border-radius: 3px; background: var(--color-neutral-900); overflow: hidden; }
.bar > div { height: 100%; background: var(--color-accent); transition: width .2s; }

/* ---------- QR ---------- */

.qr-wrap { padding: 14px; border-radius: 10px; background: #ecebe0; }
.qr { width: 168px; height: 168px; display: grid; }
.qr > div { background: #ecebe0; }
.qr > div.on { background: #14170f; }

/* ---------- detail item rows ---------- */

.item {
  padding: 11px 2px;
  border-bottom: 1px solid var(--color-divider);
}
.item__line { display: flex; align-items: center; gap: 10px; }
.item__name { flex: 1; font-size: 14px; }
.item__name--bad { color: var(--red); }
.item__tail { font-size: 12px; color: var(--color-neutral-400); }
.item__tail--bad { color: var(--red); }

.sub-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--color-divider);
  cursor: pointer;
}

/* ---------- overlays ---------- */

.scrim {
  position: absolute; inset: 0;
  background: rgba(8, 10, 5, 0.74);
  display: flex; flex-direction: column; justify-content: flex-end;
  z-index: 40;
  animation: fade .16s ease-out;
}
.scrim__void { flex: 1; cursor: pointer; }
.sheet {
  background: var(--color-sheet);
  border-radius: 12px 12px 0 0;
  box-shadow: 0 0 0 1px var(--color-neutral-800), var(--shadow-lg);
  padding: 18px 18px calc(16px + var(--safe-bottom));
  animation: rise .2s cubic-bezier(.2, .8, .2, 1);
  max-height: 84%;
  display: flex; flex-direction: column;
  min-height: 0;
}
.sheet--list { padding: 0; }
.sheet__hd { padding: 16px 18px 12px; border-bottom: 1px solid var(--color-divider); flex: none; }
.sheet__title { font-size: 16.5px; font-weight: 500; }
.sheet__sub { font-size: 11.5px; color: var(--color-neutral-400); margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; }
.sheet__body { flex: 1; overflow-y: auto; padding: 10px 18px 14px; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.sheet__foot { padding: 10px 18px calc(14px + var(--safe-bottom)); border-top: 1px solid var(--color-divider); flex: none; }

@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes rise { from { transform: translateY(14px); opacity: .4 } to { transform: none; opacity: 1 } }

/* ---------- toast ---------- */

#toast-root { position: fixed; inset: 0; pointer-events: none; z-index: 80; display: flex; justify-content: center; }
.toast {
  position: absolute;
  left: 18px; right: 18px;
  bottom: calc(46px + var(--safe-bottom));
  max-width: 424px;
  margin: 0 auto;
  background: var(--color-surface-hi);
  border-radius: var(--radius);
  padding: 13px 15px;
  box-shadow: 0 0 0 1px var(--color-accent-700), var(--shadow-lg);
  display: flex; align-items: center; gap: 11px;
  animation: rise .18s ease-out;
}
.toast--err { box-shadow: 0 0 0 1px var(--red-ring), var(--shadow-lg); }
.toast i { font-size: 19px; color: var(--color-accent-400); line-height: 1; }
.toast--err i { color: var(--red); }
.toast span { flex: 1; font-size: 13px; line-height: 1.45; text-wrap: pretty; }

/* ---------- connect / setup screen ---------- */

.connect { padding: 28px 22px; display: flex; flex-direction: column; gap: 18px; }
.connect__mark { font-size: 40px; color: var(--color-accent-400); line-height: 1; }
.connect__h1 { font-size: 24px; font-weight: 500; letter-spacing: -0.015em; }
.connect__p { font-size: 13.5px; color: var(--color-neutral-400); line-height: 1.6; text-wrap: pretty; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-neutral-600); }
.field__help { font-size: 11.5px; color: var(--color-neutral-600); line-height: 1.5; text-wrap: pretty; }

.sync {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--color-neutral-600);
}
.sync i { font-size: 13px; line-height: 1; }
.sync--busy i { animation: spin 1s linear infinite; color: var(--color-accent-400); }
.sync--err { color: var(--red); }
.sync--ok i { color: var(--color-accent-400); }
@keyframes spin { to { transform: rotate(360deg) } }

.boot { height: 100%; display: grid; place-items: center; gap: 12px; align-content: center; color: var(--color-neutral-500); font-size: 13px; }
.boot i { font-size: 26px; color: var(--color-accent-400); animation: spin 1s linear infinite; }
