@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

/* ── Variables — "Steel Fjord" design system ─────────────────────────────── */
:root {
  /* Brand — Steel Fjord (theme-independent) */
  --primary:           #3D6478;
  --primary-hover:     #335567;
  --primary-pressed:   #2A4757;
  --primary-light:     #C7DCE3;
  --primary-extralight:#EBF2F4;

  /* legacy alias kept for any remaining old references */
  --primary-light-old: #DBEAFE;

  --secondary:      #3B82F6;
  --secondary-light:#DBEAFE;
  --success:        #22C55E;
  --success-light:  #DCFCE7;
  --warning:        #F59E0B;
  --warning-light:  #FEF3C7;
  --danger:         #EF4444;
  --danger-light:   #FEE2E2;
  --info:           #3B82F6;
  --info-light:     #DBEAFE;

  --bg:             #F8FAFB;
  --bg-card:        #FFFFFF;
  --bg-sidebar:     #FFFFFF;
  --bg-header:      #FFFFFF;
  --bg-hover:       #F0F4F6;
  --bg-input:       #FFFFFF;
  --bg-selected:    #EBF2F4;

  --text:           #1B2A30;
  --text-secondary: #4F6470;
  --text-muted:     #82949C;
  --text-disabled:  #B3C0C5;
  --text-inverse:   #FFFFFF;

  --border:         #E2E9EC;
  --border-input:   #CDD8DD;

  --shadow-sm:      0 1px 2px rgba(10,20,25,0.04);
  --shadow:         0 2px 8px rgba(10,20,25,0.06);
  --shadow-md:      0 4px 16px rgba(10,20,25,0.07);
  --shadow-lg:      0 8px 30px rgba(10,20,25,0.08);
  --shadow-xl:      0 16px 48px rgba(10,20,25,0.10);

  --radius-sm:      6px;
  --radius:         10px;
  --radius-lg:      14px;
  --radius-dialog:  18px;
  --radius-xl:      20px;
  --radius-full:    9999px;

  --header-h:       64px;
  --sidebar-w:      260px;
  --sidebar-w-icons:64px;
  --transition:     0.2s ease;

  /* Item type colors — mapped onto the Fjord chart palette */
  --c-table:     #3D6478;
  --c-view:      #3B82F6;
  --c-dashboard: #22C55E;
  --c-kpi:       #F59E0B;
  --c-report:    #EF4444;
  --c-dataset:   #94A3B8;

  /* Playbook — warm amber accent */
  --c-playbook:        #D97706;
  --playbook-bg:       #FFFBF5;
  --playbook-border:   rgba(245,158,11,0.25);
  --playbook-icon-bg:  rgba(245,158,11,0.12);
}

[data-theme="dark"] {
  --bg:             #10171A;
  --bg-card:        #1A2429;
  --bg-sidebar:     #141C20;
  --bg-header:      #1A2429;
  --bg-hover:       #222E33;
  --bg-input:       #1A2429;
  --bg-selected:    rgba(61,100,120,0.22);

  --text:           #EEF4F6;
  --text-secondary: #C3D2D8;
  --text-muted:     #7E929B;
  --text-disabled:  #54656C;

  --border:         #324048;
  --border-input:   #44545D;

  --shadow-sm:      0 1px 2px rgba(0,0,0,0.25);
  --shadow:         0 2px 8px rgba(0,0,0,0.28);
  --shadow-md:      0 4px 16px rgba(0,0,0,0.30);
  --shadow-lg:      0 8px 30px rgba(0,0,0,0.35);
  --shadow-xl:      0 16px 48px rgba(0,0,0,0.45);

  /* Playbook dark overrides */
  --c-playbook:        #F59E0B;
  --playbook-bg:       #1C1810;
  --playbook-border:   rgba(245,158,11,0.20);
  --playbook-icon-bg:  rgba(245,158,11,0.10);
}

/* ── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Lucide icons ─────────────────────────────────────────────────────────── */
/* Default: inherit text color via stroke="currentColor", scale with font-size */
.lucide { width: 1em; height: 1em; stroke-width: 2; vertical-align: -0.15em; flex-shrink: 0; }
.ic-action  { color: var(--text-secondary); }
.ic-muted   { color: var(--text-muted); }
.ic-success, .ic-check { color: var(--success, #10B981); }
.ic-danger, .ic-x      { color: var(--text-muted); }
.ic-warning { color: var(--warning, #F59E0B); }
.ic-star    { color: #F59E0B; }

/* ── DB vendor logo chips (theme-independent contrast background) ───────────── */
.db-logo-chip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px;
  background: #ffffff; border: 1px solid var(--border);
  flex-shrink: 0;
}
.db-logo-chip img { width: 22px; height: 22px; display: block; }
.db-logo-chip.bi-icon-chip { background: var(--bi-color, var(--primary)); }
.db-logo-chip.bi-icon-chip .lucide { width: 20px; height: 20px; color: #fff; }

/* ── Integration type-select cards (Workspace > Integrations) ───────────────── */
.conn-type-card {
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
  padding: 1.1rem 0.75rem; text-align: center;
}
.conn-type-card .db-logo-chip { width: 44px; height: 44px; border-radius: 10px; }
.conn-type-card .db-logo-chip img { width: 26px; height: 26px; }
.conn-type-card .db-logo-chip.bi-icon-chip .lucide { width: 24px; height: 24px; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; }

/* ── Typography ────────────────────────────────────────────────────────────── */
h1 { font-size: 1.75rem; font-weight: 600; line-height: 1.2; }
h2 { font-size: 1.375rem; font-weight: 600; line-height: 1.3; }
h3 { font-size: 1.125rem; font-weight: 600; }
h4 { font-size: 1rem; font-weight: 600; }

/* ── Layout ────────────────────────────────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  grid-template-areas:
    "header header"
    "sidebar main";
  min-height: 100vh;
}

.app-layout.no-sidebar {
  grid-template-areas: "header header" "main main";
  grid-template-columns: 1fr;
}

/* ── Header ────────────────────────────────────────────────────────────────── */
.app-header {
  grid-area: header;
  height: var(--header-h);
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
  transition: background var(--transition), border-color var(--transition);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-weight: 600;
  font-size: 1.125rem;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.logo:hover { text-decoration: none; }

/* ── Top navigation links (Catalog / Data Management / Administration) ── */
.app-nav { display: flex; align-items: center; gap: 0.125rem; margin-left: 1rem; }

.app-nav-link {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.875rem;
  border-radius: 8px;
  font-size: 0.8375rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
  letter-spacing: 0.01em;
}
.app-nav-link:hover {
  background: var(--bg-hover);
  color: var(--text);
  text-decoration: none;
}
.app-nav-link.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.logo-icon {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 1rem;
  flex-shrink: 0;
}

.header-search {
  flex: 1;
  max-width: 560px;
  position: relative;
}

.header-search input {
  width: 100%;
  padding: 0.5rem 1rem 0.5rem 2.75rem;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-full);
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.9rem;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  outline: none;
}
.header-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(61,100,120,0.15);
}
.header-search input::placeholder { color: var(--text-muted); }

.search-icon {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 0.9rem;
}

/* ── Global search dropdown ──────────────────────────────────────────────── */
.search-dropdown {
  position: absolute; top: calc(100% + 0.4rem); left: 0; right: 0;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  z-index: 500; overflow: hidden;
}
.search-dropdown.hidden { display: none; }
.search-result-item {
  display: flex; align-items: center; gap: 0.6rem; width: 100%;
  padding: 0.6rem 1rem; background: none; border: none; cursor: pointer;
  text-align: left; color: var(--text); font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}
.search-result-item:last-of-type { border-bottom: none; }
.search-result-item:hover, .search-result-item.active { background: var(--bg-hover); }
.search-result-item .lucide { color: var(--text-muted); flex-shrink: 0; }
.search-result-name { font-weight: 600; }
.search-result-path { color: var(--text-muted); font-size: 0.78rem; margin-left: auto; }
.search-result-viewall {
  display: block; width: 100%; padding: 0.6rem 1rem; background: var(--bg);
  border: none; border-top: 1px solid var(--border); cursor: pointer;
  color: var(--primary); font-size: 0.8rem; font-weight: 600; text-align: center;
}
.search-result-viewall:hover { background: var(--bg-hover); }
.search-result-viewall-half { flex: 1; border-top: none; }
.search-result-viewall-half + .search-result-viewall-half { border-left: 1px solid var(--border); }
.search-result-viewall-playbook { color: var(--c-playbook, #D97706); }
.search-section-label {
  padding: 0.3rem 1rem 0.2rem;
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.search-section-label-playbook { color: var(--c-playbook, #D97706); }
.search-result-playbook .lucide { color: var(--c-playbook, #D97706); }
.search-dropdown-empty { padding: 1rem; color: var(--text-muted); font-size: 0.85rem; text-align: center; }

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-btn {
  width: 36px; height: 36px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  transition: background var(--transition), color var(--transition);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

.user-menu {
  position: relative;
}

/* ── Language Switcher ──────────────────────────────────────────────────────── */
.lang-switcher { position: relative; }

.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  height: 34px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: 0.05em;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}
.lang-btn:hover {
  border-color: var(--primary);
  background: var(--primary-extralight);
  color: var(--primary);
}

.lang-flag-circle {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 1.5px rgba(0,0,0,0.15);
}
.lang-flag-circle svg,
.lang-flag-circle img { width: 100%; height: 100%; display: block; object-fit: cover; }

.lang-chevron {
  display: inline-block;
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}
.lang-btn[aria-expanded="true"] .lang-chevron { transform: rotate(180deg); }

.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
  padding: 5px;
  min-width: 175px;
  z-index: 300;
  display: none;
}
[data-theme="dark"] .lang-menu { box-shadow: 0 8px 24px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.3); }
.lang-menu.open { display: block; animation: fadeIn 0.15s ease; }

.lang-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: none;
  background: none;
  cursor: pointer;
  width: 100%;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  font-family: inherit;
  transition: background var(--transition);
  text-align: left;
}
.lang-menu-item:hover { background: var(--bg-hover); }
.lang-menu-item .lang-name { font-size: 0.775rem; font-weight: 400; color: var(--text-muted); margin-left: auto; }

.user-avatar {
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: white;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: opacity var(--transition);
}
.user-avatar:hover { opacity: 0.85; }

.dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 0.5rem;
  min-width: 200px;
  z-index: 200;
  display: none;
}
.dropdown.open { display: block; animation: fadeIn 0.15s ease; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
  transition: background var(--transition);
  background: none;
  border: none;
  width: 100%;
  text-align: left;
}
.dropdown-item:hover { background: var(--bg-hover); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-divider { height: 1px; background: var(--border); margin: 0.375rem 0; }

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
.app-sidebar {
  grid-area: sidebar;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0.75rem;
  overflow-y: auto;
  height: calc(100vh - var(--header-h));
  position: sticky;
  top: var(--header-h);
  transition: background var(--transition), border-color var(--transition);
}

.sidebar-section { margin-bottom: 0.75rem; }
.sidebar-divider { border: none; border-top: 1px solid var(--border); margin: 0 0.75rem 0.75rem; }
.sidebar-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 0.75rem;
  margin-bottom: 0.375rem;
}
.sidebar-label-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.sidebar-label-toggle:hover { color: var(--text); }
.sidebar-collapse-icon { width: 13px; height: 13px; flex-shrink: 0; transition: transform 0.2s; }
.sidebar-section.collapsed .sidebar-collapse-icon { transform: rotate(-90deg); }
.sidebar-section.collapsed .sidebar-collapsible,
.sidebar-section.collapsed #domainSearchWrap { display: none; }

/* ── Collapse-to-icons (shared by Catalog/Workspace/Admin sidebars) ──────── */
/* Desktop-only: scoped to min-width:901px so it never competes with the
   mobile drawer breakpoint below — without this, the attribute selector's
   higher specificity could win over the mobile media query on some
   properties (e.g. grid-template-columns) and leave the layout in a mixed,
   broken state while shrinking past 900px. */
@media (min-width: 901px) {
  [data-sidebar-collapsed="true"] .app-layout:not(.no-sidebar) { grid-template-columns: var(--sidebar-w-icons) 1fr; }
  [data-sidebar-collapsed="true"] .app-sidebar,
  [data-sidebar-collapsed="true"] .admin-sidebar {
    width: var(--sidebar-w-icons);
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
  /* Detail page sidebar collapse */
  [data-sidebar-collapsed="true"] .detail-nav-col { width: var(--sidebar-w-icons); min-width: var(--sidebar-w-icons); }
  /* Settings page sidebar collapse */
  [data-sidebar-collapsed="true"] .settings-nav-col { width: var(--sidebar-w-icons); }
  [data-sidebar-collapsed="true"] .settings-nav-btn { justify-content: center; padding-left: 0.5rem; padding-right: 0.5rem; }
  [data-sidebar-collapsed="true"] .settings-nav-btn-label,
  [data-sidebar-collapsed="true"] .settings-nav-label { display: none; }
  [data-sidebar-collapsed="true"] .detail-nav { padding-left: 0.5rem; padding-right: 0.5rem; }
  [data-sidebar-collapsed="true"] .detail-nav-btn { justify-content: center; padding-left: 0.5rem; padding-right: 0.5rem; }
  [data-sidebar-collapsed="true"] .detail-nav-btn span { display: none; }
  [data-sidebar-collapsed="true"] .detail-nav-group-label,
  [data-sidebar-collapsed="true"] .detail-nav-divider { display: none; }
  /* Shared item rules */
  [data-sidebar-collapsed="true"] .filter-item,
  [data-sidebar-collapsed="true"] .admin-nav-item {
    justify-content: center;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
  /* First child of each item is always the icon/dot — keep it, hide the rest */
  [data-sidebar-collapsed="true"] .filter-item > *:not(:first-child),
  [data-sidebar-collapsed="true"] .admin-nav-item > *:not(:first-child) {
    display: none;
  }
  [data-sidebar-collapsed="true"] .sidebar-label,
  [data-sidebar-collapsed="true"] .sidebar-label-toggle,
  [data-sidebar-collapsed="true"] .sidebar-divider,
  [data-sidebar-collapsed="true"] #domainSearchWrap {
    display: none;
  }
  [data-sidebar-collapsed="true"] .sidebar-collapse-toggle { justify-content: center; padding-left: 0.5rem; padding-right: 0.5rem; }
  [data-sidebar-collapsed="true"] .sidebar-collapse-toggle .lucide { transform: rotate(180deg); }
  [data-sidebar-collapsed="true"] .sidebar-collapse-toggle-label { display: none; }
  [data-sidebar-collapsed="true"] .sidebar-auto-row { display: none; }
}
.sidebar-collapse-toggle {
  display: flex; align-items: center; gap: 0.5rem;
  width: 100%; margin-top: 0.5rem; padding: 0.5rem 0.75rem;
  border: none; background: none; border-radius: var(--radius);
  color: var(--text-muted); font-size: 0.8rem; cursor: pointer;
  font-family: inherit; transition: background var(--transition), color var(--transition);
}
.sidebar-collapse-toggle:hover { background: var(--bg-hover); color: var(--text); }
.sidebar-collapse-toggle .lucide { flex-shrink: 0; transition: transform 0.2s; }
.sidebar-auto-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.4rem 0.75rem; font-size: 0.72rem; color: var(--text-muted);
}
.sidebar-bottom { margin-top: auto; padding-top: 0.5rem; border-top: 1px solid var(--border); }
.app-sidebar, .admin-sidebar { display: flex; flex-direction: column; }

.filter-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
  user-select: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.filter-item:hover { background: var(--bg-hover); color: var(--text); }
.filter-item.active { background: var(--primary-extralight); color: var(--primary); font-weight: 500; }
.filter-item:focus-visible,
.sidebar-label-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.filter-icon {
  width: 24px; height: 24px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.filter-count {
  margin-left: auto;
  font-size: 0.75rem;
  background: var(--bg);
  color: var(--text-muted);
  border-radius: var(--radius-full);
  padding: 0.1rem 0.5rem;
  min-width: 22px;
  text-align: center;
  font-weight: 500;
}
.filter-item.active .filter-count { background: var(--primary); color: white; }
.filter-count.loading { color: transparent; animation: filter-count-pulse 1.3s ease-in-out infinite; }
@keyframes filter-count-pulse {
  0%, 100% { background: var(--bg); }
  50% { background: var(--border); }
}

/* ── Active filter chips ──────────────────────────────────────────────────── */
.filter-chips {
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center;
  margin: 0.25rem 0 1rem;
}
.filter-chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--primary-extralight); color: var(--primary);
  border-radius: var(--radius-full);
  padding: 0.25rem 0.4rem 0.25rem 0.75rem;
  font-size: 0.78rem; font-weight: 500;
}
.filter-chip button {
  background: none; border: none; cursor: pointer; color: inherit;
  display: flex; align-items: center; padding: 0.15rem; border-radius: 50%;
  opacity: 0.75;
}
.filter-chip button:hover { opacity: 1; background: rgba(0,0,0,0.08); }
.filter-chip button .lucide { width: 0.85em; height: 0.85em; }
.filter-chip-clear {
  background: none; border: none; cursor: pointer;
  font-size: 0.78rem; color: var(--text-muted); text-decoration: underline;
  padding: 0.25rem 0.4rem;
}
.filter-chip-clear:hover { color: var(--text); }

/* ── Side panel (shared slide-over primitive) ────────────────────────────── */
.side-panel-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(0,0,0,0);
  display: none; justify-content: flex-end;
  transition: background 0.25s ease;
}
.side-panel-overlay.visible { display: flex; }
.side-panel-overlay.open { background: rgba(0,0,0,0.4); }
.side-panel {
  width: 440px; max-width: 92vw; height: 100%;
  background: var(--bg-card); border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  overflow-y: auto;
  display: flex; flex-direction: column;
}
.side-panel-overlay.open .side-panel { transform: translateX(0); }
.side-panel-header {
  display: flex; align-items: flex-start; gap: 0.75rem;
  padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg-card); z-index: 1;
}
.side-panel-close {
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  margin-left: auto; flex-shrink: 0; padding: 0.25rem;
}
.side-panel-close:hover { color: var(--text); }
.side-panel-body { padding: 1.5rem; flex: 1; }
.side-panel-footer {
  padding: 1rem 1.5rem; border-top: 1px solid var(--border);
  display: flex; gap: 0.75rem; justify-content: flex-end;
  position: sticky; bottom: 0; background: var(--bg-card);
}

/* Type icon colors */
.type-table    { background: rgba(61,100,120,0.12); color: var(--c-table); }
.type-view     { background: rgba(59,130,246,0.12); color: var(--c-view); }
.type-dashboard{ background: rgba(34,197,94,0.12);  color: var(--c-dashboard); }
.type-kpi      { background: rgba(245,158,11,0.12); color: var(--c-kpi); }
.type-report   { background: rgba(239,68,68,0.12);  color: var(--c-report); }
.type-dataset  { background: rgba(148,163,184,0.12);color: var(--c-dataset); }
.type-playbook { background: var(--playbook-icon-bg); color: var(--c-playbook); }

/* ── Playbook cards ─────────────────────────────────────────────────────────── */
.item-card.playbook-card {
  background: var(--playbook-bg);
  border-color: var(--playbook-border);
}
.item-card.playbook-card:hover {
  border-color: var(--c-playbook);
}
.playbook-card .card-excerpt {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.playbook-card .card-footer-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: auto;
  padding-top: 0.5rem;
  border-top: 1px solid var(--playbook-border);
}
.playbook-card .card-footer-meta i {
  width: 12px;
  height: 12px;
}
.badge-playbook {
  background: var(--playbook-icon-bg);
  color: var(--c-playbook);
  border: 1px solid var(--playbook-border);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
}
/* List-view row for playbooks */
.list-item.playbook-list-item {
  background: var(--playbook-bg);
  border-color: var(--playbook-border);
}
.list-item.playbook-list-item:hover {
  border-color: var(--c-playbook);
}

/* ── Main Content ───────────────────────────────────────────────────────────── */
.app-main {
  grid-area: main;
  padding: 1.5rem;
  overflow-y: auto;
  min-height: 0;
}

/* ── Toolbar ────────────────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.results-count {
  font-size: 0.875rem;
  color: var(--text-secondary);
}
.results-count strong { color: var(--text); }

.toolbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.view-toggle button {
  padding: 0.375rem 0.625rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.875rem;
  transition: background var(--transition), color var(--transition);
}
.view-toggle button.active { background: var(--primary); color: white; }
.view-toggle button:hover:not(.active) { background: var(--bg-hover); color: var(--text); }

.sort-select {
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.875rem;
  cursor: pointer;
  outline: none;
}

/* ── Cards Grid ─────────────────────────────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.item-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  position: relative;
  overflow: hidden;
  color: var(--text);
}
.item-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--primary);
}

.card-header {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  margin-bottom: 0.75rem;
}

.favorite-star {
  background: none; border: none; cursor: pointer; padding: 0.2rem;
  color: var(--text-muted); flex-shrink: 0; line-height: 1;
  border-radius: var(--radius-sm); transition: color 0.15s, transform 0.1s;
}
.favorite-star:hover { color: #F59E0B; transform: scale(1.1); }
.favorite-star.active { color: #F59E0B; }
.favorite-star.active .lucide { fill: #F59E0B; }
#favoritesFilterBtn.active { background: rgba(245,158,11,0.12); color: #B45309; font-weight: 500; }
[data-theme="dark"] #favoritesFilterBtn.active { color: #FBBF24; }

.card-type-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.125rem;
  flex-shrink: 0;
}

.card-title-area { flex: 1; min-width: 0; }
.card-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.125rem;
}
.card-path {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-description {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 0.875rem;
  min-height: 2.5em;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.775rem;
  color: var(--text-muted);
}
.card-meta svg { flex-shrink: 0; }

.card-footer {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-wrap: wrap;
}

/* ── List View ──────────────────────────────────────────────────────────────── */
.items-list { display: flex; flex-direction: column; gap: 0.5rem; }

.list-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition: box-shadow var(--transition), border-color var(--transition);
}
.list-item:hover { box-shadow: var(--shadow-sm); border-color: var(--primary); }

.list-item-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.list-item-name { font-weight: 600; font-size: 0.9rem; min-width: 180px; }
.list-item-desc {
  flex: 1;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item-owner { font-size: 0.8rem; color: var(--text-muted); min-width: 120px; text-align: right; }

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.625rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Inline quick-edit (Workspace Data Assets table) ─────────────────────── */
.badge-select {
  border: none; cursor: pointer; appearance: none;
  padding: 0.2rem 1.4rem 0.2rem 0.625rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23475569' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
}
.inline-editable { cursor: pointer; border-radius: var(--radius-sm); padding: 0.1rem 0.3rem; margin: -0.1rem -0.3rem; }
.inline-editable:hover { background: var(--bg-hover); }
.inline-edit-input {
  width: 100%; border: 1px solid var(--primary); border-radius: var(--radius-sm);
  padding: 0.2rem 0.4rem; font-size: inherit; font-family: inherit;
  background: var(--bg-card); color: var(--text); outline: none;
}

/* ── Quality-gap facet chips + bulk action toolbar ───────────────────────── */
.filter-chip-toggle {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-full);
  padding: 0.3rem 0.75rem; font-size: 0.78rem; color: var(--text-secondary);
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.filter-chip-toggle:hover { border-color: var(--primary); }
.filter-chip-toggle.active { background: var(--primary-extralight); border-color: var(--primary); color: var(--primary); font-weight: 600; }

.bulk-toolbar {
  display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
  background: var(--primary-extralight); border: 1px solid var(--primary);
  border-radius: var(--radius-lg); padding: 0.6rem 0.9rem; margin-bottom: 1rem;
}
.bulk-toolbar.hidden { display: none; }
#bulkSelectedCount { font-size: 0.82rem; font-weight: 600; color: var(--primary); margin-right: 0.4rem; }

/* ── /detail Activity tab ────────────────────────────────────────────────── */
/* Keep old history styles for backward compat */
.history-timeline { display: flex; flex-direction: column; gap: 0.9rem; }
.history-entry { display: flex; align-items: flex-start; gap: 0.7rem; }
.history-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-top: 0.4rem; flex-shrink: 0; }
.history-entry-body { font-size: 0.85rem; }

/* New unified Activity feed */
/* Outer activity card — no global padding, sections manage their own */
.activity-section-card { padding: 0 !important; overflow: hidden; }
.activity-card-title { font-size: 1rem; font-weight: 600; margin: 0; }

.activity-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.85rem 1.25rem; flex-wrap: wrap; gap: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.activity-filters { display: flex; gap: 0.25rem; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 0.2rem; }
.activity-filter-btn {
  background: none; border: 1px solid transparent; border-radius: 6px;
  padding: 0.3rem 0.85rem; font-size: 0.8rem; font-weight: 500;
  color: var(--text-muted); cursor: pointer; font-family: inherit;
  transition: all var(--transition);
}
.activity-filter-btn.active { background: var(--bg-card); border-color: var(--border); color: var(--text); font-weight: 600; }
.activity-comment-input { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.activity-textarea {
  width: 100%; resize: vertical; min-height: 72px;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.6rem 0.85rem; font-size: 0.875rem;
  background: var(--bg-card); color: var(--text); font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.activity-textarea:focus { outline:none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-extralight); }
.activity-feed { padding: 0; }
.activity-entry { display: flex; gap: 0.85rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.activity-entry:last-child { border-bottom: none; }
.activity-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: var(--primary-extralight); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; margin-top: 0.1rem;
}
.activity-avatar--system { background: var(--bg); border: 1px solid var(--border); color: var(--text-muted); }
.activity-body { flex: 1; min-width: 0; }
.activity-text { font-size: 0.875rem; margin-bottom: 0.25rem; }
.activity-badge { display: inline-flex; align-items: center; font-size: 0.7rem; font-weight: 600; padding: 0.15rem 0.5rem; border-radius: 100px; margin-left: 0.4rem; }
.activity-badge--change { background: rgba(148,163,184,0.15); color: var(--text-muted); }
.activity-badge--comment { background: var(--primary-extralight); color: var(--primary); }
.activity-comment-bubble {
  margin: 0.35rem 0 0.3rem; padding: 0.55rem 0.85rem;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 0 10px 10px 10px; font-size: 0.875rem; line-height: 1.6; color: var(--text);
}
.activity-meta { font-size: 0.78rem; color: var(--text-muted); display: flex; align-items: center; gap: 0.75rem; }
.activity-delete-btn { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 0; display:inline-flex; align-items:center; gap:0.2rem; font-size:0.75rem; transition: color var(--transition); }
.activity-delete-btn:hover { color: var(--danger, #ef4444); }

.badge-active     { background: #D1FAE5; color: #065F46; }
.badge-draft      { background: #FEF3C7; color: #92400E; }
.badge-deprecated { background: #FEE2E2; color: #991B1B; }
.badge-archived   { background: #F1F5F9; color: #475569; }

[data-theme="dark"] .badge-active     { background: rgba(16,185,129,0.2); color: #6EE7B7; }
[data-theme="dark"] .badge-draft      { background: rgba(245,158,11,0.2); color: #FCD34D; }
[data-theme="dark"] .badge-deprecated { background: rgba(239,68,68,0.2); color: #FCA5A5; }
[data-theme="dark"] .badge-archived   { background: rgba(148,163,184,0.1); color: #94A3B8; }

.badge-public       { background: #D1FAE5; color: #065F46; }
.badge-internal     { background: #DBEAFE; color: #1E40AF; }
.badge-confidential { background: #FEF3C7; color: #92400E; }
.badge-restricted   { background: #FEE2E2; color: #991B1B; }

[data-theme="dark"] .badge-internal   { background: rgba(61,100,120,0.2); color: #93C5FD; }

/* ── Tags ───────────────────────────────────────────────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  background: var(--bg);
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 500;
  border: 1px solid var(--border);
}
[data-theme="dark"] .tag { background: var(--bg-hover); }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
  white-space: nowrap;
  font-family: inherit;
}
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-hover); box-shadow: var(--shadow-sm); }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #DC2626; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:disabled:active { transform: none; }

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.375rem;
}
.form-label span.required { color: var(--danger); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 0.5625rem 0.875rem;
  border: 1px solid var(--border-input);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(61,100,120,0.12);
}
.form-control::placeholder { color: var(--text-muted); }

textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control { cursor: pointer; }

.form-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }
.form-error { font-size: 0.8rem; color: var(--danger); margin-top: 0.25rem; }
.form-control.is-invalid { border-color: var(--danger); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

/* Tag input */
.tag-input-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  padding: 0.375rem 0.625rem;
  border: 1px solid var(--border-input);
  border-radius: var(--radius);
  background: var(--bg-input);
  min-height: 42px;
  cursor: text;
  transition: border-color var(--transition);
}
.tag-input-container:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(61,100,120,0.12); }
.tag-input-container .tag { cursor: default; }
.tag-input-container .tag button {
  background: none; border: none; cursor: pointer;
  color: inherit; padding: 0; margin-left: 2px;
  font-size: 0.75rem; line-height: 1;
}
.tag-input-container input {
  border: none; outline: none; background: transparent;
  color: var(--text); font-size: 0.875rem; font-family: inherit;
  flex: 1; min-width: 80px;
}

/* ── Modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.15s ease;
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.2s ease;
  position: relative;
}

.modal-lg { max-width: 860px; }
.modal-xl { max-width: 1100px; }

.modal-header {
  padding: 1.5rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}
.modal-title { font-size: 1.125rem; font-weight: 600; flex: 1; }
.modal-subtitle { font-size: 0.8125rem; color: var(--text-muted); margin-top: 0.125rem; }
.modal-close {
  width: 32px; height: 32px;
  border: none; background: transparent;
  color: var(--text-muted); border-radius: var(--radius);
  cursor: pointer; font-size: 1.25rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text); }

.modal-body { padding: 1.5rem; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Quick view modal specifics */
.qv-header {
  display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem;
}
.qv-type-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.qv-name { font-size: 1.25rem; font-weight: 600; }
.qv-path { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

.qv-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
  background: var(--bg);
  border-radius: var(--radius);
  padding: 0.875rem;
  margin-bottom: 1.25rem;
  border-left: 3px solid var(--primary);
}

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.875rem;
  margin-bottom: 1.25rem;
}
.meta-item label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.25rem;
}
.meta-item value {
  font-size: 0.875rem;
  color: var(--text);
  font-weight: 500;
  display: block;
}
.meta-item value.empty { color: var(--text-muted); font-weight: 400; font-style: italic; }

/* Properties edit rows */
.extra-edit-row {
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

/* ── Tabs ───────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
  overflow-x: auto;
}

.tab-btn {
  padding: 0.75rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Table ──────────────────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg-card); }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.data-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg-hover);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-hover); }
.data-table .monospace { font-family: 'Courier New', monospace; font-size: 0.8rem; }
.data-table .text-muted { color: var(--text-muted); }
.data-table .icon-check { color: var(--success); }
.data-table .icon-x { color: var(--text-muted); }

/* ── Pagination ─────────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  margin-top: 1.5rem;
}
.page-btn {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.875rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  font-family: inherit;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Cards Stats ─────────────────────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: box-shadow var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.stat-content {}
.stat-value { font-size: 1.625rem; font-weight: 600; line-height: 1; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }

/* ── Admin Sidebar ───────────────────────────────────────────────────────────── */
.admin-layout {
  display: flex;
  min-height: calc(100vh - var(--header-h));
}

.admin-sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0.75rem;
  flex-shrink: 0;
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  overflow-x: hidden;
  transition: width var(--transition);
}

.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.admin-nav-item:hover { background: var(--bg-hover); color: var(--text); }
.admin-nav-item.active { background: var(--primary-extralight); color: var(--primary); font-weight: 600; }
.admin-nav-item .nav-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }
.admin-nav-item .nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.admin-content { flex: 1; padding: 2rem; overflow-y: auto; }
.admin-page { display: none; }
.admin-page.active { display: block; }
.admin-page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem;
}
.admin-page-title { font-size: 1.25rem; font-weight: 600; }

/* ── Lineage Graph ───────────────────────────────────────────────────────────── */
.lineage-graph {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  overflow-x: auto;
  min-height: 200px;
  position: relative;
}

/* ── Lineage graph — CSS renderer (same pattern as ERD) ────────────────────── */
:root {
  --ln-dbt:    #6366F1;
  --ln-view:   #059669;
  --ln-excel:  #0EA5E9;
  --ln-manual: #94A3B8;
  --ln-focus-glow: 0 0 0 3px rgba(37,99,235,.18);
}
[data-theme="dark"] {
  --ln-dbt:    #818CF8;
  --ln-view:   #34D399;
  --ln-excel:  #38BDF8;
  --ln-manual: #64748B;
}

.lineage-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  color: var(--text-muted);
  font-size: 0.9rem;
  gap: 0.75rem;
}
.lineage-empty .big-icon { font-size: 2.5rem; }

/* Scroll wrapper */
.lineage-graph-scroll {
  overflow: auto;
  padding: 1.5rem 1.5rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 0.75rem;
}

/* Canvas — sized by JS */
.ln-canvas {
  position: relative;
  display: inline-block;
}

/* SVG connector layer */
.ln-connectors {
  position: absolute;
  inset: 0;
  overflow: visible;
  pointer-events: none;
  z-index: 0;
}

/* Column label */
.ln-col-label {
  position: absolute;
  text-align: center;
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Node cards */
.ln-node {
  position: absolute;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  user-select: none;
  transition: box-shadow .15s, border-color .15s, transform .15s;
  z-index: 2;
  overflow: hidden;
}
.ln-node:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
  transform: translateY(-1px);
}
.ln-node.ln-focus {
  border: 2px solid var(--primary);
  box-shadow: var(--shadow-md), var(--ln-focus-glow);
}
.ln-node-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.625rem 0.3rem;
}
.ln-node-icon {
  width: 28px; height: 28px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ln-node-icon svg { display: block; }
.ln-type-TABLE   { background: #DBEAFE; color: #1D4ED8; }
.ln-type-VIEW    { background: #D1FAE5; color: #065F46; }
.ln-type-KPI     { background: #FEF3C7; color: #92400E; }
.ln-type-DASHBOARD { background: #F3E8FF; color: #6D28D9; }
.ln-type-REPORT  { background: #FCE7F3; color: #9D174D; }
.ln-type-DATASET { background: #E0F2FE; color: #075985; }
[data-theme="dark"] .ln-type-TABLE   { background: #1E3A5F; color: #93C5FD; }
[data-theme="dark"] .ln-type-VIEW    { background: #064E3B; color: #6EE7B7; }
[data-theme="dark"] .ln-type-KPI     { background: #451A03; color: #FCD34D; }
[data-theme="dark"] .ln-type-DASHBOARD { background: #3B0764; color: #C4B5FD; }
[data-theme="dark"] .ln-type-REPORT  { background: #500724; color: #FBCFE8; }
[data-theme="dark"] .ln-type-DATASET { background: #0C4A6E; color: #7DD3FC; }
.ln-node-name {
  font-size: 0.78rem; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1; min-width: 0;
}
.ln-node-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.375rem; padding: 0 0.625rem 0.5rem;
}
.ln-node-meta {
  font-size: 0.68rem; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Source badges (shared between graph nodes and import preview tables) */
.ln-badge {
  font-size: 0.6rem; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; padding: 1px 5px 2px; border-radius: 4px;
  flex-shrink: 0; line-height: 1.4; white-space: nowrap;
}
.ln-badge.dbt     { background: #EDE9FE; color: #5B21B6; }
.ln-badge.view_sql{ background: #D1FAE5; color: #065F46; }
.ln-badge.excel   { background: #E0F2FE; color: #0369A1; }
.ln-badge.manual  { background: #F1F5F9; color: #64748B; }
[data-theme="dark"] .ln-badge.dbt     { background: #2E1065; color: #C4B5FD; }
[data-theme="dark"] .ln-badge.view_sql{ background: #064E3B; color: #6EE7B7; }
[data-theme="dark"] .ln-badge.excel   { background: #0C4A6E; color: #7DD3FC; }
[data-theme="dark"] .ln-badge.manual  { background: #1E293B; color: #94A3B8; }

/* Legend */
.ln-legend {
  display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
  padding: 0.5rem 0.25rem;
  font-size: 0.72rem; color: var(--text-sec);
}
.ln-legend-item { display: flex; align-items: center; gap: 0.35rem; }
.ln-legend-line { width: 22px; height: 0; border-radius: 1px; flex-shrink: 0; }
.ln-legend-line.dbt     { border-top: 2px dashed var(--ln-dbt); }
.ln-legend-line.view_sql{ border-top: 2px solid var(--ln-view); }
.ln-legend-line.excel   { border-top: 2px solid var(--ln-excel); }
.ln-legend-line.manual  { border-top: 2px solid var(--ln-manual); }

/* ── Detail page ─────────────────────────────────────────────────────────────── */
/* ── Detail page — new sidebar layout ─────────────────────────────────── */
.detail-breadcrumb-bar {
  padding: 0.35rem 1.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  font-size: 0.8rem;
}

.detail-layout {
  display: flex;
  min-height: calc(100vh - var(--header-h));
}

/* Sidebar column — fixed height + sticky, exactly like .admin-sidebar in workspace */
.detail-nav-col {
  width: 220px;
  min-width: 220px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  overflow-x: hidden;
  transition: width var(--transition);
}

/* Nav fills the sticky column so sidebar-bottom always pins to the bottom */
.detail-nav {
  width: 100%;
  padding: 1.25rem 0.75rem;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.detail-nav-group-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.75rem 0.5rem 0.3rem;
}
.detail-nav-group-label:first-child { padding-top: 0.1rem; }
.detail-nav-divider { height: 1px; background: var(--border); margin: 0.4rem 0.25rem; }
.detail-nav-btn {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.detail-nav-btn:hover { background: var(--bg-hover); color: var(--text); }
.detail-nav-btn.active { background: var(--primary-extralight); color: var(--primary); font-weight: 600; }
.detail-nav-btn .lucide { width: 16px; height: 16px; flex-shrink: 0; }

.detail-body { flex: 1; min-width: 0; overflow-y: auto; padding: 0 1.5rem 2rem; }

/* Editor wrap — no outer border; the .doc-section-card provides the container */
#docEditorWrap {
  background: var(--bg-card);
  overflow: hidden;
  min-height: 120px;
}

@media (max-width: 900px) {
  .detail-layout { flex-direction: column; }
  .detail-nav-col { width: 100%; min-width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .detail-nav {
    width: 100%; height: auto; position: static;
    display: flex; flex-direction: row; overflow-x: auto;
    padding: 0.5rem;
  }
  .detail-nav-group-label, .detail-nav-divider { display: none; }
  .detail-body { padding: 0 0.75rem 1.5rem; }
}

.detail-header {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2rem;
  margin-bottom: 1.5rem;
}

.detail-title-row {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
.detail-type-icon {
  width: 64px; height: 64px;
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.75rem;
  flex-shrink: 0;
}
.detail-title { font-size: 1.75rem; font-weight: 600; line-height: 1.2; }
.detail-badges { display: flex; gap: 0.5rem; margin-top: 0.625rem; flex-wrap: wrap; }
.detail-actions { margin-left: auto; display: flex; gap: 0.5rem; }

.detail-owners {
  display: flex;
  gap: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.owner-block label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.25rem;
}
.owner-block .owner-name { font-weight: 600; font-size: 0.9rem; }
.owner-block .owner-email { font-size: 0.8rem; color: var(--text-muted); }

/* ── Documentation tab ───────────────────────────────────────────────────────── */
/* Outer card — no global padding; each inner section manages its own spacing */
.doc-section-card { padding: 0 !important; overflow: hidden; }

/* Header row with divider below */
.doc-tab-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.doc-tab-title { font-size: 1rem; font-weight: 600; margin: 0 0 0.2rem; }
.doc-tab-subtitle { font-size: 0.82rem; color: var(--text-muted); margin: 0; }
.doc-tab-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

.doc-toolbar {
  display: flex; gap: 0.2rem; flex-wrap: wrap;
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.doc-toolbar-btn {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 28px;
  border: none; background: none; border-radius: 5px;
  cursor: pointer; color: var(--text-secondary); font-size: 0.8rem;
  font-weight: 600; font-family: inherit;
  transition: background var(--transition), color var(--transition);
}
.doc-toolbar-btn:hover { background: var(--bg-hover); color: var(--text); }
.doc-toolbar-btn.is-active { background: var(--primary-extralight); color: var(--primary); }
.doc-toolbar-btn .lucide { width: 14px; height: 14px; }

/* Table picker — fixed positioning via JS */
.doc-table-picker {
  position: fixed; z-index: 9999;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg, 0 8px 30px rgba(0,0,0,0.15));
  padding: 0.6rem; user-select: none;
}
.doc-table-picker-grid { display: grid; grid-template-columns: repeat(5,1fr); gap: 3px; margin-bottom: 0.4rem; }
.doc-table-picker-cell {
  width: 22px; height: 22px; border-radius: 3px;
  border: 1px solid var(--border); background: var(--bg); cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.doc-table-picker-cell.highlighted { background: var(--primary-extralight); border-color: var(--primary); }
.doc-table-picker-label { font-size: 0.75rem; color: var(--text-muted); text-align: center; min-width: 56px; }

/* Floating bubble menu above tables */
.doc-bubble-menu {
  position: fixed; z-index: 9999;
  display: flex; align-items: center; gap: 0.15rem;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.25rem 0.4rem;
  box-shadow: var(--shadow-lg, 0 8px 24px rgba(0,0,0,0.15));
  font-size: 0.78rem;
}
.doc-bubble-menu button {
  display: flex; align-items: center; gap: 0.25rem;
  background: none; border: none; cursor: pointer;
  color: var(--text-secondary); border-radius: 5px;
  padding: 0.25rem 0.5rem; font-size: 0.78rem; font-family: inherit;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.doc-bubble-menu button:hover { background: var(--bg-hover); color: var(--text); }
.doc-bubble-menu button.is-danger:hover { color: var(--danger, #ef4444); }
.doc-bubble-menu .lucide { width: 13px; height: 13px; }
.doc-bubble-sep { width: 1px; height: 18px; background: var(--border); margin: 0 0.1rem; }

/* Color palette dropdown */
.doc-color-palette {
  position: fixed; z-index: 9999;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg, 0 8px 24px rgba(0,0,0,0.15));
  padding: 0.5rem; width: 168px;
}
.doc-color-palette-label { font-size: 0.7rem; font-weight: 600; color: var(--text-muted); padding: 0 0.2rem 0.3rem; letter-spacing: 0.04em; }
.doc-color-grid { display: grid; grid-template-columns: repeat(6,1fr); gap: 3px; }
.doc-color-swatch {
  width: 22px; height: 22px; border-radius: 4px;
  cursor: pointer; border: 2px solid transparent;
  transition: border-color var(--transition), transform var(--transition);
  position: relative;
}
.doc-color-swatch:hover { transform: scale(1.15); border-color: var(--primary); }
.doc-color-swatch.is-none { background: var(--bg); border-color: var(--border) !important; }
.doc-color-swatch.is-none::after { content:'✕'; position:absolute; inset:0; display:flex; align-items:center; justify-content:center; font-size:11px; color:var(--text-muted); }

/* Color toolbar button — shows indicator bar below letter */
.doc-color-btn { position: relative; padding-bottom: 2px !important; }
.doc-color-indicator {
  position: absolute; bottom: 2px; left: 4px; right: 4px; height: 3px; border-radius: 2px;
  background: currentColor; pointer-events: none;
}

/* Link / image inline popover */
.doc-inline-popover {
  position: fixed; z-index: 9999;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg, 0 8px 24px rgba(0,0,0,0.15));
  padding: 0.6rem; width: 280px;
  display: flex; flex-direction: column; gap: 0.5rem;
}
.doc-inline-popover input[type="url"], .doc-inline-popover input[type="text"] {
  width: 100%; padding: 0.45rem 0.65rem; font-size: 0.85rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text); font-family: inherit;
  outline: none;
}
.doc-inline-popover input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-extralight); }
.doc-inline-popover-row { display: flex; gap: 0.4rem; align-items: center; }
.doc-inline-popover-row label { font-size: 0.8rem; color: var(--text-muted); display:flex; align-items:center; gap:0.3rem; cursor:pointer; }
.doc-inline-popover-actions { display: flex; gap: 0.4rem; justify-content: flex-end; }
.doc-toolbar-sep { width: 1px; height: 18px; background: var(--border); margin: auto 0.3rem; }

/* TipTap editor area */
.doc-editor-area {
  padding: 1.25rem 1.75rem;
  min-height: 320px;
  outline: none;
  font-size: 0.9rem;
  line-height: 1.75;
  color: var(--text);
}
.doc-editor-area.doc-editor-readonly { cursor: default; }
.doc-editor-area:focus { outline: none; }
.doc-editor-area p { margin: 0 0 0.75rem; }
.doc-editor-area h1 { font-size: 1.5rem; font-weight: 700; margin: 1.25rem 0 0.5rem; }
.doc-editor-area h2 { font-size: 1.2rem; font-weight: 600; margin: 1rem 0 0.4rem; }
.doc-editor-area h3 { font-size: 1rem; font-weight: 600; margin: 0.75rem 0 0.3rem; }
.doc-editor-area ul, .doc-editor-area ol { padding-left: 1.5rem; margin: 0 0 0.75rem; }
.doc-editor-area li { margin-bottom: 0.25rem; }
.doc-editor-area blockquote {
  border-left: 3px solid var(--primary); padding-left: 1rem;
  color: var(--text-muted); margin: 0.75rem 0;
}
.doc-editor-area code {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 4px; padding: 0.1rem 0.4rem;
  font-size: 0.82rem; font-family: monospace;
}
/* Code block (lowlight) */
.doc-editor-area pre {
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  overflow-x: auto;
  font-size: 0.84rem;
  line-height: 1.65;
  position: relative;
}
[data-theme="light"] .doc-editor-area pre { background: #f6f8fa; }
.doc-editor-area pre code { background: none; border: none; padding: 0; font-size: inherit; color: #e6edf3; }
[data-theme="light"] .doc-editor-area pre code { color: #24292f; }
.doc-editor-area pre.hljs { background: none; padding: 0; }

/* Highlight.js token colors — dark (default) */
.doc-editor-area .hljs-comment, .doc-editor-area .hljs-quote { color: #8b949e; font-style: italic; }
.doc-editor-area .hljs-keyword, .doc-editor-area .hljs-selector-tag, .doc-editor-area .hljs-deletion { color: #ff7b72; }
.doc-editor-area .hljs-string, .doc-editor-area .hljs-addition { color: #a5d6ff; }
.doc-editor-area .hljs-number, .doc-editor-area .hljs-literal { color: #79c0ff; }
.doc-editor-area .hljs-built_in, .doc-editor-area .hljs-type { color: #ffa657; }
.doc-editor-area .hljs-function, .doc-editor-area .hljs-title { color: #d2a8ff; }
.doc-editor-area .hljs-variable, .doc-editor-area .hljs-template-variable { color: #e6edf3; }
.doc-editor-area .hljs-attr, .doc-editor-area .hljs-attribute { color: #79c0ff; }
.doc-editor-area .hljs-name, .doc-editor-area .hljs-tag { color: #7ee787; }
.doc-editor-area .hljs-operator, .doc-editor-area .hljs-punctuation { color: #e6edf3; }
.doc-editor-area .hljs-meta { color: #d29922; }

/* Highlight.js token colors — light theme */
[data-theme="light"] .doc-editor-area .hljs-comment, [data-theme="light"] .doc-editor-area .hljs-quote { color: #6e7781; }
[data-theme="light"] .doc-editor-area .hljs-keyword { color: #cf222e; }
[data-theme="light"] .doc-editor-area .hljs-string, [data-theme="light"] .doc-editor-area .hljs-addition { color: #0a3069; }
[data-theme="light"] .doc-editor-area .hljs-number, [data-theme="light"] .doc-editor-area .hljs-literal { color: #0550ae; }
[data-theme="light"] .doc-editor-area .hljs-built_in, [data-theme="light"] .doc-editor-area .hljs-type { color: #953800; }
[data-theme="light"] .doc-editor-area .hljs-function, [data-theme="light"] .doc-editor-area .hljs-title { color: #8250df; }
[data-theme="light"] .doc-editor-area .hljs-attr, [data-theme="light"] .doc-editor-area .hljs-attribute { color: #0550ae; }
[data-theme="light"] .doc-editor-area .hljs-name, [data-theme="light"] .doc-editor-area .hljs-tag { color: #116329; }
[data-theme="light"] .doc-editor-area .hljs-meta { color: #7d4e00; }
[data-theme="light"] .doc-editor-area .hljs-operator,
[data-theme="light"] .doc-editor-area .hljs-punctuation { color: #24292f; }
[data-theme="light"] .doc-editor-area .hljs-variable,
[data-theme="light"] .doc-editor-area .hljs-template-variable { color: #005cc5; }

/* Code block language bubble — floats top-right inside the block */
.doc-code-lang-bubble {
  position: fixed; z-index: 9999;
}
.doc-code-lang-bubble select {
  background: rgba(30,40,50,0.75);
  color: #c9d1d9;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 5px;
  font-size: 0.72rem;
  font-family: inherit;
  padding: 0.18rem 0.5rem;
  cursor: pointer;
  outline: none;
  backdrop-filter: blur(4px);
  transition: background var(--transition), border-color var(--transition);
}
.doc-code-lang-bubble select:hover,
.doc-code-lang-bubble select:focus { background: rgba(30,40,50,0.92); border-color: rgba(255,255,255,0.25); }
[data-theme="light"] .doc-code-lang-bubble select {
  background: rgba(240,242,244,0.9);
  color: #24292f;
  border-color: rgba(0,0,0,0.18);
}
[data-theme="light"] .doc-code-lang-bubble select:hover,
[data-theme="light"] .doc-code-lang-bubble select:focus { background: rgba(240,242,244,1); }
.doc-editor-area table { border-collapse: collapse; width: 100%; margin: 0.75rem 0; }
.doc-editor-area th, .doc-editor-area td { border: 1px solid var(--border); padding: 0.5rem 0.75rem; }
.doc-editor-area th { background: var(--bg); font-weight: 600; }
.doc-editor-area img { max-width: 100%; border-radius: var(--radius); margin: 0.5rem 0; }
.doc-editor-area a { color: var(--primary); text-decoration: underline; }
.doc-editor-area hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
/* TipTap selected cell highlight */
.doc-editor-area .selectedCell::after { background: var(--primary-extralight); }
/* Editing indicator */
#docEditorWrap.is-editing { border-left: 2px solid var(--primary); }

/* ── @ Mention Dropdown ──────────────────────────────────────────────────────── */
.doc-mention-dropdown {
  position: fixed;
  z-index: 9999;
  min-width: 260px;
  max-width: 340px;
  max-height: 240px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.22);
  padding: 4px 0;
}
.doc-mention-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: background 0.12s;
}
.doc-mention-item:hover,
.doc-mention-item.active {
  background: var(--bg);
}
.doc-mention-item .mi-type {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg);
  color: var(--text-muted);
  flex-shrink: 0;
}
.doc-mention-item .mi-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.doc-mention-item .mi-domain {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.doc-mention-empty {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Empty State ─────────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  color: var(--text-muted);
}
.empty-icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.5; }
.empty-title { font-size: 1.125rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.5rem; }
.empty-desc { font-size: 0.875rem; max-width: 320px; }

/* ── Toast ──────────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 280px;
  max-width: 400px;
  font-size: 0.875rem;
  animation: slideLeft 0.3s ease;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info    { border-left: 4px solid var(--primary); }
.toast-icon { font-size: 1.125rem; flex-shrink: 0; }
.toast-msg { flex: 1; }
.toast-close { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 1.1rem; padding: 0; }

/* ── Loading ─────────────────────────────────────────────────────────────────── */
.spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
.spinner-sm { width: 16px; height: 16px; }

.skeleton {
  background: linear-gradient(90deg, var(--bg) 25%, var(--bg-hover) 50%, var(--bg) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}

/* ── Breadcrumb ──────────────────────────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  font-size: 0.8125rem;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); text-decoration: none; }
.breadcrumb .sep { color: var(--text-muted); }
.breadcrumb .current { color: var(--text-secondary); font-weight: 500; }

.back-to-catalog-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.82rem; font-weight: 600; color: var(--primary);
  margin-bottom: 0.6rem;
}
.back-to-catalog-btn:hover { text-decoration: underline; }
.back-to-catalog-btn .lucide { width: 0.9em; height: 0.9em; }

/* ── Related assets strip (/detail Overview) ─────────────────────────────── */
.related-assets-list { display: flex; flex-direction: column; gap: 0.75rem; }
.related-assets-group-label {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); font-weight: 600; margin-bottom: 0.4rem;
}
.related-assets-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.related-asset-card {
  display: flex; align-items: center; gap: 0.5rem;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 0.5rem 0.75rem; cursor: pointer; background: var(--bg);
  font-size: 0.82rem; transition: border-color 0.15s, background 0.15s;
}
.related-asset-card:hover { border-color: var(--primary); background: var(--bg-hover); }
.related-asset-card .lucide { color: var(--text-muted); }

/* ── Section card ─────────────────────────────────────────────────────────────── */
.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.section-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── Login page ──────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #EBF2F4 0%, #F8FAFB 100%);
  padding: 1.5rem;
}
[data-theme="dark"] .login-page {
  background: linear-gradient(135deg, #10171A 0%, #1A2429 100%);
}
.login-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
}
.login-logo {
  display: flex; flex-direction: column; align-items: center;
  margin-bottom: 2rem; text-align: center;
}
.login-logo-icon {
  width: 56px; height: 56px;
  background: var(--primary);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 1.5rem;
  margin-bottom: 1rem;
}
.login-logo h1 { font-size: 1.375rem; }
.login-logo p { font-size: 0.875rem; color: var(--text-muted); margin-top: 0.25rem; }
.login-divider {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  position: relative;
  margin: 1rem 0;
}
.login-divider::before, .login-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 24px);
  height: 1px;
  background: var(--border);
}
.login-divider::before { left: 0; }
.login-divider::after { right: 0; }
.btn-azure {
  background: #0078D4;
  color: white;
  width: 100%;
  padding: 0.625rem;
  font-size: 0.9rem;
}
.btn-azure:hover { background: #006AC1; }

/* ── Animations ─────────────────────────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideLeft { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
/* ── Hamburger trigger (hidden on desktop, shown only below the mobile breakpoint) ── */
.hamburger-btn { display: none; }

@media (max-width: 900px) {
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-areas: "header" "main";
  }
  .admin-layout { flex-direction: column; }

  .hamburger-btn { display: flex; }

  /* Mobile drawer — replaces collapse-to-icons entirely below this breakpoint */
  .app-sidebar, .admin-sidebar {
    display: none;
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    z-index: 200;
    width: 280px;
    box-shadow: var(--shadow-lg);
  }
  .app-sidebar.mobile-open, .admin-sidebar.mobile-open { display: flex; }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    top: var(--header-h); left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 190;
  }
  .sidebar-backdrop.open { display: block; }

  .cards-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .meta-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .detail-title { font-size: 1.25rem; }
  .detail-title-row { flex-direction: column; gap: 1rem; }
  .detail-actions { margin-left: 0; }
  .modal { border-radius: var(--radius-lg) var(--radius-lg) 0 0; align-self: flex-end; max-height: 95vh; }
  .modal-overlay { align-items: flex-end; padding: 0; }
}

/* ── Utility ─────────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--text-muted); }
.font-bold { font-weight: 600; }
.font-semibold { font-weight: 600; }
.w-full { width: 100%; }

/* ── Data Quality Score ─────────────────────────────────────────────────────── */
.quality-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  vertical-align: middle;
}
.quality-badge.excellent { background: rgba(16,185,129,0.13); color: #059669; }
.quality-badge.good      { background: rgba(61,100,120,0.12);  color: #3D6478; }
.quality-badge.fair      { background: rgba(245,158,11,0.13); color: #D97706; }
.quality-badge.poor      { background: rgba(239,68,68,0.12);  color: #DC2626; }
[data-theme="dark"] .quality-badge.excellent { background: rgba(16,185,129,0.2); color: #34D399; }
[data-theme="dark"] .quality-badge.good      { background: rgba(61,100,120,0.2);  color: #9CC4D1; }
[data-theme="dark"] .quality-badge.fair      { background: rgba(245,158,11,0.2); color: #FCD34D; }
[data-theme="dark"] .quality-badge.poor      { background: rgba(239,68,68,0.2);  color: #F87171; }

.quality-bar-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 0.5rem;
}
.quality-bar-label {
  font-size: 0.75rem;
  width: 80px;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.quality-bar-track {
  flex: 1;
  height: 7px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.quality-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.7s cubic-bezier(.4,0,.2,1);
}
.quality-bar-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 22px;
  text-align: right;
}

.quality-score-ring {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.quality-score-circle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 600;
  flex-shrink: 0;
}
.quality-score-circle.excellent { background: rgba(16,185,129,0.13); color: #059669; }
.quality-score-circle.good      { background: rgba(61,100,120,0.12);  color: #3D6478; }
.quality-score-circle.fair      { background: rgba(245,158,11,0.13); color: #D97706; }
.quality-score-circle.poor      { background: rgba(239,68,68,0.12);  color: #DC2626; }
[data-theme="dark"] .quality-score-circle.excellent { background: rgba(16,185,129,0.2); color: #34D399; }
[data-theme="dark"] .quality-score-circle.good      { background: rgba(61,100,120,0.2);  color: #9CC4D1; }
[data-theme="dark"] .quality-score-circle.fair      { background: rgba(245,158,11,0.2); color: #FCD34D; }
[data-theme="dark"] .quality-score-circle.poor      { background: rgba(239,68,68,0.2);  color: #F87171; }

.quality-breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.625rem;
  margin-top: 0.875rem;
}
.quality-dim-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
}
.quality-dim-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.2rem;
}
.quality-dim-score {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.quality-dim-max {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-left: 0.15rem;
}
.quality-dim-bar {
  height: 3px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: 0.35rem;
}
.quality-dim-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
}

.quality-low-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}
.quality-low-item:last-child { border-bottom: none; }
.quality-low-name {
  color: var(--primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
  text-decoration: none;
}
.quality-low-name:hover { text-decoration: underline; }

/* ── Tenant Admin Dashboard ───────────────────────────────────────────────── */

.dash-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius-lg);
  padding: 0.85rem 1.1rem;
  margin-bottom: 1.25rem;
}
[data-theme="dark"] .dash-banner { background: rgba(239,68,68,0.12); }
.dash-banner-icon { font-size: 1.1rem; flex-shrink: 0; }
.dash-banner-text { flex: 1; font-size: 0.85rem; color: var(--text); font-weight: 500; }
.dash-banner-action {
  font-size: 0.8rem; font-weight: 600; color: #DC2626; text-decoration: none; white-space: nowrap;
}
.dash-banner-action:hover { text-decoration: underline; }

.dash-grid-top {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}
.dash-hero-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  text-align: center;
}
.dash-hero-ring {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.8s ease;
}
.dash-hero-ring-inner {
  width: 108px;
  height: 108px;
  border-radius: 50%;
  background: var(--bg-card);
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.15rem;
}
.dash-hero-score { font-size: 2.1rem; font-weight: 600; }
.dash-hero-max { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }
.dash-hero-label { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.dash-hero-trend { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.2rem; }

.dash-coverage-card { margin-bottom: 0; }
.dash-coverage-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.7rem;
}
.dash-coverage-label { font-size: 0.8rem; width: 130px; color: var(--text-secondary); flex-shrink: 0; }
.dash-coverage-track {
  flex: 1; height: 8px; background: var(--border); border-radius: var(--radius-full); overflow: hidden;
}
.dash-coverage-fill { height: 100%; border-radius: var(--radius-full); transition: width 0.7s cubic-bezier(.4,0,.2,1); }
.dash-coverage-pct { font-size: 0.8rem; font-weight: 600; color: var(--text); min-width: 38px; text-align: right; }

.dash-action-center { margin-bottom: 1.25rem; }
.dash-action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-top: 0.75rem;
}
.dash-action-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.dash-action-item.severity-high   { border-left: 3px solid #DC2626; }
.dash-action-item.severity-medium { border-left: 3px solid #D97706; }
.dash-action-icon { font-size: 1.3rem; }
.dash-action-count { font-size: 1.6rem; font-weight: 600; color: var(--text); }
.dash-action-label { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0.3rem; }
.dash-action-btn {
  font-size: 0.78rem; font-weight: 600; color: var(--primary); text-decoration: none; margin-top: auto;
}
.dash-action-btn:hover { text-decoration: underline; }

.dash-grid-mid, .dash-grid-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.dash-conn-item {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}
.dash-conn-item:last-child { border-bottom: none; }
.dash-conn-dot {
  width: 9px; height: 9px; border-radius: 50%; margin-top: 0.35rem; flex-shrink: 0;
}
.dash-conn-dot.ok    { background: #10B981; }
.dash-conn-dot.error { background: #EF4444; }
.dash-conn-name { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.dash-conn-meta { font-size: 0.76rem; color: var(--text-muted); margin-top: 0.1rem; }

.dash-composition { display: flex; align-items: center; gap: 1.5rem; }
.dash-donut {
  width: 110px; height: 110px; border-radius: 50%; flex-shrink: 0;
  position: relative;
}
.dash-donut::after {
  content: '';
  position: absolute; inset: 22px;
  background: var(--bg-card); border-radius: 50%;
}
.dash-donut-legend { flex: 1; display: flex; flex-direction: column; gap: 0.4rem; }
.dash-legend-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.78rem; }
.dash-legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dash-legend-label { flex: 1; color: var(--text-secondary); }
.dash-legend-count { font-weight: 600; color: var(--text); }

.dash-activity-item {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}
.dash-activity-item:last-child { border-bottom: none; }
.dash-activity-icon { font-size: 1rem; flex-shrink: 0; }
.dash-activity-text { flex: 1; font-size: 0.8rem; color: var(--text-secondary); line-height: 1.4; }
.dash-activity-time { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; }

.dash-top-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}
.dash-top-row:last-child { border-bottom: none; }
.dash-top-name { flex: 1; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-top-views { color: var(--text-muted); font-size: 0.76rem; flex-shrink: 0; }
.dash-adoption-footer {
  margin-top: 0.85rem; padding-top: 0.75rem; border-top: 1px solid var(--border);
  font-size: 0.78rem; color: var(--text-muted); font-weight: 600;
}

@media (max-width: 900px) {
  .dash-grid-top, .dash-grid-mid, .dash-grid-bottom { grid-template-columns: 1fr; }
}

/* ── Plan upgrade badges on nav items ──────────────────────────────────── */
.plan-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.4rem;
  border-radius: 100px;
  margin-left: auto;
  flex-shrink: 0;
  pointer-events: none;
}
.plan-badge-starter {
  background: rgba(16,185,129,0.12);
  color: #34d399;
  border: 1px solid rgba(16,185,129,0.3);
}
.plan-badge-pro {
  background: rgba(61,100,120,0.15);
  color: #3D6478;
  border: 1px solid rgba(61,100,120,0.3);
}
.plan-badge-enterprise {
  background: rgba(245,158,11,0.12);
  color: #fbbf24;
  border: 1px solid rgba(245,158,11,0.3);
}

/* locked nav item — still visible, slightly muted */
.admin-nav-item.plan-locked {
  opacity: 0.7;
}
.admin-nav-item.plan-locked:hover {
  opacity: 1;
}

/* full-page plan gate card */
.plan-gate-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3.5rem 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 14px);
  margin-top: 1rem;
}
.plan-gate-card .gate-icon { font-size: 2.5rem; margin-bottom: 1rem; }
.plan-gate-card .gate-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.4rem; }
.plan-gate-card .gate-desc { font-size: 0.875rem; color: var(--text-muted); max-width: 380px; margin-bottom: 1.5rem; line-height: 1.6; }

/* AI FAB upgrade badge */
.ai-fab-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #f59e0b;
  color: #0f172a;
  font-size: 0.55rem;
  font-weight: 600;
  padding: 0.1rem 0.35rem;
  border-radius: 100px;
  letter-spacing: 0.03em;
  pointer-events: none;
}

/* Agent locked card */
.agent-locked-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(245,158,11,0.07);
  border: 1px solid rgba(245,158,11,0.25);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-top: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.agent-locked-banner strong { color: #fbbf24; }

/* ── Settings Page Layout ───────────────────────────────────────────────────── */
.settings-layout { display: flex; min-height: calc(100vh - var(--header-h)); }

.settings-nav-col {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--bg-sidebar); border-right: 1px solid var(--border);
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto; overflow-x: hidden;
  transition: width var(--transition);
}
.settings-nav {
  padding: 1.5rem 0.75rem; height: 100%;
  display: flex; flex-direction: column; gap: 2px;
}
.settings-nav-label {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--text-muted); padding: 0.5rem 0.5rem 0.3rem;
}
.settings-nav-btn {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.55rem 0.75rem; border-radius: var(--radius);
  border: none; background: none; width: 100%; text-align: left;
  font-size: 0.875rem; color: var(--text-secondary);
  cursor: pointer; font-family: inherit;
  transition: background var(--transition), color var(--transition);
}
.settings-nav-btn:hover { background: var(--bg-hover); color: var(--text); }
.settings-nav-btn.active { background: var(--primary-extralight); color: var(--primary); font-weight: 600; }
.settings-nav-btn .lucide { width: 16px; height: 16px; flex-shrink: 0; }
.settings-nav-btn-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.settings-body { flex: 1; min-width: 0; padding: 2rem 2.5rem; }
.settings-page-title { font-size: 1.3rem; font-weight: 700; margin: 0 0 0.25rem; }
.settings-page-subtitle { font-size: 0.875rem; color: var(--text-muted); margin: 0 0 1.75rem; }

.settings-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.settings-field { display: flex; flex-direction: column; gap: 0.3rem; }
.settings-field label { font-size: 0.78rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.settings-field .field-val { font-size: 0.9rem; color: var(--text); font-weight: 500; }

/* ── Preference Cards ───────────────────────────────────────────────────────── */
.pref-section { margin-bottom: 0; }
.pref-section-title {
  font-size: 0.8rem; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-muted); margin: 0 0 0.75rem;
}
.pref-cards { display: flex; gap: 0.75rem; flex-wrap: wrap; }

.theme-card {
  width: 140px; border: 2px solid var(--border); border-radius: 12px;
  overflow: hidden; cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.theme-card:hover { border-color: var(--primary); }
.theme-card.selected { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-extralight); }
.theme-card-preview { height: 80px; display: flex; flex-direction: column; gap: 4px; padding: 8px; }
.theme-card-preview.light-prev { background: #F8FAFB; }
.theme-card-preview.dark-prev  { background: #10171A; }
.theme-card-preview.system-prev { background: linear-gradient(135deg, #F8FAFB 50%, #10171A 50%); }
.theme-mini-header { height: 10px; border-radius: 3px; background: rgba(61,100,120,0.3); }
.theme-mini-content { display: flex; gap: 3px; flex: 1; }
.theme-mini-sidebar { width: 22px; border-radius: 3px; background: rgba(0,0,0,0.08); }
.dark-prev .theme-mini-sidebar { background: rgba(255,255,255,0.06); }
.theme-mini-main { flex: 1; border-radius: 3px; background: rgba(0,0,0,0.04); }
.dark-prev .theme-mini-main { background: rgba(255,255,255,0.04); }
.theme-card-label {
  font-size: 0.82rem; font-weight: 500; padding: 0.5rem 0.75rem;
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--border);
}
.theme-card.selected .theme-card-label::after { content: '✓'; color: var(--primary); font-weight: 700; }

.lang-card {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.7rem 1rem; border: 2px solid var(--border);
  border-radius: 10px; cursor: pointer; min-width: 130px;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-size: 0.9rem; font-weight: 500;
}
.lang-card:hover { border-color: var(--primary); }
.lang-card.selected { border-color: var(--primary); background: var(--primary); color: #fff; box-shadow: 0 0 0 3px var(--primary-extralight); }
.lang-flag { font-size: 1.3rem; line-height: 1; }

.view-option-cards { display: flex; gap: 0.6rem; }
.view-option-card {
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
  padding: 0.75rem 1.25rem; border: 2px solid var(--border);
  border-radius: 10px; cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-size: 0.82rem; font-weight: 500; color: var(--text-muted);
}
.view-option-card:hover { border-color: var(--primary); color: var(--text); }
.view-option-card.selected { border-color: var(--primary); background: var(--primary); color: #fff; box-shadow: 0 0 0 3px var(--primary-extralight); }
.view-option-card .lucide { width: 20px; height: 20px; }

.pref-toggle-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; padding: 1rem 1.25rem;
  border: 1px solid var(--border); border-radius: 12px; background: var(--bg-card);
}
.pref-toggle-row + .pref-toggle-row { margin-top: 0.5rem; }
.pref-toggle-info { flex: 1; }
.pref-toggle-info strong { font-size: 0.9rem; font-weight: 600; display: block; margin-bottom: 0.2rem; }
.pref-toggle-info span { font-size: 0.82rem; color: var(--text-muted); }

.toggle-switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; margin-top: 2px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--border); border-radius: 100px; transition: background var(--transition);
}
.toggle-slider::before {
  content: ''; position: absolute; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; top: 3px; left: 3px;
  transition: transform var(--transition); box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }
.toggle-switch-sm { width: 28px; height: 16px; margin-top: 0; }
.toggle-switch-sm .toggle-slider::before { width: 10px; height: 10px; top: 3px; left: 3px; }
.toggle-switch-sm input:checked + .toggle-slider::before { transform: translateX(12px); }

/* ── AI Floating Button ─────────────────────────────────────────────────────── */
.ai-float-btn {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--primary); color: #fff;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2); z-index: 400;
  transition: transform 0.15s, box-shadow 0.15s;
}
.ai-float-btn:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(0,0,0,0.28); }
.ai-float-btn .lucide { width: 24px; height: 24px; }

.ai-panel {
  position: fixed; bottom: calc(1.5rem + 52px + 0.75rem); right: 1.5rem;
  width: 320px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl); z-index: 400;
  display: flex; flex-direction: column; overflow: hidden;
  animation: slideUp 0.2s ease;
}
.ai-panel.hidden { display: none; }
.ai-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.875rem 1rem; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 0.9rem;
}
.ai-panel-body {
  padding: 1.5rem 1rem; font-size: 0.875rem; color: var(--text-muted);
  text-align: center; display: flex; flex-direction: column;
  align-items: center; gap: 0.75rem; min-height: 160px; justify-content: center;
}

/* ── Import step indicator ──────────────────────────────────────────────────── */
.import-step-row {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 2rem;
}
.import-step-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.import-step-item.active { color: var(--primary); font-weight: 600; }
.import-step-item.done   { color: #10B981; }
.import-step-dot {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700;
  flex-shrink: 0;
  background: var(--bg-card);
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}
.import-step-item.active .import-step-dot { border-color: var(--primary); color: var(--primary); background: var(--primary-extralight); }
.import-step-item.done   .import-step-dot { border-color: #10B981; background: #F0FDF4; color: #10B981; }
[data-theme="dark"] .import-step-item.done .import-step-dot { background: #052e16; }
.import-step-line { flex: 1; height: 2px; background: var(--border); margin: 0 0.5rem; max-width: 48px; transition: background 0.2s; }
.import-step-line.done { background: #10B981; }

/* ── ERD custom renderer (replaces Mermaid) ─────────────────────────────────── */
:root {
  --erd-header-bg: #F1F5F7;
  --erd-key:       #E0A82E;   /* gold PK key icon                     */
  --erd-fk:        #5C7C8A;   /* muted teal: FK icon + PK/FK col text  */
  --erd-line:      #B8C7CE;   /* dashed relationship connector         */
  --erd-focus:     var(--primary);
}
[data-theme="dark"] {
  --erd-header-bg: #1E2C33;
  --erd-key:       #E7B84B;
  --erd-fk:        #8FA9B5;
  --erd-line:      #3E4E56;
  --erd-focus:     #5A8296;
}
.erd-canvas { position: relative; display: inline-block; text-align: left; }
.erd-connectors { position: absolute; inset: 0; overflow: visible; z-index: 0; }
.erd-col.erd-col-active { background: var(--primary-extralight); border-radius: 4px; }
.erd-col.erd-col-active .erd-colname { color: var(--primary); font-weight: 600; }
.erd-table {
  position: absolute; z-index: 1; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); overflow: hidden; cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.erd-table:hover { box-shadow: var(--shadow-md); border-color: var(--primary-light); }
.erd-table.focus { border: 2px solid var(--erd-focus); box-shadow: var(--shadow-md); }
.erd-table-header {
  background: var(--erd-header-bg); border-bottom: 1px solid var(--border);
  padding: 0.6rem 0.9rem; text-align: center; font-weight: 600;
  font-size: 0.9rem; letter-spacing: -0.01em; color: var(--text);
}
.erd-cols { padding: 0.5rem 0; }
.erd-col { display: flex; align-items: center; gap: 0.5rem; padding: 0.3rem 0.9rem; font-size: 0.85rem; color: var(--text); }
.erd-col .erd-ic { width: 15px; height: 15px; flex-shrink: 0; }
.erd-col .erd-ic.key  { color: var(--erd-key); }
.erd-col .erd-ic.link { color: var(--erd-fk); }
.erd-col .erd-sp { width: 15px; flex-shrink: 0; }
.erd-col.is-key .erd-colname { color: var(--erd-fk); }
.erd-col .erd-colname { line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── AI Suggest Modal ──────────────────────────────────────────────────────── */
.ai-suggest-check-group {
  display: flex; flex-direction: column; gap: 0.6rem;
  margin: 0.5rem 0 1.25rem;
}
.ai-suggest-check {
  display: flex; align-items: center; gap: 0.6rem;
  font-size: 0.9rem; cursor: pointer; color: var(--text);
}
.ai-suggest-check input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }
.ai-suggest-quota-note {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.8rem; color: var(--text-muted);
  padding: 0.6rem 0.75rem; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.ai-suggest-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 0.875rem;
}
.ai-suggest-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.6rem 0.875rem; background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.ai-suggest-label { font-weight: 600; font-size: 0.85rem; color: var(--text); }
.ai-suggest-value {
  padding: 0.75rem 0.875rem; font-size: 0.875rem;
  color: var(--text-secondary); line-height: 1.6; white-space: pre-wrap;
  display: flex; flex-wrap: wrap; gap: 0.375rem; align-items: flex-start;
}
.ai-suggest-cols-list {
  padding: 0.25rem 0; max-height: 220px; overflow-y: auto;
}
.ai-suggest-col-row {
  display: flex; gap: 1rem; align-items: baseline;
  padding: 0.375rem 0.875rem; font-size: 0.82rem;
  border-bottom: 1px solid var(--border);
}
.ai-suggest-col-row:last-child { border-bottom: none; }
.ai-suggest-col-name {
  font-family: var(--font-mono, monospace); color: var(--text);
  font-size: 0.78rem; font-weight: 600; min-width: 120px; flex-shrink: 0;
}
.ai-suggest-col-desc { color: var(--text-secondary); flex: 1; line-height: 1.5; }
.ai-suggest-applied { color: var(--success, #059669); font-size: 0.8rem; font-weight: 500; }
