/* IntentScoring -- app-specific styles (supplements is-tokens.css + is-tool.css) */

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ---------- Auth gate ---------- */
.auth-gate {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: var(--paper);
}
.auth-box {
  text-align: center;
  font-family: var(--f-sans);
  width: 360px;
  background: var(--card, #fff);
  border: 1px solid var(--rule-2);
  border-radius: 6px;
  padding: 40px 36px 32px;
  box-shadow: 0 2px 12px rgba(27,24,20,.06);
}
.auth-box .auth-brand {
  color: var(--clay);
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.15em;
  margin-bottom: 8px;
}
.auth-box .auth-heading {
  color: var(--ink);
  font-family: var(--f-display);
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 28px;
}
.auth-box input {
  display: block; width: 100%; box-sizing: border-box;
  background: var(--paper); border: 1px solid var(--rule-2); border-radius: 3px;
  color: var(--ink); padding: 10px 14px; font-size: 14px;
  outline: none; margin-bottom: 10px; font-family: inherit;
}
.auth-box input:focus { border-color: var(--clay); }
.auth-box input::placeholder { color: var(--ink-4); }
.auth-box .auth-btn {
  width: 100%; padding: 10px;
  background: var(--clay); color: #fff8f0;
  border: none; border-radius: 3px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  font-family: inherit;
  transition: background .14s;
}
.auth-box .auth-btn:hover { background: var(--clay-ink); }
.auth-box .auth-btn:disabled { opacity: .5; cursor: not-allowed; }
.auth-box .auth-error {
  color: var(--danger); font-size: 13px;
  margin-top: 12px; min-height: 20px;
}
/* Confirmations share this slot. Rendering "reset email sent" in the danger
   colour told a new user their successful action had failed. */
.auth-box .auth-error.is-ok { color: var(--ok); }
.auth-box .auth-toggle-btn {
  background: none; border: none;
  color: var(--clay); font-size: 13px;
  cursor: pointer; font-family: inherit;
  margin-top: 16px;
}
.auth-box .auth-toggle-btn:hover { text-decoration: underline; }

/* ---------- Paywall gate ---------- */
.paywall {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--paper);
}
.paywall-card {
  text-align: center; width: 440px; max-width: 92vw;
  background: var(--card, #fff);
  border: 1px solid var(--rule-2); border-radius: 6px;
  padding: 48px 40px 40px;
  box-shadow: 0 2px 12px rgba(27,24,20,.06);
}
.paywall-card .auth-brand { color: var(--clay); font-family: var(--f-mono); font-size: 11px; letter-spacing: .15em; margin-bottom: 8px; }
.paywall-card h2 { font-family: var(--f-display); font-size: 22px; font-weight: 700; color: var(--ink); margin: 0 0 12px; }
.paywall-card p { font-size: 15px; color: var(--ink-2); line-height: 1.55; margin: 0 0 8px; }
.paywall-card .paywall-price { font-family: var(--f-mono); font-size: 13px; color: var(--ink-3); margin: 16px 0 24px; }
.paywall-card .paywall-btn {
  display: inline-block; padding: 12px 32px;
  background: var(--clay); color: #fff8f0;
  border: none; border-radius: 3px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: background .14s;
}
.paywall-card .paywall-btn:hover { background: var(--clay-ink); }
.paywall-card .paywall-btn:disabled { opacity: .5; cursor: not-allowed; }
/* Annual sits under monthly as the quieter of the two, so both plans are
   reachable without either one looking like the only option. */
.paywall-card .paywall-btn + .paywall-btn { margin-top: 10px; }
.paywall-card .paywall-btn-alt {
  background: transparent; color: var(--clay);
  box-shadow: inset 0 0 0 1px var(--clay);
}
.paywall-card .paywall-btn-alt:hover { background: var(--clay); color: #fff8f0; }
.paywall-card .paywall-sub { font-size: 13px; color: var(--ink-4); margin-top: 14px; }
.paywall-card .paywall-status { font-family: var(--f-mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--danger); margin-bottom: 16px; }
.paywall-card .paywall-signout { background: none; border: none; color: var(--ink-4); font-size: 13px; cursor: pointer; font-family: inherit; margin-top: 20px; }
.paywall-card .paywall-signout:hover { color: var(--ink-2); text-decoration: underline; }

/* ---------- Toast system ---------- */
.toast-stack {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 100; max-width: 380px;
}
.toast {
  background: var(--card);
  border: 1px solid var(--rule-2);
  border-left: 3px solid var(--clay);
  border-radius: 3px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  display: flex; align-items: flex-start; gap: 10px;
  animation: toast-in 0.2s ease-out;
}
@keyframes toast-in {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--ochre); }
.toast.success { border-left-color: var(--ok); }
.toast.info { border-left-color: var(--slate); }
.toast .lucide { width: 16px; height: 16px; margin-top: 1px; flex-shrink: 0; }
.toast.error .lucide { color: var(--danger); }
.toast.warn .lucide { color: var(--ochre); }
.toast.success .lucide { color: var(--ok); }
.toast.info .lucide { color: var(--slate); }
.toast-body { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.toast-title { font-size: 12px; font-weight: 600; color: var(--ink); }
.toast-msg {
  font-family: var(--f-mono); font-size: 11px;
  color: var(--ink-2); line-height: 1.4; word-break: break-word;
}
.toast-dismiss {
  background: transparent; border: none;
  color: var(--ink-4); cursor: pointer;
  display: grid; place-items: center; padding: 2px;
}
.toast-dismiss:hover { color: var(--ink); }
.toast-dismiss .lucide { width: 14px; height: 14px; margin: 0; }

/* ---------- Toggle switch ---------- */
.toggle {
  display: inline-flex; align-items: center; gap: 10px;
  cursor: pointer; font-size: 12px; color: var(--ink-2); user-select: none;
}
.toggle input { display: none; }
.toggle-track {
  width: 32px; height: 18px;
  background: var(--paper-2); border: 1px solid var(--rule-2);
  border-radius: 999px; position: relative;
  transition: background .14s;
}
.toggle-track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 12px; height: 12px; border-radius: 999px;
  background: var(--ink-4);
  transition: transform .14s, background .14s;
}
.toggle input:checked + .toggle-track {
  background: rgba(156,67,24,0.2); border-color: var(--clay);
}
.toggle input:checked + .toggle-track::after {
  transform: translateX(14px); background: var(--clay);
}

/* ---------- Secret input (eye toggle) ---------- */
.input-with-action { position: relative; }
.input-with-action .input { padding-right: 88px; font-family: var(--f-mono); }
.input-with-action .input-action {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  display: flex; gap: 4px;
}
.input-with-action .icon-btn {
  background: transparent; border: 1px solid var(--rule-2);
  color: var(--ink-4); width: 28px; height: 28px;
  display: grid; place-items: center; border-radius: 3px;
  cursor: pointer; transition: background .14s, color .14s;
}
.input-with-action .icon-btn:hover { background: var(--paper-2); color: var(--ink); }
.input-with-action .icon-btn .lucide { width: 13px; height: 13px; }

/* ---------- Collapsible section ---------- */
.collapse-toggle {
  background: none; border: none; color: var(--ink-2);
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.04em;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: 0;
}
.collapse-toggle:hover { color: var(--ink); }
.collapse-toggle .lucide {
  width: 14px; height: 14px; transition: transform .14s;
}
.collapse-toggle.open .lucide { transform: rotate(90deg); }

/* ---------- Results toolbar ---------- */
.results-toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.results-toolbar .count {
  font-family: var(--f-mono); font-size: 11px; color: var(--ink-3); letter-spacing: 0.04em;
}
.results-toolbar .count strong { color: var(--ink); font-weight: 600; }
.results-toolbar .toolbar-actions {
  margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap;
}

/* ---------- Results table (extends is-tool.css table.leads) ---------- */
.table-wrap {
  border: 1px solid var(--rule-2); border-radius: 4px;
  overflow: hidden; background: var(--card);
}
.table-scroll { overflow-x: auto; }
table.results {
  width: 100%; border-collapse: collapse; min-width: 900px;
}
table.results th, table.results td {
  text-align: left; padding: 11px 14px;
  border-bottom: 1px solid #efe9dc; vertical-align: top; font-size: 13px;
}
table.results th {
  font-family: var(--f-mono); font-size: 9.5px;
  letter-spacing: .11em; text-transform: uppercase;
  color: var(--ink-4); font-weight: 500;
  background: var(--paper-2); border-bottom: 1px solid var(--rule-2);
  padding: 9px 14px; white-space: nowrap;
}
table.results tr:last-child td { border-bottom: none; }
table.results tbody tr { transition: background .1s; }
table.results tbody tr:hover { background: #faf6ee; }

/* cell types */
.cell-name { font-weight: 600; color: var(--ink); font-size: 14px; letter-spacing: -.01em; }
.cell-addr { color: var(--ink-2); font-size: 12px; line-height: 1.4; max-width: 260px; }
.cell-mono { font-family: var(--f-mono); font-size: 12px; color: var(--ink-2); }
.cell-link {
  font-family: var(--f-mono); font-size: 12px;
  color: var(--clay); text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px;
}
.cell-link:hover { text-decoration: underline; color: var(--clay-ink); }
.cell-link .lucide { width: 11px; height: 11px; }
.cell-cat { font-family: var(--f-mono); font-size: 11px; color: var(--ink-3); letter-spacing: 0.02em; }
.rating {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--f-mono); font-size: 12px; color: var(--ink);
}
.rating .lucide { width: 12px; height: 12px; color: var(--ochre); fill: var(--ochre); }
.rating .count { color: var(--ink-4); font-size: 10px; }

/* email cells */
.cell-emails { display: flex; flex-direction: column; gap: 4px; }
.email-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--f-mono); font-size: 11px; color: var(--ink);
  background: rgba(156,67,24,0.08); border: 1px solid rgba(156,67,24,0.25);
  border-radius: 2px; padding: 2px 6px; width: fit-content; max-width: 100%;
}
.email-chip .email-name { color: var(--ink-3); margin-right: 4px; font-size: 10px; }
.email-pending {
  font-family: var(--f-mono); font-size: 11px; color: var(--ink-4);
  display: inline-flex; align-items: center; gap: 6px;
}
.email-pending .lucide { width: 12px; height: 12px; }
.email-dup { font-family: var(--f-mono); font-size: 10px; color: var(--ink-4); }
.dup-row { opacity: 0.45; }
.dup-row .cell-name::after {
  content: "DUP"; font-family: var(--f-mono); font-size: 9px;
  letter-spacing: 0.08em; background: var(--paper-2); color: var(--ink-3);
  padding: 1px 5px; border-radius: 2px; margin-left: 8px; vertical-align: middle;
}

/* ---------- Score badge ---------- */
.score-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--f-mono); width: 70px;
}
.score-badge .score-num {
  font-size: 14px; font-weight: 600; width: 22px; text-align: center; color: var(--ink);
}
.score-badge .score-bar {
  flex: 1; height: 4px; background: var(--paper-2);
  border-radius: 2px; overflow: hidden; position: relative;
}
.score-badge .score-bar > span {
  position: absolute; inset: 0; border-radius: 2px; transition: width .14s;
}
.score-badge.tier-good .score-num { color: var(--ok); }
.score-badge.tier-good .score-bar > span { background: var(--ok); }
.score-badge.tier-ok .score-num { color: var(--ochre); }
.score-badge.tier-ok .score-bar > span { background: var(--ochre); }
.score-badge.tier-bad .score-num { color: var(--danger); }
.score-badge.tier-bad .score-bar > span { background: var(--danger); }

/* ---------- Filter tag ---------- */
.filter-tag {
  display: inline-block; font-family: var(--f-mono); font-size: 9px;
  letter-spacing: 0.06em; text-transform: uppercase;
  background: rgba(141,47,34,0.1); color: var(--danger);
  border: 1px solid rgba(141,47,34,0.25);
  padding: 1px 5px; border-radius: 2px; margin-left: 8px;
  vertical-align: middle; cursor: help;
}
tr.filtered-row { opacity: 0.55; }
tr.filtered-row.dup-row { opacity: 0.35; }

/* ---------- Empty / loading states ---------- */
.empty-state, .loading-state {
  padding: 48px 24px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  color: var(--ink-3);
}
.empty-state .lucide, .loading-state .lucide { width: 28px; height: 28px; color: var(--ink-4); }
.empty-state .title, .loading-state .title { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.empty-state .sub, .loading-state .sub {
  font-family: var(--f-mono); font-size: 11px; color: var(--ink-4);
  max-width: 360px; line-height: 1.5;
}
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Modal / dialog ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(27,24,20,0.5); backdrop-filter: blur(4px);
  z-index: 90; display: grid; place-items: center; padding: 20px;
  animation: fadeIn 0.15s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--card); border: 1px solid var(--rule-2); border-radius: 4px;
  padding: 24px; max-width: 520px; width: 100%; box-shadow: var(--shadow-lift);
  display: flex; flex-direction: column; gap: 16px;
}
.modal h3 { margin: 0; font-size: 16px; }
.modal p { margin: 0; font-size: 13px; color: var(--ink-2); line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.btn-danger-ghost {
  background: transparent; color: var(--danger);
  border-color: rgba(141,47,34,0.3);
}
.btn-danger-ghost:hover { background: rgba(141,47,34,0.08); }

/* ---------- Run log ---------- */
.runlog {
  border: 1px solid var(--rule-2); border-radius: 3px; background: var(--paper-2);
  max-height: 140px; overflow-y: auto; padding: 10px 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.runlog::-webkit-scrollbar { width: 6px; }
.runlog::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 4px; }
.log-line {
  font-family: var(--f-mono); font-size: 11px; color: var(--ink-2);
  display: flex; gap: 8px;
}
.log-line .ts { color: var(--ink-4); }
.log-line.ok .msg { color: var(--ok); }
.log-line.err .msg { color: var(--danger); }
.log-line.warn .msg { color: var(--ochre); }

/* ---------- Checkbox ---------- */
.checkbox-stack { display: flex; flex-direction: column; gap: 8px; }
.checkbox-row {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  font-size: 13px; color: var(--ink-2); user-select: none;
}
.checkbox-row input { display: none; }
.checkbox-box {
  width: 16px; height: 16px; border: 1px solid var(--rule-2); border-radius: 2px;
  display: grid; place-items: center; background: var(--card);
  transition: background .14s, border-color .14s; flex-shrink: 0;
}
.checkbox-box .lucide { width: 12px; height: 12px; color: white; }
.checkbox-row input:checked + .checkbox-box { background: var(--clay); border-color: var(--clay); }
.checkbox-row:hover .checkbox-box { border-color: var(--ink-4); }
.checkbox-label { line-height: 1.3; }

/* ---------- Range slider ---------- */
.range {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px;
  background: var(--paper-2); border: 1px solid var(--rule-2);
  border-radius: 999px; outline: none; margin: 6px 0;
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px;
  background: var(--clay); border-radius: 999px; cursor: pointer;
  border: 2px solid var(--card); box-shadow: 0 0 0 1px var(--rule-2);
  transition: transform .1s;
}
.range::-webkit-slider-thumb:hover { transform: scale(1.1); }
.range::-moz-range-thumb {
  width: 18px; height: 18px; background: var(--clay);
  border-radius: 999px; cursor: pointer; border: 2px solid var(--card);
}
.range-ticks {
  display: flex; justify-content: space-between;
  font-family: var(--f-mono); font-size: 10px; color: var(--ink-4); margin-top: 2px;
}

/* ---------- Batch progress ---------- */
.batch-panel { display: flex; flex-direction: column; gap: 12px; }
.batch-progress-inline {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--f-mono); font-size: 11px; color: var(--ink-2);
}
.batch-progress-inline .lucide { width: 12px; height: 12px; color: var(--clay); }
.batch-progress { display: flex; flex-direction: column; gap: 6px; }
.batch-progress-bar {
  height: 6px; background: var(--paper-2); border: 1px solid var(--rule-2);
  border-radius: 999px; overflow: hidden;
}
.batch-progress-fill {
  height: 100%; background: var(--clay); transition: width .14s;
}
.batch-progress-meta {
  font-size: 11px; color: var(--ink-3); display: flex; gap: 8px; flex-wrap: wrap;
}
.batch-progress-meta .dim { color: var(--ink-4); }

/* ---------- Section header ---------- */
.shdr {
  position: relative; padding-left: 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.shdr::before {
  content: ""; position: absolute; left: 0; top: 4px; bottom: 4px;
  width: 4px; border-radius: 2px; background: var(--clay);
}
.shdr h2 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); }
.shdr .desc {
  font-family: var(--f-mono); font-size: 11px; color: var(--ink-3); letter-spacing: 0.02em;
}

/* ---------- Card (old-style panels used by Profile/Qualification/API/Results) ---------- */
.card {
  background: var(--card); border: 1px solid var(--rule-2); border-radius: 4px;
  padding: 20px; display: flex; flex-direction: column; gap: 16px;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.card-head .card-actions { display: flex; gap: 8px; align-items: center; }
.card.entity-rail { border-left: 3px solid var(--clay); padding-left: 18px; }

/* ---------- Form fields ---------- */
.field-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px;
}
.field-wide { grid-column: 1 / -1; }

/* Pill (old-style) used by status badges in cards */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--f-mono); font-size: 10px;
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px;
  border: 1px solid var(--rule-2); color: var(--ink-3); background: var(--card);
}
.pill.ok { color: var(--ok); border-color: rgba(63,107,70,0.3); background: rgba(63,107,70,0.08); }
.pill.warn { color: var(--ochre); border-color: rgba(154,116,20,0.3); background: rgba(154,116,20,0.08); }
.pill.err { color: var(--danger); border-color: rgba(141,47,34,0.3); background: rgba(141,47,34,0.08); }
.pill.info { color: var(--slate); border-color: rgba(66,90,99,0.3); background: rgba(66,90,99,0.08); }
.pill.muted { color: var(--ink-3); }

/* key status row */
.key-status-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Misc utilities */
.divider { height: 1px; background: var(--rule); margin: 4px 0; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.muted { color: var(--ink-3); }

/* icon host inline span */
.icon-host { display: inline-flex; align-items: center; }

/* ---------- View-specific layout ---------- */
.view-content { display: flex; flex-direction: column; gap: 24px; }

/* ---------- Setup wizard (onboarding) ---------- */
.setup { background: var(--card); border: 1px solid var(--rule-2); border-radius: 4px; max-width: 720px; }
.setup-head { padding: 20px 22px 16px; border-bottom: 1px solid var(--rule); }
.setup-head h3 { font-size: 18px; }
.setup-head p { font-size: 13.5px; color: var(--ink-3); margin-top: 7px; max-width: 56ch; }
.sstep { display: grid; grid-template-columns: 26px minmax(0,1fr) auto; gap: 14px; align-items: start; padding: 16px 22px; border-bottom: 1px solid var(--rule); }
.sstep:last-child { border-bottom: 0; }
.sstep .num { font-family: var(--f-mono); font-size: 11px; color: var(--ink-4); border: 1px solid var(--rule-2); border-radius: 50%; width: 22px; height: 22px; display: grid; place-items: center; margin-top: 1px; }
.sstep.done .num { background: var(--ok); border-color: var(--ok); color: #fff; }
.sstep .t { font-size: 14.5px; font-weight: 600; }
.sstep .d { font-size: 13px; color: var(--ink-3); margin-top: 4px; max-width: 48ch; line-height: 1.5; }
.sstep.next { background: #f9f5ed; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  /* The rail was display:none here, and the rail is the only thing in the app
     that can change view. Tapping "Add key" in the setup wizard therefore left
     a phone user on the keys screen with no way back to Results -- the first
     thing they do after paying, and a dead end. It is a scrolling strip now. */
  .rail {
    flex-direction: row; align-items: center; gap: 6px;
    padding: 8px 14px; border-right: 0; border-bottom: 1px solid #332e28;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
  }
  .rail .brand, .rail-label, .rail-foot { display: none; }
  .rail-group { padding: 0; margin-bottom: 0; display: flex; }
  .rail .stack { flex-direction: row; gap: 6px; }
  .rail a.rl {
    white-space: nowrap; padding: 7px 12px; border-radius: 999px;
    border: 1px solid #332e28; font-size: 13px;
  }
  .rail a.rl .dot { display: none; }
  .topbar { padding: 0 14px; gap: 10px; }
  .page { padding: 18px 14px 36px; }
  /* Was display:none, which removed the only on-screen answer to "is my key
     saved?" on the one device where the keys screen is hardest to use. */
  .key-status-row { flex-wrap: wrap; gap: 6px; }
  .results-toolbar { gap: 8px; }
  .results-toolbar .toolbar-actions { flex-wrap: wrap; }
}
