:root {
  color-scheme: light;
  --forest: #173c2a;
  --forest-2: #24563d;
  --cream: #f4f0e6;
  --paper: #fffdf8;
  --ink: #1d3026;
  --muted: #69776f;
  --line: rgba(23, 60, 42, .14);
  --focus: #e8b848;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
a { color: inherit; }

.studio-page {
  background:
    radial-gradient(circle at 87% 10%, rgba(255,255,255,.12), transparent 27rem),
    linear-gradient(135deg, #0f3020 0%, var(--forest) 62%, #0f3322 100%);
}

.studio {
  width: min(1480px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(20px, 3.5vw, 54px);
  display: grid;
  align-items: center;
  grid-template-columns: minmax(290px, 380px) minmax(0, 1fr);
  gap: clamp(32px, 4vw, 68px);
}

.controls { color: #fff; }

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

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-weight: 750;
}

.brand-logo {
  display: block;
  width: auto;
  height: 52px;
}

.page-logo {
  display: block;
  width: auto;
  height: 46px;
  margin-bottom: 14px;
}

.verify-hero .page-logo { margin: 0 auto 18px; }
.certificate-view .page-logo { margin: 22px auto 16px; }

.analytics-link {
  border-radius: 9px;
  padding: 9px 11px;
  color: rgba(255,255,255,.7);
  font-size: .875rem;
  font-weight: 700;
  text-decoration: none;
  transition: color .2s ease, background .2s ease;
}

.analytics-link:hover { color: #fff; background: rgba(255,255,255,.09); }

.header-nav { display: flex; align-items: center; gap: 2px; }

h1 {
  max-width: 11ch;
  margin: 0;
  font: 400 clamp(2.8rem, 5vw, 4.75rem)/.96 Georgia, "Times New Roman", serif;
  letter-spacing: -.045em;
}

.intro {
  margin: 22px 0 28px;
  color: rgba(255,255,255,.7);
  font-size: 1rem;
  line-height: 1.55;
}

.field {
  display: block;
  margin-top: 17px;
}

.field span {
  display: block;
  margin-bottom: 9px;
  font-size: .875rem;
  font-weight: 750;
}

.field input {
  width: 100%;
  min-height: 56px;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 13px;
  padding: 0 17px;
  color: var(--ink);
  background: rgba(255,255,255,.96);
  outline: none;
  box-shadow: 0 16px 42px rgba(3,20,12,.14);
  transition: border-color .2s ease, box-shadow .2s ease;
}

.field input::placeholder { color: #87928c; }
.field input:focus { border-color: var(--focus); box-shadow: 0 0 0 4px rgba(232,184,72,.22); }

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

.button {
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: 13px;
  padding: 0 14px;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 750;
  transition: transform .18s ease, background .18s ease, opacity .18s ease;
}

.button svg { width: 18px; height: 18px; flex: none; }
.button-wide { grid-column: 1 / -1; }
.button-primary { color: var(--forest); background: #fff; }
.button-secondary { color: #fff; background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.22); }
.button:hover:not(:disabled) { transform: translateY(-2px); }
.button:active:not(:disabled) { transform: translateY(0); }
.button:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.button:disabled { cursor: not-allowed; opacity: .43; }

.status {
  min-height: 22px;
  margin: 14px 0 0;
  color: rgba(255,255,255,.72);
  font-size: .875rem;
}

.certificate-result {
  margin-top: 12px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 13px;
  padding: 14px;
  background: rgba(255,255,255,.08);
}

.certificate-result[hidden] { display: none; }
.certificate-result div { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }
.certificate-result span { color: rgba(255,255,255,.58); font-size: .76rem; }
.certificate-result strong { font-size: .9rem; letter-spacing: .04em; }
.certificate-result a,
.certificate-result button {
  display: inline-block;
  margin-top: 10px;
  border: 0;
  padding: 0;
  color: #fff;
  background: none;
  cursor: pointer;
  font-size: .78rem;
  font-weight: 700;
  text-decoration: underline;
}

.certificate-result button { margin-left: 15px; color: rgba(255,255,255,.7); }

.privacy {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 10px 0 0;
  color: rgba(255,255,255,.5);
  font-size: .77rem;
  line-height: 1.5;
}

.privacy svg { width: 17px; height: 17px; flex: none; margin-top: 1px; }
.preview { min-width: 0; }

.preview-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  margin: 0 4px 14px;
  color: rgba(255,255,255,.62);
  font-size: .78rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.preview-heading strong { color: #fff; }

.certificate {
  overflow: hidden;
  border-radius: 7px;
  background: var(--cream);
  box-shadow: 0 40px 90px rgba(0,13,6,.34), 0 2px 8px rgba(0,0,0,.18);
}

.certificate canvas,
.certificate img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2.04 / 1;
  background: var(--cream);
}

.field-hint {
  display: block;
  margin-top: 8px;
  color: rgba(255,255,255,.55);
  font-size: .77rem;
  font-weight: 500;
}

.notice {
  margin: 0 0 6px;
  border: 1px solid rgba(232,184,72,.45);
  border-radius: 14px;
  padding: 15px 16px;
  background: rgba(232,184,72,.14);
}

.notice[hidden] { display: none; }
.notice strong { display: block; font-size: .95rem; }
.notice p { margin: 7px 0 0; color: rgba(255,255,255,.72); font-size: .83rem; line-height: 1.5; }
.notice a { display: inline-block; margin-top: 10px; color: #f5d789; font-size: .82rem; font-weight: 750; }

.delivery-note {
  display: inline-block;
  margin: 16px auto 0;
  border-radius: 999px;
  padding: 9px 15px;
  background: rgba(255,255,255,.1);
  color: rgba(255,255,255,.82);
  font-size: .85rem;
  font-weight: 650;
}

.delivery-note[hidden] { display: none; }
.delivery-note.sent { color: #c8f7d8; background: rgba(50,185,99,.18); }
.delivery-note.pending { color: #fbe6b0; background: rgba(232,184,72,.18); }

/* WhatsApp */
.whatsapp-panel { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 26px; align-items: start; }
.qr-frame {
  display: grid;
  place-items: center;
  min-height: 340px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: #fff;
  text-align: center;
}
.qr-frame img { width: 100%; max-width: 300px; height: auto; image-rendering: pixelated; }
.qr-frame p { margin: 0; color: var(--muted); font-size: .88rem; line-height: 1.55; }
.wa-state { display: inline-flex; align-items: center; gap: 8px; border-radius: 999px; padding: 8px 13px; font-size: .82rem; font-weight: 800; }
.wa-state.ready { color: #17633b; background: #e7f6ed; }
.wa-state.waiting { color: #8a6412; background: #fdf3dd; }
.wa-state.broken { color: #7b2a1f; background: #fff2ee; }
.wa-steps { margin: 18px 0 0; padding-left: 20px; color: var(--muted); font-size: .9rem; line-height: 1.7; }
.wa-progress { margin-top: 16px; }
.wa-progress[hidden] { display: none; }
.wa-progress p { margin: 8px 0 0; color: var(--muted); font-size: .85rem; }
#events table { font-size: .82rem; }
#events td { padding: 8px 10px; vertical-align: top; }
#events td:first-child { white-space: nowrap; color: var(--muted); }

@media (max-width: 760px) {
  .whatsapp-panel { grid-template-columns: 1fr; }
}

/* Analytics */
.dashboard {
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: 40px 28px 60px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--forest-2);
  font-size: .9rem;
  font-weight: 700;
  text-decoration: none;
}

.back-link:hover { text-decoration: underline; }

.dashboard-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 30px;
  margin: 28px 0 32px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.dashboard h1 { max-width: none; font-size: clamp(2.5rem, 5vw, 4rem); }
.dashboard-copy { max-width: 430px; margin: 0; color: var(--muted); line-height: 1.55; }

.dashboard-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 22px; }
.dashboard-button {
  min-height: 43px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 14px;
  color: var(--forest);
  background: #fff;
  cursor: pointer;
  font-weight: 750;
  text-decoration: none;
}

.dashboard-button:hover { background: #edf2ee; }

.dashboard-search {
  margin-bottom: 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  background: rgba(255,255,255,.7);
}
.dashboard-search label { display: block; margin-bottom: 9px; font-size: .86rem; font-weight: 750; }
.dashboard-search > div { display: grid; grid-template-columns: 1fr auto; gap: 9px; }
.dashboard-search input {
  min-width: 0;
  min-height: 43px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 13px;
  background: #fff;
  outline: none;
}
.dashboard-search input:focus { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(232,184,72,.18); }
.dashboard-search output { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 11px; color: var(--muted); font-size: .85rem; }
.dashboard-search output:empty { display: none; }
.dashboard-search output a { color: var(--forest-2); font-weight: 750; }

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.metric {
  min-height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-radius: 20px;
  padding: 24px;
  color: #fff;
  background: var(--forest);
}

.metric span { color: rgba(255,255,255,.65); font-size: .9rem; }
.metric strong { margin-top: 8px; font: 400 2.6rem Georgia, serif; }

.dashboard-grid {
  display: grid;
  grid-template-columns: .88fr 1.4fr;
  gap: 24px;
  margin-top: 26px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px;
  background: rgba(255,255,255,.82);
}

.panel h2 { margin: 0 0 24px; font: 700 1.7rem Georgia, serif; }

.creator-row + .creator-row { margin-top: 20px; }
.creator-top { display: flex; justify-content: space-between; gap: 16px; font-weight: 750; }
.bar { height: 8px; overflow: hidden; margin-top: 9px; border-radius: 999px; background: rgba(23,60,42,.1); }
.bar-fill { height: 100%; border-radius: inherit; background: var(--forest-2); }
.creator-date { margin: 7px 0 0; color: var(--muted); font-size: .76rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: 13px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .78rem; }
td a { color: var(--forest-2); font-weight: 700; }
td:last-child, th:last-child { text-align: right; white-space: nowrap; }
.empty { padding: 35px 18px; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); text-align: center; }
.error-banner { display: none; margin-bottom: 20px; border: 1px solid rgba(139,45,32,.2); border-radius: 12px; padding: 14px 16px; color: #7b2a1f; background: #fff2ee; }
.loading { color: var(--muted); }

/* Public verification */
.verify-page {
  width: min(900px, 100%);
  margin: 0 auto;
  padding: 42px 24px 70px;
}

.verify-hero {
  margin-top: 55px;
  text-align: center;
}

.verify-hero h1 { max-width: none; font-size: clamp(2.8rem, 7vw, 5.2rem); }
.verify-hero > p:not(.eyebrow) { max-width: 620px; margin: 20px auto 0; color: var(--muted); line-height: 1.6; }
.verify-form { max-width: 680px; margin: 32px auto 0; text-align: left; }
.verify-form label { display: block; margin-bottom: 9px; font-size: .875rem; font-weight: 750; }
.verify-form div { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.verify-form input {
  min-width: 0;
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 0 16px;
  color: var(--ink);
  background: #fff;
  outline: none;
  font-size: 1rem;
}
.verify-form input:focus { border-color: var(--focus); box-shadow: 0 0 0 4px rgba(232,184,72,.22); }
.verify-form button {
  border: 0;
  border-radius: 13px;
  padding: 0 22px;
  color: #fff;
  background: var(--forest);
  cursor: pointer;
  font-weight: 750;
}

.verify-results { display: grid; gap: 14px; max-width: 680px; margin: 30px auto 0; }
.verification-card {
  border: 1px solid var(--line);
  border-radius: 17px;
  padding: 22px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(23,60,42,.07);
}
.verified-badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 7px 10px;
  color: #17633b;
  background: #e7f6ed;
  font-size: .76rem;
  font-weight: 800;
}
.verified-badge.inactive { color: #7b2a1f; background: #fff2ee; }
.verification-card h2 { margin: 16px 0 8px; font: 700 1.7rem Georgia, serif; }
.verification-card > strong { color: var(--forest-2); letter-spacing: .04em; }
.verification-card p { margin: 8px 0 16px; color: var(--muted); font-size: .86rem; }
.verification-card a { color: var(--forest-2); font-weight: 750; }
.not-found { border: 1px dashed var(--line); border-radius: 15px; padding: 28px; text-align: center; }
.not-found p { margin: 8px 0 0; color: var(--muted); }

.certificate-page {
  color: #fff;
  background:
    radial-gradient(circle at 87% 10%, rgba(255,255,255,.12), transparent 27rem),
    linear-gradient(135deg, #0f3020 0%, var(--forest) 62%, #0f3322 100%);
}
.certificate-view { width: min(1180px, 100%); margin: 0 auto; padding: 36px 24px 60px; }
.back-link.light { color: rgba(255,255,255,.72); }
.certificate-view header { margin: 40px 0 26px; text-align: center; }
.certificate-view h1 { max-width: none; margin-top: 13px; font-size: clamp(2.5rem, 6vw, 4.7rem); }
.certificate-view header p { color: rgba(255,255,255,.65); }
.certificate-status { display: inline-flex; border-radius: 999px; padding: 8px 12px; font-size: .8rem; font-weight: 800; }
.certificate-status.valid { color: #c8f7d8; background: rgba(50,185,99,.17); }
.certificate-status.invalid { color: #ffd6cf; background: rgba(190,67,47,.18); }
.public-certificate { margin-top: 28px; }
.public-certificate[hidden], .public-actions[hidden] { display: none; }
.public-actions { display: flex; justify-content: center; gap: 10px; margin-top: 20px; }

@media (max-width: 980px) {
  .studio { min-height: auto; grid-template-columns: 1fr; align-items: start; padding-bottom: 44px; }
  .preview { grid-row: 1; }
  .controls { grid-row: 2; max-width: 680px; }
  .studio-header { margin-bottom: 28px; }
  h1 { max-width: 13ch; font-size: clamp(2.8rem, 10vw, 4.7rem); }
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .studio { padding: 15px 15px 34px; gap: 30px; }
  .preview-heading span { display: none; }
  .actions { grid-template-columns: 1fr; }
  .button-wide { grid-column: auto; }
  .dashboard { padding: 26px 15px 45px; }
  .dashboard-header { display: block; }
  .dashboard-copy { margin-top: 16px; }
  .metrics { grid-template-columns: 1fr; }
  .metric { min-height: 112px; }
  .panel { padding: 18px; }
  .dashboard-search > div { grid-template-columns: 1fr; }
  .verify-page { padding: 25px 15px 50px; }
  .verify-hero { margin-top: 38px; }
  .verify-form div { grid-template-columns: 1fr; }
  .verify-form button { min-height: 52px; }
  .public-actions { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

@media print {
  @page { size: landscape; margin: 0; }
  html, body { min-height: 0; background: #fff !important; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .screen-only { display: none !important; }
  .studio { display: block; width: 100%; min-height: 0; margin: 0; padding: 0; }
  .certificate { width: 100%; border-radius: 0; box-shadow: none; }
}
