@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Sans:ital,wght@0,300;0,400;0,500;1,400&display=swap');

:root {
  --primary: #0d6efd;
  --primary-dk: #0a58ca;
  --teal: #0dcaf0;
  --surface: #f8fafc;
  --surface-2: #eef2f7;
  --sidebar-bg: #0e1726;
  --sidebar-border: #1e2d45;
  --sidebar-accent: #162236;
  --sidebar-active: #0d3d6e;
  --sidebar-user-text: #c8ddf4;
  --sidebar-user-subtext: #4a6380;
  --sidebar-w: 260px;
  --topbar-h: 60px;
  --topbar-bg: #ffffff;
  --text: #1a2540;
  --muted: #6b7a99;
  --border: #e2e8f0;
  --card-bg: #ffffff;
  --accent1: #6366f1;
  --accent2: #10b981;
  --accent3: #f59e0b;
  --accent4: #ef4444;
  --table-head-bg: #f8fafc;
  --table-row-hover: #f8fafc;
  --lineage-node-bg: #ffffff;
  --help-panel-bg: #ffffff;
}

html[data-theme='dark'] {
  --primary: #60a5fa;
  --primary-dk: #3b82f6;
  --teal: #22d3ee;
  --surface: #0f1117;
  --surface-2: #181b22;
  --sidebar-bg: #050b15;
  --sidebar-border: #172235;
  --sidebar-accent: #132033;
  --sidebar-active: #123f73;
  --sidebar-user-text: #d9e7fb;
  --sidebar-user-subtext: #7689a8;
  --topbar-bg: #181b22;
  --text: #e6edf3;
  --muted: #8b949e;
  --border: #30363d;
  --card-bg: #1c2028;
  --accent1: #8b93ff;
  --accent2: #34d399;
  --accent3: #fbbf24;
  --accent4: #f87171;
  --table-head-bg: #161b22;
  --table-row-hover: #1c2028;
  --lineage-node-bg: #1c2028;
  --help-panel-bg: #1c2028;
}

*, *::before, *::after { box-sizing: border-box; }
body { font-family: 'DM Sans', sans-serif; background: var(--surface); color: var(--text); margin: 0; transition: background-color 0.2s ease, color 0.2s ease; }

#sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  z-index: 1000;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.22s ease, background-color 0.2s ease;
}
body.sidebar-collapsed #sidebar { width: 0; }
body.sidebar-collapsed #topbar  { left: 0; transition: left 0.22s ease; }
body.sidebar-collapsed #main    { margin-left: 0; transition: margin-left 0.22s ease; }
#topbar  { transition: left 0.22s ease, background-color 0.2s ease, border-color 0.2s ease; }
#main    { transition: margin-left 0.22s ease; }

.sidebar-brand {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

 .brand-name,
.sidebar-brand .brand-name {
    font-family: 'Syne', sans-serif;
    font-weight: 800;
    font-size: 17px;
    color: #fff;
    letter-spacing: -0.02em;
    line-height: 1.2;
}
 .brand-sub,
.sidebar-brand .brand-sub {
    font-size: 10px;
    color: #4a6380;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: 3px;
}
.sidebar-section-label {
  font-size: 9px; font-weight: 700; letter-spacing: 0.18em;
  text-transform: uppercase; color: #2d4a6b;
  padding: 18px 20px 6px;
}
.sidebar-nav { list-style: none; padding: 0; margin: 0; }
.sidebar-nav .nav-item { margin: 1px 10px; }
.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 7px;
  color: #7a9bbf;
  font-size: 13px; font-weight: 400;
  text-decoration: none;
  transition: all 0.15s;
  cursor: pointer;
}
.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
  background: var(--sidebar-accent);
  color: #c8ddf4;
}
.sidebar-nav .nav-link.active {
  background: var(--sidebar-active);
  color: #7dc4ff;
  font-weight: 500;
}
.sidebar-nav .nav-link .nav-icon {
  font-size: 15px; width: 20px; text-align: center; flex-shrink: 0;
}
.nav-badge {
  margin-left: auto;
  background: var(--accent4);
  color: #fff;
  font-size: 9px; font-weight: 700;
  padding: 2px 6px; border-radius: 99px;
}
.nav-badge.green { background: var(--accent2); }
.nav-badge.amber { background: var(--accent3); color: #1a1a1a; }
.nav-badge.warning { background: #d97706; color: #fff; }

#topbar {
  position: fixed; top: 0; left: var(--sidebar-w); right: 0;
  height: var(--topbar-h);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  z-index: 999;
}
.topbar-title {
  font-family: 'Syne', sans-serif;
  font-size: 15px; font-weight: 700; color: var(--text);
}
.topbar-search {
  flex: 1; max-width: 420px; margin-left: 16px;
  position: relative;
}
.topbar-search input {
  width: 100%; padding: 7px 14px 7px 36px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; background: var(--surface);
  outline: none; color: var(--text);
  transition: border-color 0.15s, background-color 0.2s ease, color 0.2s ease;
}
.topbar-search input:focus { border-color: var(--primary); }
.topbar-search .search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 14px;
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent1), #818cf8);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 700;
  cursor: pointer;
}
.notif-btn {
  position: relative; cursor: pointer;
  width: 34px; height: 34px;
  border-radius: 8px; background: var(--surface);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 16px;
  transition: background 0.15s, border-color 0.2s ease;
}
.notif-btn:hover { background: var(--surface-2); }
.notif-dot {
  position: absolute; top: 4px; right: 4px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent4);
  border: 2px solid var(--topbar-bg);
}

#main {
  margin-left: var(--sidebar-w);
  padding-top: var(--topbar-h);
  min-height: 100vh;
}
.page-content { padding: 28px 28px 60px; display: none; }
.page-content.active { display: block; }

.mdr-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  transition: box-shadow 0.2s, background-color 0.2s ease, border-color 0.2s ease;
}
.mdr-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.06); }
html[data-theme='dark'] .mdr-card:hover { box-shadow: 0 8px 28px rgba(0,0,0,0.28); }

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  position: relative; overflow: hidden;
}
.stat-card .stat-val {
  font-family: 'Syne', sans-serif;
  font-size: 32px; font-weight: 800; color: var(--text);
  line-height: 1;
}
.stat-card .stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat-card .stat-icon {
  position: absolute; right: 16px; top: 16px;
  font-size: 28px; opacity: 0.12;
}
.stat-card .stat-delta {
  font-size: 11px; margin-top: 8px;
  display: flex; align-items: center; gap: 4px;
}
.stat-card .delta-up { color: var(--accent2); }
.stat-card .delta-down { color: var(--accent4); }
a.stat-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s, transform 0.15s;
}
a.stat-card-link:hover {
  box-shadow: 0 4px 16px rgba(13,110,253,0.12);
  transform: translateY(-2px);
  text-decoration: none;
  color: inherit;
  border-color: var(--primary);
}
.section-title {
  font-family: 'Syne', sans-serif;
  font-size: 18px; font-weight: 700; color: var(--text);
  margin-bottom: 4px;
}
.section-sub { font-size: 13px; color: var(--muted); margin-bottom: 20px; }
.page-header-row { gap: 12px; }
.page-header-actions {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  margin-top: -3px;
}
.mdr-breadcrumb {
  font-size: 12px; color: var(--muted); margin-bottom: 20px;
  display: flex; align-items: center; gap: 6px;
}
.mdr-breadcrumb a { color: var(--primary); text-decoration: none; cursor: pointer; }
.mdr-breadcrumb a:hover { text-decoration: underline; }
.status-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 99px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.status-proposed  { background: #f1f5f9; color: #64748b; }
.status-review    { background: #fef9ec; color: #d97706; }
.status-approved  { background: #f0fdf4; color: #16a34a; }
.status-published { background: #eff6ff; color: #2563eb; }
.status-rejected  { background: #fef2f2; color: #dc2626; }
.status-retired   { background: #f5f3ff; color: #7c3aed; }
html[data-theme='dark'] .status-proposed  { background: #182332; color: #a8b6cd; }
html[data-theme='dark'] .status-review    { background: #3a2910; color: #f8c15a; }
html[data-theme='dark'] .status-approved  { background: #11281e; color: #58d69f; }
html[data-theme='dark'] .status-published { background: #132742; color: #7fb4ff; }
html[data-theme='dark'] .status-rejected  { background: #351617; color: #ff9696; }
html[data-theme='dark'] .status-retired   { background: #271b39; color: #c4a5ff; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.domain-tag {
  display: inline-block;
  padding: 2px 9px; border-radius: 5px;
  font-size: 11px; font-weight: 600;
  background: #eff6ff; color: #2563eb;
}
html[data-theme='dark'] .domain-tag { background: #132742; color: #7fb4ff; }
.mdr-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mdr-table th {
  text-align: left; padding: 10px 14px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--muted); border-bottom: 2px solid var(--border);
  background: var(--table-head-bg);
}
.mdr-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.mdr-table > tbody > tr:last-child > td { border-bottom: none; }
.mdr-table tr:hover td { background: var(--table-row-hover); }
.mdr-table td a { color: var(--primary); text-decoration: none; font-weight: 500; cursor: pointer; }
.mdr-table td a:hover { text-decoration: underline; }
.lineage-node {
  background: var(--lineage-node-bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 12px 18px;
  text-align: center;
  font-size: 12px; font-weight: 600;
  min-width: 130px;
  transition: border-color 0.2s, box-shadow 0.2s;
  cursor: pointer;
}
.lineage-node:hover { border-color: var(--primary); box-shadow: 0 2px 12px rgba(13,110,253,0.12); }
.lineage-node.current { border-color: var(--primary); background: #eff6ff; color: var(--primary); }
html[data-theme='dark'] .lineage-node.current { background: #132742; }
.lineage-node .ln-type { font-size: 9px; font-weight: 400; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.lineage-arrow { font-size: 20px; color: var(--muted); display: flex; align-items: center; }
.wf-step {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.wf-step:last-child { border-bottom: none; }
.wf-icon {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.term-card {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 16px; background: var(--card-bg);
  margin-bottom: 12px; cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.term-card:hover { border-color: var(--accent1); box-shadow: 0 2px 12px rgba(99,102,241,0.08); }
.term-card .term-name { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 15px; color: var(--text); }
.term-card .term-def { font-size: 13px; color: var(--muted); margin-top: 5px; line-height: 1.5; }
#breakpoint-badge {
  background: #0e1726;
  color: #7dd3fc;
  font-family: monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 3px 8px;
  border-radius: 4px;
  pointer-events: none;
  user-select: none;
  flex-shrink: 0;
}
.org-scroll-wrap {
  overflow: visible;
  padding-bottom: 16px;
}
.org-tree {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 24px 0;
  transform-origin: top center;
}
.org-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.org-enterprise-card {
  background: var(--card-bg);
  border: 2px solid var(--text);
  border-radius: 10px;
  padding: 14px 28px;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  text-align: center;
  min-width: 220px;
}
.org-line-down {
  width: 2px;
  height: 28px;
  background: #94a3b8;
  flex-shrink: 0;
}
.org-children {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: center;
}
.org-child {
  position: relative;
  padding-top: 28px;
  padding-left: 12px;
  padding-right: 12px;
}
.org-child::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: #94a3b8;
}
.org-children > .org-child:first-child::before { left: 50%; }
.org-children > .org-child:last-child::before  { right: 50%; }
.org-children > .org-child:only-child::before  { display: none; }
.org-root-children > .org-child::before { display: none; }
.org-root-children > .org-child::after  { display: none; }
.org-child::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 28px;
  background: #94a3b8;
}
.org-domain-card {
  display: block;
  position: relative;
  z-index: 1;
  border: 2px solid;
  border-radius: 10px;
  padding: 12px 14px;
  min-width: 165px;
  max-width: 200px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
}
.org-domain-card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,0.13);
  transform: translateY(-2px);
  text-decoration: none;
  color: inherit;
}
.org-card-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.org-card-name {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 13px;
  line-height: 1.25;
  color: var(--text);
}
.org-card-items {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 2px;
}
.org-smartie {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.org-card-coverage {
  font-size: 12px;
  font-weight: 700;
}
.org-card-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-top: 2px;
  font-weight: 600;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.page-content.active { animation: fadeIn 0.25s ease; }
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb { background: #1e3350; border-radius: 4px; }
#sidebar-toggle {
  display: none;
  background: none; border: none;
  color: var(--text); font-size: 22px;
  padding: 0 4px; cursor: pointer;
  line-height: 1;
}
#sidebar-collapse-btn,
#theme-toggle-btn {
  display: flex; align-items: center; justify-content: center;
  background: none; border: none;
  color: var(--muted); font-size: 18px;
  padding: 0 4px; cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s, transform 0.15s;
}
#sidebar-collapse-btn:hover,
#theme-toggle-btn:hover { color: var(--text); }
#theme-toggle-btn { margin-right: 4px; }
html[data-theme='dark'] #theme-toggle-btn { color: #fbbf24; }
#sidebarOffcanvas {
  width: var(--sidebar-w) !important;
  background: var(--sidebar-bg) !important;
  border-right: none !important;
}
#sidebarOffcanvas .offcanvas-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--sidebar-border);
}
#sidebarOffcanvas .offcanvas-body {
  padding: 0;
  display: flex; flex-direction: column;
  overflow-y: auto;
}
#sidebarOffcanvas .btn-close {
  filter: invert(1) grayscale(1) brightness(2);
  opacity: 0.5;
}
#sidebarOffcanvas .btn-close:hover { opacity: 1; }
@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }
  #sidebar { display: none; }
  #topbar { left: 0 !important; transition: none !important; }
  #main { margin-left: 0 !important; transition: none !important; }
  #sidebar-toggle { display: block; }
  #sidebar-collapse-btn { display: none; }
}
.help-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px;
  border: none; border-radius: 50%;
  background: transparent;
  cursor: pointer; font-size: 15px; padding: 0; line-height: 1;
  opacity: 0.7;
  transition: opacity 0.15s, transform 0.15s;
  flex-shrink: 0;
}
.help-btn:hover { opacity: 1; transform: scale(1.15); }
.help-overlay {
  position: fixed; inset: 0;
  background: rgba(14, 23, 38, 0.5);
  z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.help-panel {
  background: var(--help-panel-bg); border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.2);
  width: 100%; max-width: 580px;
  max-height: 85vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.help-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.help-panel-title {
  font-family: 'Syne', sans-serif; font-weight: 700; font-size: 15px; color: var(--text);
}
.help-panel-close {
  background: none; border: none; padding: 4px 6px;
  color: var(--muted); cursor: pointer; font-size: 13px;
  border-radius: 6px; line-height: 1;
}
.help-panel-close:hover { background: var(--surface); color: var(--text); }
.help-panel-body {
  padding: 22px 22px 24px;
  overflow-y: auto;
  font-size: 13px; color: var(--text); line-height: 1.65;
}
.help-section { margin-bottom: 20px; }
.help-section:last-child { margin-bottom: 0; }
.help-section-title {
  font-weight: 700; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); margin-bottom: 8px;
}
.help-p { margin-bottom: 10px; }
.help-p:last-child { margin-bottom: 0; }
.help-formula {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 14px 16px;
  font-size: 12.5px; line-height: 2;
}
.help-formula-row { display: flex; align-items: baseline; gap: 10px; }
.help-formula-weight {
  display: inline-block; min-width: 38px;
  font-weight: 700; color: var(--primary); text-align: right; flex-shrink: 0;
}
.help-levels { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.help-level {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: 99px;
  font-size: 11px; font-weight: 600;
}
.help-list { padding-left: 18px; margin: 0; }
.help-list li { margin-bottom: 5px; }
.help-list li:last-child { margin-bottom: 0; }
.help-tip {
  display: flex; gap: 10px; align-items: flex-start;
  background: #eff6ff; border-radius: 8px; padding: 12px 14px;
  font-size: 12.5px; margin-top: 14px;
}
html[data-theme='dark'] .help-tip { background: #132742; }
.help-tip i { color: var(--primary); margin-top: 2px; flex-shrink: 0; }
html[data-theme='dark'] .btn-outline-secondary,
html[data-theme='dark'] .btn-outline-primary,
html[data-theme='dark'] .btn-outline-danger,
html[data-theme='dark'] .btn-outline-warning,
html[data-theme='dark'] .btn-outline-success {
  --bs-btn-color: var(--text);
  --bs-btn-border-color: var(--border);
  --bs-btn-hover-color: var(--text);
  --bs-btn-hover-border-color: var(--primary);
  --bs-btn-hover-bg: rgba(96,165,250,0.12);
}
html[data-theme='dark'] .form-control,
html[data-theme='dark'] .form-select {
  background-color: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}
html[data-theme='dark'] .form-control:focus,
html[data-theme='dark'] .form-select:focus {
  background-color: var(--surface-2);
  color: var(--text);
}
.modal-dialog-scrollable {
  height: calc(100% - 2rem);
}
.modal-dialog-scrollable .modal-content {
  max-height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.modal-dialog-scrollable .modal-content > form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
.modal-dialog-scrollable .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

html[data-theme='dark'] .modal-content {
  background: var(--card-bg);
  color: var(--text);
}
html[data-theme='dark'] .modal-header,
html[data-theme='dark'] .modal-footer {
  border-color: var(--border);
}
html[data-theme='dark'] .offcanvas {
  color: var(--text);
}

html[data-sidebar-variant='red'] {
  --sidebar-bg: #34161d;
  --sidebar-border: #5c2733;
  --sidebar-accent: #421c25;
  --sidebar-active: #7a3440;
  --sidebar-user-text: #faeef1;
  --sidebar-user-subtext: #d49aa7;
}

html[data-sidebar-variant='orange'] {
  --sidebar-bg: #4a2c12;
  --sidebar-border: #7a4a20;
  --sidebar-accent: #5c3818;
  --sidebar-active: #9a5f2a;
  --sidebar-user-text: #fff4e8;
  --sidebar-user-subtext: #e2b784;
}

html[data-sidebar-variant='green'] {
  --sidebar-bg: #18352b;
  --sidebar-border: #2b5b49;
  --sidebar-accent: #1f4335;
  --sidebar-active: #2f6a54;
  --sidebar-user-text: #ecf8f1;
  --sidebar-user-subtext: #9ec8b3;
}

.sidebar-variant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.sidebar-variant-card {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: var(--card-bg);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.sidebar-variant-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

.sidebar-variant-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13,110,253,0.14);
}

html[data-theme='dark'] .sidebar-variant-card.selected {
  box-shadow: 0 0 0 3px rgba(96,165,250,0.18);
}

.sidebar-variant-preview {
  height: 112px;
  border-radius: 12px;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.sidebar-variant-brand {
  width: 56%;
  height: 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.88);
}

.sidebar-variant-link {
  width: 72%;
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.3);
}

.sidebar-variant-link.active {
  width: 88%;
  background: rgba(255,255,255,0.88);
}

.sidebar-variant-link.muted {
  width: 60%;
  opacity: 0.7;
}

.sidebar-variant-name {
  font-family: 'Syne', sans-serif;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
}

.sidebar-variant-note {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}


/* ===== Lineage Relationship Map ===== */
.lineage-map-card {
  width: 100%;
  overflow: hidden;
}

.lineage-map-title {
  font-family: 'Syne', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.lineage-map-subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.lineage-map-hint {
  font-size: 11px;
  color: var(--muted);
}

/* Sequence breadcrumb legend */
.lineage-map-sequence {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 4px 0 20px;
  flex-wrap: wrap;
}

.lineage-sequence-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 100px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(148, 163, 184, 0.12);
  color: var(--text);
}

.lineage-sequence-pill.upstream {
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
}

.lineage-sequence-pill.asset {
  background: rgba(15, 23, 42, 0.08);
  color: var(--text);
}

.lineage-sequence-pill.downstream {
  background: rgba(15, 118, 110, 0.12);
  color: #0f766e;
}

.lineage-sequence-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 15px;
}

/* Shell: vertical flow column */
.lineage-map-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  gap: 0;
}

/* Upstream / Downstream sections */
.lineage-map-column {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.lineage-map-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: #1d4ed8;
  padding: 0 4px;
  margin-bottom: 6px;
}

.lineage-map-column-header.downstream {
  color: #0f766e;
}

.lineage-map-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.12);
  color: inherit;
  font-size: 12px;
}

.lineage-map-column-header.downstream .lineage-map-count {
  background: rgba(15, 118, 110, 0.12);
}

/* Cards in a wrapping row inside each section */
.lineage-map-stack {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  width: 100%;
}

.lineage-map-empty {
  flex: 1 1 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  background: rgba(148, 163, 184, 0.06);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 16px;
}

/* Vertical connector between sections */
.lineage-v-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 2px 0;
  color: var(--muted);
  font-size: 18px;
}

.lineage-v-line {
  width: 2px;
  height: 20px;
  border-radius: 2px;
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.3) 0%, rgba(15, 118, 110, 0.3) 100%);
}

/* Center asset card */
.lineage-map-center {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 380px;
  padding: 0;
  min-height: 0;
}

.lineage-core-card {
  width: 100%;
  border-radius: 24px;
  padding: 24px 20px;
  text-align: center;
  background: linear-gradient(180deg, #eff6ff 0%, #ffffff 100%);
  border: 1px solid rgba(37, 99, 235, 0.18);
  box-shadow: 0 12px 32px rgba(37, 99, 235, 0.14);
  min-width: 0;
}

html[data-theme='dark'] .lineage-core-card {
  background: linear-gradient(180deg, #132742 0%, var(--card-bg) 100%);
}

.lineage-core-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2563eb 0%, #0f766e 100%);
  color: white;
  font-size: 22px;
}

.lineage-core-type {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #2563eb;
  font-weight: 700;
  margin-bottom: 6px;
}

.lineage-core-name {
  font-family: 'Syne', sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  word-break: break-word;
}

.lineage-core-meta,
.lineage-core-domain {
  font-size: 12px;
  color: var(--muted);
  margin-top: 5px;
}

/* Orbit decorations not used in vertical layout */
.lineage-core-orbit,
.lineage-core-connector {
  display: none;
}

/* Flow cards */
.lineage-flow-card {
  position: relative;
  flex: 1 1 240px;
  max-width: 420px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card-bg);
  text-align: left;
  padding: 14px 16px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.lineage-flow-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.10);
}

.lineage-flow-card.upstream {
  border-left: 4px solid #2563eb;
}

.lineage-flow-card.downstream {
  border-left: 4px solid #0f766e;
}

.lineage-flow-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.lineage-flow-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.lineage-flow-direction {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}

.lineage-flow-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.06);
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
}

html[data-theme='dark'] .lineage-flow-pill {
  background: rgba(255, 255, 255, 0.08);
}

.lineage-flow-name {
  font-family: 'Syne', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  word-break: break-word;
}

.lineage-flow-meta,
.lineage-flow-domain {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* Responsive */
@media (max-width: 767.98px) {
  .lineage-map-sequence {
    display: none;
  }

  .lineage-map-center {
    max-width: 100%;
  }

  .lineage-flow-card {
    flex: 1 1 100%;
    max-width: 100%;
  }

  .lineage-flow-topline {
    flex-wrap: wrap;
  }

  .lineage-flow-pill {
    max-width: 100%;
  }

  .lineage-map-hint {
    width: 100%;
  }
}
