:root{
  --canvas:#F4F5FB;
  --surface:#FFFFFF;
  --ink:#1A1A2E;
  --muted:#6E7191;
  --border:#E3E4F0;
  --primary:#4B3F9E;
  --primary-dark:#362C6E;
  --primary-tint:#EDEAFB;
  --amber:#F5A623;
  --amber-tint:#FDF1DD;
  --teal:#16A394;
  --teal-tint:#E3F7F4;
  --danger:#E4574C;
  --danger-tint:#FBE9E8;
  --radius:14px;
  --shadow: 0 1px 2px rgba(26,26,46,.04), 0 8px 24px rgba(26,26,46,.06);
  --shadow-lg: 0 20px 60px rgba(26,26,46,.18);
}
*{box-sizing:border-box;}
html,body{margin:0;padding:0;}
body{
  background:var(--canvas);
  color:var(--ink);
  font-family:'Inter',sans-serif;
  font-size:14px;
  -webkit-font-smoothing:antialiased;
}
.mono{font-family:'IBM Plex Mono',monospace; letter-spacing:-.2px;}
.ic{width:18px;height:18px;display:inline-block;vertical-align:middle;}
.ic-sm{width:13px;height:13px;}
button{font-family:inherit;cursor:pointer;}
select,input,textarea{font-family:inherit;}

/* ===== layout shell ===== */
.app{display:flex; min-height:100vh;}
.rail{
  width:72px; flex-shrink:0;
  background:var(--primary-dark);
  display:flex; flex-direction:column; align-items:center;
  padding:20px 0; position:sticky; top:0; height:100vh;
}
.rail-brand{
  width:38px;height:38px;border-radius:10px;
  background:var(--amber); color:var(--primary-dark);
  font-family:'Space Grotesk',sans-serif; font-weight:700; font-size:19px;
  display:flex; align-items:center; justify-content:center; margin-bottom:32px;
}
.rail-brand span{color:var(--primary-dark);}
.rail-nav{display:flex; flex-direction:column; gap:6px; flex:1;}
.rail-bottom{display:flex; flex-direction:column; gap:6px;}
.rail-btn{
  width:44px;height:44px; border:none; border-radius:11px; background:transparent;
  color:rgba(255,255,255,.55); display:flex; align-items:center; justify-content:center;
  transition:background .15s, color .15s;
  position:relative;
}
.rail-btn:hover{background:rgba(255,255,255,.08); color:#fff;}
.rail-btn.active{background:var(--amber); color:var(--primary-dark);}

.main{flex:1; min-width:0; padding:28px 32px 40px;}

/* ===== topbar ===== */
.topbar{display:flex; align-items:center; gap:24px; margin-bottom:24px;}
.eyebrow{margin:0 0 2px; font-size:12px; color:var(--muted); font-weight:500;}
.topbar-left h1{margin:0; font-family:'Space Grotesk',sans-serif; font-size:26px; font-weight:600;}
.topbar-search{
  flex:1; max-width:420px; display:flex; align-items:center; gap:10px;
  background:var(--surface); border:1px solid var(--border); border-radius:10px;
  padding:10px 14px; color:var(--muted);
}
.topbar-search input{border:none; outline:none; flex:1; font-size:14px; background:transparent; color:var(--ink);}
.topbar-right{display:flex; align-items:center; gap:14px; margin-left:auto;}
.icon-btn{
  width:38px;height:38px; border-radius:10px; border:1px solid var(--border); background:var(--surface);
  display:flex; align-items:center; justify-content:center; position:relative; color:var(--ink);
}
.icon-btn .badge{
  position:absolute; top:-6px; right:-6px; background:var(--danger); color:#fff;
  font-size:10px; font-weight:700; border-radius:20px; padding:1px 5px; min-width:16px; text-align:center;
}
.avatar{
  border-radius:50%; color:#fff; display:flex; align-items:center; justify-content:center;
  font-family:'Space Grotesk',sans-serif; font-weight:600; flex-shrink:0;
}
.avatar.sm{width:38px;height:38px;font-size:13px;}
.avatar.xs{width:24px;height:24px;font-size:10px;}
.avatar.lg{width:56px;height:56px;font-size:19px;}

/* ===== stats ===== */
.stats{display:grid; grid-template-columns:repeat(4,1fr); gap:16px; margin-bottom:20px;}
.stat-card{
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius);
  padding:18px 20px; display:flex; align-items:center; gap:14px; box-shadow:var(--shadow);
}
.stat-icon{
  width:42px;height:42px;border-radius:11px; background:color-mix(in srgb, var(--c) 14%, white);
  color:var(--c); display:flex; align-items:center; justify-content:center; flex-shrink:0;
}
.stat-num{margin:0; font-family:'Space Grotesk',sans-serif; font-size:24px; font-weight:700; line-height:1;}
.stat-label{margin:4px 0 0; font-size:12.5px; color:var(--muted);}

/* ===== filter bar ===== */
.filterbar{
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius);
  padding:14px 18px; display:flex; align-items:end; gap:18px; margin-bottom:16px; flex-wrap:wrap;
  box-shadow:var(--shadow);
}
.filter-group{display:flex; flex-direction:column; gap:5px; min-width:150px;}
.filter-group label{font-size:11px; color:var(--muted); font-weight:600; text-transform:uppercase; letter-spacing:.03em;}
.filter-group select, .filter-group input{
  border:1px solid var(--border); border-radius:9px; padding:8px 10px; font-size:13.5px; color:var(--ink);
  background:var(--canvas);
}
.filter-actions{margin-left:auto;}

/* ===== buttons ===== */
.btn{
  display:inline-flex; align-items:center; gap:8px; border-radius:10px; padding:10px 16px;
  font-size:13.5px; font-weight:600; border:1px solid transparent; transition:transform .12s, box-shadow .12s;
}
.btn:active{transform:scale(.97);}
.btn.sm{padding:7px 12px; font-size:12.5px;}
.btn.full{width:100%; justify-content:center;}
.btn .ic{width:16px;height:16px;}
.btn-primary{background:var(--primary); color:#fff;}
.btn-primary:hover{background:var(--primary-dark);}
.btn-outline{background:var(--surface); color:var(--ink); border-color:var(--border);}
.btn-outline:hover{background:var(--canvas);}
.btn-ghost{background:transparent; color:var(--muted); border-color:var(--border);}

/* ===== toolbar ===== */
.toolbar{display:flex; align-items:center; margin-bottom:14px;}
.toolbar-left{display:flex; gap:10px;}
.toolbar-count{margin-left:auto; color:var(--muted); font-size:13px;}

/* ===== table ===== */
.table-wrap{
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius);
  overflow:visible; box-shadow:var(--shadow);
}
.crm-table{width:100%; border-collapse:collapse;}
.crm-table thead th{
  text-align:left; font-size:11.5px; text-transform:uppercase; letter-spacing:.04em;
  color:var(--muted); font-weight:700; padding:14px 16px; border-bottom:1px solid var(--border);
  background:#FAFAFD;
}
.crm-table thead th:first-child{border-top-left-radius:var(--radius);}
.crm-table thead th:last-child{border-top-right-radius:var(--radius);}
.crm-table td{padding:14px 16px; border-bottom:1px solid var(--border); vertical-align:top;}
.crm-table tbody tr:last-child td{border-bottom:none;}
.crm-table tbody tr:hover{background:#FBFAFF;}
.chk{width:36px;}

.lead-name{margin:0; font-weight:600; font-size:14px;}
.lead-mobile{margin:2px 0 0; font-family:'IBM Plex Mono',monospace; font-size:12px; color:var(--muted);}
.lead-meta{margin:2px 0 0; font-size:11px; color:#A3A6C2;}

.course-pill{
  display:inline-block; background:var(--primary-tint); color:var(--primary-dark);
  font-size:12px; font-weight:600; padding:5px 10px; border-radius:20px; white-space:nowrap;
}

.owner{display:flex; align-items:center; gap:8px; font-size:13px; font-weight:500; white-space:nowrap;}

.fu-date{margin:0; font-size:12.5px; font-weight:600;}
.fu-date.muted{color:var(--muted); font-weight:400;}
.fu-add{
  margin-top:6px; width:20px;height:20px; border-radius:50%; background:var(--danger); color:#fff;
  border:none; font-size:14px; line-height:1; display:flex; align-items:center; justify-content:center;
}

.comment-txt{margin:0; max-width:220px; color:var(--muted); font-size:12.5px; line-height:1.4;
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;}

.contact-icons{display:flex; gap:6px;}
.ci{
  width:30px;height:30px; border-radius:8px; border:1px solid var(--border); background:var(--surface);
  display:flex; align-items:center; justify-content:center; color:var(--muted);
}
.ci.mail:hover{color:var(--primary); border-color:var(--primary);}
.ci.call:hover{color:var(--teal); border-color:var(--teal);}
.ci.wa:hover{color:#25D366; border-color:#25D366;}
.ci .ic{width:15px;height:15px;}

.action-cell{position:relative; text-align:right;}
.row-menu{
  display:none; position:absolute; right:12px; top:40px; z-index:20;
  background:var(--surface); border:1px solid var(--border); border-radius:12px;
  box-shadow:var(--shadow-lg); padding:6px; min-width:150px;
}
.row-menu.open{display:block;}
.row-menu button{
  display:flex; align-items:center; gap:10px; width:100%; padding:9px 10px; border:none; background:none;
  border-radius:8px; font-size:13px; color:var(--ink); text-align:left;
}
.row-menu button:hover{background:var(--canvas);}
.row-menu button.danger{color:var(--danger);}

/* ===== learning-path track (signature element) ===== */
.track{display:flex; align-items:center; width:132px;}
.track .dot{
  width:9px;height:9px;border-radius:50%; background:var(--border); flex-shrink:0;
  transition:background .15s, box-shadow .15s; cursor:pointer;
}
.track .dot.filled{background:var(--primary);}
.track .dot.current{
  background:var(--amber); width:12px;height:12px;
  box-shadow:0 0 0 4px var(--amber-tint);
}
.track .seg{flex:1; height:2px; background:var(--border);}
.track .seg.filled{background:var(--primary);}
.track.is-lost .dot, .track.is-lost .seg{opacity:.5;}
.track-label{margin:6px 0 0; font-size:11.5px; font-weight:600; color:var(--muted);}
.track-label.lost{color:var(--danger); display:flex; align-items:center; gap:4px;}
.track.lg{width:100%;}
.track.lg .dot{width:14px;height:14px; cursor:default;}
.track.lg .dot.current{width:18px;height:18px;}

/* ===== pagination ===== */
.pagination{display:flex; align-items:center; justify-content:space-between; margin-top:16px; color:var(--muted); font-size:13px;}
.pg-btns{display:flex; gap:8px;}

/* ===== overlay / drawer / modal ===== */
.overlay{
  position:fixed; inset:0; background:rgba(26,26,46,.35); backdrop-filter:blur(2px);
  opacity:0; pointer-events:none; transition:opacity .2s; z-index:40;
}
.overlay.show{opacity:1; pointer-events:auto;}

.drawer{
  position:fixed; top:0; right: -460px; width:440px; height:100vh; background:var(--surface);
  box-shadow:var(--shadow-lg); z-index:50; transition:right .28s cubic-bezier(.2,.8,.2,1);
  display:flex; flex-direction:column;
}
.drawer.open{right:0;}
.drawer-head{display:flex; align-items:center; justify-content:space-between; padding:20px 24px; border-bottom:1px solid var(--border);}
.drawer-head h3{margin:0; font-family:'Space Grotesk',sans-serif; font-size:18px;}
.drawer-body{padding:24px; overflow-y:auto; flex:1;}
.drawer-hero{display:flex; align-items:center; gap:14px; margin-bottom:24px;}
.drawer-hero h2{margin:0; font-family:'Space Grotesk',sans-serif; font-size:19px;}
.drawer-course{margin:3px 0 0; color:var(--muted); font-size:13px;}
.drawer-grid{display:grid; grid-template-columns:1fr 1fr; gap:16px 20px; margin-bottom:26px;}
.drawer-grid span{display:block; font-size:11px; text-transform:uppercase; letter-spacing:.03em; color:var(--muted); font-weight:700; margin-bottom:4px;}
.drawer-grid p{margin:0; font-size:13.5px; font-weight:500;}
.link-inline{color:var(--primary); display:flex; align-items:center; gap:5px; text-decoration:none; font-weight:600;}
.drawer-section{margin-bottom:22px; padding-top:18px; border-top:1px solid var(--border);}
.drawer-section h4{margin:0 0 14px; font-size:13px; text-transform:uppercase; letter-spacing:.03em; color:var(--muted);}
.track-legend{display:flex; justify-content:space-between; margin-top:8px; font-size:10.5px; color:var(--muted);}
.drawer-tabs{display:flex; gap:6px; border-bottom:1px solid var(--border); margin-bottom:18px;}
.dtab{background:none; border:none; padding:10px 4px; font-size:13px; font-weight:600; color:var(--muted); border-bottom:2px solid transparent; margin-right:16px;}
.dtab.active{color:var(--primary); border-color:var(--primary);}
.dtab-panel{display:none;}
.dtab-panel.active{display:block;}
.note-item{background:var(--canvas); border-radius:10px; padding:12px 14px; font-size:13px; color:var(--ink); margin:0 0 14px;}
.note-input{width:100%; border:1px solid var(--border); border-radius:10px; padding:10px 12px; font-size:13px; resize:vertical; min-height:70px; margin-bottom:10px;}
.status-row{display:flex; justify-content:space-between; align-items:center; padding:10px 0; border-bottom:1px solid var(--border); font-size:13.5px;}
.status-pill{font-size:11.5px; font-weight:700; padding:4px 10px; border-radius:20px;}
.status-pill.pending{background:var(--amber-tint); color:#9A6A0C;}
.status-pill.draft{background:#F1F1F6; color:var(--muted);}
.status-pill.locked{background:var(--danger-tint); color:var(--danger);}

.modal{
  position:fixed; top:50%; left:50%; transform:translate(-50%,-46%); width:560px; max-width:92vw;
  background:var(--surface); border-radius:18px; box-shadow:var(--shadow-lg); z-index:60;
  opacity:0; pointer-events:none; transition:opacity .2s, transform .2s; max-height:88vh; display:flex; flex-direction:column;
}
.modal.open{opacity:1; pointer-events:auto; transform:translate(-50%,-50%);}
.modal-head{display:flex; align-items:center; justify-content:space-between; padding:22px 26px; border-bottom:1px solid var(--border);}
.modal-head h3{margin:0; font-family:'Space Grotesk',sans-serif; font-size:18px;}
.modal-body{padding:22px 26px; overflow-y:auto;}
.form-row{margin-bottom:16px; display:flex; flex-direction:column; gap:6px;}
.form-row.two{flex-direction:row; gap:16px;}
.form-row.two > div{flex:1; display:flex; flex-direction:column; gap:6px;}
.form-row label{font-size:12px; font-weight:700; color:var(--muted); text-transform:uppercase; letter-spacing:.03em;}
.form-row input, .form-row select, .form-row textarea{
  border:1px solid var(--border); border-radius:10px; padding:10px 12px; font-size:13.5px; background:var(--canvas); color:var(--ink);
}
.form-row textarea{min-height:70px; resize:vertical;}
.modal-actions{display:flex; justify-content:flex-end; gap:10px; margin-top:6px;}

/* ===== responsive ===== */
@media (max-width:1200px){
  .stats{grid-template-columns:repeat(2,1fr);}
}
@media (max-width:900px){
  .rail{position:fixed; bottom:0; top:auto; width:100%; height:64px; flex-direction:row; padding:0 12px;}
  .rail-nav{flex-direction:row; flex:1; justify-content:space-around;}
  .rail-brand{display:none;}
  .rail-bottom{display:none;}
  .main{padding:20px 16px 90px;}
  .comment-txt{max-width:140px;}
}



.drawer.active{
    right:0;
}

.drawer-overlay{
    position:fixed;
    inset:0;
    background:rgba(26,26,46,.35);
    backdrop-filter:blur(2px);
    opacity:0;
    pointer-events:none;
    transition:.2s;
    z-index:40;
}

.drawer-overlay.active{
    opacity:1;
    pointer-events:auto;
}

.drawer-header{
    padding:20px 25px;
    border-bottom:1px solid #eceff5;
    display:flex;
    justify-content:space-between;
    align-items:center;
    background:#fff;
}

.drawer-body{
    padding:30px;
    overflow-y:auto;
}

.drawer-top{
    text-align:center;
    margin-bottom:30px;
}

.drawer-icon{
    width:75px;
    height:75px;
    margin:auto;
    border-radius:18px;
    background:#eef2ff;
    color:#4f46e5;
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:30px;
    margin-bottom:18px;
}

.drawer-top h3{
    font-size:24px;
    font-weight:700;
    margin-bottom:8px;
}

.drawer-top p{
    color:#7b8190;
    font-size:14px;
    margin-bottom:0;
}

.form-group{
    margin-bottom:24px;
}

.form-group label{
    display:block;
    margin-bottom:8px;
    font-weight:600;
    color:#374151;
}

.custom-input{
    height:48px;
    border-radius:12px;
    border:1px solid #d9dde8;
    padding:0 15px;
    font-size:15px;
    transition:.25s;
    box-shadow:none;
}

.custom-input:focus{
    border-color:#4f46e5;
    box-shadow:0 0 0 .2rem rgba(79,70,229,.15);
}

.drawer-footer{
    position:sticky;
    bottom:0;
    background:#fff;
    padding:20px 30px;
    border-top:1px solid #eceff5;
    display:flex;
    justify-content:flex-end;
    gap:12px;
}

.drawer-footer .btn{
    min-width:140px;
    height:46px;
    border-radius:12px;
    font-weight:600;
}

.drawer-close{
    background:none;
    border:none;
    font-size:28px;
    color:#777;
}

.drawer-close:hover{
    color:#000;
}