/* PinTagged partner portal (test environment). Mobile first; WCAG AA
   contrast for every text/background pair below; 48px touch targets. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1a1d23;
  --muted: #4a5160;
  --border: #c9ced8;
  --brand: #0b5cad;
  --brand-dark: #08457f;
  --on-brand: #ffffff;
  --ok: #146c2e;
  --ok-bg: #e6f4ea;
  --warn: #7a4d00;
  --warn-bg: #fff4dc;
  --bad: #a3141e;
  --bad-bg: #fde8ea;
  --focus: #ffbf47;
  --radius: 10px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--brand); }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 12px; z-index: 10; }
.skip:focus { left: 8px; top: 8px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; box-shadow: 0 0 0 5px #1a1d23; }
[hidden] { display: none !important; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 16px; background: var(--brand-dark); color: var(--on-brand);
}
.topbar h1 { font-size: 1.05rem; margin: 0; line-height: 1.3; }
.topbar .sub { display: block; font-size: .85rem; font-weight: 400; opacity: .95; }
.test-banner { background: var(--warn-bg); color: var(--warn); text-align: center; font-size: .85rem; padding: 4px 16px; border-bottom: 1px solid #e7cf9c; }

main { max-width: 1100px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 480px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 0 0 16px; }
.card h2, .card h3 { margin-top: 0; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spread { justify-content: space-between; }

label { display: block; font-weight: 600; margin-bottom: 4px; }
.hint { display: block; font-weight: 400; color: var(--muted); font-size: .875rem; }
input, select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; font: inherit; color: var(--text);
  background: var(--surface); border: 2px solid var(--border); border-radius: 8px;
}
textarea { min-height: 120px; resize: vertical; }
input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--bad); }
.code-input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.4rem; letter-spacing: .12em; text-transform: uppercase; text-align: center; }

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; min-width: 48px; padding: 10px 18px; font: inherit; font-weight: 600;
  border-radius: 8px; border: 2px solid var(--brand); background: var(--surface); color: var(--brand);
  cursor: pointer; text-decoration: none;
}
button.primary, .button.primary { background: var(--brand); color: var(--on-brand); }
button.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
button.danger { border-color: var(--bad); color: var(--bad); }
button.danger.primary { background: var(--bad); color: #fff; }
button.big { width: 100%; min-height: 64px; font-size: 1.15rem; }
button.link { border: 0; background: none; min-height: 48px; padding: 8px; text-decoration: underline; color: inherit; }
.topbar button { border-color: #fff; background: transparent; color: #fff; }
button:disabled { opacity: .55; cursor: not-allowed; }

.alert { border-radius: 8px; padding: 12px 14px; border: 2px solid; margin: 0 0 12px; }
.alert:empty { display: none; }
.alert.error { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.alert.ok { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.alert.warn { background: var(--warn-bg); border-color: #b07a10; color: var(--warn); }
.alert ul { margin: 4px 0 0; padding-left: 20px; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; border: 1px solid; }
.badge.active { color: var(--ok); background: var(--ok-bg); border-color: var(--ok); }
.badge.paused, .badge.draft, .badge.suspended { color: var(--warn); background: var(--warn-bg); border-color: #b07a10; }
.badge.closed, .badge.replaced, .badge.revoked { color: #3d4350; background: #eceef2; border-color: #8a91a0; }

/* Staff redemption */
.scanner { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 3 / 4; max-height: 60vh; margin: 0 auto; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner .frame { position: absolute; inset: 18%; border: 4px solid rgba(255, 255, 255, .9); border-radius: 12px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .35); pointer-events: none; }
.offer-big { font-size: 2.2rem; font-weight: 800; line-height: 1.1; margin: 4px 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.receipt { border: 3px solid var(--ok); }
.receipt .tick { font-size: 2.6rem; color: var(--ok); line-height: 1; }
.ref { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.25rem; letter-spacing: .05em; }
.terms { white-space: pre-wrap; background: var(--bg); border-radius: 8px; padding: 10px; font-size: .9rem; max-height: 200px; overflow: auto; }
.countdown { font-variant-numeric: tabular-nums; }

/* Admin */
nav.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 2px solid var(--border); margin: 0 0 16px; }
nav.tabs button { border: 0; border-bottom: 4px solid transparent; border-radius: 0; background: none; color: var(--text); }
nav.tabs button[aria-current="page"] { border-bottom-color: var(--brand); color: var(--brand); }
.grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .grid.three { grid-template-columns: repeat(3, 1fr); } }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .85rem; color: var(--muted); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
@media (max-width: 640px) {
  table.responsive thead { position: absolute; left: -9999px; }
  table.responsive tr { display: block; border-bottom: 2px solid var(--border); padding: 8px 0; }
  table.responsive td { display: grid; grid-template-columns: 9.5em 1fr; border: 0; padding: 4px 8px; }
  table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: .85rem; }
}
.form-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 600px) { .form-grid.two { grid-template-columns: 1fr 1fr; } }

dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); color: var(--text); }
dialog::backdrop { background: rgba(10, 14, 22, .6); }
dialog form, dialog .dialog-body { padding: 20px; }
dialog h2 { margin-top: 0; }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.3rem; background: var(--bg); padding: 10px; border-radius: 8px; overflow-wrap: anywhere; user-select: all; }
summary { min-height: 48px; display: flex; align-items: center; cursor: pointer; font-weight: 600; }
details[open] > summary { margin-bottom: 6px; }
