/* CRM — dark, because cold callers stare at it all day. */

:root {
  --bg: #0b1210; --panel: #101a18; --panel-2: #0e1715; --line: #1e2d2a;
  --ink: #e6f1ee; --muted: #8aa29c; --teal: #2dd4bf; --teal-dim: #1b8f82;
  --bad: #ef4444; --warn: #eab308;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14px; }
a { color: var(--teal); }

/* ── chrome ──────────────────────────────────────────────────────────────── */
.bar { display: flex; align-items: center; gap: 22px; padding: 0 22px; height: 56px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.bar .brand { font-weight: 800; letter-spacing: 1.5px; color: var(--ink); text-decoration: none; font-size: 15px; }
.bar .brand span { color: var(--teal); margin-left: 6px; font-weight: 600; letter-spacing: 1px; }
.bar nav { display: flex; gap: 4px; }
.bar nav a { color: var(--muted); text-decoration: none; padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: 13.5px; }
.bar nav a:hover { color: var(--ink); background: #ffffff0a; }
.bar nav a.on { color: var(--teal); background: #2dd4bf14; }
.bar .me { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }

main { padding: 22px; max-width: 1500px; margin: 0 auto; }
h1 { font-size: 22px; margin: 0 0 4px; }
.sub { color: var(--muted); margin: 0 0 18px; }

/* ── controls ────────────────────────────────────────────────────────────── */
button, .btn {
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  background: #ffffff0d; color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 15px; text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { border-color: var(--teal-dim); }
button.primary, .btn.primary { background: var(--teal); color: #04110f; border-color: var(--teal); }
button.primary:hover { background: #4fe3d1; }
button.ghost { background: transparent; }
button.danger { color: #fca5a5; border-color: #ef444455; }
button:disabled { opacity: .5; cursor: default; }

input, select, textarea {
  font: inherit; font-size: 13.5px; color: var(--ink); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal-dim); box-shadow: 0 0 0 3px #2dd4bf1f; }
textarea { min-height: 76px; resize: vertical; line-height: 1.5; }
label { font-size: 12px; font-weight: 600; color: var(--muted); display: block; margin-bottom: 5px; }
select option { background: var(--panel); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.toolbar .grow { flex: 1; min-width: 220px; }
.field { min-width: 150px; }

/* ── panels and tables ───────────────────────────────────────────────────── */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 14px; }
.panel h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--teal); margin: 0 0 14px; }

table { width: 100%; border-collapse: collapse; }
thead th { text-align: left; font-size: 11px; letter-spacing: .7px; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 0 12px 10px; white-space: nowrap; }
tbody td { padding: 11px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: #ffffff06; }
td.num, th.num { text-align: right; }
.wrap { overflow-x: auto; }
.addr { font-weight: 600; }
.sub2 { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); padding: 40px; text-align: center; }

.pill { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 999px; border: 1px solid; white-space: nowrap; }
.chip { display: inline-block; font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; }
.due { font-weight: 700; }
.due.over { color: var(--bad); }
.due.soon { color: var(--warn); }

/* ── sign in ─────────────────────────────────────────────────────────────── */
.signin { max-width: 380px; margin: 11vh auto; padding: 0 20px; }
.signin .logo { font-weight: 800; letter-spacing: 2px; font-size: 22px; text-align: center; margin-bottom: 6px; }
.signin .logo span { color: var(--teal); }
.signin p.lead { color: var(--muted); text-align: center; margin: 0 0 24px; }
.signin .panel { padding: 22px; }
.signin .row { margin-bottom: 14px; }

.setup { max-width: 640px; margin: 10vh auto; padding: 28px; color: var(--ink); font-family: var(--font); }
.setup h1 { color: var(--teal); }
.setup code { background: #ffffff12; padding: 2px 6px; border-radius: 4px; }
.setup li { margin: 8px 0; }

/* ── lead detail ─────────────────────────────────────────────────────────── */
.cols { display: grid; grid-template-columns: 1.3fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 1000px) { .cols { grid-template-columns: 1fr; } }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 18px; }
@media (max-width: 700px) { .facts { grid-template-columns: repeat(2, 1fr); } }
.fact .k { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.fact .v { font-size: 14.5px; font-weight: 600; margin-top: 2px; word-break: break-word; }
.timeline { display: flex; flex-direction: column; gap: 12px; }
.note { border-left: 2px solid var(--line); padding: 2px 0 2px 14px; }
.note .meta { font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.note .body { white-space: pre-wrap; line-height: 1.5; }
.call-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.big-phone { font-size: 21px; font-weight: 700; letter-spacing: .4px; }

/* ── upload mapping ──────────────────────────────────────────────────────── */
.map-grid { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 10px 14px; align-items: center; }
.map-grid .head { font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); }
.sample { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px); background: var(--teal); color: #04110f; font-weight: 700; padding: 11px 20px; border-radius: 999px; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; max-width: 80vw; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--bad); color: #fff; }

/* ── the address, which copies itself ────────────────────────────────────── */
/* A button so it is reachable by keyboard, styled as the link it replaced. */
button.addr {
  background: none; border: 0; padding: 0; margin: 0; font: inherit; font-weight: 600;
  color: var(--teal); cursor: pointer; text-align: left; line-height: 1.35;
}
button.addr:hover { text-decoration: underline; border-color: transparent; }
button.addr:active { opacity: .7; }

/* ── the quick note, tucked under its own lead ───────────────────────────── */
tr.quick td { border-top: 0; padding-top: 0; padding-bottom: 14px; background: #ffffff05; }
tr.quick .toolbar .grow { min-width: 260px; }

/* ── stepping from one lead to the next ──────────────────────────────────── */
.lead-nav { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; }
.lead-nav .grow { flex: 1; }

/* ── status picker ───────────────────────────────────────────────────────── */
.pk { display: inline-block; }
.pk-btn {
  display: inline-flex; align-items: center; gap: 7px; min-width: 150px;
  padding: 7px 10px; border: 1px solid; border-radius: 9px; background: none;
  font: inherit; font-size: 13px; cursor: pointer; text-align: left;
}
.pk-btn .pk-label { flex: 1; }
.pk-btn .pk-caret { opacity: .7; font-size: 11px; }
.pk-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

.pk-menu {
  position: fixed; z-index: 60; min-width: 260px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 18px 50px -12px #000c;
}
.pk-opt {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px;
  border: 1px solid transparent; border-radius: 8px; background: none;
  font: inherit; font-size: 13.5px; text-align: left; cursor: pointer;
}
.pk-opt .pk-label { font-weight: 700; }
.pk-opt .pk-note { margin-left: auto; color: var(--muted); font-size: 11.5px; }
.pk-opt:hover { background: #ffffff0d; border-color: var(--line); }
.pk-opt.on { background: #ffffff12; }
.pk-opt.on::after { content: '✓'; color: var(--muted); margin-left: 6px; }

/* ── small controls ──────────────────────────────────────────────────────── */
button.sm, .btn.sm { font-size: 12px; padding: 5px 11px; border-radius: 7px; }
.toolbar.tight { gap: 8px; margin-bottom: 14px; }
.toolbar.tight label { font-size: 10.5px; letter-spacing: .4px; margin-bottom: 4px; }
.toolbar.tight .field { min-width: 132px; }
.toolbar.tight input, .toolbar.tight select { font-size: 13px; padding: 7px 10px; }
.toolbar.tight .spacer { flex: 1; min-width: 0; }

/* ── the leads table ─────────────────────────────────────────────────────── */
/* Two lines per lead and nothing else: the address with where it is, the
   person with their number. Everything secondary is 11.5px and muted, so the
   eye lands on the address and the status colour. */
.leads-panel { padding: 0; overflow: hidden; }
.leads-table { font-size: 13px; }
.leads-table thead th { padding: 12px 12px 10px; font-size: 10.5px; letter-spacing: .8px; }
.leads-table tbody td { padding: 8px 12px; }
.leads-table .meta { color: var(--muted); font-size: 11.5px; margin-top: 2px; line-height: 1.35; }
.leads-table .meta a { color: var(--muted); text-decoration: none; }
.leads-table .meta a:hover { color: var(--teal); }
.leads-table .chip { font-size: 10px; padding: 1px 7px; }

.leads-table .c-addr { min-width: 230px; }
.leads-table .c-addr .addr { font-size: 13.5px; }
.leads-table .c-contact { min-width: 150px; }
.leads-table .c-contact .who { font-weight: 600; white-space: nowrap; }
.leads-table .c-contact .meta { white-space: nowrap; }
.leads-table .c-due { width: 1%; white-space: nowrap; }
.leads-table .c-note { max-width: 300px; }
.leads-table .c-note .line { color: var(--muted); display: block; line-height: 1.35;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leads-table .c-note .when { color: #5f7570; font-size: 11px; }
.leads-table .c-act { width: 1%; white-space: nowrap; text-align: right; }
.leads-table .c-act > * { margin-left: 6px; }

/* The row's own buttons stay quiet until the pointer is on that row. */
.leads-table .c-act .btn, .leads-table .c-act button { opacity: .55; transition: opacity .12s; }
.leads-table tr:hover .c-act .btn, .leads-table tr:hover .c-act button,
.leads-table .c-act button.on { opacity: 1; }
.leads-table .note-toggle.on { border-color: var(--teal-dim); color: var(--teal); }

/* The follow-up date: text until you click it. */
.fu-btn {
  display: inline-flex; align-items: baseline; gap: 7px; padding: 4px 8px; font-size: 12.5px;
  font-weight: 600; background: none; border: 1px solid transparent; border-radius: 7px; color: var(--ink);
}
.fu-btn:hover { border-color: var(--line); background: #ffffff08; }
.fu-btn .d { font-size: 11px; font-weight: 600; color: var(--muted); }
.fu-btn.none { color: var(--muted); font-weight: 500; }
.fu-btn.over, .fu-btn.over .d { color: var(--bad); }
.fu-btn.soon, .fu-btn.soon .d { color: var(--warn); }
.leads-table input.fu { width: auto; min-width: 136px; padding: 5px 8px; font-size: 12.5px; }

/* The picker sits in a row, so it is sized for one. */
.leads-table .pk-btn { min-width: 134px; padding: 5px 9px; font-size: 12.5px; }
.leads-table .c-dom { width: 1%; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }

/* ── sortable headers ────────────────────────────────────────────────────── */
.leads-table th.so { cursor: pointer; user-select: none; }
.leads-table th.so:hover { color: var(--ink); }
.leads-table th.so::after { content: '↕'; opacity: .25; margin-left: 5px; font-size: 10px; }
.leads-table th.so.on { color: var(--teal); }
.leads-table th.so.on[data-dir="asc"]::after { content: '↑'; opacity: 1; }
.leads-table th.so.on[data-dir="desc"]::after { content: '↓'; opacity: 1; }
.leads-table th.so.num::after { margin-left: 4px; }
.leads-table th.reset { text-align: right; padding-right: 12px; }
