/* ===== VANGUARD CRM STYLES ===== */
:root {
  --blue: #1d60e4;
  --navy: #07124d;
  --accent: #387bfe;
  --dark: #0a0f2e;
  --sidebar-w: 250px;
  --header-h: 60px;
  --gray-50: #f8f9fc;
  --gray-100: #eef0f6;
  --gray-200: #dde1eb;
  --gray-300: #b8bdd0;
  --gray-400: #8a90a5;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --green: #10b981;
  --red: #ef4444;
  --yellow: #f59e0b;
  --orange: #f97316;
  --font-head: 'Black Ops One', Impact, sans-serif;
  --font-body: 'Public Sans', -apple-system, sans-serif;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: var(--font-body); background: var(--gray-50); color: var(--gray-800); line-height: 1.5; overflow-x: hidden; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
ul { list-style: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; }
img { max-width: 100%; display: block; }
h1,h2,h3,h4 { font-weight: 700; color: var(--gray-800); }

/* ===== LAYOUT ===== */
.app { display: flex; min-height: 100vh; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  color: #fff;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform .3s;
}
.sidebar-brand {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  gap: .75rem;
}
.sidebar-brand img { height: 36px; width: auto; }
.sidebar-brand span { font-family: var(--font-head); font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem 0; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem 1.5rem;
  color: rgba(255,255,255,.65);
  font-size: .9rem;
  font-weight: 500;
  transition: all .15s;
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover { color: #fff; background: rgba(255,255,255,.05); text-decoration: none; }
.sidebar-nav a.active { color: #fff; background: rgba(255,255,255,.1); border-left-color: var(--accent); }
.sidebar-nav a svg { width: 20px; height: 20px; flex-shrink: 0; opacity: .7; }
.sidebar-nav a.active svg { opacity: 1; }
.nav-section { padding: .5rem 1.5rem .25rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: rgba(255,255,255,.35); margin-top: .5rem; }
.sidebar-footer { padding: 1rem 1.5rem; border-top: 1px solid rgba(255,255,255,.1); font-size: .8rem; color: rgba(255,255,255,.4); }

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

/* ===== TOP BAR ===== */
.topbar {
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 1rem; }
.topbar-title { font-size: 1.15rem; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.topbar-search {
  display: flex;
  align-items: center;
  background: var(--gray-100);
  border-radius: 6px;
  padding: .4rem .75rem;
  gap: .5rem;
}
.topbar-search input { border: none; background: transparent; width: 200px; font-size: .85rem; outline: none; }
.topbar-search svg { color: var(--gray-400); width: 16px; height: 16px; }
.notif-btn { position: relative; background: none; border: none; color: var(--gray-500); padding: .35rem; border-radius: 6px; transition: background .15s; }
.notif-btn:hover { background: var(--gray-100); }
.notif-btn svg { width: 22px; height: 22px; }
.notif-badge { position: absolute; top: -2px; right: -2px; width: 16px; height: 16px; border-radius: 50%; background: var(--red); color: #fff; font-size: .65rem; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.user-menu { display: flex; align-items: center; gap: .5rem; cursor: pointer; padding: .35rem .5rem; border-radius: 6px; transition: background .15s; border: none; background: none; }
.user-menu:hover { background: var(--gray-100); }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; }
.user-info { text-align: left; }
.user-name { font-size: .85rem; font-weight: 600; color: var(--gray-800); }
.user-role { font-size: .7rem; color: var(--gray-400); text-transform: capitalize; }
.user-dropdown { position: absolute; top: calc(var(--header-h) - 4px); right: 1rem; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg); border: 1px solid var(--gray-200); min-width: 180px; z-index: 200; display: none; }
.user-dropdown.show { display: block; }
.user-dropdown a, .user-dropdown button { display: block; width: 100%; text-align: left; padding: .6rem 1rem; font-size: .85rem; color: var(--gray-700); border: none; background: none; cursor: pointer; }
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--gray-50); text-decoration: none; }

/* ===== CONTENT ===== */
.content { flex: 1; padding: 1.5rem; }
.page { display: none; }
.page.active { display: block; }

/* ===== CARDS ===== */
.card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.card-header h3 { font-size: 1rem; }
.card-body { padding: 1.25rem; }

/* ===== STAT CARDS ===== */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}
.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.blue { background: rgba(29,96,228,.1); color: var(--blue); }
.stat-icon.green { background: rgba(16,185,129,.1); color: var(--green); }
.stat-icon.yellow { background: rgba(245,158,11,.1); color: var(--yellow); }
.stat-icon.red { background: rgba(239,68,68,.1); color: var(--red); }
.stat-icon.orange { background: rgba(249,115,22,.1); color: var(--orange); }
.stat-info { flex: 1; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.2; color: var(--gray-800); }
.stat-label { font-size: .8rem; color: var(--gray-500); margin-top: .1rem; }

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: .7rem 1rem; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--gray-500); background: var(--gray-50); border-bottom: 1px solid var(--gray-200); white-space: nowrap; }
td { padding: .7rem 1rem; border-bottom: 1px solid var(--gray-100); font-size: .875rem; vertical-align: middle; }
tr:hover td { background: var(--gray-50); }
.table-empty { padding: 3rem; text-align: center; color: var(--gray-400); }

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 100px;
  font-size: .7rem;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
}
.badge-green { background: rgba(16,185,129,.1); color: #059669; }
.badge-blue { background: rgba(29,96,228,.1); color: var(--blue); }
.badge-yellow { background: rgba(245,158,11,.1); color: #d97706; }
.badge-red { background: rgba(239,68,68,.1); color: #dc2626; }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }
.badge-orange { background: rgba(249,115,22,.1); color: #ea580c; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-radius: 6px;
  font-size: .85rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all .15s;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--accent); text-decoration: none; }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-outline { background: #fff; color: var(--gray-700); border-color: var(--gray-300); }
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-400); text-decoration: none; }
.btn-sm { padding: .3rem .65rem; font-size: .78rem; }
.btn-lg { padding: .65rem 1.5rem; font-size: .95rem; }
.btn-icon { padding: .4rem; border-radius: 6px; background: none; border: 1px solid transparent; color: var(--gray-500); }
.btn-icon:hover { background: var(--gray-100); color: var(--gray-700); }
.btn-group { display: flex; gap: .5rem; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .8rem; font-weight: 600; color: var(--gray-700); margin-bottom: .35rem; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: .875rem;
  background: #fff;
  color: var(--gray-800);
  transition: border-color .15s, box-shadow .15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29,96,228,.1);
}
.form-textarea { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.form-row-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.form-help { font-size: .75rem; color: var(--gray-400); margin-top: .25rem; }
.form-error { font-size: .75rem; color: var(--red); margin-top: .25rem; }

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all .2s;
}
.modal-overlay.show { opacity: 1; visibility: visible; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 95%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform .2s;
}
.modal-overlay.show .modal { transform: translateY(0); }
.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1000px; }
.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 1.05rem; }
.modal-close { background: none; border: none; color: var(--gray-400); font-size: 1.5rem; padding: .25rem; cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--gray-700); }
.modal-body { padding: 1.25rem; }
.modal-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: .5rem; }

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.page-header h2 { font-size: 1.5rem; }

/* ===== FILTERS ===== */
.filters {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.filters .form-input, .filters .form-select { width: auto; min-width: 150px; padding: .4rem .65rem; font-size: .82rem; }
.filter-search { width: 250px !important; }

/* ===== PAGINATION ===== */
.pagination { display: flex; align-items: center; justify-content: space-between; padding: .75rem 1rem; border-top: 1px solid var(--gray-100); font-size: .82rem; color: var(--gray-500); }
.pagination-btns { display: flex; gap: .35rem; }
.pagination-btns button { padding: .3rem .6rem; border: 1px solid var(--gray-300); border-radius: 4px; background: #fff; font-size: .8rem; color: var(--gray-600); cursor: pointer; }
.pagination-btns button:hover { background: var(--gray-50); }
.pagination-btns button.active { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ===== TABS ===== */
.tabs { display: flex; border-bottom: 2px solid var(--gray-200); margin-bottom: 1.5rem; gap: 0; }
.tab-btn {
  padding: .65rem 1.25rem;
  font-size: .85rem;
  font-weight: 600;
  color: var(--gray-500);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all .15s;
}
.tab-btn:hover { color: var(--gray-700); }
.tab-btn.active { color: var(--blue); border-bottom-color: var(--blue); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== DETAIL VIEW ===== */
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; }
.detail-item { }
.detail-label { font-size: .75rem; color: var(--gray-500); font-weight: 500; }
.detail-value { font-size: .9rem; color: var(--gray-800); font-weight: 500; }

/* ===== ALERTS ===== */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-size: .85rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.alert-info { background: rgba(29,96,228,.08); color: var(--blue); border: 1px solid rgba(29,96,228,.2); }
.alert-warning { background: rgba(245,158,11,.08); color: #d97706; border: 1px solid rgba(245,158,11,.2); }
.alert-danger { background: rgba(239,68,68,.08); color: #dc2626; border: 1px solid rgba(239,68,68,.2); }
.alert-success { background: rgba(16,185,129,.08); color: #059669; border: 1px solid rgba(16,185,129,.2); }

/* ===== DASHBOARD GRID ===== */
.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; }
.dash-grid-equal { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.dash-alerts-list { max-height: 400px; overflow-y: auto; }
.alert-item { padding: .75rem; border-bottom: 1px solid var(--gray-100); display: flex; gap: .75rem; align-items: flex-start; }
.alert-item:last-child { border-bottom: none; }
.alert-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: .35rem; flex-shrink: 0; }
.alert-dot.red { background: var(--red); }
.alert-dot.yellow { background: var(--yellow); }
.alert-dot.blue { background: var(--blue); }
.alert-text { font-size: .82rem; color: var(--gray-700); }
.alert-meta { font-size: .72rem; color: var(--gray-400); margin-top: .15rem; }

/* ===== CHART PLACEHOLDER ===== */
.chart-placeholder {
  height: 250px;
  background: var(--gray-50);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-400);
  font-size: .85rem;
  border: 1px dashed var(--gray-300);
}

/* ===== LOADING ===== */
.loading { display: flex; align-items: center; justify-content: center; padding: 3rem; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--gray-200); border-top-color: var(--blue); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== TOAST ===== */
.toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 9999; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--blue);
  font-size: .85rem;
  min-width: 280px;
  max-width: 400px;
  animation: slideIn .3s ease;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
.toast.warning { border-left-color: var(--yellow); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== MOBILE TOGGLE ===== */
.sidebar-toggle { display: none; background: none; border: none; color: var(--gray-600); padding: .35rem; }
.sidebar-toggle svg { width: 24px; height: 24px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  /* Sidebar: off-canvas with overlay */
  .sidebar { transform: translateX(-100%); width: 280px; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 99;
  }
  .sidebar.open ~ .sidebar-overlay { display: block; }
  .main { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .sidebar-nav a { padding: .85rem 1.5rem; font-size: .95rem; }

  /* Topbar */
  .topbar { padding: 0 .75rem; height: 54px; }
  .topbar-search { display: none; }
  .topbar-title { font-size: 1rem; }
  .user-info { display: none; }
  .user-menu { padding: .25rem; }

  /* Content */
  .content { padding: .75rem; }
  .page-header { margin-bottom: 1rem; }
  .page-header h2 { font-size: 1.2rem; }

  /* Stats */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: .5rem; margin-bottom: 1rem; }
  .stat-card { padding: .75rem; gap: .5rem; }
  .stat-icon { width: 36px; height: 36px; border-radius: 8px; }
  .stat-icon svg { width: 18px; height: 18px; }
  .stat-value { font-size: 1.25rem; }
  .stat-label { font-size: .7rem; }

  /* Dashboard grids */
  .dash-grid, .dash-grid-equal { grid-template-columns: 1fr; gap: 1rem; }

  /* Tables */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -.75rem; padding: 0 .75rem; }
  th, td { padding: .55rem .65rem; font-size: .8rem; }

  /* Forms */
  .form-row, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
  .form-input, .form-select, .form-textarea { font-size: 16px; padding: .6rem .75rem; }
  .form-group { margin-bottom: .75rem; }

  /* Buttons - larger touch targets */
  .btn { padding: .6rem 1rem; font-size: .9rem; }
  .btn-sm { padding: .45rem .75rem; }
  .btn-group { flex-wrap: wrap; }
  .btn-icon { padding: .5rem; }

  /* Filters */
  .filters { gap: .5rem; }
  .filters .form-input, .filters .form-select { min-width: 0; flex: 1; font-size: .85rem; }
  .filter-search { width: 100% !important; }

  /* Modals - full screen on mobile */
  .modal-overlay { align-items: flex-end; }
  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    border-radius: 12px 12px 0 0;
    transform: translateY(100%);
  }
  .modal-overlay.show .modal { transform: translateY(0); }
  .modal-lg, .modal-xl { max-width: 100%; }
  .modal-header { padding: .85rem 1rem; }
  .modal-body { padding: 1rem; }
  .modal-footer { padding: .85rem 1rem; }

  /* Detail view */
  .detail-grid { grid-template-columns: 1fr; gap: .5rem; }
  .detail-value { font-size: .85rem; }

  /* Tabs */
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 0; }
  .tab-btn { padding: .55rem .85rem; font-size: .8rem; white-space: nowrap; }

  /* Cards */
  .card-header { padding: .75rem 1rem; flex-wrap: wrap; }
  .card-body { padding: .75rem 1rem; }

  /* Toast */
  .toast-container { top: auto; bottom: .75rem; right: .5rem; left: .5rem; }
  .toast { min-width: 0; max-width: 100%; }

  /* User dropdown */
  .user-dropdown { right: .5rem; }

  /* Pagination */
  .pagination { flex-wrap: wrap; gap: .5rem; padding: .6rem .75rem; }
}

  /* Hide less important columns */
  .hide-mobile { display: none !important; }

/* Small phones */
@media (max-width: 420px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .btn-group { width: 100%; }
  .btn-group .btn { flex: 1; justify-content: center; }
  .topbar-right .notif-btn { display: none; }
}
