:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #d8dee6;
  --text: #18202c;
  --muted: #5b6778;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --danger: #b91c1c;
  --ok-bg: #ecfdf5;
  --ok-bd: #6ee7b7;
  --err-bg: #fef2f2;
  --err-bd: #fca5a5;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.topbar {
  background: #0f172a;
  color: #fff;
  padding: 10px 16px;
}
.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}
.brand {
  color: #fff;
  font-weight: 700;
  font-size: 1.15rem;
  text-decoration: none;
}
.nav-links {
  display: flex;
  gap: 12px;
  flex: 1;
}
.nav-links a {
  color: #cbd5e1;
  text-decoration: none;
  font-weight: 500;
}
.nav-links a:hover { color: #fff; }
.user-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.user-pill { font-size: 0.85rem; color: #cbd5e1; }

.container {
  max-width: 1120px;
  margin: 18px auto;
  padding: 0 14px;
}
.stack { display: flex; flex-direction: column; gap: 14px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}
.login-wrap { display: flex; justify-content: center; padding-top: 32px; }
.login-card { width: 100%; max-width: 420px; }

.search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.search-input {
  flex: 1 1 280px;
  padding: 10px 12px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.mode-toggle { display: flex; gap: 4px; }
.pill-opt {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  background: #f8fafc;
}
.pill-opt.disabled { opacity: 0.5; cursor: not-allowed; }

.acct-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #f8fafc;
  font-size: 0.9rem;
  cursor: pointer;
}

.filters-box { font-size: 0.92rem; }
.filters-box summary { cursor: pointer; color: var(--muted); }
.filters-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 10px;
}
.field, .field-inline { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; }
.field-inline { flex-direction: row; align-items: center; gap: 6px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}
.full-span { grid-column: 1 / -1; }

.btn {
  display: inline-block;
  padding: 9px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
  text-decoration: none;
  font-size: 0.92rem;
}
.btn-sm { padding: 5px 10px; font-size: 0.85rem; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-ghost { background: transparent; color: inherit; }
.inline-form { display: inline; }

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  background: #e2e8f0;
  font-size: 0.78rem;
  font-weight: 600;
}
.badge-gmail { background: #dbeafe; color: #1e40af; }
.badge-imap { background: #ede9fe; color: #5b21b6; }
.badge-pop3 { background: #fef3c7; color: #92400e; }
.badge-type-drive { background: #dcfce7; color: #166534; }
.badge-type-attachment { background: #ffedd5; color: #9a3412; }

.alert { padding: 10px 12px; border-radius: 6px; border: 1px solid transparent; }
.alert-ok { background: var(--ok-bg); border-color: var(--ok-bd); }
.alert-error { background: var(--err-bg); border-color: var(--err-bd); color: #7f1d1d; }

.answer-card { border-left: 4px solid var(--primary); }
.answer-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.answer-body { white-space: pre-wrap; margin-top: 8px; }

.results-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.hit-card { margin-bottom: 10px; }
.hit-top { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.hit-badges { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.hit-title { margin: 6px 0 4px; font-size: 1.05rem; }
.hit-title a { color: var(--primary); text-decoration: none; }
.hit-snippet { margin: 6px 0; font-size: 0.94rem; color: #27303f; }
.hit-snippet mark { background: #fef08a; padding: 0 2px; border-radius: 2px; }
.hit-actions { display: flex; gap: 8px; margin-top: 8px; }

.meta-grid { display: grid; grid-template-columns: 90px 1fr; gap: 4px 12px; margin: 10px 0; }
.meta-grid dt { font-weight: 600; color: var(--muted); }
.meta-grid dd { margin: 0; word-break: break-word; }
.body-pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  background: #f8fafc;
  padding: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  margin: 8px 0 0;
}

.section-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; margin-top: 10px; }
th, td { border-bottom: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
th { font-size: 0.85rem; color: var(--muted); }
.action-row { display: flex; gap: 6px; flex-wrap: wrap; }
.remove-box { margin-top: 6px; }
.remove-form { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.danger-link { color: var(--danger); cursor: pointer; }
.err-text { color: var(--danger); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.label-inline { font-weight: 600; font-size: 0.9rem; }

/* What's New modal (matching Customer Portal) */
.whats-new-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10000000;
}
.whats-new-card {
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--border);
  width: min(680px, 100%);
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
}
.whats-new-header {
  padding: 13px 18px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.whats-new-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.whats-new-title-row h2 {
  margin: 0;
  font-size: 1.08rem;
  color: #0f172a;
}
.whats-new-close-x {
  font-size: 1.1rem;
  line-height: 1;
  color: var(--muted);
}
.whats-new-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 0.75rem;
  align-items: center;
}
.whats-new-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 18px 0;
  border-bottom: 1px solid #e2e8f0;
}
.whats-new-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 6px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.whats-new-tab.is-active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.whats-new-panel {
  padding: 0 18px;
  overflow: auto;
  max-height: calc(100vh - 285px);
}
.whats-new-group {
  padding: 10px 0;
  border-bottom: 1px solid #e2e8f0;
}
.whats-new-date {
  font-weight: 800;
  color: #0f172a;
  font-size: 0.86rem;
  margin-bottom: 4px;
}
.whats-new-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 4px;
}
.whats-new-list li {
  font-size: 0.84rem;
  line-height: 1.38;
}
.whats-new-likelihood {
  color: #a16207;
  font-weight: 800;
  font-size: 0.8rem;
  margin-bottom: 4px;
}
.whats-new-coming-text {
  margin: 0;
  color: #334155;
  font-size: 0.84rem;
  line-height: 1.4;
}
.whats-new-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-top: 1px solid #e2e8f0;
}
.whats-new-again {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #475569;
  font-size: 0.8rem;
  cursor: pointer;
}
