:root{
  --crm-bg:#f4f7fb;
  --crm-sidebar:#111827;
  --crm-sidebar-2:#1f2937;
  --crm-accent:#0d6efd;
  --crm-text:#0f172a;
  --crm-muted:#6b7280;
  --crm-card:#ffffff;
  --crm-border:#e5e7eb;
}
*{box-sizing:border-box}
body.crm-body{background:var(--crm-bg);color:var(--crm-text);min-height:100vh}
.crm-shell{display:flex;min-height:100vh}
.crm-sidebar{width:270px;background:linear-gradient(180deg,var(--crm-sidebar),var(--crm-sidebar-2));color:#fff;position:sticky;top:0;height:100vh;padding:1.25rem 1rem;overflow-y:auto}
.crm-brand{font-size:1.15rem;font-weight:700;letter-spacing:.3px;margin-bottom:1rem}
.crm-brand small{display:block;color:#9ca3af;font-weight:500}
.crm-nav a{display:flex;align-items:center;gap:.75rem;color:#e5e7eb;text-decoration:none;padding:.8rem .9rem;border-radius:.85rem;margin-bottom:.35rem;font-weight:600}
.crm-nav a:hover,.crm-nav a.active{background:rgba(255,255,255,.09);color:#fff}
.crm-main{flex:1;min-width:0}
.crm-topbar{background:#fff;border-bottom:1px solid var(--crm-border);padding:1rem 1.4rem;display:flex;align-items:center;justify-content:space-between;gap:1rem;position:sticky;top:0;z-index:10}
.crm-content{padding:1.4rem}
.crm-card{background:var(--crm-card);border:1px solid var(--crm-border);border-radius:1rem;box-shadow:0 6px 20px rgba(15,23,42,.04)}
.crm-card .card-header{background:#fff;border-bottom:1px solid var(--crm-border);font-weight:700;padding:1rem 1.15rem;border-radius:1rem 1rem 0 0}
.crm-kpi{padding:1.2rem}
.crm-kpi .label{font-size:.85rem;color:var(--crm-muted);font-weight:600}
.crm-kpi .value{font-size:1.9rem;font-weight:800;line-height:1.1;margin-top:.2rem}
.crm-pagehead{display:flex;justify-content:space-between;align-items:flex-start;gap:1rem;margin-bottom:1.2rem}
.crm-pagehead h1{font-size:1.65rem;font-weight:800;margin:0}
.crm-pagehead p{margin:.35rem 0 0;color:var(--crm-muted)}
.crm-table thead th{font-size:.82rem;text-transform:uppercase;letter-spacing:.03em;color:#64748b;background:#f8fafc;border-bottom:1px solid var(--crm-border)}
.crm-table td,.crm-table th{vertical-align:middle;padding:.95rem .9rem}
.crm-badge{display:inline-flex;align-items:center;padding:.38rem .62rem;border-radius:999px;font-size:.75rem;font-weight:700}
.crm-badge.soft{background:#eff6ff;color:#1d4ed8}
.crm-badge.ok{background:#ecfdf5;color:#047857}
.crm-badge.warn{background:#fff7ed;color:#c2410c}
.crm-badge.danger{background:#fef2f2;color:#b91c1c}
.crm-muted{color:var(--crm-muted)}
.crm-stat-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:1rem}
.crm-actions{display:flex;gap:.6rem;flex-wrap:wrap}
.crm-detail-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:1rem}
.crm-field{background:#f8fafc;border:1px solid var(--crm-border);border-radius:.9rem;padding:1rem}
.crm-field .k{font-size:.78rem;color:var(--crm-muted);text-transform:uppercase;font-weight:700;margin-bottom:.25rem}
.crm-field .v{font-size:1rem;font-weight:600;word-break:break-word}
.crm-timeline{position:relative;padding-left:1.4rem}
.crm-timeline:before{content:'';position:absolute;left:.35rem;top:.2rem;bottom:.2rem;width:2px;background:#dbeafe}
.crm-event{position:relative;padding:0 0 1rem 1rem}
.crm-event:before{content:'';position:absolute;left:-.15rem;top:.35rem;width:.75rem;height:.75rem;border-radius:50%;background:var(--crm-accent)}
.crm-login-wrap{min-height:100vh;display:flex;align-items:center;justify-content:center;background:radial-gradient(circle at top left,#dbeafe,#f4f7fb 40%,#eef2ff)}
.crm-login-card{width:min(470px,92vw);padding:2rem;border-radius:1.2rem;background:#fff;border:1px solid var(--crm-border);box-shadow:0 18px 50px rgba(15,23,42,.12)}
.crm-toolbar{display:flex;gap:.75rem;flex-wrap:wrap;align-items:center}
.crm-callout{border-radius:1rem;padding:1rem 1.1rem;border:1px solid var(--crm-border);background:#fff}
@media (max-width:1200px){.crm-stat-grid,.crm-detail-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media (max-width:992px){.crm-sidebar{display:none}.crm-content{padding:1rem}.crm-topbar{padding:1rem}.crm-pagehead{flex-direction:column}.crm-stat-grid,.crm-detail-grid{grid-template-columns:1fr}}


.crm-main{display:flex;flex-direction:column;min-width:0}
.crm-content{width:100%;max-width:1400px;margin:0 auto;padding:24px}
.crm-pagehead{display:flex;justify-content:space-between;align-items:flex-start;gap:16px;flex-wrap:wrap;margin-bottom:20px}
.crm-actions{display:flex;gap:10px;flex-wrap:wrap}
.crm-toolbar{display:flex;gap:12px;align-items:center}
.crm-detail-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:16px}
.crm-pager{display:flex;justify-content:space-between;align-items:center;gap:16px;margin-top:16px;padding-top:12px;border-top:1px solid #e9ecef}
@media (max-width: 1200px){.crm-detail-grid{grid-template-columns:repeat(2,minmax(0,1fr));}}
@media (max-width: 768px){.crm-content{padding:16px}.crm-detail-grid{grid-template-columns:1fr}.crm-toolbar,.crm-pagehead,.crm-pager{flex-direction:column;align-items:stretch}}


.crm-topbar{
  padding: 0;
}
.crm-topbar-inner{
  width:100%;
  max-width:1400px;
  margin:0 auto;
  padding:1rem 1.4rem;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:1rem;
}
.crm-content{
  width:100%;
  max-width:1400px;
  margin:0 auto;
  padding:24px;
}
.crm-card .card-body{
  padding:1.15rem;
}
.crm-toolbar{
  display:flex;
  gap:12px;
  align-items:center;
  justify-content:flex-start;
}
.crm-toolbar .form-control,
.crm-toolbar .form-select,
.crm-toolbar .btn{
  min-height:38px;
}
.crm-table{
  margin-bottom:0;
}
.crm-table td:last-child,
.crm-table th:last-child{
  width:1%;
  white-space:nowrap;
}
.crm-detail-grid{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:16px;
}
.crm-pagehead{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:16px;
  flex-wrap:wrap;
}
@media (max-width: 992px){
  .crm-topbar-inner{
    padding:1rem;
  }
}
@media (max-width: 768px){
  .crm-toolbar{
    flex-direction:column;
    align-items:stretch;
  }
  .crm-toolbar .ms-auto{
    margin-left:0 !important;
  }
}


/* Header refresh */
.crm-topbar{
  padding: 0;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(10px);
}
.crm-topbar-inner{
  width:100%;
  max-width:1400px;
  margin:0 auto;
  padding:.9rem 1.4rem;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:1rem;
}
.crm-topbar-left{display:flex;align-items:center;gap:1rem;min-width:0;flex:1}
.crm-brand-chip{display:flex;align-items:center;gap:.8rem;min-width:220px}
.crm-brand-mark{
  width:42px;height:42px;border-radius:14px;
  background:linear-gradient(135deg,#0f172a,#2563eb);
  color:#fff;display:grid;place-items:center;font-size:1rem;font-weight:800;
  box-shadow:0 10px 24px rgba(37,99,235,.18);
}
.crm-brand-copy{min-width:0}
.crm-brand-title{font-size:1rem;font-weight:800;line-height:1.1}
.crm-brand-sub{font-size:.78rem;color:var(--crm-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.crm-quicksearch{display:flex;align-items:center;gap:.6rem;flex:1;max-width:620px}
.crm-quicksearch-field{position:relative;flex:1}
.crm-quicksearch-field .form-control{
  min-height:46px;padding-left:2.8rem;padding-right:8.7rem;border-radius:999px;
  border:1px solid #dbe3ef;background:#f8fbff;box-shadow:none;
}
.crm-quicksearch-field .form-control:focus{
  background:#fff;border-color:#93c5fd;box-shadow:0 0 0 .2rem rgba(59,130,246,.12);
}
.crm-quicksearch-icon{position:absolute;left:1rem;top:50%;transform:translateY(-50%);color:#64748b;font-size:1rem}
.crm-quicksearch-hint{position:absolute;right:1rem;top:50%;transform:translateY(-50%);font-size:.75rem;color:#94a3b8;font-weight:700}
.crm-topbar-right{display:flex;align-items:center;gap:.75rem;flex-shrink:0}
.crm-user-pill{
  display:flex;align-items:center;gap:.7rem;padding:.45rem .75rem .45rem .45rem;
  background:#fff;border:1px solid var(--crm-border);border-radius:999px;
  box-shadow:0 8px 22px rgba(15,23,42,.05);
}
.crm-user-avatar{
  width:38px;height:38px;border-radius:50%;display:grid;place-items:center;
  background:#e0e7ff;color:#1e3a8a;font-weight:800;text-transform:uppercase;
}
.crm-user-meta{line-height:1.1}
.crm-user-meta .name{font-size:.92rem;font-weight:800}
.crm-user-meta .role{font-size:.76rem;color:var(--crm-muted);text-transform:capitalize}
.crm-logout-btn{border-radius:999px;padding:.65rem 1rem;font-weight:700}
.crm-pagehead{
  background:linear-gradient(180deg,rgba(255,255,255,.95),rgba(255,255,255,.78));
  border:1px solid var(--crm-border);border-radius:1.15rem;padding:1rem 1.1rem;
  box-shadow:0 10px 30px rgba(15,23,42,.04);
}
.crm-pagehead h1{font-size:1.75rem}
.crm-kpi{padding:1.5rem}
.crm-kpi .label{font-size:1.05rem;color:#64748b;font-weight:700}
.crm-kpi .value{font-size:3.1rem;font-weight:900;letter-spacing:-.03em}
.crm-card{border-radius:1.2rem;box-shadow:0 10px 30px rgba(15,23,42,.05)}
.crm-card .card-header{padding:1.1rem 1.2rem;font-size:1.25rem}
.crm-phone-help{font-size:.8rem;color:var(--crm-muted);margin-top:.45rem}
@media (max-width: 1100px){
  .crm-topbar-inner{flex-wrap:wrap;align-items:stretch}
  .crm-topbar-left,.crm-topbar-right{width:100%}
  .crm-topbar-right{justify-content:space-between}
  .crm-quicksearch{max-width:none}
}
@media (max-width: 768px){
  .crm-topbar-inner{padding:1rem}
  .crm-brand-chip{min-width:0}
  .crm-quicksearch{flex-direction:column;align-items:stretch}
  .crm-quicksearch .btn{width:100%}
  .crm-quicksearch-field .form-control{padding-right:1rem}
  .crm-quicksearch-hint{display:none}
  .crm-user-pill{flex:1}
}
