:root {
  --bg: #20242a;
  --bg-deep: #181b20;
  --panel: #2a2f36;
  --panel-2: #313740;
  --text: #f4f6f8;
  --muted: #aab2bd;
  --line: rgba(255,255,255,.09);
  --blue: #4f8ee8;
  --blue-dark: #3974c8;
  --orange: #d98a28;
  --green: #36a665;
  --red: #d65353;
  --shadow: 0 18px 45px rgba(0,0,0,.28);
  --radius: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--bg-deep); color: var(--text); font-family: Inter, Arial, Helvetica, sans-serif; }
body { min-height: 100vh; min-height: 100dvh; }
button, input { font: inherit; }
button { border: 0; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
.hidden { display: none !important; }

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 20% 0%, rgba(79,142,232,.13), transparent 34%),
    linear-gradient(180deg, #252a31 0%, #1d2025 100%);
}

.app-shell { width: 100%; max-width: 560px; min-height: 100vh; min-height: 100dvh; margin: 0 auto; padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom); }
.app-header { height: 76px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.brand-mark { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 20px; background: linear-gradient(145deg, #49515d, #30353c); border: 1px solid rgba(255,255,255,.08); box-shadow: 0 8px 20px rgba(0,0,0,.18); }
.brand-copy { min-width: 0; }
.brand-copy strong { display: block; font-size: 17px; }
.brand-copy span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.network-badge { margin-left: auto; display: inline-flex; align-items: center; gap: 7px; padding: 7px 9px; border-radius: 999px; font-size: 11px; color: var(--muted); background: rgba(255,255,255,.035); border: 1px solid var(--line); }
.network-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.network-badge.offline .network-dot { background: var(--red); }

.app-main { min-height: calc(100dvh - 76px); padding: 22px 0 18px; }
.screen { display: none; min-height: calc(100dvh - 118px); flex-direction: column; }
.screen.active { display: flex; }

.hero-card, .panel, .stat-card, .action-card, .modal-card, .loading-card {
  background: linear-gradient(180deg, rgba(48,54,63,.96), rgba(39,44,51,.96));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.hero-card { margin: auto 0; padding: 26px 22px; border-radius: 22px; }
.eyebrow { color: #8fb9f2; font-size: 11px; font-weight: 800; letter-spacing: 1.4px; margin-bottom: 8px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 30px; line-height: 1.08; margin-bottom: 10px; }
h2 { font-size: 26px; margin-bottom: 5px; }
h3 { font-size: 21px; margin-bottom: 8px; }
p { color: var(--muted); line-height: 1.5; }

.field-label { display: block; margin: 20px 0 8px; color: #d6dbe1; font-size: 12px; font-weight: 700; }
.pin-input, .text-input { width: 100%; border: 1px solid rgba(255,255,255,.11); outline: none; background: #1b1f24; color: var(--text); border-radius: 13px; }
.pin-input:focus, .text-input:focus { border-color: rgba(79,142,232,.8); box-shadow: 0 0 0 4px rgba(79,142,232,.12); }
.pin-input { height: 68px; text-align: center; font-size: 30px; font-weight: 800; letter-spacing: 13px; padding-left: 13px; }
.text-input { min-height: 54px; padding: 0 14px; text-transform: uppercase; }

.btn { width: 100%; min-height: 56px; border-radius: 13px; padding: 13px 16px; color: white; font-weight: 800; font-size: 16px; transition: transform .08s ease, opacity .15s ease; }
.btn:active:not(:disabled) { transform: scale(.985); }
.btn-primary { margin-top: 16px; background: linear-gradient(180deg, var(--blue), var(--blue-dark)); }
.btn-secondary { margin-top: 12px; background: #3a414b; border: 1px solid var(--line); }
.btn-ghost { margin-top: auto; background: transparent; border: 1px solid var(--line); }
.btn-danger { margin-top: auto; background: linear-gradient(180deg, #dd6161, #bd4242); }
.danger-text { color: #ef9696; }

.section-head { display: flex; justify-content: space-between; align-items: flex-start; margin: 8px 2px 18px; }
.section-head p { margin-bottom: 0; font-size: 13px; }
.panel { border-radius: var(--radius); padding: 22px; }
.scan-panel { text-align: center; }
.scan-symbol { width: 86px; height: 86px; display: grid; place-items: center; margin: 2px auto 18px; border-radius: 24px; background: #20252b; border: 1px solid var(--line); font-size: 42px; color: #a8c8f5; }
.scan-panel .field-label { text-align: left; }
.divider { display: flex; align-items: center; gap: 10px; margin: 22px 0 6px; color: #818b97; font-size: 11px; text-transform: uppercase; }
.divider::before, .divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }

.visit-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-bottom: 15px; }
.stat-card { border-radius: 15px; padding: 15px; }
.stat-card span { display: block; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: 1px; margin-bottom: 6px; }
.stat-card strong { display: block; font-size: 17px; overflow-wrap: anywhere; }
.action-grid { display: grid; gap: 12px; margin-bottom: 18px; }
.action-card { width: 100%; min-height: 108px; border-radius: 17px; padding: 18px; text-align: left; color: white; position: relative; overflow: hidden; }
.action-card::after { content: ""; position: absolute; width: 120px; height: 120px; right: -54px; top: -55px; border-radius: 50%; background: rgba(255,255,255,.055); }
.action-kicker { display: block; font-size: 10px; font-weight: 800; letter-spacing: 1.2px; opacity: .72; margin-bottom: 8px; }
.action-card strong { display: block; font-size: 23px; margin-bottom: 5px; }
.action-card small { color: rgba(255,255,255,.72); font-size: 12px; }
.action-pick { background: linear-gradient(145deg, #8d5a20, #6a4218); }
.action-return { background: linear-gradient(145deg, #287d4d, #1d5f3a); }
.action-inventory { background: linear-gradient(145deg, #416b9e, #315177); }

.done-screen { justify-content: center; align-items: center; text-align: center; padding-bottom: 8vh; }
.done-icon { width: 88px; height: 88px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 22px; font-size: 42px; color: #9be0b8; background: rgba(54,166,101,.14); border: 1px solid rgba(54,166,101,.3); }

.modal { position: fixed; inset: 0; z-index: 800; display: none; align-items: flex-end; justify-content: center; padding: 16px; background: rgba(8,10,13,.72); backdrop-filter: blur(6px); }
.modal.show { display: flex; }
.modal-card { width: 100%; max-width: 540px; border-radius: 22px; padding: 20px; }
.modal-card.compact { max-width: 440px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.icon-btn { width: 42px; height: 42px; flex: 0 0 auto; border-radius: 12px; color: var(--text); background: #3b424c; font-size: 26px; }
.reader { width: 100%; min-height: 260px; overflow: hidden; border-radius: 15px; background: #111; margin-top: 12px; }
.camera-note { margin: 12px 0 0; font-size: 12px; text-align: center; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.modal-actions .btn { margin-top: 0; }

.loading { position: fixed; inset: 0; z-index: 1000; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(10,12,15,.72); backdrop-filter: blur(6px); }
.loading.show { display: flex; }
.loading-card { min-width: 210px; border-radius: 18px; padding: 22px; text-align: center; }
.spinner { width: 36px; height: 36px; margin: 0 auto 13px; border: 4px solid rgba(255,255,255,.14); border-top-color: #d8e7fa; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast { position: fixed; z-index: 1100; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); width: calc(100% - 32px); max-width: 520px; transform: translate(-50%, 30px); opacity: 0; pointer-events: none; padding: 14px 16px; border-radius: 13px; color: white; text-align: center; line-height: 1.35; background: #343b44; border: 1px solid var(--line); box-shadow: var(--shadow); transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #573033; }

@media (min-width: 520px) {
  .app-shell { padding-left: 22px; padding-right: 22px; }
  .action-grid { grid-template-columns: 1fr 1fr; }
  .action-inventory { grid-column: 1 / -1; }
}

@media (max-height: 650px) {
  .app-main { padding-top: 14px; }
  .hero-card { margin: 0; }
}
