/* ===================== Tag Verify — styles ===================== */
:root {
  --bg: #0a0a0b;
  --surface: #141417;
  --surface-2: #1c1c21;
  --border: #292930;
  --text: #f5f5f7;
  --muted: #9a9aa4;
  --muted-2: #6c6c76;
  --accent: #10b981;
  --accent-ink: #052e22;
  /* action CTAs — deep indigo, deliberately NOT green (green = status/verified) */
  --cta: #4f46e5;
  --cta-ink: #ffffff;
  --cta-grad-a: #6366f1;
  --cta-grad-b: #4338ca;
  --green: #22c55e;
  --green-bg: rgba(34,197,94,.12);
  --red: #f05252;
  --red-bg: rgba(240,82,82,.12);
  --amber: #f5a524;
  --amber-bg: rgba(245,165,36,.13);
  --slate: #7c8694;
  --slate-bg: rgba(124,134,148,.12);
  --radius: 16px;
  --radius-sm: 11px;
  --header-h: 56px;
  --nav-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --shadow: 0 8px 30px rgba(0,0,0,.45);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
h1,h2,h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: .86em; color: #cbd5cf; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.center-text { text-align: center; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 30;
  height: calc(var(--header-h) + var(--safe-top));
  padding: var(--safe-top) 16px 0;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(10,10,11,.86);
  backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(160deg, #13a06f, #0a7a55);
}
.brand-text { min-width: 0; }
.brand-text h1 { font-size: 17px; line-height: 1.1; }
.master-chip { display: block; font-size: 12px; line-height: 1.3; }
.master-chip.ok { color: var(--green); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 12px 16px; font-size: 15px; font-weight: 600; cursor: pointer;
  color: var(--text); background: var(--surface-2); transition: transform .06s ease, background .15s ease, opacity .15s;
  user-select: none;
}
.btn:active { transform: scale(.975); }
.btn-lg { padding: 15px 18px; font-size: 16px; width: 100%; }
.btn-primary { background: var(--cta); color: var(--cta-ink); border-color: transparent; }
.btn-primary:active { background: #4338ca; }
.btn-ghost { background: var(--surface); border-color: var(--border); }
.btn-danger { background: transparent; color: var(--red); border-color: rgba(240,82,82,.4); }
.btn-scan {
  background: linear-gradient(145deg, var(--cta-grad-a), var(--cta-grad-b));
  color: #fff; border: none; font-weight: 700; font-size: 17px;
  box-shadow: 0 6px 22px rgba(79,70,229,.45), inset 0 1px 0 rgba(255,255,255,.2);
}
.btn-scan svg { stroke-width: 2.4; }
.btn-scan:active { background: linear-gradient(145deg, #5257e0, #3a2fb0); box-shadow: 0 3px 12px rgba(79,70,229,.34); }
.btn-col { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.icon-btn { background: transparent; border: none; color: var(--muted); padding: 8px; border-radius: 10px; cursor: pointer; display: grid; place-items: center; }
.icon-btn:active { background: var(--surface-2); color: var(--text); }
.link-btn { background: none; border: none; color: var(--accent); font-size: 14px; font-weight: 600; cursor: pointer; padding: 4px; }

/* ---------- layout ---------- */
#main { padding: 16px 16px calc(var(--nav-h) + var(--safe-bottom) + 20px); max-width: 640px; margin: 0 auto; }
.tab-panel { animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- empty state ---------- */
.empty-state { text-align: center; padding: 44px 8px 10px; }
.empty-icon { width: 76px; height: 76px; margin: 0 auto 18px; border-radius: 20px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); color: var(--accent); }
.empty-state h2 { font-size: 20px; margin-bottom: 8px; }
.empty-state p { margin: 0 auto 20px; max-width: 330px; }
.empty-state .hint { margin-top: 16px; font-size: 13px; }

/* ---------- stats strip ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 15px 10px 13px; display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer;
  color: var(--text);
}
.stat:active { background: var(--surface-2); }
.stat-num { font-size: 28px; font-weight: 740; letter-spacing: -0.02em; line-height: 1; }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat-verified .stat-num { color: var(--green); }
.stat-pending  .stat-num { color: var(--slate); }
.stat-notfound .stat-num { color: var(--red); }
.stat-dup      .stat-num { color: var(--amber); }

.progress-wrap { display: flex; align-items: center; gap: 10px; margin: 12px 2px 18px; }
.progress { flex: 1; height: 7px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg, #13a06f, #22c55e); border-radius: 99px; transition: width .4s ease; }
.progress-wrap span { font-size: 12px; white-space: nowrap; }

/* ---------- entry ---------- */
.entry { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.entry-row { display: flex; gap: 8px; }
.tag-input {
  flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 14px 15px; font-size: 17px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase;
}
.tag-input::placeholder { color: var(--muted-2); font-weight: 500; letter-spacing: 0; text-transform: none; }
.tag-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(16,185,129,.18); }
.entry-row .btn { flex: none; }

/* ---------- result card ---------- */
.result-card { border-radius: var(--radius); padding: 18px; margin-bottom: 20px; border: 1px solid var(--border); background: var(--surface); animation: pop .22s cubic-bezier(.2,.8,.3,1.1); }
@keyframes pop { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
.result-card.matched   { border-color: rgba(34,197,94,.45);  background: linear-gradient(180deg, var(--green-bg), var(--surface) 60%); }
.result-card.notfound  { border-color: rgba(240,82,82,.45);  background: linear-gradient(180deg, var(--red-bg), var(--surface) 60%); }
.result-card.duplicate { border-color: rgba(245,165,36,.5);  background: linear-gradient(180deg, var(--amber-bg), var(--surface) 60%); }
.rc-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.rc-label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.rc-tag { font-size: 34px; font-weight: 780; letter-spacing: .01em; word-break: break-all; line-height: 1.1; }
.rc-status { display: inline-flex; align-items: center; gap: 6px; font-size: 17px; font-weight: 800; padding: 8px 16px; border-radius: 99px; white-space: nowrap; text-transform: uppercase; letter-spacing: .05em; }
.rc-status.matched   { color: var(--green); background: var(--green-bg); }
.rc-status.notfound  { color: var(--red);   background: var(--red-bg); }
.rc-status.duplicate { color: var(--amber); background: var(--amber-bg); }
.rc-fields { margin-top: 14px; border-top: 1px solid var(--border); }
.rc-field { display: flex; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.rc-field:last-child { border-bottom: none; }
.rc-field .k { color: var(--muted); font-size: 14px; flex: none; max-width: 45%; }
.rc-field .v { text-align: right; font-weight: 600; word-break: break-word; }
.rc-note { margin-top: 12px; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.rc-note.matched { color: var(--green); }
.rc-note.notfound { color: var(--red); }
.rc-note.duplicate { color: var(--amber); }

/* ---------- lists / records ---------- */
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 2px 10px; }
.section-head h3 { font-size: 15px; }
.record-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.record {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer;
}
.record:active { background: var(--surface-2); }
.rec-main { min-width: 0; flex: 1; }
.rec-tag { font-weight: 680; font-size: 15px; letter-spacing: .02em; word-break: break-all; }
.rec-sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.rec-time { font-size: 11px; color: var(--muted-2); }
.pill { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.pill.verified  { color: var(--green); background: var(--green-bg); }
.pill.pending   { color: var(--slate); background: var(--slate-bg); }
.pill.not_found { color: var(--red);   background: var(--red-bg); }
.pill.duplicate { color: var(--amber); background: var(--amber-bg); }

.recent { margin-top: 8px; }

/* ---------- records tab ---------- */
.records-head { position: sticky; top: calc(var(--header-h) + var(--safe-top)); z-index: 10; background: var(--bg); padding-top: 4px; margin: -4px -2px 10px; padding-left: 2px; padding-right: 2px; }
.search-input { width: 100%; background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 16px; margin-bottom: 10px; }
.search-input:focus { outline: none; border-color: var(--accent); }
.filter-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.filter-chips::-webkit-scrollbar { display: none; }
.chip { flex: none; background: var(--surface); border: 1px solid var(--border); color: var(--muted); border-radius: 99px; padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer; }
.chip.active { background: var(--accent); color: #042016; border-color: transparent; }
.records-meta { font-size: 12.5px; margin: 2px 2px 10px; }

/* ---------- cards (export tab) ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card h3 { font-size: 15px; margin-bottom: 8px; }
.card p { margin: 0 0 4px; font-size: 14px; }
.danger-card { border-color: rgba(240,82,82,.22); }
.kv-list { font-size: 14px; display: flex; flex-direction: column; gap: 6px; }
.kv-list .row { display: flex; justify-content: space-between; gap: 12px; }
.kv-list .row .v { color: var(--text); font-weight: 600; text-align: right; word-break: break-word; }
.version { text-align: center; font-size: 12px; margin-top: 18px; }

/* ---------- bottom nav ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: rgba(10,10,11,.9); backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.nav-btn { background: none; border: none; color: var(--muted-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; cursor: pointer; }
.nav-btn.active { color: var(--accent); }
.nav-btn svg { opacity: .9; }

/* ---------- camera modal ---------- */
.modal { position: fixed; inset: 0; z-index: 60; background: #000; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: calc(var(--safe-top) + 10px) 16px 10px; color: #fff; }
.modal-title { font-weight: 650; font-size: 16px; }
.reader { flex: 1; min-height: 0; overflow: hidden; background: #000; }
.reader video { width: 100% !important; height: 100% !important; object-fit: cover; }
.scan-feedback { min-height: 46px; padding: 6px 16px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; }
.scan-feedback .pill { font-size: 12px; }
.modal-foot { text-align: center; padding: 8px 16px calc(var(--safe-bottom) + 16px); font-size: 13px; }

.center-modal { background: rgba(0,0,0,.6); align-items: center; justify-content: center; padding: 20px; }
.col-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; width: 100%; max-width: 380px; }
.col-card h3 { font-size: 17px; margin-bottom: 6px; }
.col-card p { font-size: 14px; margin-bottom: 14px; }
.select { width: 100%; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm); padding: 12px; font-size: 16px; margin-bottom: 4px; }

/* ---------- detail sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 70; display: flex; align-items: flex-end; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); animation: fade .2s ease; }
.sheet-body {
  position: relative; width: 100%; max-height: 82vh; overflow-y: auto;
  background: var(--surface); border-radius: 22px 22px 0 0; padding: 10px 18px calc(var(--safe-bottom) + 22px);
  border-top: 1px solid var(--border); animation: slideup .26s cubic-bezier(.2,.8,.2,1);
}
@keyframes slideup { from { transform: translateY(100%); } to { transform: none; } }
.sheet-body::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 99px; background: var(--border); margin: 6px auto 16px; }
.sheet-tag { font-size: 24px; font-weight: 740; word-break: break-all; }
.sheet-fields { margin-top: 14px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-bottom) + 18px); transform: translateX(-50%);
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  padding: 11px 18px; border-radius: 12px; font-size: 14px; font-weight: 600; z-index: 90;
  box-shadow: var(--shadow); max-width: 90vw; text-align: center; animation: toastin .2s ease;
}
.toast.good { border-color: rgba(34,197,94,.5); }
.toast.bad  { border-color: rgba(240,82,82,.5); }
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (min-width: 560px) { .rc-tag { font-size: 40px; } }
