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

:root {
  --primary: #6264a7;
  --primary-dark: #464775;
  --primary-light: #e8e8f4;
  --nav-bg: #1b1b32;
  --nav-text: #c8c6c4;
  --nav-hover: rgba(255,255,255,0.08);
  --nav-active-bg: rgba(98,100,167,0.2);
  --surface: #ffffff;
  --bg: #f5f5f5;
  --text: #242424;
  --text-secondary: #616161;
  --border: #e0e0e0;
  --success: #107c10;
  --danger: #d13438;
  --warning: #ffb900;
  --info: #0078d4;
  --radius: 8px;
  --shadow: 0 2px 4px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

/* ── APP LAYOUT ── */
.app-layout {
  display: grid;
  grid-template-columns: auto 1fr;
  min-height: 100vh;
}

/* ── SIDEBAR ── */
.sidebar {
  background: var(--nav-bg);
  color: var(--nav-text);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  position: sticky;
  top: 0;
  height: 100vh;
  width: 250px;
  transition: width 0.2s ease;
}

.sidebar.collapsed {
  width: 60px;
}

.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-section,
.sidebar.collapsed .auth-info,
.sidebar.collapsed .auth-actions {
  display: none;
}

.sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: 20px 8px 12px;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 10px 8px;
  border-left-width: 0;
}

.sidebar.collapsed .nav-icon {
  width: auto;
}

.sidebar.collapsed .sidebar-footer {
  padding: 8px;
}

.sidebar.collapsed .btn-collapse {
  justify-content: center;
}

.sidebar.collapsed .collapse-icon {
  transform: rotate(180deg);
}

.btn-collapse {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  padding: 10px 16px;
  font-size: 0.85rem;
  transition: color 0.15s;
  margin-top: auto;
}

.btn-collapse:hover {
  color: #fff;
}

.collapse-icon {
  font-size: 0.9rem;
  transition: transform 0.2s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo { flex-shrink: 0; }

.sidebar-title {
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.3;
  color: #fff;
}

.nav-items {
  list-style: none;
  flex: 1;
  padding: 8px 0;
}

.nav-section {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 16px 16px 4px;
  color: rgba(255,255,255,0.4);
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  font-size: 0.9rem;
}

.nav-item:hover {
  background: var(--nav-hover);
}

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

.nav-icon { font-size: 1.1rem; width: 20px; text-align: center; display: flex; align-items: center; justify-content: center; }

.nav-divider {
  border-top: 1px solid rgba(255,255,255,0.08);
  margin: 8px 16px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.auth-info {
  font-size: 0.8rem;
  margin-bottom: 8px;
  word-break: break-all;
  line-height: 1.4;
}

.auth-actions { display: flex; gap: 8px; }

.btn-sidebar {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
}

.btn-sidebar:hover { background: rgba(255,255,255,0.18); }

/* ── MAIN ── */
.main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── TOPBAR ── */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.breadcrumb {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.tenant-info {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ── PAGE ── */
.page {
  flex: 1;
  padding: 24px 32px;
  overflow-y: auto;
}

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

.page-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.btn-export {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  background: #1d6f42;
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
  margin-top: 4px;
}

.btn-export:hover {
  background: #185a36;
  transform: translateY(-1px);
}

.btn-export:active {
  transform: translateY(0);
}

.btn-export svg {
  flex-shrink: 0;
}

.page-desc {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 28px 0 16px;
}

/* ── SUMMARY CARDS ── */
.summary-row {
  display: flex;
  align-items: stretch;
  gap: 24px;
  flex-wrap: wrap;
}

.summary-card {
  display: flex;
  gap: 16px;
  align-items: center;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  border-left: 4px solid var(--primary);
  min-width: 220px;
  flex: 1 1 0;
  position: relative;
  overflow: hidden;
}

.summary-card.accent-purple { border-left-color: var(--primary); }
.summary-card.accent-red { border-left-color: var(--danger); }
.summary-card.accent-green { border-left-color: var(--success); }

.summary-icon { font-size: 1.6rem; }

.summary-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  font-weight: 600;
}

.summary-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
}

.summary-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.summary-link {
  color: var(--info);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  flex: 0 0 auto;
  align-self: center;
}

.summary-link:hover { text-decoration: underline; }

/* ── ANALYTICS ── */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.analytics-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.analytics-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.bar-chart { display: flex; flex-direction: column; gap: 10px; }

.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
}

.clickable-card, .clickable-row, .clickable-item, .clickable-value {
  cursor: pointer;
}
.clickable-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.12); }
.clickable-row:hover { background: #f5f5f5; border-radius: 4px; }
.clickable-item:hover { color: var(--primary); text-decoration: underline; }
.clickable-value:hover { color: var(--primary); }

.bar-label {
  width: 130px;
  flex-shrink: 0;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-track {
  flex: 1;
  height: 8px;
  background: #eee;
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.bar-count {
  width: 50px;
  flex-shrink: 0;
  text-align: right;
  font-weight: 600;
  color: var(--text);
}

/* ── GOVERNANCE ── */
.governance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.governance-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  border-left: 4px solid var(--warning);
}

.governance-card.accent-warning { border-left-color: var(--warning); }
.governance-card.accent-info { border-left-color: var(--info); }

.governance-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  margin-bottom: 8px;
}

.governance-icon { font-size: 1.2rem; }
.governance-value { font-size: 1.8rem; font-weight: 700; }
.governance-desc { font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 12px; }
.governance-list { font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 12px; }
.governance-list div { padding: 2px 0; }

.btn-link {
  background: none;
  border: none;
  color: var(--info);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}

.btn-link:hover { text-decoration: underline; }

/* ── ALL AGENTS VIEW ── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  background: none;
  border: none;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-family: inherit;
  transition: color 0.15s, border-color 0.15s;
}

.tab:hover { color: var(--text); }

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.metric-pills {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.metric-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 100px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.metric-pill:hover {
  border-color: var(--primary);
  background: #f5f4ff;
}

.metric-pill.active {
  border-color: var(--primary);
  background: #eeeaff;
  box-shadow: 0 0 0 2px rgba(91, 78, 242, 0.18);
}

.metric-pill-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  font-weight: 600;
}

.metric-pill-value {
  font-size: 1.3rem;
  font-weight: 700;
}

.actions-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.overview-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

/* Toggle switch */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  user-select: none;
  margin-left: auto;
}

.toggle-label input { display: none; }

.toggle-slider {
  position: relative;
  width: 36px;
  height: 20px;
  background: #ccc;
  border-radius: 10px;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-slider::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-label input:checked + .toggle-slider {
  background: var(--primary);
}

.toggle-label input:checked + .toggle-slider::after {
  transform: translateX(16px);
}

/* ── BUTTONS ── */
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
}

.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-outline {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 18px;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  text-decoration: none;
  text-align: center;
}

.btn-outline:hover { background: #f0f0f0; }

.btn-danger-outline {
  background: var(--surface);
  color: #d13438;
  border-color: #d13438;
}
.btn-danger-outline:hover { background: #fde7e9; }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
}

.btn-danger:hover { background: #b02a2e; }

.btn-ghost {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
}

.btn-ghost:hover { background: #f0f0f0; }

.btn-icon {
  background: none;
  border: none;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.3rem;
  color: var(--text-secondary);
}

.btn-icon:hover { background: #f0f0f0; }

.btn-sm { padding: 5px 12px; font-size: 0.8rem; }

/* ── FILTER BAR ── */
.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}

.filter-select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.82rem;
  background: var(--surface);
  color: var(--text);
}

.filter-spacer { flex: 1; }

.item-count {
  font-size: 0.82rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.column-chooser { position: relative; }

.column-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  padding: 12px;
  z-index: 50;
  min-width: 200px;
  max-height: 300px;
  overflow-y: auto;
}

.column-dropdown label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 0.82rem;
  cursor: pointer;
}

.search-input {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.82rem;
  min-width: 180px;
}

/* ── BULK BAR ── */
.bulk-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 12px;
  font-size: 0.85rem;
  font-weight: 600;
}

/* ── TABLE ── */
.table-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}

/* Virtual-scroll layout */
.virt-head-wrap {
  position: sticky;
  top: 0;
  z-index: 2;
}

.virt-head-table,
.virt-body-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 800px;
  table-layout: fixed;
}

.virt-scroll-container {
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: calc(100vh - 300px);
}

.virt-spacer {
  pointer-events: none;
}

.virt-body-table {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 800px;
}

th, td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid #eee;
  font-size: 0.82rem;
}

th {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 600;
  background: #fafafa;
  position: sticky;
  top: 0;
}

/* Fixed row height for virtual scrolling */
.virt-body-table tbody tr {
  height: 44px;
  max-height: 44px;
}

.virt-body-table tbody td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 260px;
  position: relative;
}

.virt-body-table tbody tr:hover td {
  overflow: visible;
  white-space: normal;
  word-break: break-word;
}

.virt-body-table tbody tr:hover {
  height: auto;
  min-height: 44px;
  max-height: none;
  z-index: 1;
}

/* Column filter row */
.column-filter-row th {
  padding: 4px 6px;
  background: #f5f5f5;
  border-bottom: 2px solid #e0e0e0;
}

.col-filter {
  width: 100%;
  padding: 4px 6px;
  font-size: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  box-sizing: border-box;
}

.col-filter:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(91, 78, 242, 0.15);
}

select.col-filter {
  cursor: pointer;
  appearance: auto;
}

tbody tr { cursor: pointer; transition: background 0.1s; }
tbody tr:hover { background: #f5f5ff; }

.cell-name {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
  max-height: 38px;
}

tr:hover .cell-name {
  max-height: none;
  overflow: visible;
}

.cell-name-primary { font-weight: 600; color: var(--text); white-space: nowrap; }
.cell-name-sub { font-size: 0.75rem; color: var(--text-secondary); white-space: nowrap; }

tr:hover .cell-name-primary,
tr:hover .cell-name-sub {
  white-space: normal;
  word-break: break-word;
}

/* Identity list */
.identity-list {
  margin-top: 4px;
  max-height: 200px;
  overflow-y: auto;
}

.identity-row {
  font-size: 0.8rem;
  padding: 3px 0;
  border-bottom: 1px solid #f0f0f0;
}

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

/* Activity list */
.activity-list {
  max-height: 300px;
  overflow-y: auto;
}

.activity-item {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 0.8rem;
}

.activity-item:last-child { border-bottom: none; }

.activity-op {
  font-weight: 600;
  color: var(--primary);
  min-width: 100px;
}

.activity-user {
  flex: 1;
  color: var(--text);
}

.activity-date {
  color: var(--text-secondary);
  font-size: 0.75rem;
  white-space: nowrap;
}

.spinner-sm {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid #ddd;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-all { color: var(--success); background: #e6f4e6; }
.badge-some { color: var(--info); background: #e0f0ff; }
.badge-none { color: var(--text-secondary); background: #f0f0f0; }
.badge-blocked { color: var(--danger); background: #fde7e9; }
.badge-ok { color: var(--success); background: #e6f4e6; }

/* ── AUTH GATE ── */
.auth-gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 80vh;
  max-width: 480px;
  margin: 0 auto;
}

/* When sidebar is hidden, main takes full width */
.app-layout:has(.sidebar[style*="display: none"]),
.app-layout:has(.sidebar[style*="display:none"]) {
  grid-template-columns: 1fr;
}

.auth-gate-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.auth-gate h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.auth-gate p {
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.5;
  margin-bottom: 24px;
}

.btn-lg {
  padding: 14px 32px;
  font-size: 1rem;
}

.auth-gate-requirements {
  text-align: left;
  background: #f8f7ff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  margin: 8px 0 16px;
  width: 100%;
}

.auth-gate-requirements summary {
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  padding: 4px 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.auth-gate-requirements summary::-webkit-details-marker { display: none; }

.auth-gate-requirements summary::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.25s ease;
  flex-shrink: 0;
}

.auth-gate-requirements[open] summary::before {
  transform: rotate(45deg);
}

.auth-gate-requirements summary:hover {
  color: var(--primary);
}

.auth-gate-requirements .prereq-content {
  display: grid;
  grid-template-rows: var(--rows, 0fr);
  transition: grid-template-rows 0.3s ease;
}

.auth-gate-requirements[open] .prereq-content {
  grid-template-rows: var(--rows, 1fr);
}

.auth-gate-requirements .prereq-inner {
  overflow: hidden;
  min-height: 0;
}

.auth-gate-requirements h4 {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.auth-gate-requirements ul {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.auth-gate-requirements li {
  padding: 3px 0;
}

.auth-gate-requirements code {
  font-size: 0.75rem;
  background: #eee;
  padding: 1px 5px;
  border-radius: 3px;
}

.onboarding-steps {
  text-align: left;
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: var(--radius);
  padding: 20px 24px;
  margin: 12px 0;
  max-width: 520px;
}

.onboarding-steps h4 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text);
}

.onboarding-steps ol {
  padding-left: 20px;
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.onboarding-steps ul {
  margin: 4px 0 4px 8px;
  padding-left: 16px;
  list-style: disc;
}

.onboarding-steps code {
  font-size: 0.75rem;
  background: #FEF3C7;
  padding: 1px 5px;
  border-radius: 3px;
}

.onboarding-options {
  max-width: 520px;
  margin: 16px 0;
}

.onboarding-option {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}

.onboarding-option h4 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.onboarding-option p {
  font-size: 0.8rem !important;
  margin-bottom: 12px;
}

.onboarding-option .btn-primary,
.onboarding-option .btn-outline {
  display: inline-block;
  text-decoration: none;
  text-align: center;
}

.onboarding-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.onboarding-divider::before,
.onboarding-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border);
}

.onboarding-copy-row {
  display: flex;
  gap: 8px;
}

.onboarding-copy-row .form-input {
  flex: 1;
  font-size: 0.72rem;
  padding: 8px 10px;
}

.auth-gate-credits {
  margin-top: 20px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-secondary);
  max-width: 420px;
}

.auth-gate-credits p {
  margin: 4px 0;
  font-size: 0.78rem !important;
}

.credits-names {
  font-size: 0.72rem !important;
  color: var(--text-secondary) !important;
  opacity: 0.8;
}

.credits-support {
  font-size: 0.72rem !important;
  color: var(--text-secondary) !important;
  margin-top: 6px !important;
}
.credits-support a {
  color: var(--primary);
}

.auth-gate-hint {
  font-size: 0.8rem !important;
  color: var(--text-secondary) !important;
  margin-top: 16px;
}

.btn-download-ps {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 8px 18px;
  border-radius: 8px;
  background: #012456;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
}
.btn-download-ps:hover {
  background: #1a3a6e;
  transform: translateY(-1px);
}
.btn-download-ps:active {
  transform: translateY(0);
}
.btn-download-ps svg {
  flex-shrink: 0;
}

.about-section {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  margin-top: 16px;
}

.about-contributors {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.contributor {
  background: #f5f4ff;
  border: 1px solid #e0ddf7;
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
}

.prereq-box {
  margin-top: 28px;
  padding: 20px 24px;
  background: #f8f7ff;
  border: 1px solid #e0ddf5;
  border-radius: 8px;
  text-align: left;
  max-width: 480px;
}

.prereq-box h3 {
  margin: 0 0 12px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}

.prereq-box ul {
  margin: 0;
  padding-left: 20px;
}

.prereq-box li {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  line-height: 1.5;
}

.prereq-box li:last-child { margin-bottom: 0; }

.prereq-box code {
  background: #eee;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.78rem;
}

.prereq-box a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.prereq-box a:hover { text-decoration: underline; }

/* ── SETTINGS ── */
.settings-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  max-width: 640px;
  margin: 0 auto;
}

.settings-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.settings-status {
  margin: 12px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.settings-input-row {
  margin-bottom: 16px;
}

.settings-input-row .form-input {
  font-size: 0.9rem;
  padding: 10px 14px;
  font-family: monospace;
}

.settings-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
}

.settings-data-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 12px;
}

.settings-help {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  margin-top: 8px;
}

.settings-help h4 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.settings-help ol {
  padding-left: 20px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.8;
}

.settings-help code {
  background: #f0f0f0;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.8rem;
}

.table-status {
  text-align: center;
  padding: 16px;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ── DETAIL PANEL ── */
.detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
}

.detail-overlay.open { display: flex; justify-content: flex-end; }

.detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.2);
}

.detail-panel {
  position: relative;
  width: 500px;
  max-width: 92vw;
  height: 100vh;
  background: var(--surface);
  box-shadow: -4px 0 16px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  animation: slideIn 0.25s ease;
  overflow-y: auto;
}

@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--border);
}

.detail-head h2 { font-size: 1.2rem; font-weight: 700; }
.detail-subtitle { font-size: 0.8rem; color: var(--text-secondary); }

.detail-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
}

.detail-tabs {
  display: flex;
  gap: 0;
  padding: 0 24px;
  border-bottom: 2px solid var(--border);
}

.detail-tabs .tab { padding: 8px 16px; font-size: 0.82rem; }

.detail-body {
  flex: 1;
  padding: 16px 24px;
  overflow-y: auto;
}

.detail-section {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #f0f0f0;
}

.detail-section h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 10px;
}

.meta-grid {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 6px 12px;
  font-size: 0.82rem;
}

.meta-label { color: var(--text-secondary); }
.meta-value { font-weight: 500; word-break: break-all; }

.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.text-secondary { color: var(--text-secondary); font-size: 0.82rem; }

.element-group { margin-bottom: 12px; }
.element-group-title { font-weight: 600; font-size: 0.85rem; cursor: pointer; }
.element-group-title:hover { color: var(--primary); }
.element-item { font-size: 0.78rem; color: var(--text-secondary); margin: 4px 0 4px 16px; }
.element-def { font-family: monospace; font-size: 0.72rem; background: #f5f5f5; padding: 6px; border-radius: 4px; word-break: break-all; max-height: 120px; overflow-y: auto; margin-top: 4px; }

/* ── INLINE FORMS ── */
#inline-forms {
  padding: 0 24px 24px;
}

.inline-form {
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 12px;
}

.inline-form h4 { font-size: 0.9rem; font-weight: 600; margin-bottom: 12px; }

.inline-form label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 8px 0 4px;
}

.form-input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.82rem;
}

.form-input-sm {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.78rem;
}

.form-buttons {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.access-list {
  font-size: 0.82rem;
  margin-bottom: 8px;
}

.access-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid #f0f0f0;
}

.access-remove {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0 4px;
}

.add-access-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
}

/* ── CONFIRM DIALOG ── */
.confirm-dialog {
  border: none;
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
  padding: 28px;
  max-width: 400px;
  font-family: inherit;
}

.confirm-dialog::backdrop {
  background: rgba(0,0,0,0.3);
}

.confirm-dialog h3 { font-size: 1.1rem; margin-bottom: 8px; }
.confirm-dialog p { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 20px; }

.confirm-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── TOAST ── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 4.7s forwards;
  max-width: 380px;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--info); }

@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ── LOADING OVERLAY ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(245, 245, 245, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.spinner-ring {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.loading-text.loading-error {
  color: var(--danger);
  font-weight: 600;
  animation: none;
  max-width: 480px;
  text-align: center;
  line-height: 1.5;
}

/* ── CACHE AGE ── */
.cache-age {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-right: 12px;
}

/* ── TILE LIVE LOADING ── */
.tile-streaming {
  opacity: 0.7;
}

.tile-tick {
  animation: tileTick 0.3s ease;
}

@keyframes tileTick {
  0% { transform: scale(1); }
  40% { transform: scale(1.08); color: var(--primary); }
  100% { transform: scale(1); }
}

.tile-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(0,0,0,0.06);
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}

.tile-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #8b5cf6);
  border-radius: 0 0 var(--radius) var(--radius);
  transition: width 0.4s ease;
  position: relative;
}

.tile-progress-fill::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
  animation: barShimmer 1.5s infinite;
}

/* ── STREAM PROGRESS BAR ── */
.stream-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: linear-gradient(135deg, var(--primary-light), #f0efff);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--primary-dark);
  margin-bottom: 12px;
  overflow: hidden;
  position: relative;
}

.stream-progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  animation: streamPulse 1s ease-in-out infinite;
  flex-shrink: 0;
}

.stream-progress-text {
  flex: 1;
}

.stream-progress-bar-wrap {
  height: 4px;
  background: rgba(98,100,167,0.15);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 6px;
}

.stream-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #8b5cf6);
  border-radius: 2px;
  transition: width 0.4s ease;
  position: relative;
}

.stream-progress-bar-fill::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  animation: barShimmer 1.5s infinite;
}

@keyframes streamPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}

@keyframes barShimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ── SKELETON SHIMMER ── */
.skeleton {
  background: #e8e8f0;
  border-radius: 6px;
  position: relative;
  overflow: hidden;
}

.skeleton::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.skeleton-value {
  display: inline-block;
  width: 60px;
  height: 32px;
}

.skeleton-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.skeleton-bar-label {
  width: 80px;
  height: 14px;
}

.skeleton-bar-track {
  flex: 1;
  height: 14px;
}

.skeleton-bar-count {
  width: 28px;
  height: 14px;
}

.skeleton-gov-value {
  display: inline-block;
  width: 36px;
  height: 28px;
}

.skeleton-gov-item {
  width: 100%;
  height: 16px;
  margin-bottom: 6px;
}

/* ── RESPONSIVE ── */
/* Hamburger — hidden on desktop */
.btn-hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text);
  padding: 4px 8px;
  margin-right: 8px;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 89;
}

.sidebar-backdrop.open { display: block; }

/* ── MOBILE ── */
@media (max-width: 768px) {
  .app-layout { grid-template-columns: 1fr; }

  .btn-hamburger { display: block; }

  .sidebar {
    position: fixed;
    left: -260px;
    z-index: 90;
    transition: left 0.3s ease;
    width: 250px;
  }

  .sidebar.open { left: 0; }

  .page { padding: 16px; }
  .topbar { padding: 10px 12px; }

  .topbar-right { gap: 6px; font-size: 0.72rem; }
  .breadcrumb { font-size: 0.78rem; }
  .cache-age { display: none; }

  /* Page header */
  .page-header h1 { font-size: 1.2rem; }
  .page-desc { font-size: 0.8rem; }

  /* Overview */
  .summary-row { flex-direction: column; gap: 12px; }
  .summary-card { padding: 14px 16px; }
  .summary-card .summary-value { font-size: 1.8rem; }
  .analytics-grid { grid-template-columns: 1fr; }
  .governance-grid { grid-template-columns: 1fr; }

  /* Metric pills */
  .metric-pills { gap: 8px; }
  .metric-pill { padding: 8px 12px; }
  .metric-pill-value { font-size: 1rem; }

  /* Actions bar */
  .actions-bar { gap: 6px; }
  .actions-bar .btn-primary,
  .actions-bar .btn-outline { font-size: 0.75rem; padding: 6px 10px; }
  .toggle-label span:last-child { font-size: 0.75rem; }

  /* Filter bar — stack vertically */
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-spacer { display: none; }
  .filter-select { width: 100%; }
  .search-input { width: 100% !important; min-width: 0 !important; }
  .column-chooser { align-self: flex-end; }

  /* Table */
  .table-card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .virt-head-table,
  .virt-body-table { min-width: 600px; }
  .virt-scroll-container { max-height: calc(100vh - 200px); }

  th, td { padding: 8px 8px; font-size: 0.75rem; }
  .column-filter-row th { padding: 3px 4px; }
  .col-filter { font-size: 0.7rem; padding: 3px 4px; }

  /* Bulk bar */
  .bulk-bar { flex-wrap: wrap; font-size: 0.78rem; padding: 8px 12px; }

  /* Detail panel — full screen on mobile */
  .detail-panel {
    width: 100vw;
    max-width: 100vw;
  }

  .detail-head { padding: 14px 16px 10px; }
  .detail-head h2 { font-size: 1.1rem; }
  .detail-body { padding: 0 16px 16px; }
  .detail-actions-row { padding: 8px 16px; gap: 6px; flex-wrap: wrap; }
  .detail-actions-row .btn-sm { font-size: 0.72rem; padding: 4px 8px; }

  /* Auth gate */
  .auth-gate { padding: 24px 16px; min-height: 60vh; }
  .auth-gate h1 { font-size: 1.4rem; }
  .auth-gate p { font-size: 0.88rem; }

  /* Settings */
  .settings-card { padding: 16px; }
  .prereq-box { padding: 14px 16px; }
  .settings-help ol { padding-left: 16px; }
}

/* ── SMALL MOBILE (< 400px) ── */
@media (max-width: 400px) {
  .metric-pills { flex-direction: column; }
  .metric-pill { flex-direction: row; justify-content: space-between; }

  .actions-bar { flex-direction: column; }
  .toggle-label { margin-left: 0; }

  .detail-actions-row { justify-content: center; }
}
