/* ===== MenuDisplays CRM Stylesheet ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #00d4ff;
  --primary-dark: #00a8cc;
  --dark: #1a1a2e;
  --dark2: #16213e;
  --sidebar-w: 230px;
  --text: #1a1a2e;
  --text-light: #666;
  --bg: #f4f6fa;
  --card: #ffffff;
  --border: #e2e8f0;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,0.07);
  --font: 'Inter', -apple-system, sans-serif;
}

html, body { height: 100%; font-family: var(--font); background: var(--bg); color: var(--text); }

/* ===== LAYOUT ===== */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--dark); display: flex; flex-direction: column;
  z-index: 100; transition: transform 0.3s;
}
.main-wrap { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

/* ===== SIDEBAR ===== */
.sidebar-logo { padding: 20px 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.logo-text { font-size: 20px; font-weight: 900; color: white; display: block; }
.logo-accent { color: var(--primary); }
.logo-sub { font-size: 11px; color: rgba(255,255,255,0.35); margin-top: 2px; display: block; }
.sidebar-nav { list-style: none; padding: 12px 0; flex: 1; overflow-y: auto; }
.sidebar-nav li a {
  display: flex; align-items: center; gap: 10px; padding: 10px 20px;
  color: rgba(255,255,255,0.65); text-decoration: none; font-size: 14px; font-weight: 500;
  border-left: 3px solid transparent; transition: all 0.15s;
}
.sidebar-nav li a:hover, .sidebar-nav li a.active {
  color: white; background: rgba(255,255,255,0.06); border-left-color: var(--primary);
}
.nav-icon { font-size: 16px; width: 22px; text-align: center; }
.badge {
  margin-left: auto; background: var(--danger); color: white;
  font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 20px; min-width: 20px; text-align: center;
}
.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-footer span { display: block; font-size: 12px; color: rgba(255,255,255,0.4); }

/* ===== TOPBAR ===== */
.topbar {
  height: 60px; background: white; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; padding: 0 24px; position: sticky; top: 0; z-index: 50;
}
.sidebar-toggle { display: none; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text); }
.topbar-title { font-size: 18px; font-weight: 700; color: var(--text); flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-date { font-size: 13px; color: var(--text-light); }

/* ===== BUTTONS ===== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: 8px; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; border: none; transition: all 0.15s; font-family: var(--font); }
.btn-primary { background: var(--primary); color: var(--dark); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline { background: transparent; color: var(--text); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-xs { padding: 4px 10px; font-size: 12px; }

/* ===== MAIN CONTENT ===== */
.main-content { padding: 24px; flex: 1; }

/* ===== KPI CARDS ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi-card {
  background: var(--card); border-radius: var(--radius); padding: 20px 16px;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 14px;
  border-left: 4px solid transparent;
}
.kpi-card.highlight { border-left-color: var(--success); }
.kpi-card.warn { border-left-color: var(--warning); }
.kpi-icon { font-size: 28px; flex-shrink: 0; }
.kpi-val { font-size: 26px; font-weight: 800; color: var(--text); line-height: 1; }
.kpi-label { font-size: 13px; font-weight: 600; color: var(--text); margin-top: 4px; }
.kpi-sub { font-size: 11px; color: var(--text-light); margin-top: 2px; }

/* ===== DASHBOARD ROWS ===== */
.dash-row { display: flex; gap: 20px; margin-bottom: 20px; }
.dash-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; flex: 1; }
.card-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-header h3 { font-size: 15px; font-weight: 700; color: var(--text); }
.card-link { font-size: 13px; color: var(--primary); text-decoration: none; font-weight: 600; }
.loading-row { padding: 20px; text-align: center; color: var(--text-light); font-size: 14px; }

/* ===== PIPELINE BARS ===== */
.pipeline-bars { padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; }
.pipeline-loading { color: var(--text-light); font-size: 14px; text-align: center; padding: 20px; }
.pipeline-row { display: flex; align-items: center; gap: 12px; }
.pipeline-label { font-size: 13px; color: var(--text); width: 110px; flex-shrink: 0; }
.pipeline-bar-wrap { flex: 1; background: #f0f2f5; border-radius: 4px; height: 10px; overflow: hidden; }
.pipeline-bar { height: 100%; border-radius: 4px; background: var(--primary); transition: width 0.5s; }
.pipeline-count { font-size: 13px; font-weight: 700; color: var(--text); width: 24px; text-align: right; }

/* ===== LEADS LIST (HOT) ===== */
.leads-list { padding: 8px 0; }
.lead-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 20px;
  border-bottom: 1px solid var(--border); text-decoration: none; color: inherit; transition: background 0.1s;
}
.lead-row:hover { background: #f8fafc; }
.lead-row:last-child { border-bottom: none; }
.lead-avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--dark), var(--primary)); display: flex; align-items: center; justify-content: center; color: white; font-size: 14px; font-weight: 700; flex-shrink: 0; }
.lead-info { flex: 1; min-width: 0; }
.lead-name { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead-meta { font-size: 12px; color: var(--text-light); }
.status-pill { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; white-space: nowrap; }
.pill-hot { background: #fef2f2; color: #dc2626; }
.pill-warm { background: #fffbeb; color: #d97706; }
.pill-cold { background: #eff6ff; color: #2563eb; }
.pill-new { background: #f0fdf4; color: #16a34a; }
.pill-contacted { background: #eff6ff; color: #2563eb; }
.pill-qualified { background: #fdf4ff; color: #9333ea; }
.pill-sent { background: #fff7ed; color: #ea580c; }
.pill-won { background: #f0fdf4; color: #16a34a; }
.pill-lost { background: #fef2f2; color: #dc2626; }
.pill-pending { background: #fffbeb; color: #d97706; }
.pill-approved { background: #f0fdf4; color: #16a34a; }
.pill-paid { background: #f0fdf4; color: #16a34a; }
.pill-overdue { background: #fef2f2; color: #dc2626; }
.pill-draft { background: #f8fafc; color: #64748b; }

/* ===== APPROVAL LIST ===== */
.approval-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}
.approval-row:last-child { border-bottom: none; }
.approval-info { flex: 1; }
.approval-subject { font-size: 14px; font-weight: 600; color: var(--text); }
.approval-detail { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.approval-actions { display: flex; gap: 8px; }
.urgency-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-top: 3px; }
.urgency-urgent { background: var(--danger); }
.urgency-high { background: var(--warning); }
.urgency-medium { background: var(--info); }
.urgency-low { background: var(--success); }

/* ===== DATA TABLE ===== */
.data-table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th { background: #f8fafc; padding: 12px 16px; text-align: left; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-light); border-bottom: 2px solid var(--border); white-space: nowrap; }
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.data-table tr:hover td { background: #f8fafc; }
.data-table tr:last-child td { border-bottom: none; }
.table-action { display: flex; gap: 6px; }

/* ===== PAGE LAYOUT ===== */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.page-title { font-size: 22px; font-weight: 800; color: var(--text); }
.page-actions { display: flex; gap: 10px; align-items: center; }
.filter-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.filter-input { padding: 8px 14px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 14px; font-family: var(--font); color: var(--text); background: white; }
.filter-input:focus { outline: none; border-color: var(--primary); }

/* ===== MODAL ===== */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 200; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: white; border-radius: var(--radius); width: 100%; max-width: 640px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-light); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ===== FORMS ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text); }
.form-group input, .form-group select, .form-group textarea {
  padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: var(--font); color: var(--text); background: white; width: 100%;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--primary); }

/* ===== ESTIMATE BUILDER ===== */
.line-items-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.line-items-table th { background: var(--dark); color: white; padding: 10px 12px; font-size: 13px; text-align: left; }
.line-items-table td { padding: 8px; border-bottom: 1px solid var(--border); }
.line-items-table input, .line-items-table select { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; width: 100%; background: white; }
.estimate-totals { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; padding: 12px 0; }
.total-row { display: flex; gap: 20px; font-size: 14px; }
.total-row span:first-child { color: var(--text-light); }
.total-row.grand { font-size: 18px; font-weight: 800; color: var(--dark); border-top: 2px solid var(--dark); padding-top: 8px; margin-top: 4px; }

/* ===== KANBAN (Projects) ===== */
.kanban { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 12px; }
.kanban-col { min-width: 220px; background: #f0f2f5; border-radius: var(--radius); flex-shrink: 0; }
.kanban-header { padding: 12px 16px; font-size: 13px; font-weight: 700; color: var(--text); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; }
.kanban-cards { padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.kanban-card { background: white; border-radius: 8px; padding: 12px; box-shadow: var(--shadow); cursor: pointer; }
.kanban-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.12); }
.kanban-card h4 { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.kanban-card p { font-size: 12px; color: var(--text-light); }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-light); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h4 { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.empty-state p { font-size: 14px; margin-bottom: 20px; }

/* ===== TOAST ===== */
#toast { position: fixed; bottom: 24px; right: 24px; background: var(--dark); color: white; padding: 14px 20px; border-radius: 10px; font-size: 14px; font-weight: 500; z-index: 999; display: none; box-shadow: 0 8px 24px rgba(0,0,0,0.2); }
#toast.success { background: var(--success); }
#toast.error { background: var(--danger); }

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .dash-row { flex-direction: column; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .main-content { padding: 16px; }
}
