/* ============================================================
   PaymentGateway Admin Control Panel — Enterprise Fintech UI
   ============================================================ */

:root {
  --sidebar-w: 260px;
  --topbar-h: 60px;
  --bg: #f4f7fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --border: #e2e6ef;
  --border-light: #edf0f7;

  --text-primary: #1a2033;
  --text-secondary: #5a6478;
  --text-muted: #8c95a8;
  --text-inverse: #ffffff;

  --sidebar-bg: #1a1d2e;
  --sidebar-text: #b8bfd4;
  --sidebar-hover: rgba(255,255,255,0.06);
  --sidebar-active-bg: rgba(59,130,246,0.12);
  --sidebar-active-text: #60a5fa;
  --sidebar-section: #6b7394;

  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-light: #eff6ff;

  --success: #16a34a;
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --info: #0891b2;
  --info-bg: #ecfeff;
  --info-border: #a5f3fc;
  --neutral: #4b5563;
  --neutral-bg: #f9fafb;

  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  --surface-raised: #f8f9fc;
  --surface-sunken: #eef1f7;

  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.12);

  --transition: 150ms ease;

  /* Spacing (4px grid) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;

  /* Form */
  --form-gap: var(--sp-4);
  --form-section-gap: var(--sp-6);
  --input-h: 36px;
  --btn-height: 32px;
  --btn-height-sm: 28px;
  --btn-height-lg: 40px;
  --btn-height-xs: 24px;
  --input-bg: var(--surface);
  --input-border: var(--border);
  --input-border-focus: var(--accent);
  --input-focus-ring: 0 0 0 3px rgba(59, 130, 246, .12);
  --input-invalid-border: var(--danger);
  --input-invalid-bg: var(--surface);
  --label-color: var(--text-secondary);
  --hint-color: var(--text-muted);

  /* Inline code */
  --code-bg: var(--surface-sunken);
  --code-color: var(--text-primary);
  --code-border: var(--border-light);
}

/* ── Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: var(--font-sans); background: var(--bg); color: var(--text-primary); line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
input, textarea, select, button { font-family: inherit; font-size: inherit; }

/* ── Layout ───────────────────────────────────────────────── */
.admin-wrapper { display: flex; min-height: 100vh; }

/* ── Sidebar ──────────────────────────────────────────────── */
.admin-sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  height: 100dvh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0;
  z-index: 100;
  overflow: hidden;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.sidebar-logo-icon {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 16px;
  flex-shrink: 0;
}
.sidebar-logo-text {
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  line-height: 1.2;
}
.sidebar-logo-sub {
  color: var(--sidebar-text);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: .5px;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1 1 auto;
  min-height: 0;
  padding: 12px 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.12) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 2px; }

.sidebar-section {
  padding: 14px 16px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--sidebar-section);
}

/* Collapsible group header (button styled like .sidebar-section) */
.sidebar-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 16px 4px;
  background: transparent;
  border: 0;
  color: var(--sidebar-section);
  font: inherit;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .8px;
  text-transform: uppercase;
  cursor: pointer;
  text-align: left;
}
.sidebar-section-toggle:hover { color: #e2e8f0; }
.sidebar-section-toggle .chev {
  font-size: 11px;
  transition: transform 150ms ease;
  opacity: .7;
}
.sidebar-group.collapsed .sidebar-section-toggle .chev { transform: rotate(-90deg); }
.sidebar-group-body {
  overflow: hidden;
  max-height: 600px;
  transition: max-height 180ms ease;
}
.sidebar-group.collapsed .sidebar-group-body {
  max-height: 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 400;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: #e2e8f0;
  text-decoration: none;
}
.sidebar-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 500;
  border-inline-start: 3px solid var(--accent);
}
.sidebar-link .nav-icon,
.sidebar-link .icon { width: 20px; flex-shrink: 0; opacity: .75; display: flex; align-items: center; justify-content: center; }
.sidebar-link .nav-icon svg { width: 18px; height: 18px; }
.sidebar-link.active .nav-icon,
.sidebar-link.active .icon { opacity: 1; }
.sidebar-badge {
  margin-inline-start: auto;
  background: rgba(239,68,68,.25);
  color: #fca5a5;
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 20px;
  font-weight: 600;
  line-height: 1.5;
}
.sidebar-signout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  transition: background var(--transition), color var(--transition);
}
.sidebar-signout:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }

.sidebar-footer {
  flex-shrink: 0;
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(255,255,255,.06);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sidebar-text);
  font-size: 12px;
}
.sidebar-avatar {
  width: 30px; height: 30px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { color: #e2e8f0; font-weight: 500; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 10px; color: var(--sidebar-section); text-transform: uppercase; letter-spacing: .4px; }

/* ── Main area ────────────────────────────────────────────── */
.admin-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ───────────────────────────────────────────────── */
.admin-topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.topbar-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
}
.topbar-menu-btn:hover { background: var(--surface-2); }
.topbar-search {
  flex: 0 1 280px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 0 12px;
  height: 36px;
}
.topbar-search-icon { color: var(--text-muted); display: flex; }
.topbar-search-input {
  flex: 1;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 13px;
  color: var(--text-primary);
  min-width: 0;
}
.topbar-search-input::placeholder { color: var(--text-muted); }
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-inline-start: auto;
}
.topbar-user-chip { display: flex; align-items: center; }
.topbar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.topbar-breadcrumb {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 0;
  justify-content: flex-end;
}
.topbar-breadcrumb a { color: var(--text-secondary); }
.topbar-breadcrumb a:hover { color: var(--accent); text-decoration: none; }
.topbar-breadcrumb .sep { color: var(--text-muted); }
.topbar-breadcrumb .current { color: var(--text-primary); font-weight: 500; }

.topbar-env-badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .3px;
}
.env-dev { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }
.env-prod { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }

.topbar-user {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-secondary);
}

/* ── Page content ─────────────────────────────────────────── */
.admin-content { flex: 1; padding: 24px; }
/* .page-header / .page-title / .page-subtitle: defined below in the consolidated Page header block */

.page-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 12px;
}
.card-title { font-size: 14px; font-weight: 600; color: var(--text-primary); flex: 1; }
.card-body { padding: 20px; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-light);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ── KPI Cards ────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.kpi-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.kpi-value { font-size: 26px; font-weight: 700; color: var(--text-primary); line-height: 1; margin-bottom: 4px; }
.kpi-sub { font-size: 11px; color: var(--text-secondary); }
.kpi-card.accent { border-left: 3px solid var(--accent); }
.kpi-card.success { border-left: 3px solid var(--success); }
.kpi-card.warning { border-left: 3px solid var(--warning); }
.kpi-card.danger { border-left: 3px solid var(--danger); }

/* Clickable KPI card */
a.kpi-link {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: box-shadow 120ms ease, transform 120ms ease;
}
a.kpi-link:hover {
  box-shadow: 0 4px 12px rgba(59,130,246,.15);
  transform: translateY(-1px);
  border-color: var(--accent);
  text-decoration: none;
  color: inherit;
}
a.kpi-link:active { transform: translateY(0); }

/* ── Stat row ─────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.stat-item { text-align: center; padding: 12px; }
.stat-number { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.stat-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ── Status & Risk Badges ─────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.badge-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid var(--danger-border); }
.badge-info    { background: var(--info-bg);    color: var(--info);    border: 1px solid var(--info-border); }
.badge-neutral { background: var(--neutral-bg); color: var(--neutral); border: 1px solid var(--border); }
.badge-accent  { background: var(--accent-light); color: var(--accent); border: 1px solid #bfdbfe; }

/* Status-specific */
.status-Pending       { background: #fefce8; color: #854d0e; border: 1px solid #fef08a; }
.status-Processing    { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.status-Paid          { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.status-Failed        { background: var(--danger-bg);  color: var(--danger);  border: 1px solid var(--danger-border); }
.status-Cancelled     { background: #f3f4f6; color: #4b5563; border: 1px solid #d1d5db; }
.status-Expired       { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.status-Refunded      { background: #faf5ff; color: #7e22ce; border: 1px solid #e9d5ff; }
.status-PartiallyRefunded { background: #faf5ff; color: #9333ea; border: 1px solid #ddd6fe; }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}
table.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-table th {
  background: var(--surface-2);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky; top: 0;
}
.admin-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: var(--surface-2); }
.admin-table .mono { font-family: var(--font-mono); font-size: 12px; }
.admin-table .text-muted { color: var(--text-muted); }

/* Row actions */
.row-actions { display: flex; align-items: center; gap: 4px; }
.action-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  transition: background var(--transition), color var(--transition);
}
.action-btn:hover { background: var(--border-light); color: var(--text-primary); }
.action-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }

/* ── Filters ──────────────────────────────────────────────── */
/* .filter-bar is a light wrapper (margin only) defined below.
   .filter-card is the boxed/surface variant defined later. */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }
.filter-group .form-input { min-width: 140px; }

/* ── Form Controls ────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
/* .form-group: base definition is in the Form card block below */
.form-group.full { grid-column: 1 / -1; }
.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-label .hint { font-weight: 400; color: var(--text-muted); font-size: 11px; }
.form-input, .form-select, .form-textarea {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 13px;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.form-input.error, .form-select.error { border-color: var(--danger); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
.form-check label { font-size: 13px; cursor: pointer; }
.form-hint { font-size: 11px; color: var(--hint-color); line-height: 1.45; }
.form-hint code,
.form-note code {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--code-bg);
  color: var(--code-color);
  border: 1px solid var(--code-border);
  border-radius: 3px;
  padding: 1px 5px;
}
.form-error { font-size: 11px; color: var(--danger); }
.validation-error { color: var(--danger); font-size: 12px; margin-top: 3px; }
.field-validation-error { color: var(--danger); font-size: 12px; display: block; margin-top: var(--sp-1); }

/* Visible fields only — never style hidden inputs (avoids pink :invalid on caller pickers) */
.form-input:not([type="hidden"]):user-invalid,
.form-select:user-invalid {
  border-color: var(--input-invalid-border);
  background: var(--input-invalid-bg);
}
.form-input:not([type="hidden"]).input-validation-error,
.form-select.input-validation-error {
  border-color: var(--input-invalid-border);
  background: var(--input-invalid-bg);
}
input[type="hidden"] { display: none !important; }

/* Form sections (test payment, multi-step forms) */
.form-section {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--surface-2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
}
.form-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0;
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border-light);
}
.form-grid--2col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 720px) {
  .form-grid--2col { grid-template-columns: 1fr; }
}
.form-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--border-light);
}
.form-note {
  grid-column: 1 / -1;
  font-size: 11px;
  color: var(--hint-color);
  padding: var(--sp-3) var(--sp-4);
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  border-radius: var(--radius-sm);
  line-height: 1.5;
}

/* Caller picker (test payment) */
.caller-picker { display: flex; flex-direction: column; gap: var(--sp-2); }
.caller-picker-hint { font-size: 11px; color: var(--hint-color); margin: 0; }
.caller-picker-hint[hidden] { display: none !important; }
.caller-picker-state {
  font-size: 12px;
  color: var(--text-secondary);
  padding: var(--sp-3);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
}
.caller-picker-state[hidden] { display: none !important; }
.caller-picker-error {
  margin: 0;
  padding: var(--sp-2) var(--sp-3);
  font-size: 12px;
}
.caller-picker-error[hidden] { display: none !important; }
.caller-picker-table .admin-table { font-size: 12px; }
.caller-picker-table .admin-table th { padding: 8px 12px; }
.caller-picker-table .admin-table td { padding: 8px 12px; }
.caller-picker-table .admin-table tbody tr { cursor: pointer; transition: background var(--transition); }
.caller-picker-table .admin-table tbody tr:hover { background: var(--accent-light); }
.caller-picker-table .admin-table tbody tr.is-selected {
  background: var(--accent-light);
  box-shadow: inset 3px 0 0 var(--accent);
}
.caller-picker-table .col-select { width: 40px; text-align: center; }
.caller-picker-table input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
.caller-picker-selection {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  min-height: var(--input-h);
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.caller-picker-selection[hidden] { display: none !important; }
.caller-picker-selection-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--hint-color);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.caller-picker-selection-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.caller-picker-selection-value code {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  background: transparent;
  border: none;
  padding: 0;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-sizing: border-box;
  height: var(--btn-height);
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.25;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  text-decoration: none;
  vertical-align: middle;
}
button.btn {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); text-decoration: none; color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); text-decoration: none; color: var(--text-primary); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: #b91c1c; text-decoration: none; color: #fff; }
.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-warning:hover:not(:disabled) { background: #b45309; text-decoration: none; color: #fff; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover:not(:disabled) { background: #15803d; text-decoration: none; color: #fff; }
.btn-ghost { background: transparent; color: var(--text-secondary); border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--border-light); text-decoration: none; color: var(--text-primary); }
.btn-sm {
  height: var(--btn-height-sm);
  padding: 0 10px;
  font-size: 12px;
}
.btn-lg {
  height: var(--btn-height-lg);
  padding: 0 22px;
  font-size: 14px;
}
.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.btn-group > form,
.header-actions > form {
  display: inline-flex;
  margin: 0;
  align-items: center;
}

/* ── Pagination ───────────────────────────────────────────── */
/* .pagination / .page-btn: defined below in consolidated Pagination block */
.page-btn.disabled { opacity: .4; pointer-events: none; }
.page-info { font-size: 12px; color: var(--text-muted); padding: 0 8px; }

/* ── Tabs ─────────────────────────────────────────────────── */
.tabs { border-bottom: 1px solid var(--border); margin-bottom: 24px; display: flex; gap: 0; overflow-x: auto; }
.tab {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
  background: transparent;
  border-top: none; border-left: none; border-right: none;
}
.tab:hover { color: var(--text-primary); text-decoration: none; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 16px;
}
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }
.alert-danger  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid var(--danger-border); }
.alert-info    { background: var(--info-bg);    color: var(--info);    border: 1px solid var(--info-border); }
.alert-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }

/* ── Secret reveal box ────────────────────────────────────── */
.secret-box {
  background: #0f172a;
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid #1e293b;
}
.secret-box-header { color: #94a3b8; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; margin-bottom: 8px; }
.secret-value {
  font-family: var(--font-mono);
  font-size: 13px;
  color: #a5f3fc;
  word-break: break-all;
  background: #1e293b;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  cursor: text;
}
.secret-warning {
  background: #451a03;
  border: 1px solid #92400e;
  color: #fbbf24;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px;
  margin-top: 12px;
}

/* ── JSON viewer ──────────────────────────────────────────── */
.json-viewer {
  background: #0f172a;
  color: #94a3b8;
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.7;
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 40px; margin-bottom: 12px; opacity: .5; }
.empty-state-title { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state-text { font-size: 13px; }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 480px;
  width: 100%;
  margin: 20px;
}
.modal-header {
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; gap: 12px;
}
.modal-title { font-size: 15px; font-weight: 700; flex: 1; }
.modal-close { cursor: pointer; color: var(--text-muted); background: none; border: none; font-size: 18px; }
.modal-body { padding: 20px 24px; font-size: 13px; color: var(--text-secondary); }
.modal-footer { padding: 14px 24px; border-top: 1px solid var(--border-light); display: flex; justify-content: flex-end; gap: 10px; }

/* ── Copy button ──────────────────────────────────────────── */
.copy-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
}
.copy-btn:hover { background: var(--border-light); color: var(--text-primary); }
.copy-btn.copied { color: var(--success); border-color: var(--success-border); background: var(--success-bg); }

/* ── Login page ───────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo-icon {
  width: 52px; height: 52px;
  background: var(--accent);
  border-radius: var(--radius);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 24px; color: white;
  margin-bottom: 14px;
}
.login-title { font-size: 20px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.login-subtitle { font-size: 13px; color: var(--text-muted); }

/* ── Risk indicators ──────────────────────────────────────── */
.risk-ok    { color: var(--success); }
.risk-warn  { color: var(--warning); }
.risk-error { color: var(--danger); }

/* ── Charts placeholder ───────────────────────────────────── */
.chart-container { position: relative; height: 200px; }

/* ── Timeline ─────────────────────────────────────────────── */
/* Base .timeline / .timeline-item / .timeline-dot defined below in the
   "Timeline (transaction status)" block. These shared modifiers (dot color
   variants used by the dashboard) live here so they survive even if the
   primary list of timeline-dot variants changes. */
.timeline-dot.success { background: var(--success); }
.timeline-dot.danger  { background: var(--danger); }
.timeline-dot.warning { background: var(--warning); }
.timeline-dot.neutral { background: var(--border); }
.timeline-dot.accent  { background: var(--accent); }
.timeline-time { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.timeline-text { font-size: 13px; color: var(--text-secondary); }
.timeline-text strong { color: var(--text-primary); }

/* ── Detail rows ──────────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.detail-row {
  display: flex;
  flex-direction: column;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}
.detail-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 3px; }
.detail-value { font-size: 13px; color: var(--text-primary); }
.detail-value .mono { font-family: var(--font-mono); font-size: 12px; }

/* ── Utility ──────────────────────────────────────────────── */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.font-mono { font-family: var(--font-mono); font-size: 12px; }
.font-bold { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.hidden { display: none; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
  .admin-sidebar { transform: translateX(-100%); transition: transform .25s ease; }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-main { margin-left: 0; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Section card (token groups, etc.) ────────────────────── */
.section-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.section-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  background: var(--surface-raised);
}
.section-card-header h3 { font-size: 14px; font-weight: 600; margin: 0; }
.section-card .admin-table { border: none; border-radius: 0; }

/* ── Filter card (compact filter panel) ───────────────────── */
.filter-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; }
.filter-form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; align-items: end; }
.filter-form-grid .col-span-2 { grid-column: span 2; }
.filter-actions { display: flex; align-items: center; gap: 8px; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }

/* ── Production readiness checklist ───────────────────────── */
.checklist { display: flex; flex-direction: column; gap: 8px; }
.checklist-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface);
}
.checklist-item.check-pass { border-color: #bbf7d0; background: #f0fdf4; }
.checklist-item.check-critical { border-color: #fecaca; background: #fef2f2; }
.checklist-item.check-warning { border-color: #fed7aa; background: #fff7ed; }
.checklist-item.check-info { border-color: #bfdbfe; background: #eff6ff; }
.check-icon { font-size: 18px; line-height: 1; flex-shrink: 0; }
.check-pass .check-icon { color: var(--success); }
.check-critical .check-icon { color: var(--danger); }
.check-warning .check-icon { color: var(--warning); }
.check-info .check-icon { color: var(--info, #3b82f6); }
.check-body { flex: 1; }
.check-body strong { font-size: 13px; display: block; }
.check-message { font-size: 12px; color: var(--text-muted); margin: 4px 0 0; }
.check-badge { margin-left: auto; flex-shrink: 0; }
.checklist-summary { display: flex; gap: 16px; }

/* ── Audit diff viewer ─────────────────────────────────────── */
.audit-detail-row td { padding: 0 !important; background: var(--surface-raised); }
.audit-diff { display: grid; grid-template-columns: 1fr 1fr; gap: 0; padding: 16px 20px; gap: 16px; }
.audit-diff-col { display: flex; flex-direction: column; gap: 6px; }
.audit-diff-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; padding: 4px 8px; border-radius: 4px; }
.diff-before { background: #fef2f2; color: #b91c1c; }
.diff-after { background: #f0fdf4; color: #15803d; }
.json-before { border-left: 3px solid #f87171; }
.json-after { border-left: 3px solid #4ade80; }

/* ── Timeline (transaction status) ────────────────────────── */
.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ''; position: absolute; left: 8px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding: 0 0 24px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  position: absolute; left: -24px; top: 3px;
  width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--surface);
}
.dot-info { background: #3b82f6; }
.dot-success { background: var(--success); }
.dot-danger { background: var(--danger); }
.dot-warning { background: var(--warning); }
.dot-default { background: var(--text-muted); }
.timeline-content strong { font-size: 13px; display: block; margin-bottom: 2px; }
.timeline-content p { font-size: 12px; color: var(--text-muted); margin: 4px 0 0; }
.timeline-content span { font-size: 11px; }

/* ── Detail grid two-col variant ──────────────────────────── */
.detail-grid.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.detail-grid.two-col > div { border-right: 1px solid var(--border-light); padding-right: 16px; }
.detail-grid.two-col > div:last-child { border-right: none; padding-right: 0; padding-left: 16px; }

/* ── Row warning highlight ─────────────────────────────────── */
.row-warning { background: #fff7ed !important; }
.row-warning:hover { background: #ffedd5 !important; }

/* ── Secret reveal card ────────────────────────────────────── */
.secret-reveal-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.secret-box {
  display: flex; align-items: center; gap: 12px;
  background: #0d1117; border: 1px solid #30363d; border-radius: var(--radius);
  padding: 14px 16px; margin-top: 8px;
}
.secret-box code { font-family: var(--font-mono); font-size: 13px; color: #58a6ff; flex: 1; word-break: break-all; }
.masked-secret { font-family: var(--font-mono); font-size: 13px; letter-spacing: 2px; color: var(--text-muted); }

/* ── Action row (edit page credential rotation) ───────────── */
.action-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--border-light); }
.action-row:last-child { border-bottom: none; }

/* ── Form card ────────────────────────────────────────────── */
.form-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.form-section { margin-bottom: 28px; }
.form-section:last-child { margin-bottom: 0; }
.form-section-title { font-size: 13px; font-weight: 700; color: var(--text-primary); text-transform: uppercase; letter-spacing: .5px; margin: 0 0 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border-light); }
.danger-zone-title { color: var(--danger); border-bottom-color: #fecaca; }
.form-row { display: flex; gap: 16px; }
.form-row.two-col > .form-group { flex: 1; }
.form-row.three-col > .form-group { flex: 1; }
.form-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }
.form-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.form-hint { font-size: 11px; color: var(--text-muted); }
.form-control {
  padding: 8px 12px; font-size: 13px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface-raised); color: var(--text-primary);
  transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-actions { display: flex; gap: 10px; padding-top: 16px; border-top: 1px solid var(--border-light); margin-top: 8px; }
.tenant-form-shell { max-width: 920px; }
.tenant-form-card { padding: 28px; }
.tenant-form-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tenant-logo-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  gap: 16px;
  align-items: start;
}
.tenant-logo-preview {
  width: 132px;
  min-height: 84px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-raised);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 10px;
}
.tenant-logo-preview img {
  max-width: 100%;
  max-height: 64px;
  object-fit: contain;
}
.tenant-logo-preview-empty {
  font-size: 11px;
  line-height: 1.35;
  color: var(--text-muted);
  text-align: center;
}
.mode-toggle-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.mode-toggle-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--surface-raised);
  cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.mode-toggle-card:has(input:checked) {
  border-color: var(--accent);
  background: rgba(99, 102, 241, .06);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .08);
}
.mode-toggle-card input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
}
.mode-toggle-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.mode-toggle-desc {
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-muted);
}
.tenant-logo-preview-inline {
  width: auto;
  min-width: 96px;
  min-height: 56px;
  display: inline-flex;
}
@media (max-width: 720px) {
  .tenant-logo-field { grid-template-columns: 1fr; }
  .tenant-logo-preview { width: 100%; min-height: 72px; }
}
.checkbox-group { flex-direction: row !important; align-items: center; gap: 8px !important; }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.field-error { font-size: 11px; color: var(--danger); }
.required { color: var(--danger); }

/* ── KPI inline ──────────────────────────────────────────── */
.kpi-inline { font-size: 13px; font-weight: 600; color: var(--text-muted); }

/* ── Badge extras ────────────────────────────────────────── */
.badge-xs { font-size: 10px; padding: 1px 6px; }
.badge-lg { font-size: 13px; padding: 4px 12px; }
.badge-muted { background: var(--surface-raised); color: var(--text-muted); border: 1px solid var(--border); }
.badge-info { background: #eff6ff; color: #1d4ed8; }
.ml-1 { margin-left: 4px; }
.mr-1 { margin-right: 4px; }
.text-nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }
.small { font-size: 12px; }
.mt-3 { margin-top: 12px; }
.mb-3 { margin-bottom: 12px; }

/* ── Empty state card ────────────────────────────────────── */
.empty-state-card { text-align: center; padding: 48px 24px; color: var(--text-muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
/* .empty-state base is defined above. Tighten padding when used inside table cells. */
.admin-table .empty-state, td.empty-state { padding: 32px; font-size: 13px; }

/* ── Page header ─────────────────────────────────────────── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; gap: 16px; }
.page-title { font-size: 22px; font-weight: 700; color: var(--text-primary); margin: 0 0 4px; }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin: 0; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* ── Pagination ──────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; align-items: center; padding: 16px 0; flex-wrap: wrap; }
.page-btn { padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 12px; color: var(--text-secondary); text-decoration: none; background: var(--surface); }
.page-btn:hover { background: var(--surface-raised); border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Filter bar (boxed wrapper, used across listing pages) ── */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.filter-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter-form .form-control { min-width: 140px; }


/* ── Lookup page utilities ───────────────────────────────── */
.row-inactive { opacity: 0.55; }
.row-inactive td { color: var(--text-muted); }
.badge-code { font-family: var(--font-mono, monospace); font-size: 12px; background: var(--surface-raised); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; color: var(--text-secondary); }
.badge-secondary { background: var(--surface-raised); color: var(--text-muted); border: 1px solid var(--border); }

/* ── Form card (used in lookup create forms) ─────────────── */
.form-card-header { margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.form-card-title { font-size: 15px; font-weight: 600; color: var(--text-primary); margin: 0; }
.form-grid.three-col { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .form-grid.three-col { grid-template-columns: 1fr; } }

/* ── Topbar mobile menu ───────────────────────────────────── */
.topbar-menu-btn {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 6px 10px;
  color: var(--text-secondary);
}
@media (max-width: 900px) {
  .topbar-menu-btn { display: inline-flex; align-items: center; justify-content: center; }
}

/* ── Row action dropdown ──────────────────────────────────── */
.action-menu { position: relative; display: inline-block; }
.action-menu-trigger {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0;
}
.action-menu-trigger:hover { background: var(--surface-2); color: var(--text-primary); }
.action-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 60;
  padding: 4px 0;
}
.action-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-primary);
  background: transparent;
  border: none;
  cursor: pointer;
  text-decoration: none;
}
.action-menu-item:hover { background: var(--surface-2); text-decoration: none; }
.action-menu-item.danger { color: var(--danger); }
.action-menu-divider { height: 1px; background: var(--border-light); margin: 4px 0; }

/* ── Pagination bar ───────────────────────────────────────── */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 0 4px;
}

/* ── Dashboard panels ─────────────────────────────────────── */
.dashboard-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 1100px) { .dashboard-grid-2 { grid-template-columns: 1fr; } }

.provider-status-list { display: flex; flex-direction: column; gap: 8px; }
.provider-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 13px;
}

/* ── Settings tabs ────────────────────────────────────────── */
.tab-container { margin-top: 8px; }
.tab-nav {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
}
.tab-btn {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-container > .tab-content { display: none; }
.tab-container > .tab-content.active { display: block; }

/* ── RTL support (Arabic fields) ──────────────────────────── */
[dir="rtl"] .form-control,
[dir="rtl"] .form-input,
[dir="rtl"] .form-textarea { text-align: right; }
html[dir="rtl"] .admin-sidebar { left: auto; right: 0; }
html[dir="rtl"] .admin-main { margin-left: 0; margin-right: var(--sidebar-w); }
html[dir="rtl"] .sidebar-link.active { border-right: none; border-left: 2px solid var(--accent); }
html[dir="rtl"] .action-menu-panel { right: auto; left: 0; }

/* ── Loading skeleton ─────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--border-light) 25%, #eef1f7 50%, var(--border-light) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
  border-radius: var(--radius-sm);
  min-height: 14px;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Roles grid ───────────────────────────────────────────── */
.roles-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(240px,1fr)); gap:10px; }
.role-check-item { border:1px solid var(--border-light); border-radius:var(--radius-sm); padding:12px 14px; cursor:pointer; transition:border-color var(--transition),background var(--transition); }
.role-check-item:hover { border-color:var(--accent); background:var(--accent-light); }
.role-name { display:block; font-weight:600; font-size:13px; color:var(--text-primary); }
.role-desc { display:block; font-size:11px; color:var(--text-muted); margin-top:2px; }

/* ── Permissions grid ──────────────────────────────────────── */
.perm-group-title { font-size:12px; font-weight:700; text-transform:uppercase; letter-spacing:.05em; color:var(--text-secondary); }
.perm-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(260px,1fr)); gap:6px; }
.perm-check-item { display:flex; flex-direction:column; padding:8px 12px; border:1px solid var(--border-light); border-radius:var(--radius-sm); transition:border-color var(--transition); }
.perm-check-item:hover { border-color:var(--accent); }
.perm-name { font-size:13px; font-weight:500; color:var(--text-primary); }
.perm-code { font-size:10px; font-family:var(--font-mono); color:var(--text-muted); margin-top:2px; }

/* ── Role card ─────────────────────────────────────────────── */
.role-card { transition:box-shadow var(--transition); }
.role-card:hover { box-shadow:var(--shadow); }
.permission-summary { display:flex; flex-wrap:wrap; gap:6px; }
.perm-category { display:flex; align-items:center; gap:6px; background:var(--surface-2); border:1px solid var(--border-light); border-radius:100px; padding:2px 10px; font-size:11px; }
.perm-cat-label { color:var(--text-secondary); }
.perm-count { background:var(--accent); color:white; border-radius:100px; padding:1px 7px; font-size:10px; font-weight:700; }

/* ── User avatar cell ──────────────────────────────────────── */
.user-cell { display:flex; align-items:center; gap:10px; }
.user-avatar { width:32px; height:32px; border-radius:50%; background:var(--accent); color:white; display:flex; align-items:center; justify-content:center; font-weight:700; font-size:13px; flex-shrink:0; }

/* ── Info list ─────────────────────────────────────────────── */
.info-list { display:grid; grid-template-columns:auto 1fr; gap:6px 16px; font-size:12px; }
.info-list dt { color:var(--text-muted); font-weight:500; white-space:nowrap; }
.info-list dd { color:var(--text-primary); margin:0; word-break:break-all; }

/* ── Page header enhanced ───────────────────────────────────── */
.page-header-left { display:flex; flex-direction:column; gap:6px; flex:1; min-width:0; }
.page-title-group { display:flex; align-items:center; gap:12px; }
.page-title-icon { width:40px; height:40px; display:flex; align-items:center; justify-content:center; background:var(--accent-light); color:var(--accent); border-radius:var(--radius); flex-shrink:0; }
.back-link { display:inline-flex; align-items:center; gap:6px; color:var(--text-muted); font-size:12px; text-decoration:none; transition:color var(--transition); }
.back-link:hover { color:var(--text-primary); }

/* ── Card section / form elements ──────────────────────────── */
.card-section-title { font-size:13px; font-weight:600; color:var(--text-primary); margin:0; }
/* .form-actions: base definition is in the Form card block above */
.required-label::after { content:" *"; color:var(--danger); }
.border-danger-subtle { border-color:var(--danger-border) !important; }
.bg-danger-subtle { background:var(--danger-bg) !important; }
.text-danger { color:var(--danger) !important; }

/* ── Status badges ──────────────────────────────────────────── */
.status-badge { display:inline-flex; align-items:center; gap:4px; padding:2px 8px; border-radius:100px; font-size:11px; font-weight:600; }
.status-active { background:var(--success-bg); color:var(--success); border:1px solid var(--success-border); }
.status-inactive { background:var(--neutral-bg); color:var(--neutral); border:1px solid var(--border); }
.status-warning { background:var(--warning-bg); color:var(--warning); border:1px solid var(--warning-border); }
.status-danger { background:var(--danger-bg); color:var(--danger); border:1px solid var(--danger-border); }

/* ── Misc utilities ─────────────────────────────────────────── */
.table-footer { padding:10px 0 4px; }
.btn-xs {
  height: var(--btn-height-xs);
  padding: 0 8px;
  font-size: 11px;
  line-height: 1.25;
}
.font-mono { font-family:var(--font-mono) !important; }
.text-sm { font-size:12px; }
.icon-xs { width:14px; height:14px; }
.icon-sm { width:16px; height:16px; }
.flex-shrink-0 { flex-shrink:0; }
.col-actions { width:160px; white-space:nowrap; }

/* ── Grid / column utilities ────────────────────────────────── */
.row { display:flex; flex-wrap:wrap; }
.row.g-3 { gap:12px; }
.row.g-4 { gap:16px; }
.col-12 { flex:0 0 100%; max-width:100%; }
.col-md-6 { flex:0 0 calc(50% - 6px); }
.col-md-5 { flex:0 0 calc(41.67% - 6px); }
.col-md-7 { flex:0 0 calc(58.33% - 6px); }
.col-lg-4 { flex:0 0 calc(33.33% - 8px); }
.col-lg-8 { flex:0 0 calc(66.67% - 8px); }
.col-xl-4 { flex:0 0 calc(33.33% - 8px); }
@media (max-width:768px) { .col-md-5,.col-md-6,.col-md-7,.col-lg-4,.col-lg-8,.col-xl-4 { flex:0 0 100%; } }

/* ── Flex / spacing helpers ─────────────────────────────────── */
.d-flex { display:flex !important; }
.d-inline { display:inline !important; }
.d-block { display:block !important; }
.d-none { display:none !important; }
.d-grid { display:grid !important; }
.align-items-center { align-items:center !important; }
.align-items-start { align-items:flex-start !important; }
.justify-content-between { justify-content:space-between !important; }
.justify-content-end { justify-content:flex-end !important; }
.flex-wrap { flex-wrap:wrap !important; }
.w-100 { width:100% !important; }
.h-100 { height:100% !important; }
.gap-2 { gap:8px !important; }
.gap-3 { gap:12px !important; }
.gap-4 { gap:16px !important; }
.mb-0 { margin-bottom:0 !important; }
.mb-1 { margin-bottom:4px !important; }
.mb-2 { margin-bottom:8px !important; }
.mb-3 { margin-bottom:12px !important; }
.mb-4 { margin-bottom:16px !important; }
.mt-1 { margin-top:4px !important; }
.mt-2 { margin-top:8px !important; }
.mt-3 { margin-top:12px !important; }
.ms-1 { margin-left:4px !important; }
.ms-2 { margin-left:8px !important; }
.ms-3 { margin-left:12px !important; }
.me-1 { margin-right:4px !important; }
.me-2 { margin-right:8px !important; }
.me-3 { margin-right:12px !important; }
.my-2 { margin-top:8px !important; margin-bottom:8px !important; }
.p-0 { padding:0 !important; }

/* ── Toggle switch ──────────────────────────────────────────── */
.form-switch .form-check-input { width:36px; height:20px; appearance:none; -webkit-appearance:none; background:var(--border); border-radius:100px; cursor:pointer; position:relative; transition:background var(--transition); }
.form-switch .form-check-input::after { content:""; position:absolute; top:3px; left:3px; width:14px; height:14px; border-radius:50%; background:white; transition:transform var(--transition); }
.form-switch .form-check-input:checked { background:var(--accent); }
.form-switch .form-check-input:checked::after { transform:translateX(16px); }

/* ── Bulk action bar ────────────────────────────────────────── */
.bulk-action-bar { display:flex; align-items:center; gap:12px; padding:10px 16px; background:var(--accent-light); border:1px solid var(--accent); border-radius:var(--radius); margin-bottom:8px; }
.bulk-count { font-weight:600; font-size:13px; color:var(--accent); }
.col-check { width:36px; padding-left:12px !important; }
.selectable-row { cursor:pointer; }
.selectable-row:has(.row-select:checked) { background:var(--accent-light) !important; }

/* ── Skeleton loading states (extras) ───────────────────────── */
/* Base .skeleton is defined above in "Loading skeleton" block */
.skeleton-row td { padding:14px 12px !important; }
.skeleton-text { height:12px; border-radius:6px; }
.skeleton-text.w-75 { width:75%; }
.skeleton-text.w-50 { width:50%; }
.skeleton-badge { height:20px; width:64px; border-radius:100px; }
.skeleton-btn { height:28px; width:48px; border-radius:var(--radius-sm); }
.skeleton-card { height:80px; border-radius:var(--radius); }

/* ── Accessibility: skip-link & focus rings ───────────────── */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  z-index: 1000;
}
.skip-link:focus { left: 12px; top: 12px; }

button:focus-visible,
a:focus-visible,
.btn:focus-visible,
.form-input:focus-visible,
.form-select:focus-visible,
.form-control:focus-visible,
.form-textarea:focus-visible,
.sidebar-link:focus-visible,
.tab-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sidebar-link:focus-visible { outline-offset: -2px; }

/* ── Sidebar sign-out button ──────────────────────────────── */
.sidebar-signout {
  margin-left: auto;
  color: #94a3b8;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  text-decoration: none;
}
.sidebar-signout:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }

/* ── Env badge: staging variant ───────────────────────────── */
.env-stage { background: var(--info-bg); color: var(--info); border: 1px solid var(--info-border); }

/* ── Operational alerts (dashboard) ────────────────────────── */
.alert-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.alert-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  border-left-width: 3px;
}
.alert-card .alert-card-icon {
  font-size: 18px;
  line-height: 1;
  margin-top: 1px;
  flex-shrink: 0;
}
.alert-card .alert-card-body { flex: 1; min-width: 0; }
.alert-card .alert-card-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin: 0 0 2px;
}
.alert-card .alert-card-text {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0 0 6px;
}
.alert-card .alert-card-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}
.alert-card .alert-card-link:hover { text-decoration: underline; }
.alert-card.danger { border-left-color: var(--danger); background: var(--danger-bg); }
.alert-card.danger .alert-card-icon { color: var(--danger); }
.alert-card.warning { border-left-color: var(--warning); background: var(--warning-bg); }
.alert-card.warning .alert-card-icon { color: var(--warning); }
.alert-card.info { border-left-color: var(--info); background: var(--info-bg); }
.alert-card.info .alert-card-icon { color: var(--info); }
.alert-card.success { border-left-color: var(--success); background: var(--success-bg); }
.alert-card.success .alert-card-icon { color: var(--success); }

/* ── Fast-access shortcut grid ────────────────────────────── */
.shortcut-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.shortcut-tile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.shortcut-tile:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(59,130,246,.12);
  text-decoration: none;
  color: var(--text-primary);
  transform: translateY(-1px);
}
.shortcut-tile-icon {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: var(--radius-sm);
  font-size: 16px;
  flex-shrink: 0;
}

/* ── Section header on dashboard ──────────────────────────── */
.section-eyebrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.section-eyebrow .eyebrow-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .6px;
}

/* ── Inline copy chip ─────────────────────────────────────── */
.copy-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.copy-chip:hover { background: var(--accent-light); color: var(--accent); }
.copy-chip.copied { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.copy-chip::after {
  content: "⧉";
  opacity: .55;
  font-size: 11px;
}
.copy-chip.copied::after { content: "✓"; opacity: 1; }

/* ── Additional mobile responsiveness ──────────────────────── */
@media (max-width:768px) {
  .page-header { flex-direction:column; align-items:flex-start; gap:12px; }
  .header-actions { flex-wrap:wrap; }
  .filter-grid { grid-template-columns:1fr 1fr; }
  .filter-actions { flex-wrap:wrap; }
  .admin-table thead { display:none; }
  .admin-table td { display:flex; justify-content:space-between; padding:8px 12px !important; border-bottom:1px solid var(--border-light) !important; }
  .admin-table td::before { content:attr(data-label); font-weight:600; color:var(--text-muted); font-size:11px; flex-shrink:0; margin-right:8px; }
  .admin-table tr { border:1px solid var(--border); border-radius:var(--radius); margin-bottom:8px; display:block; }
  .table-wrapper { overflow-x:auto; }
  .kpi-grid { grid-template-columns:1fr 1fr; }
  .detail-grid.two-col { grid-template-columns:1fr; }
  .col-check { display:none; }
  .bulk-action-bar { flex-wrap:wrap; }
  .form-grid { grid-template-columns:1fr; }
  .form-actions { flex-wrap:wrap; }
  .tab-nav { flex-wrap:wrap; gap:2px; }
}

/* ── Language switcher ───────────────────────────────────────── */
.lang-switcher {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  margin-inline-start: var(--sp-4);
  font-size: 12px;
}
.lang-switcher-sep {
  color: var(--text-muted);
  user-select: none;
}
.lang-switcher-btn {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: color var(--transition), background var(--transition);
}
.lang-switcher-btn:hover {
  color: var(--text-primary);
  background: var(--surface-2);
}
.lang-switcher-btn.active {
  color: var(--accent);
  background: var(--accent-light);
}
.login-lang-switcher {
  display: flex;
  justify-content: center;
  margin-bottom: var(--sp-4);
}

/* ── Approx-style dashboard hero ───────────────────────────── */
.dash-hero-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 280px;
  gap: 16px;
  margin-bottom: 24px;
}
.balance-hero {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  min-height: 220px;
}
.balance-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 85% 20%, rgba(59,130,246,.06) 0%, transparent 55%);
  pointer-events: none;
}
.balance-hero-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 8px;
}
.balance-hero-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  margin-bottom: 6px;
}
.balance-hero-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--success);
  margin-bottom: 20px;
}
.balance-hero-trend.down { color: var(--danger); }
.balance-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}
.balance-hero-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
  font-size: 12px;
  color: var(--text-secondary);
}
.balance-hero-footer strong { color: var(--text-primary); font-weight: 600; }
.stat-stack { display: flex; flex-direction: column; gap: 12px; }
.stat-stack-card {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 120ms ease, transform 120ms ease;
}
.stat-stack-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
  text-decoration: none;
  color: inherit;
}
.stat-stack-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 4px;
}
.stat-stack-value { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.stat-stack-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-stack-icon.blue { background: var(--accent-light); color: var(--accent); }
.stat-stack-icon.green { background: var(--success-bg); color: var(--success); }
.stat-stack-icon.orange { background: var(--warning-bg); color: var(--warning); }
.donut-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}
.donut-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}
.donut-wrap { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 140px; }
.donut-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 12px;
  font-size: 11px;
  color: var(--text-secondary);
}
.donut-legend-item { display: flex; align-items: center; gap: 5px; }
.donut-legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dashboard-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

/* ── Transactions explorer ─────────────────────────────────── */
.tx-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.tx-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: var(--radius-full, 9999px);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  text-decoration: none;
  transition: all var(--transition);
}
.filter-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light, rgba(37, 99, 235, 0.06));
}
.filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.filter-card-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px 16px;
  background: none;
  border: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
}
.filter-panel.collapsed { display: none; }
.filter-panel { padding: 0 16px 16px; }
.filter-grid .span-2 { grid-column: span 2; }
.link-mono {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}
.link-mono:hover { text-decoration: underline; }
.cell-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.copy-btn-xs { padding: 1px 6px; font-size: 10px; }
.col-actions { width: 44px; text-align: right; }
.tx-summary-card {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.tx-summary-label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.tx-summary-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.tx-summary-value small { font-weight: 500; color: var(--text-muted); }
.timeline-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

/* ── Tenant / Provider health KPIs ───────────────────────────── */
.health-kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.health-kpi-strip-compact {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  max-width: 480px;
}
.health-kpi {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}
.health-kpi-label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.health-kpi-value {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.health-kpi-value-sm { font-size: 13px; font-weight: 600; }
.health-kpi-sub {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}
.section-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.font-medium { font-weight: 500; }

@media (max-width: 1200px) {
  .dash-hero-grid { grid-template-columns: 1fr 1fr; }
  .donut-card { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .dash-hero-grid { grid-template-columns: 1fr; }
  .topbar-menu-btn { display: flex; }
  .topbar-search { flex: 1; max-width: none; }
  .topbar-breadcrumb { display: none; }
}

/* ============================================================
   v2 FOUNDATION — token polish + topbar chrome, metric cards,
   provider health, webhook feed, system status. Appended last
   so these win over earlier equal-specificity rules.
   ============================================================ */

:root {
  /* Softer, more layered page + premium shadows */
  --bg: #f5f7fb;
  --radius-xl: 16px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
  --shadow: 0 4px 16px rgba(16,24,40,.08);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.14);
  /* Brand gradient used by logo + avatars */
  --brand-grad: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
}

/* Deepen the sidebar with a subtle vertical gradient */
.admin-sidebar {
  background: linear-gradient(180deg, #1c2033 0%, #161929 100%);
  border-inline-end: 1px solid rgba(255,255,255,.04);
}

/* ── Sidebar logo tile (PG mark) ───────────────────────────── */
.sidebar-logo-icon.brand-tile {
  background: var(--brand-grad);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: .5px;
  color: #fff;
  box-shadow: 0 2px 8px rgba(59,130,246,.35);
}

/* ── Topbar search (wider, centered feel) ──────────────────── */
.admin-topbar { height: 64px; padding: 0 24px; gap: 16px; }
.topbar-breadcrumb { flex: 0 1 auto; justify-content: flex-start; }
.topbar-search {
  flex: 1 1 auto;
  max-width: 460px;
  height: 40px;
  border-radius: var(--radius-lg);
}
.topbar-search:focus-within {
  border-color: var(--accent);
  box-shadow: var(--input-focus-ring);
  background: var(--surface);
}

/* ── Topbar icon buttons + notifications ───────────────────── */
.topbar-icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.topbar-icon-btn:hover { background: var(--surface-2); color: var(--text-primary); border-color: var(--border); text-decoration: none; }
.topbar-icon-btn svg { width: 18px; height: 18px; }
.notif-badge {
  position: absolute;
  top: -5px; inset-inline-end: -5px;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  border: 2px solid var(--surface);
}

/* ── Notifications dropdown ─────────────────────────────────── */
.topbar-notif { position: relative; }
.notif-panel {
  position: absolute;
  top: calc(100% + 10px);
  inset-inline-end: 0;
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 80;
  overflow: hidden;
}
.notif-panel[hidden] { display: none; }
.notif-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px; font-weight: 700; color: var(--text-primary);
}
.notif-item {
  display: flex; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  font-size: 12px; color: var(--text-secondary);
  text-decoration: none;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface-2); text-decoration: none; }
.notif-item .notif-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 4px; flex-shrink: 0; }
.notif-item strong { display: block; color: var(--text-primary); font-size: 12px; margin-bottom: 2px; }
.notif-empty { padding: 24px 16px; text-align: center; color: var(--text-muted); font-size: 12px; }
.notif-panel-foot { padding: 10px 16px; text-align: center; border-top: 1px solid var(--border-light); }

/* ── Topbar user chip ──────────────────────────────────────── */
.topbar-user-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 4px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition);
}
.topbar-user-chip:hover { background: var(--surface-2); text-decoration: none; }
.topbar-user-chip .topbar-user-avatar { background: var(--brand-grad); }
.topbar-user-meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.topbar-user-meta .tu-name { font-size: 12px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.topbar-user-meta .tu-role { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }
.topbar-user-chip .tu-chev { color: var(--text-muted); display: flex; }
@media (max-width: 720px) { .topbar-user-meta { display: none; } }

/* ── Env pill with status dot ──────────────────────────────── */
.topbar-env-badge { display: inline-flex; align-items: center; gap: 6px; }
.topbar-env-badge::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 18%, transparent);
}

/* ── Metric cards (KPI row, reference-style) ───────────────── */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 120ms ease, transform 120ms ease, border-color 120ms ease;
  display: block;
  color: inherit;
  text-decoration: none;
}
a.metric-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: var(--accent); text-decoration: none; color: inherit; }
.metric-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.metric-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.metric-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.metric-icon svg { width: 20px; height: 20px; }
.metric-icon.blue   { background: var(--accent-light); color: var(--accent); }
.metric-icon.green  { background: var(--success-bg);  color: var(--success); }
.metric-icon.red    { background: var(--danger-bg);   color: var(--danger); }
.metric-icon.amber  { background: var(--warning-bg);  color: var(--warning); }
.metric-icon.violet { background: #f3f0ff;            color: #7c3aed; }
.metric-icon.cyan   { background: var(--info-bg);     color: var(--info); }
.metric-value { font-size: 28px; font-weight: 700; color: var(--text-primary); line-height: 1; margin-bottom: 8px; }
.metric-value .metric-unit { font-size: 15px; font-weight: 600; color: var(--text-muted); }
.metric-foot { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.metric-trend { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; }
.metric-trend.up { color: var(--success); }
.metric-trend.down { color: var(--danger); }
.metric-trend.flat { color: var(--text-muted); }

/* ── Provider status / performance rows ────────────────────── */
.provider-list { display: flex; flex-direction: column; }
.provider-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border-light);
}
.provider-row:last-child { border-bottom: none; }
.provider-logo {
  width: 36px; height: 36px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: var(--text-secondary);
  flex-shrink: 0;
}
.provider-meta { flex: 1; min-width: 0; }
.provider-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.provider-code { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }

/* ── Webhook / callback log feed ───────────────────────────── */
.log-feed { display: flex; flex-direction: column; }
.log-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--border-light);
  text-decoration: none;
}
.log-row:last-child { border-bottom: none; }
.log-row:hover { background: var(--surface-2); text-decoration: none; }
.log-method {
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 4px;
  background: var(--accent-light); color: var(--accent);
  flex-shrink: 0;
}
.log-path { flex: 1; min-width: 0; font-family: var(--font-mono); font-size: 12px; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-status { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; flex-shrink: 0; }
.log-status.ok { background: var(--success-bg); color: var(--success); }
.log-status.err { background: var(--danger-bg); color: var(--danger); }
.log-time { font-size: 11px; color: var(--text-muted); flex-shrink: 0; white-space: nowrap; }

/* ── Sidebar System Status card ────────────────────────────── */
.sys-status {
  flex-shrink: 0;
  margin: 4px 12px 12px;
  padding: 14px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: var(--radius);
}
.sys-status-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.sys-status-head .sys-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.2); }
.sys-status-title { font-size: 11px; font-weight: 700; color: #e2e8f0; text-transform: uppercase; letter-spacing: .5px; }
.sys-status-state { font-size: 13px; font-weight: 600; color: #4ade80; margin-bottom: 10px; }
.sys-status-row { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: var(--sidebar-text); padding: 2px 0; }
.sys-status-row strong { color: #cbd5e1; font-weight: 600; }

/* ── Donut (conic-gradient, real percentages) ──────────────── */
.donut {
  width: 150px; height: 150px; border-radius: 50%;
  position: relative;
  flex-shrink: 0;
}
.donut::after {
  content: "";
  position: absolute; inset: 22px;
  background: var(--surface);
  border-radius: 50%;
}
.donut-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 1;
}
.donut-center .dc-value { font-size: 22px; font-weight: 700; color: var(--text-primary); line-height: 1; }
.donut-center .dc-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-top: 2px; }

/* ── Panel grid for dashboard lower section ────────────────── */
.panel-grid-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .panel-grid-3 { grid-template-columns: 1fr; } }

/* ── Outline buttons (were referenced but undefined) ───────── */
.btn-outline,
.btn-outline-secondary {
  background: var(--surface);
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-outline:hover:not(:disabled),
.btn-outline-secondary:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text-primary);
  border-color: var(--accent);
  text-decoration: none;
}
.btn-outline-primary {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--accent);
}
.btn-outline-primary:hover:not(:disabled) {
  background: var(--accent-light);
  color: var(--accent-hover);
  border-color: var(--accent-hover);
  text-decoration: none;
}
.btn-outline-danger {
  background: var(--surface);
  color: var(--danger);
  border-color: var(--danger-border);
}
.btn-outline-danger:hover:not(:disabled) {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger);
  text-decoration: none;
}

/* Feather icons inherit text sizing/alignment */
[data-feather] { width: 1em; height: 1em; vertical-align: -0.125em; }
.icon-xs[data-feather] { width: 14px; height: 14px; }
.icon-sm[data-feather] { width: 16px; height: 16px; }

/* ── Aliases for classes referenced in markup but never defined ── */
.form-help { font-size: 11px; color: var(--hint-color); line-height: 1.45; display: block; margin-top: var(--sp-1); }
.form-container { width: 100%; }
.tx-summary-metric { display: flex; flex-direction: column; gap: 2px; }
.page-back-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-muted); font-size: 12px; text-decoration: none;
  margin-bottom: var(--sp-2); transition: color var(--transition);
}
.page-back-link:hover { color: var(--text-primary); text-decoration: none; }

/* ============================================================
   v3 — professional typography, unified filters, live system
   health. Appended last to win over earlier rules.
   ============================================================ */

:root {
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', 'Consolas', monospace;
}
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv11', 'ss01';
  letter-spacing: -0.005em;
}

/* ── Unified filter system ─────────────────────────────────── */
.filter-bar,
.filter-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

/* Inline (label-less) filter row — aligned, actions pushed to the end */
.filter-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}
.filter-form > .form-control,
.filter-form > .form-input,
.filter-form > select {
  flex: 1 1 190px;
  min-width: 160px;
  max-width: 280px;
}
.filter-form > button[type="submit"] { margin-inline-start: auto; }

/* Grid filters — label+control cells in a tidy responsive grid */
.filter-grid,
.filter-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px 16px;
  align-items: end;
}
.filter-grid .form-group,
.filter-form-grid .form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 0;
  min-width: 0;
}
.filter-grid .span-2,
.filter-form-grid .span-2,
.filter-grid .col-span-2 { grid-column: span 2; }
@media (max-width: 560px) {
  .filter-grid .span-2,
  .filter-form-grid .span-2 { grid-column: span 1; }
}
.filter-grid .form-label,
.filter-form-grid .form-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
}

/* Consistent control sizing across all filters */
.filter-form .form-control,
.filter-grid .form-control,
.filter-form-grid .form-control,
.filter-bar .form-control,
.filter-form .form-input,
.filter-grid .form-input,
.filter-form-grid .form-input {
  height: 40px;
  border-radius: var(--radius);
  background: var(--surface);
}
.filter-form textarea.form-control,
.filter-grid textarea.form-control { height: auto; }

/* Actions — own row in grids, right-aligned; inline row otherwise */
.filter-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.filter-grid .filter-actions,
.filter-form-grid .filter-actions {
  grid-column: 1 / -1;
  flex-direction: row;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
}
.filter-grid .form-group.filter-actions,
.filter-form-grid .form-group.filter-actions { flex-direction: row; }
.filter-actions { flex-wrap: wrap; }
.filter-actions .checkbox-group,
.filter-actions > .checkbox-label { margin-inline-end: auto; }

/* Collapsible advanced-filter header */
.filter-card-toggle { border-radius: var(--radius-lg); }
.filter-card-toggle .filter-toggle-icon { transition: transform 160ms ease; }
.filter-card-toggle[aria-expanded="false"] .filter-toggle-icon { transform: rotate(-90deg); }

/* ── Live system-health overview (dashboard) ───────────────── */
.sys-health {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 24px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.sys-health-status {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-inline-end: 24px;
  border-inline-end: 1px solid var(--border-light);
}
.sys-health-ring {
  width: 52px; height: 52px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sys-health-ring svg { width: 26px; height: 26px; }
.sys-health-ring.ok   { background: var(--success-bg); color: var(--success); }
.sys-health-ring.warn { background: var(--warning-bg); color: var(--warning); }
.sys-health-ring.crit { background: var(--danger-bg);  color: var(--danger); }
.sys-health-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 2px; }
.sys-health-state { font-size: 18px; font-weight: 700; color: var(--text-primary); line-height: 1.15; }
.sys-health-vitals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}
.vital-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 4px; }
.vital-value { font-size: 20px; font-weight: 700; color: var(--text-primary); line-height: 1; }
.vital-value small { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.vital-value.ok { color: var(--success); }
.vital-value.warn { color: var(--warning); }
.vital-value.crit { color: var(--danger); }
@media (max-width: 760px) {
  .sys-health { grid-template-columns: 1fr; gap: 16px; }
  .sys-health-status { padding-inline-end: 0; border-inline-end: none; padding-bottom: 16px; border-bottom: 1px solid var(--border-light); }
}

/* ── Sidebar status: dynamic dot states ────────────────────── */
.sys-status .sys-dot.warn { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,.2); }
.sys-status .sys-dot.crit { background: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,.2); }
.sys-status-state.warn { color: #fbbf24; }
.sys-status-state.crit { color: #f87171; }

/* ============================================================
   v4 — MICROSOFT FLUENT 2 SKIN
   Re-themes tokens + components to the Fluent design language
   (Azure Portal / M365 admin). Appended last so it wins.
   ============================================================ */

:root {
  /* Typography — Segoe UI Variable (native on Windows) */
  --font-sans: 'Segoe UI Variable Text', 'Segoe UI Variable', 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', sans-serif;

  /* Brand / communication blue ramp */
  --accent: #0078d4;
  --accent-hover: #106ebe;
  --accent-pressed: #005a9e;
  --accent-light: #eff6fc;
  --accent-selected: #deecf9;

  /* Neutral surfaces (Fluent) */
  --bg: #faf9f8;
  --surface: #ffffff;
  --surface-2: #faf9f8;
  --surface-raised: #f3f2f1;
  --surface-sunken: #f3f2f1;
  --border: #e1dfdd;
  --border-light: #edebe9;

  /* Text (Fluent neutral foregrounds) */
  --text-primary: #242424;
  --text-secondary: #424242;
  --text-muted: #707070;

  /* Semantic (Fluent) */
  --success: #0e700e; --success-bg: #f1faf1; --success-border: #9fd89f;
  --warning: #835c00; --warning-bg: #fff9f0; --warning-border: #fde29a;
  --danger:  #b10e1c; --danger-bg:  #fdf3f4; --danger-border: #f1bbc0;
  --info:    #0078d4; --info-bg:    #eff6fc; --info-border:   #b4d6fa;
  --neutral: #424242; --neutral-bg: #f3f2f1;

  /* Radius — Fluent: 4px controls, 8px cards */
  --radius-sm: 2px;
  --radius: 4px;
  --radius-lg: 8px;
  --radius-xl: 12px;

  /* Elevation — Fluent depth */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.10), 0 0 1px rgba(0,0,0,.12);
  --shadow:    0 4px 8px rgba(0,0,0,.10), 0 0 2px rgba(0,0,0,.12);
  --shadow-lg: 0 8px 16px rgba(0,0,0,.12), 0 0 2px rgba(0,0,0,.12);

  /* Focus + input */
  --input-focus-ring: 0 0 0 1px var(--accent);
  --brand-grad: linear-gradient(135deg, #0078d4 0%, #2b88d8 100%);
  --transition: 120ms cubic-bezier(.33,0,.67,1);
}

body { letter-spacing: 0; }

/* ── Fluent focus stroke (keyboard) ────────────────────────── */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-radius: 2px;
}

/* ── Buttons (Fluent) ──────────────────────────────────────── */
.btn { border-radius: var(--radius); font-weight: 600; font-size: 14px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-primary:active:not(:disabled) { background: var(--accent-pressed); border-color: var(--accent-pressed); }
.btn-secondary { background: #fff; border-color: #d1d1d1; color: var(--text-primary); }
.btn-secondary:hover:not(:disabled) { background: #f5f5f5; border-color: #c7c7c7; color: var(--text-primary); }
.btn-secondary:active:not(:disabled) { background: #ededed; }
.btn-ghost { background: transparent; color: var(--text-primary); }
.btn-ghost:hover:not(:disabled) { background: #f5f5f5; color: var(--text-primary); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #9a0c18; border-color: #9a0c18; color: #fff; }

/* ── Inputs (Fluent: subtle border + accent bottom stroke on focus) ── */
.form-input, .form-select, .form-control, .form-textarea {
  border-radius: var(--radius);
  border-color: #d1d1d1;
  background: #fff;
}
.form-input:focus, .form-select:focus, .form-control:focus, .form-textarea:focus,
.filter-form .form-control:focus, .filter-grid .form-control:focus, .filter-form-grid .form-control:focus {
  border-color: var(--accent);
  box-shadow: inset 0 -1px 0 0 var(--accent);
  outline: none;
}

/* ── Cards / surfaces ──────────────────────────────────────── */
.card, .metric-card, .donut-card, .sys-health, .filter-card, .filter-bar,
.kpi-card, .section-card, .form-card, .tx-summary-card { border-radius: var(--radius-lg); }
.card { box-shadow: var(--shadow-sm); }

/* ── Topbar (Fluent command surface) ───────────────────────── */
.admin-topbar { box-shadow: 0 1px 2px rgba(0,0,0,.08); border-bottom: 1px solid var(--border); }
.topbar-icon-btn, .topbar-user-chip, .topbar-search { border-radius: var(--radius); }

/* ── Sidebar (Fluent neutral-dark nav, blue selection) ─────── */
.admin-sidebar { background: #1b1a19; border-inline-end: 1px solid rgba(255,255,255,.06); }
.sidebar-logo-icon.brand-tile { background: var(--brand-grad); box-shadow: none; border-radius: var(--radius); }
.sidebar-link.active {
  background: rgba(0,120,212,.18);
  color: #ffffff;
  border-inline-start: 3px solid var(--accent);
}
.sidebar-link.active .nav-icon { color: #4cb0ff; opacity: 1; }
.sidebar-link:hover { background: rgba(255,255,255,.06); }

/* ── Tabs → Fluent Pivot ───────────────────────────────────── */
.tab, .tab-btn { font-weight: 600; color: var(--text-secondary); }
.tab.active, .tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab:hover, .tab-btn:hover { color: var(--text-primary); }

/* ── Alerts → Fluent MessageBar ────────────────────────────── */
.alert { border-radius: var(--radius); border-width: 1px; border-inline-start-width: 3px; align-items: center; }
.alert-success { border-inline-start-color: var(--success); }
.alert-warning { border-inline-start-color: var(--warning); }
.alert-danger  { border-inline-start-color: var(--danger); }
.alert-info    { border-inline-start-color: var(--info); }

/* ── Badges (Fluent subtle) ────────────────────────────────── */
.badge { border-radius: var(--radius); font-weight: 600; }

/* ── Command bar (Fluent) ──────────────────────────────────── */
.command-bar {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  padding: 6px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.command-bar .cb-group { display: flex; align-items: center; gap: 2px; }
.command-bar .cb-spacer { margin-inline-start: auto; }
.command-bar .cb-divider { width: 1px; height: 20px; background: var(--border); margin: 0 6px; }
.command-bar .btn-ghost { height: 34px; border-radius: var(--radius); color: var(--text-primary); font-weight: 400; }

/* ── Sortable table headers ────────────────────────────────── */
.admin-table th[data-sort] { cursor: pointer; user-select: none; }
.admin-table th[data-sort]:hover { color: var(--text-primary); background: var(--surface-raised); }
.admin-table th[data-sort] .sort-ind { opacity: .45; margin-inline-start: 4px; font-size: 10px; }
.admin-table th[aria-sort="ascending"] .sort-ind,
.admin-table th[aria-sort="descending"] .sort-ind { opacity: 1; color: var(--accent); }

/* ── Density: compact mode ─────────────────────────────────── */
body.density-compact .admin-table th { padding-top: 6px; padding-bottom: 6px; }
body.density-compact .admin-table td { padding-top: 6px; padding-bottom: 6px; }
body.density-compact .card-body { padding: 14px 16px; }
body.density-compact .metric-card { padding: 12px 14px; }
body.density-compact .metric-value { font-size: 24px; }
body.density-compact .filter-card, body.density-compact .filter-bar { padding: 12px 14px; }
body.density-compact .btn { height: 28px; }
body.density-compact .form-control,
body.density-compact .filter-form .form-control,
body.density-compact .filter-grid .form-control,
body.density-compact .filter-form-grid .form-control { height: 32px; }

/* ── Flyout panel (Fluent Panel) ───────────────────────────── */
.flyout-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 300; opacity: 0; transition: opacity 160ms ease; }
.flyout-overlay.open { opacity: 1; }
.flyout {
  position: fixed; top: 0; bottom: 0; inset-inline-end: 0;
  width: 480px; max-width: 92vw;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 200ms cubic-bezier(.1,.9,.2,1);
  z-index: 301;
}
html[dir="rtl"] .flyout { transform: translateX(-100%); }
.flyout.open { transform: translateX(0); }
.flyout-header { display: flex; align-items: center; gap: 12px; padding: 18px 24px 14px; border-bottom: 1px solid var(--border-light); }
.flyout-title { font-size: 18px; font-weight: 600; flex: 1; color: var(--text-primary); }
.flyout-close { width: 32px; height: 32px; border: none; background: transparent; border-radius: var(--radius); cursor: pointer; color: var(--text-secondary); font-size: 18px; display: flex; align-items: center; justify-content: center; }
.flyout-close:hover { background: #f5f5f5; color: var(--text-primary); }
.flyout-body { flex: 1; overflow-y: auto; padding: 20px 24px; }
.flyout-footer { padding: 14px 24px; border-top: 1px solid var(--border-light); display: flex; gap: 8px; justify-content: flex-end; }

/* ── Server-side sortable column headers (links) ───────────── */
.admin-table th a.th-sort {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
}
.admin-table th a.th-sort:hover { color: var(--accent); text-decoration: none; }
.admin-table th[aria-sort="ascending"] a.th-sort,
.admin-table th[aria-sort="descending"] a.th-sort { color: var(--accent); }
.admin-table th[aria-sort="ascending"] .sort-ind,
.admin-table th[aria-sort="descending"] .sort-ind { color: var(--accent); opacity: 1; }
.admin-table th a.th-sort .sort-ind { opacity: .45; font-size: 10px; }

/* ── Row action menu: ensure it floats above table/sticky headers ── */
.action-menu-panel { z-index: 200; }
/* JS upgrades the open panel to position:fixed (z-index 1000) so it escapes
   the .table-wrapper overflow clip; this is the no-JS fallback. */
