/* ============================================================
   CRM — Main Stylesheet
   ============================================================ */

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

:root {
  --blue:        #3b82f6;
  --blue-dark:   #2563eb;
  --blue-light:  #eff6ff;
  --green:       #10b981;
  --green-light: #ecfdf5;
  --red:         #ef4444;
  --red-light:   #fef2f2;
  --yellow:      #f59e0b;
  --yellow-light:#fffbeb;
  --purple:      #8b5cf6;
  --purple-light:#f5f3ff;
  --orange:      #f97316;
  --cyan:        #06b6d4;

  --sidebar-bg:  #0f172a;
  --sidebar-w:   240px;
  --header-h:    60px;

  --bg:          #f8fafc;
  --card:        #ffffff;
  --text:        #0f172a;
  --text-2:      #334155;
  --muted:       #64748b;
  --border:      #e2e8f0;
  --border-2:    #cbd5e1;
  --hover:       #f1f5f9;

  --shadow-sm:   0 1px 3px rgba(0,0,0,.08);
  --shadow-md:   0 4px 16px rgba(0,0,0,.1);
  --shadow-lg:   0 10px 40px rgba(0,0,0,.15);

  --radius:      8px;
  --radius-lg:   12px;
  --transition:  .15s ease;
}

body { font-family: 'Inter', -apple-system, sans-serif; color: var(--text); font-size: 14px; line-height: 1.5; }
#appPage { background: var(--bg); }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }

/* ── LAYOUT ── */
.app-layout { display: flex; height: 100vh; overflow: hidden; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: width var(--transition);
  position: relative;
  z-index: 100;
}
.sidebar.collapsed { width: 64px; }
.sidebar.collapsed .brand-name,
.sidebar.collapsed .user-info,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed span { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }
.sidebar.collapsed .nav-item svg { margin: 0; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { width: 32px; height: 32px; background: var(--blue); border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.brand-name { font-size: 16px; font-weight: 700; color: white; white-space: nowrap; }
.sidebar-toggle { background: none; border: none; color: rgba(255,255,255,.5); padding: 4px; border-radius: 4px; transition: color var(--transition); flex-shrink: 0; }
.sidebar-toggle:hover { color: white; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.nav-section-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: rgba(255,255,255,.3); padding: 16px 6px 6px; white-space: nowrap; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius);
  color: rgba(255,255,255,.6); font-size: 13.5px; font-weight: 500;
  transition: background var(--transition), color var(--transition);
  position: relative; white-space: nowrap; cursor: pointer;
}
.nav-item svg { flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.08); color: white; }
.nav-item.active { background: rgba(59,130,246,.25); color: white; }
.nav-item.active svg { color: var(--blue); }
.nav-badge {
  margin-left: auto; background: var(--red); color: white;
  font-size: 10px; font-weight: 700; min-width: 18px; height: 18px;
  border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 5px;
}

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 8px;
}
.user-pill { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  color: white; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.user-avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.user-info { min-width: 0; }
.user-name { font-size: 12.5px; font-weight: 600; color: white; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 11px; color: rgba(255,255,255,.4); display: block; text-transform: capitalize; }
.logout-btn { background: none; border: none; color: rgba(255,255,255,.4); padding: 6px; border-radius: var(--radius); transition: color var(--transition); flex-shrink: 0; }
.logout-btn:hover { color: var(--red); }

/* ── MAIN WRAPPER ── */
.main-wrapper { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ── TOP HEADER ── */
.top-header {
  height: var(--header-h); background: var(--card); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
  gap: 16px; flex-shrink: 0; z-index: 50;
}
.header-left { display: flex; align-items: center; gap: 12px; flex: 1; }
.mobile-menu-btn { display: none; background: none; border: none; color: var(--muted); padding: 4px; }
.global-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: 8px; padding: 7px 12px; max-width: 380px; width: 100%;
}
.global-search svg { color: var(--muted); flex-shrink: 0; }
.global-search input { border: none; background: none; outline: none; font-size: 13.5px; color: var(--text); width: 100%; }
.global-search input::placeholder { color: var(--muted); }
.header-right { display: flex; align-items: center; gap: 10px; }
.header-btn {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  background: var(--hover); border: none; border-radius: var(--radius); color: var(--muted);
  transition: background var(--transition); position: relative;
}
.header-btn:hover { background: var(--border); color: var(--text); }
.notif-badge {
  position: absolute; top: 4px; right: 4px;
  background: var(--red); color: white; font-size: 9px; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 8px; padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
}
.header-user { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; font-weight: 500; cursor: pointer; }

/* ── PAGE CONTENT ── */
.page-content { flex: 1; overflow-y: auto; padding: 0; }

/* ── PAGE HEADER ── */
.page-header {
  padding: 24px 28px 20px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
}
.page-title-area h1 { font-size: 22px; font-weight: 700; color: var(--text); }
.page-title-area p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── BUTTONS ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius); font-size: 13.5px; font-weight: 500; font-family: inherit; border: none; transition: background var(--transition), opacity var(--transition); cursor: pointer; white-space: nowrap; }
.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-secondary { background: var(--hover); color: var(--text-2); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--red-light); color: var(--red); }
.btn-danger:hover { background: #fecaca; }
.btn-success { background: var(--green-light); color: var(--green); }
.btn-success:hover { background: #a7f3d0; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 7px; width: 34px; height: 34px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── CARDS ── */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 14px; font-weight: 600; color: var(--text); }
.card-body { padding: 20px; }

/* ── KPI CARDS ── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; padding: 0 28px 24px; }
.kpi-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; position: relative; overflow: hidden; }
.kpi-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; }
.kpi-card.blue::before { background: var(--blue); }
.kpi-card.green::before { background: var(--green); }
.kpi-card.red::before { background: var(--red); }
.kpi-card.purple::before { background: var(--purple); }
.kpi-card.yellow::before { background: var(--yellow); }
.kpi-card.cyan::before { background: var(--cyan); }
.kpi-card.orange::before { background: var(--orange); }
.kpi-icon { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.kpi-card.blue .kpi-icon { background: var(--blue-light); color: var(--blue); }
.kpi-card.green .kpi-icon { background: var(--green-light); color: var(--green); }
.kpi-card.red .kpi-icon { background: var(--red-light); color: var(--red); }
.kpi-card.purple .kpi-icon { background: var(--purple-light); color: var(--purple); }
.kpi-card.yellow .kpi-icon { background: var(--yellow-light); color: var(--yellow); }
.kpi-card.cyan .kpi-icon { background: #ecfeff; color: var(--cyan); }
.kpi-card.orange .kpi-icon { background: #fff7ed; color: var(--orange); }
.kpi-value { font-size: 26px; font-weight: 800; color: var(--text); line-height: 1; }
.kpi-label { font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 500; }

/* ── CONTENT GRID ── */
.content-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 0 28px 28px; }
.content-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.content-grid.col-wide { grid-template-columns: 1.6fr 1fr; }
@media (max-width: 1100px) { .content-grid, .content-grid.three, .content-grid.col-wide { grid-template-columns: 1fr; } }

/* ── TABLES ── */
.table-container { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 16px; text-align: left; border-bottom: 1px solid var(--border); background: var(--bg); white-space: nowrap; }
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13.5px; color: var(--text-2); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--hover); }
.data-table .actions { display: flex; gap: 4px; opacity: 0; transition: opacity var(--transition); }
.data-table tr:hover .actions { opacity: 1; }
.data-table .sortable { cursor: pointer; user-select: none; }
.data-table .sortable:hover { color: var(--text); }

/* ── TABLE CARD WRAPPER ── */
.table-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); margin: 0 28px 28px; overflow: hidden; }

/* ── TOOLBAR (search + filters above table) ── */
.table-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 16px 20px; border-bottom: 1px solid var(--border); background: var(--card);
}
.toolbar-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 7px 12px; min-width: 220px;
}
.toolbar-search input { border: none; background: none; outline: none; font-size: 13px; width: 100%; color: var(--text); }
.toolbar-search svg { color: var(--muted); flex-shrink: 0; }
.toolbar-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-select {
  padding: 7px 10px; border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: 12.5px; font-family: inherit; background: var(--bg); color: var(--text-2);
  outline: none; cursor: pointer; transition: border-color var(--transition);
}
.filter-select:focus { border-color: var(--blue); }
.toolbar-right { margin-left: auto; display: flex; gap: 8px; }

/* ── BADGES / PILLS ── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.badge-blue { background: var(--blue-light); color: var(--blue); }
.badge-green { background: var(--green-light); color: var(--green); }
.badge-red { background: var(--red-light); color: var(--red); }
.badge-yellow { background: var(--yellow-light); color: var(--yellow); }
.badge-purple { background: var(--purple-light); color: var(--purple); }
.badge-gray { background: var(--hover); color: var(--muted); }
.badge-orange { background: #fff7ed; color: var(--orange); }
.badge-cyan { background: #ecfeff; color: var(--cyan); }

/* status badges */
.status-open        { background: var(--blue-light); color: var(--blue); }
.status-won         { background: var(--green-light); color: var(--green); }
.status-lost        { background: var(--red-light); color: var(--red); }
.status-prospect    { background: #fff7ed; color: var(--orange); }
.status-customer    { background: var(--green-light); color: var(--green); }
.status-partner     { background: var(--purple-light); color: var(--purple); }
.status-new         { background: var(--blue-light); color: var(--blue); }
.status-contacted   { background: var(--yellow-light); color: var(--yellow); }
.status-qualified   { background: var(--green-light); color: var(--green); }
.status-unqualified { background: var(--red-light); color: var(--red); }
.status-converted   { background: var(--purple-light); color: var(--purple); }
.status-hot         { background: #fef2f2; color: #dc2626; }
.status-warm        { background: #fff7ed; color: #ea580c; }
.status-cold        { background: #f0f9ff; color: #0284c7; }
.status-urgent      { background: var(--red-light); color: var(--red); }
.status-high        { background: #fff7ed; color: var(--orange); }
.status-medium      { background: var(--yellow-light); color: var(--yellow); }
.status-low         { background: var(--green-light); color: var(--green); }
.status-resolved    { background: var(--green-light); color: var(--green); }
.status-pending     { background: var(--yellow-light); color: var(--yellow); }
.status-closed      { background: var(--hover); color: var(--muted); }
.status-in_progress { background: var(--blue-light); color: var(--blue); }
.status-todo        { background: var(--hover); color: var(--muted); }
.status-completed   { background: var(--green-light); color: var(--green); }

/* ── AVATAR + NAME ── */
.entity-name { display: flex; align-items: center; gap: 10px; }
.entity-name .avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--blue), var(--purple)); color: white; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.entity-name .name-text { font-weight: 500; color: var(--text); }
.entity-name .name-sub { font-size: 12px; color: var(--muted); }
.name-link { color: var(--blue); cursor: pointer; font-weight: 500; }
.name-link:hover { text-decoration: underline; }

/* ── PAGINATION ── */
.pagination { display: flex; align-items: center; gap: 6px; padding: 14px 20px; border-top: 1px solid var(--border); justify-content: flex-end; }
.pagination .page-info { font-size: 12px; color: var(--muted); margin-right: auto; }
.page-btn { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; color: var(--text-2); background: var(--card); cursor: pointer; transition: background var(--transition); }
.page-btn:hover { background: var(--hover); }
.page-btn.active { background: var(--blue); color: white; border-color: var(--blue); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── KANBAN BOARD ── */
.kanban-wrapper { padding: 20px 28px; overflow-x: auto; }
.kanban-board { display: flex; gap: 16px; min-width: max-content; align-items: flex-start; }
.kanban-col { width: 280px; background: var(--bg); border-radius: var(--radius-lg); border: 1px solid var(--border); flex-shrink: 0; }
.kanban-col-header { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.kanban-col-header .stage-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.kanban-col-name { font-size: 13px; font-weight: 600; flex: 1; margin-left: 8px; }
.kanban-col-count { font-size: 12px; color: var(--muted); background: var(--border); padding: 2px 7px; border-radius: 10px; }
.kanban-col-value { font-size: 11px; color: var(--muted); padding: 6px 16px 10px; }
.kanban-cards { padding: 8px; min-height: 100px; display: flex; flex-direction: column; gap: 8px; }
.deal-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; cursor: pointer; transition: box-shadow var(--transition), transform var(--transition); }
.deal-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.deal-card-name { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.deal-card-company { font-size: 12px; color: var(--muted); margin-bottom: 10px; display: flex; align-items: center; gap: 4px; }
.deal-card-value { font-size: 16px; font-weight: 700; color: var(--text); }
.deal-card-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.deal-card-close { font-size: 11px; color: var(--muted); }
.deal-card-prob { font-size: 11px; font-weight: 600; color: var(--green); }
.deal-card-owner { width: 22px; height: 22px; border-radius: 50%; background: linear-gradient(135deg, var(--blue), var(--purple)); color: white; font-size: 9px; font-weight: 700; display: flex; align-items: center; justify-content: center; }

/* ── DETAIL PAGE ── */
.detail-layout { display: grid; grid-template-columns: 1fr 340px; gap: 24px; padding: 20px 28px; }
@media (max-width: 1000px) { .detail-layout { grid-template-columns: 1fr; } }
.detail-main { display: flex; flex-direction: column; gap: 20px; }
.detail-sidebar { display: flex; flex-direction: column; gap: 16px; }
.detail-header-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; display: flex; align-items: flex-start; gap: 20px; }
.detail-avatar { width: 56px; height: 56px; border-radius: 14px; background: linear-gradient(135deg, var(--blue), var(--purple)); color: white; font-size: 20px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.detail-info h2 { font-size: 20px; font-weight: 700; color: var(--text); }
.detail-info p { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.detail-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.detail-actions { margin-left: auto; display: flex; gap: 8px; }
.detail-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .detail-fields { grid-template-columns: 1fr; } }
.detail-field label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); display: block; margin-bottom: 4px; }
.detail-field .value { font-size: 13.5px; color: var(--text-2); }
.detail-field .value a { color: var(--blue); }

/* ── TIMELINE ── */
.timeline { padding: 4px 0; }
.timeline-item { display: flex; gap: 12px; padding: 12px 0; position: relative; }
.timeline-item:not(:last-child)::before { content: ''; position: absolute; left: 15px; top: 44px; bottom: -12px; width: 1px; background: var(--border); }
.timeline-icon { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; z-index: 1; }
.tl-call    { background: #dbeafe; color: var(--blue); }
.tl-email   { background: #ecfdf5; color: var(--green); }
.tl-meeting { background: var(--purple-light); color: var(--purple); }
.tl-task    { background: var(--yellow-light); color: var(--yellow); }
.tl-note    { background: #fff7ed; color: var(--orange); }
.tl-other   { background: var(--hover); color: var(--muted); }
.timeline-content { flex: 1; }
.timeline-title { font-size: 13.5px; font-weight: 500; color: var(--text); }
.timeline-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── NOTES ── */
.note-item { background: var(--bg); border-radius: var(--radius); padding: 14px; border: 1px solid var(--border); }
.note-item.pinned { border-color: var(--yellow); background: var(--yellow-light); }
.note-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.note-author { font-size: 12px; font-weight: 500; color: var(--muted); }
.note-date { font-size: 11px; color: var(--muted); }
.note-content { font-size: 13.5px; color: var(--text-2); line-height: 1.6; }

/* ── TASKS LIST ── */
.task-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.task-item:last-child { border-bottom: none; }
.task-check { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); cursor: pointer; flex-shrink: 0; margin-top: 2px; display: flex; align-items: center; justify-content: center; transition: border-color var(--transition); }
.task-check.done { background: var(--green); border-color: var(--green); }
.task-check.done::after { content: ''; width: 6px; height: 4px; border-bottom: 2px solid white; border-left: 2px solid white; transform: rotate(-45deg) translateY(-1px); display: block; }
.task-text { flex: 1; }
.task-title { font-size: 13.5px; color: var(--text); font-weight: 500; }
.task-title.done { text-decoration: line-through; color: var(--muted); }
.task-meta { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; gap: 8px; }
.task-due.overdue { color: var(--red); font-weight: 600; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--card); border-radius: var(--radius-lg); width: 100%; max-width: 600px;
  max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
}
.modal.modal-lg { max-width: 800px; }
.modal.modal-sm { max-width: 440px; }
.modal-header { padding: 18px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.modal-header h3 { font-size: 16px; font-weight: 600; color: var(--text); }
.modal-close { background: none; border: none; font-size: 22px; color: var(--muted); line-height: 1; padding: 0 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-shrink: 0; }

/* ── FORMS ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid.single { grid-template-columns: 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.span-2 { grid-column: span 2; }
.form-group label { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.form-group label .req { color: var(--red); }
.form-input, .form-select, .form-textarea {
  padding: 8px 12px; border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: 13.5px; font-family: inherit; color: var(--text); background: white;
  transition: border-color var(--transition); outline: none; width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--blue); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-section { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding-top: 16px; padding-bottom: 4px; border-bottom: 1px solid var(--border); margin-bottom: 4px; grid-column: span 2; }

/* ── ACTIVITY LOG FORM ── */
.activity-tabs { display: flex; gap: 2px; padding: 12px 20px 0; border-bottom: 1px solid var(--border); }
.activity-tab { padding: 8px 14px; font-size: 13px; font-weight: 500; border: none; background: none; color: var(--muted); border-radius: var(--radius) var(--radius) 0 0; cursor: pointer; display: flex; align-items: center; gap: 6px; }
.activity-tab.active { background: var(--blue); color: white; }
.activity-tab:hover:not(.active) { background: var(--hover); color: var(--text); }

/* ── LOADING ── */
.loading-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 60vh; gap: 12px; color: var(--muted); }
.spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite; }
.skeleton { background: linear-gradient(90deg, var(--border) 25%, var(--hover) 50%, var(--border) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: .4; }
.empty-state h3 { font-size: 15px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.empty-state p { font-size: 13px; max-width: 300px; margin: 0 auto 20px; }

/* ── TOAST ── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: white; padding: 12px 18px; border-radius: var(--radius); font-size: 13.5px; font-weight: 500; display: flex; align-items: center; gap: 8px; box-shadow: var(--shadow-lg); animation: slideIn .2s ease; max-width: 320px; }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
.toast.warning { background: var(--yellow); color: var(--text); }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── NOTIFICATIONS ── */
.notif-dropdown {
  position: fixed; top: 60px; right: 16px; width: 340px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); z-index: 900; max-height: 480px; display: flex; flex-direction: column;
}
.notif-header { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.notif-header span { font-size: 14px; font-weight: 600; }
.notif-header button { font-size: 12px; color: var(--blue); background: none; border: none; cursor: pointer; }
.notif-list { overflow-y: auto; flex: 1; }
.notif-item { padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background var(--transition); }
.notif-item:hover { background: var(--hover); }
.notif-item.unread { background: var(--blue-light); }
.notif-item.unread:hover { background: #dbeafe; }
.notif-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.notif-msg { font-size: 12px; color: var(--muted); }
.notif-time { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ── TAB BAR ── */
.tab-bar { display: flex; gap: 2px; padding: 0 20px; border-bottom: 1px solid var(--border); background: var(--card); }
.tab { padding: 12px 16px; font-size: 13.5px; font-weight: 500; color: var(--muted); border: none; background: none; cursor: pointer; border-bottom: 2px solid transparent; transition: color var(--transition), border-color var(--transition); }
.tab:hover { color: var(--text); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }

/* ── PIPELINE PROGRESS BAR ── */
.prob-bar { width: 60px; height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; }
.prob-fill { height: 100%; background: var(--green); border-radius: 99px; }

/* ── TAGS ── */
.tag-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.tag-chip .remove { cursor: pointer; opacity: .6; }
.tag-chip .remove:hover { opacity: 1; }

/* ── SECTION ── */
.section { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.section-header { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.section-title { font-size: 14px; font-weight: 600; color: var(--text); }
.section-body { padding: 16px 20px; }

/* ── STAT ROW ── */
.stat-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.stat-row:last-child { border-bottom: none; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { font-size: 14px; font-weight: 600; color: var(--text); }

/* ── REPORT CHART ── */
.chart-container { position: relative; padding: 20px; }

/* ── TOP REPS TABLE ── */
.rep-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.rep-row:last-child { border-bottom: none; }
.rep-rank { width: 20px; font-size: 12px; color: var(--muted); font-weight: 600; }
.rep-info { flex: 1; }
.rep-name { font-size: 13.5px; font-weight: 500; }
.rep-deals { font-size: 12px; color: var(--muted); }
.rep-revenue { font-size: 14px; font-weight: 700; color: var(--green); }

/* ── OVERVIEW CARDS ── */
.overview-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.overview-card { background: var(--bg); border-radius: var(--radius); padding: 14px; border: 1px solid var(--border); text-align: center; }
.overview-num { font-size: 22px; font-weight: 800; }
.overview-lbl { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── SEGMENTED CONTROL ── */
.seg-control { display: flex; background: var(--hover); border-radius: var(--radius); padding: 3px; gap: 2px; }
.seg-btn { padding: 5px 12px; border-radius: 6px; font-size: 12.5px; font-weight: 500; border: none; background: none; color: var(--muted); cursor: pointer; transition: background var(--transition), color var(--transition); }
.seg-btn.active { background: var(--card); color: var(--text); box-shadow: var(--shadow-sm); }

/* ── BREADCRUMB ── */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.breadcrumb a { color: var(--blue); cursor: pointer; }
.breadcrumb span { color: var(--border-2); }

/* ── MOBILE ── */
@media (max-width: 768px) {
  .sidebar { position: fixed; left: -240px; height: 100%; transition: left var(--transition); }
  .sidebar.mobile-open { left: 0; }
  .mobile-menu-btn { display: flex; }
  .page-header { padding: 16px 20px 12px; }
  .kpi-grid { padding: 0 20px 16px; }
  .table-toolbar { padding: 12px 20px; }
  .content-grid { padding: 0 20px 20px; }
  .detail-layout { padding: 16px 20px; }
  .kanban-wrapper { padding: 16px 20px; }
}

/* ── TENANT BADGE ── */
.tenant-badge { display: flex; align-items: center; gap: 5px; background: var(--blue-light); color: var(--blue-dark); font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 20px; font-family: monospace; }

/* ── TRIAL BANNER ── */
.trial-banner { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 9px 24px; font-size: 13px; font-weight: 500; flex-shrink: 0; }
.trial-banner.active  { background: #fffbeb; border-bottom: 1px solid #fde68a; color: #92400e; }
.trial-banner.warning { background: #fff7ed; border-bottom: 1px solid #fed7aa; color: #7c2d12; }
.trial-banner.expired { background: #fef2f2; border-bottom: 1px solid #fecaca; color: #7f1d1d; }
.trial-banner strong  { font-weight: 700; }
.trial-banner .upgrade-link { background: #f59e0b; color: white; border: none; border-radius: 6px; padding: 4px 12px; font-size: 12px; font-weight: 600; font-family: inherit; cursor: pointer; margin-left: 4px; transition: background .15s; }
.trial-banner.warning .upgrade-link { background: #ea580c; }
.trial-banner.expired .upgrade-link { background: #dc2626; }
