:root {
  color-scheme: light;
  --ink: #111827;
  --muted: #667085;
  --line: #e4e7ec;
  --surface: #f8fafc;
  --panel: #ffffff;
  --brand: #e60022;
  --brand-dark: #b8001b;
  --gold: #f9da65;
  --blue: #285295;
  --ok: #285295;
  --bad: #c4001d;
  --warn: #a15c07;
  --shadow: 0 18px 55px rgba(17, 24, 39, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, var(--brand) 0 6px, transparent 6px),
    linear-gradient(180deg, #ffffff 0%, var(--surface) 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  font-weight: 700;
  padding: 0 18px;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

button.secondary {
  background: #fff4f6;
  color: var(--brand-dark);
  border: 1px solid #ffd5dc;
}

.app-shell {
  width: min(1180px, 100%);
  height: 100dvh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 24px;
  padding: 24px;
  overflow: hidden;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.club-logo {
  width: 44px;
  height: 50px;
  max-width: 44px;
  max-height: 50px;
  object-fit: contain;
  flex: 0 0 auto;
  filter: drop-shadow(0 8px 16px rgba(17, 24, 39, 0.1));
}

.scanner-panel,
.status-panel {
  min-width: 0;
  min-height: 0;
}

.scanner-panel {
  display: flex;
  flex-direction: column;
}

.topbar,
.section-title,
.dialog-title,
.manual-row,
.controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar,
.section-title,
.dialog-title {
  justify-content: space-between;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand-dark);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.42rem, 2.4vw, 2.05rem);
}

h2 {
  font-size: 1rem;
}

.icon-button {
  width: 48px;
  height: 48px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  background: #fff4f6;
  color: var(--brand-dark);
  border: 1px solid #ffd5dc;
  font-size: 1.35rem;
}

.icon-button svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.camera-frame {
  position: relative;
  overflow: hidden;
  width: 100%;
  flex: 1 1 auto;
  min-height: 220px;
  max-height: 54dvh;
  margin-top: 14px;
  border-radius: 8px;
  border: 1px solid #2c1115;
  background: #1f1012;
  box-shadow: var(--shadow);
}

video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.scan-box {
  position: absolute;
  inset: 18%;
  border: 3px solid rgba(255, 255, 255, 0.94);
  border-radius: 8px;
  box-shadow:
    0 0 0 999px rgba(31, 16, 18, 0.34),
    0 0 0 5px rgba(249, 218, 101, 0.32);
}

.camera-state {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  min-height: 44px;
  display: grid;
  place-items: center;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  text-align: center;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.controls {
  margin-top: 10px;
}

.controls button {
  flex: 1;
}

.manual-entry {
  margin-top: 10px;
}

.manual-entry label,
.settings-form label,
.setting-strip span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.manual-row {
  margin-top: 8px;
  align-items: stretch;
}

input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 0 14px;
}

input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(40, 82, 149, 0.15);
  outline: none;
}

.status-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result-card {
  min-height: 172px;
  border-radius: 8px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.result-card.ok {
  background: #f7f9ff;
  border-color: #b9c9ef;
  box-shadow: 0 18px 55px rgba(40, 82, 149, 0.14);
}

.result-card.bad {
  background: #fff1f3;
  border-color: #ffb8c2;
  box-shadow: 0 18px 55px rgba(196, 0, 29, 0.14);
}

.result-card.pending {
  background: #fff9e6;
  border-color: var(--gold);
}

.result-card.neutral {
  border-top: 5px solid var(--gold);
}

.result-label {
  margin: 0 0 8px;
  font-size: 0.9rem;
  font-weight: 900;
  text-transform: uppercase;
}

.result-message {
  margin: 0;
  font-size: clamp(1.25rem, 3vw, 1.9rem);
  line-height: 1.08;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.setting-strip,
.history-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
}

.toggle-grid {
  display: grid;
  gap: 10px;
}

.setting-strip label,
.toggle-grid label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.setting-strip input,
.toggle-grid input {
  width: 24px;
  height: 24px;
  min-height: 24px;
  accent-color: var(--brand);
}

.setting-strip p {
  margin: 8px 0 0;
  color: var(--muted);
}

.text-button {
  min-height: auto;
  padding: 0;
  background: transparent;
  color: var(--brand-dark);
}

.history-list {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  max-height: min(32dvh, 300px);
  overflow: auto;
}

.history-list li {
  border-left: 4px solid var(--line);
  padding: 10px 0 10px 12px;
}

.history-list li.ok {
  border-color: var(--ok);
}

.history-list li.bad {
  border-color: var(--bad);
}

.history-message {
  margin: 0;
  font-weight: 800;
}

.history-code {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

dialog {
  width: min(460px, calc(100% - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(16, 32, 29, 0.45);
}

.settings-form {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.settings-form label span {
  margin-bottom: 6px;
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 0;
  padding: 0;
}

@media (max-width: 860px) {
  .app-shell {
    display: flex;
    flex-direction: column;
    padding: 12px;
    gap: 8px;
  }

  .scanner-panel,
  .status-panel {
    display: contents;
  }

  .topbar {
    order: 1;
  }

  .camera-frame {
    order: 2;
    flex: none;
    height: clamp(210px, 34dvh, 300px);
    min-height: 0;
    max-height: none;
    margin-top: 0;
  }

  .controls {
    order: 3;
    margin-top: 0;
  }

  .manual-entry {
    order: 4;
    margin-top: 0;
  }

  .result-card {
    order: 5;
    min-height: 116px;
    padding: 14px 16px;
  }

  .setting-strip {
    order: 6;
    padding: 12px 14px;
  }

  .history-section {
    display: none;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: center;
  }

  .brand-lockup {
    gap: 10px;
  }

  .club-logo {
    width: 38px;
    height: 44px;
    max-width: 38px;
    max-height: 44px;
  }

  .eyebrow {
    font-size: 0.66rem;
  }

  h1 {
    font-size: 1.28rem;
  }

  .controls {
    flex-direction: row;
  }

  .manual-row {
    gap: 8px;
  }

  .manual-row button {
    flex: 0 0 112px;
    padding: 0 12px;
  }

  button,
  input {
    min-height: 44px;
  }

  .result-card {
    min-height: 108px;
  }

  .result-label {
    font-size: 0.76rem;
  }

  .result-message {
    font-size: clamp(1.05rem, 5vw, 1.45rem);
  }

  .toggle-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px 14px;
  }

  .setting-strip span {
    font-size: 0.78rem;
  }

  .setting-strip p {
    font-size: 0.82rem;
  }
}

@media (max-height: 720px) and (max-width: 860px) {
  .camera-frame {
    height: 28dvh;
  }

  .club-logo {
    width: 34px;
    height: 40px;
    max-width: 34px;
    max-height: 40px;
  }

  h1 {
    font-size: 1.12rem;
  }

  .eyebrow,
  .manual-entry label,
  .settings-form label,
  .setting-strip span {
    font-size: 0.7rem;
  }

  .result-card {
    min-height: 92px;
  }

  .result-message {
    font-size: 1.05rem;
  }
}
