:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #667085;
  --line: #d8dee8;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
textarea,
input {
  font: inherit;
}

.app-shell {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.65rem, 6vw, 2.4rem);
  line-height: 1.05;
}

.status-pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 7px 11px;
  font-size: 0.82rem;
  font-weight: 700;
}

.status-pill.is-ready {
  border-color: #99d6ce;
  color: var(--accent-dark);
}

.status-pill.is-error {
  border-color: #fecdca;
  color: var(--danger);
}

.scanner-panel,
.result-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
}

.result-panel {
  margin-top: 14px;
}

.mode-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.mode-control label {
  min-width: 0;
}

.mode-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-control span {
  display: grid;
  min-height: 46px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 700;
}

.mode-control input:checked + span {
  border-color: var(--accent);
  background: #e7f6f3;
  color: var(--accent-dark);
}

.camera-frame {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  background: #0b1220;
}

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

.scan-line {
  position: absolute;
  z-index: 3;
  right: 10%;
  left: 10%;
  top: 50%;
  height: 2px;
  background: #22c55e;
  box-shadow: 0 0 16px rgba(34, 197, 94, 0.9);
  opacity: 0;
}

.camera-frame.is-active .scan-line {
  opacity: 1;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  padding: 24px;
  color: #e5e7eb;
  text-align: center;
}

.empty-state strong {
  font-size: 1.2rem;
}

.empty-state span {
  color: #b8c0cc;
}

.camera-frame.is-active .empty-state {
  display: none;
}
.camera-frame.is-active::before {
  content: "";
  position: absolute;
  z-index: 2;
  pointer-events: none;
  border: 3px solid rgba(34, 197, 94, 0.95);
  border-radius: 8px;
  box-shadow: 0 0 0 999px rgba(2, 6, 23, 0.24), 0 0 18px rgba(34, 197, 94, 0.55);
}

.camera-frame.is-active:not(.is-qr):not(.is-ocr)::before {
  left: 7%;
  right: 7%;
  top: 34%;
  bottom: 34%;
}

.camera-frame.is-active.is-qr::before {
  left: 50%;
  top: 50%;
  width: min(64vw, 320px, 72%);
  max-width: 72%;
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
}

.camera-frame.is-ocr::before {
  display: none;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

button {
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 800;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.primary-button:not(:disabled):active {
  background: var(--accent-dark);
}

.secondary-button {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.message {
  min-height: 1.45em;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.message.is-error {
  color: var(--danger);
}

.result-panel label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
  color: var(--ink);
  line-height: 1.45;
}

textarea:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(15, 118, 110, 0.16);
}

@media (max-width: 420px) {
  .app-shell {
    padding-right: 12px;
    padding-left: 12px;
  }

  .app-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .status-pill {
    align-self: flex-start;
  }
}

.registered-panel {
  margin-top: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
}

.panel-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.2;
}

.panel-heading h2 span {
  display: inline-grid;
  min-width: 2rem;
  min-height: 1.45rem;
  place-items: center;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 0.86rem;
}

.three-actions {
  grid-template-columns: 1fr 1fr 1fr;
}

.icon-button,
.small-button {
  min-height: 38px;
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  font-size: 0.9rem;
}

.registered-list {
  display: grid;
  gap: 10px;
}

.empty-list {
  margin: 0;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 16px;
  color: var(--muted);
  text-align: center;
}

.registered-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
}

.registered-value {
  overflow-wrap: anywhere;
  font-weight: 700;
  line-height: 1.35;
}

.registered-meta {
  grid-column: 1;
  color: var(--muted);
  font-size: 0.82rem;
}

.item-actions {
  grid-row: 1 / span 2;
  grid-column: 2;
  display: flex;
  gap: 8px;
}

.danger-button {
  border-color: #fecdca;
  color: var(--danger);
}

@media (max-width: 520px) {
  .three-actions {
    grid-template-columns: 1fr;
  }

  .registered-item {
    grid-template-columns: 1fr;
  }

  .registered-meta,
  .item-actions {
    grid-column: 1;
    grid-row: auto;
  }

  .item-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

.header-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.admin-link {
  display: inline-grid;
  min-height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 7px 11px;
  font-size: 0.88rem;
  font-weight: 800;
  text-decoration: none;
}

.admin-shell {
  max-width: 720px;
}

.admin-panel {
  margin-top: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
}

.admin-panel h2 {
  margin: 0 0 12px;
  font-size: 1.2rem;
  line-height: 1.2;
}

.admin-form {
  display: grid;
  gap: 10px;
}

.admin-form label {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.admin-form input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcfe;
  color: var(--ink);
}

.admin-form input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(15, 118, 110, 0.16);
}

.notice-message {
  margin: 0 0 12px;
  border: 1px solid #99d6ce;
  border-radius: 8px;
  background: #e7f6f3;
  color: var(--accent-dark);
  padding: 12px;
  font-weight: 700;
}

.notice-message.is-error {
  border-color: #fecdca;
  background: #fff4f2;
  color: var(--danger);
}

.admin-status {
  margin: 0 0 10px;
  color: var(--muted);
  line-height: 1.45;
}

.admin-status strong {
  color: var(--ink);
}

@media (max-width: 420px) {
  .header-actions {
    align-self: stretch;
    justify-content: space-between;
    width: 100%;
  }
}

.scanner-actions {
  grid-template-columns: 1fr 1fr 1fr;
}

.mode-control {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.camera-frame.is-ocr .scan-line {
  opacity: 0;
}

.ocr-options[hidden] {
  display: none !important;
}

.ocr-options {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.ocr-options > span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.ocr-options label {
  min-width: 0;
}

.ocr-options input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.ocr-options label span {
  display: grid;
  min-height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 700;
}

.ocr-options input:checked + span {
  border-color: var(--accent);
  background: #e7f6f3;
  color: var(--accent-dark);
}

.camera-frame.is-ocr::after {
  content: "";
  z-index: 2;
  position: absolute;
  left: 8%;
  right: 8%;
  border: 2px solid rgba(34, 197, 94, 0.85);
  border-radius: 8px;
  box-shadow: 0 0 0 999px rgba(2, 6, 23, 0.18);
  pointer-events: none;
}

.camera-frame.is-ocr-line::after {
  top: 41%;
  bottom: 41%;
}

.camera-frame.is-ocr-block::after {
  top: 16%;
  bottom: 16%;
}

@media (max-width: 520px) {
  .scanner-actions {
    grid-template-columns: 1fr;
  }

  .mode-control,
  .ocr-options {
    grid-template-columns: 1fr;
  }
}

.camera-frame.is-qr .scan-line {
  right: 50%;
  left: auto;
  top: 22%;
  bottom: 22%;
  width: 2px;
  height: auto;
  transform: translateX(1px);
}

.camera-frame.is-qr .scan-line::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(68vw, 360px);
  height: 2px;
  background: #22c55e;
  box-shadow: 0 0 16px rgba(34, 197, 94, 0.9);
  transform: translate(-50%, -50%);
}

.camera-frame.is-ocr.is-qr .scan-line,
.camera-frame.is-ocr.is-qr .scan-line::after {
  opacity: 0;
}
.user-list {
  display: grid;
  gap: 12px;
}

.user-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
}

.admin-form select {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #ffffff;
  font: inherit;
}