:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f1f3f6;
  --text: #1b1f24;
  --muted: #65707d;
  --faint: #9aa3ad;
  --border: #e2e6ea;
  --accent: #2f5bea;
  --accent-soft: #e8eefd;
  --ok: #1d7f4e;
  --ok-soft: #e3f4ea;
  --warn: #9a6400;
  --warn-soft: #fdf1d8;
  --bad: #b3261e;
  --bad-soft: #fbe7e5;
  --trackA: #2f5bea;
  --trackB: #8a3ffc;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418; --panel: #181c21; --panel-2: #20252b; --text: #e6e9ed; --muted: #9aa4af; --faint: #6b7580;
    --border: #2c3239; --accent: #7a9bff; --accent-soft: #1f2a44; --ok: #58c28b; --ok-soft: #173325;
    --warn: #e0b04a; --warn-soft: #362a12; --bad: #f08a80; --bad-soft: #3a1c1a; --trackA: #7a9bff; --trackB: #b58cff;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; font-weight: 650; }
h2 { font-size: 15px; margin: 0 0 10px; font-weight: 650; }
h3 { font-size: 13px; margin: 0 0 6px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0 0 8px; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
pre { white-space: pre-wrap; word-break: break-word; margin: 0; }

.app { display: grid; grid-template-columns: 208px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--border); padding: 14px 10px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { font-weight: 700; padding: 4px 10px 14px; font-size: 15px; }
.brand small { display: block; color: var(--muted); font-weight: 500; font-size: 11.5px; }
.nav a { display: flex; align-items: center; justify-content: space-between; padding: 7px 10px; border-radius: 6px; color: var(--text); margin-bottom: 1px; }
.nav a:hover { background: var(--panel-2); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .count { background: var(--accent); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 11.5px; font-weight: 600; }
.nav .count.bad { background: var(--bad); }
.side .me { margin-top: auto; padding: 10px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12.5px; }
.main { padding: 22px 28px 60px; min-width: 0; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.head .sub { color: var(--muted); margin-top: 2px; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.grid > .card + .card { margin-top: 0; }
.head select { width: auto; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .split, .g2, .g3 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .head > * { max-width: 100%; }
  .fields[style] { grid-template-columns: minmax(0, 1fr) !important; }
  .side { position: static; height: auto; padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { padding: 4px 6px 6px; } .brand small { display: none; }
  .nav { display: flex; gap: 2px; overflow-x: auto; }
  .nav a { flex: none; gap: 6px; }
  .side .me { display: none; }
  .main { padding: 16px; }
}

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--panel); color: var(--text); padding: 6px 12px; border-radius: 6px; font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.sm { padding: 3px 8px; font-size: 12.5px; }
.btn.link { border: 0; background: none; color: var(--accent); padding: 0; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; margin: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.stack > * + * { margin-top: 10px; }

label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 3px; font-weight: 550; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=url], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 6px 9px;
}
textarea { resize: vertical; min-height: 70px; }
textarea.tall { min-height: 260px; font-family: inherit; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.field { margin-bottom: 10px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px 10px; }
input[type=checkbox] { accent-color: var(--accent); }
.check { display: flex; gap: 6px; align-items: center; color: var(--text); font-weight: 500; font-size: 13.5px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 7px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11.5px; font-weight: 600; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.badge.A { background: var(--accent-soft); color: var(--trackA); }
.badge.B { background: color-mix(in srgb, var(--trackB) 16%, transparent); color: var(--trackB); }
.badge.ok, .badge.green, .badge.sent, .badge.active, .badge.won { background: var(--ok-soft); color: var(--ok); }
.badge.warn, .badge.amber, .badge.draft, .badge.paused, .badge.approved { background: var(--warn-soft); color: var(--warn); }
.badge.bad, .badge.red, .badge.failed, .badge.lost, .badge.stopped { background: var(--bad-soft); color: var(--bad); }
.badge.received, .badge.replied { background: var(--accent-soft); color: var(--accent); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.overdue { color: var(--bad); font-weight: 600; }
.today { color: var(--warn); font-weight: 600; }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }
.quote { border-left: 3px solid var(--border); padding: 2px 0 2px 10px; color: var(--text); margin: 4px 0; font-size: 13px; }
.pill-nav { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.pill-nav a { padding: 7px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 550; }
.pill-nav a.on { color: var(--text); border-color: var(--accent); }
.pill-nav a:hover { text-decoration: none; color: var(--text); }
.pill-nav .n { color: var(--faint); font-weight: 500; margin-left: 3px; }

.flash { padding: 9px 12px; border-radius: 6px; margin-bottom: 10px; background: var(--ok-soft); color: var(--ok); font-weight: 550; }
.flash.error { background: var(--bad-soft); color: var(--bad); }
.notice { padding: 9px 12px; border-radius: 6px; background: var(--warn-soft); color: var(--warn); margin-bottom: 12px; }
.notice a { color: inherit; text-decoration: underline; }

/* stat strip */
.stages { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.stage-stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; color: var(--text); }
.stage-stat:hover { text-decoration: none; border-color: var(--accent); }
.stage-stat .v { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stage-stat .l { color: var(--muted); font-size: 12px; }

.list-item { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .t { min-width: 0; }
.list-item .t .x { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* kanban */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: 250px; gap: 10px; overflow-x: auto; padding-bottom: 10px; align-items: start; }
.col { background: var(--panel-2); border-radius: var(--radius); padding: 8px; min-height: 200px; }
.col.drop { outline: 2px dashed var(--accent); }
.col-h { display: flex; justify-content: space-between; font-weight: 600; padding: 2px 4px 8px; font-size: 13px; }
.col-h .n { color: var(--muted); font-weight: 500; }
.deal { background: var(--panel); border: 1px solid var(--border); border-radius: 7px; padding: 8px 10px; margin-bottom: 7px; cursor: grab; box-shadow: var(--shadow); }
.deal:active { cursor: grabbing; }
.deal.dragging { opacity: .45; }
.deal .nm { font-weight: 600; display: block; color: var(--text); }
.deal .meta { display: flex; gap: 6px; align-items: center; margin-top: 4px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.deal .ns { font-size: 12px; margin-top: 4px; color: var(--muted); }
.avatar { display: inline-flex; width: 20px; height: 20px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 10px; font-weight: 700; align-items: center; justify-content: center; }

/* timeline */
.tl-item { display: grid; grid-template-columns: 26px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.tl-item:last-child { border-bottom: 0; }
.tl-icon { width: 26px; height: 26px; border-radius: 50%; background: var(--panel-2); display: flex; align-items: center; justify-content: center; font-size: 13px; }
.tl-icon.email_in { background: var(--accent-soft); }
.tl-icon.email_out, .tl-icon.linkedin { background: var(--ok-soft); }
.tl-icon.stage { background: var(--warn-soft); }
.tl-item .when { color: var(--muted); font-size: 12px; }
.tl-item .body { margin-top: 4px; white-space: pre-wrap; word-break: break-word; }
.tl-item .body.clamp { max-height: 7.5em; overflow: hidden; position: relative; }
.tl-item.pinned { background: color-mix(in srgb, var(--warn-soft) 55%, transparent); margin: 0 -10px; padding: 10px; border-radius: 6px; }
details.more > summary { cursor: pointer; color: var(--accent); font-size: 12.5px; list-style: none; margin-top: 2px; }
details.more[open] > summary { display: none; }
.tl-item .clamp:has(+ details.more[open]) { display: none; }
details.more > summary::-webkit-details-marker { display: none; }

.kv { display: grid; grid-template-columns: 130px 1fr; gap: 5px 10px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.bar { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }

.contact { padding: 10px 0; border-bottom: 1px solid var(--border); }
.contact:last-child { border-bottom: 0; }
.contact .nm { font-weight: 600; }
details.edit > summary { cursor: pointer; list-style: none; display: inline; }
details.edit > summary::-webkit-details-marker { display: none; }
details.edit[open] { display: block; background: var(--panel-2); border-radius: 6px; padding: 10px; margin-top: 8px; }

.msg { border: 1px solid var(--border); border-radius: 7px; padding: 10px 12px; margin-bottom: 8px; background: var(--panel); }
.msg.in { border-left: 3px solid var(--accent); }
.msg.out { border-left: 3px solid var(--ok); }
.msg .body { white-space: pre-wrap; margin-top: 6px; word-break: break-word; }

.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
.center { max-width: 400px; margin: 10vh auto; }
.step { border: 1px solid var(--border); border-radius: 7px; padding: 10px; margin-bottom: 8px; background: var(--panel); display: grid; grid-template-columns: 90px 120px 1fr auto; gap: 8px; align-items: start; }
@media (max-width: 760px) { .step { grid-template-columns: 1fr 1fr; } }

/* why-this-company */
.why .lede { font-size: 15px; line-height: 1.5; margin: 6px 0 8px; }
.why .reasons { margin: 0; padding-left: 18px; }
.why .reasons li { margin-bottom: 3px; }
.why-col { background: var(--panel-2); border-radius: var(--radius); padding: 10px 12px; }
.why-row { display: grid; grid-template-columns: 34px 1fr; gap: 6px; padding: 3px 0; align-items: start; font-size: 13px; }
.why-row .pts { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ok); font-size: 12px; text-align: right; }
.why-row .pts.warn { color: var(--warn); }
.why-row.missing { opacity: .65; }
.why-row.missing .pts { color: var(--faint); font-weight: 600; }
.why-row .d { display: block; }

/* Data rights card on the company page: the two things a buyer needs to know first */
.rights-card { border-left: 4px solid var(--border); }
.rights-card.green { border-left-color: var(--ok); }
.rights-card.amber { border-left-color: var(--warn); }
.rights-card.red { border-left-color: var(--bad); }
.rights-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; }
.rights-card details.more { margin-top: 4px; }
form.filters > details > summary { cursor: pointer; margin-top: 8px; }
