/* ============================================================
   CRM — macOS-inspired design system
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #F5F5F7;
  --surface:     #FFFFFF;
  --surface-2:   #F0F0F2;
  --border:      rgba(0,0,0,0.08);
  --shadow-sm:   0 1px 4px rgba(0,0,0,0.06);
  --shadow-md:   0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg:   0 8px 28px rgba(0,0,0,0.12);
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   14px;
  --accent:      #0071E3;
  --accent-hov:  #0066CC;
  --danger:      #FF3B30;
  --success:     #34C759;
  --warning:     #FF9500;
  --text:        #1D1D1F;
  --text-2:      #6E6E73;
  --text-3:      #AEAEB2;
  --font:        -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  --sidebar-w:   220px;
  --topbar-h:    52px;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ---- Layout ---- */
#shell {
  display: flex;
  height: 100vh;
}

/* ---- Auth overlay ---- */
#auth-overlay {
  position: fixed; inset: 0;
  background: rgba(245,245,247,0.92);
  backdrop-filter: blur(20px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
#auth-overlay.hidden { display: none; }

.auth-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px 44px;
  width: 360px;
  text-align: center;
}
.auth-card .logo {
  width: 52px; height: 52px;
  background: var(--accent);
  border-radius: 14px;
  margin: 0 auto 20px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 22px; font-weight: 700;
}
.auth-card h1 { font-size: 20px; font-weight: 600; margin-bottom: 6px; }
.auth-card p  { color: var(--text-2); font-size: 13px; margin-bottom: 28px; }

.field { margin-bottom: 14px; text-align: left; }
.field label { display: block; font-size: 12px; font-weight: 500; color: var(--text-2); margin-bottom: 5px; }
.field input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  background: var(--surface-2);
  outline: none;
  transition: border-color .15s;
}
.field input:focus { border-color: var(--accent); background: var(--surface); }

.btn-primary {
  width: 100%; padding: 10px; margin-top: 8px;
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: background .15s;
}
.btn-primary:hover { background: var(--accent-hov); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

.auth-hint { font-size: 11px; color: var(--text-3); margin-top: 16px; }

/* ---- Sidebar ---- */
#sidebar {
  width: var(--sidebar-w);
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 0;
  flex-shrink: 0;
  z-index: 20;
  transition: transform .25s ease;
}

/* ---- Sidebar overlay (mobile backdrop) ---- */
#sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 19;
  backdrop-filter: blur(2px);
}
#sidebar-overlay.visible { display: block; }

/* ---- Hamburger toggle ---- */
#menu-btn {
  display: none;
  background: none; border: none;
  cursor: pointer; color: var(--text);
  font-size: 18px; line-height: 1;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
#menu-btn:hover { background: var(--surface-2); }

.sidebar-header {
  padding: 18px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
}
.sidebar-brand .brand-icon {
  width: 30px; height: 30px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.sidebar-brand .brand-name { font-size: 14px; font-weight: 600; }
.sidebar-brand .brand-sub  { font-size: 11px; color: var(--text-2); }

.sidebar-nav { flex: 1; padding: 10px 8px; }
.nav-section { margin-bottom: 18px; }
.nav-label {
  font-size: 10px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .06em;
  padding: 0 8px; margin-bottom: 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-2);
  font-size: 13.5px; font-weight: 450;
  transition: background .12s, color .12s;
  user-select: none;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: rgba(0,113,227,0.1); color: var(--accent); font-weight: 500; }
.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff; font-size: 10px;
  padding: 1px 6px; border-radius: 10px;
}

.sidebar-footer {
  position: relative;
  padding: 12px 8px;
  border-top: 1px solid var(--border);
}
.user-menu {
  position: absolute; bottom: calc(100% + 4px); left: 12px; right: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  overflow: hidden; opacity: 0; transform: translateY(6px);
  pointer-events: none; transition: opacity 0.15s, transform 0.15s; z-index: 200;
}
.user-menu.open { opacity: 1; transform: translateY(0); pointer-events: auto; }
.user-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; font-size: 14px; color: var(--text); cursor: pointer;
  transition: background 0.12s;
}
.user-menu-item:hover { background: var(--surface-2); }
.user-menu-item.danger { color: var(--danger); }
.user-menu-divider { height: 1px; background: var(--border); margin: 3px 0; }
.user-menu-chevron { font-size: 11px; color: var(--text-3); transition: transform 0.2s; flex-shrink: 0; }
.user-menu-chevron.open { transform: rotate(180deg); }
.user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.user-chip:hover { background: var(--surface-2); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, #0071E3, #6AC4FA);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 11px; font-weight: 600; flex-shrink: 0;
}
.user-chip .user-name  { font-size: 13px; font-weight: 500; }
.user-chip .user-role  { font-size: 11px; color: var(--text-2); }

/* ---- Main content area ---- */
#main {
  flex: 1;
  display: flex; flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: var(--topbar-h);
  background: rgba(255,255,255,0.8);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 12px;
  flex-shrink: 0;
}
.topbar-title { font-size: 16px; font-weight: 600; flex: 1; }
.topbar-actions { display: flex; gap: 8px; }

.btn-secondary {
  padding: 7px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 13px; font-weight: 450;
  cursor: pointer; display: flex; align-items: center; gap: 6px;
  transition: background .12s, box-shadow .12s;
}
.btn-secondary:hover { background: var(--surface-2); box-shadow: var(--shadow-sm); }

.btn-danger {
  padding: 7px 14px;
  background: rgba(255,59,48,.08);
  border: 1px solid rgba(255,59,48,.2);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-family: var(--font); font-size: 13px; cursor: pointer;
  transition: background .12s;
}
.btn-danger:hover { background: rgba(255,59,48,.14); }

#view {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ---- Dashboard ---- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.kpi-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
  border: 1px solid var(--border);
}
.kpi-label { font-size: 12px; color: var(--text-2); font-weight: 500; margin-bottom: 8px; }
.kpi-value { font-size: 28px; font-weight: 700; letter-spacing: -.5px; }
.kpi-sub   { font-size: 12px; color: var(--text-2); margin-top: 4px; }
.kpi-icon  { font-size: 20px; float: right; margin-top: -2px; opacity: .6; }
.kpi-card.accent-blue  .kpi-value { color: var(--accent); }
.kpi-card.accent-green .kpi-value { color: var(--success); }
.kpi-card.accent-orange .kpi-value { color: var(--warning); }
.kpi-card.accent-purple .kpi-value { color: #9673A6; }

.chart-row { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 28px; }
@media (max-width: 900px) { .chart-row { grid-template-columns: 1fr; } }

.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 20px 22px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title  { font-size: 14px; font-weight: 600; }
.card-sub    { font-size: 12px; color: var(--text-2); margin-top: 2px; }

.chart-bars {
  display: flex; align-items: flex-end; gap: 10px;
  height: 140px; padding-top: 8px;
}
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.bar-fill {
  width: 100%; border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, #4DA6FF, #0071E3);
  min-height: 4px;
  transition: height .4s ease;
}
.bar-fill.dim { background: var(--surface-2); }
.bar-label { font-size: 10px; color: var(--text-3); }

.pipeline-mini { }
.stage-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.stage-row:last-child { border-bottom: none; }
.stage-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.stage-name { flex: 1; font-size: 13px; }
.stage-count { font-size: 12px; color: var(--text-2); min-width: 20px; text-align: right; }
.stage-bar-wrap { width: 80px; height: 5px; background: var(--surface-2); border-radius: 3px; }
.stage-bar-inner { height: 100%; border-radius: 3px; }

.activity-list { }
.activity-item {
  display: flex; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
}
.activity-icon.call    { background: rgba(0,113,227,.1); color: var(--accent); }
.activity-icon.email   { background: rgba(52,199,89,.1); color: var(--success); }
.activity-icon.meeting { background: rgba(255,149,0,.1); color: var(--warning); }
.activity-icon.note    { background: rgba(150,115,166,.1); color: #9673A6; }
.activity-body { flex: 1; }
.activity-desc { font-size: 13px; line-height: 1.4; }
.activity-meta { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ---- Pipeline Kanban ---- */
#view.kanban-view { padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.kanban-toolbar {
  padding: 16px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
  background: var(--surface);
}
.kanban-board {
  flex: 1; overflow-x: auto; overflow-y: hidden;
  display: flex; gap: 14px;
  padding: 20px 24px;
  align-items: flex-start;
}
.kanban-col {
  width: 268px; flex-shrink: 0;
  display: flex; flex-direction: column;
  max-height: 100%;
}
.kanban-col-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: var(--surface);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  border: 1px solid var(--border); border-bottom: none;
}
.kanban-col-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.kanban-col-name { font-size: 13px; font-weight: 600; flex: 1; }
.kanban-col-count {
  font-size: 11px; font-weight: 500;
  background: var(--surface-2); color: var(--text-2);
  padding: 1px 7px; border-radius: 10px;
}
.kanban-cards {
  flex: 1; overflow-y: auto;
  padding: 8px;
  background: rgba(0,0,0,0.02);
  border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  display: flex; flex-direction: column; gap: 8px;
  min-height: 120px;
}
.kanban-cards.drag-over { background: rgba(0,113,227,0.05); border-color: var(--accent); }

.deal-card {
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 12px 14px;
  cursor: grab;
  transition: box-shadow .15s, transform .1s;
  user-select: none;
}
.deal-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.deal-card.dragging { opacity: .5; }
.deal-name    { font-size: 13px; font-weight: 500; margin-bottom: 4px; }
.deal-company { font-size: 12px; color: var(--text-2); margin-bottom: 10px; }
.deal-footer  { display: flex; align-items: center; justify-content: space-between; }
.deal-value   { font-size: 13px; font-weight: 600; color: var(--text); }
.deal-prob    { font-size: 11px; color: var(--text-3); }
.prob-bar     { height: 3px; background: var(--surface-2); border-radius: 2px; margin-top: 6px; }
.prob-fill    { height: 100%; border-radius: 2px; background: var(--accent); }

/* ---- Customers table ---- */
.table-wrap {
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  overflow-y: hidden;
}
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--surface-2); }
th {
  padding: 11px 16px;
  text-align: left; font-size: 12px; font-weight: 600;
  color: var(--text-2); text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 12px 16px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(0,0,0,0.015); }

.status-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px; font-weight: 500;
}
.pill-Lead        { background: rgba(108,142,191,.12); color: #4A6EA8; }
.pill-Qualified   { background: rgba(130,179,102,.12); color: #5A9A3A; }
.pill-Proposal    { background: rgba(215,155,0,.12);   color: #B07800; }
.pill-Negotiation { background: rgba(150,115,166,.12); color: #7B5FA0; }
.pill-Closed\ Won,
.pill-ClosedWon   { background: rgba(52,199,89,.12);   color: #25913F; }

.btn-icon {
  background: none; border: none; cursor: pointer;
  color: var(--text-3); font-size: 15px;
  padding: 4px 6px; border-radius: 4px;
  transition: color .12s, background .12s;
}
.btn-icon:hover { color: var(--accent); background: rgba(0,113,227,.08); }

.search-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px; width: 240px;
}
.search-bar input {
  border: none; outline: none; font-family: var(--font);
  font-size: 13px; background: transparent; flex: 1;
}
.search-bar .search-icon { color: var(--text-3); font-size: 14px; }

/* ---- Pipeline Settings ---- */
.settings-grid { display: grid; grid-template-columns: 360px 1fr; gap: 20px; }
@media (max-width: 800px) { .settings-grid { grid-template-columns: 1fr; } }

.stage-list-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.stage-list-item:last-child { border-bottom: none; }
.stage-list-item:hover { background: var(--surface-2); }
.stage-drag-handle { color: var(--text-3); cursor: grab; font-size: 14px; }
.stage-color-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.stage-item-name { flex: 1; font-size: 13.5px; }
.stage-item-order { font-size: 11px; color: var(--text-3); }
.color-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.color-swatch {
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: transform .12s;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border-color: var(--text); }

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  backdrop-filter: blur(4px);
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px 32px;
  width: 440px;
  max-width: 95vw;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close {
  background: none; border: none; color: var(--text-3);
  cursor: pointer; font-size: 18px; padding: 2px 6px;
  border-radius: 4px;
}
.modal-close:hover { color: var(--text); background: var(--surface-2); }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

/* ---- Toast ---- */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 900;
}
.toast {
  background: var(--text);
  color: #fff;
  padding: 11px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  display: flex; align-items: center; gap: 10px;
  animation: slideUp .2s ease;
  max-width: 320px;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
@keyframes slideUp {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ---- Customer detail drawer ---- */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.25);
  z-index: 400;
  backdrop-filter: blur(2px);
}
.drawer-backdrop.hidden { display: none; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 480px; max-width: 96vw;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  z-index: 401;
  animation: slideIn .22s ease;
}
@keyframes slideIn {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
.drawer-header {
  padding: 20px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: 14px;
}
.drawer-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, #0071E3, #6AC4FA);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 16px; font-weight: 600; flex-shrink: 0;
}
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 24px; }
.drawer-close {
  margin-left: auto; background: none; border: none;
  color: var(--text-3); cursor: pointer; font-size: 18px;
  padding: 2px 6px; border-radius: 4px;
}
.drawer-close:hover { color: var(--text); }

.detail-section { margin-bottom: 24px; }
.detail-section-title {
  font-size: 11px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: 10px;
}
.detail-row { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; }
.detail-label { font-size: 12px; color: var(--text-2); width: 90px; flex-shrink: 0; padding-top: 1px; }
.detail-val   { font-size: 13.5px; }

.task-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--border);
}
.task-item:last-child { border-bottom: none; }
.task-check {
  width: 16px; height: 16px; border-radius: 50%;
  border: 1.5px solid var(--border); flex-shrink: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.task-check.done { background: var(--success); border-color: var(--success); color: #fff; font-size: 9px; }
.task-desc { flex: 1; font-size: 13px; }
.task-desc.done { text-decoration: line-through; color: var(--text-3); }
.task-due { font-size: 11px; color: var(--text-3); }
.task-type-pill {
  font-size: 10px; padding: 1px 7px; border-radius: 10px;
  background: var(--surface-2); color: var(--text-2);
}

.log-item {
  display: flex; gap: 10px; padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.log-item:last-child { border-bottom: none; }
.log-line { font-size: 13px; }
.log-meta { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ---- Empty state ---- */
.empty-state {
  text-align: center; padding: 48px 24px; color: var(--text-2);
}
.empty-state .empty-icon { font-size: 36px; opacity: .3; margin-bottom: 12px; }
.empty-state p { font-size: 13px; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.25); }

/* ---- Icon font integration ---- */
i[class^="icon-"],
i[class*=" icon-"] {
  display: inline-block;
  line-height: 1;
  font-size: inherit;
  vertical-align: middle;
}
/* Per-context sizing */
.nav-icon i[class^="icon-"]     { font-size: 16px; }
.kpi-icon i[class^="icon-"]     { font-size: 20px; }
.activity-icon i[class^="icon-"]{ font-size: 15px; }
.log-type-icon i[class^="icon-"]{ font-size: 16px; }
.user-menu-item i[class^="icon-"] { font-size: 16px; }
#menu-btn i[class^="icon-"]     { font-size: 18px; }
.modal-close i[class^="icon-"]  { font-size: 16px; }
.drawer-close i[class^="icon-"] { font-size: 16px; }
.search-icon i[class^="icon-"]  { font-size: 14px; }
.search-clear i[class^="icon-"] { font-size: 11px; }
.btn-icon i[class^="icon-"]     { font-size: 14px; }
.stage-drag-handle i[class^="icon-"] { font-size: 13px; }
.dash-task-check i[class^="icon-"]   { font-size: 10px; }
.task-check i[class^="icon-"]        { font-size: 9px;  }
.dash-task-type-icon i[class^="icon-"] { font-size: 14px; }
.e-icon i[class^="icon-"]       { font-size: 30px; opacity: .25; display: block; margin-bottom: 10px; }
.kpi-trend i[class^="icon-"]    { font-size: 10px; }

/* ---- Loader ---- */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* ---- Tablet (≤ 1024px): collapse chart side-by-side ---- */
@media (max-width: 1024px) {
  .chart-row { grid-template-columns: 1fr; }
}

/* ---- Mobile (≤ 767px) ---- */
@media (max-width: 767px) {

  /* Sidebar: off-screen slide-in overlay */
  #sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
  }
  #sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  /* Show hamburger */
  #menu-btn { display: flex; align-items: center; justify-content: center; }

  /* Topbar */
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-title { font-size: 15px; }

  /* View */
  #view { padding: 14px; }

  /* Auth */
  .auth-card { width: calc(100% - 32px); padding: 28px 20px; }

  /* KPI: 2-up grid */
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
  }
  .kpi-card { padding: 14px 14px; }
  .kpi-value { font-size: 20px; }
  .kpi-icon { font-size: 16px; }

  /* Chart / activity cards */
  .card { padding: 16px; }
  .chart-row { gap: 12px; margin-bottom: 16px; }

  /* Stage bar on dashboard */
  .stage-bar-wrap { width: 50px; }

  /* Customers toolbar: wrap on small screens */
  #customers-toolbar {
    flex-wrap: wrap;
    gap: 10px;
  }
  #customers-toolbar .search-bar { flex: 1; min-width: 0; width: auto; }
  #customers-toolbar .btn-primary { flex-shrink: 0; }

  /* Table: hide Email & Phone columns (3rd and 4th) */
  table th:nth-child(3),
  table td:nth-child(3),
  table th:nth-child(4),
  table td:nth-child(4) { display: none; }

  th { padding: 10px 12px; }
  td { padding: 10px 12px; font-size: 13px; }

  /* Kanban */
  .kanban-toolbar { padding: 12px 14px; font-size: 12px; }
  .kanban-board { padding: 14px; gap: 10px; }
  .kanban-col { width: 234px; }

  /* Settings */
  .settings-grid { grid-template-columns: 1fr; }

  /* Modal → bottom sheet */
  .modal-backdrop { align-items: flex-end; }
  .modal {
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 20px 18px 32px;
  }

  /* Drawer → full width */
  .drawer { width: 100%; max-width: 100%; }
  .drawer-header { padding: 16px 18px; }
  .drawer-body { padding: 16px 18px; }

  /* Toast */
  #toast-container { left: 14px; right: 14px; bottom: 14px; }
  .toast { max-width: 100%; }
}

/* ---- Very small (≤ 400px): single-col KPIs ---- */
@media (max-width: 400px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-value { font-size: 24px; }
}

/* ============================================================
   ENHANCEMENTS
   ============================================================ */

/* ---- Skeleton shimmer ---- */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, #e5e5ea 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 5px;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.sk-gap  { margin-bottom: 10px; }
.sk-h3   { height: 11px; }
.sk-h4   { height: 15px; }
.sk-h6   { height: 22px; }
.sk-kpi  { height: 34px; }
.sk-bar  { height: 148px; border-radius: var(--radius-sm); }
.sk-row  { height: 42px; }
.sk-w40  { width: 40%; }
.sk-w60  { width: 60%; }
.sk-w100 { width: 100%; }

/* ---- View fade-in ---- */
@keyframes viewFadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}
.view-loaded { animation: viewFadeIn .22s ease both; }

/* ---- Enhanced nav active: inset left accent ---- */
.nav-item.active {
  background: rgba(0,113,227,0.08);
  color: var(--accent);
  font-weight: 500;
  box-shadow: inset 3px 0 0 var(--accent);
}

/* ---- Greeting header ---- */
.dash-greeting { margin-bottom: 22px; }
.dash-greeting-name {
  font-size: 22px; font-weight: 700; letter-spacing: -.4px; color: var(--text);
}
.dash-greeting-sub {
  font-size: 13px; color: var(--text-2); margin-top: 4px; line-height: 1.5;
}
.dash-greeting-sub .alert { color: var(--danger); font-weight: 600; }
.dash-greeting-sub .ok    { color: var(--success); font-weight: 500; }

/* ---- KPI trend indicator ---- */
.kpi-trend {
  font-size: 11px; font-weight: 500; margin-top: 6px;
  display: flex; align-items: center; gap: 3px;
}
.kpi-trend.up   { color: var(--success); }
.kpi-trend.down { color: var(--danger); }
.kpi-trend-arrow { font-size: 10px; }

/* ---- Kanban stage value pill ---- */
.kanban-col-value {
  font-size: 11px; color: var(--text-2); font-weight: 500;
  padding: 1px 7px; border-radius: 10px; background: var(--surface-2);
  flex-shrink: 0;
}

/* ---- Enhanced deal card ---- */
.deal-card-top { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.deal-avatar {
  width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, #4A90D9, #0071E3);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 9px; font-weight: 700; letter-spacing: .02em;
}
.deal-info { flex: 1; min-width: 0; }
.deal-info .deal-name    { font-size: 13px; font-weight: 500; margin-bottom: 2px; }
.deal-info .deal-company { font-size: 11.5px; color: var(--text-2); margin-bottom: 0; }

/* ---- Dashboard bottom 2-col row ---- */
.dash-bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.dash-bottom-row .card { display: flex; flex-direction: column; }
.dash-card-scroll { flex: 1; overflow-y: auto; max-height: 300px; }

/* ---- Tasks panel tabs ---- */
.tasks-tabs {
  display: flex; gap: 2px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 14px;
  flex-shrink: 0;
}
.tasks-tab {
  flex: 1; text-align: center;
  padding: 5px 4px; font-size: 11.5px; font-weight: 500;
  border-radius: 4px; cursor: pointer; border: none; background: none;
  color: var(--text-2); font-family: var(--font);
  transition: background .12s, color .12s; white-space: nowrap;
}
.tasks-tab.active {
  background: var(--surface); color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.tab-badge {
  display: inline-block; font-size: 9.5px; font-weight: 600;
  padding: 0 5px; border-radius: 8px; margin-left: 3px;
  line-height: 15px; height: 15px; vertical-align: middle;
  background: var(--surface-2); color: var(--text-3);
}
.tab-badge.bd-danger  { background: rgba(255,59,48,.12);  color: var(--danger); }
.tab-badge.bd-warning { background: rgba(255,149,0,.12);  color: var(--warning); }
.tab-badge.bd-accent  { background: rgba(0,113,227,.1);   color: var(--accent); }

/* ---- Task section label ---- */
.tasks-section-lbl {
  font-size: 10px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .07em;
  padding: 10px 2px 5px; border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.tasks-section-lbl:first-child { padding-top: 0; }

/* ---- Task row ---- */
.dash-task-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 6px 7px 4px; border-radius: var(--radius-sm);
  cursor: default; transition: background .1s;
}
.dash-task-row:hover { background: var(--surface-2); }

.dash-task-check {
  width: 18px; height: 18px; border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,0.15);
  background: none; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; color: transparent;
  transition: border-color .15s, background .15s, color .15s;
}
.dash-task-check:hover {
  border-color: var(--success);
  background: rgba(52,199,89,.08);
  color: var(--success);
}
.dash-task-check.done {
  background: var(--success); border-color: var(--success);
  color: #fff; animation: checkPop .22s ease;
}
@keyframes checkPop {
  0%   { transform: scale(0.6); }
  65%  { transform: scale(1.25); }
  100% { transform: scale(1); }
}

.dash-task-type-icon { font-size: 13px; flex-shrink: 0; width: 18px; text-align: center; }

.dash-task-desc {
  flex: 1; font-size: 13px; line-height: 1.3; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dash-task-desc.done { text-decoration: line-through; color: var(--text-3); }

.dash-task-who {
  font-size: 10.5px; color: var(--text-2);
  background: var(--surface-2); padding: 2px 7px;
  border-radius: 10px; flex-shrink: 0;
  max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.dash-task-due {
  font-size: 11px; font-weight: 500; flex-shrink: 0;
  min-width: 58px; text-align: right;
}
.dash-task-due.status-overdue  { color: var(--danger); }
.dash-task-due.status-today    { color: var(--warning); }
.dash-task-due.status-upcoming { color: var(--text-3); }

.tasks-empty {
  text-align: center; padding: 32px 16px;
  color: var(--text-3); font-size: 13px;
}
.tasks-empty .e-icon { font-size: 30px; opacity: .25; margin-bottom: 10px; }

/* ---- Clickable table rows ---- */
tbody tr { cursor: pointer; }
tbody tr:hover td { background: rgba(0,113,227,.03); }

/* ---- Search clear button ---- */
.search-clear {
  background: none; border: none; cursor: pointer;
  color: var(--text-3); font-size: 12px; padding: 0;
  border-radius: 50%; width: 18px; height: 18px;
  display: none; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .1s, color .1s;
}
.search-clear.visible { display: flex; }
.search-clear:hover { background: var(--surface-2); color: var(--text-2); }

/* ---- Button micro-interactions ---- */
.btn-primary:active   { transform: scale(0.98); }
.btn-secondary:active { transform: scale(0.97); }

/* ---- Focus rings ---- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:focus:not(:focus-visible) { outline: none; }

/* ---- Responsive overrides for new components ---- */
@media (max-width: 960px) {
  .dash-bottom-row { grid-template-columns: 1fr; }
}
@media (max-width: 767px) {
  .dash-greeting-name { font-size: 18px; }
  .dash-task-who { display: none; }
  .dash-card-scroll { max-height: 240px; }
  .tasks-tab { font-size: 11px; padding: 5px 2px; }
}
