/* eVA Opportunity Radar — UI styles */
:root {
  --brand: #4f46e5;
  --brand-2: #0ea5e9;
  --brand-d: #4338ca;
  --ink: #0f172a;
  --ink-2: #334155;
  --mute: #64748b;
  --mute-2: #94a3b8;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --ok: #047857;
  --ok-bg: #d1fae5;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.06);
  --shadow-lg: 0 10px 40px rgba(15,23,42,.18);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { margin: 0 0 .4em; line-height: 1.25; }
.muted { color: var(--mute); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.hide { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 20px;
  height: 62px; display: flex; align-items: center; gap: 20px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand .dot {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid; place-items: center; color: #fff; font-size: 16px;
}
.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav a {
  color: var(--ink-2); font-weight: 600; font-size: 14px;
  padding: 8px 14px; border-radius: 9px;
}
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.active { background: #eef2ff; color: var(--brand); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.lastrun { font-size: 12px; color: var(--mute); text-align: right; line-height: 1.3; }
.lastrun b { color: var(--ink-2); }

/* ---------- Layout ---------- */
.wrap { max-width: 1280px; margin: 0 auto; padding: 24px 20px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink-2); cursor: pointer;
  transition: .15s; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-d); }
.btn-sky { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn-sky:hover { filter: brightness(.95); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--bg); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-danger { color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: var(--danger-bg); }
.icon-btn {
  width: 34px; height: 34px; padding: 0; display: inline-grid; place-items: center;
  border-radius: 9px; border: 1px solid var(--line); background: var(--card);
  cursor: pointer; color: var(--mute); font-size: 15px; transition: .15s;
}
.icon-btn:hover { background: var(--bg); color: var(--ink); }
.icon-btn.on { color: #d97706; border-color: #fcd34d; background: #fffbeb; }

/* ---------- Stat cards ---------- */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 20px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat .v { font-size: 30px; font-weight: 800; letter-spacing: -.5px; }
.stat .l { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--mute); margin-top: 2px; }
.stat .bar { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.stat.brand .bar { background: var(--brand); }
.stat.sky .bar { background: var(--brand-2); }
.stat.ok .bar { background: var(--ok); }
.stat.warn .bar { background: var(--warn); }
.stat.ink .bar { background: var(--ink); }
.stat a { color: inherit; }

/* ---------- Cards / charts ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--mute); margin-bottom: 14px; }
.charts { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 14px; margin-bottom: 20px; }
.chart-box { position: relative; height: 220px; }

/* ---------- Filter bar ---------- */
.toolbar {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-bottom: 16px; box-shadow: var(--shadow);
}
.toolbar .search { flex: 1 1 240px; min-width: 200px; position: relative; }
.toolbar .search input { width: 100%; padding-left: 36px; }
.toolbar .search::before {
  content: "🔍"; position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  font-size: 14px; opacity: .6;
}
input, select, textarea {
  font-family: inherit; font-size: 14px; color: var(--ink);
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--card); outline: none; transition: .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.13); }
select { cursor: pointer; }
label.field { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.checkpill {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--card);
  font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; user-select: none;
}
.checkpill input { width: 15px; height: 15px; accent-color: var(--brand); padding: 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: none; background: var(--card); padding: 8px 13px; font-size: 13px; font-weight: 600; color: var(--mute); cursor: pointer; }
.seg button.on { background: var(--brand); color: #fff; }

/* ---------- Table ---------- */
.table-card { overflow: hidden; }
table.opps { width: 100%; border-collapse: collapse; }
table.opps th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--mute); font-weight: 700; padding: 12px 14px; border-bottom: 1px solid var(--line);
  background: #f8fafc; white-space: nowrap;
}
table.opps td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.opps tr:last-child td { border-bottom: none; }
table.opps tbody tr { transition: background .12s; cursor: pointer; }
table.opps tbody tr:hover { background: #f8fafc; }
.opp-title { font-weight: 600; color: var(--ink); display: block; }
.opp-title:hover { color: var(--brand); text-decoration: none; }
.opp-sub { color: var(--mute); font-size: 12.5px; margin-top: 3px; }
.opp-new { display: inline-block; background: var(--brand); color: #fff; font-size: 10px; font-weight: 800; padding: 1px 6px; border-radius: 5px; vertical-align: middle; margin-right: 6px; letter-spacing: .4px; }
.kw { display: inline-block; background: #eef2ff; color: var(--brand); font-size: 11px; padding: 1px 7px; border-radius: 999px; margin: 3px 4px 0 0; }
.col-actions { white-space: nowrap; text-align: right; }

/* relevance pill */
.rel { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; font-weight: 800; font-size: 14px; }
.rel.hi { background: var(--ok-bg); color: var(--ok); }
.rel.mid { background: var(--warn-bg); color: var(--warn); }
.rel.lo { background: #f1f5f9; color: var(--mute); }

/* badges */
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.badge.due-urgent { background: var(--danger-bg); color: var(--danger); }
.badge.due-soon { background: var(--warn-bg); color: var(--warn); }
.badge.due-ok { background: #e0f2fe; color: #0369a1; }
.badge.due-past { background: #f1f5f9; color: var(--mute); }
.badge.gray { background: #f1f5f9; color: var(--mute); }

/* status select inline */
.status-select { font-size: 12.5px; font-weight: 700; padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line); cursor: pointer; }
.st-new { color: var(--brand); background: #eef2ff; border-color: #c7d2fe; }
.st-reviewing { color: #7c3aed; background: #f5f3ff; border-color: #ddd6fe; }
.st-interested { color: #0369a1; background: #e0f2fe; border-color: #bae6fd; }
.st-applied { color: var(--warn); background: var(--warn-bg); border-color: #fde68a; }
.st-won { color: var(--ok); background: var(--ok-bg); border-color: #a7f3d0; }
.st-lost { color: var(--danger); background: var(--danger-bg); border-color: #fecaca; }
.st-ignored { color: var(--mute); background: #f1f5f9; border-color: var(--line); }

/* ---------- Pagination ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; padding: 14px; gap: 12px; flex-wrap: wrap; }
.pager .pages { display: flex; gap: 6px; }
.pager a, .pager span.cur {
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); font-size: 13px; font-weight: 600; color: var(--ink-2);
}
.pager span.cur { background: var(--brand); color: #fff; border-color: var(--brand); }
.pager a:hover { background: var(--bg); text-decoration: none; }

/* ---------- Kanban ---------- */
.board { display: grid; grid-template-columns: repeat(7, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.board-col { background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; padding: 10px; min-height: 120px; }
.board-col h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.board-col h4 .count { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; font-size: 11px; color: var(--mute); }
.kcard { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px; margin-bottom: 9px; box-shadow: var(--shadow); cursor: pointer; }
.kcard:hover { border-color: var(--brand); }
.kcard .kt { font-weight: 600; font-size: 13px; line-height: 1.3; }
.kcard .ks { color: var(--mute); font-size: 11.5px; margin-top: 4px; }

/* ---------- Drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.45); opacity: 0; pointer-events: none; transition: .2s; z-index: 60; }
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 560px; max-width: 94vw;
  background: var(--card); box-shadow: var(--shadow-lg); z-index: 70;
  transform: translateX(100%); transition: transform .25s ease; display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.drawer-body { padding: 20px 22px; overflow-y: auto; flex: 1; }
.drawer-section { margin-bottom: 22px; }
.drawer-section h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--mute); margin-bottom: 8px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--mute); }
.kv dd { margin: 0; color: var(--ink); }
.note { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 9px; font-size: 14px; }
.note .meta { font-size: 11.5px; color: var(--mute); margin-top: 5px; display: flex; justify-content: space-between; }

/* ---------- Auth / install ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg, #eef2ff, #e0f2fe); }
.auth-card { width: 100%; max-width: 420px; background: var(--card); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 34px 32px; }
.auth-card.wide { max-width: 640px; }
.auth-logo { display: flex; align-items: center; gap: 11px; font-weight: 800; font-size: 19px; margin-bottom: 6px; }
.auth-logo .dot { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); display: grid; place-items: center; color: #fff; font-size: 20px; }
.form-row { margin-bottom: 16px; }
.form-row input, .form-row select, .form-row textarea { width: 100%; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.help { font-size: 12.5px; color: var(--mute); margin-top: 5px; }

/* alerts */
.alert { padding: 12px 15px; border-radius: 10px; font-size: 14px; margin-bottom: 16px; border: 1px solid; }
.alert-error { background: var(--danger-bg); border-color: #fecaca; color: #991b1b; }
.alert-ok { background: var(--ok-bg); border-color: #a7f3d0; color: #065f46; }
.alert-info { background: #e0f2fe; border-color: #bae6fd; color: #075985; }

/* settings */
.settings-grid { display: grid; grid-template-columns: 1fr; gap: 18px; }
.tag-input { display: flex; flex-wrap: wrap; gap: 7px; padding: 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.tag { display: inline-flex; align-items: center; gap: 6px; background: #eef2ff; color: var(--brand); border-radius: 999px; padding: 4px 10px; font-size: 13px; font-weight: 600; }
.tag button { border: none; background: none; color: var(--brand); cursor: pointer; font-size: 15px; line-height: 1; padding: 0; }
.tag-input input { border: none; flex: 1; min-width: 140px; padding: 5px; }
.tag-input input:focus { box-shadow: none; }

/* toast */
.toast-zone { position: fixed; right: 18px; bottom: 18px; z-index: 90; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(8px); transition: .2s; max-width: 340px; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.ok { background: #065f46; }
.toast.err { background: #991b1b; }

.empty { text-align: center; padding: 60px 20px; color: var(--mute); }
.empty .big { font-size: 40px; margin-bottom: 10px; }
.spin { display: inline-block; width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; border-radius: 50%; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

/* responsive */
@media (max-width: 1080px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .charts { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .nav { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  table.opps thead { display: none; }
  table.opps, table.opps tbody, table.opps tr, table.opps td { display: block; width: 100%; }
  table.opps tr { border-bottom: 8px solid var(--bg); }
  table.opps td { border: none; padding: 6px 14px; }
  .col-actions { text-align: left; }
}

/* ---------- Theme toggle icon (sun shown in dark, moon shown in light) ---------- */
.icon-btn svg { display: block; }
.theme-sun { display: none; }
:root[data-theme="dark"] .theme-sun { display: block; }
:root[data-theme="dark"] .theme-moon { display: none; }

/* ============================================================
   Dark theme — applied when <html data-theme="dark"> (the default)
   ============================================================ */
:root[data-theme="dark"] {
  --brand: #818cf8;
  --brand-2: #38bdf8;
  --brand-d: #6366f1;
  --ink: #e5e7eb;
  --ink-2: #cbd5e1;
  --mute: #94a3b8;
  --mute-2: #64748b;
  --line: #1f2a3b;
  --bg: #0b1120;
  --card: #131c2e;
  --ok: #34d399;
  --ok-bg: #064e3b;
  --warn: #fbbf24;
  --warn-bg: #3b2f0a;
  --danger: #f87171;
  --danger-bg: #4c1d1d;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.45);
  --shadow-lg: 0 12px 44px rgba(0,0,0,.6);
  color-scheme: dark;
}

/* Patch the spots that use hardcoded light colors (not variables). */
:root[data-theme="dark"] .nav a.active { background: #1e293b; color: var(--brand); }
:root[data-theme="dark"] table.opps th { background: #0f1929; }
:root[data-theme="dark"] table.opps tbody tr:hover { background: #0f1929; }
:root[data-theme="dark"] .kw { background: #1e293b; color: var(--brand); }
:root[data-theme="dark"] .rel.lo { background: #1e293b; color: var(--mute); }
:root[data-theme="dark"] .badge.due-ok { background: #0c2a3f; color: #7dd3fc; }
:root[data-theme="dark"] .badge.due-past,
:root[data-theme="dark"] .badge.gray { background: #1e293b; color: var(--mute); }
:root[data-theme="dark"] .board-col { background: #0f1929; }
:root[data-theme="dark"] .note { background: #0f1929; }
:root[data-theme="dark"] .tag { background: #1e293b; }
:root[data-theme="dark"] .icon-btn.on { background: #3b2f0a; border-color: #a16207; color: #fbbf24; }
:root[data-theme="dark"] .toast { background: #1f2937; color: #fff; }
:root[data-theme="dark"] .auth-wrap { background: linear-gradient(135deg, #0b1120, #0e1a2e); }

/* alerts */
:root[data-theme="dark"] .alert-error { background: var(--danger-bg); border-color: #7f1d1d; color: #fecaca; }
:root[data-theme="dark"] .alert-ok { background: var(--ok-bg); border-color: #065f46; color: #a7f3d0; }
:root[data-theme="dark"] .alert-info { background: #0c2a3f; border-color: #075985; color: #bae6fd; }
:root[data-theme="dark"] .btn-danger { border-color: #7f1d1d; }

/* inline status selects */
:root[data-theme="dark"] .st-new { color: #a5b4fc; background: #1e293b; border-color: #312e81; }
:root[data-theme="dark"] .st-reviewing { color: #c4b5fd; background: #241b3a; border-color: #4c1d95; }
:root[data-theme="dark"] .st-interested { color: #7dd3fc; background: #0c2a3f; border-color: #075985; }
:root[data-theme="dark"] .st-applied { color: var(--warn); background: var(--warn-bg); border-color: #a16207; }
:root[data-theme="dark"] .st-won { color: var(--ok); background: var(--ok-bg); border-color: #065f46; }
:root[data-theme="dark"] .st-lost { color: var(--danger); background: var(--danger-bg); border-color: #7f1d1d; }
:root[data-theme="dark"] .st-ignored { color: var(--mute); background: #1e293b; border-color: var(--line); }
