/* ===== SMH Civil Scout — Design System (Bid Tabulations Theme) ===== */

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

/* --- CSS Custom Properties — SMH Brand --- */
:root {
  /* SMH Brand Colors */
  --smh-blue: #1B5FAA;
  --smh-blue-dark: #143D6B;
  --smh-blue-light: #2E7BD6;
  --smh-red: #D42027;
  --smh-red-dark: #A81A20;
  --smh-gold: #D4A843;

  /* Sidebar */
  --sidebar-bg: #143D6B;
  --sidebar-border: rgba(27, 95, 170, 0.3);
  --sidebar-text: #CBD5E1;
  --sidebar-text-hover: #FFFFFF;
  --sidebar-active-bg: #1B5FAA;
  --sidebar-width: 240px;

  /* Content area (light default) */
  --bg-primary: #F8FAFC;
  --bg-secondary: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F1F5F9;
  --bg-glass: rgba(0, 0, 0, 0.02);
  --bg-glass-border: #E2E8F0;

  /* Text */
  --text-primary: #1E293B;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --text-accent: #1B5FAA;

  /* Accent */
  --accent-blue: #1B5FAA;
  --accent-blue-glow: rgba(27, 95, 170, 0.15);
  --accent-amber: #F59E0B;
  --accent-amber-glow: rgba(245, 158, 11, 0.15);
  --accent-green: #10B981;
  --accent-green-glow: rgba(16, 185, 129, 0.15);
  --accent-red: #EF4444;
  --accent-red-glow: rgba(239, 68, 68, 0.15);
  --accent-purple: #8B5CF6;
  --accent-purple-glow: rgba(139, 92, 246, 0.15);
  --accent-cyan: #06B6D4;

  /* Status */
  --status-open: #10B981;
  --status-closing: #F59E0B;
  --status-planned: #1B5FAA;
  --status-predesign: #94A3B8;
  --status-bidclosed: #EF4444;

  /* Borders & shadows */
  --border-subtle: #F1F5F9;
  --border-medium: #E2E8F0;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-glow: 0 4px 16px rgba(0, 0, 0, 0.06);

  /* Spacing */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --- Dark Theme Override --- */
[data-theme="dark"] {
  --bg-primary: #0F172A;
  --bg-secondary: #1E293B;
  --bg-card: #1E293B;
  --bg-card-hover: #334155;
  --bg-glass: rgba(255, 255, 255, 0.04);
  --bg-glass-border: rgba(255, 255, 255, 0.08);

  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --text-accent: #60A5FA;

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-medium: rgba(255, 255, 255, 0.1);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 40px rgba(59, 130, 246, 0.08);
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
}

/* --- App Layout: Sidebar + Content --- */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
  z-index: 10;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo {
  height: 36px;
  width: auto;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
}

.sidebar-brand-title {
  color: #FFFFFF;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.2;
}

.sidebar-brand-sub {
  color: var(--smh-blue-light);
  font-size: 0.7rem;
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.sidebar-link:hover {
  background: rgba(27, 95, 170, 0.2);
  color: var(--sidebar-text-hover);
}

.sidebar-link.active {
  background: var(--sidebar-active-bg);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(27, 95, 170, 0.3);
}

.sidebar-link-icon {
  font-size: 1.35rem;
  width: 28px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--sidebar-border);
  text-align: center;
}

.sidebar-footer-established {
  color: var(--smh-gold);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
}

.sidebar-footer-tagline {
  color: var(--sidebar-text);
  font-size: 0.68rem;
  opacity: 0.7;
}

/* --- Main Content Area --- */
.main-content {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
}

/* --- Top Toolbar --- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-medium);
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- Page Content (scrollable) --- */
.page-content {
  flex: 1;
  padding: 28px 32px;
  max-width: 1600px;
}

/* --- Page Title --- */
.page-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* --- Status Badge in Toolbar --- */
.toolbar-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #10B981;
}

.toolbar-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10B981;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* --- Stats Grid --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  box-shadow: var(--shadow-card);
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.stat-card:nth-child(1)::before { background: var(--smh-blue); }
.stat-card:nth-child(2)::before { background: var(--accent-amber); }
.stat-card:nth-child(3)::before { background: var(--accent-green); }
.stat-card:nth-child(4)::before { background: var(--smh-red); }

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

.stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-primary);
  letter-spacing: -0.03em;
}

.stat-detail {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.stat-icon {
  font-size: 1.4rem;
  opacity: 0.7;
}

/* --- Tabs --- */
.tab-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
}

.tab-btn:hover {
  background: var(--bg-glass);
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--smh-blue);
  color: #FFFFFF;
  border-color: var(--smh-blue);
  box-shadow: 0 2px 8px rgba(27, 95, 170, 0.25);
}

.tab-count {
  background: rgba(255, 255, 255, 0.2);
  padding: 1px 7px;
  border-radius: 8px;
  font-size: 0.7rem;
  font-weight: 700;
}

.tab-btn:not(.active) .tab-count {
  background: var(--bg-glass);
  color: var(--text-muted);
}

/* --- Filters --- */
.filter-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-input,
.filter-select {
  padding: 8px 14px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
  transition: all var(--transition-fast);
  min-width: 160px;
}

.filter-input::placeholder {
  color: var(--text-muted);
}

.filter-input:focus,
.filter-select:focus {
  border-color: var(--smh-blue);
  box-shadow: 0 0 0 3px var(--accent-blue-glow);
}

/* Dropdown option readability in dark mode */
.filter-select option {
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 6px 10px;
}

[data-theme="dark"] .filter-select {
  color-scheme: dark;
}

[data-theme="dark"] .filter-select option {
  background: #1E293B;
  color: #E2E8F0;
}

.filter-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* --- Search --- */
.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 400px;
}

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

.search-input {
  width: 100%;
  padding: 8px 14px 8px 34px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
  transition: all var(--transition-fast);
}

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

.search-input:focus {
  border-color: var(--smh-blue);
  box-shadow: 0 0 0 3px var(--accent-blue-glow);
}

/* --- Data Table --- */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-medium);
  background: var(--bg-card);
  box-shadow: var(--shadow-card);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg-card-hover);
  border-bottom: 2px solid var(--border-medium);
  cursor: pointer;
  user-select: none;
  transition: color var(--transition-fast);
  white-space: nowrap;
}

.data-table th:hover {
  color: var(--text-primary);
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
  color: var(--text-secondary);
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* --- Sort indicator --- */
.sort-indicator {
  font-size: 0.65rem;
  margin-left: 4px;
  opacity: 0.5;
}

/* --- Status Badges --- */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.status-badge.open {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
}

.status-badge.closing-soon {
  background: rgba(245, 158, 11, 0.1);
  color: #D97706;
}

.status-badge.planned, .status-badge.future {
  background: rgba(27, 95, 170, 0.1);
  color: #1B5FAA;
}

.status-badge.pre-design {
  background: rgba(148, 163, 184, 0.15);
  color: #64748B;
}

.status-badge.new-today {
  background: rgba(139, 92, 246, 0.1);
  color: #7C3AED;
}

.status-badge.bid-closed, .status-badge.under-construction {
  background: rgba(212, 32, 39, 0.08);
  color: #D42027;
}

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* --- Work Scope Badges --- */
.scope-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  margin: 2px 3px;
  text-transform: capitalize;
  white-space: nowrap;
}

/* Scope cell: wrap badges neatly */
.scope-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 4px;
  max-width: 180px;
}

/* scope-tags container used by app.js */
.scope-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 5px;
  max-width: 200px;
}

/* scope-tag used by app.js (mirrors scope-badge) */
.scope-tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
  text-transform: capitalize;
}

.scope-tag.utilities { background: rgba(6, 182, 212, 0.12); color: #0E7490; }
.scope-tag.grading { background: rgba(245, 158, 11, 0.12); color: #B45309; }
.scope-tag.paving { background: rgba(99, 102, 241, 0.12); color: #4338CA; }
.scope-tag.structures { background: rgba(239, 68, 68, 0.12); color: #DC2626; }
.scope-tag.site-mgmt { background: rgba(168, 85, 247, 0.12); color: #7C3AED; }

[data-theme="dark"] .scope-tag.utilities { background: rgba(6, 182, 212, 0.2); color: #67E8F9; }
[data-theme="dark"] .scope-tag.grading { background: rgba(245, 158, 11, 0.2); color: #FBBF24; }
[data-theme="dark"] .scope-tag.paving { background: rgba(99, 102, 241, 0.2); color: #A5B4FC; }
[data-theme="dark"] .scope-tag.structures { background: rgba(239, 68, 68, 0.2); color: #FCA5A5; }
[data-theme="dark"] .scope-tag.site-mgmt { background: rgba(168, 85, 247, 0.2); color: #C4B5FD; }

.scope-badge.grading { background: rgba(245, 158, 11, 0.12); color: #B45309; }
.scope-badge.paving { background: rgba(99, 102, 241, 0.12); color: #4338CA; }
.scope-badge.utilities { background: rgba(6, 182, 212, 0.12); color: #0E7490; }
.scope-badge.bridge { background: rgba(239, 68, 68, 0.12); color: #DC2626; }
.scope-badge.concrete { background: rgba(107, 114, 128, 0.12); color: #374151; }
.scope-badge.demolition { background: rgba(168, 85, 247, 0.12); color: #7C3AED; }
.scope-badge.stormwater { background: rgba(20, 184, 166, 0.12); color: #0D9488; }
.scope-badge.earthwork { background: rgba(180, 83, 9, 0.12); color: #92400E; }
.scope-badge.erosion { background: rgba(34, 197, 94, 0.12); color: #15803D; }
.scope-badge.landscaping { background: rgba(22, 163, 74, 0.12); color: #15803D; }

[data-theme="dark"] .scope-badge.grading { background: rgba(245, 158, 11, 0.2); color: #FBBF24; }
[data-theme="dark"] .scope-badge.paving { background: rgba(99, 102, 241, 0.2); color: #A5B4FC; }
[data-theme="dark"] .scope-badge.utilities { background: rgba(6, 182, 212, 0.2); color: #67E8F9; }
[data-theme="dark"] .scope-badge.bridge { background: rgba(239, 68, 68, 0.2); color: #FCA5A5; }
[data-theme="dark"] .scope-badge.concrete { background: rgba(107, 114, 128, 0.2); color: #D1D5DB; }
[data-theme="dark"] .scope-badge.demolition { background: rgba(168, 85, 247, 0.2); color: #C4B5FD; }
[data-theme="dark"] .scope-badge.stormwater { background: rgba(20, 184, 166, 0.2); color: #5EEAD4; }
[data-theme="dark"] .scope-badge.earthwork { background: rgba(180, 83, 9, 0.2); color: #FCD34D; }
[data-theme="dark"] .scope-badge.erosion { background: rgba(34, 197, 94, 0.2); color: #86EFAC; }
[data-theme="dark"] .scope-badge.landscaping { background: rgba(22, 163, 74, 0.2); color: #86EFAC; }

/* --- Value styling --- */
.est-value {
  font-weight: 700;
  color: var(--accent-green);
  white-space: nowrap;
}

/* --- State badge --- */
.state-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
}

.state-badge.mn { background: rgba(27, 95, 170, 0.12); color: #1B5FAA; }
.state-badge.ia { background: rgba(245, 158, 11, 0.12); color: #B45309; }
.state-badge.wi { background: rgba(212, 32, 39, 0.12); color: #D42027; }
.state-badge.ne { background: rgba(212, 168, 67, 0.12); color: #92400E; }
.state-badge.co { background: rgba(99, 102, 241, 0.12); color: #4338CA; }
.state-badge.nd { background: rgba(16, 185, 129, 0.12); color: #059669; }
.state-badge.sd { background: rgba(6, 182, 212, 0.12); color: #0E7490; }

[data-theme="dark"] .state-badge.mn { background: rgba(27, 95, 170, 0.25); color: #60A5FA; }
[data-theme="dark"] .state-badge.ia { background: rgba(245, 158, 11, 0.25); color: #FBBF24; }
[data-theme="dark"] .state-badge.wi { background: rgba(212, 32, 39, 0.25); color: #FCA5A5; }
[data-theme="dark"] .state-badge.ne { background: rgba(212, 168, 67, 0.25); color: #FCD34D; }
[data-theme="dark"] .state-badge.co { background: rgba(99, 102, 241, 0.25); color: #A5B4FC; }
[data-theme="dark"] .state-badge.nd { background: rgba(16, 185, 129, 0.25); color: #6EE7B7; }
[data-theme="dark"] .state-badge.sd { background: rgba(6, 182, 212, 0.25); color: #67E8F9; }

/* --- Source links --- */
.source-link {
  color: var(--smh-blue);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.78rem;
  transition: color var(--transition-fast);
}

.source-link:hover {
  color: var(--smh-blue-light);
  text-decoration: underline;
}

.source-sub {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: var(--smh-blue);
  color: #FFFFFF;
}

.btn-primary:hover {
  background: var(--smh-blue-light);
  box-shadow: 0 4px 12px rgba(27, 95, 170, 0.3);
}

.btn-export {
  background: var(--smh-blue);
  color: #FFFFFF;
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-export:hover {
  background: var(--smh-blue-light);
  box-shadow: 0 4px 12px rgba(27, 95, 170, 0.3);
}

.btn-reload {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
}

.btn-reload:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--smh-blue);
}

.btn-theme {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
}

.btn-theme:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  background: rgba(212, 32, 39, 0.06);
  border: 1px solid rgba(212, 32, 39, 0.15);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--smh-red);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
}

.btn-logout:hover {
  background: rgba(212, 32, 39, 0.12);
  border-color: rgba(212, 32, 39, 0.3);
}

.btn-hub {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  background: rgba(27, 95, 170, 0.08);
  border: 1px solid rgba(27, 95, 170, 0.25);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--smh-blue);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
}

.btn-hub:hover {
  background: rgba(27, 95, 170, 0.15);
  border-color: rgba(27, 95, 170, 0.4);
}

.btn-admin {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  background: rgba(139, 92, 246, 0.06);
  border: 1px solid rgba(139, 92, 246, 0.15);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  color: #7C3AED;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
}

.btn-admin:hover {
  background: rgba(139, 92, 246, 0.12);
  border-color: rgba(139, 92, 246, 0.3);
}

.btn-back {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
}

.btn-back:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

/* --- Project Name Link --- */
.project-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.82rem;
  line-height: 1.35;
}

.project-sub {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* --- Footer --- */
.footer {
  padding: 16px 32px;
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: -60px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 24px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 600;
  z-index: 9999;
  transition: bottom var(--transition-spring);
  background: var(--sidebar-bg);
  color: #FFFFFF;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.toast.show {
  bottom: 24px;
}

/* --- Skip checkbox --- */
.skip-checkbox {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--smh-blue);
}

.skip-checkbox:checked {
  accent-color: var(--accent-red);
}

/* --- Multi-select / custom selects --- */
.multi-select-container {
  position: relative;
}

.multi-select-display {
  padding: 8px 14px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.82rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-width: 160px;
  transition: all var(--transition-fast);
  font-family: inherit;
}

.multi-select-display:hover {
  border-color: var(--smh-blue);
}

.multi-select-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  z-index: 100;
  max-height: 300px;
  overflow-y: auto;
}

.multi-select-dropdown.hidden {
  display: none;
}

.multi-select-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-secondary);
  transition: background var(--transition-fast);
}

.multi-select-option:hover {
  background: var(--bg-card-hover);
}

.multi-select-option.selected {
  color: var(--smh-blue);
  font-weight: 600;
}

/* --- Document link icons --- */
.doc-link {
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: color var(--transition-fast);
  text-decoration: none;
}

.doc-link:hover {
  color: var(--smh-blue);
}

/* --- Interest badges --- */
.interest-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 700;
}

.interest-badge.interested {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
}

.interest-badge.not-interested {
  background: rgba(239, 68, 68, 0.08);
  color: #DC2626;
}

.interest-badge.watching {
  background: rgba(245, 158, 11, 0.1);
  color: #D97706;
}

/* --- Crawl Progress Bar --- */
.crawl-progress {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  margin-bottom: 0;
  transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.4s ease,
              margin-bottom 0.4s ease;
}

.crawl-progress.visible {
  max-height: 200px;
  opacity: 1;
  margin-bottom: 16px;
}

.crawl-progress {
  background: var(--sidebar-bg);
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius-lg);
  padding: 16px 22px;
  font-family: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
}

.crawl-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.crawl-progress-phase {
  font-size: 0.85rem;
  font-weight: 600;
  color: #67E8F9;
  letter-spacing: 0.02em;
}

.crawl-progress-count {
  font-size: 0.78rem;
  font-weight: 700;
  color: #CBD5E1;
  background: rgba(255, 255, 255, 0.1);
  padding: 3px 10px;
  border-radius: 10px;
}

.crawl-progress-bar {
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.crawl-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 6px;
  background: linear-gradient(90deg, #06B6D4, #10B981);
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.4);
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.crawl-progress-fill::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.15) 50%, transparent 100%);
  animation: shimmer 2s infinite;
}

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

.crawl-progress-fill.complete {
  background: linear-gradient(90deg, #10B981, #34D399);
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.5);
}

.crawl-progress-fill.complete::after { animation: none; }

.crawl-progress-detail {
  margin-top: 8px;
  font-size: 0.72rem;
  color: #94A3B8;
  letter-spacing: 0.01em;
}

/* --- Login Page --- */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 24px;
  background: linear-gradient(135deg, #0F172A 0%, #143D6B 100%);
}

.login-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
}

.login-orb-1 {
  top: -15%; left: -10%;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(27, 95, 170, 0.2) 0%, transparent 70%);
  animation: float1 8s ease-in-out infinite;
}

.login-orb-2 {
  bottom: -15%; right: -10%;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(212, 168, 67, 0.1) 0%, transparent 70%);
  animation: float2 10s ease-in-out infinite;
}

@keyframes float1 {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(30px, 20px); }
}

@keyframes float2 {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-20px, -30px); }
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: rgba(30, 41, 59, 0.85);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(27, 95, 170, 0.2);
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.3);
  position: relative;
  z-index: 1;
  animation: loginFadeIn 0.6s ease-out;
}

@keyframes loginFadeIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-card.shake { animation: loginShake 0.4s ease-in-out; }

@keyframes loginShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-12px); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-8px); }
  80% { transform: translateX(6px); }
}

.login-header { text-align: center; margin-bottom: 32px; }
.login-logo { height: 48px; width: auto; margin-bottom: 16px; }
.login-title {
  font-size: 1.6rem; font-weight: 800;
  letter-spacing: -0.03em;
  color: #FFFFFF;
  margin-bottom: 4px;
}

.login-subtitle { font-size: 0.82rem; color: #94A3B8; }

.login-form { display: flex; flex-direction: column; gap: 18px; }

.login-field { display: flex; flex-direction: column; gap: 6px; }

.login-label {
  font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94A3B8;
  padding-left: 2px;
}

.login-input-wrap { position: relative; display: flex; align-items: center; }

.login-input-icon {
  position: absolute; left: 14px;
  width: 16px; height: 16px;
  color: #64748B;
  pointer-events: none;
}

.login-input {
  width: 100%;
  padding: 12px 48px 12px 40px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  color: #F1F5F9;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: all var(--transition-fast);
}

.login-input::placeholder { color: #64748B; }

.login-input:focus {
  border-color: var(--smh-blue);
  box-shadow: 0 0 0 3px rgba(27, 95, 170, 0.25);
  background: rgba(255, 255, 255, 0.08);
}

.login-eye {
  position: absolute; right: 8px;
  background: none; border: none;
  cursor: pointer; font-size: 1rem;
  padding: 6px; opacity: 0.5;
  transition: opacity var(--transition-fast);
}

.login-eye:hover { opacity: 1; }

.login-error {
  font-size: 0.8rem;
  color: var(--smh-red);
  min-height: 1.2em;
  text-align: center;
}

.login-submit {
  width: 100%; padding: 13px;
  background: var(--smh-blue);
  border: none; border-radius: var(--radius-md);
  color: white; font-size: 0.92rem;
  font-weight: 700; font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-smooth);
  position: relative; overflow: hidden;
}

.login-submit:hover:not(:disabled) {
  background: var(--smh-blue-light);
  box-shadow: 0 6px 24px rgba(27, 95, 170, 0.4);
  transform: translateY(-1px);
}

.login-submit:disabled { opacity: 0.7; cursor: not-allowed; }
.login-submit.loading .login-submit-text { opacity: 0.6; }
.login-submit-spinner { display: none; }

.login-submit.loading .login-submit-spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}

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

.login-footer { margin-top: 28px; text-align: center; font-size: 0.7rem; color: #64748B; }

/* --- Admin Panel --- */
.admin-section {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-card);
}

.admin-section-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.admin-section-title { font-size: 1.05rem; font-weight: 700; color: var(--text-primary); }

.admin-count {
  font-size: 0.78rem; font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-glass);
  padding: 4px 12px; border-radius: 10px;
}

.admin-table th { cursor: default; }

.admin-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 18px;
}

.admin-field { display: flex; flex-direction: column; gap: 6px; }

.admin-label {
  font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.admin-input {
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.85rem; font-family: inherit;
  outline: none;
  transition: all var(--transition-fast);
}

.admin-input::placeholder { color: var(--text-muted); }

.admin-input:focus {
  border-color: var(--smh-blue);
  box-shadow: 0 0 0 3px var(--accent-blue-glow);
}

.admin-form-actions { display: flex; align-items: center; gap: 12px; }
.admin-feedback { font-size: 0.8rem; }

/* Role badges */
.role-badge {
  display: inline-block; padding: 3px 10px;
  border-radius: 10px; font-size: 0.72rem;
  font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em;
}

.role-admin { background: rgba(139, 92, 246, 0.12); color: #7C3AED; }
.role-user { background: rgba(27, 95, 170, 0.12); color: #1B5FAA; }

[data-theme="dark"] .role-admin { background: rgba(139, 92, 246, 0.2); color: #A78BFA; }
[data-theme="dark"] .role-user { background: rgba(27, 95, 170, 0.2); color: #60A5FA; }

/* User table cells */
.user-username {
  font-weight: 600; color: var(--text-primary);
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  font-size: 0.82rem;
}

.user-name { color: var(--text-secondary); }

/* Password reveal */
.pw-masked { color: var(--text-muted); letter-spacing: 0.1em; font-size: 0.85rem; }
.pw-plain { font-family: 'Cascadia Code', 'Fira Code', monospace; font-size: 0.82rem; color: var(--text-primary); }

.btn-eye {
  background: none; border: none; cursor: pointer;
  font-size: 0.85rem; padding: 2px 6px; margin-left: 6px;
  opacity: 0.4; transition: opacity var(--transition-fast); vertical-align: middle;
}

.btn-eye:hover { opacity: 1; }

/* Delete button */
.btn-delete {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 12px;
  background: rgba(212, 32, 39, 0.06);
  border: 1px solid rgba(212, 32, 39, 0.15);
  border-radius: var(--radius-sm);
  font-size: 0.72rem; font-weight: 600;
  color: var(--smh-red);
  cursor: pointer; transition: all var(--transition-fast);
  font-family: inherit;
}

.btn-delete:hover {
  background: rgba(212, 32, 39, 0.12);
  border-color: rgba(212, 32, 39, 0.3);
}

/* --- Header badge (toolbar) --- */
.header-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: 20px;
  font-size: 0.72rem; font-weight: 600;
  color: var(--text-secondary);
}

/* --- Agent Intelligence: Relevance Badges --- */
.relevance-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.62rem;
  font-weight: 700;
  margin-left: 6px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.relevance-badge.hot {
  background: rgba(239, 68, 68, 0.12);
  color: #DC2626;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.relevance-badge.good {
  background: rgba(27, 95, 170, 0.1);
  color: #1B5FAA;
  border: 1px solid rgba(27, 95, 170, 0.2);
}

[data-theme="dark"] .relevance-badge.hot {
  background: rgba(239, 68, 68, 0.2);
  color: #FCA5A5;
  border-color: rgba(239, 68, 68, 0.35);
}

[data-theme="dark"] .relevance-badge.good {
  background: rgba(96, 165, 250, 0.15);
  color: #93C5FD;
  border-color: rgba(96, 165, 250, 0.3);
}

/* Agent match reasons */
.match-reasons {
  font-size: 0.62rem;
  color: var(--text-muted);
  margin-top: 2px;
  opacity: 0.7;
}

/* --- Link Validation Status --- */
.link-indicator {
  font-size: 0.6rem;
  margin-left: 2px;
  font-weight: 700;
}

.doc-badge.link-ok .link-indicator { color: #16A34A; }
.doc-badge.link-warn .link-indicator { color: #D97706; }
.doc-badge.link-broken .link-indicator { color: #DC2626; }

[data-theme="dark"] .doc-badge.link-ok .link-indicator { color: #4ADE80; }
[data-theme="dark"] .doc-badge.link-warn .link-indicator { color: #FBBF24; }
[data-theme="dark"] .doc-badge.link-broken .link-indicator { color: #FCA5A5; }

.doc-badge.link-broken {
  opacity: 0.5;
  text-decoration: line-through;
}

/* --- Sidebar admin at bottom --- */
.sidebar-admin {
  margin-top: auto;
  margin-bottom: 8px;
  opacity: 0.7;
  font-size: 0.82rem;
}
.sidebar-admin:hover { opacity: 1; }

/* --- Deep Dive Analyze UI --- */
.analyze-col { width: 36px; text-align: center; }
.analyze-checkbox { cursor: pointer; }
.analyze-status-badge { font-size: 0.9rem; cursor: default; }
.analyze-status-badge.pending { animation: pulse-report 1.5s ease-in-out infinite; }
.analyze-status-badge.failed { opacity: 0.8; }
.report-icon {
  display: inline-block; font-size: 0.85rem; margin-left: 4px;
  text-decoration: none; cursor: pointer;
  animation: pulse-report 2s ease-in-out infinite;
}
@keyframes pulse-report {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Floating action bar */
.analyze-bar {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px;
  padding: 12px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  z-index: 1000;
  font-size: 0.85rem; font-weight: 600;
  color: var(--text-primary);
}

.btn-analyze {
  padding: 8px 20px; border-radius: 8px;
  background: linear-gradient(135deg, #1B5FAA, #2563EB);
  color: white; border: none;
  font-size: 0.82rem; font-weight: 700;
  cursor: pointer; font-family: inherit;
  transition: all var(--transition-fast);
}
.btn-analyze:hover { background: linear-gradient(135deg, #1a4f8a, #1d4ed8); transform: translateY(-1px); }
.btn-analyze:disabled { opacity: 0.6; cursor: wait; }

/* --- Responsive --- */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .page-content { padding: 16px; }
  .toolbar { padding: 12px 16px; }
  .stats-grid { grid-template-columns: 1fr; }
  .filter-row { flex-direction: column; align-items: stretch; }
}