/* Payments admin — Webway AI "chalk & coral" design system.
   Tokens mirror the Webway AI console reference (ve-host/webway-ai @ 937298d)
   so both products stay visually aligned; Payments-specific pages and
   components are kept in this single stylesheet. */

/* ─── tokens ─────────────────────────────────────────────────────────── */
:root {
  /* palette — mint court paper, ink linework, coral fire */
  --bg:      oklch(95.5% 0.035 188);
  --surface: oklch(99.5% 0.005 190);
  --fg:      oklch(17% 0.03 255);
  --muted:   oklch(48% 0.03 250);
  --border:  oklch(82% 0.03 188);
  --accent:  oklch(72% 0.16 35);
  --accent-strong: oklch(43% 0.15 28);

  --accent-soft: color-mix(in oklch, var(--accent) 18%, transparent);
  --fg-soft:     color-mix(in oklch, var(--fg) 7%, transparent);

  /* ink-surface text (sidebar, toast) */
  --on-dark:       oklch(95.5% 0.035 188);
  --on-dark-muted: oklch(72% 0.03 250);

  /* pops — highlighter fills, never body text */
  --pop-lime: oklch(84% 0.16 135);
  --pop-sun:  oklch(85% 0.15 88);
  --pop-blue: oklch(50% 0.15 245);

  /* status colors */
  --ok:      oklch(45% 0.12 155);
  --ok-soft: color-mix(in oklch, var(--ok) 16%, transparent);
  --warn:      oklch(44% 0.11 62);
  --warn-soft: color-mix(in oklch, var(--warn) 20%, transparent);
  --danger:      oklch(48% 0.17 25);
  --danger-soft: color-mix(in oklch, var(--danger) 15%, transparent);

  /* the flourish: hard sticker shadow, always paired with an ink outline */
  --shadow-hard:    4px 4px 0 var(--fg);
  --shadow-hard-sm: 2px 2px 0 var(--fg);
  --shadow-deep:    3px 3px 0 oklch(11% 0.03 255);

  --font-display: 'Iowan Old Style', 'Charter', Georgia, 'Times New Roman', serif;
  --font-body:    -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
  --font-mono:    ui-monospace, 'JetBrains Mono', 'SF Mono', Menlo, monospace;

  --fs-h1: clamp(30px, 3.4vw, 42px);
  --fs-h2: clamp(22px, 2.4vw, 28px);
  --fs-h3: 17px;
  --fs-lead: 15px;
  --fs-body: 14px;
  --fs-meta: 12px;

  --gap-xs: 6px; --gap-sm: 10px; --gap-md: 16px; --gap-lg: 24px; --gap-xl: 36px; --gap-2xl: 56px;
  --container: 1240px;
  --gutter: 24px;
  --radius: 10px;
  --radius-lg: 16px;
}

/* ─── base ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; color: inherit; }
h1, h2, h3, h4 { text-wrap: balance; font-family: var(--font-display); }
p { text-wrap: pretty; }
h1, h2, h3, h4, p { margin: 0; }

code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--fg-soft);
  border-radius: 5px;
  padding: 1px 5px;
  overflow-wrap: anywhere;
}

/* ─── buttons ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px;
  border-radius: var(--radius);
  border: 2px solid var(--fg);
  background: var(--surface);
  color: var(--fg);
  font-size: 14px; font-weight: 700;
  letter-spacing: -0.005em;
  box-shadow: var(--shadow-hard-sm);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease, color 0.15s ease;
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow-hard); }
.btn:active { transform: translate(1px, 1px); box-shadow: 0 0 0 var(--fg); }
.btn-primary { background: var(--accent); color: var(--fg); }
.btn-primary:hover { background: var(--fg); color: var(--accent); }
.btn-secondary { background: var(--surface); color: var(--fg); }
.btn-secondary:hover { background: color-mix(in oklch, var(--pop-lime) 60%, var(--surface)); }
.btn-ghost { background: transparent; color: var(--fg); border-color: transparent; box-shadow: none; padding-inline: 10px; }
.btn-ghost:hover { background: var(--fg-soft); transform: none; box-shadow: none; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-danger { background: transparent; border-color: transparent; box-shadow: none; color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); transform: none; box-shadow: none; }
.btn-danger-solid { background: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: color-mix(in oklch, var(--danger) 82%, var(--fg)); color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: var(--shadow-hard-sm); }
button:focus-visible, a:focus-visible, .nav-item:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--accent-strong); outline-offset: 2px;
}
.sidebar button:focus-visible, .sidebar select:focus-visible { outline-color: var(--pop-lime); }

/* ─── app shell ──────────────────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 236px; flex-shrink: 0;
  background: var(--fg);
  color: var(--on-dark);
  border-right: 3px solid var(--fg);
  padding: 18px 14px;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}
.sidebar .muted { color: var(--on-dark-muted); }
.brand { display: flex; align-items: center; gap: 12px; padding: 2px 8px 18px; }
.brand-mark { width: 34px; height: 34px; flex-shrink: 0; display: block; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: -0.01em; color: var(--on-dark); }
.brand-version { margin-top: 1px; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.04em; color: var(--on-dark-muted); }

.nav-label {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--on-dark-muted);
  padding: 16px 12px 7px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; margin-bottom: 3px;
  border-radius: var(--radius); color: var(--on-dark-muted);
  font-size: 14px; font-weight: 600; border: 0; background: transparent;
  width: 100%; text-align: left;
  transition: background 0.14s ease, color 0.14s ease, transform 0.12s ease, box-shadow 0.12s ease;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { color: var(--on-dark); background: color-mix(in oklch, var(--surface) 14%, transparent); }
.nav-item.active {
  color: var(--fg); background: var(--pop-lime); font-weight: 800;
  box-shadow: var(--shadow-deep); transform: translate(-1px, -1px);
}
.nav-item.active svg { color: var(--fg); }
.nav-item.nav-back {
  color: var(--on-dark);
  border: 1.5px solid color-mix(in oklch, var(--surface) 28%, transparent);
  margin-bottom: 6px;
}
.sidebar-foot {
  margin-top: auto; padding-top: 16px;
  border-top: 1px solid color-mix(in oklch, var(--surface) 22%, transparent);
}
.sidebar-foot form { margin: 0; }

/* ─── user menu (sidebar account) ─────────────────────────────────────── */
.user-menu { position: relative; }
.user-menu summary {
  list-style: none;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius);
  cursor: pointer;
  color: var(--on-dark);
  transition: background 0.14s ease;
}
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover,
.user-menu[open] summary { background: color-mix(in oklch, var(--surface) 14%, transparent); }
.user-menu summary:focus-visible { outline: 3px solid var(--pop-lime); outline-offset: 2px; }
.avatar {
  width: 30px; height: 30px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--pop-lime); color: var(--fg);
  border: 2px solid var(--fg);
  font-family: var(--font-mono); font-size: 11px; font-weight: 800;
  letter-spacing: 0.02em;
}
.user-menu-name {
  font-size: 13px; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-menu-panel {
  position: absolute; bottom: calc(100% + 6px); left: 0; right: 0;
  z-index: 40;
  background: var(--surface); color: var(--fg);
  border: 2px solid var(--fg); border-radius: var(--radius);
  box-shadow: var(--shadow-hard);
  padding: 6px;
}
.user-menu-panel form { margin: 0; }
.user-menu-link {
  display: block; width: 100%; text-align: left;
  padding: 8px 10px; border: 0; border-radius: 8px;
  background: transparent; color: var(--fg);
  font-size: 13px; font-weight: 600;
  transition: background 0.12s ease;
}
.user-menu-link:hover { background: var(--fg-soft); }

/* ─── settings hub / tenant summary stats ─────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--gap-lg);
  align-items: start;
}
.summary-strip {
  display: flex; flex-wrap: wrap; gap: 12px;
}
.summary-strip .stat { flex: 1 1 120px; }
.stat {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 14px;
  background: var(--surface);
  border: 2px solid var(--fg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hard-sm);
}
.stat-label {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.stat-value {
  font-family: var(--font-display); font-size: 24px; font-weight: 700;
  line-height: 1.1; font-variant-numeric: tabular-nums;
}

.main { flex: 1; min-width: 0; padding: 26px 32px 60px; }
.main-inner { max-width: var(--container); margin-inline: auto; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-title { font-family: var(--font-display); font-size: var(--fs-h1); font-weight: 700; letter-spacing: -0.025em; line-height: 1.02; }
.page-sub { color: var(--muted); font-family: var(--font-mono); font-size: 12.5px; letter-spacing: 0.01em; margin-top: 8px; }
.page-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ─── surfaces ───────────────────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 2px solid var(--fg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-hard);
}
.panel-pad { padding: 20px; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 20px; border-bottom: 2px solid var(--fg);
}
.panel-head h2, .panel-head h3 {
  font-family: var(--font-display); font-size: 18px; font-weight: 700;
  letter-spacing: -0.015em; line-height: 1.2;
}
.panel-head .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.panel > .panel-pad > h2 { font-size: 18px; margin-bottom: 8px; }

/* ─── badges / pills ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  border: 1.5px solid var(--fg); box-shadow: var(--shadow-hard-sm);
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase;
  line-height: 1.6; white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok      { background: var(--ok-soft); color: var(--ok); }
.badge-warn    { background: var(--warn-soft); color: var(--warn); }
.badge-danger  { background: var(--danger-soft); color: var(--danger); }
.badge-neutral { background: var(--fg-soft); color: var(--muted); }

/* ─── tables ─────────────────────────────────────────────────────────── */
.table-scroll { overflow-x: auto; }
.table-scroll .tbl { min-width: 640px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td {
  padding: 12px 16px; text-align: left;
  border-bottom: 1px solid var(--border); vertical-align: middle;
}
.tbl th {
  color: var(--fg); font-weight: 700; font-family: var(--font-mono);
  font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase;
  border-bottom: 2px solid var(--fg); padding-top: 14px; padding-bottom: 12px;
}
.tbl tbody tr { transition: background 0.12s ease; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: color-mix(in oklch, var(--accent) 13%, transparent); }
.tbl a { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 2px; font-weight: 600; }
.tbl a:hover { color: var(--fg); }
.num-col, .tbl .num-col { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 14px; }

/* ─── action rows ────────────────────────────────────────────────────── */
.row-actions {
  display: flex; align-items: center; justify-content: flex-end;
  flex-wrap: wrap; gap: 6px;
}
.row-actions form { margin: 0; display: inline-flex; }

/* ─── layout helpers ─────────────────────────────────────────────────── */
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.inline { display: inline; }

/* ─── forms ──────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.hint { font-size: 11.5px; color: var(--muted); }
.input, .select {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--fg);
  font: inherit; font-size: 14px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.input:hover, .select:hover { border-color: var(--fg); }
.input:focus, .select:focus { outline: none; border-color: var(--fg); box-shadow: var(--shadow-hard-sm); }
textarea.input, textarea { min-height: 120px; font-family: var(--font-mono); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: end; }

/* ─── feedback ───────────────────────────────────────────────────────── */
.flash {
  padding: 12px 16px; border-radius: var(--radius);
  border: 2px solid var(--fg); box-shadow: var(--shadow-hard-sm);
  font-weight: 600;
}
.flash-ok  { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.flash-err { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.secret-box {
  background: var(--warn-soft);
  border: 2px solid var(--fg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-hard);
  padding: 18px 20px;
}
.secret-box strong { display: block; margin-bottom: 8px; }
.secret-box p { margin: 8px 0 0; }
.key {
  display: block; margin-top: 5px;
  font-family: var(--font-mono); font-size: 13px;
  background: var(--surface); border: 1.5px solid var(--fg);
  border-radius: 8px; padding: 9px 11px;
  word-break: break-all; user-select: all;
}

/* ─── cluster ────────────────────────────────────────────────────────── */
.node-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.node-card {
  background: var(--surface); border: 2px solid var(--fg);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-hard-sm);
  padding: 18px; height: 100%;
}
.node-card h2, .node-card h3 { font-size: 18px; margin-bottom: 6px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 13px; border-bottom: 1px solid var(--border); }
.kv:last-child { border-bottom: 0; }
.val { font-weight: 700; font-family: var(--font-mono); font-size: 12.5px; text-align: right; }
.val.ok   { color: var(--ok); }
.val.bad  { color: var(--danger); }
.val.warn { color: var(--warn); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--muted); }
.dot.ok   { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad  { background: var(--danger); }
.mono-err { font-family: var(--font-mono); font-size: 11.5px; word-break: break-word; margin: 0 0 6px; }

/* ─── public pages ───────────────────────────────────────────────────── */
.public-shell {
  min-height: 100vh; display: grid; place-items: center;
  padding: 32px 20px; background: var(--bg);
}
.public-card {
  width: min(440px, 100%);
  background: var(--surface); border: 2px solid var(--fg);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-hard);
  padding: 26px;
}
.public-card h1, .public-card h2 { font-size: var(--fs-h2); margin-bottom: 10px; }
.public-card .muted { margin-bottom: 14px; }

/* ─── auth page — dark surface, mirroring the Webway AI reference ────── */
.auth-shell {
  min-height: 100vh; display: grid; place-items: center;
  padding: 32px 20px;
  background: #0f1115;
  color: #e8eaed;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.auth-card {
  width: min(360px, 100%);
  background: #171a21;
  border: 1px solid #262b36;
  border-radius: 14px;
  padding: 28px;
  display: flex; flex-direction: column; gap: 14px;
}
.auth-card .brand { padding: 0 0 4px; }
.auth-card .brand-name { color: #e8eaed; }
.auth-card h1 {
  font-family: inherit; font-size: 20px; font-weight: 700;
  letter-spacing: -0.01em; color: #e8eaed;
}
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card .field label {
  font-family: inherit; font-size: 13px; font-weight: 400;
  letter-spacing: normal; text-transform: none; color: #9aa4b2;
}
.auth-card .input {
  background: #0f1115; border: 1px solid #303642;
  border-radius: 8px; color: #e8eaed; padding: 10px 12px;
}
.auth-card .input:hover { border-color: #4f7cff; }
.auth-card .input:focus { border-color: #4f7cff; box-shadow: 0 0 0 2px rgba(79, 124, 255, 0.25); }
.auth-card .btn {
  width: 100%; border: 0; border-radius: 8px;
  box-shadow: none; padding: 11px 14px;
}
.auth-card .btn:hover, .auth-card .btn:active { transform: none; box-shadow: none; }
.auth-card .btn-primary { background: #4f7cff; color: #fff; }
.auth-card .btn-primary:hover { background: #3f6beb; color: #fff; }
.auth-card .btn-secondary {
  background: #10131a; border: 1px solid #303642; color: #e8eaed;
}
.auth-card .btn-secondary:hover { background: #10131a; border-color: #4f7cff; color: #e8eaed; }
.auth-card .flash { margin: 0; padding: 0; border: 0; background: transparent; box-shadow: none; border-radius: 0; font-size: 13px; font-weight: 400; }
.auth-card .flash-err { color: #ff8a8a; }
.auth-card .flash-ok  { color: #8fd18f; }
.auth-divider { text-align: center; font-size: 12px; color: #6b7382; }

/* ─── responsive: sidebar collapses to a top bar ─────────────────────── */
@media (max-width: 920px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: static;
    flex-direction: row; align-items: center;
    padding: 10px 12px; overflow-x: auto;
    border-right: 0; border-bottom: 3px solid var(--fg);
  }
  .sidebar .brand { padding: 0; margin-right: 8px; }
  .nav-label { display: none; }
  .nav-item { width: auto; padding: 9px; margin: 0; }
  .nav-item span { display: none; }
  .sidebar-foot { display: flex; align-items: center; gap: 4px; margin: 0 0 0 auto; padding: 0; border: 0; }
  .user-menu-name { display: none; }
  .user-menu summary { padding: 6px; }
  /* The top bar scrolls horizontally; pin the panel to the viewport so it cannot overflow. */
  .user-menu-panel { position: fixed; top: 58px; bottom: auto; left: auto; right: 12px; width: 200px; }
  .main { padding: 18px 16px 48px; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .page-actions { width: 100%; }
}

@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 22px; }
}
