/* ============================================================
   Office CRM — app.css
   Font: DM Sans (clean, professional)
   Palette: Deep navy sidebar + warm white content
   ============================================================ */

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

:root {
  --navy:      #0f1b2d;
  --navy-2:    #162236;
  --navy-3:    #1e3050;
  --accent:    #3b82f6;
  --accent-h:  #2563eb;
  --accent-s:  #dbeafe;
  --green:     #10b981;
  --green-s:   #d1fae5;
  --amber:     #f59e0b;
  --amber-s:   #fef3c7;
  --red:       #ef4444;
  --red-s:     #fee2e2;
  --purple:    #8b5cf6;
  --purple-s:  #ede9fe;

  --bg:        #f8fafc;
  --bg-card:   #ffffff;
  --border:    #e2e8f0;
  --border-2:  #cbd5e1;
  --text:      #0f172a;
  --text-2:    #475569;
  --text-3:    #94a3b8;

  --sidebar-w: 240px;
  --radius:    10px;
  --shadow:    0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--navy-3);
}
.logo-icon { font-size: 22px; color: var(--accent); }
.logo-text  { font-size: 16px; font-weight: 600; color: #f1f5f9; letter-spacing: -.3px; }

.nav-links {
  list-style: none;
  padding: 16px 12px;
  flex: 1;
  overflow-y: auto;
}
.nav-links li + li { margin-top: 2px; }
.nav-links a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 400;
  transition: background .15s, color .15s;
}
.nav-links a svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-links a:hover { background: var(--navy-3); color: #e2e8f0; }
.nav-links a.active { background: var(--accent); color: #fff; font-weight: 500; }

.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid var(--navy-3);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-badge { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; flex-shrink: 0;
}
.user-name { font-size: 12.5px; font-weight: 500; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-3); text-transform: capitalize; }
.logout-btn {
  color: #64748b;
  display: flex; align-items: center;
  transition: color .15s;
}
.logout-btn svg { width: 17px; height: 17px; }
.logout-btn:hover { color: var(--red); }

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

/* ── Topbar ── */
.topbar {
  height: 56px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  position: sticky; top: 0; z-index: 50;
}
.sidebar-toggle { display: none; background: none; border: none; cursor: pointer; color: var(--text-2); }
.sidebar-toggle svg { width: 22px; height: 22px; }
.topbar-title { font-size: 15px; font-weight: 600; flex: 1; }
.topbar-actions { display: flex; gap: 8px; }

/* ── Flash ── */
.flash {
  padding: 11px 24px;
  font-size: 13.5px;
  font-weight: 500;
}
.flash-success { background: var(--green-s); color: #065f46; border-bottom: 1px solid #a7f3d0; }
.flash-error   { background: var(--red-s);   color: #991b1b; border-bottom: 1px solid #fca5a5; }
.flash-info    { background: var(--accent-s); color: #1e40af; border-bottom: 1px solid #93c5fd; }

/* ── Page content ── */
.page-content { padding: 28px 28px 40px; flex: 1; }

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

/* ── Stat cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.stat-icon {
  width: 40px; height: 40px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
}
.stat-icon.blue   { background: var(--accent-s); }
.stat-icon.green  { background: var(--green-s); }
.stat-icon.amber  { background: var(--amber-s); }
.stat-icon.purple { background: var(--purple-s); }
.stat-icon.red    { background: var(--red-s); }
.stat-val  { font-size: 24px; font-weight: 600; line-height: 1.2; }
.stat-label{ font-size: 12px; color: var(--text-2); margin-top: 2px; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead tr { border-bottom: 1px solid var(--border); }
th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-3);
  white-space: nowrap;
}
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
.td-name { font-weight: 500; }
.td-sub  { font-size: 12px; color: var(--text-2); }

/* ── Badges / Status ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-new       { background:#eff6ff; color:#1d4ed8; }
.badge-contacted { background:#fef3c7; color:#92400e; }
.badge-qualified { background:#d1fae5; color:#065f46; }
.badge-proposal  { background:#ede9fe; color:#5b21b6; }
.badge-won       { background:#dcfce7; color:#14532d; }
.badge-lost      { background:#fee2e2; color:#991b1b; }
.badge-active    { background:#d1fae5; color:#065f46; }
.badge-inactive  { background:#f1f5f9; color:#475569; }
.badge-prospect  { background:#eff6ff; color:#1d4ed8; }
.badge-high      { background:#fee2e2; color:#991b1b; }
.badge-medium    { background:#fef3c7; color:#92400e; }
.badge-low       { background:#f0fdf4; color:#166534; }
.badge-call      { background:#ede9fe; color:#5b21b6; }
.badge-email     { background:#dbeafe; color:#1e40af; }
.badge-meeting   { background:#d1fae5; color:#065f46; }
.badge-note      { background:#f1f5f9; color:#475569; }
.badge-task      { background:#fef3c7; color:#92400e; }
.badge-zoom_call { background:#ede9fe; color:#5b21b6; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 15px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, box-shadow .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); }
.btn-secondary { background: var(--bg-card); color: var(--text); border-color: var(--border-2); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger    { background: var(--red); color: #fff; }
.btn-danger:hover  { background: #dc2626; }
.btn-green     { background: var(--green); color: #fff; }
.btn-sm        { padding: 4px 10px; font-size: 12.5px; }
.btn-icon      { padding: 6px 8px; }

/* ── Forms ── */
.form-grid   { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-group  { display: flex; flex-direction: column; gap: 5px; }
.form-full   { grid-column: 1 / -1; }
label        { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.form-control {
  padding: 8px 12px;
  border: 1px solid var(--border-2);
  border-radius: 7px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-card);
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
select.form-control { cursor: pointer; }
textarea.form-control { min-height: 90px; resize: vertical; }

/* ── Search bar ── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: var(--radius) var(--radius) 0 0;
  flex-wrap: wrap;
}
.search-input-wrap { position: relative; flex: 1; min-width: 180px; }
.search-input-wrap svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--text-3);
}
.search-input {
  padding: 7px 12px 7px 33px;
  border: 1px solid var(--border-2);
  border-radius: 7px;
  font-size: 13.5px;
  font-family: inherit;
  width: 100%;
  background: var(--bg);
}
.search-input:focus { outline: none; border-color: var(--accent); background: #fff; }

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}
.page-header h1 { font-size: 20px; font-weight: 600; }

/* ── Call Popup ── */
.call-popup {
  position: fixed;
  bottom: 24px; right: 24px;
  width: 320px;
  background: var(--navy);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,.3);
  z-index: 999;
  overflow: hidden;
  animation: slideUp .3s ease;
  color: #f1f5f9;
}
.call-popup.hidden { display: none; }
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.call-popup-header {
  background: var(--accent);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.call-popup-header .pulse {
  width: 8px; height: 8px; border-radius: 50%;
  background: #fff;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }
.call-popup-body { padding: 14px; }
.call-caller-name { font-size: 17px; font-weight: 600; margin-bottom: 3px; }
.call-caller-num  { font-size: 12.5px; color: #94a3b8; margin-bottom: 12px; }
.call-customer-info { background: var(--navy-3); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; font-size: 12.5px; line-height: 1.8; }
.call-popup-actions { display: flex; gap: 8px; }
.call-popup-actions .btn { flex: 1; justify-content: center; font-size: 12.5px; }

/* ── Login page ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
}
.login-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 40px 36px;
  width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo .logo-icon { font-size: 36px; color: var(--accent); display: block; margin-bottom: 8px; }
.login-logo h1 { font-size: 20px; font-weight: 600; }
.login-logo p { font-size: 13px; color: var(--text-2); margin-top: 4px; }

/* ── Detail page ── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}
.info-table { width: 100%; }
.info-table tr td:first-child {
  width: 40%;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-3);
  padding: 8px 0;
  vertical-align: top;
}
.info-table tr td:last-child {
  padding: 8px 0;
  color: var(--text);
}
.info-table tr { border-bottom: 1px solid var(--border); }
.info-table tr:last-child { border-bottom: none; }

.timeline { list-style: none; padding: 0; }
.timeline li {
  position: relative;
  padding: 0 0 18px 28px;
}
.timeline li::before {
  content: '';
  position: absolute;
  left: 8px; top: 6px; bottom: -4px;
  width: 1px;
  background: var(--border);
}
.timeline li:last-child::before { display: none; }
.timeline li::after {
  content: '';
  position: absolute;
  left: 4px; top: 6px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-card);
}
.tl-type  { display: inline-flex; margin-bottom: 4px; }
.tl-subj  { font-size: 13.5px; font-weight: 500; }
.tl-body  { font-size: 12.5px; color: var(--text-2); margin-top: 3px; }
.tl-meta  { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--bg-card);
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}
.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 15px; font-weight: 600; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-3); font-size: 20px; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body   { padding: 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-3); }
.empty-state svg { width: 40px; height: 40px; margin-bottom: 12px; opacity: .4; }
.empty-state p { font-size: 14px; }

/* ── Pagination ── */
.pagination { display: flex; align-items: center; gap: 4px; padding: 14px 20px; justify-content: flex-end; }
.pagination a, .pagination span {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 6px;
  font-size: 13px;
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--border);
}
.pagination a:hover  { background: var(--bg); }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Responsive ── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid.cols-3 { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .page-content { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .topbar { padding: 0 14px; }
  .call-popup { width: calc(100vw - 32px); right: 16px; bottom: 16px; }
}

/* ── Dashboard hero cards & charts ── */
.hero-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(215px,1fr)); gap:16px; margin-bottom:22px; }
.hero-card { border-radius:14px; padding:20px 22px; color:#fff; box-shadow:0 6px 18px rgba(15,27,45,.18); }
.hero-sub { font-size:11.5px; opacity:.85; margin-bottom:6px; font-weight:500; letter-spacing:.2px; }
.hero-val { font-size:27px; font-weight:600; line-height:1.15; letter-spacing:-.5px; }
.hero-label { font-size:12.5px; opacity:.9; margin-top:4px; }
.brk { display:flex; justify-content:space-between; padding:7px 0; border-bottom:1px solid var(--border); font-size:13.5px; }
.brk span { color:var(--text-2); }
@media (max-width:1000px) { .charts-row { grid-template-columns:1fr !important; } .ops-row { grid-template-columns:1fr !important; } }

/* ── Filter chips & product badges ── */
.chips { display:flex; gap:10px; flex-wrap:wrap; margin-bottom:16px; }
.chip { display:inline-flex; align-items:center; gap:7px; padding:7px 14px; border-radius:20px;
  background:var(--bg-card); border:1px solid var(--border); font-size:13px; color:var(--text-2);
  text-decoration:none; transition:border-color .15s, box-shadow .15s; }
.chip b { color:var(--text); font-weight:600; }
.chip:hover { border-color:var(--border-2); box-shadow:var(--shadow); }
.chip-on { border-color:var(--accent); background:var(--accent-s); color:#1e40af; }
.chip-on b { color:#1e40af; }
.chip-billing.chip-on { border-color:var(--amber); background:var(--amber-s); color:#92400e; }
.chip-billing.chip-on b { color:#92400e; }
.chip-tech.chip-on { border-color:var(--purple); background:var(--purple-s); color:#5b21b6; }
.chip-tech.chip-on b { color:#5b21b6; }
.chip-closed.chip-on { border-color:var(--green); background:var(--green-s); color:#065f46; }
.chip-closed.chip-on b { color:#065f46; }
.chip-cb { border-color:#fca5a5; }
.pbadge { display:inline-flex; padding:3px 10px; border-radius:6px; font-size:11.5px; font-weight:600; letter-spacing:.2px; }
