:root {
  --navy: #1E2E4F;
  --navy-dark: #142039;
  --navy-soft: #2c4374;
  --red: #D64545;
  --red-dark: #b53636;
  --bg: #f7f8fa;
  --ink: #1a1a1a;
  --muted: #6b7280;
  --line: #e5e7eb;
  --good: #1f8a3a;
  --bad: var(--red);
  --card: #ffffff;
}
* { box-sizing: border-box; }
@media (orientation: landscape) and (max-device-width: 900px) {
  body::before {
    content: "Rotate your phone to portrait."; position: fixed; inset: 0; z-index: 999;
    display: flex; align-items: center; justify-content: center;
    background: var(--navy); color: #fff; font-size: 22px; font-weight: 700; text-align: center; padding: 20px;
  }
}
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; }
body { padding-bottom: env(safe-area-inset-bottom); }
.appbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) calc(env(safe-area-inset-right) + 16px) 12px calc(env(safe-area-inset-left) + 16px);
  background: var(--navy); color: #fff;
  position: sticky; top: 0; z-index: 10;
  box-shadow: 0 1px 0 rgba(0,0,0,0.06);
}
.appbar .brand { color: #fff; font-weight: 800; font-size: 22px; text-decoration: none; letter-spacing: 1px; }
.appbar nav { display: flex; gap: 14px; }
.appbar nav a { color: #fff; text-decoration: none; font-weight: 600; font-size: 15px; }
.appbar nav a.muted { opacity: 0.7; }
.container { max-width: 720px; margin: 0 auto; padding: 18px 16px 60px; }
.hero { text-align: center; padding: 24px 0 8px; }
.hero h1 { margin: 0 0 8px; font-size: 28px; }
h1 { font-size: 26px; color: var(--navy); }
h2 { margin-top: 28px; font-size: 18px; color: var(--navy); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.good { color: var(--good); }
.bad { color: var(--bad); }
a { color: var(--navy); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin: 14px 0; }
.card.good { border-color: var(--good); background: #effaf1; }
.card.bad { border-color: var(--bad); background: #fdecea; }
input, button, select, textarea { font: inherit; }
input[type="email"], input[type="text"], input[type="search"], input[type="datetime-local"] {
  width: 100%; padding: 12px 14px; font-size: 17px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
label { display: block; margin: 10px 0; font-weight: 600; }
button, .big-button, .as-label {
  display: inline-block; padding: 14px 22px; font-size: 17px; font-weight: 700;
  background: var(--navy); color: #fff; border: 0; border-radius: 12px; cursor: pointer; text-decoration: none;
}
button.primary { background: var(--red); }
button:disabled { opacity: 0.5; }
.big-button { display: block; width: 100%; text-align: center; padding: 22px; font-size: 22px; margin: 14px 0; box-shadow: 0 4px 0 var(--navy-dark); }
.big-button:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--navy-dark); }
.scan-button {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 44px 16px; margin: 16px 0;
  background: var(--navy); color: #fff; border-radius: 18px; cursor: pointer;
  box-shadow: 0 6px 0 var(--navy-dark);
  user-select: none; -webkit-tap-highlight-color: transparent;
  border: 1px solid var(--navy-dark);
}
.scan-button:active { transform: translateY(3px); box-shadow: 0 3px 0 var(--navy-dark); }
.scan-button .scan-icon {
  width: 64px; height: 64px; border-radius: 14px; background: var(--red);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 4px rgba(255,255,255,0.08);
}
.scan-button .scan-icon svg { width: 36px; height: 36px; fill: #fff; }
.scan-button .scan-label { font-size: 24px; font-weight: 800; letter-spacing: 0.3px; }
.scan-button .scan-sub { color: rgba(255,255,255,0.78); font-size: 13px; }
.status-card { padding: 16px; border-radius: 14px; margin: 12px 0; background: #fff; border: 1px solid var(--line); }
.status-card.good { background: #effaf1; border-color: var(--good); }
.status-card.bad { background: #fdecea; border-color: var(--bad); color: var(--bad); }
.status-card.warn { background: #fff7e8; border-color: #d99a2e; }
.status-card.working { background: #fff; border: 1px dashed var(--line); color: var(--muted); }
.status-card.big { text-align: center; padding: 22px 16px; }
.big-check { font-size: 56px; color: var(--good); line-height: 1; }
.big-name { font-size: 22px; font-weight: 800; margin-top: 4px; color: var(--navy); }
.big-total { font-size: 38px; font-weight: 800; color: var(--red); margin: 6px 0 12px; }
.grant-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }
.profile-btn { background: var(--navy); color: #fff; padding: 10px 18px; font-size: 15px; font-weight: 700; border-radius: 8px; text-decoration: none; }
.undo-btn { background: transparent; color: var(--muted); border: 1px solid var(--line); padding: 8px 18px; font-size: 14px; font-weight: 600; border-radius: 8px; }
.match-pick { display: block; width: 100%; text-align: left; background: #fff; color: var(--ink); border: 1px solid var(--line); padding: 14px; margin: 8px 0; border-radius: 12px; }
.match-pick .pts { background: var(--navy); color: #fff; padding: 4px 10px; border-radius: 999px; font-weight: 700; font-size: 13px; margin-left: 8px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow, .grow { flex: 1; min-width: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 14px 0; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px; text-align: center; text-decoration: none; color: var(--ink); display: block; transition: transform 0.1s, box-shadow 0.1s; }
a.stat:active { transform: translateY(1px); box-shadow: 0 1px 0 var(--line); }
a.stat:hover { border-color: var(--navy); }
.stat .num { font-size: 28px; font-weight: 800; color: var(--navy); }
.stat .lbl { color: var(--muted); font-size: 13px; }
.email-actions { display: flex; gap: 8px; margin: 14px 0 8px; flex-wrap: wrap; }
.email-btn { background: var(--navy); color: #fff; padding: 12px 16px; font-size: 15px; font-weight: 600; border: 0; border-radius: 10px; flex: 1; min-width: 140px; cursor: pointer; }
.email-btn:disabled { opacity: 0.5; }
.entrants { list-style: none; padding: 0; counter-reset: rank; }
.entrant-row { display: flex; gap: 10px; align-items: center; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 12px; margin: 6px 0; }
.entrant-row.won { background: #fef6f5; border-color: var(--bad); }
.entrant-row .rank { font-weight: 800; color: var(--muted); width: 28px; text-align: right; }
.entrant-row a.grow { color: var(--ink); text-decoration: none; min-width: 0; }
.entrant-row .name { font-weight: 700; color: var(--navy); }
.entrant-row .totals { text-align: right; display: flex; flex-direction: column; gap: 2px; align-items: flex-end; }
.entrant-row .total-num { font-size: 22px; font-weight: 800; color: var(--red); line-height: 1; }
.entrant-row .won-tag { background: var(--bad); color: #fff; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.recent { list-style: none; padding: 0; margin: 0; }
.recent li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.recent li > .grow { flex: 1; }
.recent a { color: var(--ink); font-weight: 600; text-decoration: none; }
.match-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 10px 0; }
.match-card.won { background: #fdf2ec; border-color: var(--bad); }
.match-card .pts { background: var(--navy); color: #fff; padding: 4px 10px; border-radius: 999px; font-weight: 700; }
.match-card .block { display: block; margin-top: 10px; text-align: center; padding: 12px; }
.big-num { font-size: 56px; font-weight: 800; color: var(--red); text-align: center; margin: 8px 0; }
.reason-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.reason-btn { display: flex; flex-direction: column; gap: 4px; padding: 18px; font-size: 16px; }
.reason-btn .muted { color: rgba(255,255,255,0.85); font-size: 14px; font-weight: 600; }
.drawings { list-style: none; padding: 0; }
.drawings li { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 14px; margin: 8px 0; }
.drawings .winner { font-weight: 700; }
.drawings a { color: var(--ink); }
.audit-list { list-style: none; padding: 0; margin: 0; }
.audit-item { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 8px 0; }
.audit-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.audit-action { font-weight: 700; color: var(--navy); text-transform: uppercase; letter-spacing: 0.5px; font-size: 13px; }
.audit-when { white-space: nowrap; }
.audit-meta { margin-top: 4px; }
.audit-details { margin-top: 6px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: #f3f4f6; padding: 8px; border-radius: 8px; word-break: break-word; overflow-wrap: anywhere; }
.undo { background: transparent; color: var(--muted); border: 1px solid var(--line); padding: 4px 10px; font-size: 13px; border-radius: 8px; }
details { margin: 12px 0; }
details summary { cursor: pointer; padding: 8px 0; font-weight: 600; color: var(--navy); }
.profile-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin: 14px 0; }
.profile-card h3 { margin: 0 0 6px; color: var(--navy); font-size: 15px; text-transform: uppercase; letter-spacing: 0.5px; }
.profile-card p { margin: 6px 0; line-height: 1.45; }
.profile-card ul { margin: 6px 0 6px 18px; padding: 0; }
.profile-card ul li { margin: 4px 0; }
.search-links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.profile-card .li-link { display: inline-block; background: #0a66c2; color: #fff; padding: 9px 14px; border-radius: 8px; text-decoration: none; font-weight: 600; font-size: 14px; }
.profile-card .g-link { display: inline-block; background: #fff; color: var(--navy); border: 1px solid var(--line); padding: 9px 14px; border-radius: 8px; text-decoration: none; font-weight: 600; font-size: 14px; }
.enrich-pending { color: var(--muted); font-style: italic; font-size: 14px; }
.enrich-failed { color: var(--bad); font-size: 14px; }
@media (min-width: 600px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}
