/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f8fafb;
  color: #1a1a2e;
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: #fff;
  border-right: 1px solid #e8ecf0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
}
.sidebar-header { padding: 20px 20px 16px; }
.logo { display: flex; align-items: center; gap: 10px; }
.logo-text { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 1.1rem; color: #1a1a2e; }
.sidebar-nav { flex: 1; padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  background: none; border: none; cursor: pointer;
  font-size: 0.875rem; font-weight: 500; color: #64748b;
  text-align: left; width: 100%; transition: all 0.15s;
}
.nav-item:hover { background: #f1f5f9; color: #1a1a2e; }
.nav-item.active { background: #ecfdf5; color: #16a34a; }
.nav-badge {
  margin-left: auto; background: #e8ecf0; color: #64748b;
  font-size: 0.7rem; padding: 2px 8px; border-radius: 10px; font-weight: 600;
}
.sidebar-footer {
  padding: 16px 20px; border-top: 1px solid #e8ecf0;
  font-size: 0.75rem; color: #94a3b8;
}
.sidebar-stats { font-weight: 600; color: #16a34a; margin-bottom: 4px; }

/* ── Main Content ── */
.main-content { flex: 1; overflow-y: auto; height: 100vh; }
.page { display: none; padding: 40px 60px; max-width: 960px; margin: 0 auto; }
.page.active { display: block; }

/* ── Dashboard Home ── */
.dashboard-home { text-align: center; padding-top: 60px; }
.hero-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2.4rem; font-weight: 700; color: #1a1a2e; margin-bottom: 8px;
}
.hero-sub { color: #64748b; font-size: 1.05rem; margin-bottom: 36px; }

/* Search Box */
.search-box {
  background: #fff; border: 1.5px solid #e2e8f0; border-radius: 16px;
  padding: 16px 18px 12px; max-width: 680px; margin: 0 auto 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-box:focus-within {
  border-color: #16a34a; box-shadow: 0 0 0 3px rgba(22,163,74,0.1);
}
#search-input {
  width: 100%; border: none; outline: none; resize: none;
  font-family: inherit; font-size: 0.95rem; color: #1a1a2e;
  line-height: 1.5; background: transparent;
}
#search-input::placeholder { color: #94a3b8; }
.search-controls { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }

/* Company Selector */
.company-selector { position: relative; }
.company-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 20px;
  background: #f1f5f9; border: 1px solid #e2e8f0; cursor: pointer;
  font-size: 0.8rem; color: #475569; font-weight: 500; transition: all 0.15s;
}
.company-btn:hover { background: #e2e8f0; }
.company-dropdown {
  position: absolute; bottom: 100%; left: 0; margin-bottom: 6px;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12); min-width: 220px; z-index: 100;
  padding: 6px;
}
.company-dropdown.hidden { display: none; }
.dropdown-header { padding: 8px 12px; font-size: 0.7rem; font-weight: 600; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.05em; }
.dropdown-item {
  padding: 8px 12px; border-radius: 8px; cursor: pointer;
  font-size: 0.85rem; color: #334155; transition: background 0.1s;
}
.dropdown-item:hover { background: #f1f5f9; }
.dropdown-item.active { color: #16a34a; font-weight: 600; }
.dropdown-item.active::after { content: ' \2713'; }

/* Send Button */
.send-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: #16a34a; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #fff; transition: background 0.15s;
}
.send-btn:hover { background: #15803d; }
.send-btn:disabled { background: #94a3b8; cursor: not-allowed; }

/* Scope Bar */
.scope-bar {
  display: flex; align-items: center; gap: 8px;
  justify-content: center; margin-bottom: 32px;
}
.scope-label { display: flex; align-items: center; gap: 4px; font-size: 0.8rem; color: #64748b; font-weight: 500; }
.scope-btn {
  padding: 5px 14px; border-radius: 18px; border: 1.5px solid #e2e8f0;
  background: #fff; font-size: 0.8rem; font-weight: 500; color: #64748b;
  cursor: pointer; transition: all 0.15s;
}
.scope-btn.active { background: #f0fdf4; border-color: #16a34a; color: #16a34a; }
.scope-btn.small { padding: 4px 10px; font-size: 0.75rem; }

/* Quick Cards */
.quick-cards {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  max-width: 680px; margin: 0 auto;
}
.quick-card {
  background: #fff; border: 1px solid #e8ecf0; border-radius: 14px;
  padding: 20px; text-align: left; cursor: pointer;
  transition: all 0.2s; position: relative;
}
.quick-card:hover { border-color: #16a34a; box-shadow: 0 4px 12px rgba(22,163,74,0.08); transform: translateY(-1px); }
.card-icon {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; margin-bottom: 12px;
}
.card-icon.green { background: #ecfdf5; color: #16a34a; }
.card-icon.blue { background: #eff6ff; color: #2563eb; }
.card-icon.teal { background: #f0fdfa; color: #0d9488; }
.card-icon.orange { background: #fff7ed; color: #ea580c; }
.quick-card h3 { font-size: 0.9rem; font-weight: 600; margin-bottom: 6px; color: #1a1a2e; }
.quick-card p { font-size: 0.8rem; color: #64748b; line-height: 1.4; }

/* ── Search Results ── */
.search-results { text-align: left; }
.results-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.back-btn {
  display: flex; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer;
  font-size: 0.85rem; color: #16a34a; font-weight: 500;
}
.back-btn:hover { color: #15803d; }
.results-count { font-size: 0.8rem; color: #94a3b8; }
.results-scope { justify-content: flex-start; margin-bottom: 16px; }

/* Chat Bubbles */
.chat-bubble {
  max-width: 85%; padding: 14px 18px; border-radius: 16px;
  font-size: 0.9rem; line-height: 1.6; margin-bottom: 12px;
}
.chat-bubble.user {
  background: #16a34a; color: #fff; margin-left: auto;
  border-bottom-right-radius: 4px;
}
.chat-bubble.assistant {
  background: #fff; border: 1px solid #e8ecf0;
  border-bottom-left-radius: 4px; color: #334155;
}

/* Typing Indicator */
.typing-indicator { display: flex; gap: 4px; padding: 4px 0; }
.typing-indicator span {
  width: 7px; height: 7px; background: #94a3b8; border-radius: 50%;
  animation: typing 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Results List */
.results-list { display: flex; flex-direction: column; gap: 10px; }
.result-card {
  background: #fff; border: 1px solid #e8ecf0; border-radius: 14px;
  padding: 18px 20px; display: flex; align-items: flex-start; gap: 16px;
  transition: border-color 0.15s;
}
.result-card:hover { border-color: #cbd5e1; }
.result-info { flex: 1; min-width: 0; }
.result-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.result-name { font-weight: 600; font-size: 0.95rem; color: #1a1a2e; }
.result-level {
  font-size: 0.65rem; font-weight: 600; padding: 2px 8px;
  border-radius: 10px; text-transform: uppercase; letter-spacing: 0.03em;
}
.level-Federal { background: #eff6ff; color: #2563eb; }
.level-Provincial { background: #faf5ff; color: #7c3aed; }
.level-Regional { background: #fff7ed; color: #ea580c; }
.level-Other { background: #f1f5f9; color: #64748b; }
.result-org { font-size: 0.8rem; color: #94a3b8; margin-bottom: 6px; }
.result-desc { font-size: 0.83rem; color: #475569; line-height: 1.5; margin-bottom: 8px; }
.result-meta { display: flex; gap: 16px; flex-wrap: wrap; }
.result-meta span { font-size: 0.78rem; color: #64748b; display: flex; align-items: center; gap: 4px; }
.result-meta .amount { color: #16a34a; font-weight: 600; }
.result-meta .deadline { color: #94a3b8; }
.result-score {
  min-width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; color: #fff; flex-shrink: 0;
}
.score-high { background: #16a34a; }
.score-med { background: #eab308; }
.score-low { background: #94a3b8; }
.result-link {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.78rem; color: #16a34a; text-decoration: none; font-weight: 500;
}
.result-link:hover { text-decoration: underline; }
.result-closed {
  font-size: 0.7rem; font-weight: 600; color: #dc2626;
  background: #fef2f2; padding: 2px 8px; border-radius: 8px;
}

/* ── Programs List Page ── */
.programs-header h1 { font-family: 'Space Grotesk', sans-serif; font-size: 1.6rem; margin-bottom: 16px; }
.programs-toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.programs-filter {
  flex: 1; min-width: 250px; padding: 10px 14px; border: 1.5px solid #e2e8f0;
  border-radius: 10px; font-size: 0.85rem; font-family: inherit; outline: none;
  transition: border-color 0.2s;
}
.programs-filter:focus { border-color: #16a34a; }
.programs-scope { display: flex; gap: 6px; }
.programs-table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid #e8ecf0; }
.programs-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.programs-table th {
  background: #f8fafb; padding: 10px 14px; text-align: left;
  font-weight: 600; color: #64748b; border-bottom: 1px solid #e8ecf0;
  white-space: nowrap; position: sticky; top: 0;
}
.programs-table th.sortable { cursor: pointer; }
.programs-table th.sortable:hover { color: #16a34a; }
.programs-table td { padding: 10px 14px; border-bottom: 1px solid #f1f5f9; color: #334155; }
.programs-table tr:hover td { background: #fafffe; }
.programs-table a { color: #16a34a; text-decoration: none; }
.programs-table a:hover { text-decoration: underline; }
.programs-status { padding: 12px 0; font-size: 0.8rem; color: #94a3b8; text-align: center; }
.sort-arrow { font-size: 0.7rem; }

/* ── About Page ── */
.about-content { max-width: 700px; }
.about-content h1 { font-family: 'Space Grotesk', sans-serif; font-size: 1.8rem; margin-bottom: 16px; }
.about-content h2 { font-size: 1.1rem; margin: 24px 0 8px; color: #1a1a2e; }
.about-content p { color: #475569; line-height: 1.7; margin-bottom: 12px; font-size: 0.92rem; }
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px; margin-top: 24px;
}
.stat-card {
  background: #fff; border: 1px solid #e8ecf0; border-radius: 12px;
  padding: 16px; text-align: center;
}
.stat-card .stat-value { font-size: 1.4rem; font-weight: 700; color: #16a34a; }
.stat-card .stat-label { font-size: 0.75rem; color: #94a3b8; margin-top: 4px; }

/* ── Suggestions Nav ── */
.nav-divider { height: 1px; background: #e8ecf0; margin: 10px 8px; }
.nav-section-label {
  font-size: 0.7rem; font-weight: 600; color: #94a3b8;
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 6px 12px 4px;
}
.suggestions-nav { display: flex; flex-direction: column; gap: 1px; }
.sug-nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: 8px;
  background: none; border: none; cursor: pointer;
  font-size: 0.82rem; font-weight: 500; color: #64748b;
  text-align: left; width: 100%; transition: all 0.15s;
}
.sug-nav-item:hover { background: #f1f5f9; color: #1a1a2e; }
.sug-nav-item.active { background: #ecfdf5; color: #16a34a; }
.sug-dot {
  width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0;
}
.sug-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sug-badge {
  margin-left: auto; background: #e8ecf0; color: #64748b;
  font-size: 0.68rem; padding: 1px 7px; border-radius: 10px; font-weight: 600;
}
.sug-nav-item.active .sug-badge { background: #dcfce7; color: #16a34a; }

/* ── Suggestions Page ── */
.suggestions-header { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.suggestions-header h1 { font-family: 'Space Grotesk', sans-serif; font-size: 1.4rem; flex: 1; }
.suggestions-scope { justify-content: flex-start; margin-bottom: 16px; }

/* ── Requirements Accordion ── */
.req-accordion { margin-top: 10px; }
.req-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 1px solid #e2e8f0; border-radius: 8px;
  padding: 5px 12px; cursor: pointer;
  font-size: 0.78rem; font-weight: 500; color: #64748b;
  transition: all 0.15s;
}
.req-toggle:hover { background: #f8fafb; border-color: #cbd5e1; color: #334155; }
.req-plus { font-weight: 700; font-size: 0.9rem; width: 12px; text-align: center; }
.req-count-pill {
  font-size: 0.7rem; font-weight: 600; padding: 1px 8px;
  border-radius: 10px; margin-left: 4px;
  background: #f1f5f9; color: #64748b;
}
.req-count-pill.pill-good { background: #dcfce7; color: #16a34a; }
.req-count-pill.pill-partial { background: #fef9c3; color: #a16207; }
.req-count-pill.pill-warn { background: #fef2f2; color: #dc2626; }

.req-panel { padding: 10px 0 2px; }
.req-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.req-cell {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 8px 10px; border-radius: 8px;
  font-size: 0.76rem; line-height: 1.35;
}
.req-cell svg { flex-shrink: 0; margin-top: 1px; }
.req-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.req-label { font-weight: 500; color: #334155; }
.req-detail { font-size: 0.68rem; color: #94a3b8; }

.req-cell.req-met { background: #f0fdf4; }
.req-cell.req-met .req-label { color: #166534; }
.req-cell.req-unknown { background: #fefce8; }
.req-cell.req-unknown .req-label { color: #854d0e; }
.req-cell.req-unmet { background: #fef2f2; }
.req-cell.req-unmet .req-label { color: #991b1b; }
.req-cell.req-neutral { background: #f8fafb; }
.req-cell.req-neutral .req-label { color: #475569; }
.req-cell.req-info { background: #eff6ff; border-left: 3px solid #3b82f6; }
.req-cell.req-info .req-label { color: #1e40af; }

/* ── Ineligible Section ── */
.ineligible-section { margin-top: 20px; padding-top: 16px; border-top: 1px dashed #e2e8f0; }
.ineligible-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  background: none; border: none; cursor: pointer;
  font-size: 0.85rem; font-weight: 500; color: #94a3b8;
  padding: 6px 0; transition: color 0.15s;
}
.ineligible-toggle:hover { color: #64748b; }
.ineligible-count {
  background: #f1f5f9; color: #94a3b8; font-size: 0.7rem;
  padding: 1px 8px; border-radius: 10px; font-weight: 600;
}
.ineligible-list { padding-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.result-card-dimmed { opacity: 0.55; }
.result-card-dimmed:hover { opacity: 0.8; }

/* ── Smart Questions Bubble ── */
.questions-bubble {
  background: linear-gradient(135deg, #ecfdf5 0%, #f0fdf4 100%);
  border: 1px solid #bbf7d0; border-radius: 14px;
  padding: 14px 52px 14px 18px;
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 20px; position: relative;
  animation: slideDown 0.3s ease-out;
}
@keyframes slideDown { from { transform: translateY(-100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.qb-close {
  position: absolute; top: 8px; right: 16px;
  background: none; border: none; cursor: pointer;
  font-size: 1.3rem; color: #94a3b8; line-height: 1;
  padding: 4px;
}
.qb-close:hover { color: #64748b; }
.qb-icon { flex-shrink: 0; color: #16a34a; }
.qb-content { flex: 1; min-width: 0; }
.qb-question { font-size: 0.88rem; font-weight: 500; color: #1a1a2e; margin-bottom: 2px; }
.qb-impact { font-size: 0.74rem; color: #64748b; }
.qb-actions { display: flex; gap: 6px; flex-shrink: 0; }
.qb-btn {
  padding: 6px 16px; border-radius: 8px; border: 1px solid #e2e8f0;
  font-size: 0.78rem; font-weight: 600; cursor: pointer; transition: all 0.15s;
  background: #fff;
}
.qb-yes { color: #16a34a; border-color: #bbf7d0; }
.qb-yes:hover { background: #dcfce7; }
.qb-no { color: #dc2626; border-color: #fecaca; }
.qb-no:hover { background: #fef2f2; }
.qb-skip { color: #94a3b8; }
.qb-skip:hover { background: #f1f5f9; }

/* ── Utilities ── */
.hidden { display: none !important; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .sidebar { width: 220px; min-width: 220px; }
  .page { padding: 24px 24px; }
  .quick-cards { grid-template-columns: 1fr; }
  .hero-title { font-size: 1.8rem; }
}
@media (max-width: 640px) {
  body { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; }
  .sidebar-nav { flex-direction: row; overflow-x: auto; }
  .sidebar-footer { display: none; }
}
