:root {
  color-scheme: light;
  --paper: #ffffff;
  --surface: #ffffff;
  --soft: #f3f5f9;
  --ink: #022739;
  --muted: #4f5d66;
  --line: #dbe5eb;
  --control: #708e9d;
  --accent: #0c629c;
  --button: #022739;
  --on-button: #ffffff;
  --ok-bg: #eaf6ee;
  --ok-ink: #0a5d2c;
  --error-bg: #fbecec;
  --error-ink: #a72222;
  --s1: #2a78d6;
  --s2: #eb6834;
  --track: #e9eef2;
  --grid: #e3e8ec;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --paper: #0f1418; --surface: #161d22; --soft: #1c252b; --ink: #e8eef2; --muted: #a3b2bb; --line: #2a343b; --control: #6f8794;
    --accent: #6fb3e8; --button: #e8eef2; --on-button: #0f1418; --ok-bg: #12301f; --ok-ink: #7fd6a0; --error-bg: #3a1a1a; --error-ink: #f2a3a3;
    --s1: #3987e5; --s2: #d95926; --track: #253038; --grid: #26313a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0f1418; --surface: #161d22; --soft: #1c252b; --ink: #e8eef2; --muted: #a3b2bb; --line: #2a343b; --control: #6f8794;
  --accent: #6fb3e8; --button: #e8eef2; --on-button: #0f1418; --ok-bg: #12301f; --ok-ink: #7fd6a0; --error-bg: #3a1a1a; --error-ink: #f2a3a3;
  --s1: #3987e5; --s2: #d95926; --track: #253038; --grid: #26313a;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 16px/1.6 Inter, system-ui, sans-serif; -webkit-font-smoothing: antialiased; min-height: 100vh; display: flex; flex-direction: column; }
h1, h2, h3 { font-family: Quattrocento, Georgia, serif; line-height: 1.15; letter-spacing: -.02em; margin: 0 0 .4em; text-wrap: balance; }
h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); }
h2 { font-size: 1.3rem; }
p { margin: 0 0 .8em; }
a { color: var(--accent); text-underline-offset: .2em; }
code { font: 600 .95em ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .02em; }
img { max-width: 100%; height: auto; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 16px; z-index: 50; }
.skip-link:focus { left: 16px; }

.site-header { position: sticky; top: 0; z-index: 20; background: var(--paper); border-bottom: 1px solid var(--line); }
.header-inner { width: min(1200px, calc(100% - 32px)); margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 68px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font: 700 1.25rem/1.1 Quattrocento, Georgia, serif; }
.brand img { border-radius: 10px; background: #fff; padding: 2px; }
.brand small { display: block; font: 500 .75rem Inter, sans-serif; color: var(--muted); margin-top: 2px; }
.header-tools { display: flex; align-items: center; gap: 10px; }
.lang { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.lang a { padding: 6px 10px; font-size: .8rem; font-weight: 600; color: var(--muted); text-decoration: none; }
.lang a[aria-current] { background: var(--soft); color: var(--ink); }
.theme-toggle, .link-button { white-space: nowrap; min-height: 36px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--ink); font: 600 .85rem Inter, sans-serif; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; }
.area-nav { border-top: 1px solid var(--line); }
.area-nav .header-inner { min-height: 48px; justify-content: flex-start; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.area-nav a { padding: 12px 12px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: .92rem; white-space: nowrap; border-bottom: 3px solid transparent; }
.area-nav a[aria-current] { color: var(--ink); border-bottom-color: var(--accent); }

.shell { width: min(1200px, calc(100% - 32px)); margin: 0 auto; }
main.shell { padding: 32px 0 56px; flex: 1; }
main.narrow { width: min(640px, calc(100% - 32px)); }
.site-footer { border-top: 1px solid var(--line); padding: 20px 0; color: var(--muted); font-size: .85rem; }
.site-footer .shell { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.site-footer a { color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.form-card { max-width: 640px; }
.form-card.wide { max-width: 820px; }
.page-head { margin-bottom: 20px; }
.page-head h1 { margin-bottom: .2em; }
.eyebrow { font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.eyebrow a { color: inherit; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.lead { font-size: 1.1rem; color: var(--muted); }
.notice { border-radius: 10px; padding: 12px 16px; margin: 0 0 16px; font-weight: 500; }
.notice.ok { background: var(--ok-bg); color: var(--ok-ink); }
.notice.error { background: var(--error-bg); color: var(--error-ink); }
.text-link { font-weight: 600; text-decoration: none; }

.button { min-height: 46px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 20px; border-radius: 8px; border: 1px solid transparent; background: var(--button); color: var(--on-button); font: 650 .95rem Inter, sans-serif; text-decoration: none; cursor: pointer; transition: transform 120ms ease-out; }
.button:active { transform: scale(.98); }
.button.secondary { background: transparent; color: var(--ink); border-color: var(--control); }
.button.danger { background: transparent; color: var(--error-ink); border-color: var(--error-ink); }
.small-button { min-height: 34px; padding: 4px 12px; font-size: .82rem; }
form.inline { display: inline; margin: 0; }

.stack { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field-label { font-weight: 600; font-size: .92rem; display: flex; align-items: center; gap: 6px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--control); border-radius: 8px; padding: 10px 12px; min-height: 46px; width: 100%; }
textarea { min-height: 90px; resize: vertical; }
input[type="checkbox"] { width: 20px; min-height: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: .95rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin: 0; display: grid; gap: 14px; }
legend { font-weight: 700; padding: 0 6px; display: flex; align-items: center; gap: 6px; }
.hint { position: relative; display: inline-block; font-weight: 400; }
.hint summary { list-style: none; cursor: pointer; color: var(--accent); font-size: .95rem; line-height: 1; padding: 2px; }
.hint summary::-webkit-details-marker { display: none; }
.hint[open] > div { position: absolute; z-index: 10; left: 0; top: 24px; width: min(300px, 80vw); background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: .85rem; box-shadow: 0 8px 24px rgb(0 0 0 / .12); }

.hero-card { padding: 16px 0; }
.code-form { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; margin: 20px 0; }
.code-input { text-transform: uppercase; font: 700 1.3rem ui-monospace, Menlo, monospace; letter-spacing: .08em; min-height: 54px; }
.code-form .button { min-height: 54px; }
.steps { color: var(--muted); padding-left: 20px; }

.offer, .voucher { text-align: center; display: grid; gap: 12px; justify-items: center; padding: 28px 20px; }
.advertiser { display: flex; align-items: center; gap: 12px; font-size: 1.1rem; }
.advertiser img { width: 56px; height: 56px; object-fit: contain; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
.reward { font: 700 clamp(2rem, 7vw, 3rem)/1.1 Quattrocento, Georgia, serif; margin: 0; }
.code-chip code { font-size: 1.1rem; }
.offer form, .offer .stack { width: 100%; max-width: 420px; text-align: left; }
.offer .button, .voucher > .button { width: 100%; max-width: 420px; }
.message { max-width: 520px; }
.voucher-code { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; background: var(--soft); border-radius: 10px; padding: 10px 16px; }
.voucher-code code { font-size: 1.5rem; letter-spacing: .08em; }
.qr { width: 180px; max-width: 60vw; background: #fff; padding: 6px; border-radius: 8px; border: 1px solid var(--line); }
.qr svg { display: block; width: 100%; height: auto; }
.offer-image { border-radius: 10px; max-height: 320px; object-fit: contain; }
.terms { text-align: left; width: 100%; max-width: 520px; font-size: .9rem; color: var(--muted); }
.terms summary { cursor: pointer; font-weight: 600; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--soft); color: var(--ink); white-space: nowrap; }
.status-used { background: var(--ok-bg); color: var(--ok-ink); }
.status-void { background: var(--error-bg); color: var(--error-ink); }
.muted-badge { margin-left: 8px; color: var(--muted); }
.manage { max-width: 640px; margin-inline: auto; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 16px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.danger-zone { margin-top: 12px; }
.voucher-list { list-style: none; padding: 0; display: grid; gap: 12px; }
.voucher-list .card { margin: 0; padding: 0; }
.voucher-list a { display: grid; gap: 4px; padding: 16px; color: var(--ink); text-decoration: none; }
.row-meta { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: .85rem; }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 20px; }
.filters .field { min-width: 180px; flex: 1 1 180px; max-width: 280px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; align-content: start; gap: 2px; background: var(--surface); }
.kpi-label { font-size: .85rem; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi-value { font: 700 1.6rem/1.2 Inter, sans-serif; font-variant-numeric: tabular-nums; overflow-wrap: break-word; }
.kpi-note { font-size: .8rem; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-2 > .card { margin-bottom: 20px; }
.chart-card { margin: 0 0 20px; }
.chart-card figcaption h2 { margin-bottom: 8px; }
.line-chart svg { width: 100%; height: auto; display: block; }
.line-chart .grid { stroke: var(--grid); stroke-width: 1; }
.line-chart .axis { fill: var(--muted); font-size: 11px; font-family: Inter, sans-serif; }
.line-chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.line.s1 { stroke: var(--s1); } .line.s2 { stroke: var(--s2); }
.dot { stroke: var(--surface); stroke-width: 2; }
.dot.s1 { fill: var(--s1); } .dot.s2 { fill: var(--s2); }
.hit { fill: transparent; }
.hit:hover { fill: var(--soft); fill-opacity: .6; }
.legend { list-style: none; display: flex; gap: 16px; padding: 0; margin: 0 0 6px; font-size: .85rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.swatch.s1 { background: var(--s1); } .swatch.s2 { background: var(--s2); }
.bar { display: block; width: 100%; height: 6px; margin-top: 4px; }
.bar.big { height: 10px; margin: 0; }
.bar .track { fill: var(--track); }
.bar .fill.s1 { fill: var(--s1); }
.bar-rows { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 12px; }
.bar-rows li { display: grid; grid-template-columns: minmax(110px, 30%) 1fr auto; gap: 12px; align-items: center; }
.bar-label { font-weight: 600; font-size: .9rem; }
.bar-value { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.bar-value small { color: var(--muted); font-weight: 500; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: .8rem; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.breakdown td:first-child { min-width: 160px; }
.plain-list { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 10px; }
.plain-list li { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.row-actions { display: flex; gap: 8px; }
.share-links ul { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 10px; }
.share-links li { display: grid; grid-template-columns: 170px 1fr auto auto; gap: 10px; align-items: center; }
.share-links .url { overflow-wrap: anywhere; font-size: .82rem; background: var(--soft); padding: 6px 8px; border-radius: 6px; }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; }
.temp-password code { font-size: 1.2rem; }

@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; gap: 0; }
  .share-links li { grid-template-columns: 1fr auto auto; }
  .share-links li > span { grid-column: 1 / -1; font-weight: 600; }
}
@media (max-width: 560px) {
  main.shell { padding-top: 20px; }
  .brand { font-size: 1.05rem; }
  .brand img { width: 36px; height: 36px; }
  .brand small { display: none; }
  .header-tools { gap: 6px; }
  .theme-toggle, .link-button { padding: 6px 9px; }
  .code-form, .inline-form, .field-row { grid-template-columns: 1fr; }
  .kpi-value { font-size: 1.1rem; }
  .filters .field { max-width: none; }
  .bar-rows li { grid-template-columns: 1fr auto; }
  .bar-rows .bar { grid-column: 1 / -1; grid-row: 2; }
  .facts { grid-template-columns: 1fr; gap: 2px; }
  .facts dd { margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) { .button { transition: none; } }
