:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #16181d;
  --muted: #6b7280;
  --line: #e5e7eb;
  --side: #111827;
  --side-ink: #cbd5e1;
  --accent: #2563eb;
  --accent-soft: #eff4ff;
  --ok: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 20px 12px; position: sticky; top: 0; height: 100vh; }
.brand { color: #fff; font-weight: 700; font-size: 16px; padding: 0 10px 18px; letter-spacing: .2px; }
.brand span { color: #60a5fa; }
.side a { display: block; color: var(--side-ink); padding: 8px 10px; border-radius: 8px; margin-bottom: 2px; }
.side a:hover { background: #1f2937; text-decoration: none; }
.side a.on { background: #1e3a8a; color: #fff; }
.side .foot { position: absolute; bottom: 16px; left: 22px; font-size: 12px; color: #64748b; }

main { padding: 28px 36px; max-width: 1280px; }
h1 { font-size: 22px; margin: 0 0 4px; }
.sub { color: var(--muted); margin: 0 0 22px; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.card h2 { font-size: 15px; margin: 0 0 12px; }
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g2 { grid-template-columns: repeat(2, 1fr); }
.stat .n { font-size: 26px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.dim, .dim { color: var(--muted); }

input[type=text], input[type=email], input[type=url], input[type=number], input[type=password], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }
label { display: block; font-size: 12px; color: var(--muted); margin: 0 0 4px; font-weight: 600; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > * { flex: 0 0 auto; }
.row input[type=text], .row select { width: auto; min-width: 180px; }

.btn { display: inline-block; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { background: #f9fafb; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1d4ed8; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: 12px; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: #f3f4f6; color: #374151; }
.pill.new { background: #f3f4f6; }
.pill.contacted { background: #eff6ff; color: #1d4ed8; }
.pill.replied { background: #fef3c7; color: #92400e; }
.pill.meeting { background: #ede9fe; color: #6d28d9; }
.pill.won { background: #dcfce7; color: #166534; }
.pill.lost { background: #fee2e2; color: #991b1b; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs a { padding: 5px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--ink); font-size: 13px; }
.tabs a.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.tabs a:hover { text-decoration: none; }

.notice { background: var(--accent-soft); border: 1px solid #c7d7fe; color: #1e3a8a; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.empty { text-align: center; color: var(--muted); padding: 36px 10px; }
details > summary { cursor: pointer; font-weight: 600; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
  .side .foot { display: none; }
  .brand { padding: 0 10px; }
  main { padding: 18px 16px; }
  .g4, .g2 { grid-template-columns: 1fr 1fr; }
  table { display: block; overflow-x: auto; }
}

.meter { position: relative; font-size: 12px; display: flex; justify-content: space-between; gap: 10px; padding: 2px 0 6px; min-width: 190px; }
.meter::after { content: ""; position: absolute; left: 0; right: 0; bottom: 2px; height: 3px; background: #eef0f3; border-radius: 3px; }
.meter i { position: absolute; left: 0; bottom: 2px; height: 3px; background: var(--accent); border-radius: 3px; z-index: 1; max-width: 100%; }
.meter span { color: var(--muted); }
.meter.big { font-size: 14px; padding: 6px 0 12px; }
.meter.big::after, .meter.big i { height: 6px; }
.ramp { display: flex; align-items: flex-end; gap: 3px; height: 90px; padding: 6px 0; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.ramp .bar { flex: 1; background: #c7d7fe; border-radius: 3px 3px 0 0; min-height: 2px; }
.ramp .bar.today { background: var(--accent); }
h3 { color: var(--ink); }

/* sequences */
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.title-input { font-size: 20px !important; font-weight: 700 !important; border-color: transparent !important; background: transparent !important; padding: 4px 6px !important; min-width: 320px !important; }
.title-input:hover, .title-input:focus { border-color: var(--line) !important; background: #fff !important; }
.notice.bad { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.notice.warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.bad-text { color: var(--bad); }
.checks { padding: 12px 16px; }
.check { padding: 3px 0; font-size: 13px; }
.check.error { color: #991b1b; }
.check.warn { color: #92400e; }
.flow { max-width: 760px; }
.flow-start { text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); background: #fff; border: 1px dashed var(--line); border-radius: 999px; padding: 6px; }
.flow-wait { text-align: center; font-size: 12px; color: var(--muted); padding: 6px 0; position: relative; }
.step { margin-bottom: 0; border-left: 4px solid #c7d7fe; }
.step.email { border-left-color: #c4b5fd; }
.step-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.chan { display: inline-block; width: 22px; height: 22px; line-height: 22px; text-align: center; border-radius: 5px; background: #0a66c2; color: #fff; font-size: 11px; font-weight: 700; }
.step.email .chan { background: #7c3aed; }
.hint { font-size: 12px; margin: 4px 0 10px; }
.counter { font-size: 11px; text-align: right; margin-top: 2px; }
.step-foot { border-top: 1px solid var(--line); padding-top: 10px; gap: 14px; }
label.inline { display: flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; color: var(--ink); font-size: 13px; }
label.inline input[type=number] { padding: 5px 8px; }
label.inline select { padding: 5px 8px; }
.add-step { margin: 0; border-style: dashed; }
.choice { display: block; font-weight: 400; color: var(--ink); font-size: 13px; padding: 8px 0; }
.bubble { white-space: pre-wrap; background: #f3f6fb; border-radius: 10px; padding: 12px 14px; margin-top: 8px; }
.bubble.email { background: #fff; border: 1px solid var(--line); }
.mail-head { font-size: 13px; margin-top: 8px; line-height: 1.8; }
.mail-head .dim { display: inline-block; width: 60px; }
code { background: #f3f4f6; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.vars { max-width: 760px; margin-top: 18px; }

/* tasks */
.badge { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 999px; background: #ef4444; color: #fff; font-size: 11px; font-weight: 700; text-align: center; float: right; margin-top: 2px; }
.task { border-left: 4px solid #0a66c2; }
.task.approval { border-left-color: #f59e0b; }

/* inbox */
.thread-row { display: grid; grid-template-columns: 200px 1fr auto; gap: 14px; padding: 12px 18px; border-bottom: 1px solid var(--line); color: var(--ink); align-items: center; }
.thread-row:last-child { border-bottom: 0; }
.thread-row:hover { background: #f9fafb; text-decoration: none; }
.thread-row .who { display: flex; flex-direction: column; }
.thread-row .what { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.thread-row .meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.chan-mini { display: inline-block; width: 16px; height: 16px; line-height: 16px; text-align: center; border-radius: 4px; font-size: 9px; font-weight: 700; color: #fff; background: #0a66c2; vertical-align: 1px; }
.chan-mini.em { background: #7c3aed; }
.msg { max-width: 80%; margin-bottom: 14px; }
.msg.out { margin-left: auto; }
.msg-meta { font-size: 12px; margin-bottom: 4px; }
.msg-subject { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.msg-body { white-space: pre-wrap; padding: 10px 14px; border-radius: 12px; background: #f3f4f6; }
.msg.out .msg-body { background: #e8efff; }

/* dashboard */
.todo { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; padding: 12px 18px; background: #fffbeb; border-color: #fde68a; }
.chart { display: flex; align-items: flex-end; gap: 3px; height: 160px; border-bottom: 1px solid var(--line); padding-top: 8px; }
.chart .col { flex: 1; height: 100%; position: relative; display: flex; align-items: flex-end; }
.chart .col:hover { background: #f5f7fb; }
.chart .stack { width: 100%; display: flex; flex-direction: column; min-height: 0; border-radius: 3px 3px 0 0; overflow: hidden; }
.chart .stack i { display: block; min-height: 0; }
.chart i.li, .legend i.li { background: #0a66c2; }
.chart i.em, .legend i.em { background: #a78bfa; }
.chart .dot { position: absolute; left: 50%; width: 8px; height: 8px; margin: 0 0 -4px -4px; border-radius: 50%; background: #f59e0b; border: 2px solid #fff; box-sizing: content-box; }
.legend { font-size: 12px; margin-top: 8px; gap: 14px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: -1px; }
.legend i.dot-l { background: #f59e0b; border-radius: 50%; }
.hbar { background: #eef0f3; border-radius: 4px; height: 8px; overflow: hidden; }
.hbar i { display: block; height: 100%; background: var(--accent); }
@media (max-width: 860px) { .thread-row { grid-template-columns: 1fr; } .msg { max-width: 100%; } }

/* sequence editor: actions sidebar + flow */
.editor { display: grid; grid-template-columns: 220px minmax(0, 760px); gap: 18px; align-items: start; }
.actions-panel { position: sticky; top: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.panel-title { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; margin-bottom: 10px; }
.group-label { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: #0a66c2; font-weight: 700; margin: 12px 0 6px; }
.group-label:first-of-type { margin-top: 0; }
.action-btn { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; font: inherit; font-size: 13px; color: var(--ink); cursor: pointer; }
.action-btn:hover { background: #eef4ff; border-color: #c7d7fe; }
.action-btn .chan { background: #0a66c2; }
.action-btn.email .chan { background: #7c3aed; }
@media (max-width: 900px) { .editor { grid-template-columns: 1fr; } .actions-panel { position: static; } .card.vars { margin-left: 0 !important; } }
