/* === DARK THEME (default) === */
:root, [data-theme="dark"] {
  --bg: #0b0d11;
  --surface: #14171f;
  --surface2: #1c2030;
  --border: #2a2f42;
  --text: #eceef3;
  --text2: #a3a9be;
  --text3: #727994;
  --accent: #5b88ff;
  --accent-hover: #4a76ee;
  --accent-dim: rgba(91,136,255,0.12);
  --green: #34d373;
  --green-dim: rgba(52,211,115,0.12);
  --yellow: #fbbf24;
  --yellow-dim: rgba(251,191,36,0.12);
  --red: #f87171;
  --red-dim: rgba(248,113,113,0.12);
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
  --radius: 10px;
  --radius-lg: 14px;
  --mono: "DM Mono", monospace;
}

/* === LIGHT THEME === */
[data-theme="light"] {
  --bg: #f2f3f7;
  --surface: #ffffff;
  --surface2: #eceef3;
  --border: #d4d7e0;
  --text: #111827;
  --text2: #4b5268;
  --text3: #6b7394;
  --accent: #3b6cf5;
  --accent-hover: #2d5ce0;
  --accent-dim: rgba(59,108,245,0.10);
  --green: #15803d;
  --green-dim: rgba(21,128,61,0.10);
  --yellow: #b45309;
  --yellow-dim: rgba(180,83,9,0.10);
  --red: #dc2626;
  --red-dim: rgba(220,38,38,0.10);
  --shadow: 0 1px 4px rgba(0,0,0,0.07);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.10);
}
[data-theme="light"] .sidebar { background: #fff; border-right-color: var(--border); }
[data-theme="light"] .opp-card:hover { background: #f7f8fc; }
[data-theme="light"] .toast { background: #fff; box-shadow: var(--shadow-lg); }
[data-theme="light"] .chat-bubble.user { background: var(--accent); color: #fff; }
[data-theme="light"] .ws-tab.active { background: var(--accent-dim); color: var(--accent); }
[data-theme="light"] .filter-select { background: #fff; }
[data-theme="light"] .search-input { background: #fff; }
[data-theme="light"] .field-input, [data-theme="light"] .field-textarea { background: #fff; border-color: var(--border); }
[data-theme="light"] .chat-input { background: #fff; }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: #bbb; }
[data-theme="light"] .nav-btn { color: var(--text2); }
[data-theme="light"] .nav-btn:hover { color: var(--text); }
[data-theme="light"] .tag { background: #eef0f5; color: var(--text2); border-color: var(--border); }

/* === RESET === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "DM Sans", sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  height: 100vh;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.5;
  transition: background 0.25s, color 0.25s;
}

/* === SIDEBAR === */
.sidebar {
  width: 230px;
  min-width: 230px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  gap: 8px;
  transition: background 0.25s, border-color 0.25s;
}
.logo {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 8px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.logo-mark {
  width: 38px;
  height: 38px;
  background: var(--accent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  color: white;
  flex-shrink: 0;
}
.logo-name { font-weight: 700; font-size: 16px; letter-spacing: -0.3px; }
.logo-sub { font-size: 11px; color: var(--text3); margin-top: 1px; letter-spacing: 0.2px; }
.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  border: none;
  background: none;
  color: var(--text2);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  width: 100%;
}
.nav-btn:hover { background: var(--surface2); color: var(--text); }
.nav-btn.active { background: var(--accent-dim); color: var(--accent); font-weight: 600; }
.nav-icon { font-size: 16px; width: 22px; text-align: center; }
.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.api-status { display: flex; align-items: center; gap: 8px; padding: 6px 12px; font-size: 13px; color: var(--text3); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text3); flex-shrink: 0; transition: all 0.3s; }
.status-dot.online { background: var(--green); box-shadow: 0 0 8px var(--green); }
.status-dot.offline { background: var(--red); }

/* Theme toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  width: 100%;
  text-align: left;
  border-radius: 6px;
  transition: all 0.15s;
}
.theme-toggle:hover { background: var(--surface2); color: var(--text); }

/* === MAIN CONTENT === */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
  transition: background 0.25s;
}
.page { display: none; animation: fadeIn 0.2s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* === PAGE HEADER === */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  gap: 16px;
}
.page-title { font-size: 24px; font-weight: 700; letter-spacing: -0.4px; }
.page-sub { font-size: 14px; color: var(--text2); margin-top: 3px; }

/* === BUTTONS === */
.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(79,124,255,0.2);
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 3px 8px rgba(79,124,255,0.25); }
.btn-primary:active { transform: translateY(0); }
.btn-primary.full-width { width: 100%; padding: 13px; font-size: 15px; }
.btn-primary:disabled { opacity: 0.5; cursor: default; transform: none; box-shadow: none; }
.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-link { background: none; border: none; color: var(--accent); font-family: inherit; font-size: 14px; cursor: pointer; padding: 0; font-weight: 500; }
.btn-link:hover { text-decoration: underline; }
.btn-back { background: none; border: none; color: var(--text2); font-family: inherit; font-size: 14px; cursor: pointer; padding: 0; }
.btn-back:hover { color: var(--text); }

/* === STATS CARDS === */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all 0.2s;
  box-shadow: var(--shadow);
}
.stat-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.stat-label { font-size: 12px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 8px; font-weight: 600; }
.stat-value { font-size: 30px; font-weight: 700; font-family: var(--mono); letter-spacing: -0.5px; }
.stat-hint { font-size: 13px; color: var(--text3); margin-top: 4px; }

/* === SECTIONS === */
.section-row { display: grid; grid-template-columns: 1fr 340px; gap: 14px; }
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}
.section-card.wide { }
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.section-head h2 { font-size: 16px; font-weight: 600; }

/* === OPPORTUNITY CARDS === */
.opp-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: var(--shadow);
}
.opp-card:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.opp-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; gap: 12px; }
.opp-title { font-size: 15px; font-weight: 600; line-height: 1.4; }
.opp-meta { display: flex; gap: 14px; font-size: 13px; color: var(--text2); flex-wrap: wrap; align-items: center; }
.opp-meta span { display: flex; align-items: center; gap: 4px; }
.opp-tags { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.tag {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 5px;
  background: var(--surface2);
  color: var(--text2);
  border: 1px solid var(--border);
  font-weight: 500;
}
.tag.setaside { background: var(--accent-dim); color: var(--accent); border-color: transparent; font-weight: 600; }

/* === FILTERS === */
.filter-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.search-input {
  flex: 1;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.15s;
}
.search-input:focus, .field-input:focus, .field-textarea:focus, .chat-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.search-input::placeholder, .field-input::placeholder, .field-textarea::placeholder, .chat-input::placeholder { color: var(--text3); }
.filter-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s;
  max-width: 180px;
}
.filter-select:focus { border-color: var(--accent); }

/* === WORKSPACE === */
.workspace-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.workspace-actions { display: flex; gap: 8px; }
.tender-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.hero-badge { display: inline-block; font-size: 12px; padding: 4px 12px; border-radius: 5px; background: var(--accent-dim); color: var(--accent); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.6px; font-weight: 700; }
.hero-title { font-size: 22px; font-weight: 700; line-height: 1.3; margin-bottom: 10px; letter-spacing: -0.3px; }
.hero-meta { font-size: 14px; color: var(--text2); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.meta-sep { color: var(--text3); }
.ws-grid { display: grid; grid-template-columns: 1fr 260px; gap: 16px; }
.ws-tabs {
  display: flex;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 14px;
}
.ws-tab {
  flex: 1;
  background: none;
  border: none;
  border-radius: 7px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text3);
  cursor: pointer;
  transition: all 0.15s;
}
.ws-tab:hover { color: var(--text2); }
.ws-tab.active { background: var(--accent-dim); color: var(--accent); font-weight: 600; }
.ws-panel { display: none; }
.ws-panel.active { display: block; }
.ws-sidebar { display: flex; flex-direction: column; gap: 10px; }
.ws-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
}
.ws-card-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text2); margin-bottom: 8px; font-weight: 700; }
.score-display { font-size: 38px; font-weight: 700; font-family: var(--mono); color: var(--accent); }
.score-label { font-size: 13px; color: var(--text2); margin-top: 2px; }

/* === CHAT === */
.chat-container { display: flex; flex-direction: column; gap: 12px; height: 500px; }
.chat-messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 0; }
.chat-bubble { max-width: 80%; padding: 12px 16px; border-radius: 14px; font-size: 14px; line-height: 1.6; }
.chat-bubble.user { align-self: flex-end; background: var(--accent); color: white; border-bottom-right-radius: 4px; }
.chat-bubble.ai { align-self: flex-start; background: var(--surface2); color: var(--text); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-suggestions { display: flex; flex-wrap: wrap; gap: 6px; }
.chat-suggestion {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.chat-suggestion:hover { border-color: var(--accent); color: var(--accent); }
.chat-input-row { display: flex; gap: 8px; }
.chat-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}

/* === PIPELINE === */
.pipeline-tabs { display: flex; gap: 4px; margin-bottom: 18px; flex-wrap: wrap; }
.pipeline-tab {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 7px 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
}
.pipeline-tab:hover { border-color: var(--accent); color: var(--accent); }
.pipeline-tab.active { background: var(--accent); border-color: var(--accent); color: white; }

/* === PROFILE === */
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.profile-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow);
}
.profile-section-title { font-size: 15px; font-weight: 700; margin-bottom: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.field-group { margin-bottom: 16px; }
.field-label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 6px; font-weight: 600; }
.field-input, .field-textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.15s;
}
.field-textarea { resize: vertical; min-height: 80px; }
.field-hint { font-size: 12px; color: var(--text3); margin-top: 5px; line-height: 1.5; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cert-checkboxes { display: flex; flex-direction: column; gap: 12px; }
.cert-check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text); cursor: pointer; }
.cert-check input { width: 18px; height: 18px; cursor: pointer; accent-color: var(--accent); }

/* === EMPTY STATES === */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 24px; text-align: center; gap: 10px; }
.empty-state.small { padding: 24px; }
.empty-icon { font-size: 36px; color: var(--text3); margin-bottom: 4px; }
.empty-title { font-size: 17px; font-weight: 600; color: var(--text); }
.empty-sub { font-size: 14px; color: var(--text2); max-width: 380px; line-height: 1.5; }

/* === UTILITIES === */
.loading-pulse { color: var(--text2); font-size: 14px; padding: 20px 0; animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes spin { to { transform: rotate(360deg); } }
.result-count { font-size: 13px; color: var(--text2); margin-bottom: 12px; }
.badge { display: inline-block; font-size: 12px; padding: 3px 10px; border-radius: 5px; font-weight: 600; }
.badge-green { background: var(--green-dim); color: var(--green); }
.badge-yellow { background: var(--yellow-dim); color: var(--yellow); }
.badge-red { background: var(--red-dim); color: var(--red); }
.badge-blue { background: var(--accent-dim); color: var(--accent); }
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 500;
  z-index: 999;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* === RESPONSIVE === */
@media (max-width: 1100px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .section-row, .profile-grid, .ws-grid { grid-template-columns: 1fr; }
  .main { padding: 20px; }
}
@media (max-width: 768px) {
  .sidebar { width: 60px; min-width: 60px; padding: 12px 8px; }
  .logo-name, .logo-sub, .nav-btn span:not(.nav-icon), .api-status span:not(.status-dot), .theme-toggle span { display: none; }
  .logo { padding: 8px 4px 12px; justify-content: center; }
  .logo-mark { width: 32px; height: 32px; }
  .nav-btn { justify-content: center; padding: 10px; }
  .nav-icon { width: auto; }
  .main { padding: 16px; }
  .page-header { flex-direction: column; gap: 12px; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .filter-bar { flex-direction: column; }
  .filter-select { max-width: 100%; }
}
