:root {
  --bg: #f0f4f8;
  --bg-subtle: #e8edf3;
  --paper: #ffffff;
  --ink: #0f172a;
  --ink-secondary: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --accent: #0d9488;
  --accent-hover: #0f766e;
  --accent-soft: #ccfbf1;
  --accent-glow: rgba(13, 148, 136, 0.15);
  --ok: #059669;
  --ok-bg: #d1fae5;
  --warn: #d97706;
  --warn-bg: #fef3c7;
  --bad: #dc2626;
  --bad-bg: #fee2e2;
  --info: #2563eb;
  --info-bg: #dbeafe;
  --sidebar: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: rgba(13, 148, 136, 0.18);
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #f8fafc;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.1);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sidebar-width: 260px;
  --transition: 0.18s ease;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.5;
}

a {
  color: var(--accent-hover);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover { color: var(--accent); text-decoration: underline; }

code, .mono {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

/* ── Layout ── */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 100;
  overflow-y: auto;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 20px 14px;
  gap: 2px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 6px 10px 20px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #14b8a6, #0d9488);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 18px;
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.35);
  flex-shrink: 0;
}

.brand h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: #f1f5f9;
  letter-spacing: -0.01em;
}

.brand p {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--sidebar-text);
}

.nav-section {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #475569;
  padding: 16px 12px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 14px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.nav-link svg {
  width: 18px;
  height: 18px;
  opacity: 0.7;
  flex-shrink: 0;
}

.nav-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
  text-decoration: none;
}

.nav-link:hover svg { opacity: 1; }

.nav-link.is-active {
  background: var(--sidebar-active);
  color: #5eead4;
}

.nav-link.is-active svg { opacity: 1; color: #5eead4; }

.sidebar-foot {
  margin-top: auto;
  padding: 16px 10px 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #334155, #475569);
  color: #e2e8f0;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.user-pill span {
  font-size: 13px;
  color: #cbd5e1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(13, 148, 136, 0.2);
  color: #5eead4;
  font-size: 11px;
  font-weight: 600;
}

.chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.8;
}

.content {
  padding: 28px 32px 64px;
  max-width: 1280px;
  width: 100%;
}

/* ── Mobile nav ── */
.mobile-topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 90;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.menu-toggle {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  cursor: pointer;
  color: var(--ink);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 99;
  backdrop-filter: blur(2px);
}

/* ── Page header ── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.page-header h2 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.page-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  max-width: 540px;
}

.page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform 0.1s ease, box-shadow var(--transition);
  white-space: nowrap;
  line-height: 1.2;
}

.btn:hover {
  background: var(--accent-hover);
  text-decoration: none;
  color: white;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.btn:active { transform: scale(0.98); }

.btn.secondary {
  background: var(--paper);
  color: var(--ink-secondary);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-sm);
}

.btn.secondary:hover {
  background: var(--bg);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  box-shadow: none;
}

.btn.ghost:hover {
  background: var(--bg-subtle);
  color: var(--ink);
}

.btn.danger { background: var(--bad); }
.btn.danger:hover { background: #b91c1c; box-shadow: 0 4px 12px rgba(220, 38, 38, 0.2); }

.btn.sm { padding: 6px 12px; font-size: 13px; }

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Stats ── */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.stat {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--transition), border-color var(--transition);
}

.stat:hover {
  box-shadow: var(--shadow);
  border-color: var(--line-strong);
}

.stat::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 3px 0 0 3px;
}

.stat.accent-ok::before { background: var(--ok); }
.stat.accent-warn::before { background: var(--warn); }
.stat.accent-bad::before { background: var(--bad); }
.stat.accent-info::before { background: var(--info); }

.stat span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.1;
}

.stat strong.mono { font-size: 14px; font-family: var(--font-mono); font-weight: 600; }

/* ── Cards ── */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 0;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-padded { padding: 22px 24px; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
}

.card-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.card-body { padding: 0 24px 20px; }
.card-body:first-child { padding-top: 20px; }

.card h3 {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 600;
}

.card-padded > h3 { margin-bottom: 16px; }

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  background: #f8fafc;
  white-space: nowrap;
}

tbody tr {
  transition: background var(--transition);
}

tbody tr:hover { background: #f8fafc; }

tbody tr:last-child td { border-bottom: none; }

td .help { margin-top: 2px; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.muted { background: var(--bg-subtle); color: var(--muted); }
.badge.info { background: var(--info-bg); color: var(--info); }

/* ── Alerts ── */
.flash {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 14px;
  border: 1px solid transparent;
}

.flash-success { background: var(--ok-bg); color: #065f46; border-color: #a7f3d0; }
.flash-warning, .flash-info { background: var(--warn-bg); color: #92400e; border-color: #fde68a; }
.flash-error { background: var(--bad-bg); color: #991b1b; border-color: #fecaca; }

/* ── Secret / code blocks ── */
.secret-box {
  position: relative;
  background: #0f172a;
  color: #e2e8f0;
  padding: 16px 18px;
  padding-right: 48px;
  border-radius: var(--radius);
  word-break: break-all;
  margin: 12px 0 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  border: 1px solid #1e293b;
}

.secret-box pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: inherit;
}

.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--transition), color var(--transition);
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  color: white;
}

.copy-btn.copied { color: #5eead4; border-color: #5eead4; }

/* ── Forms ── */
.field { margin-bottom: 18px; }

.field label, .field .label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink-secondary);
}

.field-input,
input[type="text"],
input[type="email"],
input[type="url"],
input[type="password"],
input[type="search"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 14px;
  background: var(--paper);
  color: var(--ink);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.field-input:focus,
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.field-check {
  width: auto;
  accent-color: var(--accent);
  margin-right: 8px;
}

.checkbox-field {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.checkbox-field label {
  margin: 0;
  cursor: pointer;
}

.checkbox-field .help { margin-top: 4px; }

.help {
  color: var(--muted);
  font-size: 12px;
  margin-top: 5px;
  line-height: 1.45;
}

/* ── Filters ── */
.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  padding: 16px 20px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.filters input,
.filters select {
  width: auto;
  min-width: 160px;
  flex: 1;
  max-width: 240px;
}

/* ── Grid & definition lists ── */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.dl {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 10px 16px;
  font-size: 14px;
  margin: 0;
}

.dl dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.dl dd {
  margin: 0;
  color: var(--ink-secondary);
  word-break: break-word;
}

/* ── Empty states ── */
.empty {
  color: var(--muted);
  padding: 48px 24px;
  text-align: center;
  font-size: 14px;
}

.empty-icon {
  display: block;
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty strong {
  display: block;
  color: var(--ink-secondary);
  font-size: 15px;
  margin-bottom: 6px;
}

/* ── Login ── */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(13, 148, 136, 0.12), transparent),
    var(--bg);
}

.login-card {
  width: min(420px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-lg);
}

.login-card .brand {
  border-bottom: none;
  padding: 0 0 24px;
  margin-bottom: 0;
}

.login-card .brand h1 { color: var(--ink); }
.login-card .brand p { color: var(--muted); }

.login-card .btn {
  width: 100%;
  padding: 12px;
  margin-top: 8px;
  font-size: 15px;
}

.login-hint {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* ── Pay pages ── */
.pay-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 30% 20%, rgba(13, 148, 136, 0.25), transparent 50%),
    linear-gradient(160deg, #0f172a 0%, #1e293b 100%);
}

.pay-card {
  width: min(460px, 100%);
  background: var(--paper);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
}

.pay-merchant {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.pay-amount {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 8px 0 12px;
  color: var(--ink);
}

.pay-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

.pay-actions .btn { flex: 1; }

/* ── Status pill in header ── */
.status-pill {
  align-self: center;
}

/* ── Responsive ── */
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-lg);
  }

  .shell.nav-open .sidebar { transform: translateX(0); }
  .shell.nav-open .sidebar-backdrop { display: block; }

  .mobile-topbar { display: flex; }

  .content { padding: 20px 16px 48px; }

  .grid-2 { grid-template-columns: 1fr; }

  .dl { grid-template-columns: 1fr; gap: 4px; }
  .dl dt { margin-top: 8px; }

  .filters input,
  .filters select {
    max-width: none;
    min-width: 0;
    flex: 1 1 100%;
  }

  .page-header h2 { font-size: 1.4rem; }

  .stat strong { font-size: 1.35rem; }
}

@media (max-width: 480px) {
  th, td { padding: 10px 12px; font-size: 13px; }
  .pay-actions { flex-direction: column; }
}
