/* ============================================
   SUBSET CRM — Design System
   ============================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
  --bg-base:       #0d0f1a;
  --bg-surface:    #13162a;
  --bg-elevated:   #1c2040;
  --bg-hover:      #222748;
  --sidebar-bg:    #0a0c18;
  --sidebar-width: 230px;

  --accent:        #6c63ff;
  --accent-soft:   rgba(108, 99, 255, 0.15);
  --accent-glow:   rgba(108, 99, 255, 0.35);

  --success:       #22d3a3;
  --success-soft:  rgba(34, 211, 163, 0.14);
  --warning:       #fbbf24;
  --warning-soft:  rgba(251, 191, 36, 0.14);
  --danger:        #f87171;
  --danger-soft:   rgba(248, 113, 113, 0.14);
  --info:          #60a5fa;
  --info-soft:     rgba(96, 165, 250, 0.14);

  --text-primary:  #e8eaf6;
  --text-secondary:#9098c0;
  --text-muted:    #5a6390;

  --border:        rgba(255,255,255,0.07);
  --border-bright: rgba(255,255,255,0.14);

  --radius-sm:  6px;
  --radius-md:  12px;
  --radius-lg:  18px;
  --radius-xl:  24px;

  --shadow-sm:  0 2px 8px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 24px rgba(0,0,0,0.5);
  --shadow-lg:  0 8px 48px rgba(0,0,0,0.6);

  --transition: 0.2s ease;
  --font-body:  'Inter', sans-serif;
  --font-head:  'Outfit', sans-serif;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; outline: none; }
input, textarea, select { font-family: inherit; outline: none; border: none; }
ul, ol { list-style: none; }
img { max-width: 100%; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  padding: 24px 0 16px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px 28px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.brand-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  box-shadow: 0 0 24px var(--accent-glow);
  flex-shrink: 0;
}
.brand-name {
  font-family: var(--font-head);
  font-size: 16px; font-weight: 700;
  color: var(--text-primary);
  display: block; line-height: 1.2;
}
.brand-sub {
  font-size: 11px; color: var(--text-muted);
  display: block; margin-top: 2px;
}

/* Nav items */
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 10px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 14px; font-weight: 500;
  transition: all var(--transition);
  position: relative;
  cursor: pointer;
}
.nav-item:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.nav-item.active .nav-icon { color: var(--accent); }
.nav-icon { display: flex; align-items: center; flex-shrink: 0; }
.nav-label { flex: 1; }
.nav-badge {
  background: var(--accent);
  color: #fff; font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 99px;
  min-width: 20px; text-align: center;
}
.nav-badge:empty { display: none; }
.nav-badge.danger { background: var(--danger); }
.nav-badge.success { background: var(--success); }

.sidebar-footer {
  padding: 16px 20px 0;
  border-top: 1px solid var(--border);
}
.sidebar-date {
  font-size: 11px; color: var(--text-muted);
  line-height: 1.6;
}

/* ---------- Main Content ---------- */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  padding: 32px 36px;
}

/* ---------- Page Header ---------- */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 28px; gap: 16px; flex-wrap: wrap;
}
.page-title {
  font-family: var(--font-head);
  font-size: 28px; font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}
.page-subtitle { font-size: 14px; color: var(--text-muted); margin-top: 4px; }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: border-color var(--transition);
}
.card:hover { border-color: var(--border-bright); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.stat-card.accent::before { background: linear-gradient(90deg, var(--accent), #a78bfa); }
.stat-card.success::before { background: linear-gradient(90deg, var(--success), #34d399); }
.stat-card.warning::before { background: linear-gradient(90deg, var(--warning), #f59e0b); }
.stat-card.danger::before  { background: linear-gradient(90deg, var(--danger),  #fb923c); }
.stat-card.info::before    { background: linear-gradient(90deg, var(--info),    #818cf8); }

.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }
.stat-value {
  font-family: var(--font-head);
  font-size: 34px; font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
  margin: 6px 0 0;
}
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ---------- Sections & Grids ---------- */
.section-title {
  font-size: 16px; font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}
.section-title .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  display: inline-block;
  box-shadow: 0 0 8px var(--accent-glow);
}

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .two-col, .three-col { grid-template-columns: 1fr; } }

/* ---------- Tables ---------- */
.table-wrapper { overflow-x: auto; border-radius: var(--radius-md); }
.data-table {
  width: 100%; border-collapse: collapse;
  font-size: 13.5px;
}
.data-table thead th {
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px;
  padding: 10px 14px;
  text-align: left;
  white-space: nowrap;
}
.data-table thead th:first-child { border-radius: var(--radius-sm) 0 0 0; }
.data-table thead th:last-child  { border-radius: 0 var(--radius-sm) 0 0; }
.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.data-table tbody tr:hover { background: var(--bg-elevated); }
.data-table tbody tr.overdue-row { background: rgba(248,113,113,0.04); }
.data-table td { padding: 12px 14px; color: var(--text-primary); vertical-align: middle; }
.data-table .cell-muted { color: var(--text-muted); font-size: 12px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 99px;
  font-size: 11.5px; font-weight: 600;
  white-space: nowrap;
}
.badge-accent  { background: var(--accent-soft);  color: var(--accent); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-info    { background: var(--info-soft);    color: var(--info); }
.badge-muted   { background: var(--bg-elevated);  color: var(--text-muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--radius-md);
  font-size: 13.5px; font-weight: 600;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 20px var(--accent-glow);
}
.btn-primary:hover {
  background: #7c72ff;
  box-shadow: 0 0 28px var(--accent-glow);
  transform: translateY(-1px);
}
.btn-ghost {
  background: var(--bg-elevated); color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-success { background: var(--success); color: #0d1a14; }
.btn-success:hover { background: #1cbf93; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #ef4444; }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-icon { padding: 7px; border-radius: var(--radius-sm); }

/* ---------- Forms ---------- */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }
.form-input, .form-select, .form-textarea {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 14px;
  font-size: 14px;
  transition: border-color var(--transition);
  width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-select { appearance: none; cursor: pointer; }
.form-textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
option { background: var(--bg-elevated); color: var(--text-primary); }

/* ---------- Search Bar ---------- */
.search-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 14px;
  width: 260px;
  transition: border-color var(--transition);
}
.search-bar:focus-within { border-color: var(--accent); }
.search-bar input {
  background: none; color: var(--text-primary);
  font-size: 14px; flex: 1;
}
.search-bar svg { color: var(--text-muted); flex-shrink: 0; }

/* ---------- Todo / List Items ---------- */
.todo-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  transition: opacity var(--transition);
}
.todo-item:last-child { border-bottom: none; }
.todo-item.done { opacity: .4; }
.todo-check {
  width: 20px; height: 20px;
  border: 2px solid var(--border-bright);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; margin-top: 1px;
  transition: all var(--transition);
  background: transparent;
  padding: 0;
}
.todo-check.checked {
  background: var(--accent); border-color: var(--accent);
}
.todo-check.checked svg { display: block; }
.todo-check svg { display: none; color: #fff; }
.todo-body { flex: 1; }
.todo-title { font-size: 14px; color: var(--text-primary); font-weight: 500; }
.todo-meta  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.todo-time  { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* ---------- Followup Timeline ---------- */
.timeline { position: relative; padding-left: 20px; }
.timeline::before {
  content: ''; position: absolute;
  top: 0; left: 6px; bottom: 0;
  width: 2px; background: var(--border);
}
.tl-item {
  position: relative; padding: 0 0 20px 22px;
}
.tl-dot {
  position: absolute; left: -14px; top: 4px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-base);
  box-shadow: 0 0 8px var(--accent-glow);
}
.tl-dot.done   { background: var(--success); box-shadow: 0 0 8px rgba(34,211,163,.4); }
.tl-dot.missed { background: var(--danger);  box-shadow: 0 0 8px rgba(248,113,113,.4); }
.tl-date { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.tl-body { font-size: 13.5px; color: var(--text-primary); }
.tl-sub  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ---------- Kanban Board ---------- */
.kanban { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 8px; }
.kanban-col {
  min-width: 220px; flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.kanban-col-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.kanban-col-title {
  font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted);
}
.kanban-count {
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 99px;
}
.kanban-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.kanban-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.kanban-card-name { font-size: 13.5px; font-weight: 600; color: var(--text-primary); }
.kanban-card-sub  { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.kanban-card-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }

/* ---------- Calendar ---------- */
.cal-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.cal-month {
  font-family: var(--font-head);
  font-size: 20px; font-weight: 700; color: var(--text-primary);
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.cal-day-name {
  text-align: center;
  font-size: 11px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  padding-bottom: 8px;
}
.cal-cell {
  min-height: 80px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.cal-cell:hover { border-color: var(--border-bright); background: var(--bg-elevated); }
.cal-cell.today { border-color: var(--accent); box-shadow: 0 0 12px var(--accent-glow); }
.cal-cell.other-month { opacity: .4; }
.cal-num {
  font-size: 13px; font-weight: 600; color: var(--text-secondary);
  margin-bottom: 4px;
}
.cal-cell.today .cal-num { color: var(--accent); }
.cal-event {
  font-size: 10.5px; font-weight: 500;
  padding: 2px 6px; border-radius: 4px;
  margin-bottom: 2px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.cal-event.followup  { background: var(--info-soft);    color: var(--info); }
.cal-event.payment   { background: var(--warning-soft); color: var(--warning); }
.cal-event.meeting   { background: var(--success-soft); color: var(--success); }
.cal-event.urgent    { background: var(--danger-soft);  color: var(--danger); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-xl);
  padding: 32px;
  width: 100%; max-width: 560px;
  max-height: 88vh; overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: slideUp .25s ease;
}
.modal-close {
  position: absolute; top: 16px; right: 18px;
  background: var(--bg-elevated); color: var(--text-muted);
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  font-size: 14px; display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.modal-title {
  font-family: var(--font-head);
  font-size: 20px; font-weight: 700; color: var(--text-primary);
  margin-bottom: 20px;
}

/* ---------- Toast ---------- */
#toast-container {
  position: fixed; bottom: 28px; right: 28px;
  z-index: 1000; display: flex; flex-direction: column; gap: 10px;
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-size: 14px; color: var(--text-primary);
  box-shadow: var(--shadow-md);
  animation: slideInRight .25s ease;
  display: flex; align-items: center; gap: 10px;
  min-width: 260px; max-width: 360px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--info); }

/* ---------- Empty State ---------- */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 48px 16px; text-align: center;
  color: var(--text-muted);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: .5; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.empty-sub   { font-size: 13px; }

/* ---------- Client Locations ---------- */
.location-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.location-chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px; font-weight: 500;
  padding: 2px 10px; border-radius: 99px;
}

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 0; }
.tab {
  padding: 8px 16px; font-size: 13.5px; font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer; background: none;
  transition: all var(--transition);
  border-bottom: 2px solid transparent;
  position: relative; bottom: -1px;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Inline Actions ---------- */
.action-row {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 18px; gap: 12px; flex-wrap: wrap;
}
.action-left, .action-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- Progress Bar ---------- */
.progress-bar {
  height: 6px; border-radius: 99px;
  background: var(--bg-elevated); overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), #a78bfa);
  transition: width .4s ease;
}

/* ---------- Pill filters ---------- */
.filter-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  padding: 5px 14px; border-radius: 99px;
  font-size: 12.5px; font-weight: 600;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer; transition: all var(--transition);
}
.pill:hover   { border-color: var(--border-bright); color: var(--text-primary); }
.pill.active  { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ---------- Report bars ---------- */
.report-bar-row {
  display: grid; grid-template-columns: 120px 1fr 60px;
  align-items: center; gap: 12px; margin-bottom: 10px;
}
.report-bar-label { font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.report-bar-val   { font-size: 13px; font-weight: 700; color: var(--text-primary); text-align: right; }

/* ---------- Upload Zone ---------- */
.upload-zone {
  border: 2px dashed var(--border-bright);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.upload-zone input { display: none; }
.upload-icon { font-size: 36px; margin-bottom: 10px; }
.upload-text { font-size: 14px; color: var(--text-secondary); }
.upload-sub  { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-hover); }

/* ---------- Divider ---------- */
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ---------- Animations ---------- */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.fade-in { animation: fadeIn .3s ease; }
