:root {
  --blue: #0a66c2;
  --blue-dark: #084d94;
  --bg: #f3f6f9;
  --card: #ffffff;
  --text: #1d2530;
  --muted: #6b7684;
  --line: #e3e8ee;
  --green: #1a7f4b;
  --green-bg: #e7f6ee;
  --amber: #9a6700;
  --amber-bg: #fff4d6;
  --red: #b42318;
  --red-bg: #fdecea;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 30, 54, .08), 0 1px 2px rgba(16, 30, 54, .04);
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 36px 32px; width: 100%; max-width: 380px; }
.login-card h1 { margin: 0 0 4px; font-size: 24px; }
.login-card .sub { color: var(--muted); margin-bottom: 24px; }
.brand-dot { color: var(--blue); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.phone-row { display: flex; gap: 8px; }
.phone-row select { width: 92px; }
input[type=text], input[type=password], input[type=tel], input[type=number], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
  outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); }
.btn { border: none; border-radius: 8px; padding: 10px 16px; font-weight: 600; transition: background .15s, transform .05s; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-block { width: 100%; padding: 12px; font-size: 16px; }
.btn-ghost { background: transparent; color: var(--blue); border: 1px solid var(--line); }
.btn-ghost:hover { background: #eef4fb; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 7px; }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: #14663c; }
.btn-soft { background: #eef1f5; color: var(--text); }
.btn-soft:hover { background: #e2e7ee; }
.btn-danger-soft { background: var(--red-bg); color: var(--red); }
.err { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ---------- shell ---------- */
header {
  background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.header-inner {
  max-width: 1080px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 4px; height: 56px;
}
.logo { font-weight: 800; font-size: 17px; margin-right: 18px; white-space: nowrap; }
nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
nav button {
  background: none; border: none; padding: 8px 13px; border-radius: 8px; color: var(--muted); font-weight: 600; white-space: nowrap;
}
nav button.active { background: #e8f1fb; color: var(--blue); }
nav button:hover { color: var(--blue); }
.who { color: var(--muted); font-size: 13px; white-space: nowrap; display: flex; align-items: center; gap: 10px; }
.who a { color: var(--blue); cursor: pointer; text-decoration: none; font-weight: 600; }

main { max-width: 1080px; margin: 0 auto; padding: 20px 16px 60px; }
h2 { font-size: 20px; margin: 4px 0 16px; }

/* ---------- cards / sections ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; overflow: hidden; }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.card-head h3 { margin: 0; font-size: 16px; flex: 1; }
.count-pill { background: #e8f1fb; color: var(--blue); font-weight: 700; font-size: 13px; padding: 2px 10px; border-radius: 99px; }
.card-body { padding: 6px 0; }
.empty { padding: 22px 18px; color: var(--muted); text-align: center; }

/* progress banner */
.progress-banner {
  background: linear-gradient(120deg, var(--blue), #2e8ae0); color: #fff; border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 20px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.progress-banner .big { font-size: 26px; font-weight: 800; }
.progress-banner .lbl { opacity: .85; font-size: 13px; }
.pb-item { min-width: 110px; }
.bar { flex: 1 1 180px; height: 10px; background: rgba(255,255,255,.3); border-radius: 99px; overflow: hidden; min-width: 140px; }
.bar > div { height: 100%; background: #fff; border-radius: 99px; transition: width .3s; }

/* prospect row */
.prow { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.prow:last-child { border-bottom: none; }
.prow .info { flex: 1 1 220px; min-width: 0; }
.prow .nm { font-weight: 700; }
.prow .meta { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.prow .acts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.badge { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.b-new { background: #e8f1fb; color: var(--blue); }
.b-requested { background: var(--amber-bg); color: var(--amber); }
.b-in_sequence { background: #ede9fe; color: #6d28d9; }
.b-replied { background: var(--green-bg); color: var(--green); }
.b-completed { background: #e2e7ee; color: var(--muted); }
.b-not_accepted, .b-dnc, .b-skipped { background: var(--red-bg); color: var(--red); }
.warn-old { color: var(--amber); font-size: 12px; font-weight: 700; }

/* message box */
.msgbox { flex-basis: 100%; background: #f7f9fb; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 14px; white-space: pre-wrap; }
.msgbox-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.msgbox-head .step { font-size: 12px; font-weight: 700; color: #6d28d9; }

/* toolbar */
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.toolbar input[type=text] { flex: 1 1 160px; max-width: 260px; }
.toolbar select { width: auto; }
.spacer { flex: 1; }

/* table */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; padding: 10px 14px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line); }
td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr.clickable:hover { background: #f7f9fb; cursor: pointer; }
td .sub { color: var(--muted); font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
th.num { text-align: right; }

/* steps editor */
.step-card { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin: 12px 18px; }
.step-head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.step-head input[type=text] { flex: 1 1 180px; }
.step-head .days { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.step-head .days input { width: 64px; }
.step-card textarea { min-height: 84px; resize: vertical; }
.hint { color: var(--muted); font-size: 13px; padding: 0 18px 12px; }
code { background: #eef1f5; border-radius: 4px; padding: 1px 5px; font-size: 13px; }

/* dashboard */
.funnel { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.funnel .fcard { flex: 1 1 120px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.funnel .fcard .v { font-size: 26px; font-weight: 800; }
.funnel .fcard .l { color: var(--muted); font-size: 13px; }
.funnel .fcard .r { font-size: 12px; color: var(--green); font-weight: 700; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(20,30,45,.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 460px; max-height: 92vh; overflow-y: auto; padding: 22px; }
.modal h3 { margin: 0 0 16px; }
.modal .row2 { display: flex; gap: 10px; }
.modal .row2 .field { flex: 1; }
.modal-acts { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* toast */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1d2530; color: #fff;
  padding: 11px 20px; border-radius: 10px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 99;
  max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; }
#toast.error { background: var(--red); }

.recent-item { padding: 9px 18px; border-bottom: 1px solid var(--line); font-size: 13.5px; display: flex; gap: 8px; }
.recent-item:last-child { border-bottom: none; }
.recent-item .t { color: var(--muted); white-space: nowrap; margin-left: auto; }

@media (max-width: 640px) {
  .logo { margin-right: 6px; font-size: 15px; }
  .who .phone-lbl { display: none; }
  th, td { padding: 8px 8px; }
  main { padding: 14px 10px 60px; }
}
