:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #172033;
  --muted: #687289;
  --line: #e6e9f2;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #f59e0b;
  --shadow: 0 18px 45px rgba(23, 32, 51, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, #eaf1ff, transparent 32%), var(--bg);
  color: var(--text);
}

a { color: inherit; text-decoration: none; }

.container {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
}

.navbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
  background: rgba(255, 255, 255, 0.82);
  border-bottom: 1px solid rgba(230, 233, 242, 0.8);
}

.navbar-inner {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-badge {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.24);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.hero {
  padding: 54px 0 28px;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 28px;
  align-items: start;
}

.card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-pad { padding: 26px; }

h1, h2, h3, p { margin-top: 0; }

h1 {
  font-size: clamp(30px, 5vw, 52px);
  line-height: 1.03;
  letter-spacing: -0.05em;
  margin-bottom: 16px;
}

h2 {
  font-size: clamp(22px, 3vw, 30px);
  letter-spacing: -0.03em;
  margin-bottom: 10px;
}

h3 {
  font-size: 18px;
  margin-bottom: 10px;
}

.lead {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
  margin-bottom: 22px;
}

.small { font-size: 13px; color: var(--muted); }

.btn, button {
  border: 0;
  border-radius: 12px;
  padding: 11px 16px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.18s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

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

.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }

.btn-light {
  background: #eef2ff;
  color: #1e3a8a;
}

.btn-light:hover { background: #dbeafe; }

.btn-danger {
  color: #fff;
  background: var(--danger);
}

.btn-ghost {
  color: var(--text);
  background: #f3f5fa;
}

.btn-ghost:hover { background: #e9edf7; }

.btn-sm {
  padding: 8px 11px;
  font-size: 12px;
}

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

.form-row {
  display: grid;
  gap: 8px;
}

label {
  color: #344054;
  font-size: 14px;
  font-weight: 700;
}

input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
  outline: none;
}

input:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.alert {
  padding: 13px 15px;
  border-radius: 14px;
  margin-bottom: 16px;
  font-weight: 650;
}

.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-info { background: #dbeafe; color: #1e40af; }
.alert-warning { background: #fef3c7; color: #92400e; }

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

th, td {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f8fafc;
  color: #475467;
  font-size: 13px;
}

tr:last-child td { border-bottom: 0; }

.code-pill {
  display: inline-block;
  max-width: 230px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 999px;
  background: #f1f5f9;
  padding: 6px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.qr-preview {
  width: 102px;
  min-height: 102px;
  padding: 5px;
  border-radius: 14px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  background: #fff;
}

.qr-preview canvas, .qr-preview img {
  width: 90px !important;
  height: 90px !important;
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.searchbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  margin-bottom: 18px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.55);
}

.modal.active { display: grid; }

.modal-card {
  width: min(540px, 100%);
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.24);
  padding: 24px;
}

.reader-box {
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: #0f172a;
  min-height: 320px;
}

#reader {
  width: 100%;
  min-height: 320px;
}

.result-card {
  display: grid;
  gap: 12px;
}

.result-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.result-row:last-child { border-bottom: 0; }

.status-valid {
  color: #fff;
  background: var(--success);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 800;
}

.footer-note {
  padding: 18px 0 42px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(440px, 100%);
}

@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 1fr; }
  .searchbar { grid-template-columns: 1fr; }
  .navbar-inner { align-items: flex-start; flex-direction: column; padding: 16px 0; }
  .nav-actions { justify-content: flex-start; }
}

.soft-card {
  padding: 16px;
  background: #f8fafc;
  box-shadow: none;
  margin-bottom: 16px;
}

.code-block {
  overflow-x: auto;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #0f172a;
  color: #e5e7eb;
  padding: 14px;
  font-size: 13px;
  line-height: 1.6;
}

.error-list {
  margin: 0;
  padding-left: 20px;
  color: #7f1d1d;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 14px;
  margin: 22px 0;
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
  padding: 18px;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.stat-card strong {
  display: block;
  font-size: 34px;
  letter-spacing: -0.05em;
}

.report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  align-items: start;
}

.report-filter {
  display: grid;
  grid-template-columns: 1.2fr 0.7fr 0.7fr auto;
  gap: 14px;
  align-items: end;
  margin-top: 18px;
}

.filter-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.compact-table table {
  min-width: 420px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 900;
}

.status-valid {
  color: #fff;
  background: var(--success);
}

.status-invalid {
  color: #fff;
  background: var(--danger);
}

@media (max-width: 1080px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .report-filter { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .report-grid { grid-template-columns: 1fr; }
  .report-filter { grid-template-columns: 1fr; }
}

@media print {
  body { background: #fff; }
  .no-print, .navbar, .footer-note { display: none !important; }
  .container { width: 100%; }
  .hero { padding: 0; }
  .card, .stat-card { box-shadow: none; break-inside: avoid; }
  .table-wrap { overflow: visible; }
  table { min-width: 0; font-size: 12px; }
}

.download-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
  padding: 16px;
  margin: 16px 0;
}

.download-panel h3 {
  margin: 0 0 4px;
}

.download-panel .small {
  margin: 0;
}

.download-panel button[disabled] {
  cursor: wait;
  opacity: 0.7;
}
