/* Dashboard design system — the teal SaaS chrome (CLAUDE.md §5 tokens, from the canonical
   walkthrough). Light surface, generous whitespace, single soft elevation. WCAG 2.2 AA:
   AA contrast, visible focus, ≥44px targets, prefers-reduced-motion honored. */

:root {
  --teal: #00695c;
  --teal-light: #e6f3f2;
  --teal-mid: #4daca4;
  --blue: #005eb8;
  --amber: #e67700;
  --red: #c92a2a;
  --green: #2f9e44;

  --gray-50: #f8f9fa;
  --gray-100: #f1f3f5;
  --gray-200: #e9ecef;
  --gray-400: #ced4da;
  --gray-600: #868e96; /* DECORATIVE / non-text only (3.32:1 — fails 1.4.3 for text; use gray-700) */
  --gray-700: #495057; /* AA body/secondary text on white (8.18:1) */
  --gray-900: #212529;
  --field-border: #8a9097; /* form-control border — meets 1.4.11 non-text contrast (≥3:1 on white) */
  --text: #212529;

  --radius: 8px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: var(--gray-50);
  -webkit-font-smoothing: antialiased;
}

.visually-hidden {
  /* biome-ignore lint/complexity/noImportantStyles: canonical a11y screen-reader-only pattern (position:absolute !important wins over layout); WCAG 2.2 AA (AGENTS.md §5) */
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.boot {
  padding: 40px;
  color: var(--gray-700);
  text-align: center;
}

/* Focus: visible teal ring (≥3:1 vs white/teal-light), never removed. */
:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
  border-radius: 4px;
}

h1,
h2,
h3 {
  color: var(--gray-900);
  margin: 0 0 6px;
}
h2 {
  font-size: 1.7rem;
  font-weight: 700;
}
h3 {
  font-size: 1.1rem;
  font-weight: 600;
}
a {
  color: var(--teal);
}

/* ── Buttons (min 44×44 target) ────────────────────────────────────────────── */
.btn-primary,
.btn-ghost,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn-primary {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}
.btn-primary:hover {
  background: #00564b;
}
.btn-ghost {
  background: #fff;
  color: var(--teal);
  border-color: var(--teal);
}
.btn-ghost:hover {
  background: var(--teal-light);
}
.btn-danger {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}
button[disabled],
.btn-primary[aria-busy="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.field {
  margin-bottom: 14px;
}
.field label,
.label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-700);
  margin-bottom: 5px;
}
.control,
input[type="text"],
input[type="email"],
input[type="number"],
textarea,
select {
  width: 100%;
  font: inherit;
  font-size: 16px; /* ≥16px avoids iOS focus-zoom */
  padding: 10px 12px;
  border: 1px solid var(--field-border); /* 1.4.11 non-text contrast (≥3:1) */
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
}
textarea {
  min-height: 64px;
  resize: vertical;
}
.hint {
  font-size: 0.78rem;
  color: var(--gray-700);
  margin: 4px 0 0;
}
.err-text {
  color: var(--red);
  font-size: 0.82rem;
  margin: 4px 0 0;
}

/* Color swatches as a native radio group (Tab/Arrow/Space for free; non-color selected
   indicator via the ring + a checkmark). The visible swatch is 30px but the LABEL hit area
   is ≥44px (2.5.8 + CLAUDE). */
.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.swatch-opt {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  cursor: pointer;
  border-radius: 8px;
}
.swatch-opt input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.swatch-dot {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  box-shadow: 0 0 0 1px var(--gray-200);
}
.swatch-opt input:checked + .swatch-dot {
  box-shadow:
    0 0 0 2px #fff,
    0 0 0 4px var(--teal);
}
.swatch-opt input:checked + .swatch-dot::after {
  content: "✓";
  color: #fff;
  font-size: 0.8rem;
  display: grid;
  place-items: center;
  height: 100%;
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}
.swatch-opt input:focus-visible + .swatch-dot {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
}

/* ── Cards / callouts / badges / tiles ─────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
.callout {
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 0.85rem;
  margin: 12px 0;
}
.callout.info {
  background: var(--teal-light);
  color: #00443c;
}
.callout.amber {
  background: #fff4e6;
  color: #8a4b00;
}
.callout.danger {
  background: #fff0f0;
  color: #8a1f1f;
}
.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.status-badge.active {
  background: #e6f4ea;
  color: #1b6b34;
}
.status-badge.trialing {
  background: #e7f0fb;
  color: #0b4a8f;
}
.status-badge.past_due {
  background: #fff4e6;
  color: #8a4b00;
}
.status-badge.suspended,
.status-badge.canceled {
  background: #fdeaea;
  color: #8a1f1f;
}
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.tile {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px;
}
.tile .v {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
}
.tile .l {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-700);
}
/* Stat-tile delta (▲/▼ vs the prior window). The glyph is decorative (aria-hidden); a
   visually-hidden sentence carries the meaning, so color is never the only signal (WCAG 1.4.1). */
.tile .d {
  font-size: 0.64rem;
  font-weight: 600;
  margin-top: 4px;
}
.tile .d.up {
  color: var(--green);
}
.tile .d.down {
  color: var(--red);
}
.tile .d.flat {
  color: var(--gray-700);
}

/* ── Busiest-hours bar chart (ported from the walkthrough) ─────────────────────
   The visible bars are aria-hidden; the data lives in a visually-hidden <table> (the real text
   alternative, WCAG 1.1.1). Horizontal scroll keeps the 24 bars usable at 320px (reflow, 1.4.10). */
.bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 92px;
  padding: 8px 4px 0;
  border-bottom: 1px solid var(--gray-200);
  overflow-x: auto;
}
.bars .bar {
  flex: 1;
  min-width: 8px;
  background: linear-gradient(180deg, var(--teal-mid), var(--teal));
  border-radius: 4px 4px 0 0;
  min-height: 4px;
}
.bars-x {
  display: flex;
  gap: 6px;
  padding: 5px 4px 0;
  overflow-x: auto;
}
.bars-x span {
  flex: 1;
  min-width: 8px;
  text-align: center;
  font-size: 0.58rem;
  color: var(--gray-700);
}

/* ── Window toggle (7/30/90) — a native-radio segmented control (roving focus + Space for free,
   like the color swatches). Each segment is a ≥44px touch target; the teal fill marks the choice. */
.win-toggle {
  display: flex;
  border: 0;
  padding: 0;
  margin: 0 0 16px;
}
.win-toggle .seg {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--gray-200);
  background: #fff;
  color: var(--gray-700);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}
.win-toggle .seg:first-of-type {
  border-radius: var(--radius) 0 0 var(--radius);
}
.win-toggle .seg:last-of-type {
  border-radius: 0 var(--radius) var(--radius) 0;
}
.win-toggle .seg + .seg {
  border-left: 0;
}
.win-toggle .seg:has(input:checked) {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}
.win-toggle .seg input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
/* `:focus` (not only `:focus-visible`): the view restores focus to the checked radio PROGRAMMATICALLY
   after a window change, and programmatic focus does not match `:focus-visible` in most browsers — so
   the ring must show on plain `:focus` too, else the just-operated control has no visible focus (2.4.7). */
.win-toggle .seg input:focus + span {
  outline: 3px solid var(--teal);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ── Lists / tables ────────────────────────────────────────────────────────── */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-200);
}
.list .meta {
  color: var(--gray-700);
  font-size: 0.82rem;
}
.code {
  font-family: var(--mono);
  font-size: 0.82rem;
  background: var(--gray-100);
  padding: 2px 6px;
  border-radius: 4px;
  word-break: break-all;
}
.empty {
  text-align: center;
  color: var(--gray-700);
  padding: 28px 12px;
}
.skeleton {
  background: linear-gradient(90deg, var(--gray-100), var(--gray-200), var(--gray-100));
  border-radius: var(--radius);
  height: 56px;
  margin-bottom: 10px;
}

/* ── Dashboard shell: sidebar + main ───────────────────────────────────────── */
.dash {
  display: flex;
  min-height: 100vh;
}
.dash-side {
  width: 200px;
  flex-shrink: 0;
  background: #fbfbfc;
  border-right: 1px solid var(--gray-200);
  padding: 16px 0;
}
.dash-brand {
  font-family: "IBM Plex Sans", var(--font);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0 16px 14px;
  color: var(--gray-900);
}
.dash-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--gray-700);
  text-decoration: none;
  font-size: 0.85rem;
  border-left: 3px solid transparent;
  min-height: 44px;
}
.dash-nav a[aria-current="page"] {
  background: var(--teal-light);
  color: var(--teal);
  border-left-color: var(--teal);
  font-weight: 600;
}
.dash-nav a:hover {
  background: var(--gray-100);
}
.dash-main {
  flex: 1;
  padding: 22px 26px;
  max-width: 980px;
}
.dash-sub {
  color: var(--gray-700);
  font-size: 0.85rem;
  margin: 0 0 18px;
}
.designer-grid {
  display: flex;
  gap: 28px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.designer-form {
  flex: 1 1 320px;
  min-width: 300px;
}
.designer-preview {
  flex: 0 0 auto;
  position: sticky;
  top: 22px;
}

/* ── Wallet-pass live preview (mirrors the walkthrough .wallet-pass) ────────── */
.wallet-pass {
  width: 220px;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
  font-family: var(--font);
}
.wp-strip {
  padding: 14px 14px 16px;
  color: #fff;
}
.wp-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.92rem;
}
.wp-logo img {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.25);
}
.wp-progress-label {
  font-size: 0.74rem;
  opacity: 0.9;
  margin-top: 12px;
  letter-spacing: 0.04em;
}
.wp-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}
.wp-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  opacity: 0.55;
  display: grid;
  place-items: center;
  font-size: 0.6rem;
}
.wp-dot.filled {
  opacity: 1;
  background: currentColor;
}
.wp-reward {
  font-size: 0.78rem;
  margin-top: 8px;
}
.wp-ready {
  font-weight: 700;
  letter-spacing: 0.06em;
}
.wp-qr-zone {
  background: #fff;
  padding: 12px;
  display: grid;
  place-items: center;
}
.wp-qr-zone .ph {
  font-size: 0.6rem;
  color: var(--gray-400);
}
.preview-cap {
  text-align: center;
  font-size: 0.7rem;
  color: var(--gray-700);
  margin-top: 6px;
}

/* ── Auth (login / MFA) ────────────────────────────────────────────────────── */
.auth-wrap {
  max-width: 380px;
  margin: 8vh auto;
  padding: 0 20px;
}
.auth-wrap h2 {
  font-size: 1.4rem;
}
.qr-box svg {
  width: 160px;
  height: 160px;
}

/* ── Toast ─────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--gray-900);
  color: #fff;
  padding: 10px 18px;
  border-radius: 100px;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  z-index: 50;
}
.toast.err {
  background: var(--red);
}

/* ── Responsive (tablet down) ──────────────────────────────────────────────── */
@media (max-width: 720px) {
  .dash {
    flex-direction: column;
  }
  .dash-side {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    overflow-x: auto;
    padding: 8px;
  }
  .dash-brand {
    display: none;
  }
  .dash-nav {
    display: flex;
  }
  .dash-nav a {
    white-space: nowrap;
    border-left: none;
    border-bottom: 3px solid transparent;
  }
  .dash-nav a[aria-current="page"] {
    border-left: none;
    border-bottom-color: var(--teal);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    /* biome-ignore lint/complexity/noImportantStyles: a11y override — !important wins over every component transition; prefers-reduced-motion honored (AGENTS.md §5) */
    animation: none !important;
    /* biome-ignore lint/complexity/noImportantStyles: a11y override — !important wins over every component transition; prefers-reduced-motion honored (AGENTS.md §5) */
    transition: none !important;
  }
}
