:root {
  --bg: #f7f8fa;
  --ink: #17212b;
  --muted: #647282;
  --line: #dfe5eb;
  --panel: #ffffff;
  --primary: #066e64;
  --primary-dark: #044e48;
  --accent: #d17a22;
  --danger: #b83232;
  --success: #157347;
  --shadow: 0 18px 50px rgba(31, 45, 61, 0.12);
  --banner-ratio: 1024 / 350;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.topbar {
  align-items: center;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 24px;
  justify-content: space-between;
  min-height: 72px;
  padding: 14px clamp(16px, 4vw, 56px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  color: var(--primary);
  display: block;
  font-size: 1.2rem;
}

.tagline {
  color: var(--muted);
  display: block;
  font-size: 0.86rem;
  margin-top: 2px;
}

.nav {
  background: #edf3f2;
  border: 1px solid #d9e7e5;
  border-radius: 8px;
  display: flex;
  padding: 4px;
}

.nav-button,
.tab {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  min-height: 38px;
  padding: 0 14px;
}

.nav-button.active,
.tab.active {
  background: var(--panel);
  box-shadow: 0 8px 20px rgba(6, 110, 100, 0.12);
  color: var(--primary-dark);
  font-weight: 700;
}

main {
  margin: 0 auto;
  max-width: 1240px;
  min-width: 0;
  padding: 28px clamp(16px, 4vw, 56px) 56px;
  width: 100%;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hero {
  align-items: stretch;
  background:
    linear-gradient(105deg, rgba(12, 31, 42, 0.88), rgba(6, 86, 78, 0.74)),
    url("https://images.unsplash.com/photo-1501281668745-f7f57925c3b4?auto=format&fit=crop&w=1800&q=80");
  background-position: center;
  background-size: cover;
  color: #fff;
  display: grid;
  gap: 24px;
  grid-template-columns: 1fr minmax(260px, 360px);
  min-height: 360px;
  padding: clamp(28px, 5vw, 64px);
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 4.8rem);
  line-height: 1;
  margin: 0;
  max-width: 900px;
}

.hero p {
  color: rgba(255, 255, 255, 0.84);
  font-size: 1.06rem;
  line-height: 1.6;
  max-width: 670px;
}

.hero-panel {
  align-self: end;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 22px;
}

.hero-panel strong {
  font-size: 2.1rem;
}

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

.section-heading,
.panel-title {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin: 30px 0 18px;
}

h2,
h3 {
  margin: 0;
}

.event-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  justify-items: center;
  min-width: 0;
  overflow: visible;
  width: 100%;
}

.event-card,
.panel,
.dashboard article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(31, 45, 61, 0.06);
}

.event-card {
  display: grid;
  max-width: 1024px;
  min-width: 0;
  overflow: hidden;
  width: 100%;
}

.event-image {
  align-items: flex-end;
  aspect-ratio: var(--banner-ratio);
  background: linear-gradient(135deg, #12313d, #0b7168);
  color: #fff;
  display: flex;
  min-height: 80px;
  padding: 18px;
}

.event-image.has-image {
  background-position: center;
  background-size: cover;
}

.field-help {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.banner-preview {
  aspect-ratio: var(--banner-ratio);
  background-color: #eef3f5;
  background-position: center;
  background-size: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: -4px 0 14px;
  min-height: 80px;
  width: 100%;
}

.event-body {
  display: grid;
  gap: 14px;
  min-width: 0;
  overflow: visible;
  padding: 18px;
}

.event-meta,
.muted,
.lot-note {
  color: var(--muted);
  font-size: 0.9rem;
}

.lot-row,
.order-row,
.ticket-row,
.event-admin-row,
.admin-user-row {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) max-content;
  margin-top: 10px;
  max-width: 100%;
  overflow: hidden;
  padding: 12px;
  width: 100%;
}

.lot-row > :first-child {
  min-width: 0;
}

.event-card .lot-row {
  grid-template-columns: 1fr;
}

.ticket-list {
  display: grid;
  gap: 12px;
}

.buyer-panel {
  display: grid;
  gap: 18px;
}

.buyer-orders {
  display: grid;
  gap: 16px;
}

.buyer-order-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  padding: 14px;
}

.buyer-order-header {
  align-items: start;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) max-content;
}

.buyer-order-header h3 {
  margin-top: 8px;
}

.buyer-ticket-list {
  display: grid;
  gap: 12px;
}

.ticket-card {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr 110px auto;
  padding: 14px;
}

.ticket-copy {
  display: grid;
  gap: 5px;
}

.ticket-copy strong {
  color: var(--ink);
  font-size: clamp(1rem, 3vw, 1.35rem);
}

.ticket-qr {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  height: 110px;
  padding: 6px;
  width: 110px;
}

.lot-price {
  color: var(--primary-dark);
  font-size: 1rem;
  font-weight: 800;
  margin-top: 4px;
  max-width: 100%;
  min-width: 0;
  overflow-wrap: normal;
  text-align: left;
  white-space: nowrap;
  width: 100%;
}

.event-body > .primary {
  display: inline-flex;
  justify-content: center;
  justify-self: stretch;
  max-width: 100%;
  min-width: 0;
  width: 100%;
}

.primary,
.secondary,
.ghost,
.danger {
  align-items: center;
  border-radius: 6px;
  display: inline-flex;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
}

.primary {
  background: var(--primary);
  border: 1px solid var(--primary);
  color: #fff;
  font-weight: 800;
}

.primary:hover {
  background: var(--primary-dark);
}

.secondary {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 700;
}

.ghost {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
}

.danger {
  background: #fff5f5;
  border: 1px solid #f0c7c7;
  color: var(--danger);
  font-weight: 700;
}

.dashboard {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 18px;
}

.dashboard-shell {
  display: grid;
  gap: 18px;
}

.dashboard-top {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.dashboard-nav {
  background: #edf3f2;
  border: 1px solid #d9e7e5;
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
}

.dashboard-nav-button {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  min-height: 38px;
  padding: 0 14px;
}

.dashboard-nav-button.active {
  background: #fff;
  box-shadow: 0 8px 20px rgba(6, 110, 100, 0.12);
  color: var(--primary-dark);
  font-weight: 800;
}

.dashboard-page {
  display: none;
}

.dashboard-page.active {
  display: block;
}

.dashboard.dashboard-page.active {
  display: grid;
}

.login-panel {
  margin: 0 auto;
  max-width: 460px;
}

.dashboard article {
  display: grid;
  gap: 6px;
  padding: 18px;
}

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

.dashboard strong {
  font-size: 1.7rem;
}

.inline-filter {
  margin: 0;
  min-width: min(320px, 100%);
}

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

.print-report-header {
  display: none;
}

.report-empty {
  background: #f8fafb;
  border: 1px dashed var(--line);
  border-radius: 8px;
  margin: 0;
  padding: 18px;
}

.report-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

.report-card {
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 16px;
}

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

.report-card strong {
  color: var(--ink);
  font-size: 1.45rem;
  overflow-wrap: anywhere;
}

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

.report-table {
  border-collapse: collapse;
  min-width: 840px;
  width: 100%;
}

.report-table th,
.report-table td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
  white-space: nowrap;
}

.report-table th {
  background: #f4f7f8;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

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

.admin-layout {
  align-items: start;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 1.25fr);
}

.panel {
  padding: 18px;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 0.86rem;
  font-weight: 700;
  gap: 6px;
  margin-bottom: 13px;
}

.check-option {
  align-items: start;
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  gap: 10px;
  grid-template-columns: auto 1fr;
  padding: 12px;
}

.check-option input {
  margin-top: 3px;
  min-height: auto;
  width: auto;
}

.check-option span {
  display: grid;
  gap: 3px;
}

.check-option small {
  color: var(--muted);
  font-weight: 500;
}

input,
textarea,
select {
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  min-height: 42px;
  outline: none;
  padding: 10px 12px;
  width: 100%;
}

select {
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, var(--primary) 50%) calc(100% - 18px) 52% / 6px 6px no-repeat,
    linear-gradient(135deg, var(--primary) 50%, transparent 50%) calc(100% - 13px) 52% / 6px 6px no-repeat,
    linear-gradient(#fbfcfd, #fbfcfd);
  cursor: pointer;
  font-weight: 700;
  padding-right: 38px;
}

select:hover {
  border-color: #b8c7d3;
  background:
    linear-gradient(45deg, transparent 50%, var(--primary-dark) 50%) calc(100% - 18px) 52% / 6px 6px no-repeat,
    linear-gradient(135deg, var(--primary-dark) 50%, transparent 50%) calc(100% - 13px) 52% / 6px 6px no-repeat,
    linear-gradient(#fff, #f7faf9);
}

select option {
  color: var(--ink);
  font-weight: 600;
  padding: 10px;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(6, 110, 100, 0.12);
}

.field-row {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
}

.lot-fields {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.lot-config {
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.lot-config h4 {
  margin: 0 0 10px;
}

.tabs {
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  padding-bottom: 8px;
}

.admin-tab {
  display: none;
}

.admin-tab.active {
  display: block;
}

.status {
  border-radius: 999px;
  display: inline-block;
  font-size: 0.76rem;
  font-weight: 800;
  padding: 5px 9px;
}

.status.paid,
.status.active,
.status.valid {
  background: #e9f7ef;
  color: var(--success);
}

.status.pending {
  background: #fff7e8;
  color: #a05b00;
}

.status.cancelled,
.status.used,
.status.inactive {
  background: #fff0f0;
  color: var(--danger);
}

.validator {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(320px, 0.9fr) minmax(320px, 1.1fr);
}

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

.scanner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.scanner-box {
  background: #101820;
  border-radius: 8px;
  margin-top: 12px;
  overflow: hidden;
  position: relative;
}

.scanner-box video {
  aspect-ratio: 4 / 3;
  display: block;
  object-fit: cover;
  width: 100%;
}

.scanner-frame {
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.28);
  height: 58%;
  left: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 58%;
}

.scanner-status {
  margin: 10px 0 0;
}

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

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

dialog::backdrop {
  background: rgba(15, 23, 31, 0.62);
}

.checkout {
  margin: 0;
  padding: 22px;
  position: relative;
}

.confirm-modal {
  display: grid;
  gap: 12px;
  margin: 0;
  max-width: 480px;
  padding: 24px;
}

.confirm-modal h2 {
  margin: 0;
}

.confirm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}

.close {
  background: #f0f3f5;
  border: 1px solid var(--line);
  border-radius: 50%;
  height: 34px;
  position: absolute;
  right: 16px;
  top: 16px;
  width: 34px;
}

.checkout-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr 220px;
}

.pix-box {
  background: #f7faf9;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.qr-card {
  aspect-ratio: 1;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  place-items: center;
  padding: 12px;
  text-align: center;
}

.qr-image {
  display: block;
  height: min(220px, 100%);
  image-rendering: pixelated;
  width: min(220px, 100%);
}

.qr-card small {
  color: var(--muted);
}

.pix-code {
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: #26323d;
  font-family: Consolas, monospace;
  overflow-wrap: anywhere;
  padding: 12px;
}

.price-breakdown {
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: grid;
  gap: 6px;
  margin-bottom: 13px;
  padding: 12px;
}

.price-breakdown span {
  display: block;
}

.settings-form {
  display: grid;
  gap: 12px;
  max-width: 520px;
}

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

.admin-users-panel {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.form-divider {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 4px 0;
  width: 100%;
}

.checkout-tickets {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
}

.receipt-alert {
  background: #eefaf5;
  border: 1px solid #c8eadb;
  border-radius: 8px;
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
}

.receipt-alert span {
  color: var(--success);
  font-weight: 800;
}

.link-button {
  align-items: center;
  display: inline-flex;
  justify-content: center;
  text-decoration: none;
  width: fit-content;
}

.toast {
  background: #17212b;
  border-radius: 8px;
  bottom: 18px;
  color: #fff;
  left: 50%;
  opacity: 0;
  padding: 12px 16px;
  position: fixed;
  transform: translate(-50%, 14px);
  transition: 0.2s ease;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 860px) {
  .topbar,
  .section-heading,
  .panel-title,
  .dashboard-top {
    align-items: stretch;
    flex-direction: column;
  }

  .nav,
  .dashboard-nav {
    overflow-x: auto;
  }

  .hero,
  .admin-layout,
  .validator,
  .checkout-grid,
  .dashboard,
  .report-grid {
    grid-template-columns: 1fr;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .ticket-card {
    grid-template-columns: 1fr;
  }

  .buyer-order-header {
    grid-template-columns: 1fr;
  }

  .lot-row,
  .admin-user-row {
    grid-template-columns: 1fr;
  }

  .lot-price {
    width: auto;
  }

  .ticket-qr {
    height: 160px;
    width: 160px;
  }
}

@page {
  margin: 12mm;
  size: A4;
}

@media print {
  body.printing-report {
    background: #fff;
  }

  body.printing-report .topbar,
  body.printing-report .dashboard-top,
  body.printing-report .dashboard-nav,
  body.printing-report .no-print,
  body.printing-report .toast {
    display: none !important;
  }

  body.printing-report main {
    max-width: none;
    padding: 0;
  }

  body.printing-report .view,
  body.printing-report .dashboard-page {
    display: none !important;
  }

  body.printing-report #admin,
  body.printing-report [data-dashboard-page="reports"] {
    display: block !important;
  }

  body.printing-report #adminDashboard {
    display: block !important;
  }

  body.printing-report [data-dashboard-page="reports"] {
    border: 0;
    box-shadow: none;
    padding: 0;
  }

  body.printing-report .panel-title {
    margin: 0 0 10mm;
  }

  body.printing-report .panel-title .eyebrow,
  body.printing-report .panel-title h2 {
    display: none;
  }

  body.printing-report .print-report-header {
    border-bottom: 1px solid #cfd7df;
    display: block;
    margin-bottom: 7mm;
    padding-bottom: 5mm;
  }

  body.printing-report .print-report-header h2 {
    color: #111827;
    font-size: 18pt;
    margin: 0 0 2mm;
  }

  body.printing-report .print-report-header p {
    color: #4b5563;
    margin: 0;
  }

  body.printing-report .report-grid {
    gap: 4mm;
    grid-template-columns: repeat(4, 1fr);
    margin-bottom: 8mm;
  }

  body.printing-report .report-card {
    break-inside: avoid;
    box-shadow: none;
    padding: 4mm;
  }

  body.printing-report .report-card strong {
    font-size: 14pt;
  }

  body.printing-report .report-table-wrap {
    border-radius: 0;
    overflow: visible;
  }

  body.printing-report .report-table {
    font-size: 8.5pt;
    min-width: 0;
  }

  body.printing-report .report-table th,
  body.printing-report .report-table td {
    padding: 2.5mm 2mm;
    white-space: normal;
  }

  body.printing-report .report-table th:first-child,
  body.printing-report .report-table td:first-child {
    display: none;
  }
}
