/* EnEx web — Scan experience styled to match the Android app. */
:root {
  --blue: #0878E8;
  --blue-press: #0A63C4;
  --ink: #0F172A;
  --slate: #475569;
  --muted: #64748B;
  --faint: #94A3B8;
  --bg: #F5F7FB;
  --line: #E2E8F0;
  --card: #ffffff;
  --info-bg: #EFF6FF; --info-bd: #BFDBFE; --info-tx: #1D4ED8;
  --err-bg: #FEF2F2; --err-bd: #FECACA; --err-tx: #991B1B;
  --warn-bg: #FFFBEB; --warn-bd: #FDE68A; --warn-tx: #92400E; --warn-tx2: #78350F;
  --good: #16A34A; --neutral: #FEF9C3; --neutral-solid: #FDE68A; --useless: #F97316; --harmful: #EF4444; --banned: #111827;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }

.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px 40px; }

/* top bar */
.topbar { max-width: 720px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; }
.topbar a.back { text-decoration: none; color: var(--blue); font-weight: 700; font-size: 15px; }
.topbar .admin-link { text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14px; border: 1px solid var(--line); padding: 7px 14px; border-radius: 9px; }
.topbar .admin-link:hover { color: var(--blue-press); border-color: var(--blue); }

/* header card */
.hdr-card { background: var(--card); border-radius: 18px; box-shadow: 0 6px 18px rgba(15,23,42,.08); padding: 14px; margin-top: 12px; }
.hdr-row { display: flex; align-items: center; gap: 8px; }
.hdr-brand { display: flex; align-items: center; gap: 8px; flex: 1; cursor: pointer; text-decoration: none; }
.hdr-brand img { width: 42px; height: 42px; border-radius: 10px; object-fit: cover; }
.hdr-brand .word { font-size: 40px; line-height: 40px; font-weight: 900; color: var(--blue); letter-spacing: -1px; }
.hdr-iconbtn { width: 54px; height: 54px; border: none; background: transparent; color: var(--ink); cursor: pointer; border-radius: 12px; display: grid; place-items: center; }
.hdr-iconbtn:hover { background: #F1F5F9; }
.hdr-iconbtn svg { width: 32px; height: 32px; }
.hdr-expand { font-size: 9px; letter-spacing: 1.5px; color: #355C8A; margin: 6px 0 0; }
.hdr-expand b { color: var(--blue); }
.hdr-tag { color: var(--muted); margin: 12px 0 0; font-size: 15px; }

/* tabs */
.tabs-row { display: flex; gap: 6px; background: #fff; border-radius: 12px; padding: 6px; margin: 12px 0; box-shadow: 0 2px 8px rgba(15,23,42,.05); }
.tab-btn { flex: 1; border: none; background: transparent; padding: 10px; border-radius: 9px; font-size: 14px; color: var(--muted); font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.tab-btn.active { color: var(--blue); background: #EAF3FE; font-weight: 800; }
.tab-btn svg { width: 18px; height: 18px; }

/* search field */
.field { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 4px 8px; margin-top: 8px; }
.field:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(8,120,232,.12); }
.field .icon-btn { border: none; background: transparent; cursor: pointer; color: var(--muted); width: 40px; height: 40px; display: grid; place-items: center; border-radius: 8px; }
.field .icon-btn:hover { color: var(--blue); }
.field input { flex: 1; border: none; outline: none; font-size: 15px; padding: 10px 0; background: transparent; color: var(--ink); }

.stack { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }

/* suggestion card */
.sugg { background: #fff; border-radius: 12px; box-shadow: 0 1px 4px rgba(15,23,42,.06); padding: 14px; cursor: pointer; }
.sugg:hover { box-shadow: 0 4px 12px rgba(15,23,42,.1); }
.sugg .name { font-weight: 600; }
.sugg .meta { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* notices */
.notice-info, .notice-err { display: flex; align-items: center; gap: 8px; border-radius: 10px; padding: 12px; font-size: 13px; border: 1px solid; }
.notice-info { background: var(--info-bg); border-color: var(--info-bd); color: var(--info-tx); }
.notice-err { background: var(--err-bg); border-color: var(--err-bd); color: var(--err-tx); }
.notice-info svg, .notice-err svg { width: 20px; height: 20px; flex: none; }

/* generic card */
.card { background: #fff; border-radius: 16px; box-shadow: 0 6px 18px rgba(15,23,42,.07); padding: 16px; }
.card.warn { background: var(--warn-bg); border: 1px solid var(--warn-bd); }
.section-title { font-size: 18px; font-weight: 800; color: var(--ink); margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: none; cursor: pointer; background: var(--blue); color: #fff; font-weight: 800; font-size: 15px; padding: 13px 18px; border-radius: 10px; width: 100%; }
.btn:hover { background: var(--blue-press); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }
.btn-ghost { background: transparent; color: var(--blue); border: 1px solid var(--line); }
.btn-ghost:hover { background: #F1F5F9; }
.btn-outline-danger { background: #fff; color: #DC2626; border: 1px solid var(--line); width: auto; padding: 8px 12px; font-size: 12px; border-radius: 8px; }
.btn svg { flex: none; }

/* collapsible section label (divider with centered pill) */
.sec-label { position: relative; height: 26px; display: flex; align-items: center; justify-content: center; margin: 6px 0; }
.sec-label::before { content: ""; position: absolute; left: 0; right: 0; height: 1px; background: #93C5FD; }
.sec-label .txt { position: relative; background: #fff; padding: 0 10px; font-size: 12px; font-weight: 800; color: var(--info-tx); }
.sec-label .toggle { position: absolute; right: 0; background: #fff; border: none; cursor: pointer; color: var(--info-tx); display: grid; place-items: center; width: 24px; height: 24px; }
.sec-label .toggle svg { width: 20px; height: 20px; }

/* product detail */
.pd-name { font-size: 24px; font-weight: 800; margin: 4px 0; }
.pd-cat { color: #2563EB; font-weight: 700; }
.pd-meta { color: var(--slate); font-size: 14px; margin: 2px 0; }
.pd-desc { margin: 6px 0; }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0; }
.src-chip { display: inline-flex; align-items: center; gap: 4px; background: #F1F5F9; color: var(--slate); font-size: 11px; padding: 4px 8px; border-radius: 50px; }
.src-chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.ver-chip { background: var(--info-bg); color: var(--info-tx); font-size: 11px; font-weight: 700; padding: 4px 8px; border-radius: 50px; }

/* detail tabs (scan result / community added) */
.dtabs { display: flex; width: 100%; }
.dtab { flex: 1; background: transparent; border: none; cursor: pointer; padding: 0; }
.dtab .lbl { display: flex; align-items: center; justify-content: center; gap: 3px; padding: 10px 4px; font-size: 11px; color: var(--muted); }
.dtab.active .lbl { color: var(--blue); font-weight: 800; }
.dtab .count { background: #E0EDFF; color: var(--info-tx); font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 50px; }
.dtab .bar { height: 1px; background: var(--line); }
.dtab.active .bar { height: 3px; background: var(--blue); }

/* scan-ingredients cta */
.scan-cta { display: flex; align-items: center; gap: 8px; background: var(--info-bg); border-radius: 10px; padding: 12px; cursor: pointer; color: var(--info-tx); font-weight: 700; }
.scan-cta svg { width: 26px; height: 26px; }

/* ingredient rows */
.ing-row { display: flex; align-items: center; gap: 6px; padding: 6px 0; border-bottom: 1px solid #F1F5F9; }
.ing-row .nm { flex: 1; font-weight: 600; }
.ing-row .info { border: none; background: transparent; cursor: pointer; color: var(--muted); width: 30px; height: 30px; display: grid; place-items: center; }
.ing-row .info svg { width: 18px; height: 18px; }
.badge { color: #fff; font-size: 11px; padding: 4px 8px; border-radius: 50px; white-space: nowrap; }
.badge.good { background: var(--good); }
.badge.neutral { background: var(--neutral-solid); color: #713F12; }
.badge.useless { background: var(--useless); }
.badge.harmful { background: var(--harmful); }
.badge.banned { background: var(--banned); }

/* at a glance */
.glance { background: #F8FAFC; border-radius: 12px; padding: 12px; margin: 8px 0; }
.glance h4 { margin: 0 0 8px; font-size: 18px; font-weight: 800; }
.glance-bar { display: flex; height: 18px; gap: 1px; border-radius: 3px; overflow: hidden; }
.glance-legend { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 10px; margin-top: 8px; }
.glance-legend .lg { display: flex; align-items: center; gap: 4px; font-size: 11px; color: #334155; }
.glance-legend .lg.empty { color: var(--faint); }
.glance-legend .sw { width: 10px; height: 10px; border-radius: 2px; }
.glance-legend .n { font-weight: 800; }

/* photo capture slots */
.slot { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); background: #F8FAFC; border-radius: 12px; padding: 12px; }
.slot.done { background: #F0FDF4; border-color: #86EFAC; }
.slot .num { width: 52px; height: 52px; border-radius: 8px; background: #E2E8F0; display: grid; place-items: center; font-weight: 800; color: var(--slate); font-size: 18px; overflow: hidden; }
.slot .num img { width: 100%; height: 100%; object-fit: cover; }
.slot .body { flex: 1; min-width: 0; }
.slot .t { font-weight: 800; font-size: 14px; color: #1E293B; display: flex; align-items: center; gap: 4px; }
.slot .s { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot .acts { display: flex; gap: 4px; }
.slot .acts button { border: none; background: transparent; cursor: pointer; color: var(--blue); width: 36px; height: 36px; display: grid; place-items: center; border-radius: 8px; }
.slot .acts button:hover { background: #EAF3FE; }
.slot .acts button svg { width: 22px; height: 22px; }
.slot .check svg { width: 16px; height: 16px; color: var(--good); }

/* ready to scan empty state */
.ready { background: #fff; border-radius: 16px; box-shadow: 0 6px 18px rgba(15,23,42,.07); padding: 24px; text-align: center; margin-top: 12px; }
.ready .big { width: 64px; height: 64px; margin: 0 auto; display: grid; place-items: center; }
.ready .big svg { width: 48px; height: 48px; color: var(--blue); }
.ready h3 { font-size: 18px; font-weight: 800; margin: 12px 0 6px; }
.ready p { color: var(--muted); font-size: 13px; line-height: 18px; margin: 4px 0; }

/* history */
.hist-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 0 4px; }
.hist-head h3 { margin: 0; font-size: 18px; font-weight: 800; }
.hist-card { background: #fff; border-radius: 12px; box-shadow: 0 2px 8px rgba(15,23,42,.06); padding: 14px; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.hist-card .body { flex: 1; min-width: 0; }
.hist-card .nm { font-weight: 700; font-size: 15px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-card .meta { display: flex; align-items: center; gap: 6px; margin-top: 2px; color: var(--muted); font-size: 12px; }
.hist-card .bc { background: #F1F5F9; color: var(--slate); font-size: 10px; padding: 2px 4px; border-radius: 4px; }
.hist-card .time { color: var(--faint); font-size: 11px; margin-top: 2px; }
.hist-card .del { border: none; background: transparent; cursor: pointer; color: var(--faint); width: 32px; height: 32px; display: grid; place-items: center; }
.hist-card .del svg { width: 18px; height: 18px; }

/* scan overlay (camera) */
.cam-overlay { position: fixed; inset: 0; background: #000; z-index: 50; display: flex; flex-direction: column; }
.cam-overlay video { flex: 1; width: 100%; object-fit: cover; }
.cam-top { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: rgba(0,0,0,.5); color: #fff; }
.cam-top b { font-size: 16px; }
.cam-top button { background: transparent; border: none; color: #fff; cursor: pointer; font-size: 22px; }
.cam-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 16px; background: rgba(0,0,0,.55); color: #CBD5E1; font-size: 13px; text-align: center; }
.cam-bottom .btn { max-width: 320px; margin: 10px auto 0; }

/* progress */
.progress { background: #fff; border-radius: 12px; padding: 16px; box-shadow: 0 2px 8px rgba(15,23,42,.06); }
.progress p { margin: 0 0 10px; color: var(--slate); font-size: 14px; }
.progress .track { height: 6px; background: #E2E8F0; border-radius: 50px; overflow: hidden; }
.progress .track > span { display: block; height: 100%; width: 40%; background: var(--blue); border-radius: 50px; animation: slide 1.2s infinite ease-in-out; }
@keyframes slide { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }

/* dialog */
.dlg-back { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: grid; place-items: center; z-index: 60; padding: 20px; }
.dlg { background: #fff; border-radius: 16px; padding: 20px; max-width: 460px; width: 100%; max-height: 80vh; overflow: auto; }
.dlg h3 { margin: 0 0 10px; font-size: 18px; }
.dlg p { margin: 6px 0; }
.dlg .row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.dlg .thumb { width: 100%; height: 150px; object-fit: cover; border-radius: 10px; margin-bottom: 10px; }

.upload-field { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.upload-field input[type=file] { font-size: 13px; }
.form-error { color: #DC2626; font-size: 13px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 24px 0 0; }
