/* MetaResearchAgent Console — Standalone Styles */
/* Matches the JS-rendered class names exactly */

:root {
  --bg: #ffffff; --bg2: #f4f5f7; --surface: #ffffff;
  --text: #1a1a2e; --text2: #555; --muted: #999;
  --brand: #0066cc; --brand-hover: #0050a0;
  --success: #16a34a; --error: #dc2626; --warning: #eab308; --info: #2563eb;
  --border: #e2e4e8; --radius: 8px; --shadow: 0 1px 3px rgba(0,0,0,.08);
}
[data-theme="dark"] {
  --bg: #000000; --bg2: #0a0a0a; --surface: #141414;
  --text: #e0e0e0; --text2: #a0a0a0; --muted: #666;
  --brand: #4d94ff; --brand-hover: #70aaff;
  --success: #4caf87; --error: #ff6b7a; --warning: #ffcc44; --info: #44d4f0;
  --border: #222; --shadow: 0 1px 3px rgba(0,0,0,.5);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px; line-height: 1.6;
  color: var(--text); background: var(--bg2);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Login ---- */
.login-wrapper {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 1rem;
}
.login-card h1 { font-size: 1.6rem; margin-bottom: .25rem; }

/* ---- Card ---- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem;
  box-shadow: var(--shadow);
}

/* ---- Shell Layout ---- */
.shell-header {
  display: flex; align-items: center; gap: 1.5rem;
  padding: .75rem 1.5rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.shell-brand {
  font-weight: 700; font-size: 1.1rem; color: var(--text);
  white-space: nowrap;
}
.shell-nav { display: flex; gap: .25rem; flex: 1; }
.shell-actions { display: flex; gap: .5rem; align-items: center; }
.shell-main { max-width: 1100px; margin: 0 auto; padding: 1.5rem; width: 100%; }

/* ---- Nav Links ---- */
.nav-link {
  padding: .4rem .9rem; border-radius: 6px;
  font-size: .85rem; font-weight: 500;
  color: var(--text2); text-decoration: none; transition: all .15s;
}
.nav-link:hover { background: var(--bg2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--brand); color: #fff; }

/* ---- Page Header ---- */
.page-header {
  display: flex; align-items: center; gap: 1rem;
  margin-bottom: 1.25rem; flex-wrap: wrap;
}
.page-header h2 { font-size: 1.35rem; font-weight: 700; }

/* ---- Health Dot ---- */
.health-dot {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}

/* ---- Stat Grid ---- */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem; margin-bottom: 1.5rem;
}
.stat-card { text-align: center; padding: 1.25rem; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--brand); }
.stat-label { font-size: .8rem; color: var(--muted); margin-top: .25rem; text-transform: uppercase; letter-spacing: .5px; }

/* ---- Section ---- */
.section { margin-bottom: 1.5rem; }
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .75rem;
}
.section-header h3 { font-size: 1rem; font-weight: 600; }

/* ---- Table ---- */
.table {
  width: 100%; border-collapse: collapse;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  font-size: .85rem;
}
.table thead { background: var(--bg2); }
.table th {
  text-align: left; padding: .6rem .75rem;
  font-weight: 600; font-size: .75rem;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); border-bottom: 1px solid var(--border);
}
.table td {
  padding: .6rem .75rem; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:hover { background: var(--bg2); }
.table tbody tr:last-child td { border-bottom: none; }

/* ---- Badge ---- */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: .72rem; font-weight: 600; color: #fff;
  text-transform: uppercase; letter-spacing: .3px;
}

/* ---- Score Badge ---- */
.score-badge {
  display: inline-block; padding: 2px 10px; border-radius: 10px;
  font-size: .8rem; font-weight: 700; color: #fff; min-width: 32px; text-align: center;
}

/* ---- Input / Select / Textarea ---- */
.input, select.input {
  display: block; width: 100%;
  padding: .5rem .75rem; font-size: .9rem;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  outline: none; transition: border-color .15s;
  font-family: inherit;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(0,102,204,.15); }
.input-sm { font-size: .82rem; padding: .35rem .6rem; }
textarea.input { resize: vertical; min-height: 60px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .4rem; padding: .5rem 1rem; font-size: .85rem; font-weight: 600;
  border: none; border-radius: 6px; cursor: pointer;
  transition: all .15s; font-family: inherit; text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover { opacity: .9; }
.btn-ghost {
  background: transparent; color: var(--text2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg2); color: var(--text); }
.btn-sm { padding: .3rem .7rem; font-size: .78rem; }
.btn-xs { padding: .2rem .5rem; font-size: .72rem; }

/* ---- Filter Row ---- */
.filter-row {
  display: flex; gap: 1rem; align-items: center;
  margin-bottom: 1rem; flex-wrap: wrap;
}
.filter-row label {
  display: flex; align-items: center; gap: .4rem;
  font-size: .82rem; color: var(--text2);
}
.filter-row .input, .filter-row select { width: auto; min-width: 140px; }

/* ---- Search Bar ---- */
.search-row {
  display: flex; gap: .75rem; margin-bottom: 1rem;
  align-items: center; flex-wrap: wrap;
}
.search-row .input { flex: 1; min-width: 200px; }

/* ---- Pagination ---- */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: .25rem; margin-top: 1rem;
}
.page-btn {
  padding: .3rem .65rem; font-size: .8rem; border-radius: 4px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); cursor: pointer; transition: all .15s;
}
.page-btn:hover { background: var(--bg2); }
.page-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.page-btn:disabled { opacity: .4; cursor: default; }

/* ---- Detail Card ---- */
.detail-card { margin-bottom: 1.5rem; }
.detail-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: .75rem 2rem;
}
.detail-grid strong { font-size: .75rem; text-transform: uppercase; color: var(--muted); letter-spacing: .5px; }
.detail-grid p { margin-top: .15rem; }
.detail-actions { margin-top: 1.25rem; display: flex; gap: .5rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.error-box {
  margin-top: 1rem; padding: .75rem; border-radius: 6px;
  background: rgba(220,38,38,.08); color: var(--error); font-size: .85rem;
}

/* ---- Lead Expand Row ---- */
.lead-expand {
  background: var(--bg2); border-top: 1px dashed var(--border);
  padding: 1rem; font-size: .82rem;
}
.lead-expand h4 { font-size: .85rem; margin-bottom: .5rem; font-weight: 600; }
.lead-section { margin-bottom: .75rem; }
.lead-contacts { width: 100%; border-collapse: collapse; margin-top: .25rem; }
.lead-contacts th, .lead-contacts td {
  text-align: left; padding: .3rem .5rem; font-size: .78rem;
  border-bottom: 1px solid var(--border);
}
.feedback-btns { display: flex; gap: .4rem; margin-top: .75rem; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 1rem;
}
.modal {
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
}
.modal h3 { font-size: 1.1rem; margin-bottom: 1rem; }
.modal label {
  display: block; font-size: .82rem; font-weight: 500;
  color: var(--text2); margin-bottom: .75rem;
}
.modal label .input { margin-top: .25rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.form-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }

/* ---- Toast ---- */
#toast-container {
  position: fixed; top: 1rem; right: 1rem; z-index: 9999;
  display: flex; flex-direction: column; gap: .5rem;
}

/* ---- Link ---- */
.link { color: var(--brand); font-weight: 500; }
.link:hover { text-decoration: underline; }

/* ---- Animations ---- */
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.5; } }

/* ---- Utilities ---- */
.text-muted { color: var(--muted); }

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .shell-header { flex-wrap: wrap; gap: .75rem; }
  .shell-nav { order: 3; width: 100%; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .table { font-size: .78rem; }
}
