/* =====================================================================
   Lumen — app chrome additions, admin console & partner portal
   Builds on tokens from lumen.css
   ===================================================================== */

/* ---------- page shell for WordPress pages ---------- */
.page-main { display: block; outline: none; }
.page-content:not(:has(#lumen-root)) { max-width: 760px; margin-inline: auto; padding: clamp(2rem, 6vw, 4rem) var(--gutter); display: grid; gap: 1rem; }
.page-content:not(:has(#lumen-root)) h1 { font-family: var(--f-display); font-weight: 500; font-size: var(--fs-2xl); line-height: 1.1; margin: 0 0 .5rem; }
.page-content:not(:has(#lumen-root)) h2 { font-family: var(--f-display); font-weight: 500; font-size: var(--fs-xl); margin: 1.5rem 0 0; }
.page-content:not(:has(#lumen-root)) p, .page-content:not(:has(#lumen-root)) li { color: var(--ink-2); max-width: 68ch; }
.page-content:not(:has(#lumen-root)) a { color: var(--emerald); }
.not-found { text-align: left; }
.lumen-app-page .page-content { display: block; }
.legal-links a { font-size: var(--fs-sm); color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; padding: .35rem 0; }
.legal-links a:hover { color: var(--ink); text-decoration-color: currentColor; }
a.lang { text-decoration: none; color: inherit; }

/* ---------- auth pages ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; }
.auth__head { display: flex; justify-content: space-between; align-items: center; min-height: 72px; }
.auth__foot { padding-block: 1.25rem; border-top: 1px solid var(--line-2); }
.login__forms { display: grid; gap: 1rem; max-width: 440px; width: 100%; }
.login__form[data-form="sent"] { justify-items: start; }
.login__form .success__badge { margin-bottom: .5rem; }

/* ---------- loading & busy ---------- */
.loading { display: flex; gap: .8rem; align-items: center; padding: 3rem 0; color: var(--ink-3); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--emerald); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-color: var(--b-fg) transparent var(--b-fg) transparent; animation: spin .8s linear infinite; }
.toast--error { background: var(--neg); color: #fff; }
.toast--error .ic { color: #fff; }
textarea { width: 100%; min-height: 90px; padding: .6rem .85rem; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; resize: vertical; }
input[type="color"] { width: 56px; height: 40px; padding: 2px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); }
input[type="file"] { font: inherit; font-size: var(--fs-sm); }
.field__help { font-size: var(--fs-xs); color: var(--ink-3); }

/* member app bits */
.quest--done .quest__ic { background: var(--gold-soft); color: var(--gold-ink); }
.claimlist { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; gap: .5rem; font-size: var(--fs-sm); }
.claimlist li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .3rem .8rem; padding-top: .5rem; border-top: 1px solid var(--line-2); }
.claimlist .fineprint { flex-basis: 100%; }
.mono-code { font-family: var(--f-mono); letter-spacing: .06em; background: none; border: 0; padding: 0; cursor: pointer; }
.pwchange { border-top: 1px solid var(--line-2); padding-top: 1rem; }
.pwchange summary { cursor: pointer; font-weight: 600; font-size: var(--fs-sm); margin-bottom: 1rem; }
.reqlog { margin-top: 1rem; }
.scanvid { width: 100%; border-radius: var(--r-md); background: #000; aspect-ratio: 4/3; object-fit: cover; }
.cardcode canvas { width: 140px; height: 140px; }
.voucher canvas { width: 120px; height: 120px; }
.dash__rings .ringbox__svg .rings text { font-size: 44px; }

/* ---------- console layout ---------- */
.console .sidebar { background: var(--surface-2); }
.navgroup { display: grid; gap: .1rem; }
.navgroup + .navgroup { margin-top: .9rem; }
.navgroup__h { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; padding: 0 .75rem .3rem; }
.sidenav .count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--gold); color: #1C140A; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.console .sidenav { overflow-y: auto; flex: 1 1 auto; min-height: 0; align-content: start; margin-inline: -.25rem; padding-inline: .25rem; }
.console .sidenav a { padding-block: .5rem; }
.console .sidebar { gap: 1rem; }
.role-chip { display: inline-flex; align-items: center; gap: .35rem; font-size: var(--fs-xs); font-weight: 600; color: var(--ink-2); padding: .3rem .7rem; border-radius: 999px; background: var(--paper-2); }
.console-main > section { display: grid; gap: 1.25rem; max-width: 1280px; margin-inline: auto; }
.crumbs { display: flex; gap: .5rem; align-items: center; font-size: var(--fs-sm); color: var(--ink-3); }
.crumbs a { color: var(--emerald); text-decoration: none; }

/* KPI tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; }
.tile { padding: 1.1rem 1.2rem; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line-2); display: grid; gap: .25rem; align-content: start; }
.tile__v { font-family: var(--f-display); font-size: 1.8rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile__s { font-size: var(--fs-xs); color: var(--ink-3); }
.tile--link { text-decoration: none; color: inherit; transition: border-color .2s; }
.tile--link:hover { border-color: var(--emerald); }
.tile--alert { border-color: color-mix(in srgb, var(--warn) 45%, var(--line-2)); background: color-mix(in srgb, var(--warn-soft) 55%, var(--surface)); }
.tile--alert .tile__v { color: var(--warn); }

/* work queue */
.queue { list-style: none; margin: 0; padding: 0; display: grid; }
.queue li { display: flex; gap: .8rem; align-items: center; padding: .7rem 0; border-top: 1px solid var(--line-2); font-size: var(--fs-sm); }
.queue li:first-child { border-top: 0; }
.queue .ic { color: var(--gold); }
.queue a { margin-left: auto; }

/* chart */
.chart { width: 100%; height: auto; display: block; }
.chart text { font: 11px var(--f-body); fill: var(--ink-3); }
.chart .grid { stroke: var(--line-2); stroke-width: 1; }
.chart .bar-issued { fill: var(--emerald); }
.chart .bar-redeemed { fill: var(--gold); }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .35rem; vertical-align: -1px; }
.hbar { display: grid; gap: .5rem; }
.hbar__row { display: grid; grid-template-columns: 90px 1fr auto; gap: .7rem; align-items: center; font-size: var(--fs-sm); }
.hbar__track { height: 10px; border-radius: 5px; background: var(--paper-2); overflow: hidden; }
.hbar__track i { display: block; height: 100%; background: var(--tc, var(--emerald)); border-radius: 5px; }

/* data tables */
.dtable { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); background: var(--surface); }
.dtable th { text-align: left; font-size: var(--fs-xs); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; padding: .7rem .8rem; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
.dtable td { padding: .65rem .8rem; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.dtable tr:last-child td { border-bottom: 0; }
.dtable .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dtable tr[data-href] { cursor: pointer; }
.dtable tr[data-href]:hover td { background: var(--surface-2); }
.dtable .tx__sub { display: block; font-size: var(--fs-xs); color: var(--ink-3); }
.dtable .actions { display: flex; gap: .4rem; justify-content: flex-end; flex-wrap: wrap; }
.panel > .table-scroll { margin-inline: calc(-1 * clamp(1.1rem, 2.5vw, 1.6rem)); border-top: 1px solid var(--line-2); }
.panel > .table-scroll .dtable { background: transparent; }
.panel > .table-scroll .dtable th { background: transparent; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; font-size: var(--fs-sm); color: var(--ink-3); }

.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; }
.filters .field { min-width: 150px; flex: 0 1 200px; }
.filters .search { flex: 1 1 260px; }
.filters select, .filters input { min-height: 40px; }

/* detail layout */
.detail { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.detail__side { display: grid; gap: 1rem; position: sticky; top: calc(80px + env(safe-area-inset-top, 0px)); }
.facts { display: grid; gap: .7rem; margin: 0; }
.facts div { display: grid; grid-template-columns: 120px 1fr; gap: .8rem; font-size: var(--fs-sm); }
.facts dt { color: var(--ink-3); }
.facts dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }
.bigbal { font-family: var(--f-display); font-size: 2.6rem; font-weight: 300; line-height: 1; }
.btnrow { display: flex; flex-wrap: wrap; gap: .5rem; }

/* forms in dialogs */
.dlg--form { width: min(720px, calc(100vw - 32px)); }
.form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-sec { grid-column: 1 / -1; font-size: var(--fs-xs); letter-spacing: .12em; text-transform: uppercase; font-weight: 700; color: var(--ink-3); padding-top: .6rem; border-top: 1px solid var(--line-2); margin-top: .3rem; }
.check--inline { align-self: center; }
.keybox { font-family: var(--f-mono); font-size: var(--fs-sm); padding: .8rem 1rem; border-radius: var(--r-md); background: var(--paper-2); border: 1px dashed var(--gold); overflow-wrap: anywhere; user-select: all; }

/* import */
.dropzone { display: grid; place-items: center; gap: .6rem; padding: 2rem; border: 2px dashed var(--line); border-radius: var(--r-lg); text-align: center; color: var(--ink-2); background: var(--surface); }
.dropzone.is-over { border-color: var(--emerald); background: var(--emerald-soft); }
.progress { height: 10px; border-radius: 5px; background: var(--paper-2); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--emerald), var(--gold)); transition: width .3s; }
.errlist { max-height: 220px; overflow: auto; font-size: var(--fs-sm); color: var(--neg); margin: 0; padding-left: 1.2rem; }

/* tiers editor */
.tiers-edit { display: grid; gap: .5rem; }
.tiers-edit__row { display: grid; grid-template-columns: 1fr 1fr 1fr .8fr .8fr .8fr auto; gap: .5rem; align-items: end; }
.tiers-edit__row .field label { font-size: var(--fs-xs); }

/* partner portal */
.pos { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.memberchip { display: flex; gap: .8rem; align-items: center; padding: .9rem 1rem; border-radius: var(--r-md); background: var(--emerald-soft); }
.memberchip strong { display: block; }
.memberchip .muted { font-size: var(--fs-xs); }
.memberchip.is-bad { background: color-mix(in srgb, var(--neg) 12%, var(--surface)); }
.estimate { font-family: var(--f-display); font-size: 2rem; color: var(--emerald); line-height: 1.1; }
.inputrow { display: flex; gap: .5rem; }
.inputrow input { flex: 1; }
.codeblock { margin: 0; padding: 1rem; border-radius: var(--r-md); background: var(--emerald-deep); color: #D9E6DE; font: 12px/1.6 var(--f-mono); overflow-x: auto; white-space: pre; }

@media (max-width: 1100px) {
  .detail, .pos { grid-template-columns: minmax(0, 1fr); }
  .detail__side { position: static; }
  .tiers-edit__row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .form-grid--3 { grid-template-columns: minmax(0, 1fr); }
  .facts div { grid-template-columns: 1fr; gap: .1rem; }
  .dtable thead { display: none; }
  .dtable, .dtable tbody, .dtable tr, .dtable td { display: block; }
  .dtable tr { padding: .6rem .8rem; border-bottom: 1px solid var(--line-2); }
  .dtable td { border: 0; padding: .15rem 0; display: flex; justify-content: space-between; gap: 1rem; text-align: right; }
  .dtable td::before { content: attr(data-label); color: var(--ink-3); font-size: var(--fs-xs); text-align: left; }
  .dtable td[data-label=""]::before { content: none; }
  .dtable .num { text-align: right; }
  .tiers-edit__row { grid-template-columns: 1fr 1fr; }
  .hbar__row { grid-template-columns: 70px 1fr auto; }
}

/* late fixes */
.panel > * { min-width: 0; }
.facts .tx__sub { display: block; font-size: var(--fs-xs); color: var(--ink-3); font-weight: 400; }
.panel .table-scroll .simple th:first-child, .panel .table-scroll .simple td:first-child { padding-left: clamp(1.1rem, 2.5vw, 1.6rem); }
.search--top { min-width: 220px; }
@media (max-width: 640px) { .search--top { min-width: 0; flex: 1 1 auto; } .dtable td > .tx__sub { display: none; } }
