:root {
  --primary: #0e7c86;
  --primary-dark: #0a5f67;
  --primary-soft: #e3f4f5;
  --navy: #0b3954;
  --blue: #1f6fb2;
  --blue-soft: #e6f0fa;
  --green: #1f9d6b;
  --green-soft: #e3f6ee;
  --red: #d64545;
  --red-soft: #fdecec;
  --amber: #c98a12;
  --amber-soft: #fdf3e0;
  --purple: #6b4fbb;
  --purple-soft: #efeafb;
  --bg: #f2f7f9;
  --card: #ffffff;
  --text: #16303f;
  --muted: #64798a;
  --border: #dbe6ec;
  --shadow: 0 1px 2px rgba(11, 57, 84, .06), 0 4px 16px rgba(11, 57, 84, .06);
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; flex-shrink: 0; background: linear-gradient(180deg, var(--navy) 0%, #0a4a5c 100%);
  color: #cfe3ea; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 18px; color: #fff; }
.brand-logo { width: 36px; height: 36px; border-radius: 10px; background: var(--primary); display: grid; place-items: center; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.brand-sub { font-size: 11px; color: #8fb6c4; }
.nav { padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 9px; color: #cfe3ea; font-weight: 500;
}
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.nav a.active { background: var(--primary); color: #fff; }
.nav .sep { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: #7fa6b5; padding: 14px 12px 6px; }
.nav svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav .badge { margin-left: auto; background: var(--red); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 10px; }
.side-user { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #2a9da7; color: #fff; display: grid; place-items: center; font-weight: 600; flex-shrink: 0; }
.side-user .who { flex: 1; min-width: 0; }
.side-user .who div:first-child { color: #fff; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .who div:last-child { font-size: 11px; color: #8fb6c4; }
.icon-btn { background: none; border: 0; color: inherit; cursor: pointer; padding: 6px; border-radius: 8px; display: grid; place-items: center; }
.icon-btn:hover { background: rgba(255,255,255,.1); }
.icon-btn svg { width: 18px; height: 18px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: var(--card);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.menu-btn { display: none; color: var(--navy); }
.menu-btn:hover { background: var(--bg); }
.search { flex: 1; max-width: 460px; position: relative; }
.search input { padding-left: 36px; background: var(--bg); border-color: transparent; }
.search input:focus { background: #fff; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.topbar .spacer { flex: 1; }
.today-chip { color: var(--muted); font-size: 13px; white-space: nowrap; }
.content { padding: 24px 28px 48px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

/* ---------- Components ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.card-body { padding: 8px 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.mb { margin-bottom: 16px; } .mb2 { margin-bottom: 24px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent;
  background: var(--primary); color: #fff; padding: 9px 16px; border-radius: 9px; font: inherit; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: background .15s, box-shadow .15s;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.xs { padding: 4px 9px; font-size: 12px; border-radius: 7px; }
.btn.ghost { background: #fff; color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: var(--bg); }
.btn.green { background: var(--green); } .btn.green:hover { background: #17845a; }
.btn.red { background: var(--red); } .btn.red:hover { background: #b93838; }
.btn.blue { background: var(--blue); } .btn.blue:hover { background: #185c94; }
.btn.wa { background: #25a35a; } .btn.wa:hover { background: #1d8a4b; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: #fff; border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(14,124,134,.14); }
textarea { resize: vertical; min-height: 84px; }
label.f { display: block; }
label.f > span { display: block; font-size: 12.5px; font-weight: 600; color: #3b5568; margin-bottom: 5px; }
label.f > span em { color: var(--red); font-style: normal; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.hint { font-size: 12px; margin-top: 5px; }
.hint.err { color: var(--red); } .hint.ok { color: var(--green); }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.st-New { background: var(--blue-soft); color: var(--blue); }
.st-Interested { background: var(--primary-soft); color: var(--primary-dark); }
.st-Follow-up { background: var(--amber-soft); color: #9a6a0b; }
.st-Rate-Shared { background: var(--purple-soft); color: var(--purple); }
.st-Closed-Won { background: var(--green-soft); color: #157a52; }
.st-Not-Interested { background: #eef1f3; color: #6b7a86; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; font-size: 12px; background: var(--bg); color: var(--muted); }
.tag.rate { background: var(--purple-soft); color: var(--purple); font-weight: 600; }
.tag.red { background: var(--red-soft); color: var(--red); font-weight: 600; }
.tag.carry { background: var(--amber-soft); color: #9a6a0b; font-weight: 600; }

/* ---------- Stats ---------- */
.stat { padding: 16px 18px; display: flex; align-items: center; gap: 14px; }
.stat .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; }
.stat .ic svg { width: 22px; height: 22px; }
.stat .num { font-size: 24px; font-weight: 700; line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.ic.teal { background: var(--primary-soft); color: var(--primary); }
.ic.blue { background: var(--blue-soft); color: var(--blue); }
.ic.red { background: var(--red-soft); color: var(--red); }
.ic.green { background: var(--green-soft); color: var(--green); }
.ic.purple { background: var(--purple-soft); color: var(--purple); }

/* ---------- Week banner ---------- */
.week {
  background: linear-gradient(120deg, #0b3954 0%, #0e7c86 70%, #18a2a0 100%); color: #fff;
  border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.week::after { content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%; background: rgba(255,255,255,.06); }
.week.friday { background: linear-gradient(120deg, #3b2a6b 0%, #1f6fb2 70%, #2a8fc8 100%); }
.week h2 { font-size: 19px; }
.week .sub { color: rgba(255,255,255,.78); margin-top: 3px; }
.week-grid { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 20px; margin-top: 18px; position: relative; z-index: 1; }
.wbox { background: rgba(255,255,255,.1); border-radius: 10px; padding: 14px 16px; }
.wbox .t { font-size: 12.5px; color: rgba(255,255,255,.8); display: flex; align-items: center; gap: 6px; }
.wbox .big { font-size: 28px; font-weight: 700; margin: 4px 0 8px; }
.wbox .big span { font-size: 14px; font-weight: 500; color: rgba(255,255,255,.75); }
.bar { height: 7px; background: rgba(255,255,255,.18); border-radius: 6px; overflow: hidden; }
.bar > div { height: 100%; background: #7ef0c4; border-radius: 6px; }
.wbox .split { display: flex; justify-content: space-between; font-size: 12px; margin-top: 7px; color: rgba(255,255,255,.85); }
.days-box { display: flex; flex-direction: column; }
.days { display: flex; gap: 8px; align-items: flex-end; flex: 1; margin-top: 6px; }
.day { flex: 1; text-align: center; font-size: 11.5px; color: rgba(255,255,255,.8); }
.day .cols { height: 62px; display: flex; align-items: flex-end; justify-content: center; gap: 3px; margin-bottom: 5px; }
.day .cols div { width: 9px; border-radius: 3px 3px 0 0; min-height: 3px; }
.day .c1 { background: #7ef0c4; } .day .c2 { background: #ffd27a; }
.day.today { color: #fff; font-weight: 700; }
.day .n { font-size: 11px; color: rgba(255,255,255,.7); }
.legend { display: flex; gap: 12px; font-size: 11.5px; color: rgba(255,255,255,.8); margin-top: 6px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.week-actions { display: flex; gap: 8px; margin-top: 16px; position: relative; z-index: 1; flex-wrap: wrap; }
.week .btn.ghost { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.25); color: #fff; }
.week .btn.ghost:hover { background: rgba(255,255,255,.24); }
.week .btn.white { background: #fff; color: var(--navy); }

/* ---------- Task list ---------- */
.tlist { display: flex; flex-direction: column; }
.titem { display: flex; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.titem:last-child { border-bottom: 0; }
.titem:hover { background: #fafcfd; }
.titem .tic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.titem .tic svg { width: 18px; height: 18px; }
.titem .info { flex: 1; min-width: 0; }
.titem .nm { font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.titem .meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; display: flex; gap: 10px; flex-wrap: wrap; }
.titem .cm { font-size: 13px; color: #3b5568; margin-top: 6px; background: var(--bg); border-radius: 8px; padding: 6px 10px; border-left: 3px solid var(--primary); overflow-wrap: anywhere; }
.titem .acts { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; max-width: 270px; }
.titem.done { opacity: .6; }
.empty { padding: 28px 18px; text-align: center; color: var(--muted); }
.empty .e-ic { font-size: 28px; margin-bottom: 6px; }
.section-title { display: flex; align-items: center; gap: 8px; margin: 26px 0 12px; }
.count { background: var(--bg); color: var(--muted); font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 10px; }
.count.red { background: var(--red-soft); color: var(--red); }
.card.overdue { border-color: #f3c4c4; }
.card.overdue .card-head { background: var(--red-soft); border-radius: var(--radius) var(--radius) 0 0; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; padding: 11px 14px; border-bottom: 1px solid var(--border); background: #f8fbfc; white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f7fbfc; }
table.static tbody tr { cursor: default; }
td .sub { font-size: 12px; color: var(--muted); }
td .tag, td .pill, td .sub.nw, td.nw { white-space: nowrap; }
.clip { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filters { display: grid; grid-template-columns: 2fr repeat(5, 1fr) auto; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }

/* ---------- Lead detail ---------- */
.detail { display: grid; grid-template-columns: 360px 1fr; gap: 16px; align-items: start; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 9px 10px; font-size: 13.5px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.next-box { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.next-box > div { border-radius: 10px; padding: 10px 12px; }
.next-box .l { font-size: 12px; font-weight: 600; display: flex; gap: 5px; align-items: center; }
.next-box .v { font-weight: 700; margin-top: 3px; }
.timeline { padding: 6px 20px 16px; }
.tl { display: flex; gap: 12px; position: relative; padding: 12px 0; }
.tl::before { content: ""; position: absolute; left: 15px; top: 44px; bottom: -12px; width: 2px; background: var(--border); }
.tl:last-child::before { display: none; }
.tl .dot { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; z-index: 1; }
.tl .dot svg { width: 15px; height: 15px; }
.tl .body { flex: 1; min-width: 0; }
.tl .head { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tl .head b { color: var(--text); }
.tl .txt { margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.tl.system .txt { color: var(--muted); font-size: 13px; font-style: italic; }
.kind-tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.kind-tabs button { border: 1px solid var(--border); background: #fff; padding: 6px 12px; border-radius: 20px; font: inherit; font-size: 13px; cursor: pointer; color: var(--muted); font-weight: 500; }
.kind-tabs button.on { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal .dh { padding: 10px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; text-align: center; border-bottom: 1px solid var(--border); }
.cal .dc { min-height: 92px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 7px 8px; cursor: pointer; transition: background .12s; }
.cal .dc:nth-child(7n) { border-right: 0; }
.cal .dc:hover { background: #f7fbfc; }
.cal .dc.out { background: #fafbfc; color: #b3c0c9; }
.cal .dc.sel { background: var(--primary-soft); box-shadow: inset 0 0 0 2px var(--primary); }
.cal .dn { font-weight: 600; font-size: 13px; }
.cal .dc.today .dn { background: var(--primary); color: #fff; border-radius: 50%; width: 24px; height: 24px; display: grid; place-items: center; }
.cal .chip { display: block; font-size: 11.5px; font-weight: 600; padding: 2px 6px; border-radius: 5px; margin-top: 4px; }
.cal .chip.c { background: var(--blue-soft); color: var(--blue); }
.cal .chip.m { background: var(--green-soft); color: #157a52; }
.cal .chip.o { background: var(--red-soft); color: var(--red); }

/* ---------- Modal / toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(11, 57, 84, .45); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade .15s; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); animation: pop .18s; }
.modal.wide { max-width: 760px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 10px; position: sticky; top: 0; background: #fff; z-index: 1; }
.modal-head .icon-btn { color: var(--muted); } .modal-head .icon-btn:hover { background: var(--bg); }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
#toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--navy); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow); font-weight: 500; max-width: 360px; animation: pop .2s; }
.toast.err { background: var(--red); } .toast.ok { background: var(--green); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: linear-gradient(140deg, #0b3954 0%, #0e7c86 60%, #22b0a8 100%); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-art::before, .login-art::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255,255,255,.06); }
.login-art::before { width: 420px; height: 420px; right: -120px; bottom: -120px; }
.login-art::after { width: 220px; height: 220px; left: -60px; top: 30%; }
.login-art h1 { font-size: 34px; line-height: 1.2; max-width: 440px; position: relative; z-index: 1; }
.login-art p { color: rgba(255,255,255,.8); max-width: 420px; font-size: 15px; position: relative; z-index: 1; }
.login-art ul { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 10px; position: relative; z-index: 1; }
.login-art li { display: flex; gap: 10px; align-items: center; color: rgba(255,255,255,.92); }
.login-art li span { width: 26px; height: 26px; border-radius: 8px; background: rgba(255,255,255,.15); display: grid; place-items: center; }
.login-form { display: grid; place-items: center; padding: 32px 20px; }
.login-box { width: 100%; max-width: 360px; }
.login-box h2 { font-size: 24px; margin-bottom: 4px; }
.login-box form { display: grid; gap: 14px; margin-top: 24px; }
.login-box .btn { padding: 11px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .week-grid { grid-template-columns: 1fr 1fr; }
  .week-grid .days-box { grid-column: 1 / -1; }
  .detail { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr 1fr; }
  .filters .q { grid-column: 1 / -1; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .menu-btn { display: grid; }
  .today-chip, .topbar > .btn { display: none; }
  .search { max-width: none; }
  .topbar { padding: 10px 16px; }
  .content { padding: 18px 16px 40px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { display: none; }
}
@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
  .week-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .titem { flex-wrap: wrap; }
  .titem .acts { max-width: none; width: 100%; justify-content: flex-start; padding-left: 48px; }
  .cal .dc { min-height: 64px; padding: 4px; }
  .cal .chip { font-size: 10px; padding: 1px 3px; }
  .kv { grid-template-columns: 96px 1fr; }
  h1 { font-size: 20px; }
}
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 40; }
