/* ============================================
   CRM Design System — crm.css
   Clean, professional. Notion meets HubSpot.
   ============================================ */

/* --- Custom Properties --- */
:root {
  /* Colors */
  --ink: #0f172a;
  --ink-secondary: #475569;
  --ink-muted: #94a3b8;
  --bg: #f8fafc;
  --bg-white: #ffffff;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #eff6ff;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --danger: #dc2626;
  --danger-light: #fef2f2;

  /* Stage Colors */
  --stage-prospect: #64748b;
  --stage-intro: #2563eb;
  --stage-engaged: #4f46e5;
  --stage-proposal: #7c3aed;
  --stage-signed: #16a34a;
  --stage-delivery: #d97706;
  --stage-closed: #059669;
  --stage-dead: #dc2626;

  /* Warm Levels */
  --warm-cold: #2563eb;
  --warm-warm: #d97706;
  --warm-hot: #ea580c;
  --warm-active: #16a34a;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;

  /* Layout */
  --sidebar-width: 240px;
  --topbar-height: 56px;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: var(--weight-normal);
  line-height: var(--leading-normal);
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

img { max-width: 100%; }

ul, ol { list-style: none; }

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  color: var(--ink);
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-base); }

/* --- Auth Gate --- */
#auth-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.auth-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl);
  width: 360px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.auth-card h1 {
  font-size: var(--text-xl);
  margin-bottom: var(--space-xs);
}

.auth-card p {
  color: var(--ink-muted);
  margin-bottom: var(--space-lg);
}

.auth-card .auth-error {
  color: var(--danger);
  font-size: var(--text-sm);
  margin-top: var(--space-sm);
  display: none;
}

/* --- Layout --- */
#app {
  display: none;
}

#app.active {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--ink);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  padding: var(--space-lg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand h2 {
  color: #fff;
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
}

.sidebar-brand span {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-nav {
  padding: var(--space-md) 0;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px var(--space-lg);
  color: #94a3b8;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
  border-left: 3px solid transparent;
  text-decoration: none;
}

.nav-item:hover {
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.05);
  text-decoration: none;
}

.nav-item.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border-left-color: var(--accent);
}

.nav-item .nav-icon {
  width: 20px;
  text-align: center;
  font-size: var(--text-base);
}

.sidebar-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: var(--text-xs);
  color: var(--ink-muted);
}

/* --- Main content wrapper --- */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
  max-width: calc(100vw - var(--sidebar-width));
}

/* --- Top Bar --- */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.topbar-title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--ink);
  white-space: nowrap;
}

.business-toggle {
  display: flex;
  gap: var(--space-xs);
}

.biz-pill {
  padding: 4px 12px;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-white);
  color: var(--ink-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.biz-pill.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.biz-pill.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.biz-pill.disabled:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 6px;
  padding: 4px 8px;
  font-size: var(--text-xs);
  font-weight: var(--weight-normal);
  color: #fff;
  background: var(--ink);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  z-index: 200;
  letter-spacing: 0;
  text-transform: none;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

/* --- Search Bar --- */
.search-bar {
  position: relative;
}

.search-bar input {
  width: 260px;
  padding: 7px 12px 7px 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  transition: all var(--transition-fast);
}

.search-bar input::placeholder {
  color: var(--ink-muted);
}

.search-bar input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  background: var(--bg-white);
}

.search-bar .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-muted);
  font-size: var(--text-sm);
  pointer-events: none;
}

/* --- Main Content Area --- */
#main {
  flex: 1;
  padding: var(--space-lg);
  max-width: 1400px;
  width: 100%;
}

/* --- Cards --- */
.card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-fast);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.card-title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
}

/* Metric Cards */
.metric-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.metric-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.metric-card .metric-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-xs);
}

.metric-card .metric-value {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: var(--ink);
  line-height: 1;
}

.metric-card .metric-sub {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  margin-top: var(--space-xs);
}

/* --- Tables --- */
.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

thead th {
  text-align: left;
  padding: 10px var(--space-md);
  font-weight: var(--weight-semibold);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  cursor: default;
  user-select: none;
}

thead th.sortable {
  cursor: pointer;
}

thead th.sortable:hover {
  color: var(--ink);
}

thead th.sortable::after {
  content: ' \2195';
  font-size: 10px;
  opacity: 0.4;
}

thead th.sort-asc::after { content: ' \2191'; opacity: 1; }
thead th.sort-desc::after { content: ' \2193'; opacity: 1; }

tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition-fast);
}

tbody tr:nth-child(even) {
  background: var(--bg);
}

tbody tr:hover {
  background: var(--accent-light);
  cursor: pointer;
}

tbody td {
  padding: 10px var(--space-md);
  vertical-align: middle;
}

/* --- Badges / Tags --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  border-radius: var(--radius-full);
  line-height: 1.5;
  white-space: nowrap;
}

/* Stage badges */
.badge-prospect   { background: #f1f5f9; color: #475569; }
.badge-intro      { background: #eff6ff; color: #2563eb; }
.badge-engaged    { background: #eef2ff; color: #4f46e5; }
.badge-proposal   { background: #f5f3ff; color: #7c3aed; }
.badge-signed     { background: #f0fdf4; color: #16a34a; }
.badge-delivery   { background: #fffbeb; color: #d97706; }
.badge-closed     { background: #ecfdf5; color: #059669; }
.badge-dead       { background: #fef2f2; color: #dc2626; }

/* Warm level badges */
.badge-cold   { background: #eff6ff; color: #2563eb; }
.badge-warm   { background: #fffbeb; color: #d97706; }
.badge-hot    { background: #fff7ed; color: #ea580c; }
.badge-active { background: #f0fdf4; color: #16a34a; }

/* Tag badges */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-full);
  background: var(--bg);
  color: var(--ink-secondary);
  border: 1px solid var(--border);
  margin-right: 4px;
  margin-bottom: 2px;
}

/* Deal type badges */
.badge-bot        { background: #fdf4ff; color: #a855f7; }
.badge-spec       { background: #fefce8; color: #ca8a04; }
.badge-residential { background: #f0fdfa; color: #0d9488; }
.badge-commercial  { background: #f0f9ff; color: #0284c7; }

/* Status badges */
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger  { background: var(--danger-light); color: var(--danger); }
.badge-info    { background: var(--accent-light); color: var(--accent); }

/* --- Forms --- */
.form-group {
  margin-bottom: var(--space-md);
}

.form-group label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--ink);
  margin-bottom: var(--space-xs);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg-white);
  transition: all var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 8px 16px;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  font-family: var(--font);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
}

.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-white);
  color: var(--ink);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--bg);
  border-color: #cbd5e1;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-ghost {
  background: transparent;
  color: var(--ink-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--bg);
  color: var(--ink);
}

.btn-sm {
  padding: 4px 10px;
  font-size: var(--text-xs);
}

.btn-lg {
  padding: 10px 20px;
  font-size: var(--text-base);
}

/* --- Modal / Dialog --- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 95%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  animation: modalIn 200ms ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  font-size: var(--text-xl);
  color: var(--ink-muted);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--bg);
  color: var(--ink);
}

.modal-body {
  padding: var(--space-lg);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border);
}

/* --- Pipeline Board --- */
.pipeline-board {
  display: flex;
  gap: var(--space-md);
  overflow-x: auto;
  padding-bottom: var(--space-md);
  min-height: 400px;
}

.pipeline-column {
  min-width: 240px;
  max-width: 280px;
  flex: 1;
  background: var(--bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.pipeline-column-header {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pipeline-column-header h4 {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  text-transform: capitalize;
}

.pipeline-column-header .count {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  background: var(--bg-white);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.pipeline-column-body {
  padding: var(--space-sm);
  flex: 1;
  overflow-y: auto;
  max-height: 600px;
}

.pipeline-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.pipeline-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}

.pipeline-card .deal-name {
  font-weight: var(--weight-semibold);
  font-size: var(--text-sm);
  margin-bottom: var(--space-xs);
}

.pipeline-card .deal-company {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  margin-bottom: var(--space-sm);
}

.pipeline-card .deal-value {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--success);
}

/* --- Activity Feed --- */
.activity-feed {
  display: flex;
  flex-direction: column;
}

.activity-item {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--border-light);
  position: relative;
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  flex-shrink: 0;
  background: var(--bg);
  border: 1px solid var(--border);
}

.activity-icon.type-call    { background: #eff6ff; }
.activity-icon.type-email   { background: #f0fdf4; }
.activity-icon.type-meeting { background: #fdf4ff; }
.activity-icon.type-note    { background: #fffbeb; }
.activity-icon.type-task    { background: #f0f9ff; }

.activity-content {
  flex: 1;
  min-width: 0;
}

.activity-content .activity-title {
  font-weight: var(--weight-medium);
  font-size: var(--text-sm);
  margin-bottom: 2px;
}

.activity-content .activity-desc {
  font-size: var(--text-xs);
  color: var(--ink-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-content .activity-meta {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  margin-top: 2px;
}

/* Timeline connector */
.activity-feed.timeline .activity-item::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 48px;
  bottom: 0;
  width: 1px;
  background: var(--border);
}

.activity-feed.timeline .activity-item:last-child::before {
  display: none;
}

/* --- Toast Notifications --- */
#toast-container {
  position: fixed;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  min-width: 280px;
  max-width: 400px;
  pointer-events: auto;
  animation: toastIn 300ms ease, toastOut 300ms ease forwards;
  animation-delay: 0ms, 2700ms;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.toast.toast-success {
  border-left: 3px solid var(--success);
}

.toast.toast-error {
  border-left: 3px solid var(--danger);
}

.toast.toast-info {
  border-left: 3px solid var(--accent);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(20px); }
}

/* --- Loading Spinner --- */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}

.spinner-lg {
  width: 32px;
  height: 32px;
  border-width: 3px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  color: var(--ink-muted);
  gap: var(--space-md);
}

.loading-state .spinner { margin-bottom: var(--space-sm); }

/* --- Empty State --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  color: var(--ink-muted);
  text-align: center;
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

.empty-state h3 {
  font-size: var(--text-lg);
  color: var(--ink-secondary);
  margin-bottom: var(--space-xs);
}

.empty-state p {
  font-size: var(--text-sm);
  max-width: 320px;
}

/* --- Toolbar / View Header --- */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.view-header h1 {
  font-size: var(--text-2xl);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.toolbar input,
.toolbar select {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg-white);
}

.toolbar input:focus,
.toolbar select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* --- View Toggle --- */
.view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.view-toggle button {
  padding: 6px 12px;
  border: none;
  background: var(--bg-white);
  font-size: var(--text-xs);
  font-family: var(--font);
  font-weight: var(--weight-medium);
  color: var(--ink-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.view-toggle button + button {
  border-left: 1px solid var(--border);
}

.view-toggle button.active {
  background: var(--accent);
  color: #fff;
}

/* --- Pagination --- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}

.pagination .page-info {
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.pagination .page-buttons {
  display: flex;
  gap: var(--space-sm);
}

/* --- Detail Page --- */
.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  gap: var(--space-md);
}

.detail-header h1 {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-xs);
}

.detail-header .subtitle {
  font-size: var(--text-sm);
  color: var(--ink-secondary);
}

.detail-header .badges {
  display: flex;
  gap: var(--space-xs);
  margin-top: var(--space-sm);
}

.detail-actions {
  display: flex;
  gap: var(--space-sm);
  flex-shrink: 0;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
}

.detail-section {
  margin-bottom: var(--space-lg);
}

.detail-section h2 {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border);
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm) var(--space-lg);
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.info-item .info-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.info-item .info-value {
  font-size: var(--text-sm);
  color: var(--ink);
}

/* --- Stage Progress --- */
.stage-progress {
  display: flex;
  gap: 2px;
  margin-top: var(--space-sm);
}

.stage-progress .stage-step {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: var(--radius-full);
}

.stage-progress .stage-step.completed {
  background: var(--accent);
}

.stage-progress .stage-step.current {
  background: var(--accent);
}

/* --- Email View --- */
.email-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: var(--space-lg);
}

.email-tab {
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--ink-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition-fast);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: var(--font);
}

.email-tab:hover {
  color: var(--ink);
}

.email-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.email-list-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.email-list-item:hover {
  background: var(--accent-light);
}

.email-list-item .email-sender {
  font-weight: var(--weight-semibold);
  font-size: var(--text-sm);
  min-width: 160px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-list-item .email-subject {
  font-weight: var(--weight-medium);
  font-size: var(--text-sm);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-list-item .email-preview {
  color: var(--ink-muted);
  font-weight: var(--weight-normal);
}

.email-list-item .email-date {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  white-space: nowrap;
}

.email-expanded {
  padding: var(--space-lg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin: var(--space-sm) var(--space-md);
}

/* --- Calendar View --- */
.calendar-day {
  margin-bottom: var(--space-lg);
}

.calendar-day-header {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--border);
  margin-bottom: var(--space-sm);
}

.calendar-day-header .day-date {
  color: var(--ink-muted);
  font-weight: var(--weight-normal);
  font-size: var(--text-sm);
  margin-left: var(--space-sm);
}

.calendar-event {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-xs);
  transition: background var(--transition-fast);
}

.calendar-event:hover {
  background: var(--accent-light);
}

.calendar-event .event-time {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--ink-secondary);
  min-width: 100px;
  white-space: nowrap;
}

.calendar-event .event-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.calendar-event .event-location {
  font-size: var(--text-xs);
  color: var(--ink-muted);
}

.calendar-event.all-day {
  background: var(--accent-light);
  border-left: 3px solid var(--accent);
  padding: var(--space-sm) var(--space-md);
}

/* --- Tabs generic --- */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: var(--space-lg);
}

.tab-btn {
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--ink-muted);
  cursor: pointer;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition-fast);
  background: none;
  font-family: var(--font);
}

.tab-btn:hover { color: var(--ink); }
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* --- Two-column layout --- */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
}

/* --- Utility --- */
.text-muted { color: var(--ink-muted); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-right { text-align: right; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Responsive --- */
@media (max-width: 1024px) {
  .metric-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .detail-grid,
  .two-col {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  :root {
    --sidebar-width: 60px;
  }

  .sidebar-brand h2,
  .sidebar-brand span,
  .nav-item span:not(.nav-icon) {
    display: none;
  }

  .nav-item {
    justify-content: center;
    padding: 12px;
  }

  .nav-item .nav-icon {
    width: auto;
    font-size: var(--text-lg);
  }

  .sidebar-footer {
    display: none;
  }

  #main {
    padding: var(--space-md);
  }

  .metric-cards {
    grid-template-columns: 1fr;
  }

  .topbar-title {
    display: none;
  }

  .search-bar input {
    width: 160px;
  }

  .pipeline-board {
    flex-direction: column;
  }

  .pipeline-column {
    max-width: none;
  }
}

/* ============================================
   SCHEDULE MODULE
   ============================================ */

.sched-wrap { padding: var(--space-lg); }

.sched-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.sched-header-actions { display: flex; gap: var(--space-sm); }

.sched-week-nav {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.sched-week-label {
  font-size: var(--text-base);
  font-weight: 600;
  min-width: 280px;
  text-align: center;
}

.sched-publish-status {
  margin-left: auto;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.sched-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.sched-dot-published { background: var(--success); }
.sched-dot-draft { background: var(--warning); }

/* Schedule Table */
.sched-table-wrap { overflow-x: auto; }

.sched-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.sched-table thead th {
  background: var(--bg-secondary);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.sched-day-col { text-align: center !important; min-width: 160px; }
.sched-emp-col { min-width: 180px; }

.sched-table tbody tr { border-bottom: 1px solid var(--border-light); }
.sched-table tbody tr:hover { background: var(--bg-hover); }
.sched-table tbody td { padding: 8px 12px; font-size: var(--text-sm); vertical-align: middle; }

.sched-emp-name { font-weight: 500; white-space: nowrap; }

.sched-role-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  margin-left: 6px;
}

.sched-role-srss { background: #dbeafe; color: #1e40af; }
.sched-role-ss { background: #e0e7ff; color: #3730a3; }
.sched-role-ssit { background: #fef3c7; color: #92400e; }
.sched-role-fc { background: #d1fae5; color: #065f46; }
.sched-role-fm { background: #fce7f3; color: #9d174d; }

/* Assignment Cells */
.sched-day-cell { text-align: center; padding: 6px 8px !important; }
.sched-weekend { background: var(--bg-secondary); }

.sched-assignment {
  font-size: 0.78rem;
  padding: 4px 8px;
  border-radius: 4px;
  background: #eff6ff;
  border: 1px solid #dbeafe;
  color: #1e40af;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
  display: inline-block;
}

.sched-vac { background: #fffbeb; border-color: #fde68a; color: #d97706; }
.sched-training { background: #f3e8ff; border-color: #e9d5ff; color: #7c3aed; }
.sched-shop { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.sched-off { background: var(--bg-secondary); border-color: var(--border); color: var(--text-tertiary); font-style: italic; }

/* Edit Mode Select */
.sched-select {
  width: 100%;
  font-size: 0.78rem;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  cursor: pointer;
}

.sched-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15); }

/* Manage Modal */
.sched-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-md);
}

.sched-tab {
  padding: 10px 18px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  transition: var(--transition-fast);
}

.sched-tab:hover { color: var(--text-primary); }
.sched-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.sched-manage-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border-light);
}

.sched-list { max-height: 400px; overflow-y: auto; }

.sched-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  font-size: var(--text-sm);
  gap: 12px;
}

.sched-list-item:hover { background: var(--bg-hover); }

.sched-list-info { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.sched-list-name { font-weight: 500; }
.sched-list-email { font-size: var(--text-xs); color: var(--text-secondary); }
.sched-list-actions { display: flex; align-items: center; gap: var(--space-sm); flex-shrink: 0; }

@media (max-width: 900px) {
  .sched-wrap { padding: var(--space-md); }
  .sched-header { flex-direction: column; gap: var(--space-sm); align-items: flex-start; }
  .sched-manage-form .form-row { flex-direction: column; }
}
