:root {
  --brand: #D7261E;
  --brand-dark: #B01E17;
  --bg: #EEF0F3;
  --card: #FFFFFF;
  --text: #16181D;
  --muted: #5F6672;
  --line: #DADDE3;
  --radius: 14px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.container {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); }
.topbar__inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-size: 20px; font-weight: 600; }
.brand b { color: var(--brand); }
.topbar__link { color: var(--muted); text-decoration: none; font-size: 14px; }
.topbar__link:hover { color: var(--text); }

main.container { padding-top: 28px; padding-bottom: 40px; display: grid; gap: 24px; }
main[hidden] { display: none; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  padding: 28px;
}

/* Generator */
.generator {
  display: grid;
  grid-template-columns: 1fr 260px;
  grid-template-areas: "form preview" "options preview";
  grid-template-rows: auto 1fr;
  column-gap: 32px;
  align-items: start;
}
.generator__form { grid-area: form; }
.generator__options { grid-area: options; }
.generator__preview { grid-area: preview; }

h1 { font-size: 26px; line-height: 1.25; margin: 0 0 6px; }
h2 { font-size: 22px; margin: 0 0 16px; }
.lead { color: var(--muted); margin: 0 0 22px; }

.field-label { display: block; font-size: 14px; font-weight: 600; margin: 0 0 8px; }

.text-input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.text-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(215, 38, 30, .15); }
.pw-wrap { position: relative; }
.pw-wrap .text-input { padding-right: 48px; }
.pw-toggle {
  position: absolute; top: 0; right: 0;
  width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center;
  border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 10px;
}
.pw-toggle:hover { color: var(--text); }
.pw-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: -4px; }
.hint { font-size: 13px; color: var(--muted); margin: 6px 0 18px; }

.customize { border: 1px solid var(--line); border-radius: 12px; }
.customize > summary { cursor: pointer; padding: 12px 14px; font-size: 14px; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; }
.customize > summary::-webkit-details-marker { display: none; }
.customize > summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s; }
.customize[open] > summary::before { transform: rotate(45deg); }
.customize__body { padding: 4px 14px 16px; }

.swatches, .logos { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }

.swatch {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 0;
  background: var(--c);
  cursor: pointer;
  position: relative;
  padding: 0;
}
.swatch[aria-checked="true"]::after {
  content: ""; position: absolute; inset: -4px;
  border-radius: 50%; border: 2px solid var(--c);
}
.swatch--custom {
  background: conic-gradient(#ef4444, #f59e0b, #22c55e, #3b82f6, #a855f7, #ef4444);
  overflow: hidden;
  display: inline-block;
}
.swatch--custom input { opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }
.swatch--custom[aria-checked="true"]::after { border-color: var(--text); }

.check { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; margin-bottom: 10px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); }

.logo-opt {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  display: grid; place-items: center;
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  color: var(--text);
}
.logo-opt[hidden] { display: none; }
.logo-opt img { width: 30px; height: 30px; object-fit: contain; }
.logo-opt svg { width: 22px; height: 22px; }
.logo-opt span { font-size: 10px; font-weight: 800; letter-spacing: .02em; }
.logo-opt[aria-checked="true"] { border: 2px solid var(--brand); }
.logos.is-disabled { opacity: .4; pointer-events: none; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 42px; padding: 0 16px;
  border-radius: 10px;
  font: inherit; font-size: 15px; font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn--ghost { background: #fff; color: var(--text); border-color: var(--line); }
.btn--ghost:hover:not(:disabled) { border-color: #b9bec7; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--sm { height: 36px; font-size: 14px; padding: 0 12px; }

.upload { position: relative; }
.upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }

/* Preview */
.generator__preview { display: flex; flex-direction: column; align-items: stretch; gap: 12px; position: sticky; top: 16px; }
.qr-frame {
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  display: grid; place-items: center;
  background: #fff;
}
#qr-canvas, #qr-canvas canvas, #qr-canvas svg { width: 100% !important; height: auto !important; display: block; }
.qr-frame[data-empty="true"] #qr-canvas { opacity: .18; filter: grayscale(1); }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.link-btn { background: none; border: 0; color: var(--brand); font: inherit; font-size: 13px; cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:disabled { color: var(--muted); opacity: .6; cursor: not-allowed; text-decoration: none; }
.toast { margin: 0; text-align: center; font-size: 13px; color: #15803D; }

/* FAQ */
.faq details { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; }
.faq summary { cursor: pointer; padding: 14px 44px 14px 16px; font-weight: 600; list-style: none; position: relative; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-size: 22px; font-weight: 400; color: var(--muted); }
.faq details[open] summary::after { content: "−"; }
.faq details p { margin: 0; padding: 0 16px 16px; color: var(--muted); }

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

@media (max-width: 720px) {
  main.container { padding-top: 16px; padding-bottom: 32px; gap: 16px; }
  .card { padding: 20px 16px; }
  .generator { grid-template-columns: 1fr; grid-template-areas: "form" "preview" "options"; grid-template-rows: auto; }
  .generator__preview { position: static; max-width: 280px; width: 100%; margin: 0 auto 20px; }
  .hint { margin-bottom: 16px; }
  h1 { font-size: 22px; }
  .topbar__link { display: none; }
}

/* Header nav */
.topbar__nav { display: flex; align-items: center; gap: 14px; }
.topbar__user { font-size: 14px; color: var(--muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.btn { text-decoration: none; }

/* Shorten box on the home page */
.shorten { border: 1px dashed var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; }
.shorten .check { margin-bottom: 2px; }
.shorten__desc { margin: 0 0 0 25px; font-size: 13px; color: var(--muted); }
.shorten__body { margin: 12px 0 0 25px; }
.shorten__login { margin: 0; font-size: 14px; }
.shorten__login a, .shorten__result a { color: var(--brand); font-weight: 600; }
.shorten__result { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; font-size: 15px; }

.form-error { color: var(--brand); font-size: 14px; margin: 10px 0 0; }

/* Auth */
.auth-wrap { max-width: 440px; }
.auth h1 { margin-bottom: 8px; }
.auth__lead { margin: 16px 0 20px; font-size: 15px; }
.auth__gap { margin-top: 16px; }
.btn--block { width: 100%; margin-top: 20px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border-radius: 10px; padding: 4px; }
.tab { border: 0; background: none; font: inherit; font-weight: 600; padding: 9px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.tab[aria-selected="true"] { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 40, .1); }

/* Dashboard */
.container--wide { max-width: 1080px; }
.h-sm { font-size: 18px; margin: 0 0 6px; }
.muted { color: var(--muted); font-weight: 400; }
.break { overflow-wrap: anywhere; }
.empty { color: var(--muted); font-size: 14px; margin: 8px 0 0; }
#view-list, #view-stats { display: grid; gap: 20px; }
#view-list > *, #view-stats > *, main.container > *, .grid-2 > *, .grid-3 > * { min-width: 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }

.create-form { display: grid; grid-template-columns: 2fr 1fr auto; gap: 10px; }
.create-form .btn { height: 46px; }

.link-row { display: grid; grid-template-columns: 1fr 90px auto; gap: 16px; align-items: center; padding: 16px 0; border-top: 1px solid var(--line); }
.link-row:first-child { border-top: 0; }
.link-row__main { min-width: 0; }
.link-row__title { font-weight: 600; }
.link-row__short { display: flex; gap: 10px; align-items: center; font-size: 15px; }
.link-row__short a { color: var(--brand); font-weight: 600; text-decoration: none; }
.link-row__dest { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-row__meta { font-size: 12px; }
.link-row__scans { text-align: center; display: flex; flex-direction: column; }
.link-row__scans b { font-size: 22px; line-height: 1.1; }
.link-row__scans span { font-size: 12px; }
.link-row__actions, .row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.row-actions { margin-top: 12px; }
.btn--danger { color: var(--brand); }

.back { justify-self: start; text-decoration: none; font-size: 14px; }
.stats-head { display: grid; grid-template-columns: 1fr 140px; gap: 20px; align-items: center; }
.stats-head__qr { width: 140px; }
.stats-head__qr canvas { width: 100% !important; height: auto !important; display: block; }
.short-url { margin: 4px 0; display: flex; gap: 10px; align-items: center; font-size: 17px; }
.short-url a { color: var(--brand); font-weight: 700; text-decoration: none; }
#s-dest { margin: 0; font-size: 14px; }

.period { display: flex; align-items: center; gap: 10px; justify-content: flex-end; font-size: 14px; }
.select { height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; font: inherit; font-size: 14px; background: #fff; }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.kpi { background: var(--card); border-radius: var(--radius); padding: 18px 20px; box-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08); display: flex; flex-direction: column; }
.kpi__label { font-size: 13px; color: var(--muted); }
.kpi__value { font-size: 30px; line-height: 1.2; font-variant-numeric: tabular-nums; }

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

.vbars { display: flex; align-items: flex-end; gap: 2px; height: 180px; margin-top: 12px; }
.vbar { flex: 1; display: flex; flex-direction: column; height: 100%; min-width: 0; }
.vbar__track { flex: 1; display: flex; align-items: flex-end; }
.vbar__fill { width: 100%; background: var(--brand); border-radius: 3px 3px 0 0; min-height: 2px; }
.vbar__fill.is-zero { background: var(--line); }
.vbar:hover .vbar__fill { background: var(--brand-dark); }
.vbar__label { font-size: 11px; color: var(--muted); height: 18px; line-height: 18px; white-space: nowrap; overflow: visible; }

.hbar { margin-top: 12px; font-size: 14px; }
.hbar__top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.hbar__track { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.hbar__fill { height: 100%; background: var(--brand); border-radius: 4px; }

.table-wrap { overflow-x: auto; margin-top: 8px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }

.dialog { border: 0; border-radius: var(--radius); padding: 24px; width: min(480px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgba(0, 0, 0, .2); }
.dialog::backdrop { background: rgba(16, 24, 40, .45); }
.dialog__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.toast--float { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #16181D; color: #fff !important; padding: 10px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); z-index: 10; max-width: calc(100vw - 32px); }
.toast--float.toast--error { background: var(--brand); }

@media (max-width: 860px) {
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .create-form { grid-template-columns: 1fr; }
  .link-row { grid-template-columns: 1fr auto; }
  .link-row__actions { grid-column: 1 / -1; }
  .stats-head { grid-template-columns: 1fr; }
  .stats-head__qr { width: 160px; }
  .grid-2 { grid-template-columns: 1fr; }
  .kpis { gap: 8px; }
  .kpi { padding: 12px; }
  .kpi__value { font-size: 22px; }
  .topbar__user { display: none; }
  .topbar__link--keep { display: inline; }
  .vbars { height: 140px; }
}

/* Anti-abuse UI */
.center { text-align: center; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; }
.label-row .field-label { margin-bottom: 8px; }
.small-link { font-size: 13px; color: var(--brand); text-decoration: none; }
.small-link:hover { text-decoration: underline; }
.turnstile { margin-top: 16px; min-height: 0; }
.turnstile:empty { margin-top: 0; }
.form-ok { color: #15803D; font-size: 14px; margin: 12px 0 0; }
.textarea { height: auto; padding: 10px 14px; resize: vertical; line-height: 1.5; }
select.text-input { appearance: auto; }

.banner { display: flex; align-items: center; justify-content: space-between; gap: 16px; background: #FFF7E6; border: 1px solid #F5C26B; border-radius: var(--radius); padding: 14px 18px; font-size: 14px; }
.banner b { display: block; margin-bottom: 2px; }

.badge { display: inline-block; margin-left: 8px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; vertical-align: 2px; }
.badge--locked { background: #FDE8E7; color: var(--brand); }
.locked-note { font-size: 13px; color: var(--brand); margin: 4px 0 0; }

.link-row--admin { grid-template-columns: 1fr auto; align-items: start; }
.link-row--admin .link-row__title a { color: var(--brand); text-decoration: none; }
.link-row--admin .link-row__dest { white-space: normal; }
.report-meta { font-size: 13px; margin-top: 6px; }
.report-details { font-size: 13px; color: var(--muted); background: var(--bg); border-radius: 8px; padding: 8px 10px; margin-top: 6px; white-space: pre-wrap; }
.search { width: min(320px, 100%); }
.search .text-input { height: 38px; font-size: 14px; }

.warn-icon { width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 50%; background: #FDE8E7; color: var(--brand); font-size: 30px; font-weight: 800; display: grid; place-items: center; }

.prose h1 { margin-bottom: 4px; }
.prose h2 { font-size: 18px; margin: 24px 0 8px; }
.prose p, .prose li { color: #343a46; }
.prose ul { padding-left: 20px; }
.prose a, .footer a { color: var(--brand); }

@media (max-width: 720px) {
  .banner { flex-direction: column; align-items: flex-start; }
  .link-row--admin { grid-template-columns: 1fr; }
  .section-head { flex-wrap: wrap; gap: 8px; }
}

/* Static QR history in the dashboard */
.history-lead { font-size: 14px; margin: 0 0 8px; }
.history-row { display: grid; grid-template-columns: 64px 1fr auto; gap: 16px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); }
.history-row:first-child { border-top: 0; }
.history-row__qr { width: 64px; height: 64px; }
.history-row__qr svg { width: 100%; height: 100%; display: block; }
.history-row__data { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); text-decoration: none; }
a.history-row__data:hover { color: var(--brand); }
.empty a, .lead a { color: var(--brand); font-weight: 600; }
@media (max-width: 720px) {
  .history-row { grid-template-columns: 56px 1fr; }
  .history-row__qr { width: 56px; height: 56px; }
  .history-row .link-row__actions { grid-column: 1 / -1; }
}


.quota { margin: 10px 0 0; }

/* Admin overview */
.kpis--4 { grid-template-columns: repeat(4, 1fr); }
.kpi__sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.badge--muted { background: var(--bg); color: var(--muted); }
.table .badge { margin-left: 0; }
.badge--ok { background: #E7F6EC; color: #15803D; }
.table--num td:not(:first-child), .table--num th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 720px) {
  .kpis--4 { grid-template-columns: repeat(2, 1fr); }
}

/* Link check page + footer disclaimer */
.check-result { display: grid; gap: 10px; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.check-result[hidden] { display: none; }
.check-result p { margin: 0; }
.check-result__status { padding: 12px 14px; border-radius: 10px; font-weight: 600; }
.check-result__status--ok { background: #E7F6EC; color: #15803D; }
.check-result__status--warning { background: #FEF3C7; color: #92400E; }
.check-result__status--locked { background: #FDE8E7; color: var(--brand); }
.footer__note { max-width: 640px; margin: 8px auto 0; font-size: 12px; line-height: 1.5; }
