:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-surface: #1a1f2e;
  --bg-surface-hover: #222840;
  --bg-elevated: #252b3b;
  --border: #2a3144;
  --border-light: #374151;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-cyan: #06b6d4;
  --accent-cyan-dim: rgba(6, 182, 212, 0.15);
  --accent-purple: #8b5cf6;
  --accent-purple-dim: rgba(139, 92, 246, 0.15);
  --accent-amber: #f59e0b;
  --accent-green: #10b981;
  --accent-rose: #ec4899;
  --accent-red: #ef4444;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --transition: 0.2s ease;
}

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

input[type="number"] {
  color-scheme: dark;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  opacity: 1;
  cursor: pointer;
  filter: brightness(1.4);
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
}

#app {
  display: flex;
  height: 100vh;
}

/* Sidebar */
#sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

/* Drawer scrim and topbar trigger, revealed by the responsive block below. */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 940;
  background: rgba(0, 0, 0, 0.5);
}

.mobile-topbar {
  display: none;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 40;
  padding: 12px 0;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.mobile-nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  cursor: pointer;
}

.mobile-topbar-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent-cyan);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent-cyan);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.nav-links {
  list-style: none;
  padding: 12px 10px;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
}

.nav-link:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.nav-link.active {
  background: var(--accent-cyan-dim);
  color: var(--accent-cyan);
}

/* Main Content */
#content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
}

.view {
  display: none;
}
.view.active {
  display: block;
}

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.view-header h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.view-toggle {
  display: flex;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

.toggle-btn {
  padding: 10px 18px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.toggle-btn:hover {
  color: var(--text-primary);
}

.toggle-btn.active {
  background: var(--accent-cyan);
  color: #0b0f19;
}

/* Filter Dropdown */
.filter-dropdown {
  position: relative;
}

.filter-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  position: relative;
}

.filter-toggle-btn.filter-active::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-cyan);
  border: 2px solid var(--bg-elevated);
}

.filter-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  min-width: 190px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition:
    opacity var(--transition),
    transform var(--transition),
    visibility var(--transition);
}

.filter-dropdown.open .filter-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.filter-panel-wide {
  min-width: 280px;
}

/* Segmented toggles and chips are sized for a page header, so they need to be
   compact enough to fit the panel column when hosted inside one. */
.filter-panel .view-toggle .toggle-btn {
  flex: 1;
  padding: 8px 6px;
  font-size: 12px;
  white-space: nowrap;
}

.filter-panel .view-toggle + .metric-toggle,
.filter-panel .view-toggle + .sales-custom-range {
  margin-top: 10px;
}

.filter-panel .sales-custom-range {
  flex-wrap: wrap;
}

.filter-panel .sales-custom-range input {
  flex: 1;
  min-width: 118px;
}

.filter-panel-section + .filter-panel-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.filter-panel-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.filter-group-scroll {
  max-height: 160px;
  overflow-y: auto;
}

.filter-empty {
  padding: 6px 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}

.filter-option:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.filter-option input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent-cyan);
  cursor: pointer;
}

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

.btn-primary {
  background: var(--accent-cyan);
  color: #0b0f19;
}

.btn-primary:hover {
  background: #22d3ee;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.btn-danger {
  background: transparent;
  color: var(--accent-red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

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

/* Card Grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all var(--transition);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--card-accent, var(--accent-cyan));
}

.card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
}

.card-badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.card-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-cost {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cost-label {
  font-size: 12px;
  color: var(--text-muted);
}
.cost-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-green);
}

.card-people {
  display: flex;
  gap: 4px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.person-chip {
  padding: 2px 8px;
  background: var(--bg-elevated);
  border-radius: 12px;
  font-size: 11px;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* FullCalendar Dark Theme */
#calendar {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-surface);
}

.fc {
  --fc-border-color: var(--border);
  --fc-page-bg-color: var(--bg-surface);
  --fc-neutral-bg-color: var(--bg-secondary);
  --fc-list-event-hover-bg-color: var(--bg-surface-hover);
  --fc-today-bg-color: rgba(6, 182, 212, 0.08);
  --fc-event-border-color: transparent;
  --fc-neutral-text-color: var(--text-secondary);
  --fc-button-bg-color: var(--bg-elevated);
  --fc-button-border-color: var(--border);
  --fc-button-text-color: var(--text-primary);
  --fc-button-hover-bg-color: var(--bg-surface-hover);
  --fc-button-hover-border-color: var(--border-light);
  --fc-button-active-bg-color: var(--accent-cyan);
  --fc-button-active-border-color: var(--accent-cyan);
  font-family: inherit;
}

.fc .fc-toolbar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.fc .fc-button {
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  box-shadow: none !important;
  text-transform: capitalize;
}

.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active {
  background: var(--accent-cyan);
  border-color: var(--accent-cyan);
  color: #0b0f19;
}

.fc .fc-col-header-cell {
  background: var(--bg-secondary);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 0;
}

.fc .fc-col-header-cell-cushion {
  color: var(--text-secondary);
  text-decoration: none;
}

.fc .fc-daygrid-day-number {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  padding: 6px 10px;
}

.fc .fc-daygrid-day.fc-day-today .fc-daygrid-day-number {
  background: var(--accent-cyan);
  color: #0b0f19;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 4px 4px 0 auto;
}

.fc .fc-daygrid-day.fc-day-other .fc-daygrid-day-number {
  color: var(--text-muted);
  opacity: 0.5;
}

.fc .fc-daygrid-day-frame {
  min-height: 100px;
}

.fc .fc-daygrid-event {
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 6px;
  margin: 1px 2px;
  border: none;
  cursor: pointer;
}

.fc .fc-daygrid-event .fc-event-title {
  font-weight: 600;
}

.fc .fc-daygrid-event .fc-event-main {
  color: #fff;
}

.fc .fc-daygrid-dot-event .fc-event-title {
  font-weight: 600;
}

.fc .fc-h-event {
  border: none;
}

.fc .fc-daygrid-more-link {
  color: var(--accent-cyan);
  font-size: 12px;
  font-weight: 600;
}

.fc .fc-popover {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.fc .fc-popover-header {
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
}

.fc .fc-popover-body {
  padding: 4px;
}

.fc-theme-standard td,
.fc-theme-standard th {
  border-color: var(--border);
}

.fc .fc-scrollgrid {
  border-color: var(--border);
}

.fc-day-sat,
.fc-day-sun {
  background: rgba(0, 0, 0, 0.15);
}

.fc .fc-daygrid-event-harness {
  margin-bottom: 1px;
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal.open {
  display: flex;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 520px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: modalSlideIn 0.2s ease;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color var(--transition);
}

.modal-close:hover {
  color: var(--text-primary);
}

/* Forms */
.form-group {
  margin-bottom: 16px;
  flex: 1;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--transition);
}

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

.form-group input[type="color"] {
  height: 40px;
  padding: 4px;
  cursor: pointer;
}

.form-group select[multiple] {
  min-height: 80px;
}

.form-row {
  display: flex;
  gap: 16px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  user-select: none;
}

.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-cyan);
  cursor: pointer;
}

.confirmed-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-green);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
  margin-left: 4px;
}

.cal-confirmed {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.9);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
  cursor: default;
}

.major-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--accent-amber-dim, rgba(245, 158, 11, 0.15));
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.4);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
  vertical-align: middle;
  margin-left: 6px;
}

.cal-major {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(245, 158, 11, 0.9);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
  cursor: default;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Detail Panel */
.detail-panel {
  position: fixed;
  top: 0;
  right: -520px;
  width: 520px;
  height: 100vh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  z-index: 900;
  transition: right 0.3s ease;
  overflow-y: auto;
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.3);
}

.detail-panel.open {
  right: 0;
}

.detail-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 850;
  background: rgba(0, 0, 0, 0.3);
}

.detail-overlay.open {
  display: block;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  z-index: 1;
  gap: 12px;
}

.detail-header h2 {
  font-size: 18px;
  font-weight: 700;
  flex: 1;
  min-width: 0;
}

.detail-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.icon-btn:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-light);
}

#detail-body {
  padding: 24px;
}

.detail-section {
  margin-bottom: 24px;
}

.detail-section h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.detail-field {
  margin-bottom: 12px;
}

.detail-link {
  display: block;
  padding: 8px 10px;
  font-size: 14px;
  color: var(--accent-cyan);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
  text-decoration: none;
  border-radius: var(--radius-sm);
}

.detail-link:hover {
  background: var(--bg-surface-hover);
}

.detail-link:last-child {
  border-bottom: none;
}

.detail-inline-link {
  display: inline;
  padding: 0;
  font-size: inherit;
  color: var(--accent-cyan);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.detail-inline-link:hover {
  color: #22d3ee;
}

.detail-field-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.detail-field-value {
  font-size: 14px;
  color: var(--text-primary);
}

/* Line Items Table */
.line-items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.line-items-table th {
  text-align: left;
  padding: 8px 10px;
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}

.line-items-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

.line-items-table .amount {
  text-align: right;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.line-items-table .total-row td {
  font-weight: 700;
  color: var(--accent-green);
  border-top: 2px solid var(--border-light);
  padding-top: 10px;
}

.line-items-table td.col-edit {
  padding: 4px 6px;
}

.line-items-table input.li-edit-input {
  display: block;
  width: 100%;
  padding: 7px 9px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  transition: border-color var(--transition);
}

.line-items-table input.li-edit-input:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px var(--accent-cyan-dim);
}

.line-items-table input.li-edit-amount {
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.line-items-table input.li-edit-amount::-webkit-inner-spin-button,
.line-items-table input.li-edit-amount::-webkit-outer-spin-button {
  height: 24px;
}

.line-items-table .delete-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
  transition: color var(--transition);
}

.line-items-table .delete-btn:hover {
  color: var(--accent-red);
}

/* Add line item form */
.add-line-item {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  align-items: flex-end;
}

.add-line-item input {
  flex: 1;
  padding: 7px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
}

.add-line-item input:focus {
  outline: none;
  border-color: var(--accent-cyan);
}

/* Inline edit mode in detail panel */
.detail-edit-group {
  margin-bottom: 14px;
}

.detail-edit-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.detail-edit-group input,
.detail-edit-group textarea,
.detail-edit-group select {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--transition);
}

.detail-edit-group input:focus,
.detail-edit-group textarea:focus,
.detail-edit-group select:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px var(--accent-cyan-dim);
}

.detail-edit-group select[multiple] {
  min-height: 72px;
}

.detail-edit-group input[type="color"] {
  height: 36px;
  padding: 3px;
  cursor: pointer;
}

.detail-edit-row {
  display: flex;
  gap: 12px;
}

.detail-edit-row .detail-edit-group {
  flex: 1;
}

.detail-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  z-index: 2000;
  animation: toastIn 0.3s ease;
  box-shadow: var(--shadow);
}

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

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

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* List View */
.list-section {
  margin-bottom: 36px;
}

.list-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.list-section-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.list-section-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#list-events-toggle,
#list-campaigns-toggle {
  padding: 8px 14px;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
  background: var(--bg-surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

/* Keeps a too-wide table scrolling inside its own container instead of
   stretching the page. Height is uncapped, so rows just run down the page. */
.table-scroll {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* Opt in when a long table should also be capped and scrolled vertically. */
.table-scroll-capped {
  max-height: 420px;
}

.table-scroll-capped thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

/* The table's own overflow must be released or it would clip the sticky
   header, and its border moves to the wrapper. */
.table-scroll .data-table {
  border: none;
  border-radius: 0;
  overflow: visible;
  min-width: 560px;
}

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

.data-table tbody tr {
  cursor: pointer;
  transition: background var(--transition);
}

.data-table tbody tr:hover {
  background: var(--bg-surface-hover);
}

.data-table tbody tr.row-past {
  opacity: 0.6;
}

.data-table tbody tr.row-past:hover {
  opacity: 0.8;
}

.data-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table .col-color {
  width: 6px;
  padding: 0;
}

.data-table .color-dot {
  width: 6px;
  height: 100%;
  min-height: 38px;
  display: block;
}

.data-table .row-name {
  font-weight: 600;
  color: var(--text-primary);
}

.data-table .col-reason {
  display: none;
}

.data-table.show-reason .col-reason {
  display: table-cell;
}

.data-table .col-cost {
  text-align: right;
}

.data-table .row-cost {
  text-align: right;
  font-weight: 700;
  color: var(--accent-green);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.data-table .row-people {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

/* Login Page */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: var(--bg-primary);
}

.login-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px;
  width: 360px;
  max-width: 90vw;
  box-shadow: var(--shadow);
}

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

.empty-state svg {
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 16px;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

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

/* App Switcher */
.app-switcher {
  width: 100%;
}

.logo-btn {
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}

.logo-btn span {
  flex: 1;
}

.app-switcher-caret {
  color: var(--text-muted);
  transition: transform var(--transition);
}

.app-switcher.open .app-switcher-caret {
  transform: rotate(180deg);
}

.app-switcher-panel {
  left: 0;
  right: 0;
  padding: 6px;
}

.app-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.app-option:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.app-option.active {
  color: var(--accent-cyan);
}

/* Sales Dashboard */
.view-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
  max-width: 720px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--card-accent, var(--border-light));
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
}

.sales-panel {
  padding: 18px 20px;
  margin-bottom: 20px;
  cursor: default;
}

.sales-panel:hover {
  transform: none;
}

.sales-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.sales-panel-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
}

.sales-panel-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.sales-panel-header h2 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* display:flex on these would otherwise beat the browser's default
   [hidden]{display:none} rule, since author styles always win over user-agent
   styles regardless of selector specificity. */
.metric-toggle[hidden],
.sales-legend[hidden],
.sales-custom-range[hidden] {
  display: none;
}

.metric-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.metric-chip {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.metric-chip:hover {
  color: var(--text-primary);
  border-color: var(--border-light);
}

.metric-chip.active {
  background: var(--accent-cyan-dim);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.sales-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 12px;
  color: var(--text-muted);
}

.sales-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sales-legend-item::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--border-light);
}

.sales-legend-item[data-series="calls"]::before {
  background: var(--accent-cyan);
}
.sales-legend-item[data-series="emails"]::before {
  background: var(--accent-purple);
}
.sales-legend-item[data-series="demos"]::before {
  background: var(--accent-green);
  border-radius: 50%;
}
.sales-legend-item[data-series="booked"]::before {
  background: var(--accent-rose);
  border-radius: 50%;
}

.sales-chart-wrap {
  height: 260px;
}

.sales-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 4px 0 14px;
}

.data-table .col-rank {
  width: 44px;
  text-align: center;
}

.data-table .col-num {
  text-align: right;
  width: 78px;
}

.data-table .row-win {
  font-weight: 700;
  color: var(--accent-green);
}

.sales-custom-range {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.sales-custom-range input {
  padding: 7px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  color-scheme: dark;
}

.rep-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px 8px;
  margin-top: 12px;
}

.rep-stat-value {
  display: block;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
}

.rep-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sales-sync-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-muted);
}

.sync-chip {
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
}

.sync-error {
  color: var(--accent-red);
}

.rep-active {
  color: var(--accent-green);
  font-weight: 600;
}

.rep-inactive {
  color: var(--text-muted);
}

/* ── Responsive ── */

/* Below this width the sidebar leaves the flex row and becomes an off-canvas
   drawer, so #content gets the full viewport width. */
@media (max-width: 900px) {
  /* visibility, not just the transform: an offscreen drawer would otherwise
     stay in the tab order and reachable by screen readers. It is transitioned
     so it stays visible for the length of the slide out. */
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 950;
    overflow-y: auto;
    box-shadow: var(--shadow);
    visibility: hidden;
    transform: translateX(-100%);
    transition:
      transform 0.25s ease,
      visibility 0.25s ease;
  }

  #sidebar.open {
    visibility: visible;
    transform: translateX(0);
  }

  .sidebar-overlay.open {
    display: block;
  }

  .mobile-topbar {
    display: flex;
  }

  #content {
    padding: 0 16px 24px;
  }
}

/* Motion-sensitive users still get the drawer, just without the slide. */
@media (prefers-reduced-motion: reduce) {
  #sidebar {
    transition: none;
  }
}
