/* =============================================
   SalesTool Pro – Design System
   ============================================= */

/* ── Tokens ───────────────────────────────── */
:root {
  /* Brand */
  --brand:         #4f46e5;
  --brand-hover:   #4338ca;
  --brand-light:   #eef2ff;
  --brand-muted:   #c7d2fe;

  /* Semantic */
  --success:       #10b981;
  --success-bg:    #d1fae5;
  --warning:       #f59e0b;
  --warning-bg:    #fef3c7;
  --danger:        #ef4444;
  --danger-bg:     #fee2e2;
  --info:          #3b82f6;
  --info-bg:       #dbeafe;

  /* Neutrals */
  --gray-50:       #f9fafb;
  --gray-100:      #f3f4f6;
  --gray-200:      #e5e7eb;
  --gray-300:      #d1d5db;
  --gray-400:      #9ca3af;
  --gray-500:      #6b7280;
  --gray-600:      #4b5563;
  --gray-700:      #374151;
  --gray-800:      #1f2937;
  --gray-900:      #111827;
  --white:         #ffffff;

  /* Sidebar */
  --sidebar-bg:    #0f172a;
  --sidebar-hover: rgba(255,255,255,.06);
  --sidebar-active:rgba(255,255,255,.12);
  --sidebar-text:  rgba(255,255,255,.65);
  --sidebar-text-active: #ffffff;
  --sidebar-border:rgba(255,255,255,.08);

  /* Surface */
  --surface:       #ffffff;
  --surface-raised:#ffffff;
  --bg:            #f1f5f9;

  /* Layout */
  --sidebar-w:     220px;
  --topbar-h:      56px;
  --radius-sm:     6px;
  --radius:        8px;
  --radius-lg:     12px;

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.04);
  --shadow-xl: 0 20px 25px rgba(0,0,0,.1),  0 8px 10px rgba(0,0,0,.04);
}

/* ── Reset ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--gray-800);
  display: flex;
  height: 100vh;
  overflow: hidden;
}
a { color: var(--brand); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ── Sidebar ───────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar-brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid var(--sidebar-border);
  color: var(--white);
  font-size: .9rem;
  font-weight: 700;
  letter-spacing: -.2px;
  flex-shrink: 0;
}

.brand-logo {
  width: 28px;
  height: 28px;
  background: var(--brand);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-section {
  padding: 20px 10px 4px;
}

.sidebar-section-label {
  font-size: .67rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--sidebar-text);
  padding: 0 8px;
  margin-bottom: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--sidebar-text);
  font-size: .85rem;
  font-weight: 500;
  transition: background .12s, color .12s;
  user-select: none;
  margin-bottom: 1px;
}

.nav-item:hover { background: var(--sidebar-hover); color: var(--white); }
.nav-item.active { background: var(--sidebar-active); color: var(--sidebar-text-active); }
.nav-item.active .nav-icon svg { opacity: 1; }

.nav-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: .7;
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon { opacity: 1; }

.sidebar-footer {
  margin-top: auto;
  padding: 12px 10px;
  border-top: 1px solid var(--sidebar-border);
}

.agent-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--sidebar-active);
  cursor: pointer;
}

.agent-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand);
  color: white;
  font-size: .75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.agent-info { overflow: hidden; }

.agent-name {
  font-size: .8rem;
  font-weight: 600;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-role {
  font-size: .7rem;
  color: var(--sidebar-text);
  margin-top: 1px;
}

/* ── Top bar ───────────────────────────────── */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.top-bar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
}

.top-bar h1 {
  font-size: .95rem;
  font-weight: 600;
  color: var(--gray-900);
  flex: 1;
}

.topbar-agent {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .8rem;
  color: var(--gray-500);
}

.topbar-agent label { font-weight: 500; white-space: nowrap; }

#agent-id-input {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: .8rem;
  color: var(--gray-800);
  background: var(--gray-50);
  width: 200px;
  transition: border-color .15s, box-shadow .15s;
}

#agent-id-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
  background: var(--white);
}

/* ── Content ───────────────────────────────── */
#main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ── Page header ───────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-header-left h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gray-900);
}

.page-header-left p {
  font-size: .8rem;
  color: var(--gray-500);
  margin-top: 2px;
}

/* ── Stat tiles ────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.stat-label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-400);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.2;
  margin-top: 6px;
  letter-spacing: -.03em;
}

.stat-sub {
  font-size: .72rem;
  color: var(--gray-400);
  margin-top: 4px;
}

.stat-tile.accent { border-left: 3px solid var(--brand); }
.stat-tile.accent .stat-value { color: var(--brand); }

/* ── Cards ─────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card + .card { margin-top: 16px; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
}

.card-title {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-500);
}

.card-body { padding: 20px; }

/* ── Tables ────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}

thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--gray-400);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: background .1s;
}

tbody tr:hover { background: #fafbff; }
tbody tr:last-child { border-bottom: none; }

td {
  padding: 12px 16px;
  vertical-align: middle;
  color: var(--gray-700);
}

td strong { color: var(--gray-900); font-weight: 600; }

td.muted { color: var(--gray-400); font-size: .82rem; }

/* ── Badges ────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 99px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}

.badge::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.badge-active    { background: var(--success-bg); color: #065f46; }
.badge-converted { background: var(--info-bg);    color: #1e40af; }
.badge-inactive  { background: var(--gray-100);   color: var(--gray-500); }
.badge-lost      { background: var(--danger-bg);  color: #991b1b; }
.badge-junior    { background: var(--gray-100);   color: var(--gray-600); }
.badge-senior    { background: var(--brand-light);color: #3730a3; }
.badge-manager   { background: var(--info-bg);    color: #1e40af; }
.badge-director  { background: #fdf4ff;           color: #6b21a8; }

/* ── Probability bar ───────────────────────── */
.prob-cell { display: flex; align-items: center; gap: 8px; }

.prob-bar {
  width: 60px;
  height: 5px;
  background: var(--gray-200);
  border-radius: 99px;
  overflow: hidden;
  flex-shrink: 0;
}

.prob-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--brand), #818cf8);
  transition: width .4s ease;
}

.prob-label { font-size: .8rem; color: var(--gray-600); font-weight: 500; min-width: 30px; }

/* ── Buttons ───────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: .83rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .13s, box-shadow .13s, opacity .13s;
  white-space: nowrap;
  line-height: 1;
}

.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
  background: var(--brand);
  color: var(--white);
  box-shadow: 0 1px 2px rgba(79,70,229,.3);
}
.btn-primary:hover:not(:disabled) {
  background: var(--brand-hover);
  box-shadow: 0 2px 6px rgba(79,70,229,.35);
}

.btn-secondary {
  background: var(--white);
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover:not(:disabled) { background: var(--gray-50); }

.btn-ghost {
  background: transparent;
  color: var(--brand);
  border: none;
  padding: 5px 8px;
}
.btn-ghost:hover:not(:disabled) { background: var(--brand-light); }

.btn-danger {
  background: var(--danger);
  color: var(--white);
}
.btn-danger:hover:not(:disabled) { background: #dc2626; }

.btn-sm { padding: 5px 10px; font-size: .78rem; }
.btn-xs { padding: 3px 8px;  font-size: .73rem; }

/* ── Agent ID code chip ────────────────────── */
code.id-chip {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: .75rem;
  background: var(--gray-100);
  color: var(--gray-600);
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid var(--gray-200);
}

/* ── Row actions ───────────────────────────── */
.row-actions { display: flex; gap: 4px; opacity: 0; transition: opacity .12s; }
tbody tr:hover .row-actions { opacity: 1; }
/* Devices with no hover concept (touch) never trigger tr:hover at all, so
   Call/Defer/Edit/Targets/History etc. would be present but invisible and
   undiscoverable on phones/tablets — always show them there instead. */
@media (hover: none) {
  .row-actions { opacity: 1; }
}

/* ── Modal ─────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(2px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.open { display: flex; }

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-width: 540px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modal-in .18s ease;
}
.modal.modal-lg { max-width: 780px; }
.modal.modal-xl { max-width: 1020px; }

/* ── Script Drawer ──────────────────────────── */
.script-drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 950;
  cursor: pointer;
}
.script-drawer-overlay.open { display: block; }

.script-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 520px;
  max-width: 92vw;
  background: var(--white);
  box-shadow: -6px 0 32px rgba(15,23,42,.18);
  z-index: 951;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .22s cubic-bezier(.4,0,.2,1);
}
.script-drawer.open { transform: translateX(0); }

.script-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
  gap: 12px;
}
.script-drawer-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--gray-900);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.script-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 32px;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(-8px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 16px;
  border-bottom: 1px solid var(--gray-100);
}

.modal-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--gray-900);
}

.modal-close {
  background: var(--gray-100);
  border: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-500);
  font-size: .8rem;
  cursor: pointer;
  transition: background .12s;
  line-height: 1;
}

.modal-close:hover { background: var(--gray-200); color: var(--gray-700); }
.modal-body { padding: 20px 22px; overflow-y: auto; flex: 1; }

/* ── Forms ─────────────────────────────────── */
.form-group { margin-bottom: 14px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 5px;
}

.required { color: var(--danger); }

.form-input {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: .85rem;
  color: var(--gray-900);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}

.form-input::placeholder { color: var(--gray-400); }

.form-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}

select.form-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}

textarea.form-input { resize: vertical; min-height: 72px; line-height: 1.5; }

.form-hint { font-size: .73rem; color: var(--gray-400); margin-top: 4px; }

.form-error {
  color: var(--danger);
  font-size: .78rem;
  min-height: 1em;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--gray-100);
  margin-top: 16px;
}

/* ── Talking points output ─────────────────── */
.talking-points-text {
  white-space: pre-wrap;
  font-size: .875rem;
  line-height: 1.7;
  color: var(--gray-700);
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
}

/* ── Alerts ────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: .85rem;
  line-height: 1.5;
}

.alert-error   { background: var(--danger-bg);  color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: var(--success-bg); color: #065f46; border: 1px solid #6ee7b7; }
.alert-info    { background: var(--info-bg);    color: #1e40af; border: 1px solid #93c5fd; }

/* ── Spinner / loading ─────────────────────── */
.spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--gray-200);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .65s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-center {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 56px 20px;
  gap: 12px;
  color: var(--gray-400);
  font-size: .85rem;
}

/* ── Empty state ───────────────────────────── */
.empty-state {
  text-align: center;
  padding: 52px 20px;
  color: var(--gray-400);
}

.empty-icon {
  width: 44px;
  height: 44px;
  background: var(--gray-100);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}

.empty-state h3 { font-size: .9rem; font-weight: 600; color: var(--gray-600); margin-bottom: 4px; }
.empty-state p  { font-size: .82rem; }

/* ── Dashboard priority row ────────────────── */
.priority-number {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--brand-light);
  color: var(--brand);
  font-size: .72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Scrollbar ─────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ── Agent type radio cards ────────────────── */
.type-radio {
  flex: 1;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.type-radio.selected {
  border-color: var(--brand);
  background: var(--brand-light);
}

.type-radio input[type="radio"] { display: none; }

.type-radio-label { display: flex; flex-direction: column; gap: 2px; }
.type-radio-label strong { font-size: .83rem; color: var(--gray-800); }
.type-radio-label small  { font-size: .73rem; color: var(--gray-400); }

/* ── Team section ──────────────────────────── */
.section-divider {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--gray-400);
  padding: 16px 0 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gray-200);
}

/* ── Login Screen ──────────────────────────── */
.login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.login-screen.hidden { display: none; }
#signup-card.hidden { display: none; }

.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--gray-900);
  margin-bottom: 28px;
}

.login-logo-icon {
  width: 36px;
  height: 36px;
  background: var(--brand);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.login-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 24px;
}

/* ── View-As Banner ────────────────────────── */
.view-as-banner {
  background: var(--brand-light);
  border-bottom: 1px solid var(--brand-muted);
  padding: 8px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .83rem;
  color: var(--brand);
  font-weight: 500;
  flex-shrink: 0;
}

/* ── Logout Button ──────────────────────────── */
.logout-btn {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--sidebar-text);
  font-size: .74rem;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  text-align: center;
  margin-top: 4px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.logout-btn:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
}

/* ── Mobile ────────────────────────────────── */
@media (max-width: 768px) {
  body { flex-direction: column; }

  .sidebar {
    width: 100%;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    border-bottom: 1px solid var(--sidebar-border);
  }

  .sidebar-brand { border-bottom: none; padding: 0 14px; flex-shrink: 0; }
  .sidebar-section { display: flex; flex-direction: row; padding: 0; }
  .sidebar-section-label { display: none; }
  /* Was `display: none` — Sign out / Change Password lived ONLY here, so a
     mobile user had no way at all to log out or change their password.
     Kept visible and folded into the horizontal nav bar instead (same
     horizontal-scroll pattern already used for nav items on this breakpoint),
     with the name/role text hidden to save space. */
  .sidebar-footer {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    margin-top: 0;
    padding: 0 10px;
    border-top: none;
    flex-shrink: 0;
  }
  .sidebar-footer .agent-info { display: none; }
  .sidebar-footer .logout-btn {
    padding: 6px 10px;
    font-size: .72rem;
    white-space: nowrap;
    margin-bottom: 0 !important;
  }
  .nav-item { padding: 14px 12px; border-radius: 0; white-space: nowrap; }
  .nav-label { display: none; }
  .nav-icon { width: 20px; height: 20px; }

  .main-area { height: calc(100vh - 52px); }
  #main-content { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .top-bar { padding: 0 16px; }
  .topbar-agent { display: none; }
}

/* ── Call Mode Overlay ──────────────────────────────────────────── */
.call-mode-overlay {
  position: fixed;
  inset: 0;
  background: #f8fafc;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.call-mode-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: white;
  border-bottom: 2px solid var(--brand);
  flex-shrink: 0;
  gap: 12px;
}
.call-mode-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.call-active-layout {
  display: flex;
  height: 100%;
  overflow: hidden;
}
.call-context-panel {
  width: 260px;
  flex-shrink: 0;
  padding: 20px 18px;
  border-right: 1px solid var(--gray-200);
  overflow-y: auto;
  background: white;
}
.context-section-label {
  font-size: .7rem;
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 4px;
}
.call-tp-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.call-tabs {
  display: flex;
  gap: 2px;
  padding: 10px 20px 0;
  border-bottom: 1px solid var(--gray-200);
  overflow-x: auto;
  flex-shrink: 0;
  background: white;
}
.call-tab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 8px 16px 10px;
  font-size: .83rem;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
  margin-bottom: -1px;
  border-radius: 4px 4px 0 0;
}
.call-tab:hover { color: var(--gray-800); background: var(--gray-50); }
.call-tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.call-tp-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 36px;
  background: white;
}
.call-tp-panel { display: block; }
.call-tp-panel.hidden { display: none; }
.call-log-phase {
  padding: 36px 40px;
  max-width: 580px;
  overflow-y: auto;
  height: 100%;
}

/* ── Planner / Calendar ─────────────────────────────────────────────────── */
.planner-wrap { display: flex; flex-direction: column; gap: 0; }

.cal-grid-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 4px;
}
.cal-grid-header span {
  text-align: center;
  font-size: .72rem;
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 4px 0;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal-cell {
  min-height: 80px;
  border-radius: 6px;
  padding: 6px 7px 5px;
  cursor: pointer;
  border: 2px solid transparent;
  background: var(--gray-50);
  transition: background .12s, border-color .12s;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.cal-cell:hover { background: #eff0f7; }
.cal-cell--empty { background: transparent; cursor: default; border-color: transparent; }
.cal-cell--today { background: #eff6ff; }
.cal-cell--today .cal-day-num {
  color: var(--brand);
  font-weight: 700;
  background: var(--brand);
  color: white;
  border-radius: 99px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .78rem;
}
.cal-cell--selected { border-color: var(--brand); background: #eff6ff; }

.cal-day-num {
  font-size: .8rem;
  font-weight: 600;
  color: var(--gray-700);
  line-height: 1;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cal-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 2px;
}
.cal-dot {
  width: 7px;
  height: 7px;
  border-radius: 99px;
  display: inline-block;
  flex-shrink: 0;
}
.cal-dot-more {
  font-size: .65rem;
  color: var(--gray-400);
  font-weight: 600;
  line-height: 7px;
}

.cal-plan-chip {
  font-size: .65rem;
  color: var(--gray-500);
  background: var(--gray-100);
  border-radius: 4px;
  padding: 1px 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: auto;
}

/* Day detail */
.cal-appt-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--gray-100);
}
.cal-appt-row:first-child { border-top: none; }
.cal-appt-dot {
  width: 10px;
  height: 10px;
  border-radius: 99px;
  flex-shrink: 0;
}
.cal-appt-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.cal-appt-title {
  font-size: .88rem;
  font-weight: 500;
  color: var(--gray-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-appt-meta {
  font-size: .76rem;
  color: var(--gray-400);
}
.cal-appt-status {
  font-size: .72rem;
  padding: 2px 8px;
  border-radius: 99px;
  font-weight: 500;
  white-space: nowrap;
}
.cal-appt-status--scheduled  { background: #eff6ff; color: var(--brand); }
.cal-appt-status--completed  { background: #f0fdf4; color: #15803d; }
.cal-appt-status--cancelled  { background: var(--gray-100); color: var(--gray-400); }

.cal-plan-detail {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}
.cal-plan-stat {
  background: var(--gray-50);
  border-radius: 6px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cal-plan-label {
  font-size: .7rem;
  color: var(--gray-400);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.cal-plan-val {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gray-800);
}

/* ── Call history chart ────────────────────── */
.chart-range-toggle { display: inline-flex; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); overflow: hidden; }
.chart-range-btn {
  padding: 4px 11px;
  font-size: .73rem;
  font-weight: 600;
  color: var(--gray-600);
  background: var(--white);
  border: none;
  border-right: 1px solid var(--gray-300);
  cursor: pointer;
}
.chart-range-btn:last-child { border-right: none; }
.chart-range-btn:hover:not(.active) { background: var(--gray-50); }
.chart-range-btn.active { background: var(--brand); color: var(--white); }

.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; }
.chart-legend-item { display: flex; align-items: center; gap: 6px; font-size: .75rem; color: var(--gray-600); }
.chart-legend-swatch { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }

.chart-bar-col { cursor: default; }
.chart-bar-col:hover rect.chart-hit { fill: rgba(79,70,229,.05); }

.chart-tooltip {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  background: var(--gray-900);
  color: var(--white);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: .74rem;
  line-height: 1.5;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translate(-50%, -100%);
  transition: opacity .08s;
  white-space: nowrap;
}
.chart-tooltip.visible { opacity: 1; }
.chart-tooltip-date { font-weight: 700; margin-bottom: 3px; }
.chart-tooltip-row { display: flex; align-items: center; gap: 6px; }
.chart-tooltip-swatch { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
