:root {
  --brand: #0f766e; --brand-dark: #115e59; --accent: #f97316;
  --ink: #0f172a; --muted: #64748b; --line: #e2e8f0; --bg: #f1f5f9; --card: #fff;
  --ok: #16a34a; --warn: #d97706; --bad: #dc2626; --info: #2563eb;
  --radius: 12px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; }

/* header */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px; background: var(--brand); color: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.brand { font-weight: 800; font-size: 17px; letter-spacing: -.01em; }
.logo { color: var(--accent); }
.top nav { display: flex; gap: 10px; align-items: center; }
.top nav a { color: #fff; text-decoration: none; opacity: .9; }
.top .ghost { background: rgba(255,255,255,.14); color: #fff; border: 0; }

main { max-width: 1400px; margin: 0 auto; padding: 16px 16px 60px; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi b { display: block; font-size: 24px; line-height: 1.1; }
.kpi span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.kpi.hl b { color: var(--brand); }

/* pipeline */
.pipeline { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 14px; }
.pipe-main { display: flex; gap: 0; overflow-x: auto; }
.stage { flex: 1 1 0; min-width: 96px; border: 0; background: #f8fafc; padding: 10px 8px 10px 18px; cursor: pointer; text-align: left; position: relative;
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%, 12px 50%); margin-right: -6px; }
.stage:first-child { clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%); padding-left: 12px; border-radius: 8px 0 0 8px; }
.stage b { display: block; font-size: 18px; }
.stage span { font-size: 12px; color: var(--muted); white-space: nowrap; }
.stage:hover { background: #ecfdf5; }
.stage[aria-pressed="true"] { background: var(--brand); color: #fff; }
.stage[aria-pressed="true"] span { color: #d1fae5; }
.pipe-side { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.side { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 4px 12px; cursor: pointer; color: var(--muted); }
.side[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.filters input[type="search"] { flex: 1 1 240px; }
.filters input[type="search"], .filters select { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; }
.chk { display: inline-flex; gap: 6px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; cursor: pointer; }
.ghost { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 8px; padding: 7px 12px; cursor: pointer; }
.count { color: var(--muted); margin: 6px 2px 10px; }

/* list */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
.table { min-width: 980px; }
.table td:nth-child(3) { min-width: 220px; }
.table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: #f8fafc; padding: 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr.row { cursor: pointer; }
.table tr.row:hover td { background: #f0fdfa; }
.table tr.archived td { opacity: .55; }
.name { font-weight: 700; }
.sub { color: var(--muted); font-size: 12.5px; }
.tier { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; color: #fff; font-weight: 800; }
.tA { background: #16a34a; } .tB { background: #2563eb; } .tC { background: #d97706; } .tD { background: #94a3b8; } .tX { background: #475569; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #f1f5f9; color: #334155; white-space: nowrap; }
.p-bad { background: #fee2e2; color: #991b1b; } .p-warn { background: #ffedd5; color: #9a3412; } .p-ok { background: #dcfce7; color: #166534; }
.p-info { background: #dbeafe; color: #1e40af; } .p-brand { background: #ccfbf1; color: #115e59; } .p-dark { background: #e2e8f0; color: #0f172a; }
.star { border: 0; background: none; cursor: pointer; font-size: 18px; color: #cbd5e1; padding: 0 4px; line-height: 1; }
.star.on { color: #f59e0b; }
.links a { margin-right: 8px; font-size: 13px; white-space: nowrap; }
.empty { background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); padding: 40px; text-align: center; color: var(--muted); }

/* cards (phones) */
.cards { display: none; gap: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: start; cursor: pointer; }
.card .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }

/* drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.35); z-index: 30; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: #fff; z-index: 31; transform: translateX(100%);
  transition: transform .2s ease; overflow-y: auto; box-shadow: -10px 0 30px rgba(0,0,0,.12); }
.drawer.open { transform: none; }
.d-head { position: sticky; top: 0; background: #fff; border-bottom: 1px solid var(--line); padding: 14px 16px; display: flex; gap: 10px; align-items: flex-start; z-index: 1; }
.d-head h2 { margin: 0; font-size: 18px; line-height: 1.25; }
.d-close { margin-left: auto; border: 0; background: #f1f5f9; border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-size: 18px; }
.d-body { padding: 14px 16px 40px; display: grid; gap: 14px; }
.box { border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.box h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.row-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.btn { border: 0; border-radius: 8px; padding: 7px 11px; cursor: pointer; font-weight: 600; background: #e2e8f0; color: var(--ink); }
.btn.primary { background: var(--brand); color: #fff; } .btn.accent { background: var(--accent); color: #fff; } .btn.danger { background: #fee2e2; color: #991b1b; }
.btn.win { background: #16a34a; color: #fff; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 10px; font-size: 13.5px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.finding { padding: 6px 0; border-bottom: 1px dashed var(--line); } .finding:last-child { border-bottom: 0; }
.steps { display: flex; gap: 6px; flex-wrap: wrap; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 13px; display: grid; grid-template-columns: 96px 1fr auto; gap: 8px; }
.timeline .when { color: var(--muted); font-size: 12px; }
.timeline .note { background: #fffbeb; border-radius: 6px; padding: 4px 8px; white-space: pre-wrap; }
.timeline .del { border: 0; background: none; color: var(--muted); cursor: pointer; }
textarea { width: 100%; min-height: 70px; border: 1px solid var(--line); border-radius: 8px; padding: 8px; resize: vertical; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tags input { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; width: 160px; }
.tag { background: #e0f2fe; color: #075985; border-radius: 99px; padding: 2px 4px 2px 10px; font-size: 12px; display: inline-flex; align-items: center; gap: 2px; }
.tag button { border: 0; background: none; cursor: pointer; color: #075985; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px;
  display: none; z-index: 50; max-width: 90vw; }
.toast.err { background: var(--bad); }

@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 760px) {
  main { padding: 12px 12px 60px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .table { display: none; }
  .cards { display: grid; }
  .filters select, .filters .chk { flex: 1 1 45%; }
  .top { padding: 10px 14px; }
}
