:root {
  --bg: #0b1120;
  --panel: #111827;
  --panel-2: #1f2937;
  --line: #2b3648;
  --text: #e5e9f0;
  --muted: #94a3b8;
  --accent: #06b6d4;
  --accent-dim: #0e7490;
  --won: #22c55e;
  --lost: #ef4444;
  --warn: #f59e0b;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.brand { font-weight: 700; font-size: 18px; letter-spacing: -0.3px; }
.brand span { color: var(--accent); }
.brand em { color: var(--muted); font-style: normal; font-weight: 500; font-size: 13px; margin-left: 4px; }

.tabs { display: flex; gap: 6px; }
.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.tab:hover { color: var(--text); }
.tab.active { color: #fff; background: var(--panel-2); border-color: var(--line); }

.toolbar { margin-left: auto; display: flex; align-items: center; gap: 14px; }
#search {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 7px 12px;
  border-radius: 8px;
  width: 220px;
  outline: none;
}
#search:focus { border-color: var(--accent-dim); }
.status { color: var(--muted); font-size: 12px; min-width: 90px; }

.board {
  flex: 1 1 auto;
  display: flex;
  gap: 14px;
  padding: 16px 20px;
  overflow-x: auto;
  align-items: flex-start;
}

.column {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  width: 280px;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  max-height: 100%;
}
.col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.col-head .name { font-weight: 700; font-size: 13px; }
.col-head .count {
  background: var(--panel-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 12px;
  font-weight: 600;
}
.col-head.won .dot { background: var(--won); }
.col-head.lost .dot { background: var(--lost); }
.col-head.at_risk .dot { background: var(--warn); }
.col-head.qualified .dot { background: var(--won); }
.col-head.dormant .dot { background: var(--muted); }
.col-head.dormant .name { color: var(--muted); }
.col-head.qualified { background: rgba(34, 197, 94, 0.06); }
.col-head.qualified .name { color: var(--won); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; margin-right: 8px; }

.cards {
  padding: 10px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 40px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 11px;
  cursor: grab;
}
.card:active { cursor: grabbing; }
.card { position: relative; }
.card-del {
  position: absolute; top: 6px; right: 6px;
  background: transparent; border: 0; color: var(--muted);
  font-size: 16px; line-height: 1; cursor: pointer; padding: 2px 5px;
  border-radius: 5px; opacity: 0; transition: opacity 0.12s;
}
.card:hover .card-del { opacity: 1; }
.card-del:hover { color: #fff; background: var(--lost); }
.card .title { font-weight: 600; font-size: 13px; margin-bottom: 4px; padding-right: 14px; }
.card-time { justify-content: space-between; gap: 8px; color: var(--muted); font-size: 11px; margin-top: 5px; }
.card-time .stale { color: var(--warn); font-weight: 600; }
.fu-tasks { display: flex; gap: 16px; margin-top: 9px; padding-top: 8px; border-top: 1px solid var(--line); }
.fu-label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text); cursor: pointer; font-weight: 600; }
.fu-task { accent-color: var(--accent); cursor: pointer; width: 14px; height: 14px; }
.card .meta { color: var(--muted); font-size: 11.5px; display: flex; flex-wrap: wrap; gap: 6px; }
.card .badge {
  background: rgba(6, 182, 212, 0.12);
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: 6px;
  padding: 0 6px;
  font-size: 10.5px;
  font-weight: 600;
}
.card .badge.ads { background: rgba(34, 197, 94, 0.12); color: var(--won); border-color: #15803d; }
.card .badge.inbound { background: rgba(245, 158, 11, 0.14); color: var(--warn); border-color: #b45309; }
.card .badge.cold { background: rgba(148, 163, 184, 0.12); color: var(--muted); border-color: var(--line); }
.card .badge.reng { background: rgba(34, 197, 94, 0.14); color: var(--won); border-color: #15803d; }
.card .badge.reng-q { background: rgba(6, 182, 212, 0.12); color: var(--accent); border-color: var(--accent-dim); }
.card a { color: var(--accent); text-decoration: none; }
.card a:hover { text-decoration: underline; }
.card.hidden { display: none; }

.sortable-ghost { opacity: 0.4; }
.sortable-chosen { box-shadow: 0 0 0 2px var(--accent-dim); }

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s;
  font-size: 13px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: var(--lost); color: #fecaca; }

/* buttons */
.btn-add {
  background: var(--accent);
  color: #04222a;
  border: 0;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.btn-add:hover { opacity: 0.9; }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.btn-ghost:hover { color: var(--text); }

/* modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 15, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 26px 26px 22px;
  width: 440px;
  max-width: calc(100vw - 32px);
}
.modal h2 { margin: 0 0 4px; font-size: 18px; }
.modal-sub { margin: 0 0 18px; color: var(--muted); font-size: 12.5px; }
.modal label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 12px; font-weight: 600; }
.modal .req { color: var(--lost); }
.modal input, .modal select {
  display: block;
  width: 100%;
  margin-top: 5px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 11px;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
}
.modal input:focus, .modal select:focus { border-color: var(--accent-dim); }
.modal .row { display: flex; gap: 12px; }
.modal .row label { flex: 1; }

/* ---- Clients dashboard ---- */
.board.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  align-content: start;
  overflow-y: auto;
}
.client-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cc-title { font-weight: 700; font-size: 15px; }
.stage-sel {
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--line);
  border-radius: 7px; padding: 3px 6px; font-size: 11px; cursor: pointer; max-width: 110px;
}

.pace-row { display: flex; justify-content: space-between; font-size: 12.5px; }
.pace-pct { font-weight: 700; }
.pace-pct.under { color: var(--accent); }
.pace-pct.on { color: var(--won); }
.pace-pct.over { color: var(--lost); }
.pace-track { position: relative; height: 8px; background: var(--panel-2); border-radius: 99px; overflow: visible; }
.pace-fill { height: 100%; border-radius: 99px; }
.pace-fill.under { background: var(--accent); }
.pace-fill.on { background: var(--won); }
.pace-fill.over { background: var(--lost); }
.pace-marker { position: absolute; top: -2px; width: 2px; height: 12px; background: var(--text); opacity: 0.7; }
.pace-proj { font-size: 11px; color: var(--muted); }
.pace-none { font-size: 12px; color: var(--muted); font-style: italic; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); gap: 8px; }
.tile { background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 7px 8px; text-align: center; }
.tk { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.tv { font-size: 15px; font-weight: 700; margin-top: 2px; }

.goal { font-size: 12.5px; padding: 7px 10px; border-radius: 8px; line-height: 1.4; }
.goal.good { background: rgba(34, 197, 94, 0.1); border: 1px solid #15803d; }
.goal.watch { background: rgba(245, 158, 11, 0.1); border: 1px solid #b45309; }
.goal.bad { background: rgba(239, 68, 68, 0.1); border: 1px solid #b91c1c; }
.goal.none { background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.goal a { color: var(--accent); }

.ads-err { background: var(--panel-2); border: 1px dashed var(--line); border-radius: 9px; padding: 12px; font-size: 12.5px; color: var(--muted); text-align: center; }
.ads-err-sub { font-size: 11px; margin-top: 4px; opacity: 0.8; }

.todos { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.todos li { display: flex; align-items: center; gap: 7px; font-size: 12.5px; }
.todos li.done span { text-decoration: line-through; color: var(--muted); }
.todos li.empty { color: var(--muted); font-style: italic; font-size: 12px; }
.todos li span { flex: 1; }
.todos input[type=checkbox] { accent-color: var(--accent); cursor: pointer; }
.todo-x { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px; opacity: 0; }
.todos li:hover .todo-x { opacity: 1; }
.todo-x:hover { color: var(--lost); }
.todo-add input {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 7px; padding: 6px 9px; font-size: 12px; outline: none; margin-top: 2px;
}
.todo-add input:focus { border-color: var(--accent-dim); }

.cc-foot { display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 9px; }
.cc-actions a { color: var(--accent); text-decoration: none; }
.cc-actions a:hover { text-decoration: underline; }

.edit-target { background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 10px; }
.et-row { display: flex; gap: 8px; }
.et-row label { flex: 1; font-size: 10.5px; color: var(--muted); display: block; }
.et-row input, .et-row select { width: 100%; background: var(--panel); border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 5px 6px; font-size: 12px; margin-top: 3px; outline: none; }
.et-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.empty-state { color: var(--muted); padding: 40px; }

/* ---- Login gate ---- */
.login-backdrop {
  position: fixed; inset: 0; background: var(--bg);
  display: none; align-items: center; justify-content: center; z-index: 100;
}
.login-backdrop.show { display: flex; }
.login-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 36px 34px; width: 360px; max-width: calc(100vw - 32px);
  display: flex; flex-direction: column; gap: 14px; text-align: center;
}
.login-box .brand { font-size: 22px; }
.login-sub { color: var(--muted); font-size: 13px; margin: 0; }
.login-box input {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 11px 13px; border-radius: 9px; font-size: 14px; outline: none;
}
.login-box input:focus { border-color: var(--accent-dim); }
.login-box .btn-add { padding: 11px; font-size: 14px; }
.login-err { color: var(--lost); font-size: 12.5px; min-height: 16px; }
.seg { display: flex; gap: 6px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 4px; margin-bottom: 16px; }
.seg-btn {
  flex: 1; background: transparent; color: var(--muted); border: 0; cursor: pointer;
  padding: 8px 10px; border-radius: 7px; font-size: 12.5px; font-weight: 600;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--accent); color: #04222a; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
