:root {
  --bg: #f7f9fb;
  --surface: #ffffff;
  --text: #16202a;
  --muted: #5d6875;
  --line: #dce3ea;
  --primary: #0f766e;
  --primary-pressed: #115e59;
  --danger: #c2410c;
  --success: #138a4d;
  --shadow: 0 18px 48px rgba(22, 32, 42, 0.12);
  font-family: Arial, "Noto Sans Thai", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100svh;
  display: flex;
  justify-content: center;
  background: linear-gradient(180deg, #ffffff 0%, #eef4f7 100%);
}

.screen {
  width: 100%;
  max-width: 520px;
  min-height: 100svh;
  display: none;
  padding: 24px 18px;
}

.screen-active {
  display: flex;
  flex-direction: column;
}

.brand-block {
  padding-top: 18px;
}

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

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

h1 {
  font-size: 2.15rem;
  line-height: 1.1;
}

h2 {
  font-size: 1.35rem;
  line-height: 1.25;
}

.subtitle {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.step-list {
  margin: 28px 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.step-list li {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.step-list span {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: var(--primary);
  font-weight: 700;
}

.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  color: var(--muted);
  line-height: 1.55;
  cursor: pointer;
}

.consent-row input {
  width: 22px;
  height: 22px;
  margin-top: 2px;
  accent-color: var(--primary);
}

.profile-form {
  display: grid;
  gap: 14px;
}

.profile-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
}

.profile-form input {
  width: 100%;
  min-height: 48px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.profile-form input:focus {
  border-color: var(--primary);
  outline: 3px solid rgba(15, 118, 110, 0.14);
}

.profile-form .primary-button {
  margin-top: 8px;
}

.primary-button,
.secondary-button,
.icon-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
}

.primary-button,
.secondary-button {
  width: 100%;
  min-height: 54px;
  padding: 14px 18px;
  font-weight: 700;
}

.primary-button {
  margin-top: auto;
  color: #ffffff;
  background: var(--primary);
  box-shadow: var(--shadow);
}

.primary-button:active {
  background: var(--primary-pressed);
}

.primary-button:disabled {
  cursor: not-allowed;
  background: #9aa8b4;
  box-shadow: none;
}

.secondary-button {
  color: var(--text);
  background: #e8eef2;
}

.secondary-link {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--text);
  background: #e8eef2;
  font-weight: 700;
  text-decoration: none;
}

.home-admin-link {
  width: 100%;
  margin-top: 12px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.icon-button {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  color: var(--text);
  background: #e8eef2;
  font-size: 1.6rem;
  line-height: 1;
}

.status-message {
  min-height: 44px;
  display: flex;
  align-items: center;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  line-height: 1.4;
}

.status-message.error {
  border-color: #fed7aa;
  color: var(--danger);
  background: #fff7ed;
}

.status-message.ready {
  border-color: #bbf7d0;
  color: var(--success);
  background: #f0fdf4;
}

.camera-stage {
  position: relative;
  width: 100%;
  min-height: 62svh;
  overflow: hidden;
  border-radius: 8px;
  background: #111827;
}

.selfie-stage {
  position: relative;
  width: 100%;
  min-height: 64svh;
  overflow: hidden;
  border-radius: 8px;
  background: #111827;
}

.camera-video,
.capture-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.selfie-video {
  transform: scaleX(-1);
}

.capture-canvas {
  display: none;
}

.card-guide {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.18);
}

.card-frame {
  width: min(88vw, 440px);
  aspect-ratio: 1.586 / 1;
  display: grid;
  place-items: center;
  border: 3px solid rgba(255, 255, 255, 0.92);
  border-radius: 8px;
  color: #ffffff;
  text-align: center;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.55);
}

.face-guide {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(0, 0, 0, 0.14);
}

.face-frame {
  width: min(66vw, 280px);
  aspect-ratio: 0.78 / 1;
  display: grid;
  place-items: center;
  border: 3px solid rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  color: #ffffff;
  text-align: center;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.55);
}

.capture-panel {
  padding-top: 14px;
}

.capture-panel .primary-button {
  margin-top: 0;
}

.hint-text {
  min-height: 42px;
  margin: 10px 0 0;
  color: var(--muted);
  text-align: center;
  line-height: 1.45;
}

.card-preview {
  width: 100%;
  aspect-ratio: 1.586 / 1;
  object-fit: cover;
  border-radius: 8px;
  background: #dce3ea;
  border: 1px solid var(--line);
}

.preview-frame {
  position: relative;
  width: 100%;
}

.preview-frame .card-preview {
  display: block;
}

.debug-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.face-preview-panel {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.face-crop-canvas {
  width: 132px;
  height: 132px;
  display: block;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: #eef4f7;
}

.debug-info {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.metric-list {
  display: grid;
  gap: 12px;
  margin: 24px 0;
}

.log-banner {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef4f7;
}

.log-banner span {
  color: var(--muted);
  font-weight: 700;
}

.log-banner strong {
  color: var(--text);
}

.metric-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric-list dt {
  color: var(--muted);
  font-weight: 700;
}

.metric-list dd {
  margin: 0;
  color: var(--text);
  font-size: 1.3rem;
  font-weight: 700;
}

.liveness-panel {
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.liveness-current {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.liveness-current span {
  min-width: 46px;
  min-height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #ffffff;
  background: var(--primary);
  font-weight: 700;
}

.liveness-current strong {
  font-size: 1.05rem;
}

.liveness-progress {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.liveness-progress li {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #eef4f7;
  color: var(--muted);
}

.liveness-progress li.done {
  color: var(--success);
  background: #f0fdf4;
}

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

.preview-actions .primary-button,
.preview-actions .secondary-button {
  margin-top: 0;
}

#adminReviewButton,
#retryVerificationButton {
  margin-top: 14px;
}

.result-mark {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  margin: 18vh auto 20px;
  border-radius: 50%;
  color: #ffffff;
  background: var(--success);
  font-size: 2rem;
  font-weight: 700;
}

.result-mark.review {
  background: #f59e0b;
}

.result-mark.fail {
  background: #dc2626;
}

.admin-shell {
  width: min(1180px, 100%);
  min-height: 100svh;
  margin: 0 auto;
  padding: 22px 16px 32px;
}

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

.admin-header h1 {
  font-size: 1.85rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.dashboard-card {
  min-height: 86px;
  display: grid;
  align-content: center;
  gap: 7px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.dashboard-card span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.dashboard-card strong {
  font-size: 1.9rem;
  line-height: 1;
}

.dashboard-card.urgent {
  border-color: #fde68a;
  background: #fffbeb;
}

.dashboard-card.danger {
  border-color: #fecaca;
  background: #fef2f2;
}

.date-filter {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) 150px;
  gap: 10px;
  margin-bottom: 12px;
}

.date-filter label {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
}

.date-filter input {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.date-filter .secondary-button {
  min-height: 70px;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
}

.admin-tab {
  min-height: 44px;
  flex: 0 0 auto;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface);
  font-weight: 700;
  cursor: pointer;
}

.admin-tab.active {
  color: #ffffff;
  border-color: var(--primary);
  background: var(--primary);
}

.admin-toolbar {
  display: grid;
  grid-template-columns: 160px minmax(180px, 260px) 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.admin-summary {
  min-height: 76px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.admin-summary span {
  color: var(--muted);
  font-weight: 700;
}

.admin-summary strong {
  font-size: 1.85rem;
}

.admin-reviewer {
  min-height: 76px;
  display: grid;
  align-content: center;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
}

.admin-reviewer input {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-reviewer .mini-button {
  width: 100%;
}

.admin-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.admin-actions .primary-button,
.admin-actions .secondary-button {
  min-height: 76px;
  margin-top: 0;
  box-shadow: none;
}

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.admin-table {
  width: 100%;
  min-width: 1100px;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  line-height: 1.4;
}

.admin-table th {
  color: var(--muted);
  background: #eef4f7;
  font-size: 0.82rem;
  text-transform: uppercase;
}

.admin-table td {
  font-size: 0.92rem;
}

.admin-table tbody tr:last-child td {
  border-bottom: 0;
}

.admin-table a {
  color: var(--primary);
  font-weight: 700;
}

.cell-detail {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.78rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #eef4f7;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.status-badge.approved {
  color: #166534;
  background: #dcfce7;
}

.status-badge.rejected {
  color: #991b1b;
  background: #fee2e2;
}

.status-badge.pending {
  color: #92400e;
  background: #fef3c7;
}

.row-actions {
  display: flex;
  gap: 8px;
}

.mini-button {
  min-height: 34px;
  padding: 7px 10px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

.mini-button.approve {
  background: var(--success);
}

.mini-button.reject {
  background: #dc2626;
}

.mini-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

@media (min-width: 680px) {
  .screen {
    min-height: auto;
    margin: 28px 0;
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
  }

  .camera-stage {
    min-height: 580px;
  }

  .selfie-stage {
    min-height: 580px;
  }
}

@media (max-width: 760px) {
  .admin-header,
  .admin-toolbar,
  .date-filter {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-header {
    display: grid;
  }

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

  .admin-actions .primary-button,
  .admin-actions .secondary-button {
    min-height: 54px;
  }
}
