:root {
  --sidebar-bg: #1a2744;
  --sidebar-w: 230px;
  --accent: #2563eb;
  --topbar-h: 60px;
}

* { box-sizing: border-box; }

body {
  background: #f0f2f5;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  margin: 0;
}

/* ── Layout ── */
.wrapper { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: #fff;
  position: fixed;
  height: 100vh;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-brand {
  padding: 18px 20px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .3px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-brand i { font-size: 1.3rem; color: #60a5fa; }

.sidebar-nav { list-style: none; padding: 10px 0; margin: 0; flex: 1; }

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: .875rem;
  transition: background .15s, color .15s;
}
.sidebar-nav li a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav li.active a {
  background: rgba(96,165,250,.12);
  color: #fff;
  border-left: 3px solid #60a5fa;
}

.sidebar-section {
  padding: 14px 20px 4px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(255,255,255,.3);
}

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: .72rem;
  color: rgba(255,255,255,.3);
}

/* ── Main ── */
#main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.top-bar {
  background: #fff;
  height: var(--topbar-h);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 50;
}
.top-bar h5 { font-weight: 600; color: #1e293b; font-size: .95rem; }

.content-area { padding: 24px; flex: 1; }

/* ── Stat Cards ── */
.stat-card {
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.stat-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: #64748b;
  margin-bottom: 6px;
}
.stat-value {
  font-size: 1.7rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.1;
}
.stat-unit { font-size: .95rem; font-weight: 400; color: #94a3b8; margin-left: 2px; }
.stat-note { font-size: .75rem; color: #94a3b8; margin-top: 4px; }
.stat-card.success .stat-value { color: #16a34a; }
.stat-card.accent .stat-value { color: var(--accent); }

/* ── CRM Card ── */
.crm-card {
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  overflow: hidden;
}
.crm-card .card-header {
  background: #fff;
  padding: 13px 20px;
  font-weight: 600;
  font-size: .875rem;
  color: #1e293b;
  border-bottom: 1px solid #f1f5f9;
}
.crm-card.border-danger { border-color: #fecaca; }

/* ── Table ── */
.crm-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.crm-table th {
  background: #f8fafc;
  padding: 9px 16px;
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #64748b;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}
.crm-table td {
  padding: 11px 16px;
  border-bottom: 1px solid #f1f5f9;
  color: #374151;
  vertical-align: middle;
}
.crm-table tr:last-child td { border-bottom: none; }
.crm-table tr:hover td { background: #f8fafc; }
.crm-table tfoot td {
  padding: 11px 16px;
  border-top: 2px solid #e2e8f0;
}
.crm-table a { color: var(--accent); text-decoration: none; }
.crm-table a:hover { text-decoration: underline; }

/* ── Badges ── */
.badge-status {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: capitalize;
}
.badge-status.active    { background: #dcfce7; color: #15803d; }
.badge-status.inactive  { background: #f1f5f9; color: #64748b; }
.badge-status.licensing { background: #fef9c3; color: #854d0e; }
.badge-status.contracting { background: #dbeafe; color: #1d4ed8; }
.badge-status.suspended { background: #fee2e2; color: #dc2626; }

.badge-product {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: .7rem;
  font-weight: 700;
}
.badge-product.standard { background: #dbeafe; color: #1d4ed8; }
.badge-product.gi       { background: #f3e8ff; color: #7c3aed; }

.badge-policy {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: .72rem;
  font-weight: 600;
}
.badge-policy.active    { background: #dcfce7; color: #15803d; }
.badge-policy.pending   { background: #fef9c3; color: #854d0e; }
.badge-policy.cancelled { background: #fee2e2; color: #dc2626; }
.badge-policy.lapsed    { background: #f1f5f9; color: #64748b; }

/* ── Alert rows ── */
.alert-section-label {
  padding: 8px 16px 4px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: #94a3b8;
}
.alert-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid #f1f5f9;
}
.alert-row:last-child { border-bottom: none; }
.alert-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.alert-dot.red    { background: #ef4444; }
.alert-dot.yellow { background: #f59e0b; }

/* ── Production bar ── */
.production-bar {
  background: #e2e8f0;
  border-radius: 3px;
  height: 5px;
  overflow: hidden;
  width: 100px;
}
.production-bar-fill {
  background: var(--accent);
  height: 100%;
  border-radius: 3px;
}

/* ── Agent tree ── */
.tree-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  margin: 2px 0;
}
.tree-item:hover { background: #eff6ff; }
.tree-name { font-weight: 500; font-size: .875rem; color: #1e293b; }
.tree-stats { margin-left: auto; font-size: .78rem; color: #64748b; }
.tree-toggle-btn {
  background: none; border: none; padding: 0 2px; cursor: pointer; color: #94a3b8;
  font-size: .7rem;
  display: flex; align-items: center;
}
.tree-toggle-btn:hover { color: var(--accent); }
.tree-leaf-dot { width: 16px; display: inline-block; text-align: center; color: #cbd5e1; font-size: .5rem; }

/* ── Forms ── */
.form-card {
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  padding: 28px;
  max-width: 720px;
}
.form-label { font-size: .875rem; font-weight: 500; color: #374151; }
.form-section-title {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #94a3b8;
  padding-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 16px;
  margin-top: 4px;
}

/* ── Agent profile ── */
.agent-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1.3rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.profile-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.profile-table td { padding: 5px 0; vertical-align: top; }
.profile-label { color: #94a3b8; width: 90px; font-size: .8rem; padding-top: 6px; }

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: .875rem;
}
.stat-row:last-child { border-bottom: none; }
.stat-row-label { color: #64748b; }
.stat-row-value { font-weight: 600; color: #1e293b; }

/* ── Utility ── */
.text-money {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #94a3b8;
}
.empty-state i { display: block; font-size: 2.5rem; margin-bottom: 10px; }
.empty-state p { margin-bottom: 14px; font-size: .875rem; }
