:root {
  --bg: #f6f8fc;
  --panel: #fff;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --border: #e2e8f0;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); }
.admin-shell { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
.sidebar { background: #0f172a; color: #cbd5e1; padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; transition: width .2s ease; }
.sidebar-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.admin-brand { color: #fff; text-decoration: none; font-weight: 800; font-size: 20px; }
.admin-brand span { color: #60a5fa; }
.sidebar-toggle { border: 1px solid rgba(255,255,255,.2); background: transparent; color: #fff; border-radius: 8px; padding: 5px 8px; cursor: pointer; }
.sidebar-nav { display: grid; gap: 10px; }
.nav-item, .nav-sub-item { color: #cbd5e1; text-decoration: none; display: block; border-radius: 10px; padding: 9px 10px; font-size: 13px; }
.nav-item:hover, .nav-sub-item:hover { background: rgba(148,163,184,.18); color: #fff; }
.nav-group { border-top: 1px solid rgba(148,163,184,.18); padding-top: 10px; display: grid; gap: 4px; }
.nav-group span { text-transform: uppercase; font-size: 10px; letter-spacing: .6px; color: #94a3b8; padding: 2px 10px; }

/* details/summary collapsible nav groups */
.nav-group-details { border-top: 1px solid rgba(148,163,184,.18); padding-top: 8px; }
.nav-group-details + .nav-group-details { margin-top: 4px; }
.nav-group-summary {
  list-style: none;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: .7px;
  color: #94a3b8;
  padding: 4px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  border-radius: 6px;
}
.nav-group-summary::-webkit-details-marker { display: none; }
.nav-group-summary::after { content: "▾"; font-size: 11px; transition: transform .2s; }
.nav-group-details:not([open]) .nav-group-summary::after { transform: rotate(-90deg); }
.nav-group-summary:hover { color: #cbd5e1; background: rgba(148,163,184,.1); }
.nav-group-details > .nav-sub-item { margin-top: 2px; }

/* sidebar collapsed state */
.sidebar.collapsed .nav-group-summary { justify-content: center; }
.sidebar.collapsed .nav-group-summary::after { display: none; }
.sidebar.collapsed .nav-sub-item span, .sidebar.collapsed .nav-item span { display: none; }

/* Auth page styles */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px 16px;
}
.auth-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 12px 40px rgba(15,23,42,.08);
}
.auth-logo { margin-bottom: 20px; }
.brand { font-size: 22px; font-weight: 800; color: var(--text); }
.brand span { color: var(--primary); }
.auth-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.auth-subtitle { font-size: 13px; color: var(--muted); margin-bottom: 20px; }
.alert {
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 14px;
  line-height: 1.5;
}
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.alert a { color: inherit; font-weight: 600; }
.main-panel { display: grid; grid-template-rows: auto 1fr; }
.top-header { background: #fff; border-bottom: 1px solid var(--border); padding: 14px 20px; display: flex; justify-content: space-between; gap: 12px; position: sticky; top: 0; z-index: 20; }
.top-search { width: min(560px, 100%); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.top-actions { display:flex; align-items: center; gap: 10px; }
.top-user { font-size: 13px; color: var(--muted); }
.admin-logout { text-decoration: none; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; color: var(--text); font-size: 13px; }
.content { padding: 22px; display: grid; gap: 16px; }
.bypass-banner { background: #fef3c7; color: #92400e; padding: 8px 20px; font-size: 13px; text-align: center; border-bottom: 1px solid #fcd34d; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: 0 8px 24px rgba(15,23,42,.04); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-title { font-size: 16px; font-weight: 700; }
.card-subtitle { font-size: 13px; color: var(--muted); margin-top: 2px; }

.metrics-grid { display:grid; grid-template-columns: repeat(auto-fit,minmax(180px,1fr)); gap:12px; }
.metric { border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.metric-label { font-size: 11px; text-transform: uppercase; color: var(--muted); }
.metric-value { font-size: 24px; font-weight: 800; margin-top: 4px; }
.metric-value.green { color: var(--success); }
.metric-value.blue { color: var(--primary); }
.metric-value.amber { color: var(--warning); }

.form-grid { display:grid; gap: 12px; }
.form-row { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.form-group { display:grid; gap:6px; }
label { font-size: 13px; font-weight: 600; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }

.btn { display:inline-flex; text-decoration: none; border: none; border-radius: 10px; font-weight: 600; font-size: 13px; cursor: pointer; padding: 9px 12px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-ghost { border: 1px solid var(--border); color: var(--text); background: #fff; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

.badge { display:inline-block; border-radius: 999px; padding: 3px 8px; font-size: 11px; font-weight: 700; }
.badge-active { background: #dcfce7; color: #166534; }
.badge-inactive { background: #fee2e2; color: #991b1b; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-failed { background: #fee2e2; color: #991b1b; }
.badge-live { background: #dbeafe; color: #1e40af; }
.badge-sandbox { background: #fef3c7; color: #92400e; }
.badge-mno { background: #e0e7ff; color: #3730a3; }
.badge-bank { background: #dcfce7; color: #166534; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px; border-bottom: 1px solid var(--border); font-size: 13px; text-align: left; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; }

.switch { position: relative; display: inline-block; width: 48px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; border-radius: 999px; background: #cbd5e1; transition: .2s; }
.slider:before { content: ""; position: absolute; height: 20px; width: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--success); }
.switch input[data-state="maintenance"]:checked + .slider { background: var(--warning); }
.switch input[data-state="disabled"] + .slider { background: var(--danger); }
.switch input:checked + .slider:before { transform: translateX(22px); }

.quick-actions { display: flex; flex-wrap: wrap; gap: 10px; }

@media (max-width: 960px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .form-row { grid-template-columns: 1fr; }
}

/* ── Modern Sidebar with Icons ── */
.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.75;
  transition: opacity .15s;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #94a3b8;
  text-decoration: none;
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
}
.nav-item:hover { background: rgba(148,163,184,.12); color: #e2e8f0; }
.nav-item:hover .nav-icon { opacity: 1; }
.nav-item.active {
  background: rgba(96,165,250,.15);
  color: #60a5fa;
  font-weight: 600;
}
.nav-item.active .nav-icon { opacity: 1; }

.nav-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: #475569;
  padding: 12px 10px 4px;
  margin-top: 4px;
}

/* Sidebar collapsed: hide labels */
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-section-label { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }
.sidebar.collapsed .nav-icon { opacity: 0.9; }

/* Trace timeline */
.trace-timeline { display: grid; gap: 4px; }
.trace-row {
  display: grid;
  grid-template-columns: 160px 80px 110px 1fr;
  gap: 8px;
  align-items: start;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: #fafafa;
}
.trace-row.status-OK { border-left: 3px solid var(--success); }
.trace-row.status-ERROR { border-left: 3px solid var(--danger); background: #fff5f5; }
.trace-row.status-INFO { border-left: 3px solid var(--primary); }
.trace-stage { font-weight: 600; font-size: 11px; color: var(--text); }
.trace-ts { color: var(--muted); font-size: 11px; }
.trace-msg { color: #374151; }

/* Exchange log */
.exchange-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  margin-bottom: 6px;
}
.exchange-row .ex-head {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.exchange-row pre {
  background: #f1f5f9;
  border-radius: 6px;
  padding: 8px;
  font-size: 11px;
  overflow: auto;
  max-height: 200px;
  margin-top: 6px;
}

/* Callback detail */
.cb-section { margin-top: 16px; }
.cb-section h4 { font-size: 13px; font-weight: 700; margin-bottom: 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }

/* Provider logo in admin */
.provider-logo-cell { display: flex; align-items: center; gap: 10px; }
.provider-logo-thumb { width: 32px; height: 32px; object-fit: contain; border-radius: 6px; background: #f1f5f9; padding: 3px; border: 1px solid var(--border); }
.provider-logo-fallback { width: 32px; height: 32px; border-radius: 6px; background: #e2e8f0; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; color: #64748b; }

/* Environment badge */
.badge-live { background: #dbeafe; color: #1e40af; }
.badge-sandbox { background: #fef9c3; color: #854d0e; }

/* --- 2026 admin shell refresh --- */
.top-header { align-items: center; }
.topbar-left { display: flex; align-items: center; gap: 12px; }
.mobile-menu-btn {
  display: none;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 7px 9px;
  color: #0f172a;
}
.page-title { font-size: 16px; font-weight: 700; margin: 0; }
.page-subtitle { font-size: 12px; color: var(--muted); margin-top: 2px; }
.admin-logout { background: #fff; }

.sidebar { width: 280px; min-width: 280px; transition: width .2s ease, transform .2s ease; }
.sidebar-nav { display: grid; gap: 8px; }
.nav-module { border-top: 1px solid rgba(148,163,184,.18); padding-top: 8px; }
.nav-module-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: #94a3b8;
  font-weight: 600;
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
}
.nav-module-summary::-webkit-details-marker { display: none; }
.nav-module-summary:hover { background: rgba(148,163,184,.12); color: #e2e8f0; }
.module-title-wrap { display: inline-flex; align-items: center; gap: 8px; }
.module-label { letter-spacing: .2px; }
.nav-module .chevron { font-size: 12px; transition: transform .2s ease; }
.nav-module:not([open]) .chevron { transform: rotate(-90deg); }
.nav-module-items { margin-top: 4px; display: grid; gap: 3px; }
.nav-module .nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  border-radius: 10px;
  color: #cbd5e1;
  padding: 9px 10px 9px 28px;
}
.nav-module .nav-item.active { color: #dbeafe; background: rgba(37,99,235,.35); }
.nav-module .nav-item:hover { color: #fff; background: rgba(96,165,250,.22); }

.sidebar.collapsed { width: 90px; min-width: 90px; }
.sidebar.collapsed .module-label,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .chevron,
.sidebar.collapsed .admin-brand span { display: none; }
.sidebar.collapsed .admin-brand { font-size: 18px; }
.sidebar.collapsed .nav-module-summary,
.sidebar.collapsed .nav-module .nav-item { justify-content: center; padding-left: 10px; }
.sidebar.collapsed .nav-module .nav-item::after {
  content: attr(data-label);
  position: absolute;
  left: 74px;
  background: #0f172a;
  color: #fff;
  border: 1px solid rgba(148,163,184,.3);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  transform: translateX(-6px);
  pointer-events: none;
  transition: .15s ease;
}
.sidebar.collapsed .nav-module .nav-item { position: relative; }
.sidebar.collapsed .nav-module .nav-item:hover::after { opacity: 1; transform: translateX(0); }

/* Client apps UX */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.page-header h2 { font-size: 22px; margin-bottom: 4px; }
.page-header p { color: var(--muted); font-size: 13px; max-width: 720px; }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.summary-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.summary-card .label { color: var(--muted); font-size: 12px; }
.summary-card .value { font-size: 24px; font-weight: 700; margin-top: 6px; }
.filter-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.search-input { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; min-width: 280px; }
.status-pill { font-size: 11px; border-radius: 999px; padding: 3px 8px; font-weight: 700; }
.status-on { background: #dcfce7; color: #166534; }
.status-off { background: #fee2e2; color: #991b1b; }
.inline-form-card { border: 1px dashed #cbd5e1; border-radius: 12px; padding: 16px; background: #f8fafc; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.form-grid .full { grid-column: 1/-1; }
.field-label { display:block; margin-bottom: 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.input, textarea.input, select.input { width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 9px 10px; font-size: 14px; }
.inline-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.copyable {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 12px;
}
.toast { margin-top: 10px; font-size: 13px; }
.toast.ok { color: #166534; }
.toast.err { color: #991b1b; }
.side-note { background: #f8fafc; border: 1px solid var(--border); border-radius: 12px; padding: 14px; font-size: 13px; color: #334155; }

@media (max-width: 960px) {
  .mobile-menu-btn { display: inline-flex; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 40;
    transform: translateX(-100%);
    height: 100vh;
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .admin-shell { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .search-input { min-width: 100%; }
}

/* --- 2026 Q1 navigation and client apps overhaul --- */
.admin-shell { transition: grid-template-columns .22s ease; }
.main-panel { min-width: 0; }
.sidebar { padding: 16px 10px; border-right: 1px solid rgba(148,163,184,.18); }
.sidebar-head { margin-bottom: 14px; padding: 0 6px; }
.admin-brand { display: inline-flex; align-items: center; gap: 4px; }
.sidebar-toggle { display: inline-flex; align-items: center; justify-content: center; }

.sidebar-nav { gap: 10px; }
.nav-module { border-top: 1px solid rgba(148,163,184,.2); padding-top: 10px; }
.nav-module:first-child { border-top: 0; padding-top: 0; }
.nav-module-summary { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }
.nav-module .nav-item { font-size: 13px; font-weight: 500; padding-block: 10px; }
.nav-icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  opacity: .9;
}
.nav-module .nav-item.active {
  border: 1px solid rgba(147,197,253,.45);
  box-shadow: inset 0 0 0 1px rgba(30,64,175,.14);
}

.sidebar.collapsed .nav-module { padding-top: 8px; }
.sidebar.collapsed .nav-module-summary { padding-inline: 8px; }
.sidebar.collapsed .module-title-wrap { justify-content: center; width: 100%; }
.sidebar.collapsed .nav-module .nav-item { padding: 10px 8px; }
.sidebar.collapsed .nav-module .nav-item::after {
  left: 68px;
  z-index: 45;
  box-shadow: 0 8px 20px rgba(2,6,23,.4);
}

.top-header { padding: 12px 20px; backdrop-filter: blur(10px); }
.breadcrumbs {
  display: flex;
  gap: 6px;
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 2px;
  min-height: 16px;
}
.breadcrumbs .sep { color: #cbd5e1; }
.page-title { font-size: 18px; letter-spacing: -.01em; }
.page-subtitle { font-size: 12px; }
.top-user { font-weight: 600; color: #475569; }
.admin-logout { border-radius: 999px; padding: 8px 14px; font-weight: 600; }

.content { gap: 18px; }
.page-header.card { padding: 18px; }
.page-header h2 { margin: 0 0 6px; }

.client-apps-table td { vertical-align: middle; }
.client-apps-table .app-identity { display: grid; gap: 2px; }
.subtle-text { color: var(--muted); font-size: 12px; }
.status-row { display: flex; flex-wrap: wrap; gap: 6px; }

.badge-soft {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
  background: #e2e8f0;
  color: #334155;
}
.badge-soft.good { background: #dcfce7; color: #166534; }
.badge-soft.warn { background: #fef3c7; color: #92400e; }
.badge-soft.off { background: #fee2e2; color: #991b1b; }

.event-chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.event-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
}
.event-chip input { width: auto; }

.section-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: grid;
  gap: 12px;
}
.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.helper-text { color: var(--muted); font-size: 12px; }
.copyable.reveal { background: #eff6ff; border-color: #bfdbfe; color: #1e3a8a; }
.hidden { display: none !important; }

.feedback-banner {
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 500;
}
.feedback-banner.ok { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.feedback-banner.err { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

@media (max-width: 960px) {
  .top-actions { margin-left: auto; }
  .sidebar.collapsed { width: 280px; min-width: 280px; }
  .breadcrumbs { display: none; }
}
