/* ─────────────────────────────────────────────────────────
   AuraSync Control Plane — Design System
   ───────────────────────────────────────────────────────── */

:root {
  --sidebar-width: 260px;
  --topbar-height: 60px;

  /* Surfaces */
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-muted: #f1f5f9;

  /* Primary */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-muted: #dbeafe;

  /* Sidebar */
  --sidebar-bg: #0f172a;
  --sidebar-border: rgba(255,255,255,0.06);
  --sidebar-text: rgba(255,255,255,0.55);
  --sidebar-text-hover: rgba(255,255,255,0.92);
  --sidebar-active-bg: rgba(15,108,189,0.2);

  /* Neutrals */
  --border: #dbe3ee;
  --border-muted: #e8eef6;
  --text-1: #020817;
  --text-2: #334155;
  --text-3: #64748b;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(15,23,42,0.04);
  --shadow-sm: 0 1px 4px rgba(15,23,42,0.06);
  --shadow-md: 0 8px 24px rgba(15,23,42,0.09);

  /* Radii */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
}

[data-theme="dark"] {
  --bg: #020617;
  --surface: #0b1220;
  --surface-muted: #121a2e;
  --primary: #60a5fa;
  --primary-hover: #3b82f6;
  --primary-muted: #13233f;
  --border: #223252;
  --border-muted: #18243d;
  --text-1: #e2e8f0;
  --text-2: #cbd5e1;
  --text-3: #94a3b8;
  --shadow-xs: 0 1px 2px rgba(2,6,23,0.5);
  --shadow-sm: 0 1px 4px rgba(2,6,23,0.6);
  --shadow-md: 0 20px 42px rgba(2,6,23,0.72);
  --bs-body-bg: #020617;
  --bs-body-color: #e2e8f0;
  --bs-emphasis-color: #f8fafc;
  --bs-secondary-color: #cbd5e1;
  --bs-border-color: #223252;
  --bs-card-bg: #0b1220;
  --bs-card-color: #e2e8f0;
  --bs-table-bg: transparent;
  --bs-table-color: #e2e8f0;
  --bs-tertiary-bg: #121a2e;
}

/* ── Base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  background:
    radial-gradient(circle at top right, rgba(15,108,189,0.05), transparent 30%),
    radial-gradient(circle at 0% 100%, rgba(14,116,144,0.04), transparent 24%),
    var(--bg);
  font-family: 'Manrope', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 0.92rem;
  color: var(--text-1);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary); }

/* ── Bootstrap color overrides ─────────────────────────── */
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  font-weight: 600;
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #ffffff;
  box-shadow: 0 0 0 3px rgba(15,108,189,0.16);
}
.btn-outline-primary { color: var(--primary); border-color: var(--primary); font-weight: 500; }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); }
.btn-outline-secondary {
  color: var(--text-2);
  border-color: var(--border);
  background: var(--surface-muted);
  font-weight: 500;
}
.btn-outline-secondary:hover { background: #eef2f7; border-color: #cbd5e1; color: var(--text-1); }
.btn-outline-info { color: #0891b2; border-color: #a5f3fc; background: #f0fdfe; font-weight: 500; }
.btn-outline-info:hover { background: #cffafe; border-color: #67e8f9; color: #0e7490; }
.btn-outline-success { color: #15803d; border-color: #bbf7d0; background: #f0fdf4; font-weight: 500; }
.btn-outline-success:hover { background: #dcfce7; border-color: #86efac; color: #166534; }
.btn-outline-danger { color: #dc2626; border-color: #fecaca; background: #fff5f5; font-weight: 500; }
.btn-outline-danger:hover { background: #fee2e2; border-color: #fca5a5; color: #b91c1c; }

.btn {
  font-size: 0.82rem;
  border-radius: 10px;
  border-width: 1px;
  padding: 0.5rem 0.9rem;
  transition: all 0.15s;
  box-shadow: 0 1px 2px rgba(15,23,42,0.04);
}
.btn:hover { transform: translateY(-1px); }
.btn-sm { font-size: 0.79rem; padding: 0.36rem 0.78rem; }

/* ── Sidebar ───────────────────────────────────────────── */
#sidebar {
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  z-index: 1030;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

#sidebar::-webkit-scrollbar { width: 3px; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }

/* subtle dot grid overlay */
#sidebar::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
}

.sidebar-brand {
  padding: 1.2rem 1.4rem 1.1rem;
  border-bottom: 1px solid var(--sidebar-border);
  position: relative;
  flex-shrink: 0;
}

.sidebar-brand a {
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
}

.sidebar-brand .brand-logo {
  display: block;
  width: 156px;
  max-width: 100%;
  height: auto;
}

.sidebar-brand .brand-sub {
  font-size: 0.62rem;
  color: rgba(255,255,255,0.28);
  margin-top: 0.25rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 0.5rem 0 1rem;
  position: relative;
}

.nav-section-label {
  display: block;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.2);
  padding: 1rem 1.3rem 0.35rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.48rem 1rem 0.48rem 1.15rem;
  margin: 1px 0.6rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.835rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
  transition: color 0.13s, background 0.13s;
}

.sidebar-link i {
  font-size: 0.9rem;
  width: 15px;
  text-align: center;
  opacity: 0.7;
  flex-shrink: 0;
}

.sidebar-link:hover {
  color: var(--sidebar-text-hover);
  background: rgba(255,255,255,0.05);
}

.sidebar-link.active {
  color: #fff;
  background: var(--sidebar-active-bg);
  border-left-color: var(--primary);
}

.sidebar-link.active i {
  opacity: 1;
  color: #818cf8;
}

/* Settings collapse submenu in the sidebar */
.sidebar-caret {
  margin-left: auto;
  font-size: 0.7rem !important;
  transition: transform 0.15s ease;
}
.sidebar-link[aria-expanded="true"] .sidebar-caret {
  transform: rotate(180deg);
}
.sidebar-sublink {
  padding-left: 2.6rem;
  font-size: 0.8rem;
}
.sidebar-sublink i {
  font-size: 0.8rem;
}

/* Topbar settings gear dropdown */
.topbar-actions .dropdown-toggle.no-caret::after {
  display: none;
}

/* Custom brand wordmark (shown when brand name is customised, no logo URL) */
.brand-wordmark {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
}

/* Settings landing cards */
.settings-card {
  transition: transform 0.13s ease, box-shadow 0.13s ease, border-color 0.13s ease;
  color: inherit;
}
.settings-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.10);
  border-color: var(--primary);
}
.settings-card-icon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  color: var(--primary);
  background: rgba(99, 102, 241, 0.12);
  margin-bottom: 0.75rem;
}

.sidebar-footer {
  padding: 0.85rem 1.4rem;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
  position: relative;
}

.sidebar-footer .version {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.18);
  letter-spacing: 0.04em;
}

/* ── Main content ──────────────────────────────────────── */
#main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Topbar ────────────────────────────────────────────── */
#topbar {
  height: var(--topbar-height);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  padding: 0 1.75rem;
  position: sticky;
  top: 0;
  z-index: 1020;
  gap: 1rem;
}

.topbar-breadcrumb { flex: 1; }

.topbar-actions { display: flex; align-items: center; gap: 0.6rem; }
.theme-toggle { min-width: 2rem; min-height: 2rem; padding: 0.24rem; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  color: var(--text-2);
  font-weight: 500;
}

.topbar-user .user-avatar {
  width: 26px;
  height: 26px;
  background: var(--primary-muted);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 0.7rem;
  font-weight: 700;
}

/* ── Breadcrumb ────────────────────────────────────────── */
.breadcrumb {
  background: transparent;
  padding: 0; margin: 0;
  font-size: 0.78rem;
}

.breadcrumb-item a { color: var(--text-3); text-decoration: none; }
.breadcrumb-item a:hover { color: var(--text-2); }
.breadcrumb-item.active { color: var(--text-2); font-weight: 500; }
.breadcrumb-item + .breadcrumb-item::before { color: var(--text-3); }

/* ── Page content ──────────────────────────────────────── */
.page-content {
  padding: 1.9rem 2.1rem;
  flex: 1;
}

/* ── Page header ───────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.34rem;
  font-weight: 800;
  color: var(--text-1);
  letter-spacing: -0.025em;
  margin: 0;
}

/* ── Cards ─────────────────────────────────────────────── */
.card {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: 0 2px 6px rgba(15,23,42,0.04), 0 18px 30px rgba(15,23,42,0.06) !important;
  background: var(--surface);
}

.card-header {
  background: var(--surface) !important;
  border-bottom: 1px solid var(--border) !important;
  padding: 0.85rem 1.25rem !important;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-1);
}

.card-footer {
  background: #fafbfd !important;
  border-top: 1px solid var(--border) !important;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg) !important;
  padding: 0.7rem 1.25rem !important;
}

/* ── Stat Cards ────────────────────────────────────────── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  padding: 1.2rem 1.35rem;
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  transition: box-shadow 0.15s, transform 0.15s;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
}

.stat-number {
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text-1);
  letter-spacing: -0.04em;
  margin-bottom: 0.2rem;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-3);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.stat-meta {
  margin-top: 0.6rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

/* ── Tables ────────────────────────────────────────────── */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 2px 6px rgba(15,23,42,0.04), 0 14px 24px rgba(15,23,42,0.06);
}

.table-wrap .table-responsive { border-radius: 0; }

/* Reset Bootstrap table */
.table {
  margin: 0;
  border-collapse: collapse;
}

.table > :not(caption) > * > * {
  border-color: transparent;
  box-shadow: none;
}

.table > thead > tr > th {
  background: var(--surface-muted);
  font-size: 0.71rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  border-bottom: 1px solid var(--border) !important;
  border-top: none !important;
  padding: 0.76rem 1.2rem;
  white-space: nowrap;
}

.table > tbody > tr > td {
  padding: 0.92rem 1.2rem;
  vertical-align: middle;
  border-bottom: 1px solid #eef2f7 !important;
  font-size: 0.865rem;
  color: var(--text-1);
}

.table > tbody > tr:last-child > td {
  border-bottom: none !important;
}

.table-hover > tbody > tr { transition: background 0.1s; }
.table-hover > tbody > tr:hover > td { background: #f8fbff; }

/* django-tables2 overrides */
.table > thead > tr > th a { color: var(--text-3); text-decoration: none; font-weight: 600; }
.table > thead > tr > th a:hover { color: var(--text-2); }
.table > thead > tr > th.asc a::after  { content: ' ↑'; font-size: 0.65rem; }
.table > thead > tr > th.desc a::after { content: ' ↓'; font-size: 0.65rem; }

/* Pagination from django-tables2 */
.pagination {
  margin: 0;
  padding: 0.75rem 1.2rem;
  border-top: 1px solid var(--border-muted);
  gap: 0.2rem;
}
.page-link {
  color: var(--text-2);
  border-color: var(--border);
  background: var(--surface-muted);
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm) !important;
}
.page-link:hover { background: var(--bg); color: var(--primary); }
.page-item.active .page-link { background: var(--primary); border-color: var(--primary); }

/* ── Badges ────────────────────────────────────────────── */
.badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.32em 0.68em;
  border-radius: 99px;
  letter-spacing: 0.01em;
}

/* Status */
.badge-status-active       { background: #dcfce7 !important; color: #15803d !important; }
.badge-status-suspended    { background: #fef9c3 !important; color: #a16207 !important; }
.badge-status-deprovisioned{ background: #fee2e2 !important; color: #dc2626 !important; }

/* Source */
.badge-source-plan     { background: #dbeafe !important; color: #2563eb !important; }
.badge-source-override { background: #e0e7ff !important; color: #4f46e5 !important; }

/* Generic overrides */
.badge.bg-secondary { background: #f1f5f9 !important; color: #475569 !important; }
.badge.bg-primary   { background: var(--primary-muted) !important; color: var(--primary) !important; }
.badge.bg-success   { background: #dcfce7 !important; color: #15803d !important; }
.badge.bg-danger    { background: #fee2e2 !important; color: #dc2626 !important; }
.badge.bg-warning   { background: #fef9c3 !important; color: #a16207 !important; }
.badge.bg-info      { background: #cffafe !important; color: #0e7490 !important; }

/* ── Forms ─────────────────────────────────────────────── */
.form-control, .form-select {
  border-color: var(--border);
  border-radius: 10px;
  font-size: 0.87rem;
  color: var(--text-1);
  background-color: #ffffff;
  min-height: 2.62rem;
  padding: 0.56rem 0.82rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15,108,189,0.13);
}
.form-control::placeholder { color: var(--text-3); }
.form-label { font-size: 0.8rem; font-weight: 500; color: var(--text-2); margin-bottom: 0.35rem; }
/* ── Form page layout ──────────────────────────────────── */
.form-page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
  gap: 1rem;
}

.form-page-head .page-subtitle {
  font-size: 0.84rem;
  color: var(--text-3);
  margin: 0.3rem 0 0;
}

.form-page-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 1099px) {
  .form-page-layout {
    grid-template-columns: 240px 1fr;
    gap: 1.5rem;
  }
}

@media (max-width: 767px) {
  .form-page-layout {
    grid-template-columns: 1fr;
  }
}

.form-meta-panel {
  position: sticky;
  top: calc(var(--topbar-height) + 1.5rem);
}

.form-meta-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--primary-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 1.35rem;
  margin-bottom: 1.1rem;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 18%, transparent);
}

.form-meta-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 0.35rem;
}

.form-meta-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 0.55rem;
  letter-spacing: -0.015em;
}

.form-meta-body {
  font-size: 0.825rem;
  color: var(--text-3);
  line-height: 1.7;
  margin-bottom: 1.4rem;
}

.form-tips {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 1rem 1.1rem;
  background: var(--surface-muted);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
}

.form-tip {
  font-size: 0.775rem;
  color: var(--text-3);
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  line-height: 1.55;
}

.form-tip i {
  color: var(--primary);
  font-size: 0.78rem;
  flex-shrink: 0;
  margin-top: 0.15rem;
  opacity: 0.8;
}

.form-tips-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-bottom: 0.5rem;
}

/* Form card styling */
.form-card-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-2);
}

.form-card-header i {
  color: var(--primary);
  font-size: 0.88rem;
}

.form-card-body {
  padding: 1.75rem 1.75rem 1.5rem;
}

[data-theme="dark"] .form-tips {
  background: var(--surface-muted);
  border-color: var(--border);
}

[data-theme="dark"] .form-meta-icon {
  background: var(--primary-muted);
}

/* legacy — keep in case referenced elsewhere */
.card-form {}

/* ── Filter panel ──────────────────────────────────────── */
.filter-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 2px rgba(15,23,42,0.04), 0 10px 24px rgba(15,23,42,0.03);
  padding: 1rem 1.1rem;
}

.filter-panel .filter-heading {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-bottom: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.filter-panel .form-label { font-size: 0.75rem; font-weight: 600; }
.filter-panel .form-control,
.filter-panel .form-select { font-size: 0.82rem; }

/* ── Filter toolbar ────────────────────────────────────── */
.filter-toolbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.05rem 1.1rem;
  box-shadow: 0 2px 6px rgba(15,23,42,0.04), 0 14px 24px rgba(15,23,42,0.05);
}

.tenant-filter-toolbar {
  padding: 1rem 1.15rem 1.1rem;
}

.filter-toolbar-form {
  display: flex;
  gap: 0.9rem;
  align-items: flex-end;
  justify-content: space-between;
}

.tenant-filter-form {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "fields actions";
  gap: 0.8rem 1rem;
  align-items: end;
}

.filter-toolbar-fields {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.tenant-filter-fields {
  grid-area: fields;
  grid-template-columns: 1.25fr 1fr 0.8fr 1fr;
}

.tenant-filter-wide {
  grid-column: span 1;
}

.tenant-field-box {
  padding: 0.58rem 0.62rem 0.62rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 92%, #fff 8%), var(--surface));
  box-shadow: 0 1px 2px rgba(15,23,42,0.03);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.tenant-field-box:focus-within {
  border-color: color-mix(in srgb, var(--primary) 55%, var(--border) 45%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent);
  transform: translateY(-1px);
}

.tenant-field-box .form-label {
  margin-bottom: 0.38rem;
  font-size: 0.69rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
}

.tenant-field-box .form-control,
.tenant-field-box .form-select {
  border: 0;
  box-shadow: none;
  background: transparent;
  min-height: 2rem;
  padding: 0.16rem 0.2rem;
  font-size: 0.84rem;
  font-weight: 600;
}

.tenant-field-box .form-control:focus,
.tenant-field-box .form-select:focus {
  box-shadow: none;
}

[data-theme="dark"] .tenant-field-box {
  background: linear-gradient(180deg, #0f1a31, #0b162b);
  border-color: #2a3a5e;
  box-shadow: 0 1px 2px rgba(2, 6, 23, 0.35);
}

[data-theme="dark"] .tenant-field-box:focus-within {
  border-color: color-mix(in srgb, var(--primary) 60%, #2a3a5e 40%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}

.filter-field-item .form-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 0.35rem;
}

.filter-field-item .form-control,
.filter-field-item .form-select {
  font-size: 0.82rem;
  min-height: 2.25rem;
}

.filter-toolbar-actions {
  display: flex;
  gap: 0.45rem;
  flex-shrink: 0;
}

.tenant-filter-actions {
  grid-area: actions;
  align-self: stretch;
  flex-direction: column;
  justify-content: flex-end;
}

.tenant-filter-actions .btn {
  min-width: 132px;
}

@media (max-width: 991.98px) {
  .filter-toolbar-form {
    flex-direction: column;
    align-items: stretch;
  }

  .tenant-filter-form {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .tenant-filter-fields {
    grid-template-columns: 1fr 1fr;
  }

  .tenant-filter-actions {
    flex-direction: row;
  }

  .filter-toolbar-actions .btn {
    flex: 1;
  }
}

@media (max-width: 640px) {
  .tenant-filter-fields {
    grid-template-columns: 1fr;
  }
}

/* ── Filter chips (tab-style) ──────────────────────────── */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.72rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  transition: all 0.12s;
  white-space: nowrap;
}
.filter-chip:hover { background: #f8fafc; color: var(--text-1); }
.filter-chip.active {
  background: var(--primary-muted);
  border-color: transparent;
  color: var(--primary);
  font-weight: 600;
}

/* ── Detail labels ─────────────────────────────────────── */
.detail-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  margin-bottom: 0.2rem;
}

.detail-value {
  font-size: 0.88rem;
  color: var(--text-1);
  font-weight: 500;
}

/* ── Plan cards ────────────────────────────────────────── */
.plan-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  padding: 1.2rem 1.3rem;
  height: 100%;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.15s, transform 0.15s;
}
.plan-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.plan-card .plan-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 0.2rem;
  letter-spacing: -0.015em;
}
.plan-card .plan-meta {
  font-size: 0.775rem;
  color: var(--text-3);
  margin-bottom: 0.85rem;
}
.plan-card .plan-actions {
  margin-top: auto;
  display: flex;
  gap: 0.35rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border-muted);
}

/* ── Modals ────────────────────────────────────────────── */
.modal-content {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.modal-header { border-bottom: 1px solid var(--border); padding: 1.1rem 1.35rem; }
.modal-footer { border-top: 1px solid var(--border); padding: 0.85rem 1.35rem; }
.modal-body { padding: 1.25rem 1.35rem; }

/* ── Toast ─────────────────────────────────────────────── */
.toast-container { z-index: 1090; }
.toast {
  border-radius: var(--radius);
  border: none;
  box-shadow: var(--shadow-md);
  font-size: 0.84rem;
  min-width: 280px;
}

/* ── Empty state ───────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-3);
}
.empty-state i { font-size: 2rem; display: block; margin-bottom: 0.65rem; opacity: 0.35; }
.empty-state p { font-size: 0.875rem; margin: 0; }

/* ── Login ─────────────────────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sidebar-bg);
  position: relative;
  overflow: hidden;
}

.login-wrapper::before {
  content: '';
  position: absolute;
  width: 700px; height: 700px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99,102,241,0.12) 0%, transparent 70%);
  top: -200px; right: -150px;
  pointer-events: none;
}

.login-wrapper::after {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99,102,241,0.07) 0%, transparent 70%);
  bottom: -150px; left: -100px;
  pointer-events: none;
}

/* dot grid */
.login-wrapper .login-grid {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
}

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  background: rgba(255,255,255,0.98);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 80px rgba(0,0,0,0.45);
  padding: 2.5rem 2.2rem;
}

.login-logo {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-1);
  letter-spacing: -0.025em;
  display: flex;
  align-items: center;
}
.login-logo .login-logo-image {
  display: block;
  width: 180px;
  max-width: 100%;
  height: auto;
}

/* ── Misc ──────────────────────────────────────────────── */
code {
  font-size: 0.8em;
  background: var(--border-muted);
  color: #7c3aed;
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.dropdown-menu {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  font-size: 0.84rem;
  padding: 0.35rem;
}

.dropdown-item {
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem;
  font-size: 0.84rem;
}

.text-muted { color: var(--text-3) !important; }

[data-theme="dark"] .btn-outline-secondary:hover { background: #16213a; border-color: #2b3a5e; color: var(--text-1); }
[data-theme="dark"] body { color: var(--text-1); }
[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4,
[data-theme="dark"] h5,
[data-theme="dark"] h6,
[data-theme="dark"] .page-title,
[data-theme="dark"] .form-label,
[data-theme="dark"] .detail-value,
[data-theme="dark"] .card-header,
[data-theme="dark"] .topbar-user,
[data-theme="dark"] .breadcrumb-item.active { color: var(--text-1) !important; }
[data-theme="dark"] .table,
[data-theme="dark"] .table > tbody > tr > td { color: var(--text-1); }
[data-theme="dark"] .table > thead > tr > th { background: var(--surface-muted); }
[data-theme="dark"] .table > thead > tr > th,
[data-theme="dark"] .table > thead > tr > th a { color: var(--text-2); }
[data-theme="dark"] .table-hover > tbody > tr:hover > td { background: #17233e; }
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
  background-color: #0d1a31;
  border-color: #2a395d;
  color: var(--text-1);
}
[data-theme="dark"] .form-control::placeholder { color: var(--text-3); }
[data-theme="dark"] .page-link { background: var(--surface-muted); color: var(--text-2); }
[data-theme="dark"] .dropdown-menu { background: var(--surface); }
[data-theme="dark"] .dropdown-item { color: var(--text-2); }
[data-theme="dark"] .dropdown-item:hover { background: #16213a; color: var(--text-1); }
[data-theme="dark"] .filter-toolbar { background: var(--surface); border-color: var(--border); }

/* ── shadcn-like utility surfaces ─────────────────────── */
.table-wrap .table {
  --bs-table-striped-bg: transparent;
  --bs-table-bg: transparent;
}

.form-check-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15,108,189,0.13);
}

.form-check-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

.title-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.2rem;
}

.domain-meta {
  font-size: 0.8rem;
  color: var(--text-3);
}

.header-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.table-section-header {
  padding: 0.85rem 1.2rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-title {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-1);
}

.section-title i {
  color: var(--primary);
  font-size: 0.85rem;
}

.tenant-info-body {
  padding: 1.1rem 1.25rem;
}

.break-anywhere {
  word-break: break-all;
}

.text-subtle {
  color: var(--text-2);
}

.text-faint {
  color: var(--text-3);
  font-size: 0.8rem;
}

.cell-action {
  width: 48px;
}

.btn-icon-only {
  padding: 0.25rem 0.5rem;
}

.btn-icon-only i {
  font-size: 0.75rem;
}

.compact-empty-state {
  padding: 1.5rem;
}

.mono-cell {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.8rem;
  color: var(--text-2);
}

.danger-title {
  color: #dc2626;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.danger-text {
  color: #dc2626;
  font-size: 0.8rem;
}

.stat-icon-success {
  background: #e8f8ef;
  color: #15803d;
}

.stat-icon-warning {
  background: #fff7db;
  color: #a16207;
}

.stat-icon-info {
  background: #e8f8fe;
  color: #0e7490;
}

.domain-mini {
  font-size: 0.75rem;
  color: var(--text-3);
  margin-top: 1px;
}

.section-caption {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-3);
}

.schema-sql-preview {
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text-1);
  min-height: 96px;
  white-space: pre-wrap;
  word-break: break-word;
}

[data-theme="dark"] .schema-sql-preview {
  border-color: #2a3a5e;
  background: #0f1a31;
  color: #e2e8f0;
}

/* ─────────────────────────────────────────────────────────
   ATS DB Manager
   ───────────────────────────────────────────────────────── */

/* ── Overview: top search bar ───────────────────────── */
.dbo-top-search-wrap {
  margin-bottom: 1.25rem;
}

.dbo-top-search-inner {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.7rem 1rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.dbo-top-search-inner:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12), var(--shadow-sm);
}

.dbo-top-search-icon {
  color: var(--text-3);
  font-size: 0.92rem;
  flex-shrink: 0;
}

.dbo-top-search-inner:focus-within .dbo-top-search-icon {
  color: var(--primary);
}

.dbo-top-search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.92rem;
  color: var(--text-1);
  font-family: inherit;
  min-width: 0;
}

.dbo-top-search-input::placeholder { color: var(--text-3); }

.dbo-top-search-count {
  font-size: 0.75rem;
  color: var(--text-3);
  white-space: nowrap;
  font-weight: 500;
  flex-shrink: 0;
}

.dbo-top-search-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.15em 0.45em;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 0.68rem;
  color: var(--text-3);
  font-family: inherit;
  flex-shrink: 0;
  line-height: 1.4;
}

[data-theme="dark"] .dbo-top-search-inner {
  background: var(--surface);
  border-color: var(--border);
}

[data-theme="dark"] .dbo-top-search-input { color: var(--text-1); }

[data-theme="dark"] .dbo-top-search-kbd {
  background: var(--surface-muted);
  border-color: var(--border);
  color: var(--text-3);
}

/* ── Overview: two-column layout ────────────────────── */
.dbo-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 900px) {
  .dbo-layout { grid-template-columns: 1fr; }
}

/* ── Left info panel ─────────────────────────────────── */
.dbo-info-panel {
  position: sticky;
  top: calc(var(--topbar-height) + 1.25rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.dbo-info-section {
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--border-muted);
}

.dbo-info-section:last-child {
  border-bottom: none;
}

.dbo-info-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 0.7rem;
}

.dbo-info-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}

.dbo-info-row:last-child { margin-bottom: 0; }

.dbo-info-row > i {
  font-size: 0.8rem;
  color: var(--primary);
  margin-top: 0.15rem;
  flex-shrink: 0;
  opacity: 0.75;
}

.dbo-info-val {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-1);
  word-break: break-all;
}

.dbo-info-val.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;
  font-size: 0.78rem;
}

.dbo-info-sub {
  font-size: 0.68rem;
  color: var(--text-3);
  margin-top: 0.05rem;
}

.dbo-summary-chips {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.dbo-summary-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.dbo-summary-num {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-1);
  letter-spacing: -0.03em;
  line-height: 1;
}

.dbo-summary-lbl {
  font-size: 0.75rem;
  color: var(--text-3);
}

/* ── Right: table list panel ─────────────────────────── */
.dbo-tables-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

/* Search bar */
.dbo-search-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
}

.dbo-search-icon {
  color: var(--text-3);
  font-size: 0.8rem;
  flex-shrink: 0;
}

.dbo-search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 0.84rem;
  color: var(--text-1);
  font-family: inherit;
}

.dbo-search-input::placeholder { color: var(--text-3); }

.dbo-search-count {
  font-size: 0.72rem;
  color: var(--text-3);
  white-space: nowrap;
  font-weight: 500;
}

/* Table rows */
.dbo-table-list { display: flex; flex-direction: column; }

.dbo-table-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.78rem 1.1rem;
  border-bottom: 1px solid var(--border-muted);
  text-decoration: none;
  transition: background 0.1s;
  gap: 1rem;
}

.dbo-table-row:last-child { border-bottom: none; }

.dbo-table-row:hover {
  background: color-mix(in srgb, var(--primary) 4%, var(--surface));
}

.dbo-table-row:hover .dbo-table-arrow {
  opacity: 1;
  transform: translateX(2px);
}

.dbo-table-row-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.dbo-table-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--primary-muted);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  flex-shrink: 0;
}

.dbo-table-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-1);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dbo-table-hint {
  font-size: 0.7rem;
  color: var(--text-3);
  margin-top: 0.1rem;
}

.dbo-table-row-right {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.dbo-row-count {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.02em;
}

.dbo-row-label {
  font-size: 0.72rem;
  color: var(--text-3);
}

.dbo-table-arrow {
  font-size: 0.65rem;
  color: var(--text-3);
  margin-left: 0.35rem;
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
}

/* No results */
.dbo-no-results {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 3rem 1.5rem;
  color: var(--text-3);
  font-size: 0.84rem;
}

.dbo-no-results i {
  font-size: 1.5rem;
  opacity: 0.3;
}

/* Error banner */
.dbo-error-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-lg);
  color: #991b1b;
  padding: 1rem 1.2rem;
  margin-bottom: 1.5rem;
  font-size: 0.84rem;
}

.dbo-error-banner > i {
  font-size: 1.05rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.dbo-error-msg {
  font-size: 0.8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;
  margin-top: 0.2rem;
  word-break: break-all;
}

/* Dark mode */
[data-theme="dark"] .dbo-info-panel,
[data-theme="dark"] .dbo-tables-panel {
  background: var(--surface);
  border-color: var(--border);
}

[data-theme="dark"] .dbo-search-wrap {
  background: var(--surface-muted);
  border-color: var(--border);
}

[data-theme="dark"] .dbo-search-input { color: var(--text-1); }

[data-theme="dark"] .dbo-table-row:hover {
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
}

[data-theme="dark"] .dbo-table-row { border-color: var(--border-muted); }

[data-theme="dark"] .dbo-error-banner {
  background: #2d0a0a;
  border-color: #7f1d1d;
  color: #fca5a5;
}

[data-theme="dark"] .dbo-info-section { border-color: var(--border); }

/* ── Browser layout ──────────────────────────────────── */
.db-browser-wrap {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.5rem;
  align-items: start;
  min-height: calc(100vh - var(--topbar-height) - 4rem);
}

@media (max-width: 767px) {
  .db-browser-wrap {
    grid-template-columns: 1fr;
  }
}

/* ── Sidebar ─────────────────────────────────────────── */
.db-browser-sidebar {
  position: sticky;
  top: calc(var(--topbar-height) + 1.25rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  max-height: calc(100vh - var(--topbar-height) - 3rem);
  display: flex;
  flex-direction: column;
}

.db-sidebar-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
  flex-shrink: 0;
}

.db-sidebar-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  text-decoration: none;
  font-size: 0.8rem;
  flex-shrink: 0;
  transition: background 0.12s;
}

.db-sidebar-back:hover {
  background: var(--bg);
  color: var(--text-1);
}

.db-sidebar-title {
  min-width: 0;
}

.db-sidebar-db-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;
}

.db-sidebar-tenant {
  font-size: 0.68rem;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.db-sidebar-section-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 0.65rem 1rem 0.3rem;
  flex-shrink: 0;
}

.db-sidebar-nav {
  overflow-y: auto;
  flex: 1;
  padding-bottom: 0.5rem;
}

.db-sidebar-nav::-webkit-scrollbar { width: 3px; }
.db-sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.db-table-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.85rem 0.4rem 1rem;
  margin: 1px 0.5rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
  transition: background 0.1s, color 0.1s;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.db-table-link i {
  font-size: 0.72rem;
  flex-shrink: 0;
  opacity: 0.6;
}

.db-table-link:hover {
  background: var(--bg);
  color: var(--text-1);
}

.db-table-link.active {
  background: var(--primary-muted);
  color: var(--primary);
  border-left-color: var(--primary);
}

.db-table-link.active i {
  opacity: 1;
}

/* ── Main content area ───────────────────────────────── */
.db-browser-main {
  min-width: 0;
}

/* ── Table header ────────────────────────────────────── */
.db-table-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
}

.db-table-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-1);
  letter-spacing: -0.02em;
  margin-bottom: 0.3rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;
}

.db-table-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.db-table-range {
  font-size: 0.75rem;
  color: var(--text-3);
}

.db-table-pk-badge {
  font-size: 0.72rem;
  background: #fef9c3;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 99px;
  padding: 0.15em 0.55em;
  font-weight: 600;
}

/* ── Data table ──────────────────────────────────────── */
.db-data-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.db-data-table {
  font-size: 0.83rem;
  min-width: 100%;
}

.db-data-table th {
  white-space: nowrap;
  vertical-align: top;
  background: var(--surface-muted) !important;
  padding: 0.65rem 0.9rem !important;
  border-bottom: 1px solid var(--border) !important;
}

.db-col-name {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-1);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;
  margin-bottom: 0.1rem;
}

.db-col-type {
  font-size: 0.65rem;
  color: var(--text-3);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;
  font-weight: 400;
}

.db-data-table td {
  padding: 0.7rem 0.9rem !important;
  vertical-align: middle;
  max-width: 280px;
  border-bottom: 1px solid var(--border-muted) !important;
}

.db-cell-val {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;
  font-size: 0.8rem;
}

.db-null {
  color: var(--text-3);
  font-style: italic;
  font-size: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;
}

/* actions column */
.db-actions-col {
  width: 80px !important;
  white-space: nowrap;
}

.db-row-actions {
  display: flex;
  gap: 0.3rem;
  align-items: center;
}

/* ── Pagination ──────────────────────────────────────── */
.db-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1rem;
  border-top: 1px solid var(--border-muted);
  background: var(--surface);
}

.db-pagination-info {
  font-size: 0.78rem;
  color: var(--text-3);
}

/* ── Row form: schema panel ──────────────────────────── */
.db-schema-row {
  align-items: flex-start;
  flex-direction: column;
  gap: 0.2rem;
}

.db-schema-col-name {
  font-size: 0.78rem;
  color: var(--text-1);
  font-weight: 600;
}

.db-schema-col-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.db-col-type-badge {
  font-size: 0.65rem;
  background: var(--primary-muted);
  color: var(--primary);
  border-radius: 4px;
  padding: 0.05em 0.4em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;
  font-weight: 500;
}

.db-nullable-badge {
  font-size: 0.62rem;
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
  border-radius: 4px;
  padding: 0.05em 0.4em;
  font-weight: 500;
}

.db-auto-badge {
  font-size: 0.62rem;
  background: #fef9c3;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 4px;
  padding: 0.05em 0.4em;
  font-weight: 500;
}

/* ── Dark mode ───────────────────────────────────────── */
[data-theme="dark"] .db-table-card {
  background: var(--surface);
  border-color: var(--border);
}
[data-theme="dark"] .db-browser-sidebar {
  background: var(--surface);
  border-color: var(--border);
}
[data-theme="dark"] .db-sidebar-head {
  background: var(--surface-muted);
  border-color: var(--border);
}
[data-theme="dark"] .db-table-link:hover { background: #16213a; }
[data-theme="dark"] .db-table-link.active { background: var(--primary-muted); }
[data-theme="dark"] .db-data-wrap { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .db-data-table th { background: var(--surface-muted) !important; }
[data-theme="dark"] .db-data-table td { border-color: var(--border-muted) !important; }
[data-theme="dark"] .db-stat-chip { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .db-table-pk-badge { background: #2d2000; color: #fbbf24; border-color: #713f12; }
[data-theme="dark"] .db-col-type-badge { background: var(--primary-muted); color: var(--primary); }
[data-theme="dark"] .db-nullable-badge { background: #052e16; color: #4ade80; border-color: #14532d; }
[data-theme="dark"] .db-auto-badge { background: #2d2000; color: #fbbf24; border-color: #713f12; }
[data-theme="dark"] .db-pagination { background: var(--surface); border-color: var(--border); }

/* ═══════════════════════════════════════════════════════════
   AQL — AuraSync Query Language
   ═══════════════════════════════════════════════════════════ */

/* ── Layout ──────────────────────────────────────────────── */
.aql-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 1099px) {
  .aql-layout { grid-template-columns: 1fr 240px; }
}

@media (max-width: 767px) {
  .aql-layout { grid-template-columns: 1fr; }
}

.aql-main { min-width: 0; display: flex; flex-direction: column; gap: 1rem; }

/* ── Badge ────────────────────────────────────────────────── */
.aql-badge-lang {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--primary-muted);
  color: var(--primary);
  border-radius: 6px;
  padding: 0.2em 0.55em;
  vertical-align: middle;
}

/* ── Editor card ─────────────────────────────────────────── */
.aql-editor-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.aql-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
}

.aql-editor-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-2);
}

.aql-editor-hints {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  color: var(--text-3);
}

.aql-editor-hints kbd {
  display: inline-block;
  font-size: 0.68rem;
  padding: 0.1em 0.4em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: inherit;
  color: var(--text-2);
}

.aql-textarea {
  display: block;
  width: 100%;
  min-height: 90px;
  resize: vertical;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1rem;
  font-size: 0.88rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;
  color: var(--text-1);
  background: var(--surface);
  outline: none;
  line-height: 1.6;
}

.aql-textarea:focus {
  background: color-mix(in srgb, var(--primary) 3%, var(--surface));
}

.aql-textarea::placeholder { color: var(--text-3); }

.aql-editor-footer {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.85rem;
}

.aql-run-btn { min-width: 110px; }

/* ── Status ───────────────────────────────────────────────── */
.aql-status {
  font-size: 0.78rem;
  font-weight: 500;
  margin-left: 0.25rem;
}
.aql-status-running { color: var(--primary); }
.aql-status-ok      { color: #16a34a; }
.aql-status-error   { color: #dc2626; }

/* ── SQL preview ──────────────────────────────────────────── */
.aql-sql-preview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.aql-sql-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 0.45rem 0.85rem;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
}

.aql-sql-code {
  display: block;
  padding: 0.65rem 0.85rem;
  font-size: 0.8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;
  color: var(--text-1);
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.55;
}

/* ── Warnings / Errors ────────────────────────────────────── */
.aql-warning {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.65rem 0.9rem;
  font-size: 0.82rem;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  color: #92400e;
  margin-bottom: 0.4rem;
}

.aql-warning + .aql-warning { margin-top: 0.3rem; }

.aql-error {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.65rem 0.9rem;
  font-size: 0.82rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  color: #991b1b;
  margin-bottom: 0.4rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;
}

/* ── Results ──────────────────────────────────────────────── */
.aql-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.aql-results-count {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-2);
}

.aql-results-scroll {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.aql-results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;
}

.aql-results-table th {
  background: var(--surface-muted);
  border-bottom: 2px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.aql-results-table td {
  padding: 0.42rem 0.75rem;
  border-bottom: 1px solid var(--border-muted);
  color: var(--text-1);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aql-results-table tr:last-child td { border-bottom: none; }

.aql-results-table tbody tr:hover td {
  background: color-mix(in srgb, var(--primary) 5%, var(--surface));
}

.db-null {
  color: var(--text-3);
  font-style: italic;
  font-size: 0.75em;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.aql-sidebar {
  position: sticky;
  top: calc(var(--topbar-height) + 1.25rem);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.aql-sidebar-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.aql-sidebar-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 0.5rem 0.75rem;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
}

/* ── Syntax reference ─────────────────────────────────────── */
.aql-syntax-block {
  padding: 0.55rem 0.75rem 0.4rem;
  border-bottom: 1px solid var(--border-muted);
}

.aql-syntax-line {
  font-size: 0.75rem;
  line-height: 1.8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;
}

.aql-syn-kw {
  color: var(--primary);
  font-weight: 600;
}

.aql-syn-opt {
  color: var(--text-3);
}

.aql-syntax-ops {
  padding: 0.45rem 0.75rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.aql-syntax-ops div {
  font-size: 0.75rem;
  color: var(--text-2);
  line-height: 1.7;
}

.aql-syntax-ops code {
  background: var(--surface-muted);
  border: 1px solid var(--border-muted);
  border-radius: 4px;
  padding: 0.05em 0.35em;
  font-size: 0.73rem;
  color: var(--text-1);
}

.aql-syn-note {
  color: var(--text-3);
  font-size: 0.7rem;
}

/* ── Examples ─────────────────────────────────────────────── */
.aql-examples-list {
  display: flex;
  flex-direction: column;
  max-height: 220px;
  overflow-y: auto;
}

.aql-examples-list::-webkit-scrollbar { width: 3px; }
.aql-examples-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.aql-example {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-muted);
  cursor: pointer;
  transition: background 0.1s;
}

.aql-example:last-child { border-bottom: none; }

.aql-example:hover { background: color-mix(in srgb, var(--primary) 6%, var(--surface)); }

.aql-example-desc {
  font-size: 0.73rem;
  color: var(--text-2);
  font-weight: 500;
  margin-bottom: 0.2rem;
}

.aql-example-code {
  font-size: 0.68rem;
  color: var(--text-3);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Table reference ──────────────────────────────────────── */
.aql-table-ref {
  display: flex;
  flex-direction: column;
  max-height: 300px;
  overflow-y: auto;
}

.aql-table-ref::-webkit-scrollbar { width: 3px; }
.aql-table-ref::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.aql-table-details {
  border-bottom: 1px solid var(--border-muted);
}

.aql-table-details:last-child { border-bottom: none; }

.aql-table-summary {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  list-style: none;
  font-size: 0.77rem;
  font-weight: 500;
  color: var(--text-2);
  transition: background 0.1s;
  user-select: none;
}

.aql-table-summary::-webkit-details-marker { display: none; }
.aql-table-summary::marker { display: none; }

.aql-table-details[open] > .aql-table-summary,
.aql-table-summary:hover { background: color-mix(in srgb, var(--primary) 6%, var(--surface)); }

.aql-chevron {
  font-size: 0.65rem;
  color: var(--text-3);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.aql-ref-table {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;
  font-size: 0.75rem;
  color: var(--text-1);
}

.aql-col-list {
  padding: 0.2rem 0 0.35rem 1.4rem;
}

.aql-col-placeholder {
  font-size: 0.71rem;
  color: var(--text-3);
  padding: 0.2rem 0;
  font-style: italic;
}

.aql-col-item {
  font-size: 0.71rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;
  color: var(--text-3);
  padding: 0.18rem 0.4rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.aql-col-item:hover {
  background: var(--primary-muted);
  color: var(--primary);
}

/* ── Dark mode ────────────────────────────────────────────── */
[data-theme="dark"] .aql-editor-card,
[data-theme="dark"] .aql-sql-preview,
[data-theme="dark"] .aql-sidebar-section {
  background: var(--surface);
  border-color: var(--border);
}

[data-theme="dark"] .aql-editor-header,
[data-theme="dark"] .aql-sql-label,
[data-theme="dark"] .aql-sidebar-label {
  background: var(--surface-muted);
  border-color: var(--border);
}

[data-theme="dark"] .aql-textarea {
  background: var(--surface);
  color: var(--text-1);
  border-color: var(--border);
}

[data-theme="dark"] .aql-textarea:focus {
  background: color-mix(in srgb, var(--primary) 5%, var(--surface));
}

[data-theme="dark"] .aql-results-scroll { border-color: var(--border); }

[data-theme="dark"] .aql-results-table th {
  background: var(--surface-muted);
  border-color: var(--border);
}

[data-theme="dark"] .aql-results-table td { border-color: var(--border-muted); }

[data-theme="dark"] .aql-results-table tbody tr:hover td {
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
}

[data-theme="dark"] .aql-warning {
  background: #2d1f00;
  border-color: #78350f;
  color: #fcd34d;
}

[data-theme="dark"] .aql-error {
  background: #2d0a0a;
  border-color: #7f1d1d;
  color: #fca5a5;
}

[data-theme="dark"] .aql-example:hover,
[data-theme="dark"] .aql-table-details[open] > .aql-table-summary,
[data-theme="dark"] .aql-table-summary:hover {
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
}

[data-theme="dark"] .aql-syntax-ops code {
  background: var(--surface-muted);
  border-color: var(--border);
  color: var(--text-1);
}

[data-theme="dark"] .aql-col-item:hover {
  background: var(--primary-muted);
  color: var(--primary);
}

/* ═══════════════════════════════════════════════════════════
   ATS Admin Credentials page
   ═══════════════════════════════════════════════════════════ */

.atscred-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 1099px) { .atscred-layout { grid-template-columns: 1fr 240px; } }
@media (max-width: 767px)  { .atscred-layout { grid-template-columns: 1fr; } }

.atscred-main { display: flex; flex-direction: column; gap: 1.25rem; }

.atscred-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.atscred-card-head {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-2);
  padding: 0.65rem 1rem;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
}

.atscred-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

@media (max-width: 600px) { .atscred-fields { grid-template-columns: 1fr; } }

.atscred-field {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-muted);
  border-right: 1px solid var(--border-muted);
}

.atscred-field:nth-child(even) { border-right: none; }
.atscred-field:nth-last-child(-n+2) { border-bottom: none; }

.atscred-field-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 0.25rem;
}

.atscred-field-val {
  font-size: 0.85rem;
  color: var(--text-1);
}

.atscred-pw-mask {
  letter-spacing: 0.15em;
  color: var(--text-3);
}

.atscred-form {
  padding: 1.1rem 1rem;
}

.atscred-input-wrap {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.atscred-input { flex: 1; }

.atscred-pw-field-wrap {
  position: relative;
  flex: 1;
}

.atscred-pw-field-wrap .atscred-input {
  padding-right: 2.4rem;
}

.atscred-eye-btn {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 0.2rem 0.3rem;
  color: var(--text-3);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  transition: color 0.12s;
}

.atscred-eye-btn:hover { color: var(--text-1); }

.atscred-form-footer {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-muted);
}

/* Credential-change notification opt-in, set apart from the credential inputs
   because it triggers an outbound email rather than editing a field. */
.atscred-notify {
  margin-top: 1.1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border-muted);
  border-radius: 10px;
  background: var(--surface-muted);
}
.atscred-notify .form-text { margin-top: 0.35rem; }
.atscred-notify code { word-break: break-all; }

/* ── Sidebar ──────────────────────────────────────────────── */
.atscred-sidebar {
  position: sticky;
  top: calc(var(--topbar-height) + 1.25rem);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.atscred-info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.atscred-info-body {
  padding: 0.85rem 1rem;
  font-size: 0.8rem;
  color: var(--text-2);
  line-height: 1.6;
}

.atscred-info-body p { margin-bottom: 0.6rem; }
.atscred-info-body p:last-child { margin-bottom: 0; }

.atscred-convention-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border-muted);
  font-size: 0.79rem;
}

.atscred-convention-row:last-of-type { border-bottom: none; }

.atscred-convention-label {
  color: var(--text-3);
  font-weight: 500;
  min-width: 70px;
}

/* ── Dark mode ────────────────────────────────────────────── */
[data-theme="dark"] .atscred-card,
[data-theme="dark"] .atscred-info-card {
  background: var(--surface);
  border-color: var(--border);
}

[data-theme="dark"] .atscred-card-head {
  background: var(--surface-muted);
  border-color: var(--border);
}

[data-theme="dark"] .atscred-field { border-color: var(--border-muted); }
[data-theme="dark"] .atscred-form-footer { border-color: var(--border-muted); }
[data-theme="dark"] .atscred-convention-row { border-color: var(--border-muted); }
[data-theme="dark"] .atscred-notify {
  background: var(--surface-muted);
  border-color: var(--border);
}

/* ── ATS admin chip on overview ───────────────────────────── */
.dbo-admin-chip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s;
}

.dbo-admin-chip:hover {
  background: color-mix(in srgb, var(--primary) 5%, var(--surface));
  border-color: var(--primary);
}

.dbo-admin-chip-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--primary-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 0.9rem;
  flex-shrink: 0;
}

.dbo-admin-chip-body { min-width: 0; }

.dbo-admin-chip-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-3);
}

.dbo-admin-chip-val {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-1);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

[data-theme="dark"] .dbo-admin-chip {
  background: var(--surface);
  border-color: var(--border);
}

[data-theme="dark"] .dbo-admin-chip:hover {
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
  border-color: var(--primary);
}

/* ─────────────────────────────────────────────────────────
   Dashboard — Stakeholder View
   ───────────────────────────────────────────────────────── */

/* ── Trend badges ─────────────────────────────────────── */
.dash-trend {
  display: inline-flex;
  align-items: center;
  gap: 0.1rem;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 99px;
  padding: 0.18em 0.6em 0.18em 0.3em;
}
.dash-trend i { font-size: 0.88rem; }
.dash-trend-up   { color: #15803d; background: #dcfce7; }
.dash-trend-down { color: #dc2626; background: #fee2e2; }

/* ── Generic panel (replaces table-wrap for bar charts) ── */
.dash-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 2px 6px rgba(15,23,42,0.04), 0 14px 24px rgba(15,23,42,0.06);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.dash-panel-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1.2rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.dash-panel-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-1);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
}
.dash-panel-title i { color: var(--text-3); }

.dash-panel-body {
  padding: 1rem 1.2rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.dash-panel-footer {
  padding: 0.65rem 1.2rem;
  border-top: 1px solid var(--border-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.dash-link {
  font-size: 0.77rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.dash-link:hover { color: var(--primary-hover); }
.dash-link i { font-size: 0.8rem; }

/* ── Distribution bars (plan / module adoption) ─────── */
.dist-row {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.dist-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.81rem;
  color: var(--text-2);
}

.dist-count {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-1);
  flex-shrink: 0;
}

.dist-bar-track {
  height: 7px;
  background: var(--surface-muted);
  border-radius: 99px;
  overflow: hidden;
}

.dist-bar {
  height: 100%;
  border-radius: 99px;
  transition: width 0.6s cubic-bezier(0.34,1.2,0.64,1);
}

.dist-bar-primary { background: var(--primary); }
.dist-bar-teal    { background: #0891b2; }

/* ── Usage leaderboard rows ───────────────────────────── */
.usage-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.usage-label {
  width: 140px;
  flex-shrink: 0;
  overflow: hidden;
}

.usage-name {
  font-size: 0.81rem;
  font-weight: 600;
  color: var(--text-1);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
a.usage-name:hover { color: var(--primary); }

.usage-bar-track {
  flex: 1;
  height: 8px;
  background: var(--surface-muted);
  border-radius: 99px;
  overflow: hidden;
}

.usage-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
  transition: width 0.6s cubic-bezier(0.34,1.2,0.64,1);
}
.usage-bar-violet { background: #7c3aed; }

.usage-count {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-1);
  width: 36px;
  text-align: right;
  flex-shrink: 0;
}

/* ── Tenant health bars ───────────────────────────────── */
.health-row {
  display: grid;
  grid-template-columns: 10px 110px 1fr 28px 38px;
  align-items: center;
  gap: 0.5rem;
}

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.health-dot-active       { background: #22c55e; }
.health-dot-suspended    { background: #f59e0b; }
.health-dot-deprovisioned{ background: #ef4444; }

.health-label {
  font-size: 0.8rem;
  color: var(--text-2);
  white-space: nowrap;
}

.health-bar-track {
  height: 8px;
  background: var(--surface-muted);
  border-radius: 99px;
  overflow: hidden;
}

.health-bar {
  height: 100%;
  border-radius: 99px;
  transition: width 0.6s cubic-bezier(0.34,1.2,0.64,1);
}
.health-bar-active       { background: #22c55e; }
.health-bar-suspended    { background: #f59e0b; }
.health-bar-deprovisioned{ background: #ef4444; }

.health-count {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-1);
  text-align: right;
}

.health-pct {
  font-size: 0.72rem;
  color: var(--text-3);
  text-align: right;
}

.health-divider {
  border-top: 1px solid var(--border-muted);
  margin: 0.5rem 0;
}

/* ── Catalog mini stats grid ──────────────────────────── */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.catalog-stat {
  background: var(--surface-muted);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.5rem;
  text-align: center;
}

.catalog-num {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-1);
  letter-spacing: -0.03em;
}

.catalog-lbl {
  font-size: 0.65rem;
  color: var(--text-3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.15rem;
}

/* ── Alert panels ─────────────────────────────────────── */
.alert-panel {
  border-radius: var(--radius-lg);
  border: 1px solid;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(15,23,42,0.04), 0 10px 20px rgba(15,23,42,0.05);
}

.alert-panel-warning {
  border-color: #fde68a;
  background: #fffbeb;
}

.alert-panel-danger {
  border-color: #fecaca;
  background: #fff5f5;
}

.alert-panel-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.1rem;
  font-size: 0.82rem;
  font-weight: 700;
  border-bottom: 1px solid;
}

.alert-panel-warning .alert-panel-header {
  background: #fef9c3;
  border-color: #fde68a;
  color: #92400e;
}

.alert-panel-danger .alert-panel-header {
  background: #fee2e2;
  border-color: #fecaca;
  color: #991b1b;
}

.alert-panel-body {
  padding: 0.5rem 0;
}

.alert-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.1rem;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  gap: 0.5rem;
}

.alert-row:last-child { border-bottom: none; }

.alert-row-more {
  padding: 0.5rem 1.1rem;
  border-top: 1px dashed rgba(0,0,0,0.08);
}

/* ── Dark mode overrides ──────────────────────────────── */
[data-theme="dark"] .dash-panel {
  background: var(--surface);
  border-color: var(--border);
}

[data-theme="dark"] .dash-panel-header,
[data-theme="dark"] .dash-panel-footer {
  border-color: var(--border);
}

[data-theme="dark"] .dist-bar-track,
[data-theme="dark"] .usage-bar-track,
[data-theme="dark"] .health-bar-track { background: var(--surface-muted); }

[data-theme="dark"] .catalog-stat { background: var(--surface-muted); }

[data-theme="dark"] .alert-panel-warning {
  border-color: #78350f;
  background: #1c1208;
}
[data-theme="dark"] .alert-panel-warning .alert-panel-header {
  background: #291a08;
  border-color: #78350f;
  color: #fcd34d;
}

[data-theme="dark"] .alert-panel-danger {
  border-color: #7f1d1d;
  background: #180a0a;
}
[data-theme="dark"] .alert-panel-danger .alert-panel-header {
  background: #200c0c;
  border-color: #7f1d1d;
  color: #fca5a5;
}

[data-theme="dark"] .alert-row { border-color: rgba(255,255,255,0.04); }
[data-theme="dark"] .alert-row-more { border-color: rgba(255,255,255,0.08); }



/* ── Schema Sync success banner ─────────────────────────────────────────── */
.schema-sync-banner {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 2.5rem 1rem 1.1rem;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(120deg, #16a34a 0%, #0ea5e9 100%);
  box-shadow: 0 10px 28px -12px rgba(14, 165, 233, 0.65);
  overflow: hidden;
  animation: schemaSyncPop 0.45s cubic-bezier(0.18, 0.89, 0.32, 1.28) both;
}
.schema-sync-banner::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 90% -20%, rgba(255,255,255,0.28), transparent 55%);
  pointer-events: none;
}
@keyframes schemaSyncPop {
  from { opacity: 0; transform: translateY(-8px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.schema-sync-banner-icon {
  font-size: 1.9rem;
  line-height: 1;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.18));
}
.schema-sync-banner-body { position: relative; z-index: 1; }
.schema-sync-banner-title {
  font-weight: 700;
  font-size: 1.02rem;
  margin-bottom: 0.15rem;
}
.schema-sync-banner-text { font-size: 0.86rem; opacity: 0.96; }
.schema-sync-banner code {
  background: rgba(255,255,255,0.22);
  color: #fff;
  padding: 0.05rem 0.35rem;
  border-radius: 5px;
}
.schema-sync-banner-meta { margin-top: 0.55rem; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.schema-sync-banner-close { position: absolute; top: 0.7rem; right: 0.8rem; z-index: 2; }

/* ── Activity Center (monitoring) ──────────────────────────── */
/* Column-layout stat cards (override the default row flex when a
   .stat-value is present, so header/value/caption stack vertically). */
.stat-card:has(.stat-value) { flex-direction: column; gap: 0.35rem; }
.stat-value {
  font-size: 1.9rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--text-1);
  margin: 0.15rem 0;
}

/* Pulsing "online" indicator */
.live-dot, .offline-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  vertical-align: middle;
}
.live-dot {
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
  animation: live-pulse 1.8s infinite;
}
.offline-dot { background: #cbd5e1; }
@keyframes live-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); }
  70%  { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Clickable table rows */
.activity-row { cursor: pointer; transition: background 0.12s; }
.activity-row:hover { background: var(--primary-muted); }

/* Activity timeline */
.activity-timeline { list-style: none; margin: 0; padding: 0; }
.activity-timeline .timeline-item {
  position: relative;
  display: flex;
  gap: 0.85rem;
  padding: 0 0 1.1rem 0;
}
.activity-timeline .timeline-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 15px; top: 34px; bottom: 0;
  width: 2px;
  background: var(--border);
}
.timeline-icon {
  width: 32px; height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-muted);
  color: var(--primary);
  font-size: 0.85rem;
  z-index: 1;
}
.timeline-body { padding-top: 0.15rem; }
.timeline-login  .timeline-icon { background: #dcfce7; color: #15803d; }
.timeline-logout .timeline-icon { background: #f1f5f9; color: #475569; }
.timeline-write  .timeline-icon { background: #dbeafe; color: #2563eb; }
.timeline-export .timeline-icon { background: #fef9c3; color: #a16207; }
.timeline-admin  .timeline-icon { background: #fee2e2; color: #dc2626; }
