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

:root {
  --bg: #f0f2f5;
  --bg-card: #ffffff;
  --bg-hover: #f7f8fa;
  --bg-elevated: #f4f5f7;
  --bg-header: #1e293b;
  --border: #e2e8f0;
  --border-light: #edf2f7;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;

  --primary: #6366f1;
  --primary-hover: #818cf8;
  --primary-bg: rgba(99, 102, 241, 0.1);
  --primary-light: #eef2ff;

  --success: #16a34a;
  --success-bg: #dcfce7;
  --success-light: #f0fdf4;

  --warning: #d97706;
  --warning-bg: #fef3c7;
  --warning-light: #fffbeb;

  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --danger-light: #fef2f2;

  --blue: #2563eb;
  --blue-bg: #dbeafe;
  --blue-light: #eff6ff;

  --pink: #db2777;
  --pink-bg: #fce7f3;

  --orange: #ea580c;
  --orange-bg: #ffedd5;

  --teal: #0d9488;
  --teal-bg: #ccfbf1;

  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ─── Header ────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: white;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-mark {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #6366f1, #a855f7, #ec4899);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.5px;
  color: white;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.header h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.subtitle {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  margin-top: 1px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ─── Username selector ─────────────────────────────── */
.user-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(255,255,255,0.1);
  border-radius: var(--radius);
  font-size: 12px;
  color: rgba(255,255,255,0.8);
}

.user-selector select {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.2);
  color: white;
  padding: 4px 8px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
}
.user-selector select option { color: #1e293b; }

/* ─── Buttons ───────────────────────────────────────── */
.btn {
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 1px 3px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 2px 6px rgba(99, 102, 241, 0.4); }

.btn-ghost {
  background: white;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); border-color: #cbd5e1; }

.btn-sm { padding: 5px 12px; font-size: 12px; }

.btn-icon {
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  font-size: 15px;
  transition: all 0.15s;
}
.btn-icon:hover { background: var(--bg-elevated); color: var(--text); }
.btn-icon.danger:hover { color: var(--danger); background: var(--danger-bg); }

.header .btn-ghost {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.85);
}
.header .btn-ghost:hover { background: rgba(255,255,255,0.2); color: white; }
.header .btn-primary { background: #6366f1; }

/* ─── Filter Buttons ────────────────────────────────── */
.filter-group {
  display: flex;
  background: rgba(255,255,255,0.1);
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
}

.filter-btn {
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.5);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.filter-btn:hover { color: rgba(255,255,255,0.8); }
.filter-btn.active { background: white; color: var(--text); font-weight: 600; }

/* ─── Main Content ──────────────────────────────────── */
.main {
  padding: 24px 28px;
  max-width: 1440px;
  margin: 0 auto;
}

/* ─── Stats Bar ─────────────────────────────────────── */
.stats-bar {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  flex: 1;
  padding: 16px 20px;
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
}

.stat-card.success { border-left-color: var(--success); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.danger { border-left-color: var(--danger); }
.stat-card.blue { border-left-color: var(--blue); }

.stat-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.stat-card.success .stat-value { color: var(--success); }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.danger .stat-value { color: var(--danger); }
.stat-card.blue .stat-value { color: var(--blue); }
.stat-card .stat-value { color: var(--primary); }

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

.stat-card.clickable { cursor: pointer; transition: all 0.15s; }
.stat-card.clickable:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

/* ─── Table Container ───────────────────────────────── */
.table-container {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ─── Table Header ──────────────────────────────────── */
.table-header {
  display: grid;
  grid-template-columns: 2.5fr 100px 120px 150px 120px 80px;
  padding: 10px 20px;
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
  border-bottom: 2px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-secondary);
}

/* ─── Client Row ────────────────────────────────────── */
.client-row {
  border-bottom: 1px solid var(--border);
}
.client-row:last-child { border-bottom: none; }

.client-summary {
  display: grid;
  grid-template-columns: 2.5fr 100px 120px 150px 120px 80px;
  padding: 12px 20px;
  align-items: center;
  cursor: pointer;
  transition: background 0.15s;
  border-left: 4px solid transparent;
}
.client-summary:hover { background: var(--bg-hover); }

/* Color-coded left border per agreement type */
.client-row[data-type="recurring"] .client-summary { border-left-color: var(--blue); }
.client-row[data-type="ad-hoc"] .client-summary { border-left-color: var(--orange); }

.client-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.client-logo {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  object-fit: cover;
  background: linear-gradient(135deg, var(--primary-light), var(--blue-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--primary);
  border: 1px solid var(--border);
  flex-shrink: 0;
  overflow: hidden;
}

.client-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.client-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}

.client-notes-preview {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}

/* ─── Badges ────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.badge-recurring { background: var(--blue-bg); color: var(--blue); }
.badge-ad-hoc { background: var(--orange-bg); color: var(--orange); }
.badge-active { background: var(--success-bg); color: var(--success); }
.badge-on-hold { background: var(--warning-bg); color: var(--warning); }
.badge-completed { background: var(--primary-bg); color: var(--primary); }

.project-count {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ─── Outstanding Tasks Pill ────────────────────────── */
.outstanding-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}

.outstanding-pill.all-done { background: var(--success-bg); color: var(--success); }
.outstanding-pill.has-tasks { background: var(--warning-bg); color: var(--warning); }
.outstanding-pill.has-overdue { background: var(--danger-bg); color: var(--danger); }

.overdue-count {
  font-size: 11px;
  color: var(--danger);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 3px;
}

.client-actions {
  display: flex;
  gap: 2px;
  justify-content: flex-end;
}

.chevron {
  display: inline-block;
  transition: transform 0.2s;
  margin-right: 6px;
  font-size: 10px;
  color: var(--text-muted);
}
.client-row.expanded .chevron { transform: rotate(90deg); }

/* ─── Expandable Content ────────────────────────────── */
.client-expanded {
  display: none;
  padding: 0 20px 16px 20px;
  background: var(--bg-hover);
}
.client-row.expanded .client-expanded { display: block; }

.client-detail-bar {
  display: flex;
  gap: 24px;
  padding: 12px 16px;
  background: white;
  border-radius: var(--radius);
  margin: 12px 0;
  font-size: 12px;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.client-detail-bar strong {
  color: var(--text);
  font-weight: 600;
}

.client-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s;
}
.client-link:hover { background: var(--primary); color: white; }

/* ─── Projects Section ──────────────────────────────── */
.project-section {
  margin-left: 16px;
  border-left: 3px solid var(--primary);
  padding-left: 16px;
  margin-bottom: 8px;
}

.project-section[data-status="completed"] { border-left-color: var(--success); }
.project-section[data-status="on-hold"] { border-left-color: var(--warning); }

.project-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: white;
  border-radius: var(--radius);
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.project-header:hover { box-shadow: var(--shadow); }

.project-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 13px;
}

.project-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.project-tasks {
  display: none;
}
.project-section.expanded .project-tasks { display: block; }

/* ─── Task Table ────────────────────────────────────── */
.task-table {
  width: 100%;
  margin: 4px 0 8px 0;
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

.task-table-header {
  display: grid;
  grid-template-columns: 2fr 120px 110px 120px 1fr 70px;
  padding: 8px 14px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
  border-bottom: 2px solid var(--border);
}

.task-row {
  display: grid;
  grid-template-columns: 2fr 120px 110px 120px 1fr 70px;
  padding: 10px 14px;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
  transition: background 0.15s;
}
.task-row:hover { background: #f8fafc; }
.task-row:last-child { border-bottom: none; }

/* Alternate row colors like Excel */
.task-row:nth-child(even) { background: #fafbfc; }
.task-row:nth-child(even):hover { background: #f0f4f8; }

.task-title-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.task-title {
  font-weight: 500;
  cursor: pointer;
}
.task-title:hover { color: var(--primary); }

.comment-count {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--primary-bg);
  color: var(--primary);
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
}
.comment-count:hover { background: var(--primary); color: white; }

.task-assignee {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.assignee-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: white;
}

.task-deadline {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}
.task-deadline.overdue {
  color: var(--danger);
  font-weight: 700;
  background: var(--danger-bg);
  padding: 2px 8px;
  border-radius: 4px;
}
.task-deadline.soon {
  color: var(--warning);
  font-weight: 600;
  background: var(--warning-bg);
  padding: 2px 8px;
  border-radius: 4px;
}

/* ─── Progress Badges ───────────────────────────────── */
.progress-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}

.progress-not-started { background: var(--bg-elevated); color: var(--text-muted); border: 1px solid var(--border); }
.progress-in-progress { background: var(--blue-bg); color: var(--blue); }
.progress-completed { background: var(--success-bg); color: var(--success); }
.progress-blocked { background: var(--danger-bg); color: var(--danger); }

.progress-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.progress-not-started .progress-dot { background: var(--text-muted); }
.progress-in-progress .progress-dot { background: var(--blue); }
.progress-completed .progress-dot { background: var(--success); }
.progress-blocked .progress-dot { background: var(--danger); }

.task-refs {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-actions {
  display: flex;
  gap: 2px;
  justify-content: flex-end;
}

.add-task-row {
  padding: 8px 14px;
  background: #fafbfc;
}

.add-task-btn {
  background: none;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  width: 100%;
  text-align: left;
  transition: all 0.15s;
}
.add-task-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.add-project-btn {
  margin-top: 8px;
  margin-left: 16px;
}

/* ─── Comment Thread ────────────────────────────────── */
.comment-thread {
  background: #fafbfc;
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  grid-column: 1 / -1;
}

.comment-item {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}
.comment-item:last-of-type { border-bottom: none; }

.comment-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.comment-body {
  flex: 1;
}

.comment-author {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.comment-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 8px;
  font-weight: 400;
}

.comment-text {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.comment-form {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.comment-form input {
  flex: 1;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  background: white;
  color: var(--text);
}

.comment-form input:focus { outline: none; border-color: var(--primary); }

/* ─── History / Activity Panel ──────────────────────── */
.history-panel {
  background: #fafbfc;
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  max-height: 250px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--border-light);
}
.history-item:last-child { border-bottom: none; }

.history-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  margin-top: 5px;
  flex-shrink: 0;
}

.history-dot.created { background: var(--success); }
.history-dot.updated { background: var(--blue); }
.history-dot.deleted { background: var(--danger); }
.history-dot.commented { background: var(--pink); }
.history-dot.archived { background: var(--warning); }
.history-dot.restored { background: var(--teal); }

.history-entity-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  margin-left: 4px;
  text-transform: uppercase;
}
.history-entity-badge.client { background: var(--primary-bg); color: var(--primary); }
.history-entity-badge.project { background: var(--blue-bg); color: var(--blue); }
.history-entity-badge.task { background: var(--teal-bg); color: var(--teal); }

.history-content {
  flex: 1;
}

.history-author { font-weight: 600; color: var(--text); }
.history-action { color: var(--text-secondary); }
.history-time { color: var(--text-muted); font-size: 10px; }
.history-details { color: var(--text-muted); font-size: 11px; margin-top: 2px; }

.history-toggle {
  background: none;
  border: none;
  color: var(--primary);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 0;
  display: flex;
  align-items: center;
  gap: 4px;
}
.history-toggle:hover { color: var(--primary-hover); }

/* ─── Modals ────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-backdrop.active { opacity: 1; pointer-events: all; }

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  z-index: 300;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s;
}
.modal.active { opacity: 1; pointer-events: all; transform: translate(-50%, -50%) scale(1); }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--bg-elevated);
}

.modal-header h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.modal-close:hover { background: var(--bg-elevated); color: var(--text); }

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.form-group input[type="file"] { padding: 8px; }
.form-group textarea { resize: vertical; }

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

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* ─── Team Modal ────────────────────────────────────── */
.team-list {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 16px;
}

.team-member {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
}

.team-member-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.team-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: white;
}

.team-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.team-form input[type="text"] {
  flex: 1;
  padding: 8px 12px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}

.team-form input[type="color"] {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  cursor: pointer;
}

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

.empty-state p { font-size: 14px; }

/* ─── Scrollbar ─────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ─── Stats Popup Task List ─────────────────────────── */
.popup-task-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.1s;
}
.popup-task-item:hover { background: var(--bg-hover); }
.popup-task-item:last-child { border-bottom: none; }

.popup-task-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.popup-task-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.popup-task-context {
  font-size: 11px;
  color: var(--text-muted);
}

.popup-task-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ─── Archive Items ─────────────────────────────────── */
.archive-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
}
.archive-item:last-child { border-bottom: none; }

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

.archive-item-name {
  font-size: 13px;
  font-weight: 600;
}

.archive-item-type {
  font-size: 11px;
  color: var(--text-muted);
}

.archive-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 10px 14px 6px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.btn-restore {
  padding: 4px 12px;
  border-radius: 6px;
  border: 1px solid var(--teal);
  background: var(--teal-bg);
  color: var(--teal);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-restore:hover { background: var(--teal); color: white; }

.btn-archive {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--warning);
  background: var(--warning-bg);
  color: var(--warning);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-archive:hover { background: var(--warning); color: white; }

/* ─── View Tabs ─────────────────────────────────────── */
.view-tabs {
  display: flex;
  background: rgba(255,255,255,0.1);
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
}

.view-tab {
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.5);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.view-tab:hover { color: rgba(255,255,255,0.8); }
.view-tab.active { background: white; color: var(--text); }

/* ─── Today View ────────────────────────────────────── */
.today-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.today-header h2 {
  font-size: 20px;
  font-weight: 700;
}

.today-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.today-content {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.today-group-header {
  padding: 10px 16px;
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
  border-bottom: 2px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.today-task {
  display: grid;
  grid-template-columns: 2fr 150px 100px 100px 120px;
  padding: 12px 16px;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.1s;
}
.today-task:hover { background: var(--bg-hover); }
.today-task:nth-child(even) { background: #fafbfc; }

.today-task-title {
  font-weight: 600;
}

.today-task-context {
  font-size: 11px;
  color: var(--text-muted);
}

.today-total-hours {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--primary-light);
  color: var(--primary);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}

/* ─── Calendar View ─────────────────────────────────── */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}

.calendar-day-header {
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
  padding: 8px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

.calendar-day {
  background: white;
  min-height: 100px;
  padding: 6px;
  vertical-align: top;
}

.calendar-day.other-month { background: #f8fafc; opacity: 0.5; }
.calendar-day.today { background: var(--primary-light); }

.calendar-day-number {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.calendar-day.today .calendar-day-number { color: var(--primary); }

.calendar-task {
  display: block;
  padding: 2px 6px;
  margin: 2px 0;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: opacity 0.1s;
}
.calendar-task:hover { opacity: 0.8; }
.calendar-task.planned { background: var(--blue-bg); color: var(--blue); border-left: 2px solid var(--blue); }
.calendar-task.deadline { background: var(--warning-bg); color: var(--warning); border-left: 2px solid var(--warning); }
.calendar-task.overdue { background: var(--danger-bg); color: var(--danger); border-left: 2px solid var(--danger); }

/* ─── New status badges ─────────────────────────────── */
.badge-ready-to-invoice { background: #fae8ff; color: #a21caf; }
.badge-invoiced { background: #ecfdf5; color: #059669; }
.progress-ready-to-invoice { background: #fae8ff; color: #a21caf; }
.progress-invoiced { background: #ecfdf5; color: #059669; }
.progress-ready-to-invoice .progress-dot { background: #a21caf; }
.progress-invoiced .progress-dot { background: #059669; }

/* ─── Task table extended columns ───────────────────── */
.task-table-header-ext {
  display: grid;
  grid-template-columns: 1.8fr 100px 90px 90px 70px 90px 1fr 60px;
  padding: 8px 14px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
  border-bottom: 2px solid var(--border);
}

.task-row-ext {
  display: grid;
  grid-template-columns: 1.8fr 100px 90px 90px 70px 90px 1fr 60px;
  padding: 10px 14px;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
  transition: background 0.15s;
}
.task-row-ext:hover { background: #f8fafc; }
.task-row-ext:nth-child(even) { background: #fafbfc; }
.task-row-ext:nth-child(even):hover { background: #f0f4f8; }

.task-est {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}

.task-created {
  font-size: 10px;
  color: var(--text-muted);
}

/* ─── Drag & Drop ───────────────────────────────────── */
.client-row.dragging {
  opacity: 0.4;
}
.client-row.drag-over {
  border-top: 3px solid var(--primary);
}

.drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 14px;
  padding: 0 4px;
  user-select: none;
}
.drag-handle:active { cursor: grabbing; }

/* ─── Responsive ────────────────────────────────────── */
@media (max-width: 1000px) {
  .header { flex-direction: column; gap: 12px; padding: 12px 16px; }
  .header-right { flex-wrap: wrap; justify-content: center; }
  .main { padding: 16px; }
  .stats-bar { flex-wrap: wrap; }
  .stat-card { min-width: 140px; }
  .table-header { display: none; }
  .client-summary { grid-template-columns: 1fr; gap: 8px; }
  .task-table-header-ext, .task-row-ext { grid-template-columns: 1fr 1fr; gap: 6px; }
  .today-task { grid-template-columns: 1fr 1fr; }
  .calendar-grid { grid-template-columns: repeat(7, 1fr); }
  .calendar-day { min-height: 60px; }
}
