/* ============================
   Vero CRM — Design System
   ============================ */

:root {
  --bg: #0A0A0A;
  --surface: #111111;
  --surface-solid: #111111;
  --elevated: #0F0F10;
  --border: #1A1A1A;
  --accent: #2D9CDB;
  --text: #FFFFFF;
  --text-secondary: #B0B0B0;
  --text-muted: #808080;
  --stage-lead: #3b82f6;
  --stage-warm: #f59e0b;
  --stage-proposal: #a855f7;
  --stage-won: #10b981;
  --stage-lost: #ef4444;
  --stage-cold: #6b7280;
  --stale: #f59e0b;
  --radius: 10px;
  --radius-sm: 8px;
  --radius-lg: 14px;
  --font: 'Inter', sans-serif;
  --font-head: 'Inter', sans-serif;
}

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

html { font-size: 16px; }
body {
  font-family: var(--font);
  background: #0A0A0A;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
  line-height: 1.5;
}

h1, h2, h3, .section-title, .modal-title, .panel-header h2,
.metric-label, .tab, .brand, .kh-name, .panel-activity-title {
  font-family: var(--font-head);
}

.hidden { display: none !important; }

/* ============================
   Scrollbar
   ============================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ============================
   Header
   ============================ */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-right { display: flex; align-items: center; gap: 16px; }
.brand { font-family: var(--font-head); font-size: 1.3rem; font-weight: 700; letter-spacing: 0.3em; }
.brand-vero { color: #FFFFFF; }
.brand-crm { color: var(--text-muted); font-weight: 400; letter-spacing: 0.15em; }

.user-info { display: flex; align-items: center; gap: 10px; }
.user-details { display: flex; flex-direction: column; line-height: 1.3; }
.user-name { font-weight: 600; font-size: 0.9rem; }
.user-role { font-size: 0.78rem; color: var(--text-muted); }

.ws-select {
  background: var(--elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-family: var(--font);
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
}
.ws-select:focus { border-color: var(--accent); }
.ws-select option { background: var(--surface); }

/* ============================
   Avatar
   ============================ */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: #fff;
  background: var(--accent);
  flex-shrink: 0;
  text-transform: uppercase;
}
.avatar-sm { width: 32px; height: 32px; font-size: 0.72rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.4rem; }
.avatar-xl { width: 80px; height: 80px; font-size: 1.8rem; }

/* ============================
   Buttons
   ============================ */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.btn-primary:hover { opacity: 0.85; }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-ghost:hover { background: var(--elevated); color: var(--text); }
.btn-danger {
  background: var(--stage-lost);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-danger:hover { opacity: 0.85; }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }

/* ============================
   Tab Nav
   ============================ */
.tab-nav {
  display: flex;
  gap: 0;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 56px;
  z-index: 99;
  backdrop-filter: blur(16px);
}
.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-head);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 14px 22px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--text-secondary); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ============================
   Views
   ============================ */
.view {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

/* ============================
   Metrics Grid
   ============================ */
.metrics {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.metric-card {
  background: var(--surface);
  border: 1px solid #2a2a35;
  border-radius: 8px;
  padding: 24px;
}
.metric-card .metric-label {
  font-family: var(--font-head);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 10px;
}
.metric-card .metric-value {
  font-family: var(--font-head);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
}
.metric-card.stale .metric-value { color: var(--stale); }

/* Coloured left borders for stat boxes */
.metrics .metric-card:nth-child(1) { border-left: 3px solid #2D9CDB; }
.metrics .metric-card:nth-child(2) { border-left: 3px solid #34d399; }
.metrics .metric-card:nth-child(3) { border-left: 3px solid #fbbf24; }
.metrics .metric-card:nth-child(4) { border-left: 3px solid #8B9CF7; }
.metrics .metric-card:nth-child(5) { border-left: 3px solid #60a5fa; }
.metrics .metric-card:nth-child(6) { border-left: 3px solid #2D9CDB; }

/* ============================
   Chart Card
   ============================ */
.chart-card {
  background: var(--surface);
  border: 1px solid #2a2a35;
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
}

/* ============================
   Section Title
   ============================ */
.section-title {
  font-family: var(--font-head);
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 16px;
}

/* ============================
   Dashboard Columns
   ============================ */
.dashboard-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.risk-card, .activity-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
}
.risk-card {
  border: 1px solid #f87171;
}
.activity-card {
  border: 1px solid #8B9CF7;
}
.risk-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-left: 3px solid var(--stale);
  background: var(--elevated);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 8px;
}
.risk-item .risk-name { font-weight: 600; }
.risk-item .risk-days { color: var(--stale); font-size: 0.8rem; font-weight: 600; }
.risk-item .risk-value { margin-left: auto; color: var(--accent); font-weight: 600; font-size: 0.85rem; }

.dash-activity-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.dash-activity-item:last-child { border-bottom: none; }
.dash-activity-item .da-type {
  font-size: 0.7rem;
  text-transform: uppercase;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--elevated);
  color: var(--accent);
  white-space: nowrap;
}
.dash-activity-item .da-text { flex: 1; color: var(--text-secondary); font-size: 0.85rem; }
.dash-activity-item .da-time { color: var(--text-muted); font-size: 0.75rem; white-space: nowrap; }

/* ============================
   Contacts Toolbar
   ============================ */
.contacts-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}
.search-box input {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px 8px 36px;
  font-family: var(--font);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.15s;
}
.search-box input:focus { border-color: var(--accent); }

/* ============================
   Stage Pills
   ============================ */
.stage-pills, .activity-pills {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.pill {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 14px;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.pill:hover { background: var(--elevated); color: var(--text); }
.pill.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ============================
   Quick Add
   ============================ */
.quick-add {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.quick-add input {
  flex: 1;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-family: var(--font);
  font-size: 0.85rem;
  outline: none;
}
.quick-add input:focus { border-color: var(--accent); }

/* ============================
   Contacts Table
   ============================ */
.table-wrap { overflow-x: auto; }
.contacts-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  backdrop-filter: blur(8px);
}
.contacts-table thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.contacts-table tbody tr {
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid var(--border);
}
.contacts-table tbody tr:last-child { border-bottom: none; }
.contacts-table tbody tr:hover { background: var(--elevated); }
.contacts-table td {
  padding: 14px 16px;
  font-size: 0.875rem;
  vertical-align: middle;
}
.contacts-table .contact-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.contacts-table .contact-name { font-weight: 600; }
.contacts-table .contact-email { font-size: 0.75rem; color: var(--text-muted); }

/* Stale row amber left border */
.contacts-table tbody tr.stale-row {
  border-left: 3px solid var(--stale);
}

/* Stage pill inline */
.stage-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: capitalize;
  color: #fff;
}
.stage-badge.lead { background: var(--stage-lead); }
.stage-badge.warm { background: var(--stage-warm); }
.stage-badge.proposal { background: var(--stage-proposal); }
.stage-badge.won { background: var(--stage-won); }
.stage-badge.lost { background: var(--stage-lost); }
.stage-badge.cold { background: var(--stage-cold); }

.touch-text { color: var(--text-secondary); }
.touch-text.stale { color: var(--stale); font-weight: 600; }

.deal-value { font-weight: 600; color: var(--accent); }
.row-arrow { color: var(--text-muted); font-size: 1rem; }

/* ============================
   Empty State
   ============================ */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ============================
   Detail Panel (slide-in)
   ============================ */
.panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  transition: opacity 0.25s;
}
.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 480px;
  max-width: 100vw;
  height: 100vh;
  background: var(--surface-solid);
  border-left: 1px solid var(--border);
  z-index: 201;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
}
.detail-panel.open {
  transform: translateX(0);
}
.detail-panel.hidden {
  display: flex !important;
  transform: translateX(100%);
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.panel-header h2 { font-family: var(--font-head); font-size: 1.15rem; font-weight: 700; }
.panel-body { padding: 24px; flex: 1; }

.panel-contact-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 24px;
}
.panel-contact-header .avatar { margin-bottom: 12px; }
.panel-contact-name { font-size: 1.2rem; font-weight: 700; margin-bottom: 2px; }
.panel-contact-company { color: var(--text-secondary); font-size: 0.9rem; }
.panel-contact-role { color: var(--text-muted); font-size: 0.8rem; }

.panel-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 24px;
}
.panel-action-btn {
  background: var(--elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 8px 20px;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.panel-action-btn:hover { background: var(--border); color: var(--text); }

.panel-info-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}
.panel-info-card {
  background: var(--elevated);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.panel-info-card .pic-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.panel-info-card .pic-value { font-size: 0.85rem; color: var(--text); word-break: break-all; }

.panel-deal-section {
  background: var(--elevated);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 20px;
}
.panel-deal-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.panel-deal-row:last-child { margin-bottom: 0; }
.panel-deal-label { color: var(--text-muted); font-size: 0.8rem; }
.panel-deal-value { font-weight: 600; font-size: 0.85rem; }

.panel-next-action {
  background: var(--elevated);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
  padding: 14px;
  margin-bottom: 20px;
}
.panel-next-action .pna-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; margin-bottom: 4px; }
.panel-next-action .pna-text { font-size: 0.85rem; color: var(--text); }

.panel-notes {
  background: var(--elevated);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 20px;
  white-space: pre-wrap;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
}
.panel-notes-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; margin-bottom: 6px; }

.panel-activity-title {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.panel-timeline-item {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}
.panel-timeline-item:last-child { border-bottom: none; }
.panel-timeline-type { color: var(--accent); font-weight: 600; text-transform: uppercase; font-size: 0.7rem; min-width: 50px; }
.panel-timeline-text { flex: 1; color: var(--text-secondary); }
.panel-timeline-time { color: var(--text-muted); font-size: 0.72rem; white-space: nowrap; }

.panel-edit-btn {
  width: 100%;
  margin-top: 16px;
}

/* ============================
   Pipeline Kanban
   ============================ */
.kanban {
  display: flex;
  flex-direction: row;
  gap: 16px;
  overflow-x: auto;
  align-items: flex-start;
  padding-bottom: 8px;
}
.kanban-col {
  background: var(--surface);
  border: 1px solid #2a2a35;
  border-radius: 8px;
  min-width: 280px;
  max-width: 320px;
  flex-shrink: 0;
  height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
}
.kanban-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.kanban-header .kh-left { display: flex; align-items: center; gap: 8px; }
.kanban-header .kh-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.kanban-header .kh-name { font-family: var(--font-head); font-weight: 700; font-size: 0.9rem; text-transform: capitalize; }
.kanban-header .kh-count {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--elevated);
  padding: 2px 8px;
  border-radius: 10px;
}
.kanban-header .kh-value { font-size: 0.75rem; color: var(--accent); font-weight: 600; }
.kanban-body { padding: 12px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; flex: 1; }
.kanban-card {
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.kanban-card:hover { background: var(--border); }
.kanban-card.fresh { border-left: 3px solid rgba(14,165,233,0.3); }
.kanban-card.aging { border-left: 3px solid rgba(245,158,11,0.4); }
.kanban-card.stale { border-left: 3px solid var(--stale); }
.kanban-card .kc-name { font-weight: 600; font-size: 0.85rem; margin-bottom: 2px; }
.kanban-card .kc-company { color: var(--text-muted); font-size: 0.75rem; margin-bottom: 8px; }
.kanban-card .kc-footer { display: flex; justify-content: space-between; align-items: center; }
.kanban-card .kc-value { color: var(--accent); font-weight: 700; font-size: 0.85rem; }
.kanban-card .kc-days { color: var(--text-muted); font-size: 0.72rem; }
.kc-new-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 700;
  background: rgba(45, 156, 219, 0.15);
  color: #2D9CDB;
}

/* ============================
   Activity Timeline
   ============================ */
.timeline {
  position: relative;
  padding-left: 40px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 17px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.timeline-item {
  position: relative;
  padding-bottom: 20px;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  position: absolute;
  left: -31px;
  top: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--elevated);
  border: 2px solid var(--accent);
  z-index: 1;
}
.timeline-dot.call { border-color: var(--stage-won); }
.timeline-dot.email { border-color: var(--stage-lead); }
.timeline-dot.meeting { border-color: var(--stage-proposal); }
.timeline-dot.note { border-color: var(--text-muted); }
.timeline-dot.deal { border-color: var(--stage-warm); }

.timeline-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  backdrop-filter: blur(8px);
}
.timeline-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.timeline-agent-icon { font-size: 1rem; line-height: 1; }
.timeline-contact { font-weight: 600; font-size: 0.85rem; }
.timeline-type-badge {
  font-size: 0.65rem;
  text-transform: uppercase;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--elevated);
  color: var(--accent);
}
.timeline-time { margin-left: auto; color: var(--text-muted); font-size: 0.72rem; white-space: nowrap; }
.timeline-summary { color: var(--text-secondary); font-size: 0.85rem; }

/* ============================
   Modal / Overlay
   ============================ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title { font-family: var(--font-head); font-size: 1.2rem; font-weight: 700; }
.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.close-btn:hover { color: var(--text); background: var(--elevated); }

.field {
  margin-bottom: 14px;
}
.field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-family: var(--font);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.7) sepia(0.1) saturate(0.3) hue-rotate(180deg);
  cursor: pointer;
}
.field input[type="date"] { color-scheme: dark; }
.field textarea { resize: vertical; min-height: 80px; }
.field select option { background: var(--surface); }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.modal-footer {
  display: flex;
  align-items: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ============================
   Responsive
   ============================ */
/* Pipeline view needs full width for horizontal kanban scroll */
#view-pipeline { max-width: none; }

@media (max-width: 768px) {
  .metrics {
    grid-template-columns: repeat(2, 1fr);
  }
  .dashboard-cols {
    grid-template-columns: 1fr;
  }
  .header {
    padding: 12px;
    gap: 8px;
  }
  .user-details { display: none; }
  .tab { padding: 10px 12px; font-size: 0.8rem; }
  .view { padding: 16px; }
  .detail-panel { width: 100vw; }
  .contacts-toolbar { flex-direction: column; align-items: stretch; }
  .field-row { grid-template-columns: 1fr; }
  .panel-info-cards { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .metrics {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ============================
   Toast Notifications
   ============================ */
#toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: rgba(22, 27, 40, 0.95);
  backdrop-filter: blur(8px);
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 12px 20px;
  border-radius: 8px;
  border: 1px solid var(--border);
  pointer-events: auto;
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  max-width: 360px;
}
.toast.show {
  transform: translateX(0);
  opacity: 1;
}
.toast-success {
  border-color: #10b981;
  border-left: 3px solid #10b981;
}
.toast-error {
  border-color: #ef4444;
  border-left: 3px solid #ef4444;
}

/* ── Label Chips ── */
.label-input-wrap {
  display: flex; flex-wrap: wrap; gap: 5px; padding: 6px 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; min-height: 40px; align-items: center; cursor: text;
  transition: border-color 0.15s;
}
.label-input-wrap:focus-within { border-color: var(--accent); }
.label-input-wrap input {
  border: none; background: none; outline: none; padding: 2px 0;
  font-size: 0.85rem; font-family: var(--font); color: var(--text);
  flex: 1; min-width: 80px;
}
.label-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 700;
  background: rgba(59,130,246,0.12); color: #3b82f6;
  border: 1px solid rgba(59,130,246,0.2); cursor: pointer;
  white-space: nowrap; transition: 0.15s;
}
.label-chip:hover { background: rgba(59,130,246,0.2); }
.label-chip .chip-x { font-size: 12px; line-height: 1; opacity: 0.5; margin-left: 2px; }
.label-chip .chip-x:hover { opacity: 1; color: #ef4444; }
.label-chips { display: flex; flex-wrap: wrap; gap: 4px; }

/* ── Invoices ── */
.panel-invoices { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.inv-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; margin-bottom: 6px; cursor: pointer; transition: 0.15s;
}
.inv-row:hover { border-color: var(--accent); background: var(--elevated); }
.inv-num { font-weight: 700; font-size: 0.85rem; color: var(--text); }
.inv-date { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.inv-total { font-weight: 700; font-size: 0.85rem; color: var(--text); white-space: nowrap; }
.inv-status {
  display: inline-block; padding: 2px 8px; border-radius: 12px;
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
}
.inv-paid { background: rgba(16,185,129,0.12); color: #059669; }
.inv-sent { background: rgba(59,130,246,0.1); color: #3b82f6; }
.inv-draft { background: var(--elevated); color: var(--text-muted); }
.inv-overdue { background: rgba(239,68,68,0.1); color: #ef4444; }
.inv-cancelled { background: var(--elevated); color: var(--text-muted); text-decoration: line-through; }
.inv-action {
  background: none; border: none; cursor: pointer; font-size: 1rem;
  padding: 2px 4px; opacity: 0.6; transition: 0.15s;
}
.inv-action:hover { opacity: 1; }

/* ---- Pagination & status bar ---- */
.contacts-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.contacts-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 0;
}
.pagination button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.page-info {
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.label-filter-select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  min-width: 130px;
}
.label-filter-select:focus {
  outline: none;
  border-color: var(--accent);
}
.loading-skeleton {
  color: var(--text-muted);
  font-size: 0.9rem;
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ---- Import banner ---- */
.import-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.import-banner.hidden { display: none; }
.import-banner-text {
  font-size: 0.85rem;
  color: var(--text);
  flex: 1;
}
.import-undo-btn {
  white-space: nowrap;
}

/* ---- Bulk action bar ---- */
.bulk-action-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(45, 156, 219, 0.1);
  border: 1px solid rgba(45, 156, 219, 0.25);
  border-radius: 8px;
  margin-bottom: 12px;
}
.bulk-action-bar.hidden { display: none; }
.bulk-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-right: auto;
}

/* ---- Checkbox columns ---- */
.th-check, .td-check {
  width: 36px;
  min-width: 36px;
  text-align: center;
  padding: 0 4px !important;
}
.th-check input, .td-check input {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}
.selected-row {
  background: rgba(45, 156, 219, 0.06) !important;
}
