/* 2066 Sales — design tokens + product UI.
   Light CRM surface (Attio/Pipedrive school), 2066 orange accent. */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --ink: #171923;
  --muted: #6b7280;
  --faint: #9aa1ac;
  --line: #e5e7eb;
  --line-soft: #eef0f3;
  --accent: #ea580c;
  --accent-ink: #ffffff;
  --accent-soft: #fff1e7;
  --ok: #16a34a;   --ok-soft: #e8f7ee;
  --err: #dc2626;  --err-soft: #fdecec;
  --blue: #2563eb; --blue-soft: #e8effd;
  --violet: #7c3aed; --violet-soft: #f1eafd;
  --gold: #b45309; --gold-soft: #fdf3e0;
  --shadow: 0 1px 2px rgba(23,25,35,.05), 0 4px 16px rgba(23,25,35,.06);
  --shadow-lg: 0 8px 40px rgba(23,25,35,.18);
  --r: 12px; --r-sm: 8px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
code {
  background: var(--line-soft); border-radius: 4px;
  padding: 1px 5px; font-size: 12px;
}
h1, h2, h3 { margin: 0; font-weight: 600; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); border-radius: var(--r-sm);
  padding: 8px 14px; font: 600 13px var(--font); cursor: pointer;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.btn:hover { border-color: var(--faint); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #c2410c; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); background: var(--line-soft); }
.btn.block { width: 100%; justify-content: center; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn[disabled] { opacity: .55; cursor: default; }

/* ---------- auth ---------- */
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center;
  padding: 24px; position: relative; overflow: hidden;
}
.auth-ambient {
  position: absolute; inset: 0;
  background:
    radial-gradient(600px 300px at 15% 0%, #ffe8d9 0%, transparent 60%),
    radial-gradient(700px 380px at 90% 100%, #e8effd 0%, transparent 60%),
    var(--bg);
}
.auth-card {
  position: relative; width: min(420px, 100%);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow-lg);
  padding: 32px;
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.brand.sm { margin: 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, #ea580c, #f59e0b);
  color: #fff; font-weight: 800; font-size: 17px;
  display: grid; place-items: center; flex: none;
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: .2px; }
.brand-sub { color: var(--muted); font-size: 12px; }
.auth-card h1 { font-size: 20px; margin-bottom: 6px; }
.auth-lead { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.auth-card label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--ink); margin: 14px 0 5px;
}
.auth-foot { margin-top: 18px; color: var(--muted); font-size: 12.5px; }
.auth-foot a { color: var(--accent); font-weight: 600; text-decoration: none; }

input, select {
  width: 100%; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 9px 11px; font: 400 13.5px var(--font); color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-msg { min-height: 18px; margin-top: 10px; font-size: 12.5px; color: var(--err); }
.form-msg.ok { color: var(--ok); }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 10px 22px;
}
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.who { color: var(--muted); font-size: 12.5px; }
.pill {
  font-size: 11.5px; font-weight: 600; border-radius: 999px;
  padding: 3px 10px;
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }

/* ---------- page + cards ---------- */
.page { max-width: 1180px; margin: 0 auto; padding: 22px 22px 60px; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow);
  padding: 16px 18px; margin-bottom: 18px;
}
.card-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
}
.card-head h2 { font-size: 14px; }
.card-head .hint, .hint { margin-left: auto; color: var(--faint); font-size: 11.5px; }
.card .hint { margin: 10px 0 0; }
.head-actions { margin-left: auto; display: flex; gap: 8px; }

.kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px; margin-bottom: 18px;
}
.kpi {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow); padding: 14px 16px;
}
.kpi .k-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.kpi .k-value { font-size: 26px; font-weight: 700; margin-top: 2px; }
.kpi .k-note { color: var(--faint); font-size: 11.5px; }
.kpi.accent .k-value { color: var(--accent); }

.grid-2 {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px;
}
.grid-2 .card { margin-bottom: 0; }
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* ---------- funnel ---------- */
.funnel-bar {
  display: flex; height: 30px; border-radius: 8px; overflow: hidden;
  background: var(--line-soft); margin-bottom: 10px;
}
.funnel-bar .seg {
  display: grid; place-items: center; color: #fff;
  font-size: 11.5px; font-weight: 700; min-width: 0;
  transition: width .3s ease;
}
.funnel-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.funnel-legend .lg {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted);
}
.funnel-legend .dot { width: 9px; height: 9px; border-radius: 3px; }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .6px; color: var(--faint);
  padding: 6px 8px; border-bottom: 1px solid var(--line);
}
.tbl td { padding: 9px 8px; border-bottom: 1px solid var(--line-soft); }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: #fafbfc; }
.cell-main { font-weight: 600; }
.cell-dim { color: var(--muted); font-size: 12.5px; }

.stage {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
}
.st-new      { background: var(--blue-soft);   color: var(--blue); }
.st-qualified{ background: var(--gold-soft);   color: var(--gold); }
.st-proposal { background: var(--violet-soft); color: var(--violet); }
.st-won      { background: var(--ok-soft);     color: var(--ok); }
.st-lost     { background: var(--err-soft);    color: var(--err); }
.st-open     { background: var(--blue-soft);   color: var(--blue); }
.st-done     { background: var(--ok-soft);     color: var(--ok); }

.score-badge {
  display: inline-block; min-width: 34px; text-align: center;
  background: var(--accent-soft); color: var(--accent);
  font-weight: 700; font-size: 12.5px;
  border-radius: 7px; padding: 2px 8px;
}

/* ---------- empty states ---------- */
.empty { display: none; padding: 26px 10px; text-align: center; }
.empty.show { display: block; }
.empty-icon { font-size: 22px; color: var(--faint); margin-bottom: 6px; }
.empty b { display: block; font-size: 13.5px; margin-bottom: 4px; }
.empty span { color: var(--muted); font-size: 12.5px; max-width: 380px; display: inline-block; }

/* ---------- timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  display: flex; gap: 10px; padding: 8px 2px;
  border-bottom: 1px solid var(--line-soft); font-size: 13px;
}
.timeline li:last-child { border-bottom: none; }
.timeline .t-type {
  flex: none; font-weight: 700; font-size: 11.5px; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft);
  border-radius: 6px; padding: 2px 8px; height: fit-content;
}
.timeline .t-notes { color: var(--ink); }

/* ---------- modals ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(23,25,35,.45);
  display: grid; place-items: center; padding: 20px;
}
.modal {
  width: min(460px, 100%); background: var(--surface);
  border-radius: 14px; box-shadow: var(--shadow-lg);
  padding: 20px 22px; max-height: 90vh; overflow-y: auto;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.modal-head h3 { font-size: 16px; }
.modal label {
  display: block; font-size: 12.5px; font-weight: 600; margin: 12px 0 5px;
}
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px;
}

/* ---------- toasts ---------- */
.toasts {
  position: fixed; right: 18px; bottom: 18px; z-index: 80;
  display: grid; gap: 8px; max-width: 360px;
}
.toast {
  background: var(--ink); color: #fff; border-radius: 10px;
  padding: 10px 14px; font-size: 13px; box-shadow: var(--shadow-lg);
  animation: rise .18s ease;
}
.toast.err { background: var(--err); }
.toast.ok { background: #0f5c2e; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 640px) {
  .topbar { padding: 10px 14px; }
  .page { padding: 14px 12px 50px; }
}

/* ---------- navbar ---------- */
.nav { display: flex; gap: 4px; margin-left: 10px; }
.nav-link {
  color: var(--muted); text-decoration: none; font-weight: 600;
  font-size: 13px; padding: 6px 12px; border-radius: 8px;
}
.nav-link:hover { color: var(--ink); background: var(--line-soft); }
.nav-link.active { color: var(--accent); background: var(--accent-soft); }
.svc {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 12px 2px; border-bottom: 1px solid var(--line-soft);
}
.svc:last-child { border-bottom: none; }
.svc-name { font-weight: 600; font-size: 13.5px; }
.cron { margin-top: 4px; }
