:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2430;
  --border: #2d3644;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #4c8dff;
  --green: #3fb950;
  --red: #f85149;
  --amber: #d29922;
  font-size: 15px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; }
.logo { color: var(--accent); font-size: 22px; }
h1 { font-size: 19px; font-weight: 650; letter-spacing: 0.3px; }

.tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--panel-2);
  color: var(--amber);
  border: 1px solid var(--border);
}
.tag:empty { display: none; }

.carriers-chip { color: var(--muted); font-size: 13px; }

main {
  max-width: 880px;
  margin: 28px auto 60px;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 24px;
}

.card h2 { font-size: 15px; font-weight: 650; margin-bottom: 16px; color: var(--text); }
.hidden { display: none; }

/* ── Form ── */
.grid { display: grid; gap: 14px; margin-bottom: 14px; }
.grid.names { grid-template-columns: 1fr 0.7fr 1fr; }
.grid.address { grid-template-columns: 1fr; }
.grid.csz { grid-template-columns: 1.4fr 0.5fr 0.7fr; }

label { display: flex; flex-direction: column; gap: 6px; }
label span { font-size: 12.5px; font-weight: 550; color: var(--muted); }
label em { font-style: normal; opacity: 0.65; }

input {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14.5px;
  outline: none;
  transition: border-color 0.15s;
}
input:focus { border-color: var(--accent); }
input.invalid { border-color: var(--red); }

.actions { display: flex; align-items: center; gap: 14px; margin-top: 6px; }

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 11px 22px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
button:hover { opacity: 0.9; }
button:disabled { opacity: 0.5; cursor: default; }

button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 7px 14px;
  font-size: 13px;
}

.form-error { color: var(--red); font-size: 13px; }

/* ── Run status ── */
.run-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.run-head h2 { margin: 0; }

.carrier-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }

.carrier-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.carrier-card .cname { font-weight: 650; font-size: 14px; }
.carrier-card .cstatus { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.carrier-card .cpremium { font-size: 20px; font-weight: 700; margin-top: 2px; }

.carrier-card.quoted { border-color: rgba(63, 185, 80, 0.5); }
.carrier-card.quoted .cpremium { color: var(--green); }
.carrier-card.best { border-color: var(--green); box-shadow: 0 0 0 1px var(--green); }
.carrier-card.declined { border-color: rgba(248, 81, 73, 0.4); }
.carrier-card.declined .cstatus { color: var(--red); }
.carrier-card.failed .cstatus, .carrier-card.needs_reauth .cstatus { color: var(--amber); }

.spinner {
  width: 12px; height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.best-badge {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.5px;
  color: var(--green); border: 1px solid var(--green);
  border-radius: 20px; padding: 1px 8px; width: fit-content;
}

/* ── Results table ── */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border);
}
td { padding: 10px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
td.premium { font-weight: 700; }
td.notes { color: var(--muted); font-size: 13px; }

.status-pill {
  font-size: 11px; font-weight: 700; letter-spacing: 0.4px;
  padding: 2px 9px; border-radius: 20px;
}
.status-pill.quoted { color: var(--green); background: rgba(63,185,80,0.12); }
.status-pill.declined { color: var(--red); background: rgba(248,81,73,0.12); }
.status-pill.failed, .status-pill.needs_reauth, .status-pill.not_implemented { color: var(--amber); background: rgba(210,153,34,0.12); }

/* ── History ── */
.history-list { display: flex; flex-direction: column; }
.history-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 4px; border-bottom: 1px solid var(--border);
  font-size: 13.5px; cursor: pointer;
}
.history-row:last-child { border-bottom: none; }
.history-row:hover { background: var(--panel-2); border-radius: 6px; }
.history-row .who { color: var(--text); }
.history-row .where { color: var(--muted); }
.history-row .best { color: var(--green); font-weight: 650; }
.history-empty { color: var(--muted); font-size: 13.5px; padding: 6px 2px; }

@media (max-width: 640px) {
  .grid.names, .grid.csz { grid-template-columns: 1fr; }
  .carrier-cards { grid-template-columns: 1fr; }
}

/* ── View Full Quote ── */
.view-quote {
  display: inline-block;
  margin-top: 8px;
  width: fit-content;
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 6px 12px;
  transition: background 0.15s;
}
.view-quote:hover { background: rgba(76, 141, 255, 0.12); }
.view-quote.small { margin-top: 0; padding: 4px 10px; font-size: 12px; white-space: nowrap; }

/* ── Carrier session dots (header) ── */
.carriers-chip .dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted); margin-right: 6px; vertical-align: 1px;
}
.carriers-chip .dot.ok { background: var(--green); }
.carriers-chip .dot.needs_reauth { background: var(--red); }
.carriers-chip .sep { margin: 0 10px; }

/* ── Carrier connections panel ── */
.hint { color: var(--muted); font-size: 13px; margin: -6px 0 14px; }
.carrier-conn { display: flex; flex-direction: column; gap: 2px; }
.conn-row {
  display: grid; grid-template-columns: 1.4fr 1fr auto; align-items: center;
  padding: 11px 6px; border-bottom: 1px solid var(--border); gap: 12px;
}
.conn-row:last-child { border-bottom: none; }
.conn-name { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 14px; }
.conn-state { color: var(--muted); font-size: 13px; }
.conn-note { color: var(--muted); font-size: 12.5px; font-style: italic; }
button.small { padding: 6px 14px; font-size: 13px; }

/* dots (shared: header chip + connection rows) */
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--green); }
.dot.bad { background: var(--red); }
.dot.wait { background: var(--amber); animation: pulse 1.1s ease-in-out infinite; }
.dot.off { background: #4a5568; }
@keyframes pulse { 50% { opacity: 0.35; } }

.carriers-chip .dot { margin-right: 6px; vertical-align: 1px; }
.carriers-chip .sep { margin: 0 10px; }

/* ── MFA code entry ── */
.mfa-input {
  width: 110px; padding: 6px 10px; font-size: 13px;
  background: var(--panel-2); border: 1px solid var(--accent);
  border-radius: 8px; color: var(--text); outline: none;
}
