:root {
  --ink: #15202b;
  --paper: #e4eaee;
  --surface: #f7f9fb;
  --card: #ffffff;
  --rule: #c4cfd8;
  --stamp: #c45c26;
  --stamp-soft: #f6e8dc;
  --harbor: #1a5f7a;
  --harbor-soft: #e3eef2;
  --muted: #5b6874;
  --ok: #2a7a4b;
  --ok-soft: #e5f3ea;
  --danger: #9b2c2c;
  --danger-soft: #f8e8e8;
  --display: "Fraunces", "Songti SC", "Source Han Serif SC", serif;
  --sans: "IBM Plex Sans", "PingFang SC", "Noto Sans SC", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(21, 32, 43, .035), transparent 220px),
    var(--paper);
  color: var(--ink);
  font: 14.5px/1.55 var(--sans);
}

a { color: var(--harbor); text-decoration: none; }
a:hover { color: var(--stamp); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--stamp);
  outline-offset: 2px;
}

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: var(--ink);
  color: #fff;
  padding: 6px 10px;
  z-index: 40;
}
.skip:focus { top: 12px; }

.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 28px;
  height: 58px;
  background: var(--ink);
  color: #e8eef2;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #f4f7f8;
  text-decoration: none;
}
.brand:hover { color: #fff; }
.brand-mark {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--stamp);
  box-shadow: 0 0 0 3px rgba(196, 92, 38, .22);
}
.brand-name {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 680;
  letter-spacing: .01em;
}

.topbar nav { display: flex; gap: 2px; }

.topbar nav a {
  padding: 7px 12px;
  border-radius: 6px;
  color: #b7c2cb;
  font-weight: 500;
}
.topbar nav a:hover { color: #fff; background: rgba(255,255,255,.06); }
.topbar nav a.active {
  color: #fff;
  background: rgba(196, 92, 38, .18);
  box-shadow: inset 0 -2px 0 var(--stamp);
}

.gs { margin-left: auto; position: relative; }

.account {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 4px;
  flex-shrink: 0;
}
.account-name {
  color: #9aa7b2;
  font-size: 13px;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account button {
  height: 30px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid #3a4a57;
  background: transparent;
  font: inherit;
  color: #d7dee4;
  cursor: pointer;
}
.account button:hover { border-color: var(--stamp); color: #fff; }

body.login-page { background: var(--ink); }
body.login-page .topbar { display: none; }
body.login-page .container { margin: 0; max-width: none; padding: 0; min-height: 100vh; }

.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(196, 92, 38, .18), transparent 46%),
    radial-gradient(ellipse at 90% 100%, rgba(26, 95, 122, .28), transparent 42%),
    var(--ink);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid #d8e0e6;
  border-radius: 4px;
  padding: 34px 30px 26px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
}
.login-card .brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.login-card h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 28px;
  font-weight: 680;
  letter-spacing: -.01em;
}
.login-card .sub { color: var(--muted); font-size: 13px; margin: 0 0 26px; }
.login-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.login-field label { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.login-field input {
  height: 40px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--surface);
  padding: 0 12px;
  font: inherit;
  color: var(--ink);
}
.login-field input:focus { outline: none; border-color: var(--stamp); background: #fff; box-shadow: 0 0 0 3px var(--stamp-soft); }
.login-error {
  margin: 0 0 12px;
  padding: 8px 10px;
  border-radius: 4px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
}
.login-submit {
  width: 100%;
  height: 42px;
  border: 0;
  border-radius: 4px;
  background: var(--ink);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.login-submit:hover:not(:disabled) { background: #1e2d3b; }
.login-submit:disabled { opacity: .55; cursor: not-allowed; }
.login-guide {
  margin: 18px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.gs input[type="search"] {
  height: 34px;
  width: 260px;
  border: 1px solid #3a4a57;
  border-radius: 6px;
  background: #1e2c37;
  padding: 0 12px;
  font: inherit;
  color: #f4f7f8;
}
.gs input[type="search"]::placeholder { color: #8b98a3; }
.gs input[type="search"]:focus { outline: none; border-color: var(--stamp); }

.gs-results {
  position: absolute;
  top: 42px;
  right: 0;
  width: 400px;
  max-height: 70vh;
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(21, 32, 43, .18);
  padding: 6px;
  z-index: 30;
  color: var(--ink);
}
.gs-results .gs-group {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 10px 10px 4px;
}
.gs-results a {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--ink);
}
.gs-results a:hover, .gs-results a:focus { background: var(--stamp-soft); text-decoration: none; color: var(--ink); }
.gs-results a .sub {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}
.gs-results .gs-none { padding: 16px 10px; color: var(--muted); text-align: center; }

.container { max-width: 1180px; margin: 28px auto 72px; padding: 0 24px; }

.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 2px 0 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
}
.page-head h1 {
  font-family: var(--display);
  font-size: 30px;
  font-weight: 680;
  margin: 0;
  letter-spacing: -.02em;
}
.page-sub { color: var(--muted); font-size: 13px; }

.card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 16px 18px;
}

.grid { display: grid; gap: 12px; }
.grid.cols-6 { grid-template-columns: repeat(6, 1fr); }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }

.stat {
  position: relative;
  padding: 16px 16px 14px 18px;
  overflow: hidden;
}
.stat::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--stamp);
}
.stat .label {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.stat .num {
  font-family: var(--display);
  font-size: 28px;
  font-weight: 680;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.bar-list { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 36px; align-items: center; gap: 10px; font-size: 13px; }
.bar-row .lbl { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bar { background: var(--paper); border-radius: 99px; height: 7px; overflow: hidden; }
.bar-row .bar > i { display: block; height: 100%; background: var(--stamp); border-radius: 99px; }
.bar-row .val { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12px; }

.card h2 {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 14px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; align-items: center; }
.toolbar input[type="search"], .toolbar select {
  height: 36px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--card);
  padding: 0 10px;
  font: inherit;
  color: var(--ink);
}
.toolbar input[type="search"] { width: 280px; }
.toolbar select { min-width: 130px; }
.toolbar button {
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.toolbar button:hover { background: #1e2d3b; }
.toolbar a { color: var(--muted); margin-left: 4px; }

table.list {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
}
table.list th {
  text-align: left;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 11px 14px;
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
  white-space: nowrap;
}
table.list td { padding: 13px 14px; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.list tr:last-child td { border-bottom: none; }
table.list tbody tr:hover { background: #fbf6f1; }
table.list td.num { font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12px; }

.chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 99px;
  background: var(--paper);
  color: var(--muted);
  font-size: 12px;
  margin: 1px 3px 1px 0;
}
.chip.accent { background: var(--stamp-soft); color: var(--stamp); }
.chip.now { background: var(--ok-soft); color: var(--ok); }

.empty { text-align: center; color: var(--muted); padding: 36px 8px; }
.empty .icon { font-size: 18px; display: block; margin-bottom: 8px; letter-spacing: .2em; }

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}
.pager .btns button {
  height: 32px;
  padding: 0 14px;
  margin-left: 6px;
  border-radius: 6px;
  border: 1px solid var(--rule);
  background: var(--card);
  font: inherit;
  color: var(--ink);
  cursor: pointer;
}
.pager .btns button:disabled { opacity: .4; cursor: default; }
.pager .btns button:hover:not(:disabled) { border-color: var(--stamp); color: var(--stamp); }

.detail-head { display: flex; gap: 18px; align-items: flex-start; }
.detail-head .meta { flex: 1; }
.detail-head h1 {
  font-family: var(--display);
  font-size: 28px;
  font-weight: 680;
  margin: 0 0 6px;
}
.detail-head .sub { color: var(--muted); margin-bottom: 10px; }
.kv { display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: 13px; color: var(--muted); }
.kv b { color: var(--ink); font-weight: 600; }

.section { margin-top: 20px; }
.section > h2 { font-size: 13px; margin: 0 0 10px; letter-spacing: .04em; }

.timeline { display: flex; flex-direction: column; }
.tl-item {
  display: grid;
  grid-template-columns: 118px 1fr;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--rule);
}
.tl-item:last-child { border-bottom: none; }
.tl-item .when {
  color: var(--muted);
  font-size: 12px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.tl-item .what b { font-weight: 600; }
.tl-item .what .dim { color: var(--muted); font-size: 13px; }

.loading { color: var(--muted); text-align: center; padding: 56px 0; letter-spacing: .08em; }
.mono { font-family: var(--mono); font-size: 12px; }
.dim { color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

.toolbar button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--rule);
}
.toolbar button.ghost:hover { background: var(--paper); }
.toolbar button.danger { background: var(--danger); }
.toolbar button.danger:hover { background: #7a1f2b; }

.lead-form { display: grid; gap: 14px; }
.lead-form .row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.lead-form .row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.lead-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: .04em;
}
.lead-form input, .lead-form select, .lead-form textarea {
  height: 36px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--surface);
  padding: 0 10px;
  font: inherit;
  color: var(--ink);
}
.lead-form textarea { height: 90px; padding: 8px 10px; resize: vertical; font-family: var(--sans); }
.lead-form .wide { grid-column: 1 / -1; }
.score-readout {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 0 2px;
}
.score-readout .num { font-family: var(--display); font-size: 32px; font-weight: 680; line-height: 1; }
.score-readout .hint { color: var(--muted); font-size: 12px; }
.form-error { color: var(--danger); font-size: 13px; }
.chip.outreach { background: var(--ok-soft); color: var(--ok); }
.chip.parked { background: var(--stamp-soft); color: var(--stamp); }
.chip.discarded { background: var(--danger-soft); color: var(--danger); }
.chip.customer { background: var(--harbor-soft); color: var(--harbor); }

@media (max-width: 860px) {
  .lead-form .row, .lead-form .row-2 { grid-template-columns: 1fr; }
  .topbar { gap: 12px; padding: 0 14px; height: auto; min-height: 58px; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
  .gs { margin-left: 0; width: 100%; order: 5; }
  .gs input[type="search"] { width: 100%; }
  .gs-results { width: 100%; }
  .grid.cols-6 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
  .toolbar input[type="search"] { width: 100%; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .page-head h1 { font-size: 24px; }
  .tl-item { grid-template-columns: 1fr; gap: 4px; }
}
