/* MPU AI — PanelScore-inspired mobile-first dark UI */
:root {
  --bg: #0b1020;
  --bg2: #121a30;
  --card: #182238;
  --card2: #1f2c47;
  --line: #2a3a5c;
  --txt: #eef2fa;
  --mut: #93a3c4;
  --acc: #3b82f6;
  --acc2: #60a5fa;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --rev: #a78bfa;
  --gold: #f59e0b;
  --r: 14px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--txt);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  text-rendering: optimizeLegibility;
}
@media (display-mode: standalone) {
  body { user-select: none; -webkit-user-select: none; }
  input, select, textarea { user-select: text; -webkit-user-select: text; }
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding: calc(var(--sat) + 10px) 16px calc(var(--sab) + 18px);
}

.screen { display: none; flex-direction: column; flex: 1; animation: fade .18s ease; }
.screen.active { display: flex; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 0 14px;
  gap: 8px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 19px; letter-spacing: .2px;
}
.brand.small { font-size: 16px; }
.brand .bolt {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--gold), #d97706);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  color: #0b1020; flex: none;
}
.brand .subl { font-size: 10px; color: var(--mut); font-weight: 500; }
.topbar-actions { display: flex; gap: 8px; }
.iconbtn {
  background: var(--card); border: 1px solid var(--line);
  color: var(--mut); border-radius: 12px; width: 44px; height: 44px;
  font-size: 19px; display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.iconbtn:active { background: var(--card2); }

/* Hero */
.hero { padding: 6px 0 14px; }
h1 { font-size: 30px; line-height: 1.1; margin-bottom: 8px; letter-spacing: -0.4px; }
h2 { font-size: 19px; margin-bottom: 10px; }
h3 { font-size: 13px; margin-bottom: 10px; color: var(--mut); text-transform: uppercase; letter-spacing: .4px; font-weight: 700; }
.sub { color: var(--mut); font-size: 15px; margin-bottom: 16px; line-height: 1.45; }

/* Cards & buttons */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 12px; }
.timeline-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; margin-bottom: 16px; }
.kvline { display: flex; justify-content: space-between; font-size: 14px; color: var(--mut); padding: 4px 0; }
.kvline b { color: var(--txt); }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 54px; border: 0; border-radius: var(--r);
  font-size: 17px; font-weight: 700; cursor: pointer; color: #fff;
  background: var(--card); border: 1px solid var(--line);
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.primary { background: linear-gradient(135deg, var(--acc), #6366f1); border: 0; box-shadow: 0 4px 18px rgba(59,130,246,.25); }
.btn.gold { background: linear-gradient(135deg, var(--gold), #d97706); color: #0b1020; border: 0; box-shadow: 0 4px 18px rgba(245,158,11,.25); }
.btn.sec { background: var(--card); border: 1px solid var(--line); color: var(--txt); }
.btn.ghost { background: transparent; border: 1px dashed var(--line); color: var(--mut); min-height: 46px; font-weight: 600; }
.btn.danger { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.btn.small { min-height: 40px; font-size: 14px; width: auto; padding: 0 14px; border-radius: 10px; }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.spacer { flex: 1; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }
.center { text-align: center; }

label { display: block; font-size: 13px; font-weight: 700; color: var(--mut); margin: 0 0 6px; text-transform: uppercase; letter-spacing: .4px; }
input, select, textarea {
  width: 100%; background: var(--bg2); border: 1px solid var(--line); color: var(--txt);
  border-radius: 10px; padding: 13px 12px; font-size: 16px; outline: none;
  -webkit-appearance: none; appearance: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--acc); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
textarea { min-height: 80px; resize: vertical; }
select { background-image: linear-gradient(45deg, transparent 50%, var(--mut) 50%), linear-gradient(135deg, var(--mut) 50%, transparent 50%); background-position: calc(100% - 18px) 22px, calc(100% - 12px) 22px; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 32px; }

.field { margin-bottom: 14px; }
.seg {
  display: flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
}
.seg button {
  flex: 1; background: transparent; border: 0; color: var(--mut);
  padding: 13px 4px; font-size: 15px; font-weight: 700; cursor: pointer;
  transition: background 0.15s;
}
.seg button.on { background: var(--acc); color: #fff; }

.stepdots { display: flex; gap: 6px; justify-content: center; margin: 8px 0 14px; }
.stepdots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); transition: all 0.2s; }
.stepdots i.on { background: var(--acc); width: 22px; border-radius: 4px; }

/* Camera */
.camwrap {
  position: relative; border-radius: var(--r); overflow: hidden;
  background: #000; aspect-ratio: 3/4; margin-bottom: 12px;
}
.camwrap video, .camwrap img.preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.overlay { position: absolute; inset: 0; pointer-events: none; }
.overlay svg { width: 100%; height: 100%; }
.camhint {
  position: absolute; left: 10px; right: 10px; bottom: 10px;
  background: rgba(10,14,28,.78); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border-radius: 10px; padding: 9px 12px; font-size: 13.5px; color: #dbe5f7; text-align: center;
}
.camtools { position: absolute; top: 10px; right: 10px; display: flex; flex-direction: column; gap: 8px; }
.camtools button {
  width: 42px; height: 42px; border-radius: 50%; border: 0;
  background: rgba(10,14,28,.7); color: #fff; font-size: 17px; cursor: pointer;
}
.shutter {
  width: 74px; height: 74px; border-radius: 50%; border: 5px solid #fff;
  background: rgba(255,255,255,.25); margin: 0 auto; cursor: pointer;
  transition: all 0.15s;
}
.shutter:active { background: #fff; transform: scale(0.95); }

.shotmeta { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.shotnum {
  min-width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, var(--acc), #6366f1);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px;
}

.thumbs { display: flex; gap: 8px; margin: 0 0 10px; flex-wrap: wrap; }
.thumbs .t {
  width: 56px; height: 56px; border-radius: 10px;
  background: var(--bg2); border: 1px solid var(--line); overflow: hidden; position: relative;
  display: flex; align-items: center; justify-content: center; color: var(--mut); font-size: 18px;
}
.thumbs .t img { width: 100%; height: 100%; object-fit: cover; }
.thumbs .t.done::after {
  content: "✓"; position: absolute; right: 2px; bottom: -2px; color: var(--ok);
  font-weight: 900; text-shadow: 0 0 4px #000; font-size: 14px;
}
.thumbs .t.active { border-color: var(--acc); box-shadow: 0 0 0 2px rgba(59,130,246,.4); }

.qwarn {
  background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.4); color: #fcd34d;
  border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 10px;
}

/* Analyzing */
.steps { margin: 18px 0; }
.steps .s {
  display: flex; align-items: center; gap: 12px; padding: 11px 0;
  color: var(--mut); font-size: 15.5px;
}
.steps .s .ic {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line);
  display: flex; align-items: center; justify-content: center; font-size: 13px; flex: none;
}
.steps .s.run { color: var(--txt); }
.steps .s.run .ic { border-color: var(--acc); animation: pulse 1s infinite; }
.steps .s.ok { color: var(--txt); }
.steps .s.ok .ic { border-color: var(--ok); background: var(--ok); color: #06270f; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(59,130,246,.18); } }
.spin {
  width: 46px; height: 46px; border: 4px solid var(--line);
  border-top-color: var(--acc); border-radius: 50%;
  animation: rot .8s linear infinite; margin: 26px auto 8px;
}
@keyframes rot { to { transform: rotate(360deg); } }

/* Result */
.verdict { border-radius: var(--r); padding: 20px 16px; text-align: center; margin-bottom: 14px; border: 1px solid; }
.verdict .v { font-size: 24px; font-weight: 900; letter-spacing: .6px; }
.verdict .d { font-size: 14px; margin-top: 5px; opacity: .85; line-height: 1.4; }
.v-QUALIFIED { background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.5); color: #86efac; }
.v-UPGRADE { background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.5); color: #fcd34d; }
.v-DQ { background: rgba(239,68,68,.13); border-color: rgba(239,68,68,.55); color: #fca5a5; }
.v-REVIEW { background: rgba(167,139,250,.12); border-color: rgba(167,139,250,.5); color: #c4b5fd; }

.dial { display: flex; align-items: center; gap: 16px; }
.dial svg { flex: none; }

.facts { width: 100%; border-collapse: collapse; }
.facts td { padding: 8px 4px; font-size: 15px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.facts td:first-child { color: var(--mut); font-size: 13.5px; width: 42%; }
.facts tr:last-child td { border-bottom: 0; }
.conf { font-size: 11px; padding: 2px 7px; border-radius: 99px; margin-left: 6px; font-weight: 700; }
.conf.hi { background: rgba(34,197,94,.15); color: #86efac; }
.conf.lo { background: rgba(239,68,68,.15); color: #fca5a5; }
.factedit {
  background: transparent; border: 0; border-bottom: 1px dashed var(--line);
  color: var(--txt); font-size: 15px; width: 100%; padding: 2px 0; border-radius: 0;
  text-align: right;
}
.factedit:focus { border-color: var(--acc); outline: none; }
.factselect { background: var(--bg2); border: 1px solid var(--line); color: var(--txt); font-size: 14px; padding: 4px 6px; border-radius: 6px; }

.rule { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; align-items: flex-start; }
.rule:last-child { border: 0; }
.rule .tag {
  flex: none; font-size: 10px; font-weight: 800; padding: 3px 8px;
  border-radius: 7px; margin-top: 1px; letter-spacing: 0.4px;
}
.tag.dq { background: rgba(239,68,68,.18); color: #fca5a5; }
.tag.upgrade { background: rgba(245,158,11,.18); color: #fcd34d; }
.tag.deduct { background: rgba(96,165,250,.15); color: #93c5fd; }
.tag.note { background: rgba(147,163,196,.15); color: var(--mut); }

.hist { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.hist img { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; background: var(--bg2); }
.hist .hv { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 7px; letter-spacing: 0.4px; }

.list-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 99px;
  padding: 6px 11px; font-size: 14px; margin: 0 6px 6px 0;
}
.list-pill b { cursor: pointer; color: var(--bad); font-size: 15px; }

/* Admin */
.adm-section { margin-bottom: 8px; }
.adm-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 15px 2px; cursor: pointer; font-weight: 700; font-size: 16px;
  border-bottom: 1px solid var(--line);
}
.adm-body { display: none; padding: 14px 2px 6px; }
.adm-section.open .adm-body { display: block; }
.adm-head .car { color: var(--mut); transition: .15s; }
.adm-section.open .car { transform: rotate(90deg); }
.mini { font-size: 13px; color: var(--mut); margin: 4px 0 10px; line-height: 1.4; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--sab) + 24px); transform: translateX(-50%);
  background: #fff; color: #0b1020; font-weight: 700; font-size: 14.5px;
  padding: 12px 20px; border-radius: 99px; box-shadow: 0 8px 30px rgba(0,0,0,.5);
  opacity: 0; pointer-events: none; transition: .25s; z-index: 99;
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; }

.footer-note { text-align: center; color: var(--mut); font-size: 12.5px; margin-top: auto; padding-top: 18px; line-height: 1.4; }

.pinpad input { text-align: center; font-size: 28px; letter-spacing: 12px; font-weight: 800; }
.customrule {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px; margin-bottom: 8px; font-size: 13.5px;
}
.customrule .x { float: right; color: var(--bad); font-weight: 800; cursor: pointer; padding: 0 4px; }
.code-inline { background: var(--bg2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* Result extras */
.why-list { display: flex; flex-direction: column; gap: 0; }
.why-list .rule { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; align-items: flex-start; line-height: 1.45; }
.why-list .rule:last-child { border: 0; }
.why-list .rule b { display: block; }
.why-list .rule .mut { color: var(--mut); font-size: 12.5px; margin-top: 2px; }

.corr-input {
  background: var(--bg2); border: 1px solid var(--line); color: var(--txt);
  border-radius: 6px; padding: 3px 6px; font-size: 14px; max-width: 120px;
  text-align: right;
}
.corr-input:focus { border-color: var(--acc); outline: none; }

.notice-banner {
  margin-top: 8px; padding: 10px 12px; border-radius: 10px;
  background: rgba(167,139,250,.12); border: 1px solid rgba(167,139,250,.4);
  color: #c4b5fd; font-size: 13.5px; line-height: 1.4;
}
.warn-banner {
  margin-top: 8px; padding: 10px 12px; border-radius: 10px;
  background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.4);
  color: #fcd34d; font-size: 13.5px; line-height: 1.4;
}
.danger-banner {
  margin-top: 8px; padding: 10px 12px; border-radius: 10px;
  background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.4);
  color: #fca5a5; font-size: 13.5px; line-height: 1.4;
}
.ok-banner {
  margin-top: 8px; padding: 10px 12px; border-radius: 10px;
  background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.4);
  color: #86efac; font-size: 13.5px; line-height: 1.4;
}

/* PWA install */
.install-hint {
  position: fixed; bottom: calc(var(--sab) + 18px); left: 16px; right: 16px; max-width: 528px; margin: 0 auto;
  background: var(--card); border: 1px solid var(--gold); border-radius: 12px;
  padding: 12px 14px; display: flex; align-items: center; gap: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,.4); z-index: 50;
}
.install-hint .close { color: var(--mut); background: none; border: 0; font-size: 20px; cursor: pointer; }
.install-hint b { color: var(--gold); }
.install-hint .spacer { flex: 1; }

/* responsive tweaks */
@media (max-width: 360px) {
  h1 { font-size: 26px; }
  .brand { font-size: 17px; }
}
