/* ══════════════════════════════════════════════
   TOKENS & RESET
══════════════════════════════════════════════ */
:root {
  --bg:          #0c0c0c;
  --surface:     #141414;
  --card:        #1c1c1c;
  --card-hover:  #222222;
  --border:      #2a2a2a;
  --accent:      #f59e0b;
  --accent-dim:  rgba(245,158,11,0.12);
  --accent-glow: rgba(245,158,11,0.22);
  --text:        #e4e4e4;
  --text-muted:  #777;
  --text-dim:    #444;
  --success:     #22c55e;
  --danger:      #ef4444;
  --warning:     #f59e0b;
  --r:           14px;
  --r-sm:        9px;
}

*, *::before, *::after {
  margin: 0; padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  overflow: hidden;
}

/* ══════════════════════════════════════════════
   SPA VIEWS
══════════════════════════════════════════════ */
.view {
  position: absolute; inset: 0;
  display: none; flex-direction: column; overflow: hidden;
}
.view.active { display: flex; }

.scroll-area {
  flex: 1; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* ══════════════════════════════════════════════
   TOPBAR
══════════════════════════════════════════════ */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0; min-height: 56px;
}
.topbar-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 20px; letter-spacing: 1.5px;
}
.btn-back {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer; color: var(--text); font-size: 16px;
}
.btn-back:active { border-color: var(--accent); }

/* ══════════════════════════════════════════════
   HOME
══════════════════════════════════════════════ */
#view-home { background: var(--bg); }

.home-bg {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(245,158,11,0.08) 0%, transparent 70%),
    radial-gradient(ellipse 40% 60% at 100% 100%, rgba(245,158,11,0.04) 0%, transparent 60%);
}
.home-content {
  position: relative; flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 28px; gap: 13px;
}
.home-mark { display: flex; flex-direction: column; align-items: center; margin-bottom: 28px; }
.home-logo { font-family: 'Bebas Neue', sans-serif; font-size: 72px; letter-spacing: 8px; line-height: 1; }
.home-logo span { color: var(--accent); }
.home-sub { font-size: 11px; color: var(--text-muted); letter-spacing: 3px; text-transform: uppercase; margin-top: 6px; }
.home-version { position: absolute; bottom: 20px; font-size: 11px; color: var(--text-dim); font-family: 'IBM Plex Mono', monospace; }

/* ══════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════ */
.btn-primary {
  width: 100%; max-width: 300px; padding: 22px 20px;
  background: var(--accent); color: #0c0c0c;
  border: none; border-radius: var(--r);
  font-family: 'Bebas Neue', sans-serif; font-size: 24px; letter-spacing: 2.5px;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 12px;
  box-shadow: 0 4px 24px var(--accent-glow);
  transition: opacity 0.15s, transform 0.15s;
}
.btn-primary:active { opacity: 0.85; transform: scale(0.97); }

.btn-secondary {
  width: 100%; max-width: 300px; padding: 15px 20px;
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: var(--r);
  font-size: 14px; font-weight: 500; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: border-color 0.15s, color 0.15s;
}
.btn-secondary:active { border-color: var(--accent); color: var(--accent); }

.btn-cta {
  width: 100%; padding: 16px;
  background: var(--accent); color: #0c0c0c;
  border: none; border-radius: var(--r);
  font-family: 'Bebas Neue', sans-serif; font-size: 22px; letter-spacing: 2px;
  cursor: pointer; transition: opacity 0.15s;
}
.btn-cta:active { opacity: 0.85; }

.btn-cta-outline {
  width: 100%; padding: 14px;
  background: transparent; color: var(--accent);
  border: 1px solid var(--accent); border-radius: var(--r);
  font-family: 'Bebas Neue', sans-serif; font-size: 22px; letter-spacing: 2px;
  cursor: pointer;
}
.btn-cta-outline:active { opacity: 0.7; }

.btn-save {
  width: 100%; padding: 17px;
  background: var(--accent); color: #0c0c0c;
  border: none; border-radius: var(--r);
  font-family: 'Bebas Neue', sans-serif; font-size: 22px; letter-spacing: 2px;
  cursor: pointer;
}
.btn-save:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-delete {
  width: 100%; padding: 14px;
  background: transparent; color: var(--danger);
  border: 1px solid rgba(239,68,68,0.25); border-radius: var(--r);
  font-size: 14px; cursor: pointer;
}
.btn-delete:active { background: rgba(239,68,68,0.08); }

/* ══════════════════════════════════════════════
   SCAN VIEW
══════════════════════════════════════════════ */
#view-scan { background: #000; }

#scan-live-body {
  flex: 1; position: relative;
  display: flex; flex-direction: column;
}

#qr-reader { width: 100%; flex: 1; }

/* Suppress html5-qrcode chrome */
#qr-reader__dashboard      { display: none !important; }
#qr-reader__scan_region    { border: none !important; }
#qr-reader video           { width: 100% !important; height: 100% !important; object-fit: cover !important; }

.scan-window {
  width: 240px; height: 240px;
  box-shadow: 0 0 0 2000px rgba(0,0,0,0.5);
  position: relative;
}

/* Corner brackets */
.sc {
  position: absolute; width: 26px; height: 26px;
  border-color: var(--accent); border-style: solid;
}
.sc.tl { top: -1px;    left: -1px;  border-width: 3px 0 0 3px; }
.sc.tr { top: -1px;    right: -1px; border-width: 3px 3px 0 0; }
.sc.bl { bottom: -1px; left: -1px;  border-width: 0 0 3px 3px; }
.sc.br { bottom: -1px; right: -1px; border-width: 0 3px 3px 0; }

.scan-beam {
  position: absolute; left: 6px; right: 6px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: beam 2.2s ease-in-out infinite;
}

@keyframes beam {
  0%   { top: 8px; opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { top: calc(100% - 10px); opacity: 0; }
}

.scan-footer {
  flex-shrink: 0; background: rgba(0,0,0,0.88);
  padding: 16px 24px 36px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}

.scan-status-text {
  font-size: 13px; color: rgba(255,255,255,0.5);
  text-align: center; line-height: 1.55; white-space: pre-line;
}

.btn-photo-fallback {
  padding: 13px 28px; background: var(--accent); color: #0c0c0c;
  border: none; border-radius: 100px;
  font-family: 'Bebas Neue', sans-serif; font-size: 18px; letter-spacing: 1.5px;
  cursor: pointer;
}

.btn-cancel-scan {
  padding: 11px 32px;
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.14);
  border-radius: 100px; color: rgba(255,255,255,0.6); font-size: 14px; cursor: pointer;
}

.scan-flash {
  position: fixed; inset: 0;
  background: rgba(245,158,11,0.35);
  opacity: 0; pointer-events: none;
  transition: opacity 0.08s; z-index: 50;
}
.scan-flash.active { opacity: 1; }

/* ══════════════════════════════════════════════
   ASSET DETAIL
══════════════════════════════════════════════ */
.asset-content { padding: 18px; display: flex; flex-direction: column; gap: 13px; padding-bottom: 32px; }

.asset-hero {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r); padding: 20px; position: relative; overflow: hidden;
}
.asset-hero::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 3px; background: var(--accent); opacity: 0.6;
}
.asset-id-tag { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--accent); letter-spacing: 1px; margin-bottom: 8px; }
.asset-name-display { font-size: 28px; font-weight: 600; line-height: 1.15; margin-bottom: 14px; }

.badges-row { display: flex; gap: 7px; flex-wrap: wrap; }
.badge { padding: 4px 10px; border-radius: 100px; font-size: 11.5px; font-weight: 500; }
.b-success { background: rgba(34,197,94,0.14);  color: #22c55e; }
.b-danger  { background: rgba(239,68,68,0.14);  color: #ef4444; }
.b-warning { background: rgba(245,158,11,0.14); color: #f59e0b; }
.b-info    { background: rgba(96,165,250,0.14); color: #60a5fa; }
.b-neutral { background: rgba(255,255,255,0.07); color: var(--text-muted); }

.section-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1.5px; padding: 0 2px; }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.info-tile { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 13px; }
.info-tile-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 5px; }
.info-tile-value { font-size: 14px; font-weight: 500; line-height: 1.3; }
.info-tile-value.mono { font-family: 'IBM Plex Mono', monospace; font-size: 13px; }
.info-tile-value.ok   { color: var(--success); }
.info-tile-value.warn { color: var(--warning); }
.info-tile-value.bad  { color: var(--danger);  }

.full-tile { background: var(--card); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 13px; }
.notes-body { font-size: 14px; color: var(--text-muted); line-height: 1.65; white-space: pre-wrap; margin-top: 4px; }

.not-found-box { padding: 64px 28px; text-align: center; }
.not-found-icon  { font-size: 52px; margin-bottom: 14px; }
.not-found-title { font-size: 19px; font-weight: 600; margin-bottom: 8px; }
.not-found-id    { font-family: 'IBM Plex Mono', monospace; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.not-found-body  { font-size: 14px; color: var(--text-muted); }

/* ══════════════════════════════════════════════
   EDIT / ADD
══════════════════════════════════════════════ */
.edit-content { padding: 18px; display: flex; flex-direction: column; gap: 16px; padding-bottom: 36px; }
.form-section-title { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1.5px; padding: 0 2px; }
.form-block { background: var(--card); border: 1px solid var(--border); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 13px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
.form-input, .form-select, .form-textarea {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 11px 13px;
  color: var(--text); font-family: 'DM Sans', sans-serif; font-size: 15px;
  outline: none; transition: border-color 0.15s; width: 100%; appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--text-dim); }
.form-input[readonly]    { opacity: 0.4; cursor: not-allowed; }
.form-textarea { resize: vertical; min-height: 88px; line-height: 1.55; }
.form-select option { background: #1c1c1c; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ══════════════════════════════════════════════
   ADMIN
══════════════════════════════════════════════ */
.admin-toolbar {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex; gap: 10px; align-items: center; flex-shrink: 0;
}
.search-wrap { flex: 1; position: relative; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-dim); font-size: 14px; pointer-events: none; }
.search-input {
  width: 100%; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 10px 12px 10px 34px;
  color: var(--text); font-family: 'DM Sans', sans-serif; font-size: 14px; outline: none;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-dim); }
.btn-add-asset {
  padding: 10px 16px; background: var(--accent); color: #0c0c0c;
  border: none; border-radius: var(--r-sm);
  font-family: 'Bebas Neue', sans-serif; font-size: 17px; letter-spacing: 1px;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
}
.admin-stats {
  padding: 10px 18px; border-bottom: 1px solid #1a1a1a;
  background: var(--surface); flex-shrink: 0;
  display: flex; gap: 16px; flex-wrap: wrap;
}
.stat-chip { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--text-dim); }
.stat-chip span { color: var(--accent); font-weight: 500; }

.asset-list { padding: 14px 16px; display: flex; flex-direction: column; gap: 9px; }
.list-item {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 13px 14px;
  cursor: pointer; display: flex; align-items: center; gap: 13px;
  transition: border-color 0.15s, background 0.15s;
}
.list-item:active { border-color: var(--accent); background: var(--card-hover); }
.list-icon { width: 42px; height: 42px; background: var(--accent-dim); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.list-info { flex: 1; min-width: 0; }
.list-name { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-meta { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--text-muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-badge { flex-shrink: 0; font-size: 10px; padding: 3px 8px; border-radius: 100px; }
.list-arrow { color: var(--text-dim); font-size: 18px; flex-shrink: 0; }

.empty-state { text-align: center; padding: 70px 28px; color: var(--text-muted); }
.empty-icon { font-size: 52px; margin-bottom: 14px; }
.empty-hint { font-size: 13px; color: var(--text-dim); margin-top: 6px; }

/* ══════════════════════════════════════════════
   BARCODE LABEL
══════════════════════════════════════════════ */
.barcode-content { padding: 20px; display: flex; flex-direction: column; align-items: center; gap: 16px; padding-bottom: 36px; }

.barcode-label-card {
  background: #fff; border-radius: var(--r); border: 1px solid #ddd;
  padding: 28px 32px 20px;
  display: flex; flex-direction: column; align-items: center;
  width: 100%; max-width: 340px;
  min-height: 220px; justify-content: center;
}

#label-render-area { display: flex; align-items: center; justify-content: center; min-height: 200px; width: 100%; }
#label-render-area canvas { max-width: 200px; }
#label-render-area svg    { max-width: 100%; }

.label-asset-id { font-family: 'IBM Plex Mono', monospace; font-size: 14px; color: #111; margin-top: 12px; letter-spacing: 1.5px; }
.label-asset-name { font-size: 12px; color: #666; margin-top: 4px; text-align: center; }

.fmt-toggle-row { display: flex; gap: 10px; width: 100%; max-width: 340px; }
.fmt-toggle-btn {
  flex: 1; padding: 11px; background: transparent;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--text-muted); font-size: 13px; cursor: pointer; transition: all 0.15s;
}
.fmt-toggle-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

.btn-print {
  width: 100%; max-width: 340px; padding: 16px;
  background: var(--accent); color: #0c0c0c; border: none; border-radius: var(--r);
  font-family: 'Bebas Neue', sans-serif; font-size: 22px; letter-spacing: 2px; cursor: pointer;
}
.barcode-hint { font-size: 12px; color: var(--text-dim); text-align: center; max-width: 300px; line-height: 1.6; }

/* ══════════════════════════════════════════════
   LOADER & TOAST
══════════════════════════════════════════════ */
#loader {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65);
  display: none; align-items: center; justify-content: center;
  z-index: 999; backdrop-filter: blur(4px);
}
#loader.show { display: flex; }
.loader-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--r); padding: 28px 36px; text-align: center; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.75s linear infinite; margin: 0 auto 14px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loader-msg { font-size: 14px; color: var(--text-muted); }

#toast {
  position: fixed; bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--card); border: 1px solid var(--border);
  border-radius: 100px; padding: 11px 22px;
  font-size: 14px; color: var(--text); z-index: 1000;
  transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1);
  white-space: nowrap; pointer-events: none;
}
#toast.show  { transform: translateX(-50%) translateY(0); }
#toast.t-success { border-color: var(--success); color: var(--success); }
#toast.t-error   { border-color: var(--danger);  color: var(--danger);  }

/* ══════════════════════════════════════════════
   PRINT
══════════════════════════════════════════════ */
@media print {
  body > *              { visibility: hidden; }
  #print-target,
  #print-target *       { visibility: visible; }
  #print-target {
    position: absolute; top: 0; left: 0;
    background: #fff; padding: 24px; border: 1px solid #ccc;
  }
}