:root {
  --bg: #f7f8fc;
  --surface: #ffffff;
  --surface-soft: #f4f3ff;
  --line: #e8e9f2;
  --text: #202239;
  --muted: #777b96;
  --primary: #5b50e6;
  --primary-dark: #463bc9;
  --primary-soft: #edebff;
  --success: #1f9d72;
  --danger: #d94d64;
  --shadow: 0 14px 36px rgba(35, 39, 84, .08);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Vazirmatn, Tahoma, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.65;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app-shell { min-height: 100vh; display: flex; background: var(--bg); }
.sidebar {
  width: 256px; flex: 0 0 256px; min-height: 100vh; padding: 24px 16px 18px;
  display: flex; flex-direction: column; background: #fff; border-left: 1px solid var(--line);
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 12px 27px; font-size: 22px; font-weight: 800; letter-spacing: -.5px; }
.brand-mark {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 11px;
  background: linear-gradient(135deg, #766df5, #4d42d6); color: #fff; font: 800 19px Arial, sans-serif;
  box-shadow: 0 8px 16px rgba(91, 80, 230, .25);
}
.main-nav { display: grid; gap: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 13px; border-radius: 11px;
  color: #676b85; transition: .15s ease;
}
.nav-item:hover { background: #f7f7fb; color: var(--primary); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.nav-item.active svg { stroke-width: 2.3; }
.sidebar-bottom { margin-top: auto; border-top: 1px solid var(--line); padding: 17px 5px 0; }
.user-card { display: flex; gap: 10px; align-items: center; padding: 0 6px 15px; min-width: 0; }
.avatar { display: inline-grid; place-items: center; flex: 0 0 35px; width: 35px; height: 35px; border-radius: 50%; color: #564bd6; background: #e9e8ff; font-weight: 800; }
.user-card-copy { display: grid; min-width: 0; }
.user-card-copy strong, .user-card-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card-copy small { color: var(--muted); font-size: 11px; direction: ltr; text-align: right; }
.logout-button { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; padding: 9px 6px; color: #73758a; background: transparent; text-align: right; }
.logout-button:hover { color: var(--danger); }
.logout-button svg { width: 18px; height: 18px; }

.main-content { min-width: 0; flex: 1; }
.topbar { min-height: 93px; padding: 20px 43px; display: flex; align-items: center; justify-content: space-between; gap: 20px; background: rgba(255,255,255,.88); border-bottom: 1px solid var(--line); }
.topbar-title h1 { margin: 0; font-size: 21px; line-height: 1.25; letter-spacing: -.4px; }
.eyebrow { display: block; margin-bottom: 2px; color: var(--muted); font-size: 11px; }
.topbar-meta { color: #767c95; font-size: 12px; display: flex; align-items: center; gap: 8px; }
.secure-dot { width: 8px; height: 8px; border-radius: 50%; background: #6ccda5; box-shadow: 0 0 0 4px #e7f8f1; }
.menu-toggle { display: none; background: none; border: 0; font-size: 22px; color: var(--text); }
.content-wrap { padding: 32px 42px 45px; max-width: 1550px; }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 23px; }
.page-header h2 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.4px; }
.page-header p { margin: 0; color: var(--muted); }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 39px; padding: 7px 15px; border: 1px solid transparent; border-radius: 9px; font-weight: 700; transition: .15s ease; }
.button svg { width: 17px; height: 17px; }
.button.primary { color: #fff; background: var(--primary); box-shadow: 0 6px 14px rgba(91,80,230,.22); }
.button.primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.button.outline { color: #656a84; background: #fff; border-color: var(--line); }
.button.outline:hover { color: var(--primary); border-color: #cbc6fb; }
.button.danger { color: var(--danger); background: #fff6f7; border-color: #ffe2e7; }
.button.full { width: 100%; min-height: 47px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 17px; margin-bottom: 27px; }
.stat-card { position: relative; overflow: hidden; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 4px 14px rgba(35,39,84,.025); }
.stat-card .stat-icon { display: inline-grid; place-items: center; width: 39px; height: 39px; border-radius: 11px; color: var(--primary); background: var(--primary-soft); }
.stat-card:nth-child(2) .stat-icon { color: #2b9bcb; background: #e5f6fe; }
.stat-card:nth-child(3) .stat-icon { color: #ec982e; background: #fff4df; }
.stat-card:nth-child(4) .stat-icon { color: #35a77f; background: #e6f8f0; }
.stat-label { display: block; margin-top: 15px; color: var(--muted); font-size: 13px; }
.stat-value { display: block; margin-top: 2px; font-size: 27px; font-weight: 800; letter-spacing: -.7px; }
.stat-hint { display: block; margin-top: 2px; color: #9a9db0; font-size: 11px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, .8fr); gap: 20px; }
.panel { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 4px 14px rgba(35,39,84,.025); }
.panel-header { min-height: 67px; padding: 17px 20px; display: flex; align-items: center; justify-content: space-between; gap: 15px; border-bottom: 1px solid var(--line); }
.panel-header h3 { margin: 0; font-size: 15px; }
.panel-header a { color: var(--primary); font-size: 12px; font-weight: 700; }
.recent-list { display: grid; }
.recent-item { display: flex; align-items: center; gap: 12px; padding: 15px 20px; border-bottom: 1px solid #f0f1f6; }
.recent-item:last-child { border-bottom: 0; }
.recent-avatar { display: grid; place-items: center; width: 37px; height: 37px; border-radius: 10px; color: #4f4b8e; background: #f0effd; font-weight: 800; }
.recent-copy { min-width: 0; flex: 1; }
.recent-copy strong, .recent-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-copy small { color: var(--muted); font-size: 12px; }
.recent-date { color: #a2a4b2; font-size: 11px; white-space: nowrap; }
.quick-actions { padding: 15px 20px 20px; display: grid; gap: 10px; }
.quick-action { display: flex; align-items: center; gap: 11px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; color: #565a74; background: #fff; }
.quick-action:hover { border-color: #cfc9fa; color: var(--primary); background: #fbfaff; }
.quick-action svg { color: var(--primary); width: 19px; }
.quick-action span:last-child { margin-right: auto; color: #a6a7b4; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 13px; margin-bottom: 16px; }
.search-box { position: relative; width: min(380px, 100%); }
.search-box svg { position: absolute; top: 11px; right: 12px; width: 18px; color: #9699ae; }
.search-box input { width: 100%; height: 41px; padding: 0 40px 0 13px; border: 1px solid var(--line); border-radius: 10px; outline: 0; color: var(--text); background: #fff; }
.search-box input:focus { border-color: #aaa4f6; box-shadow: 0 0 0 3px #efedff; }
.table-card { overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 4px 14px rgba(35,39,84,.025); }
table { width: 100%; border-collapse: collapse; min-width: 710px; }
th { padding: 14px 18px; color: #85889c; background: #fbfbfd; border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 700; text-align: right; white-space: nowrap; }
td { padding: 15px 18px; border-bottom: 1px solid #f0f1f6; color: #50546c; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.entity-name { display: flex; align-items: center; gap: 10px; font-weight: 800; color: #363950; }
.entity-avatar { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 9px; color: #5a50da; background: #efedff; font-size: 13px; }
.subtext { display: block; margin-top: 2px; color: #9598aa; font-size: 11px; }
.muted { color: var(--muted); }
.empty-state { display: grid; place-items: center; padding: 70px 20px; text-align: center; }
.empty-state > svg { width: 45px; height: 45px; margin-bottom: 12px; color: #8d87e8; stroke-width: 1.3; }
.empty-state h3 { margin: 0 0 5px; font-size: 17px; }
.empty-state p { max-width: 420px; margin: 0 0 17px; color: var(--muted); }
.inline-form { display: inline; }
.table-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.icon-button { border: 0; padding: 6px; color: #989bad; background: transparent; border-radius: 7px; }
.icon-button:hover { color: var(--danger); background: #fff1f3; }
.icon-button svg { width: 18px; }
.stage { display: inline-flex; align-items: center; min-height: 27px; padding: 2px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; }
.stage-lead { color: #6a6396; background: #eeedf6; }
.stage-negotiation { color: #277fa9; background: #e4f5fc; }
.stage-proposal { color: #a0681d; background: #fff1dc; }
.stage-won { color: #1f8966; background: #e3f7ef; }
.stage-lost { color: #ba5262; background: #feecef; }
.stage-select { padding: 5px 7px; border: 1px solid var(--line); border-radius: 7px; color: #5f637a; background: #fff; }
.notice { margin-bottom: 18px; padding: 11px 13px; border-radius: 10px; font-size: 13px; }
.notice.success { color: #1e7f61; background: #e8f8f1; border: 1px solid #cbeede; }
.notice.error { color: #b53e50; background: #fff0f2; border: 1px solid #ffd9df; }

.modal { position: fixed; z-index: 20; inset: 0; display: none; padding: 24px; align-items: center; justify-content: center; }
.modal.is-open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(29, 31, 55, .46); backdrop-filter: blur(2px); }
.modal-card { position: relative; width: min(620px, 100%); max-height: calc(100vh - 48px); overflow: auto; padding: 26px; border-radius: 16px; background: #fff; box-shadow: 0 25px 70px rgba(24,27,57,.25); }
.modal-card h2 { margin: 0 0 20px; font-size: 18px; }
.modal-close { position: absolute; left: 14px; top: 12px; width: 31px; height: 31px; border: 0; border-radius: 7px; color: #70738a; background: #f5f5f9; font-size: 24px; line-height: 1; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full-row { grid-column: 1 / -1; }
label { display: grid; gap: 6px; color: #53566e; font-size: 12px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid #dedfe9; border-radius: 9px; outline: 0; color: var(--text); background: #fff; }
input, select { min-height: 41px; padding: 8px 11px; }
textarea { min-height: 82px; padding: 9px 11px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #a6a0f2; box-shadow: 0 0 0 3px #f0efff; }
.form-actions { display: flex; align-items: center; justify-content: flex-start; gap: 10px; margin-top: 22px; }

.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(430px, .85fr); background: #fff; }
.login-visual { position: relative; overflow: hidden; padding: 46px clamp(45px, 7vw, 128px); display: flex; flex-direction: column; color: #fff; background: linear-gradient(140deg, #6256e7 0%, #3d35ba 100%); }
.login-brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 800; }
.login-brand .brand-mark { background: rgba(255,255,255,.18); box-shadow: none; }
.visual-copy { position: relative; z-index: 1; max-width: 560px; margin: auto 0; }
.visual-label { display: inline-block; margin-bottom: 18px; padding: 6px 11px; border-radius: 99px; background: rgba(255,255,255,.15); font-size: 12px; }
.visual-copy h1 { max-width: 520px; margin: 0 0 17px; font-size: clamp(30px, 3.1vw, 47px); line-height: 1.42; letter-spacing: -1.2px; }
.visual-copy p { max-width: 460px; margin: 0; color: rgba(255,255,255,.76); font-size: 16px; }
.visual-orbs::before, .visual-orbs::after { content: ""; position: absolute; border-radius: 50%; border: 1px solid rgba(255,255,255,.09); }
.visual-orbs::before { width: 510px; height: 510px; left: -220px; bottom: -230px; box-shadow: 0 0 0 55px rgba(255,255,255,.03), 0 0 0 110px rgba(255,255,255,.025); }
.visual-orbs::after { width: 290px; height: 290px; top: -110px; left: 11%; background: rgba(255,255,255,.035); }
.login-panel { display: grid; place-items: center; padding: 35px; background: #f9f9fc; }
.login-card { width: min(400px, 100%); padding: 12px; }
.panel-kicker { color: var(--primary); font-size: 12px; font-weight: 800; }
.login-card h2 { margin: 5px 0; font-size: 25px; letter-spacing: -.6px; }
.login-card .muted { margin: 0 0 27px; }
.login-card label { margin-bottom: 16px; }
.login-card input { min-height: 47px; background: #fff; }
.register-card { width: min(620px, 100%); }
.register-card .form-grid { margin-bottom: 8px; }
.auth-switch { margin: 16px 0 0; text-align: center; color: var(--muted); font-size: 13px; }
.auth-switch a { color: var(--primary); font-weight: 800; text-decoration: none; }
.login-footer { margin: 20px 0 0; color: #9a9cad; font-size: 11px; text-align: center; }

.installer-body { min-height: 100vh; padding: 42px 20px; background: linear-gradient(145deg, #f1f0ff 0%, #f8f9fc 42%, #f4f7ff 100%); }
.installer-wrap { display: grid; place-items: center; min-height: calc(100vh - 84px); }
.installer-card { width: min(760px, 100%); padding: clamp(25px, 5vw, 44px); border: 1px solid rgba(222,223,233,.9); border-radius: 20px; background: rgba(255,255,255,.96); box-shadow: var(--shadow); }
.installer-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 29px; }
.installer-brand div { display: grid; line-height: 1.4; }
.installer-brand small { color: var(--muted); font-size: 11px; }
.installer-card > h1 { margin: 0 0 5px; font-size: 23px; }
.installer-card > p { margin: 0 0 25px; color: var(--muted); }
.installer-card form > h2 { margin: 27px 0 13px; color: #464961; font-size: 14px; }
.installer-note { margin: 24px 0 0 !important; padding-top: 18px; border-top: 1px solid var(--line); color: #8b8ea1 !important; font-size: 11px; }

@media (max-width: 1050px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .content-wrap { padding: 27px 25px; }
  .topbar { padding: 20px 26px; }
}
@media (max-width: 760px) {
  .sidebar { position: fixed; z-index: 10; top: 0; bottom: 0; right: -265px; transition: right .2s ease; box-shadow: -10px 0 30px rgba(31,33,70,.13); }
  .sidebar.is-open { right: 0; }
  .menu-toggle { display: block; }
  .topbar { min-height: 76px; padding: 16px 18px; }
  .topbar-meta { display: none; }
  .content-wrap { padding: 22px 16px 32px; }
  .page-header { align-items: stretch; flex-direction: column; }
  .page-header .button { align-self: flex-start; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .search-box { width: 100%; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 15px; }
  .stat-value { font-size: 23px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full-row { grid-column: auto; }
  .login-page { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .login-panel { min-height: 100vh; padding: 24px; background: linear-gradient(180deg, #f5f4ff 0, #fff 42%); }
}

/* CRM educational V1 additions */
:root {
  --primary: #123a63;
  --primary-dark: #0a2949;
  --primary-soft: #e8f0f8;
  --text: #17263a;
  --success: #1d956a;
  --warning: #d38a18;
}
.brand-mark { background: linear-gradient(135deg, #1d5c91, #0d3154); }
.brand-image { width: 34px; height: 34px; border-radius: 11px; object-fit: cover; }
.sidebar-caption { margin: -18px 12px 20px; color: #9aa5b5; font-size: 10px; }
.nav-item.active { background: var(--primary-soft); color: var(--primary); }
.button.primary { background: var(--primary); box-shadow: 0 6px 14px rgba(18,58,99,.22); }
.button.primary:hover { background: var(--primary-dark); }
.login-visual { background: linear-gradient(140deg, #164d7e 0%, #0a2d50 100%); }
.notification-badge, .count-badge { display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 99px; color: #fff; background: var(--danger); font-size: 10px; }
.count-badge { color: var(--primary); background: var(--primary-soft); vertical-align: middle; }
.filter-toolbar { align-items: flex-start; flex-wrap: wrap; }
.filter-group { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-chip { min-height: 31px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 99px; color: #70768a; background: #fff; font-size: 11px; }
.filter-chip.active, .filter-chip:hover { color: var(--primary); border-color: #a9bfd4; background: var(--primary-soft); }
.priority { display: inline-flex; align-items: center; gap: 4px; min-height: 26px; padding: 2px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; }
.priority::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.priority-hot { color: #c84458; background: #fff0f2; }
.priority-warm { color: #be7d17; background: #fff7e8; }
.priority-cold { color: #4783a9; background: #edf7fc; }
.stage-l0 { color: #697287; background: #eef1f5; }
.stage-l1 { color: #35759c; background: #eaf6fb; }
.stage-l2 { color: #5c5da5; background: #efefff; }
.stage-l3 { color: #a36b1e; background: #fff4df; }
.stage-l4 { color: #a4506b; background: #fff0f4; }
.stage-l5 { color: #7e61a2; background: #f3edff; }
.stage-l6 { color: #1b8d68; background: #e5f8f0; }
.stage-l7 { color: #9e5660; background: #fcecef; }
.button.small { min-height: 31px; padding: 4px 10px; font-size: 11px; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 15px; color: var(--muted); font-size: 12px; }
.detail-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.detail-header h2 { margin: 5px 0 0; font-size: 25px; }
.detail-header p { margin: 0; color: var(--muted); }
.back-link { color: var(--primary); font-size: 12px; font-weight: 700; }
.detail-actions { display: flex; gap: 9px; }
.lead-summary { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 12px; padding: 17px 20px; margin-bottom: 18px; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: 0 4px 14px rgba(35,39,84,.025); }
.lead-summary span { display: grid; gap: 3px; min-width: 0; }
.lead-summary small, .info-grid small, .mini-facts span { color: var(--muted); font-size: 11px; }
.lead-summary strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.detail-grid { display: grid; grid-template-columns: minmax(0,1.5fr) minmax(275px,.7fr); gap: 19px; align-items: start; }
.detail-main, .detail-side { display: grid; gap: 19px; }
.panel-inner { padding: 19px 20px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 15px; }
.section-heading h3 { margin: 0; font-size: 15px; }
.info-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 15px; }
.info-grid > div { display: grid; gap: 3px; color: #4f5667; }
.info-grid a { color: var(--primary); direction: ltr; text-align: right; }
.funnel-track { display: grid; grid-template-columns: repeat(8, minmax(64px,1fr)); gap: 3px; padding: 19px 20px 12px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.funnel-step { position: relative; display: grid; gap: 4px; min-width: 68px; padding: 8px 5px; color: #a0a7b2; text-align: center; }
.funnel-step::before { content: ""; display: block; width: 13px; height: 13px; margin: 0 auto 1px; border: 2px solid currentColor; border-radius: 50%; background: #fff; }
.funnel-step:not(:last-child)::after { content: ""; position: absolute; top: 14px; right: calc(-50% + 8px); left: calc(50% + 8px); height: 2px; background: #e5e9ef; }
.funnel-step.passed, .funnel-step.current { color: var(--primary); }
.funnel-step.passed::before, .funnel-step.current::before { background: currentColor; box-shadow: inset 0 0 0 3px #fff; }
.funnel-step small { font-size: 9px; white-space: nowrap; }
.timeline { display: grid; gap: 0; }
.timeline-item { position: relative; display: flex; gap: 13px; padding: 0 0 21px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before { content: ""; position: absolute; right: 5px; top: 14px; bottom: -2px; width: 1px; background: #dfe5ec; }
.timeline-item:last-child::before { display: none; }
.timeline-dot { position: relative; z-index: 1; flex: 0 0 11px; width: 11px; height: 11px; margin-top: 4px; border: 3px solid #fff; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 1px #9eb7cd; }
.timeline-item strong, .timeline-item small, .timeline-item p { display: block; }
.timeline-item small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.timeline-item p { margin: 8px 0; color: #626b7c; }
.history-list, .compact-list { display: grid; gap: 11px; }
.history-item { display: grid; grid-template-columns: 105px 1fr auto; gap: 10px; align-items: center; padding-bottom: 9px; border-bottom: 1px solid #f0f2f5; font-size: 12px; }
.history-item:last-child { border-bottom: 0; }
.history-time, .history-item small { color: var(--muted); font-size: 10px; }
.compact-item { display: flex; align-items: center; gap: 9px; padding: 9px 0; border-bottom: 1px solid #f0f2f5; }
.compact-item:last-child { border-bottom: 0; }
.compact-item > div { min-width: 0; display: grid; }
.compact-item strong, .compact-item small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compact-item small { color: var(--muted); font-size: 11px; }
.due-dot { flex: 0 0 9px; width: 9px; height: 9px; border-radius: 50%; }
.due-dot.overdue, .due-label.overdue { color: #c94c5d; background-color: #fff0f2; }
.due-dot.overdue { background: #d85263; }
.due-dot.today, .due-label.today { color: #b47716; background-color: #fff6e6; }
.due-dot.today { background: #e1a42d; }
.due-dot.upcoming, .due-label.upcoming { color: #248662; background-color: #e8f8f1; }
.due-dot.upcoming { background: #38a77f; }
.due-dot.done { background: #a6afba; }
.due-label { display: inline-block; padding: 3px 7px; border-radius: 6px; font-size: 11px; }
.note-item { padding: 9px; border-radius: 8px; background: #fafbfd; }
.note-item p { margin: 0 0 5px; color: #505a6c; white-space: pre-line; }
.note-item small { color: var(--muted); font-size: 10px; }
.assignment-form { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.assignment-form select, .assignment-form input { min-height: 31px; width: auto; padding: 4px 7px; font-size: 11px; }
.assignment-form input { max-width: 130px; }
.product-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 17px; }
.product-card { padding: 19px; }
.product-card-head { display: flex; align-items: center; justify-content: space-between; }
.product-card h3 { margin: 16px 0 2px; font-size: 16px; }
.product-card > small { color: var(--muted); }
.product-card > strong { display: block; margin: 15px 0 8px; font-size: 19px; }
.product-card p { min-height: 46px; margin: 0 0 15px; color: var(--muted); font-size: 12px; }
.import-hero { display:flex; align-items:flex-start; justify-content:space-between; gap:24px; margin-bottom:18px; padding:24px; }
.import-hero h2 { margin:8px 0 7px; font-size:22px; }
.import-hero p { max-width:760px; margin:0; color:var(--muted); line-height:1.9; }
.import-badge { padding:8px 12px; border-radius:999px; color:#4f7f6a; background:#eaf6ef; font-size:12px; white-space:nowrap; }
.import-card { margin-bottom:18px; padding:22px; }
.import-form { display:grid; gap:18px; max-width:900px; }
.import-dropzone { display:grid; gap:8px; padding:24px; border:1px dashed #bfc6dc; border-radius:16px; background:#fafbff; cursor:pointer; }
.import-dropzone strong { font-size:15px; }
.import-dropzone small { color:var(--muted); }
.import-dropzone input { display:block; width:100%; }
.import-rules { display:grid; gap:8px; padding:14px 16px; border-radius:12px; color:var(--muted); background:#f5f6fb; font-size:12px; line-height:1.8; }
.status-dot { display: inline-flex; align-items: center; gap: 5px; color: #8a94a2; font-size: 11px; }
.status-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-dot.online { color: var(--success); }
.status-dot.offline { color: #a3aab5; }
.progress-value { margin-bottom: 4px; color: var(--primary); font-size: 11px; }
.progress { min-width: 90px; height: 5px; overflow: hidden; border-radius: 99px; background: #edf0f4; }
.progress span { display: block; height: 100%; border-radius: inherit; background: var(--primary); }
.report-filter { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 18px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.report-filter label { min-width: 150px; }
.funnel-report { display: grid; gap: 7px; padding: 19px 20px; }
.funnel-report-row { display: grid; grid-template-columns: minmax(190px, .7fr) 45px minmax(100px,1fr); align-items: center; gap: 12px; padding: 7px 0; color: #596477; font-size: 12px; }
.funnel-report-row strong { color: var(--primary); }
.funnel-bar { height: 7px; overflow: hidden; border-radius: 99px; background: #edf1f5; }
.funnel-bar i { display: block; height: 100%; border-radius: inherit; background: var(--primary); }
.score-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin-bottom: 15px; }
.score-grid label input { text-align: center; }
.settings-card { margin-bottom: 18px; }
.setting-row { display: flex; justify-content: space-between; gap: 15px; padding: 11px 0; border-bottom: 1px solid #f0f2f5; }
.setting-row:last-child { border-bottom: 0; }
.setting-row code { color: var(--primary); font-family: Tahoma, sans-serif; }
.profile-hero { display: flex; align-items: center; gap: 13px; margin-bottom: 25px; }
.avatar.large { width: 52px; height: 52px; font-size: 20px; }
.profile-hero h2 { margin: 0; font-size: 19px; }
.profile-hero p { margin: 2px 0 0; color: var(--muted); }
.mobile-nav { display: none; }

/* Release 2026.08.18.5: stable responsive detail and timeline layout */
html, body { overflow-x: hidden; }
.lead-path {
  overflow-x: auto;
  padding: 18px 20px 20px;
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
}
.lead-path-track {
  position: relative;
  display: flex;
  min-width: 760px;
  padding-top: 2px;
}
.lead-path-track::before {
  content: "";
  position: absolute;
  top: 17px;
  right: 34px;
  left: 34px;
  height: 3px;
  border-radius: 99px;
  background: #e6ebf1;
}
.lead-path-step {
  position: relative;
  z-index: 1;
  display: grid;
  flex: 1 0 95px;
  justify-items: center;
  gap: 7px;
  min-width: 95px;
  color: #9aa5b1;
  text-align: center;
}
.lead-path-node {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 3px solid currentColor;
  border-radius: 50%;
  color: inherit;
  background: #fff;
  font-size: 10px;
  font-weight: 800;
}
.lead-path-label {
  max-width: 92px;
  color: #6e7988;
  font-size: 10px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.lead-path-step.passed, .lead-path-step.current { color: var(--primary); }
.lead-path-step.current .lead-path-node { box-shadow: 0 0 0 4px rgba(42, 102, 143, .12); }
.lead-path-step.current .lead-path-label { color: var(--primary); font-weight: 800; }
.lead-history {
  position: relative;
  display: grid;
  gap: 0;
  padding-right: 12px;
}
.lead-history::before {
  content: "";
  position: absolute;
  top: 18px;
  right: 5px;
  bottom: 18px;
  width: 2px;
  background: #dce5ee;
}
.lead-history-item {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0 15px;
}
.lead-history-node {
  position: relative;
  z-index: 1;
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 3px solid #fff;
  border-radius: 50%;
  color: var(--primary);
  background: #dcecf7;
  box-shadow: 0 0 0 1px #9eb7cd;
  font-size: 9px;
  font-weight: 800;
}
.lead-history-content {
  min-width: 0;
  padding-bottom: 12px;
  border-bottom: 1px solid #f0f2f5;
}
.lead-history-item:last-child .lead-history-content { border-bottom: 0; }
.lead-history-meta {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.7;
}
.lead-history-content strong { display: block; font-size: 13px; line-height: 1.7; }
.lead-history-content p { margin: 4px 0 0; color: #697384; font-size: 11px; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; }
.needs-facts { display: grid; gap: 10px; }
.needs-fact {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid #edf0f4;
  border-radius: 11px;
  background: #fbfcfd;
}
.needs-fact span { color: var(--muted); font-size: 11px; }
.needs-fact strong { color: #29364a; line-height: 1.9; white-space: pre-wrap; overflow-wrap: anywhere; }
.funnel-track {
  display: flex;
  gap: 0;
  min-width: max-content;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
}
.funnel-step {
  flex: 0 0 104px;
  min-width: 104px;
}
.funnel-step small {
  white-space: normal;
  line-height: 1.45;
}
.history-list {
  position: relative;
  display: grid;
  gap: 0;
  padding-right: 15px;
}
.history-list::before {
  content: "";
  position: absolute;
  top: 9px;
  right: 4px;
  bottom: 9px;
  width: 2px;
  border-radius: 2px;
  background: #dce5ee;
}
.history-item {
  position: relative;
  display: grid;
  grid-template-columns: 115px minmax(0, 1fr) minmax(90px, auto);
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 8px 17px 8px 0;
  border-bottom: 1px solid #f0f2f5;
}
.history-item::before {
  content: "";
  position: absolute;
  right: 0;
  top: 18px;
  width: 10px;
  height: 10px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 1px #9eb7cd;
}
.history-item:last-child { border-bottom: 0; }
.followup-item { align-items: flex-start; }
.followup-copy { flex: 1; min-width: 0; display: grid; gap: 2px; }
.followup-copy small { white-space: normal; line-height: 1.6; }
.contact-choice-grid { display: grid; gap: 10px; }
.contact-choice-grid .button { justify-content: space-between; }
.contact-choice-grid .button span { display: block; direction: ltr; font-size: 11px; opacity: .7; }
.field-help { color: var(--muted); font-size: 10px; font-weight: 400; }
.form-actions { flex-wrap: wrap; }

@media (max-width: 1050px) {
  .detail-grid { grid-template-columns: 1fr; }
  .product-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .lead-summary { grid-template-columns: repeat(3, minmax(0,1fr)); }
}
@media (max-width: 760px) {
  .content-wrap { padding-bottom: 84px; }
  .topbar-title h1 { max-width: 70vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .detail-header { align-items: stretch; flex-direction: column; }
  .detail-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .detail-actions .button { width: 100%; min-width: 0; }
  .lead-summary { grid-template-columns: repeat(2, minmax(0,1fr)); padding: 14px; }
  .info-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .info-grid > div { overflow-wrap: anywhere; }
  .panel-header { padding: 14px 15px; }
  .panel-inner { padding: 15px; }
  .lead-path { margin-inline: -15px; padding-inline: 15px; }
  .lead-path-track { min-width: 690px; }
  .lead-path-step { flex-basis: 82px; min-width: 82px; }
  .lead-path-label { max-width: 78px; font-size: 9px; }
  .lead-history-item { grid-template-columns: 30px minmax(0, 1fr); gap: 9px; }
  .funnel-track { margin-inline: -15px; padding-inline: 15px; }
  .funnel-step { flex-basis: 88px; min-width: 88px; padding-inline: 3px; }
  .funnel-step:not(:last-child)::after { right: calc(-50% + 7px); left: calc(50% + 7px); }
  .history-item {
    grid-template-columns: 1fr;
    gap: 1px;
    padding: 8px 17px 10px 0;
  }
  .history-item small { margin-top: 2px; }
  .assignment-form { width: 100%; justify-content: stretch; }
  .assignment-form select, .assignment-form input, .assignment-form .button { flex: 1 1 100%; width: 100%; max-width: none; min-height: 39px; }
  .followup-item .icon-button { flex: 0 0 auto; }
  .table-card table { min-width: 640px; }
  .product-grid { grid-template-columns: 1fr; }
  .report-filter { align-items: stretch; flex-direction: column; }
  .report-filter label { width: 100%; }
  .score-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .funnel-report-row { grid-template-columns: minmax(130px, .8fr) 35px minmax(70px,1fr); }
  .mobile-nav { position: fixed; z-index: 12; right: 10px; bottom: 10px; left: 10px; display: grid; grid-template-columns: repeat(5,1fr); padding: 6px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,255,255,.96); box-shadow: 0 12px 30px rgba(23,38,58,.15); backdrop-filter: blur(8px); }
  .mobile-nav .nav-item { min-height: 48px; padding: 3px; display: grid; justify-items: center; gap: 1px; border-radius: 10px; font-size: 9px; }
  .mobile-nav .nav-item svg { width: 18px; height: 18px; }
}
