/* ===================== Reset & Variables ===================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0f14;
  --bg-2: #131720;
  --bg-3: #1a1f2e;
  --bg-4: #212840;
  --border: #2a3050;
  --border-light: #3a4268;

  --text: #e8ecf8;
  --text-2: #9aa3c2;
  --text-3: #5c6480;

  --accent: #6c8fff;
  --accent-dim: rgba(108,143,255,0.15);
  --accent-hover: #8aaeff;

  --green: #4ade80;
  --green-dim: rgba(74,222,128,0.12);
  --red: #f87171;
  --red-dim: rgba(248,113,113,0.12);
  --yellow: #fbbf24;
  --yellow-dim: rgba(251,191,36,0.12);
  --purple: #a78bfa;
  --purple-dim: rgba(167,139,250,0.12);

  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --sidebar-w: 220px;
  --transition: 0.18s ease;
}

html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
}

/* ===================== Layout ===================== */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===================== Sidebar ===================== */
#sidebar {
  width: var(--sidebar-w);
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-header {
  padding: 1.5rem 1rem 1rem;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.logo-icon {
  font-size: 1.4rem;
  color: var(--accent);
  line-height: 1;
}

.logo-text {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
}

.sidebar-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-3);
}

.nav-links {
  list-style: none;
  padding: 0.75rem 0.5rem;
  flex: 1;
  overflow-y: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
  transition: background var(--transition), color var(--transition);
}

.nav-link svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.nav-link:hover {
  background: var(--bg-3);
  color: var(--text);
}

.nav-link.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border);
}

.api-key-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-3);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-3);
  flex-shrink: 0;
}

.dot.ok { background: var(--green); }
.dot.err { background: var(--red); }

/* ===================== Main ===================== */
#main {
  flex: 1;
  overflow-y: auto;
  position: relative;
}

/* ===================== Auth Gate ===================== */
.auth-gate {
  position: absolute;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.auth-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 360px;
  text-align: center;
}

.auth-logo {
  font-size: 2.5rem;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.auth-card h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.auth-card p {
  color: var(--text-2);
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
}

.field-group {
  display: flex;
  gap: 0.5rem;
}

.field-group input {
  flex: 1;
}

.auth-hint {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--red);
  min-height: 1.2em;
}

/* ===================== Pages ===================== */
#pages {
  padding: 1.75rem 2rem;
  max-width: 1100px;
}

.page { display: none; }
.page.active { display: block; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
}

.page-subtitle {
  color: var(--text-3);
  font-size: 0.875rem;
  margin-top: 0.2rem;
}

/* ===================== Stats Grid ===================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.stat-card.loading {
  height: 88px;
  animation: pulse 1.4s ease-in-out infinite;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.stat-sub {
  font-size: 0.75rem;
  color: var(--text-3);
}

/* ===================== Dashboard Grid ===================== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.dashboard-col {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ===================== Section Cards ===================== */
.section-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.section-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.section-card-header h2 {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-2);
}

.section-link {
  font-size: 0.75rem;
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}

.section-link:hover { color: var(--accent-hover); }

/* ===================== Drip Status ===================== */
#dripSection { margin-top: 1rem; }

.drip-status { padding: 1.25rem; }

.drip-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.drip-metric {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}

.drip-metric-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 0.35rem;
}

.drip-metric-label {
  font-size: 0.72rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.drip-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.drip-chip {
  font-size: 0.75rem;
  color: var(--text-2);
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
}

.drip-chip b { color: var(--text-1); }

.drip-next-title {
  font-size: 0.72rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: 0.6rem;
}

.drip-upcoming {
  list-style: none;
  margin: 0;
  padding: 0;
}

.drip-upcoming li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.drip-upcoming li:last-child { border-bottom: none; }

.drip-up-name { flex: 1; color: var(--text-1); font-weight: 500; }

.drip-up-step {
  font-size: 0.72rem;
  color: var(--text-2);
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
}

.drip-up-when { color: var(--text-3); font-size: 0.78rem; min-width: 52px; text-align: right; }

.drip-empty { color: var(--text-3); font-size: 0.85rem; margin: 0; }

@media (max-width: 640px) {
  .drip-metrics { grid-template-columns: 1fr; }
}

/* ===================== Dash Lists ===================== */
.dash-list { padding: 0.5rem 0; }

.dash-task-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.25rem;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.dash-task-item:last-child { border-bottom: none; }
.dash-task-item:hover { background: var(--bg-3); }

.dash-task-title {
  flex: 1;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-note-item {
  padding: 0.7rem 1.25rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}

.dash-note-item:last-child { border-bottom: none; }
.dash-note-item:hover { background: var(--bg-3); }

.dash-note-title {
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.15rem;
}

.dash-note-preview {
  font-size: 0.8rem;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-briefing-text {
  padding: 1.25rem;
  font-size: 0.875rem;
  line-height: 1.8;
  color: var(--text-2);
  max-height: 280px;
  overflow-y: auto;
}

.empty-state {
  padding: 2rem 1.25rem;
  text-align: center;
  color: var(--text-3);
  font-size: 0.875rem;
}

/* ===================== Filter Bar ===================== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 0.35rem 0.85rem;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.filter-btn:hover { border-color: var(--border-light); color: var(--text); }
.filter-btn.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

.priority-filters {
  margin-left: auto;
  display: flex;
  gap: 0.4rem;
}

/* ===================== Items List ===================== */
.items-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.task-item, .bookmark-item {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  transition: border-color var(--transition), background var(--transition);
}

.task-item:hover, .bookmark-item:hover {
  border-color: var(--border-light);
  background: var(--bg-3);
}

.task-check {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border-light);
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 1px;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}

.task-check:hover { border-color: var(--accent); }
.task-check.checked {
  background: var(--green);
  border-color: var(--green);
}

.task-check.checked::after {
  content: '';
  width: 6px;
  height: 4px;
  border-left: 2px solid #000;
  border-bottom: 2px solid #000;
  transform: rotate(-45deg) translateY(-1px);
}

.task-body { flex: 1; min-width: 0; }

.task-title {
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.2rem;
}

.task-title.done {
  text-decoration: line-through;
  color: var(--text-3);
}

.task-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-high { background: var(--red-dim); color: var(--red); }
.badge-normal { background: var(--accent-dim); color: var(--accent); }
.badge-low { background: var(--bg-4); color: var(--text-3); }

.task-date {
  font-size: 0.75rem;
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
}

.task-date.overdue { color: var(--red); }

.task-actions { display: flex; gap: 0.3rem; align-items: center; opacity: 0; transition: opacity var(--transition); }
.task-item:hover .task-actions,
.bookmark-item:hover .task-actions { opacity: 1; }

.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  transition: all var(--transition);
  font-family: inherit;
}

.icon-btn:hover { background: var(--bg-4); border-color: var(--border); color: var(--text); }
.icon-btn.danger:hover { background: var(--red-dim); border-color: var(--red); color: var(--red); }

/* ===================== Notes Grid ===================== */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.note-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
  position: relative;
}

.note-card:hover {
  border-color: var(--border-light);
  background: var(--bg-3);
  transform: translateY(-1px);
}

.note-card.pinned { border-color: var(--accent); }

.note-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.note-card-title {
  font-size: 0.9rem;
  font-weight: 600;
  flex: 1;
  margin-right: 0.5rem;
  word-break: break-word;
}

.note-card-actions { display: flex; gap: 0.25rem; opacity: 0; transition: opacity var(--transition); }
.note-card:hover .note-card-actions { opacity: 1; }

.note-card-content {
  font-size: 0.82rem;
  color: var(--text-2);
  line-height: 1.6;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  word-break: break-word;
  white-space: pre-wrap;
}

.note-card-footer {
  margin-top: 0.75rem;
  font-size: 0.72rem;
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
}

.pin-badge {
  font-size: 0.65rem;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-weight: 600;
}

/* ===================== Bookmarks ===================== */
.search-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  margin-bottom: 1rem;
}

.search-bar svg { width: 16px; height: 16px; color: var(--text-3); flex-shrink: 0; }
.search-bar input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  flex: 1;
}
.search-bar input::placeholder { color: var(--text-3); }

.bookmark-item {
  flex-direction: column;
  gap: 0.25rem;
}

.bookmark-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  width: 100%;
  gap: 0.5rem;
}

.bookmark-title {
  font-weight: 500;
  font-size: 0.9rem;
}

.bookmark-url {
  font-size: 0.78rem;
  color: var(--accent);
  text-decoration: none;
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}

.bookmark-url:hover { text-decoration: underline; }

.bookmark-desc {
  font-size: 0.82rem;
  color: var(--text-2);
}

.bookmark-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.25rem;
}

.tag {
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
  background: var(--bg-4);
  color: var(--text-3);
  border-radius: 100px;
}

/* ===================== Briefing ===================== */
.briefing-container {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.briefing-item {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.briefing-item:last-child { border-bottom: none; }

.briefing-meta {
  font-size: 0.75rem;
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
  margin-bottom: 0.75rem;
}

.briefing-text {
  font-size: 0.9rem;
  line-height: 1.85;
  color: var(--text);
}

.briefing-loading {
  padding: 2.5rem;
  text-align: center;
  color: var(--text-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.briefing-history-item {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}

.briefing-history-item:last-child { border-bottom: none; }
.briefing-history-item:hover { background: var(--bg-3); }

.bh-date {
  font-size: 0.75rem;
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
  margin-bottom: 0.3rem;
}

.bh-preview {
  font-size: 0.82rem;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===================== Buttons & Inputs ===================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-secondary {
  background: var(--bg-3);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover { background: var(--bg-4); border-color: var(--border-light); }

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border-color: var(--red);
}

.btn-danger:hover { background: var(--red); color: #fff; }

input[type="text"], input[type="password"], input[type="url"], input[type="date"], textarea, select {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  padding: 0.55rem 0.75rem;
  width: 100%;
  outline: none;
  transition: border-color var(--transition);
}

input[type="text"]:focus, input[type="password"]:focus, input[type="url"]:focus,
input[type="date"]:focus, textarea:focus, select:focus {
  border-color: var(--accent);
}

input::placeholder, textarea::placeholder { color: var(--text-3); }

textarea { resize: vertical; min-height: 100px; line-height: 1.6; }

select { appearance: none; cursor: pointer; }

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 0.35rem;
}

.form-group { margin-bottom: 1rem; }
.form-group:last-child { margin-bottom: 0; }

/* ===================== Modal ===================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 460px;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 1rem;
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.modal-close:hover { background: var(--bg-4); color: var(--text); }

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ===================== Toast ===================== */
#toastContainer {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 1000;
}

.toast {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  font-size: 0.875rem;
  min-width: 240px;
  max-width: 360px;
  animation: slideIn 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.toast.success { border-color: var(--green); }
.toast.error { border-color: var(--red); }

.toast-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.toast.success .toast-dot { background: var(--green); }
.toast.error .toast-dot { background: var(--red); }
.toast .toast-dot { background: var(--accent); }

/* ===================== Spinner ===================== */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ===================== GitHub card ===================== */
.github-user {
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.github-login {
  font-weight: 600;
  font-size: 0.875rem;
}

.github-repos {
  font-size: 0.78rem;
  color: var(--text-3);
}

.github-issue {
  padding: 0.55rem 1.25rem;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.github-issue:last-child { border-bottom: none; }
.github-issue:hover { background: var(--bg-3); }

.github-issue a {
  font-size: 0.83rem;
  color: var(--text);
  text-decoration: none;
}

.github-issue a:hover { color: var(--accent); }

.github-issue-meta {
  font-size: 0.72rem;
  color: var(--text-3);
  margin-top: 0.1rem;
}

/* ===================== Animations ===================== */
@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes slideIn {
  from { transform: translateX(16px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===================== Helpers ===================== */
.hidden { display: none !important; }

/* =================== Outreach =================== */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
@media (max-width: 520px) {
  .form-row { grid-template-columns: 1fr; }
}

.outreach-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.75rem;
}
@media (max-width: 760px) {
  .outreach-stats { grid-template-columns: repeat(2, 1fr); }
}
.ostat {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
}
.ostat-value { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.ostat-label { font-size: 0.72rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 0.15rem; }

.table-wrap { overflow-x: auto; }
.leads-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.leads-table thead th {
  text-align: left;
  padding: 0.6rem 0.85rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.leads-table tbody tr {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s ease;
}
.leads-table tbody tr:hover { background: var(--bg-3); }
.leads-table tbody td { padding: 0.7rem 0.85rem; color: var(--text-2); vertical-align: middle; }
.lead-name { font-weight: 600; color: var(--text); }
.lead-sub { font-size: 0.78rem; color: var(--text-3); margin-top: 0.1rem; }
.lead-row-action { color: var(--text-3); font-size: 1.25rem; text-align: right; white-space: nowrap; }
.lead-preview-btn { font: inherit; font-size: 0.72rem; padding: 0.22rem 0.55rem; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--text-2); cursor: pointer; vertical-align: middle; }
.lead-preview-btn:hover { border-color: #c0412b; color: #c0412b; }
.lead-row-chevron { margin-left: 0.5rem; color: var(--text-3); vertical-align: middle; }
.email-preview-tabs { display: flex; gap: 0.4rem; margin-bottom: 0.85rem; flex-wrap: wrap; }
.email-preview-meta { margin-bottom: 0.85rem; }
.email-tpl-note { margin-top: 0.75rem; font-size: 0.8rem; color: var(--text-3); }

.tier-pill {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid var(--border-light);
}
.tier-launchpad { background: rgba(108,143,255,0.12); color: #8aaeff; border-color: rgba(108,143,255,0.35); }
.tier-growth { background: rgba(74,222,128,0.12); color: #6ee7a0; border-color: rgba(74,222,128,0.35); }
.tier-webapp { background: rgba(192,132,252,0.12); color: #c4a0fc; border-color: rgba(192,132,252,0.35); }

.status-pill {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: capitalize;
}
.status-new { background: var(--bg-4); color: var(--text-2); }
.status-contacted { background: rgba(108,143,255,0.15); color: #8aaeff; }
.status-responded { background: rgba(74,222,128,0.15); color: #6ee7a0; }
.status-closed { background: rgba(245,158,11,0.15); color: #f5b14a; }

.seq-dots { display: flex; gap: 4px; }
.seq-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--bg-4); border: 1px solid var(--border-light); }
.seq-dot.on { background: var(--accent); border-color: var(--accent); }

/* Lead detail */
.lead-detail-head { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.lead-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1rem;
  font-size: 0.85rem;
  color: var(--text-2);
}
.lead-detail-grid > div { display: flex; flex-direction: column; }
.ld-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); margin-bottom: 0.1rem; }
.ld-section-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  margin: 1rem 0 0.5rem;
  font-weight: 600;
}
.seq-list { display: flex; flex-direction: column; gap: 0.5rem; }
.seq-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
}
.seq-step {
  width: 26px; height: 26px; flex-shrink: 0;
  border-radius: 50%;
  background: var(--bg-4);
  color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700;
}
.seq-info { flex: 1; min-width: 0; }
.seq-title { font-size: 0.83rem; color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seq-meta { font-size: 0.72rem; color: var(--text-3); margin-top: 0.1rem; }
.seq-state { font-size: 0.68rem; font-weight: 700; padding: 0.15rem 0.5rem; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.03em; }
.seq-state.sent { background: rgba(74,222,128,0.15); color: #6ee7a0; }
.seq-state.next { background: var(--accent-dim); color: var(--accent); }
.seq-state.pending { background: var(--bg-4); color: var(--text-3); }
.seq-state.failed { background: rgba(248,113,113,0.15); color: #f87171; }

/* ---- Find Leads ---- */
.find-leads-card { margin-top: 1.25rem; }
.find-leads-head { margin-bottom: 1rem; }
.find-leads-title { font-size: 1.05rem; font-weight: 700; margin: 0; }
.find-leads-sub { font-size: 0.85rem; color: var(--text-2); margin: 0.25rem 0 0; }
.find-leads-form { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; }
.find-leads-form .form-group { flex: 1 1 160px; margin: 0; }
.find-leads-form .fl-state { flex: 0 0 90px; }
.find-leads-form .fl-limit { flex: 0 0 80px; }
.find-leads-form .btn { flex: 0 0 auto; height: 40px; }

.prospects-results { margin-top: 1rem; }
.prospects-loading, .prospects-empty, .prospects-error { padding: 1.25rem; text-align: center; color: var(--text-2); font-size: 0.9rem; }
.prospects-error { color: #f87171; }
.prospects-count { font-size: 0.8rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; margin-bottom: 0.6rem; }

.prospect-card { display: flex; gap: 1rem; justify-content: space-between; align-items: flex-start; padding: 0.9rem 1rem; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-3); margin-bottom: 0.6rem; }
.prospect-card.added { opacity: 0.6; }
.prospect-main { min-width: 0; flex: 1; }
.prospect-name { font-weight: 700; font-size: 0.95rem; }
.prospect-meta { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 0.25rem; font-size: 0.82rem; }
.prospect-link { color: var(--accent); text-decoration: none; word-break: break-all; }
.prospect-link:hover { text-decoration: underline; }
.prospect-nosite { color: #f3b765; font-weight: 600; }
.prospect-phone { color: var(--text-2); }
.prospect-address { font-size: 0.8rem; color: var(--text-3); margin-top: 0.25rem; }
.prospect-reason { font-size: 0.8rem; color: var(--text-2); margin-top: 0.4rem; font-style: italic; }
.prospect-side { display: flex; flex-direction: column; align-items: flex-end; gap: 0.5rem; flex: 0 0 auto; }
.prospect-add { white-space: nowrap; }
.prospect-signals { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-top: 0.4rem; font-size: 0.82rem; color: var(--text-2); }
.ps-rating { color: #f3b765; font-weight: 600; }
.ps-reviews { color: var(--text); font-weight: 600; }
.ps-price { color: var(--text-3); }
.ps-dot { color: var(--text-3); }
.prospect-score { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.45rem; }
.ws-label { font-size: 0.8rem; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.ws-bar { flex: 1; max-width: 160px; height: 8px; background: var(--bg-4); border-radius: 999px; overflow: hidden; }
.ws-fill { display: block; height: 100%; border-radius: 999px; }
.ws-fill.ws-red { background: #d65a4a; }
.ws-fill.ws-yellow { background: #e0b450; }
.ws-fill.ws-green { background: #5bbd7a; }

.ld-email-row { display: flex; gap: 0.5rem; }
.ld-email-row input { flex: 1; }
.ld-email-row .btn { flex: 0 0 auto; }

/* ---- Lead scoring ---- */
.page-header-actions { display: flex; gap: 0.5rem; align-items: center; }

.lead-filters { display: flex; gap: 0.5rem; margin-top: 1.25rem; flex-wrap: wrap; }
.lead-filter-btn { background: var(--bg-3); border: 1px solid var(--border); color: var(--text-2); padding: 0.4rem 0.85rem; border-radius: 999px; font-size: 0.82rem; font-weight: 600; cursor: pointer; transition: all 0.15s; }
.lead-filter-btn:hover { border-color: var(--border-light); color: var(--text); }
.lead-filter-btn.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

.grade-badge { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.72rem; font-weight: 700; padding: 0.2rem 0.5rem; border-radius: 999px; white-space: nowrap; }
.grade-badge .grade-score { font-size: 0.66rem; opacity: 0.7; font-variant-numeric: tabular-nums; }
.grade-hot { background: rgba(248,113,113,0.16); color: #f87171; }
.grade-warm { background: rgba(243,183,101,0.16); color: #f3b765; }
.grade-cold { background: rgba(108,143,255,0.16); color: #8aaeff; }
.grade-none { background: var(--bg-4); color: var(--text-3); }

/* "No email found" warning badge on lead rows */
.email-warn { display: inline-block; margin-left: 0.4rem; font-size: 0.68rem; font-weight: 600; color: #f3b765; background: rgba(243,183,101,0.14); border-radius: 999px; padding: 0.08rem 0.4rem; white-space: nowrap; }

/* Email Preview panel (Outreach) */
.email-preview-head { display: flex; align-items: center; justify-content: space-between; width: 100%; background: none; border: none; cursor: pointer; padding: 0; text-align: left; color: inherit; }
.email-preview-chevron { font-size: 1rem; color: var(--text-3); padding-left: 1rem; }
.email-preview-body { margin-top: 1rem; }
.email-preview-tabs { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.email-tab { display: flex; flex-direction: column; gap: 0.1rem; align-items: flex-start; padding: 0.5rem 0.8rem; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-3); color: var(--text-2); cursor: pointer; transition: all 0.12s; }
.email-tab:hover { border-color: var(--accent); }
.email-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.email-tab-num { font-size: 0.82rem; font-weight: 700; }
.email-tab-label { font-size: 0.68rem; opacity: 0.85; }
.email-preview-meta { display: flex; flex-direction: column; gap: 0.3rem; background: var(--bg-3); border: 1px solid var(--border); border-radius: 10px; padding: 0.75rem 0.9rem; margin-bottom: 0.9rem; }
.email-meta-row { display: grid; grid-template-columns: 64px 1fr; gap: 0.6rem; font-size: 0.82rem; color: var(--text); }
.email-meta-key { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-3); padding-top: 0.05rem; }
.email-meta-preview { color: var(--text-2); }
.email-preview-frame { width: 100%; height: 620px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }

/* Lead detail: website analysis */
.ld-grade-right { float: right; }
.ld-opportunity { font-size: 0.88rem; line-height: 1.6; color: var(--text); background: var(--bg-3); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px; padding: 0.7rem 0.85rem; margin-bottom: 0.75rem; }
.ld-recommendation { font-size: 0.85rem; font-weight: 600; line-height: 1.5; color: var(--text); margin-bottom: 0.6rem; }
.ld-issues { margin: 0 0 0.85rem; padding-left: 1.1rem; }
.ld-issues li { font-size: 0.83rem; color: var(--text-2); margin-bottom: 0.25rem; }
.ld-noscore { font-size: 0.85rem; color: var(--text-3); padding: 0.5rem 0; }
.ld-score-note { font-size: 0.72rem; color: var(--text-3); margin-top: 0.6rem; }

.dim-chart { display: flex; flex-direction: column; gap: 0.4rem; }
.dim-row { display: grid; grid-template-columns: 110px 1fr 22px; align-items: center; gap: 0.6rem; }
.dim-label { font-size: 0.78rem; color: var(--text-2); }
.dim-bar { height: 8px; background: var(--bg-4); border-radius: 999px; overflow: hidden; }
.dim-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-hover)); border-radius: 999px; }
.dim-val { font-size: 0.75rem; color: var(--text-3); text-align: right; font-variant-numeric: tabular-nums; }

.ld-chain-warn { font-size: 0.82rem; font-weight: 600; color: #f3b765; background: rgba(243,183,101,0.12); border: 1px solid rgba(243,183,101,0.3); border-radius: 8px; padding: 0.55rem 0.75rem; margin-bottom: 0.75rem; }

/* ===================== Lead-modal questionnaire ===================== */
.ld-questionnaire { display: flex; flex-direction: column; gap: 0.85rem; margin-top: 0.4rem; }
.ld-q-when { font-size: 0.72rem; color: var(--text-3); font-weight: 500; }
.ld-q-group { border: 1px solid var(--border); border-radius: 10px; padding: 0.75rem 0.85rem; background: var(--bg-3); }
.ld-q-section { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); font-weight: 600; margin-bottom: 0.5rem; }
.ld-q-item { margin-bottom: 0.55rem; }
.ld-q-item:last-child { margin-bottom: 0; }
.ld-q-label { font-size: 0.78rem; color: var(--text-3); margin-bottom: 0.12rem; }
.ld-q-val { font-size: 0.9rem; color: var(--text-1); line-height: 1.45; white-space: pre-wrap; }

/* ===================== Public RE-UX questionnaire page ===================== */
body.q-body { background: #efe7d6; overflow-y: auto; }
#q-root {
  --q-ink: #1d1a17;
  --q-ink-2: #4a443c;
  --q-cream: #f7f1e6;
  --q-cream-2: #efe7d6;
  --q-line: #ddd2bd;
  --q-red: #c0412b;
  --q-red-dark: #a3361f;
  color: var(--q-ink);
  font-family: 'Inter', system-ui, sans-serif;
}
.q-page { max-width: 760px; margin: 0 auto; padding: 0 1.5rem 5rem; }

.q-hero { padding: 4.5rem 0 2.5rem; text-align: center; }
.q-brand { font-family: 'Fraunces', Georgia, serif; font-weight: 600; font-size: 1.6rem; letter-spacing: 0.04em; color: var(--q-ink); }
.q-eyebrow { margin: 1.6rem 0 0.6rem; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.28em; color: var(--q-red); font-weight: 600; }
.q-title { font-family: 'Fraunces', Georgia, serif; font-weight: 500; font-size: clamp(2rem, 5vw, 3.1rem); line-height: 1.08; letter-spacing: -0.01em; margin: 0 auto; max-width: 14ch; color: var(--q-ink); }
.q-sub { margin: 1.1rem auto 0; max-width: 50ch; font-size: 1.02rem; line-height: 1.6; color: var(--q-ink-2); }
.q-sub strong { color: var(--q-ink); font-weight: 600; }

.q-form { display: flex; flex-direction: column; gap: 1.25rem; }
.q-section { background: var(--q-cream); border: 1px solid var(--q-line); border-radius: 16px; padding: 1.75rem 1.75rem 1.9rem; box-shadow: 0 1px 2px rgba(29,26,23,0.04); }
.q-section-head { display: flex; gap: 1rem; align-items: flex-start; margin-bottom: 1.4rem; }
.q-section-num { font-family: 'Fraunces', Georgia, serif; font-size: 1.5rem; font-weight: 500; color: var(--q-red); line-height: 1; padding-top: 0.1rem; font-variant-numeric: tabular-nums; }
.q-section-title { font-family: 'Fraunces', Georgia, serif; font-weight: 500; font-size: 1.5rem; margin: 0; color: var(--q-ink); }
.q-section-blurb { margin: 0.25rem 0 0; font-size: 0.92rem; color: var(--q-ink-2); }

.q-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem 1.25rem; }
.q-field { display: flex; flex-direction: column; gap: 0.4rem; }
.q-field-wide { grid-column: 1 / -1; }
.q-flabel { font-size: 0.85rem; font-weight: 500; color: var(--q-ink); }
.q-req { color: var(--q-red); margin-left: 0.15rem; }
.q-field input, .q-field textarea, .q-field select {
  font-family: inherit; font-size: 0.95rem; color: var(--q-ink);
  background: #fffdf8; border: 1px solid var(--q-line); border-radius: 9px;
  padding: 0.7rem 0.8rem; width: 100%; transition: border-color 0.15s, box-shadow 0.15s;
}
.q-field textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.q-field input::placeholder, .q-field textarea::placeholder { color: #b3a892; }
.q-field input:focus, .q-field textarea:focus, .q-field select:focus {
  outline: none; border-color: var(--q-red); box-shadow: 0 0 0 3px rgba(192,65,43,0.12);
}
.q-field .q-invalid { border-color: var(--q-red); box-shadow: 0 0 0 3px rgba(192,65,43,0.12); }

.q-submit-row { text-align: center; margin-top: 0.75rem; }
.q-submit {
  font-family: inherit; font-size: 1.02rem; font-weight: 600; color: #fff;
  background: var(--q-red); border: none; border-radius: 10px;
  padding: 0.95rem 2.4rem; cursor: pointer; transition: background 0.15s, transform 0.05s;
  box-shadow: 0 4px 14px rgba(192,65,43,0.28);
}
.q-submit:hover { background: var(--q-red-dark); }
.q-submit:active { transform: translateY(1px); }
.q-submit:disabled { opacity: 0.6; cursor: default; box-shadow: none; }
.q-fineprint { margin: 0.9rem 0 0; font-size: 0.8rem; color: var(--q-ink-2); }
.q-error { text-align: center; color: var(--q-red-dark); font-size: 0.9rem; font-weight: 500; margin: 0.25rem 0 0; min-height: 1.1rem; }
.q-footer { text-align: center; margin-top: 3rem; font-size: 0.78rem; letter-spacing: 0.04em; color: #9a8e78; }

.q-thanks-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.q-thanks { text-align: center; max-width: 46ch; }
.q-thanks-mark { width: 64px; height: 64px; margin: 1.6rem auto 0.5rem; border-radius: 50%; background: var(--q-red); color: #fff; font-size: 2rem; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(192,65,43,0.3); }
.q-thanks-sign { font-family: 'Fraunces', Georgia, serif; font-style: italic; color: var(--q-ink-2); margin-top: 1.4rem; }

@media (max-width: 560px) {
  .q-fields { grid-template-columns: 1fr; }
  .q-hero { padding: 3rem 0 2rem; }
  .q-section { padding: 1.4rem 1.2rem 1.5rem; }
}

/* ---- Payments ---- */
.pay-links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.9rem;
  margin-top: 1rem;
}
.pay-link-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.9rem;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.pay-link-name { font-weight: 600; color: var(--text); }
.pay-link-desc { font-size: 0.82rem; color: var(--text-2); margin-top: 0.2rem; }
.pay-link-price { font-size: 1.15rem; font-weight: 700; color: var(--accent); margin-top: 0.5rem; }
.pay-link-actions { display: flex; gap: 0.5rem; }
.pay-link-actions .btn { flex: 1; text-align: center; }
.pay-empty, .pay-link-actions a.btn { text-decoration: none; }
.pay-empty { color: var(--text-2); padding: 1rem 0; }

.pay-badge {
  display: inline-block;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
}
.pay-badge.pay-paid { background: var(--green-dim); color: var(--green); }
.pay-badge.pay-unpaid { background: var(--yellow-dim); color: var(--yellow); }
.pay-badge.pay-overdue { background: var(--red-dim); color: var(--red); }
.pay-badge.pay-none { background: var(--bg-4); color: var(--text-3); }
.pay-action-cell { text-align: right; white-space: nowrap; }
