
:root {
  color-scheme: light;
  /* Canonical token set — see DESIGN.md. This is the single source both
     dashboards load; nothing below is redeclared per-page. */
  --ink-950: #0b1210;
  --ink-900: #101c19;
  --ink-700: #35473f;
  --ink-500: #5c6f66;
  --ink-300: #9fb0a8;
  --ink-100: #e6ece9;

  --paper: #f7f5ef;
  --surface: #ffffff;
  --surface-2: #fbfaf5;

  --line: #dde3da;
  --line-soft: #eef1ea;

  --accent: #0f6b5c;
  --accent-strong: #0a4f44;
  --accent-soft: #e3f1ec;
  --accent-tint: #cfe7de;

  --gold: #a9762c;
  --gold-soft: #f6ecd9;

  --ok: #1c7c4f;
  --ok-soft: #e3f3e9;
  --warn: #a15c07;
  --warn-soft: #fdf1dd;
  --danger: #9c2b20;
  --danger-soft: #fbe9e6;

  --method-btc: #e08a2c;
  --method-eth: #5b6ee1;
  --method-usdt: #1c9e77;
  --method-usdc: #2775ca;
  --method-generic-crypto: #4a7c68;
  --method-card: #2a4d8f;
  --method-apple-pay: #1a1a1a;
  --method-google-pay: #4285a3;
  --method-trustly: #0f8a5f;

  --font-display: "Fraunces", Georgia, "Iowan Old Style", serif;
  --font-ui: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-card: 0 1px 2px rgba(11,18,16,.04), 0 8px 24px -12px rgba(11,18,16,.12);

  --sidebar-w: 248px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink-900);
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  line-height: 1.5;
}
h1, h2, h3, .brand-title, .page-title h1 { font-family: var(--font-display); font-weight: 600; margin: 0; color: var(--ink-950); }
code, .mono, .metric-value { font-family: var(--font-mono); }
button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
a { color: inherit; }

.app { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
.content { min-width: 0; }

/* Sidebar — density/chrome differs by theme, tokens do not (DESIGN.md §5) */
.sidebar {
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--line);
}
.theme-admin .sidebar { background: var(--ink-950); color: #e5eef8; border-right: none; }
.theme-merchant .sidebar { background: var(--surface); color: var(--ink-900); }

.brand { display: flex; align-items: center; gap: 12px; min-height: 42px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 8px;
  display: grid; place-items: center;
  font-weight: 800;
  border: 1px solid rgba(255,255,255,.18);
}
.theme-admin .brand-mark { background: #111827; color: #fff; }
.theme-merchant .brand-mark { background: var(--accent); color: #fff; border-color: var(--accent-strong); }
.brand-title { font-size: 15px; font-weight: 750; line-height: 1.2; font-family: var(--font-ui); }
.brand-subtitle { font-size: 12px; margin-top: 2px; }
.theme-admin .brand-subtitle { color: #98a2b3; }
.theme-merchant .brand-subtitle { color: var(--ink-500); }

.nav { display: grid; gap: 2px; }
.nav-link {
  position: relative;
  text-decoration: none;
  padding: 9px 12px 9px 16px;
  border-radius: 7px;
  display: block;
  font-weight: 600;
  font-size: 13px;
}
.theme-admin .nav-link { color: #9fadc2; }
.theme-admin .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.theme-admin .nav-link.active { background: rgba(255,255,255,.09); color: #fff; }
.theme-merchant .nav-link { color: var(--ink-700); }
.theme-merchant .nav-link:hover { background: var(--surface-2); color: var(--ink-950); }
.theme-merchant .nav-link.active { background: var(--accent-soft); color: var(--accent-strong); }
/* Active-state indicator: a thin accent bar on the left edge, not an icon */
.nav-link.active::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: var(--accent);
}
.theme-admin .nav-link.active::before { background: #4fd1b5; }

.side-card {
  margin-top: auto;
  padding: 13px;
  border-radius: 8px;
}
.theme-admin .side-card { border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.04); }
.theme-merchant .side-card { border: 1px solid var(--line); background: var(--surface-2); }
.side-card strong { display: block; font-size: 12px; margin-bottom: 6px; }
.side-card span { font-size: 12px; line-height: 1.45; word-break: break-all; }
.theme-admin .side-card span { color: #aab7c7; }
.theme-merchant .side-card span { color: var(--ink-500); }

.nav-toggle { display: none; }
.nav-scrim { display: none; }

/* Topbar */
.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.page-title h1 { font-size: 20px; line-height: 1.2; }
.page-title p { margin: 4px 0 0; color: var(--ink-500); font-size: 13px; }
.top-actions { display: flex; align-items: center; gap: 10px; }

main { max-width: 1440px; margin: 0 auto; padding: 24px 28px 48px; }
.theme-merchant main { padding: 32px 40px 64px; }

/* Buttons */
.button {
  height: 36px;
  border: 1px solid var(--accent-strong);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  background: var(--accent);
  color: white;
  font-weight: 750;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.button:hover { background: var(--accent-strong); }
.button:disabled { opacity: .5; cursor: not-allowed; }
.button.secondary { color: var(--ink-900); background: var(--surface); border-color: var(--line); }
.button.secondary:hover { background: var(--surface-2); }
.button.danger { background: var(--danger); border-color: #7a2018; }
.button.danger:hover { background: #7a2018; }
.button.small { height: 30px; padding: 0 10px; font-size: 12px; }

/* Status / notice banners */
.notice {
  display: none;
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #fed7aa;
  background: var(--warn-soft);
  color: #7c3e05;
  font-weight: 650;
}
.notice.show { display: block; }
.notice.error { border-color: #ffc7c0; background: var(--danger-soft); color: var(--danger); }

/* KPI / stat cards */
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.metric {
  min-height: 100px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.metric-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.metric-label { color: var(--ink-500); font-size: 12px; font-weight: 750; text-transform: uppercase; }
.metric-value { margin-top: 13px; font-size: 28px; line-height: 1; font-weight: 700; color: var(--ink-950); }
.metric-foot { margin-top: 8px; color: var(--ink-300); font-size: 12px; }

/* Layout grids */
.layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(340px, .85fr); gap: 16px; margin-top: 16px; }
.stack { display: grid; gap: 16px; align-content: start; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* Panels */
.panel { border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-card); overflow: hidden; }
.panel-header { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); background: var(--surface-2); }
.panel-title { font-size: 14px; font-weight: 800; font-family: var(--font-ui); }
.panel-subtitle { margin-top: 2px; color: var(--ink-500); font-size: 12px; }
.panel-body { padding: 14px 16px 16px; box-shadow: none; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
th { color: var(--ink-500); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .02em; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
.theme-admin table td, .theme-admin table th { padding: 8px; }
.theme-merchant table td, .theme-merchant table th { padding: 12px 10px; }
code { font-family: var(--font-mono); font-size: 12px; color: var(--ink-700); }

/* Badges */
.badge { display: inline-flex; align-items: center; min-height: 22px; border-radius: 999px; padding: 3px 9px; font-size: 11px; font-weight: 800; border: 1px solid var(--line); color: var(--ink-700); background: var(--surface-2); white-space: nowrap; }
.badge.get { color: #075985; background: #e0f2fe; border-color: #bae6fd; }
.badge.post { color: #7a4b00; background: #fff4d6; border-color: #fde68a; }
.badge.ok { color: var(--ok); background: var(--ok-soft); border-color: #b8e4ca; }
.badge.warn { color: var(--warn); background: var(--warn-soft); border-color: #fed7aa; }
.badge.bad { color: var(--danger); background: var(--danger-soft); border-color: #ffc7c0; }
.badge.gold { color: var(--gold); background: var(--gold-soft); border-color: #ecd3a0; }

.method-dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
/* Token/brand artwork from /method-assets. Sized by the width/height
   attributes on the element itself so the row height never depends on the
   SVG's own intrinsic size. */
.method-icon-img { display: inline-block; vertical-align: middle; flex: none; border-radius: 50%; }

/* Method branding editor (admin_pages::payment_methods_page) */
.pm-rule { border: 0; border-top: 1px solid var(--line-soft); margin: 18px 0; }
.pm-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.pm-icon-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.pm-icon-row .method-icon-img { border: 1px solid var(--line); background: var(--surface-2); padding: 4px; }
.pm-icon-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.pm-dash { color: var(--ink-500); }

.empty { min-height: 58px; display: grid; place-items: center; color: var(--ink-500); border: 1px dashed var(--line); border-radius: 8px; background: var(--surface-2); font-weight: 650; text-align: center; padding: 20px; }

.progress { height: 10px; overflow: hidden; border-radius: 999px; background: var(--ink-100); border: 1px solid var(--line-soft); }
.progress > span { display: block; height: 100%; background: var(--accent); width: 0%; }

/* Status banner (merchant overview) */
.status-banner { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-card); margin-bottom: 20px; }
.status-banner.pending { border-color: #ecd3a0; background: var(--gold-soft); }
.status-banner.active { border-color: #b8e4ca; background: var(--ok-soft); }
.status-banner.rejected, .status-banner.suspended, .status-banner.closed { border-color: #ffc7c0; background: var(--danger-soft); }
.status-banner h2 { font-size: 16px; }
.status-banner p { margin: 4px 0 0; color: var(--ink-700); font-size: 13px; }

/* Forms */
.field { display: grid; gap: 7px; margin-bottom: 14px; }
.field label { font-weight: 750; font-size: 13px; }
.field input, .field select, .field textarea {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  color: var(--ink-900);
  background: var(--surface);
  appearance: none;
  -webkit-appearance: none;
}
.field select {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="6" viewBox="0 0 10 6"><path d="M1 1l4 4 4-4" stroke="%235c6f66" stroke-width="1.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>');
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.field textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid rgba(15,107,92,.18); border-color: var(--accent); }
.field-hint { font-size: 12px; color: var(--ink-500); }
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); background: var(--surface-2); }
.filter-bar .field { margin-bottom: 0; min-width: 140px; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track { position: absolute; inset: 0; background: var(--ink-100); border-radius: 999px; transition: background .15s ease; border: 1px solid var(--line); }
.switch-track::before { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: transform .15s ease; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent-strong); }
.switch input:checked + .switch-track::before { transform: translateX(18px); }

/* Modal */
.modal-scrim { position: fixed; inset: 0; background: rgba(11,18,16,.45); display: none; place-items: center; padding: 20px; z-index: 40; }
.modal-scrim.show { display: grid; }
.modal { width: min(440px, 100%); background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--line); box-shadow: var(--shadow-card); padding: 24px; }
.modal h3 { font-size: 17px; margin-bottom: 8px; }
.modal p { margin: 0 0 18px; color: var(--ink-700); font-size: 13px; line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* Toast */
.toast-region { position: fixed; top: 18px; right: 18px; z-index: 50; display: grid; gap: 8px; }
.toast { min-width: 260px; max-width: 360px; padding: 12px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-card); font-size: 13px; font-weight: 650; display: flex; align-items: flex-start; gap: 8px; }
.toast.ok { border-color: #b8e4ca; background: var(--ok-soft); color: var(--ok); }
.toast.error { border-color: #ffc7c0; background: var(--danger-soft); color: var(--danger); }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--line-soft); font-size: 12px; color: var(--ink-500); }
.pagination .button.small { padding: 0 12px; }

/* Skeleton loading */
.skeleton-row { height: 14px; border-radius: 4px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--line-soft) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: skeleton-pulse 1.4s ease infinite; }
@keyframes skeleton-pulse { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* Login / auth gate (shared shell used by the token/session check) */
.login { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 22px; background: var(--ink-950); }
.login.hidden { display: none; }
.login-card { width: min(420px, 100%); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-card); border: 1px solid var(--line); padding: 26px; }

@media (max-width: 1180px) {
  .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .layout { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .nav-toggle { display: flex; flex-direction: column; justify-content: center; gap: 4px; position: fixed; top: 14px; left: 14px; z-index: 30; width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-card); align-items: center; }
  .nav-toggle span { display: block; width: 18px; height: 2px; background: var(--ink-900); border-radius: 1px; }
  .sidebar { position: fixed; top: 0; left: 0; z-index: 31; width: min(80vw, 280px); height: 100vh; transform: translateX(-100%); transition: transform .18s ease; }
  .sidebar.open { transform: translateX(0); }
  .nav-scrim.show { display: block; position: fixed; inset: 0; background: rgba(11,18,16,.4); z-index: 29; }
  .topbar { padding: 0 18px 0 60px; }
  main { padding: 18px; }
  .summary-grid, .two-col, .layout { grid-template-columns: 1fr; }
  .panel-body { overflow-x: auto; }
  .filter-bar .field { min-width: 0; flex: 1 1 140px; }
}
