:root {
  --bg: #F4F6F4;
  --surface: #FFFFFF;
  --ink: #1C2330;
  --ink-soft: #4A5361;
  --ink-faint: #77808C;
  --line: #DFE4DF;
  --accent: #0E6E63;
  --accent-ink: #FFFFFF;
  --accent-soft: #E1EFEC;
  --warn: #A66A10;
  --warn-soft: #F6ECDA;
  --danger: #B03A3A;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(20, 30, 40, .06), 0 2px 8px rgba(20, 30, 40, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14.5px/1.5 "Public Sans", "Helvetica Neue", Arial, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; }
.login-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 40px 44px; width: 360px; text-align: center;
}
.login-card .mark {
  width: 52px; height: 52px; border-radius: 12px; background: var(--accent);
  color: var(--accent-ink); font-size: 26px; font-weight: 700;
  display: grid; place-items: center; margin: 0 auto 16px;
}
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card p { color: var(--ink-faint); margin: 0 0 24px; font-size: 13.5px; }
.login-card .gbtn { display: flex; justify-content: center; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }
.sidebar {
  background: #17211F; color: #D8E2DE; padding: 20px 12px; display: flex;
  flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px;
  font-weight: 700; font-size: 15px; color: #fff;
}
.sidebar .brand .mark {
  width: 28px; height: 28px; border-radius: 7px; background: var(--accent);
  display: grid; place-items: center; font-size: 15px; color: #fff;
}
.sidebar a.nav {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: 7px; color: #B9C6C1; font-weight: 500;
}
.sidebar a.nav:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.sidebar a.nav.active { background: var(--accent); color: #fff; }
.sidebar .spacer { flex: 1; }
.sidebar .user { padding: 10px 12px; font-size: 12.5px; color: #8FA09A; border-top: 1px solid rgba(255,255,255,.09); }
.sidebar .user b { color: #D8E2DE; display: block; }
.sidebar .user button {
  margin-top: 6px; background: none; border: 1px solid rgba(255,255,255,.2);
  color: #B9C6C1; border-radius: 6px; padding: 3px 10px; font-size: 12px; cursor: pointer;
}

.main { padding: 26px 30px 60px; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 21px; margin: 0; }
.page-head .grow { flex: 1; }

/* ---------- Controls ---------- */
.btn {
  background: var(--accent); color: var(--accent-ink); border: none;
  border-radius: 7px; padding: 8px 14px; font-weight: 600; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost {
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
}
.btn.small { padding: 4px 10px; font-size: 13px; }
input[type=text], input[type=search], input[type=date], input[type=email], input[type=number], select, textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 7px;
  padding: 8px 11px; outline: none; min-width: 0;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 4px 12px; font-size: 13px; cursor: pointer; color: var(--ink-soft);
}
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* ---------- Cards & tables ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card .card-head {
  padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 600;
  display: flex; align-items: center; gap: 10px;
}
.card .card-head .grow { flex: 1; }
.card .card-body { padding: 16px; }

table.data { width: 100%; border-collapse: collapse; }
table.data th {
  text-align: left; font-size: 11.5px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 600; padding: 10px 14px; border-bottom: 2px solid var(--line);
  font-family: "IBM Plex Mono", monospace;
}
table.data td { padding: 10px 14px; border-bottom: 1px solid var(--line); }
table.data tr:last-child td { border-bottom: none; }
table.data tr.click { cursor: pointer; }
table.data tr.click:hover td { background: var(--accent-soft); }

.pill {
  display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 9px;
  border-radius: 999px; white-space: nowrap; text-transform: capitalize;
}
.pill.prospect { background: #EEF0EE; color: var(--ink-soft); }
.pill.registered { background: #E3ECF8; color: #2B5AA6; }
.pill.active { background: var(--accent-soft); color: var(--accent); }
.pill.inactive { background: var(--warn-soft); color: var(--warn); }
.pill.dormant { background: #EFE7F5; color: #6A4B8C; }
.pill.cancelled { background: #F6E3E3; color: var(--danger); }
.pill.seg { background: #EEF0EE; color: var(--ink-soft); text-transform: none; }

/* ---------- Dashboard ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .n { font-family: "IBM Plex Mono", monospace; font-size: 26px; font-weight: 500; }
.stat .l { color: var(--ink-faint); font-size: 12.5px; margin-top: 2px; }
.grid-2 { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }
.pipe-group { margin-bottom: 16px; }
.pipe-group:last-child { margin-bottom: 0; }
.pipe-title {
  font-family: "IBM Plex Mono", monospace; font-size: 11.5px; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-faint); font-weight: 600;
  padding-bottom: 4px; border-bottom: 1px solid var(--line); margin-bottom: 6px;
}
.bar-row { display: grid; grid-template-columns: 170px 1fr 34px; align-items: center; gap: 10px; padding: 5px 0; font-size: 13px; }
.bar-row .track { display: block; background: var(--bg); border-radius: 4px; height: 14px; overflow: hidden; }
.bar-row .fill { display: block; height: 100%; border-radius: 4px; }
.bar-row .val { font-family: "IBM Plex Mono", monospace; text-align: right; }

/* ---------- Pipeline board ---------- */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 20px; align-items: flex-start; }
.col { min-width: 240px; width: 240px; flex: none; }
.col-head {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; font-weight: 600; font-size: 13px;
}
.col-head .dot { width: 9px; height: 9px; border-radius: 50%; }
.col-head .count { color: var(--ink-faint); font-family: "IBM Plex Mono", monospace; font-size: 12px; margin-left: auto; }
.col-body {
  background: #EBEEEB; border-radius: var(--radius); padding: 8px; min-height: 60px;
  display: flex; flex-direction: column; gap: 8px;
}
.col-body.dragover { outline: 2px dashed var(--accent); outline-offset: -2px; }
.deal-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 7px;
  padding: 10px 12px; box-shadow: var(--shadow); cursor: grab;
}
.deal-card:active { cursor: grabbing; }
.deal-card .t { font-weight: 600; font-size: 13.5px; margin-bottom: 3px; }
.deal-card .m { color: var(--ink-faint); font-size: 12.5px; }
.deal-card .foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.next-step {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
  font-size: 12px; padding: 5px 8px; border-radius: 6px;
  background: var(--bg); border-left: 3px solid var(--line);
}
.next-step .ns-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.next-step .ns-due { font-family: "IBM Plex Mono", monospace; font-size: 11px; white-space: nowrap; color: var(--ink-faint); }
.next-step.ok { border-left-color: var(--accent); }
.next-step.today { border-left-color: var(--warn); background: var(--warn-soft); }
.next-step.today .ns-due { color: var(--warn); font-weight: 600; }
.next-step.overdue { border-left-color: var(--danger); background: #F8ECEC; }
.next-step.overdue .ns-due { color: var(--danger); font-weight: 600; }
.next-step.none { border-left-color: var(--danger); color: var(--danger); font-weight: 600; background: #F8ECEC; }

/* ---------- Detail pages ---------- */
.detail-grid { display: grid; grid-template-columns: 2fr 3fr; gap: 16px; align-items: start; }
@media (max-width: 980px) { .detail-grid { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 13.5px; }
.kv dt { color: var(--ink-faint); }
.kv dd { margin: 0; }
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item { display: grid; grid-template-columns: 22px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.tl-item:last-child { border-bottom: none; }
.tl-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); margin-top: 5px; justify-self: center; }
.tl-item.kind-system .tl-dot { background: var(--ink-faint); }
.tl-item .meta { color: var(--ink-faint); font-size: 12px; }
.composer { display: flex; gap: 8px; margin-bottom: 14px; }
.composer textarea { flex: 1; resize: vertical; min-height: 42px; }
.tag-badge { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; display: inline-block; margin: 0 4px 4px 0; }

/* ---------- Tasks ---------- */
.task-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.task-row:last-child { border-bottom: none; }
.task-row.overdue .due { color: var(--danger); font-weight: 600; }
.task-row .due { font-family: "IBM Plex Mono", monospace; font-size: 12.5px; color: var(--ink-faint); margin-left: auto; white-space: nowrap; }
.task-row input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }

/* ---------- Modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(15, 22, 20, .45);
  display: grid; place-items: center; z-index: 40;
}
.modal {
  background: var(--surface); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.25);
  width: min(480px, calc(100vw - 32px)); max-height: 88vh; overflow: auto;
}
.modal h2 { font-size: 17px; margin: 0; padding: 18px 22px 0; }
.modal form { padding: 14px 22px 22px; display: flex; flex-direction: column; gap: 12px; }
.modal label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.modal .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.empty { color: var(--ink-faint); padding: 22px; text-align: center; }
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; border-radius: 8px; padding: 10px 18px;
  box-shadow: var(--shadow); z-index: 60; font-weight: 500;
}
/* ---------- Assistant ---------- */
.assist-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 30;
  background: var(--ink); color: #fff; border: none; border-radius: 999px;
  padding: 11px 18px; font-weight: 600; cursor: pointer;
  box-shadow: 0 4px 16px rgba(15,22,20,.25); display: flex; align-items: center; gap: 8px;
}
.assist-fab .spark { color: #7FD8C8; font-size: 15px; }
.assist-panel {
  position: fixed; right: 22px; bottom: 78px; z-index: 31;
  width: min(400px, calc(100vw - 32px)); height: min(560px, calc(100vh - 120px));
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 16px 48px rgba(15,22,20,.28);
  display: flex; flex-direction: column; overflow: hidden;
}
.assist-head {
  padding: 13px 16px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px; font-weight: 700;
}
.assist-head .spark { color: var(--accent); }
.assist-head .sub { font-weight: 400; font-size: 12px; color: var(--ink-faint); margin-left: auto; }
.assist-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.amsg { max-width: 88%; padding: 9px 13px; border-radius: 12px; font-size: 13.5px; white-space: pre-wrap; }
.amsg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.amsg.bot { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.amsg.thinking { color: var(--ink-faint); font-style: italic; }
.achips { display: flex; flex-wrap: wrap; gap: 6px; align-self: flex-start; }
.achip {
  background: var(--accent-soft); color: var(--accent); font-size: 11.5px; font-weight: 600;
  border-radius: 999px; padding: 3px 10px;
}
.assist-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.assist-input input { flex: 1; }
.assist-hint { padding: 0 16px 10px; font-size: 11.5px; color: var(--ink-faint); }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; overflow-x: auto; align-items: center; }
  .sidebar .brand { padding: 4px 10px; }
  .sidebar .spacer, .sidebar .user { display: none; }
}

/* ---------- Email section ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-family: "IBM Plex Mono", monospace; font-size: 11px;
  text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint);
  padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: none; }
.tbl .meta { color: var(--ink-faint); font-size: 12px; margin-top: 2px; }
.rowlink { cursor: pointer; }
.rowlink:hover td { background: var(--bg); }
.rowactions { white-space: nowrap; text-align: right; }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.hint { color: var(--ink-faint); font-size: 12.5px; margin: 6px 0 2px; line-height: 1.5; }
.pill.status-draft { background: #EEF0EE; color: var(--ink-soft); }
.pill.status-scheduled { background: #E3ECF8; color: #2B5AA6; }
.pill.status-sending { background: var(--warn-soft); color: var(--warn); }
.pill.status-sent, .pill.status-active, .pill.status-completed { background: var(--accent-soft); color: var(--accent); }
.pill.status-queued { background: #E3ECF8; color: #2B5AA6; }
.pill.status-failed, .pill.status-bounced { background: #F6E3E3; color: var(--danger); }
.pill.status-stopped, .pill.status-paused { background: var(--warn-soft); color: var(--warn); }
.steprow { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 10px 0; }
.steprow legend { font-family: "IBM Plex Mono", monospace; font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--ink-faint); padding: 0 6px; }
.stephead { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.stephead .delay input[type=number] { width: 64px; }
.audbox { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-top: 12px; }
.chips.wrap { flex-wrap: wrap; margin-top: 4px; }
.seqstep { padding: 10px 0; border-bottom: 1px solid var(--line); }
.seqstep:last-child { border-bottom: none; }
