/* Kooler King — True Date Finder
   Work-truck utility UI. Mobile-first. Committed dark, clean light fallback.
   No external fonts/CDNs. System font stack only. */

:root {
  --bg: #12151a;
  --bg-2: #171b22;
  --panel: #1b2130;
  --panel-2: #212838;
  --panel-line: #2c3446;
  --ink: #eef2f7;
  --ink-dim: #a7b0c0;
  --ink-faint: #7a8399;
  --yellow: #f5c518;
  --yellow-ink: #1a1300;
  --yellow-press: #d9ad0d;
  --blue: #2b5cff;
  --blue-soft: rgba(43, 92, 255, 0.16);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.16);
  --danger: #ff5a4d;
  --danger-soft: rgba(255, 90, 77, 0.14);
  --field-white: #f4f7fb;
  --field-ink: #12151a;
  --radius: 14px;
  --radius-lg: 20px;
  --tap: 52px;
  --maxw: 560px;
  --shadow: 0 8px 26px rgba(0, 0, 0, 0.4);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
  line-height: 1.4;
  font-size: 17px;
  padding-bottom: env(safe-area-inset-bottom);
}

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 14px 16px 28px;
}

.wrap.has-sticky { padding-bottom: 120px; }

/* ---------- Top bar / nav ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 2px 14px;
}

.iconbtn {
  min-width: var(--tap);
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  color: var(--ink);
  border-radius: 12px;
  font-size: 24px;
  text-decoration: none;
  cursor: pointer;
  flex: 0 0 auto;
}
.iconbtn:active { background: var(--panel-2); }

.flip-pill {
  margin-left: auto;
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  color: var(--ink);
  border-radius: 999px;
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
}
.flip-pill:active { background: var(--panel-2); }
.flip-pill .arrow { color: var(--yellow); font-size: 18px; line-height: 1; }

/* ---------- Brand ---------- */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 2px 18px;
}
.brand .crown { flex: 0 0 auto; width: 40px; height: 40px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name {
  font-weight: 900;
  letter-spacing: 0.14em;
  font-size: 19px;
  text-transform: uppercase;
}
.brand-sub {
  color: var(--yellow);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.page-title {
  font-size: 26px;
  font-weight: 900;
  margin: 2px 2px 6px;
  letter-spacing: -0.01em;
}
.page-lede {
  color: var(--ink-dim);
  margin: 0 2px 20px;
  font-size: 15px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: var(--tap);
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-family: var(--font);
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  color: var(--ink);
  background: var(--panel);
  -webkit-tap-highlight-color: transparent;
}
.btn + .btn { margin-top: 12px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn[aria-disabled="true"] { opacity: 0.45; cursor: default; }

.btn-primary {
  background: var(--yellow);
  color: var(--yellow-ink);
  border-color: var(--yellow);
  font-size: 19px;
  letter-spacing: 0.01em;
}
.btn-primary:active { background: var(--yellow-press); }

.btn-secondary {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--panel-line);
}
.btn-secondary:active { background: var(--panel-2); }

.btn-blue {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
.btn-ghost {
  background: transparent;
  border-color: var(--panel-line);
  color: var(--ink);
}
.btn-lg { min-height: 64px; font-size: 20px; }
.btn-ico { width: 24px; height: 24px; flex: 0 0 auto; }

/* ---------- Cards ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 14px; }

/* Home tool cards */
.tool-card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow);
  cursor: pointer;
}
.tool-card + .tool-card { margin-top: 16px; }
.tool-card:active { background: var(--panel-2); }
.tool-card .tc-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.tool-card .tc-badge {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--yellow);
  color: var(--yellow-ink);
}
.tool-card .tc-badge svg { width: 26px; height: 26px; }
.tool-card h2 { margin: 0; font-size: 21px; font-weight: 900; }
.tool-card p { margin: 0; color: var(--ink-dim); font-size: 15px; }
.tool-card .tc-go {
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--yellow);
  font-weight: 800;
  font-size: 15px;
}
.tool-card .tc-go .arrow { font-size: 18px; }

/* ---------- Sections / flow ---------- */
.hidden { display: none !important; }

.section-label {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  margin: 0 2px 10px;
}

/* Camera / capture */
.capture-hint {
  color: var(--ink-dim);
  font-size: 14px;
  text-align: center;
  margin: 14px 4px 0;
}
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* Preview */
.preview-frame {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--panel-line);
  background: #000;
  overflow: hidden;
  margin-bottom: 14px;
}
.preview-frame img { display: block; width: 100%; height: auto; }

/* Reading / spinner */
.reading {
  text-align: center;
  padding: 34px 12px;
}
.spinner {
  width: 46px;
  height: 46px;
  margin: 0 auto 18px;
  border-radius: 50%;
  border: 5px solid var(--panel-line);
  border-top-color: var(--yellow);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.reading h3 { margin: 0 0 6px; font-size: 20px; font-weight: 800; }
.reading p { margin: 0; color: var(--ink-dim); font-size: 14px; }

/* Serial editor */
.serial-edit { margin-bottom: 14px; }
.serial-edit label {
  display: block;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  margin-bottom: 8px;
}
input[type="text"],
input[type="password"],
input[type="tel"] {
  width: 100%;
  min-height: var(--tap);
  background: var(--field-white);
  color: var(--field-ink);
  border: 2px solid var(--panel-line);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-family: var(--font);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 0.08em;
}
input:focus {
  outline: none;
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px rgba(245, 197, 24, 0.28);
}
.serial-edit .hint { margin: 8px 2px 0; color: var(--ink-dim); font-size: 13px; }

/* ---------- Hero result ---------- */
.hero {
  text-align: center;
  padding: 26px 18px 22px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.hero .hero-cap {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--yellow);
  margin-bottom: 6px;
}
.hero .hero-year {
  font-size: 84px;
  line-height: 0.94;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.hero .hero-date {
  margin-top: 10px;
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
}
.badge-verified {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 14px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: #9db6ff;
  border: 1px solid rgba(43, 92, 255, 0.5);
  font-weight: 800;
  font-size: 14px;
}
.badge-verified .chk { color: var(--blue); font-size: 16px; }

/* Hero failure state */
.hero.fail { background: var(--panel); }
.hero.fail .fail-icon {
  font-size: 40px;
  line-height: 1;
  margin-bottom: 10px;
}
.hero.fail h3 { margin: 0 0 6px; font-size: 20px; font-weight: 800; color: var(--ink); }
.hero.fail p { margin: 0 0 16px; color: var(--ink-dim); font-size: 14px; }
.hero.fail .fail-actions { display: flex; flex-direction: column; gap: 10px; }

/* Mismatch warning */
.mismatch {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--amber-soft);
  border: 1px solid rgba(245, 158, 11, 0.5);
  color: #ffdf9e;
  font-size: 14px;
}
.mismatch .warn-icon { color: var(--amber); font-weight: 900; }
.mismatch b { color: #fff; }

/* ---------- Tag info rows ---------- */
.rows { margin-top: 14px; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
}
.row + .row { margin-top: 10px; }

.row .check {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  margin: 0;
  accent-color: var(--yellow);
  cursor: pointer;
}
.row .rbody { flex: 1 1 auto; min-width: 0; }
.row .rlabel {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
}
.row .rvalue {
  font-size: 18px;
  font-weight: 800;
  color: var(--ink);
  word-break: break-word;
}
.row .rmeta { margin-top: 6px; }

.state-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.state-verified { background: var(--blue-soft); color: #9db6ff; border: 1px solid rgba(43, 92, 255, 0.5); }
.state-review { background: var(--amber-soft); color: #ffcf7a; border: 1px solid rgba(245, 158, 11, 0.5); }

.row .copybtn {
  flex: 0 0 auto;
  min-width: var(--tap);
  min-height: var(--tap);
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--panel-line);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.row .copybtn:active { background: var(--blue); color: #fff; }
.row .copybtn.copied { background: var(--blue); color: #fff; border-color: var(--blue); }
.row .copybtn svg { width: 18px; height: 18px; }

/* ---------- Sticky bottom bar ---------- */
.sticky-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  background: var(--bg-2);
  border-top: 1px solid var(--panel-line);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
.sticky-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  gap: 10px;
}
.sticky-inner .btn {
  margin-top: 0;
  font-size: 15px;
  padding: 12px 6px;
  flex: 1 1 0;
  min-width: 0;
  line-height: 1.15;
}
.sticky-inner .btn-primary { font-size: 15px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%) translateY(20px);
  background: var(--blue);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 15px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 60;
  max-width: calc(100% - 32px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Inline alerts ---------- */
.alert {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 700;
}
.alert-error {
  background: var(--danger-soft);
  border: 1px solid rgba(255, 90, 77, 0.5);
  color: #ffb3ab;
}

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 420px;
  margin: 0 auto;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
}
.login-brand { text-align: center; margin-bottom: 28px; }
.login-brand .crown { width: 58px; height: 58px; }
.login-brand .brand-name { font-size: 24px; margin-top: 12px; }
.login-brand .brand-sub { font-size: 14px; }
.login-card { }
.login-card label {
  display: block;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  margin-bottom: 10px;
}
.login-card .btn { margin-top: 16px; }
.login-foot {
  text-align: center;
  color: var(--ink-faint);
  font-size: 12px;
  margin-top: 22px;
  letter-spacing: 0.02em;
}

/* ---------- Small screens ---------- */
@media (max-width: 360px) {
  body { font-size: 16px; }
  .hero .hero-year { font-size: 68px; }
  .wrap { padding-left: 12px; padding-right: 12px; }
  .sticky-inner .btn { font-size: 14px; }
}

/* ---------- Light mode (clean fallback) ---------- */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #eef1f6;
    --bg-2: #e7ebf2;
    --panel: #ffffff;
    --panel-2: #f2f5fa;
    --panel-line: #d3dae6;
    --ink: #12151a;
    --ink-dim: #4a5468;
    --ink-faint: #6b7488;
    --field-white: #ffffff;
    --field-ink: #12151a;
    --shadow: 0 6px 20px rgba(20, 30, 50, 0.12);
  }
  .badge-verified { color: #1b3ba8; }
  .state-verified { color: #1b3ba8; }
  .state-review { color: #96610a; }
  .hero .hero-cap { color: #a07d00; }
  .brand-sub { color: #a07d00; }
  .tool-card .tc-go { color: #a07d00; }
  .mismatch { color: #7a5200; }
  .mismatch b { color: #12151a; }
}
