:root {
  --bg: #0f1115;
  --panel: #181b22;
  --panel-2: #1f232c;
  --line: #2b303b;
  --text: #f2f4f8;
  --muted: #9aa3b2;
  --accent: #ffcc33;     /* electrical amber */
  --accent-d: #e0a800;
  --ok: #45c47a;
  --bad: #ff5d5d;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.4;
}

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: max(env(safe-area-inset-top), 12px) 16px 12px;
  background: linear-gradient(180deg, #14171d, #0f1115);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .3px; }
.brand .bolt { color: var(--accent); }
.region { font-size: 12px; color: var(--muted); border: 1px solid var(--line); padding: 4px 8px; border-radius: 999px; }

#app { padding: 16px 16px 24px; max-width: 640px; margin: 0 auto; }

.screen h1 { font-size: 24px; margin: 8px 0 2px; }
.screen .sub { color: var(--muted); margin: 0 0 14px; font-size: 14px; }
.section-h { font-size: 19px; margin: 26px 0 8px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card.warn { border-color: var(--bad); margin-top: 14px; }
.card.warn p { margin: 0; font-size: 14.5px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 380px) { .grid2 { grid-template-columns: 1fr; } }

label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
label.full { grid-column: 1 / -1; }
label span { font-weight: 500; opacity: .7; }

input, select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 13px 12px;
  font-size: 17px;
  width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

.row { display: flex; gap: 10px; margin-top: 14px; }
.btn {
  flex: 1;
  background: var(--accent);
  color: #1a1400;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}
.btn:active { background: var(--accent-d); }
.btn.big { width: 100%; padding: 20px; font-size: 18px; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.ghost.full-w { flex: 1; }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid var(--bad); }
.danger-text { color: var(--bad); }

.result {
  margin: 16px 0 0; padding: 14px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line);
  font-size: 15px; white-space: pre-line;
}
.result:empty { display: none; }
.result.ok { border-color: var(--ok); }
.result.bad { border-color: var(--bad); }
.result b { color: var(--accent); }

.clause { color: var(--muted); font-size: 12.5px; margin: 12px 4px 0; line-height: 1.5; }

/* Scan queue */
#scan-queue { margin-top: 4px; }
.q-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-top: 1px solid var(--line); margin-top: 10px;
  font-size: 14px;
}
.q-item:first-child { border-top: none; }
.q-item img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.q-item .q-state { color: var(--muted); }
.q-item.done .q-state { color: var(--ok); }
.q-item.fail .q-state { color: var(--bad); }

/* Filters + list */
.filters { margin-bottom: 14px; display: flex; flex-direction: column; gap: 12px; }
#flt-search { font-size: 16px; }

.r-row {
  display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; margin-bottom: 8px; cursor: pointer;
}
.r-row:active { background: var(--panel-2); }
.r-row img { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.r-row .r-main { min-width: 0; }
.r-row .r-merchant { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-row .r-meta { font-size: 12px; color: var(--muted); }
.r-row .r-total { font-weight: 800; color: var(--accent); font-size: 16px; }
.r-empty { color: var(--muted); text-align: center; padding: 30px 0; font-size: 14px; }

/* Totals */
.stat-row { display: flex; gap: 10px; margin: 14px 0; }
.stat { flex: 1; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; text-align: center; }
.stat-label { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stat-val { display: block; font-size: 20px; font-weight: 800; color: var(--accent); margin-top: 2px; }

.bar-row { display: grid; grid-template-columns: 110px 1fr auto; gap: 10px; align-items: center; padding: 6px 0; font-size: 13.5px; }
.bar-row .bar-label { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .bar { height: 10px; border-radius: 5px; background: var(--accent); min-width: 2px; }
.bar-row .bar-val { font-weight: 700; }

/* Detail dialog */
dialog#detail {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); color: var(--text);
  width: min(92vw, 560px); padding: 0; margin: auto;
}
dialog#detail::backdrop { background: rgba(0, 0, 0, .6); }
.detail-card { padding: 16px; }
.detail-head { position: relative; margin-bottom: 14px; }
.detail-head img { width: 100%; max-height: 180px; object-fit: contain; border-radius: 10px; background: var(--panel-2); }
.detail-head img[src=""] { display: none; }
.close-x {
  position: absolute; top: 8px; right: 8px;
  background: rgba(15, 17, 21, .8); color: var(--text);
  border: 1px solid var(--line); border-radius: 999px;
  width: 34px; height: 34px; cursor: pointer;
}
.d-items { margin-top: 14px; font-size: 13.5px; color: var(--muted); }
.d-items .d-item { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.d-items .d-item:last-child { border-bottom: none; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: space-around;
  background: #14171d; border-top: 1px solid var(--line);
  padding: 6px 4px max(env(safe-area-inset-bottom), 6px);
}
.tab {
  flex: 1; background: none; border: none; color: var(--muted);
  font-size: 11px; font-weight: 600; padding: 6px 2px;
  display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer;
}
.tab span { font-size: 18px; }
.tab.active { color: var(--accent); }

.disclaimer {
  max-width: 640px; margin: 8px auto 96px; padding: 0 24px;
  text-align: center; font-size: 11px; color: var(--muted); opacity: .85;
}
