/* Sun-stone Pipeline — design tokens & base styles */
:root {
  /* Neutral palette — warm off-white canvas */
  --bg-canvas: #F0EFF2;
  --bg-card: #ffffff;
  --bg-stage-band: #e7e5ea;
  --bg-subtle: #f8f7f9;
  --bg-hover: #e9e8ec;

  /* Text */
  --text-primary: #1a1a1a;
  --text-secondary: #6b6b66;
  --text-muted: #9a9a93;
  --text-inverse: #ffffff;

  /* Borders */
  --border-hairline: #e4e2e8;
  --border-strong: #d2d0d8;
  --border-focus: #1a1a1a;

  /* Priority pills */
  --priority-high-bg: #fde2e2;
  --priority-high-fg: #b42424;
  --priority-med-bg: #fde9c8;
  --priority-med-fg: #8a5a14;
  --priority-low-bg: #d9e6f4;
  --priority-low-fg: #2c5282;

  /* Status / accents */
  --accent-amber: #d97706;
  --accent-amber-bg: #fef3c7;
  --accent-green: #16794d;
  --accent-green-bg: #d6efe1;
  --accent-red: #b42424;

  /* Shadows */
  --shadow-card-hover: 0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.04);
  --shadow-drawer: -8px 0 32px rgba(0,0,0,0.08);
  --shadow-modal: 0 8px 40px rgba(0,0,0,0.18);

  /* Type */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Instrument Serif', Georgia, serif;

  /* Radii */
  --radius-card: 10px;
  --radius-pill: 999px;
  --radius-input: 10px;
  --radius-tab: 999px;
}

* { box-sizing: border-box; }

html, body, #root {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  padding: 0;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

input:focus, textarea:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--text-primary);
  outline-offset: 2px;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
  background: var(--bg-canvas);
}

/* ======= Top nav ======= */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 28px;
  background: var(--bg-canvas);
  flex-shrink: 0;
}
.topnav-left {
  display: flex;
  align-items: center;
  gap: 40px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}
.brand-logo-img {
  width: 120px;
  height: 25px;
  object-fit: contain;
  display: block;
}
.nav-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  opacity: 0.7;
  flex-shrink: 0;
}
.nav-item.active .nav-icon { opacity: 1; }
.nav-items {
  display: flex;
  gap: 4px;
  align-items: center;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 14px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav-items a,
.nav-items a:hover,
.nav-items a:visited,
a.nav-item { text-decoration: none !important; }
.nav-item:hover { color: var(--text-primary); }
.nav-item.active {
  background: white;
  color: var(--text-primary);
  border: 1px solid var(--border-hairline);
}
.topnav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background 0.15s;
}
.icon-btn:hover { background: var(--bg-hover); }
.icon-btn.bordered { border: 1px solid var(--border-hairline); background: white; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-hairline);
  background: white;
}
.user-chip img { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }

/* ======= Page surface ======= */
.page {
  background: white;
  margin: 0 16px 16px 16px;
  border-radius: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-hairline);
}

.page-header {
  padding: 28px 32px 20px 32px;
  flex-shrink: 0;
}
.page-title-row {
  display: flex;
  align-items: baseline;
  gap: 24px;
  margin-bottom: 24px;
}
.page-title {
  font-family: var(--font-display);
  font-size: 38px;
  font-weight: 400;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1;
}
.page-meta {
  display: flex;
  gap: 24px;
  color: var(--text-secondary);
  font-size: 13px;
}
.page-meta strong {
  color: var(--text-primary);
  font-weight: 600;
  margin-left: 6px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.tab-group {
  display: flex;
  gap: 4px;
  background: var(--bg-canvas);
  padding: 4px;
  border-radius: var(--radius-pill);
}
.tab {
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
}
.tab:hover { color: var(--text-primary); }
.tab.active {
  background: white;
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.tab-count {
  color: var(--text-muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.tab.active .tab-count { color: var(--text-secondary); }

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.search-input {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-canvas);
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  width: 280px;
  border: 1px solid transparent;
  transition: border-color 0.15s, background 0.15s;
}
.search-input:focus-within {
  background: white;
  border-color: var(--border-strong);
}
.search-input input {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  font-size: 13px;
  color: var(--text-primary);
}
.search-input input::placeholder { color: var(--text-muted); }

.avatar-stack {
  display: flex;
  align-items: center;
}
.avatar-stack > * + * { margin-left: -8px; }
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid white;
  object-fit: cover;
  background: var(--bg-canvas);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }
.avatar.sm { width: 22px; height: 22px; font-size: 9px; }
.avatar.active-filter { box-shadow: 0 0 0 2px var(--text-primary); }

.avatar-overflow {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-canvas);
  border: 2px solid white;
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, transform 0.05s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--text-primary);
  color: var(--text-inverse);
}
.btn.primary:hover { background: #2c2c2c; }
.btn.primary:disabled { background: var(--border-strong); cursor: not-allowed; }
.btn.ghost { color: var(--text-secondary); }
.btn.ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn.secondary {
  background: white;
  border: 1px solid var(--border-hairline);
  color: var(--text-primary);
}
.btn.secondary:hover { background: var(--bg-hover); }
.btn.danger {
  background: white;
  border: 1px solid var(--border-hairline);
  color: var(--accent-red);
}
.btn.danger:hover { background: #fdf2f2; }

/* ======= Active filter chip row ======= */
.active-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 32px 0 32px;
  flex-wrap: wrap;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 4px 4px 12px;
  background: var(--bg-canvas);
  border-radius: var(--radius-pill);
  font-size: 12px;
  color: var(--text-primary);
}
.filter-chip-label { color: var(--text-secondary); }
.filter-chip-remove {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}
.filter-chip-remove:hover { background: white; color: var(--text-primary); }
.clear-all-link {
  color: var(--text-secondary);
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.clear-all-link:hover { color: var(--text-primary); }

/* ======= Board (stacked swimlanes) ======= */
.board-scroll {
  flex: 1;
  overflow: auto;
  padding: 8px 24px 24px 24px;
}
.board-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 1100px;
}

/* Swimlane block */
.swimlane {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border-hairline);
  border-radius: 12px;
  background: white;
  overflow: hidden;
}
.swimlane.collapsed { background: white; }

/* Full-width band */
.swimlane-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px 18px;
  background: var(--bg-canvas);
  border: none;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: background 0.15s;
}
.swimlane-band:hover { background: var(--bg-hover); }
.swimlane.collapsed .swimlane-band { border-bottom: none; }
.swimlane.open .swimlane-band { border-bottom: 1px solid var(--border-hairline); }

.swimlane-band-left {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.swimlane-caret {
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
}
.swimlane-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.005em;
}
.swimlane-count {
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.swimlane-band-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.swimlane-stat strong {
  color: var(--text-primary);
  font-weight: 600;
  margin-left: 4px;
}
.swimlane-stat-sep {
  color: var(--border-strong);
}

.swimlane-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  padding: 40px 20px;
  color: var(--text-secondary);
  font-size: 13px;
}

/* Grid inside an expanded swimlane: header row + body row */
.swimlane-grid {
  display: grid;
  grid-auto-rows: auto;
  gap: 0;
  padding: 0;
}

.column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px 16px;
  background: white;
  border-right: 1px solid var(--border-hairline);
  border-bottom: 1px solid var(--border-hairline);
}
.column-header:last-child { border-right: none; }
.column-title {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.005em;
}
.column-title-count { color: var(--text-muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.column-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* Each column body inside a lane */
.lane-column {
  background: white;
  padding: 12px 12px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 200px;
  align-self: stretch;
  border-right: 1px solid var(--border-hairline);
}
.lane-column:last-child { border-right: none; }
.lane-column-empty {
  min-height: 1px;
}
.column-dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: 8px;
  padding: 24px 12px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}
.info-i {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 9px;
  font-style: italic;
  font-family: Georgia, serif;
  border: 1px solid var(--border-strong);
  cursor: help;
  margin-left: 2px;
}
.info-i:hover { color: var(--text-secondary); border-color: var(--text-secondary); }

/* ======= Card ======= */
.opp-card {
  background: white;
  border: 1px solid var(--border-hairline);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.opp-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-card-hover);
}
.opp-card.dragging { opacity: 0.5; }
.opp-card.lost {
  opacity: 0.55;
}
.opp-card.lost .card-title { text-decoration: line-through; }

.priority-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 500;
}
.priority-pill.high { background: var(--priority-high-bg); color: var(--priority-high-fg); }
.priority-pill.medium { background: var(--priority-med-bg); color: var(--priority-med-fg); }
.priority-pill.low { background: var(--priority-low-bg); color: var(--priority-low-fg); }

.card-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.stale-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-amber);
  display: inline-block;
}
.stale-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-amber);
  font-size: 11px;
  font-weight: 500;
}

.card-client {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.005em;
  margin-bottom: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}
.card-meta-row { display: flex; gap: 6px; }
.card-meta-label { color: var(--text-muted); }
.card-meta-value { color: var(--text-secondary); }

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-footer-icons {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 11px;
}
.card-footer-icon {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--bg-canvas);
  font-variant-numeric: tabular-nums;
}

/* ======= Drawer ======= */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 14, 0.18);
  z-index: 50;
  animation: fade-in 0.18s ease-out;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 560px;
  max-width: 92vw;
  background: white;
  z-index: 60;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-drawer);
  animation: slide-in-right 0.22s ease-out;
}
@keyframes slide-in-right {
  from { transform: translateX(20px); opacity: 0.6; }
  to { transform: translateX(0); opacity: 1; }
}

.drawer.narrow { width: 380px; }

.drawer-header {
  padding: 20px 24px 16px 24px;
  border-bottom: 1px solid var(--border-hairline);
  flex-shrink: 0;
}
.drawer-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.stage-breadcrumb {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--bg-canvas);
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s;
}
.stage-breadcrumb:hover { background: var(--bg-hover); }
.stage-breadcrumb strong { color: var(--text-primary); font-weight: 600; }
.stage-breadcrumb .sep { color: var(--text-muted); }

.drawer-actions { display: flex; align-items: center; gap: 8px; }

.drawer-title-block { margin-bottom: 18px; }
.drawer-title-client {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.drawer-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1.15;
  margin: 0;
}
.drawer-title-input {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1.15;
  border: none;
  background: var(--bg-subtle);
  padding: 4px 8px;
  margin: -4px -8px;
  border-radius: 6px;
  width: 100%;
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-hairline);
}
.metric-block { display: flex; flex-direction: column; gap: 2px; }
.metric-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}
.metric-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.metric-value.computed { color: var(--text-secondary); }
.metric-owner-row { display: flex; align-items: center; gap: 6px; }

.drawer-tabs {
  display: flex;
  gap: 0;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-hairline);
  flex-shrink: 0;
  overflow-x: auto;
}
.drawer-tab {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.drawer-tab:hover { color: var(--text-primary); }
.drawer-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--text-primary);
}
.drawer-tab-badge {
  background: var(--bg-canvas);
  color: var(--text-secondary);
  font-size: 10px;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  font-weight: 600;
}
.drawer-tab.active .drawer-tab-badge {
  background: var(--text-primary);
  color: white;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 48px 28px;
}

/* Drawer sections */
.section { margin-bottom: 32px; }
.section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 600;
}
.section-link {
  font-size: 12px;
  color: var(--text-secondary);
  text-decoration: underline;
  text-underline-offset: 2px;
  margin-left: auto;
}
.section-header-row {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}
.section-header-row .section-title { margin-bottom: 0; }

.about-text {
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 14px;
  white-space: pre-wrap;
}

.detail-grid {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 8px 20px;
  font-size: 13px;
}
.detail-grid dt {
  color: var(--text-muted);
  font-weight: 400;
}
.detail-grid dd {
  margin: 0;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.dd-overridden {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.overridden-tag {
  font-size: 10px;
  background: var(--bg-canvas);
  color: var(--text-secondary);
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--bg-canvas);
  font-size: 12px;
  color: var(--text-secondary);
}

/* Activity timeline */
.activity-composer {
  background: var(--bg-subtle);
  border: 1px solid var(--border-hairline);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 20px;
}
.activity-types {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.activity-type {
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  color: var(--text-secondary);
}
.activity-type.active { background: var(--text-primary); color: white; }
.activity-type:not(.active):hover { background: white; color: var(--text-primary); }
.activity-textarea {
  width: 100%;
  border: none;
  background: white;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  resize: vertical;
  min-height: 60px;
  border: 1px solid var(--border-hairline);
}
.activity-composer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.timeline-filter {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-hairline);
}
.timeline-filter-chip {
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  color: var(--text-secondary);
}
.timeline-filter-chip.active { background: var(--bg-canvas); color: var(--text-primary); font-weight: 500; }

.timeline {
  position: relative;
  padding-left: 32px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 13px;
  top: 6px;
  bottom: 6px;
  width: 1px;
  background: var(--border-hairline);
}
.timeline-entry {
  position: relative;
  margin-bottom: 18px;
}
.timeline-entry:last-child { margin-bottom: 0; }
.timeline-dot {
  position: absolute;
  left: -32px;
  top: 4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: white;
  border: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}
.timeline-dot.system { background: var(--bg-canvas); }
.timeline-dot img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.timeline-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.timeline-actor { font-weight: 600; font-size: 13px; }
.timeline-action { color: var(--text-secondary); font-size: 13px; }
.timeline-time { color: var(--text-muted); font-size: 12px; margin-left: auto; }
.timeline-body {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.55;
  background: var(--bg-subtle);
  border-radius: 8px;
  padding: 10px 12px;
}

/* Notes */
.note-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-hairline);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
}
.note-card.pinned { background: #fffbef; border-color: #f3e6b8; }
.note-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.note-author { font-size: 13px; font-weight: 600; }
.note-date { color: var(--text-muted); font-size: 12px; }
.note-pin {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-secondary);
  background: white;
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.note-body { font-size: 13px; line-height: 1.55; color: var(--text-primary); }
.note-body strong { font-weight: 600; }

/* Tasks */
.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border-hairline);
}
.task-row:last-child { border-bottom: none; }
.task-checkbox {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1.5px solid var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  background: white;
}
.task-checkbox.checked {
  background: var(--text-primary);
  border-color: var(--text-primary);
  color: white;
}
.task-title { flex: 1; font-size: 13px; }
.task-row.done .task-title { color: var(--text-muted); text-decoration: line-through; }
.task-due {
  font-size: 12px;
  color: var(--text-secondary);
}
.task-due.overdue { color: var(--accent-red); font-weight: 500; }
.task-completed-group {
  margin-top: 16px;
  padding: 10px 0;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Files */
.file-dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 16px;
  background: var(--bg-subtle);
}
.file-dropzone strong { color: var(--text-primary); font-weight: 500; }
.file-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border-hairline);
}
.file-icon {
  width: 36px;
  height: 44px;
  background: var(--bg-canvas);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  flex-shrink: 0;
}
.file-icon.pdf { background: #fde2e2; color: var(--priority-high-fg); }
.file-icon.docx { background: #d9e6f4; color: var(--priority-low-fg); }
.file-icon.pptx { background: var(--priority-med-bg); color: var(--priority-med-fg); }
.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 13px; font-weight: 500; margin-bottom: 2px; }
.file-meta { font-size: 11px; color: var(--text-muted); display: flex; gap: 8px; }
.file-category {
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-canvas);
  padding: 2px 8px;
  border-radius: 4px;
}

/* Contacts */
.contact-card {
  border: 1px solid var(--border-hairline);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
}
.contact-header { display: flex; align-items: flex-start; gap: 12px; }
.contact-info { flex: 1; }
.contact-name { font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.contact-role { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.contact-details { margin-top: 8px; font-size: 12px; color: var(--text-secondary); display: flex; flex-direction: column; gap: 3px; }
.primary-tag { font-size: 10px; background: #d6efe1; color: var(--accent-green); padding: 1px 7px; border-radius: 4px; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase;}

/* History */
.history-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-hairline);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 24px;
}
.history-stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.history-stat-value { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.history-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-hairline);
}
.history-entry:last-child { border-bottom: none; }
.history-pill-pair {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.history-pill {
  display: inline-flex;
  padding: 3px 10px;
  background: var(--bg-canvas);
  border-radius: var(--radius-pill);
  font-size: 11px;
  color: var(--text-secondary);
}
.history-arrow { color: var(--text-muted); }
.history-detail { flex: 1; font-size: 12px; color: var(--text-secondary); }
.history-detail strong { color: var(--text-primary); font-weight: 500; }

/* ======= Modals ======= */
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  border-radius: 14px;
  z-index: 70;
  box-shadow: var(--shadow-modal);
  max-width: 92vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modal-in 0.2s ease-out;
}
@keyframes modal-in {
  from { transform: translate(-50%, -48%); opacity: 0; }
  to { transform: translate(-50%, -50%); opacity: 1; }
}
.modal.add-new { width: 640px; }
.modal.confirm { width: 420px; }
.modal.save-view { width: 380px; }
.modal-header {
  padding: 20px 24px 16px 24px;
  border-bottom: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.015em;
  margin: 0;
}
.modal-body { padding: 20px 24px; flex: 1; overflow-y: auto; }
.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Form */
.form-group { margin-bottom: 16px; }
.form-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-top: 24px;
  margin-bottom: 12px;
  font-weight: 600;
}
.form-section-title:first-child { margin-top: 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row.three { grid-template-columns: 1fr 1fr 1fr; }
.form-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}
.form-label .required { color: var(--accent-red); }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-hairline);
  border-radius: 8px;
  background: white;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--text-primary);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-input.currency {
  font-variant-numeric: tabular-nums;
}
.form-priority-group { display: flex; gap: 6px; }
.form-priority-option {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-hairline);
  background: white;
  font-size: 13px;
  text-align: center;
  cursor: pointer;
}
.form-priority-option.active.high { background: var(--priority-high-bg); border-color: transparent; color: var(--priority-high-fg); font-weight: 500; }
.form-priority-option.active.medium { background: var(--priority-med-bg); border-color: transparent; color: var(--priority-med-fg); font-weight: 500; }
.form-priority-option.active.low { background: var(--priority-low-bg); border-color: transparent; color: var(--priority-low-fg); font-weight: 500; }

.form-helper { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.form-tag-input {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--border-hairline);
  border-radius: 8px;
  background: white;
  min-height: 38px;
}
.form-tag-input input {
  border: none;
  outline: none;
  background: none;
  flex: 1;
  min-width: 80px;
  font-size: 13px;
  padding: 4px 6px;
}
.form-tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-canvas);
  padding: 3px 4px 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
}

/* ======= Filter panel ======= */
.filter-section {
  border-bottom: 1px solid var(--border-hairline);
  padding: 18px 24px;
}
.filter-section:last-child { border-bottom: none; }
.filter-section-title {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}
.filter-section-title .chev { color: var(--text-muted); }
.filter-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.filter-preset {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--bg-canvas);
  font-size: 12px;
  color: var(--text-secondary);
}
.filter-preset.active { background: var(--text-primary); color: white; }
.filter-checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 13px;
  cursor: pointer;
}
.filter-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 8px;
}
.toggle-switch {
  width: 32px;
  height: 18px;
  background: var(--border-strong);
  border-radius: 999px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle-switch::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  top: 2px;
  left: 2px;
  transition: left 0.2s;
}
.toggle-switch.on { background: var(--text-primary); }
.toggle-switch.on::after { left: 16px; }

/* ======= Menus ======= */
.menu {
  position: absolute;
  background: white;
  border: 1px solid var(--border-hairline);
  border-radius: 10px;
  box-shadow: var(--shadow-modal);
  z-index: 80;
  min-width: 220px;
  padding: 6px;
  animation: menu-in 0.12s ease-out;
}
@keyframes menu-in {
  from { transform: translateY(-4px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  width: 100%;
  text-align: left;
  color: var(--text-primary);
}
.menu-item:hover { background: var(--bg-canvas); }
.menu-item.danger:hover { background: #fdf2f2; color: var(--accent-red); }
.menu-divider {
  height: 1px;
  background: var(--border-hairline);
  margin: 6px 0;
}
.menu-section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 8px 12px 4px 12px;
  font-weight: 600;
}

.submenu-arrow { margin-left: auto; color: var(--text-muted); }

/* Stage selector inline */
.stage-selector {
  background: white;
  border: 1px solid var(--border-hairline);
  border-radius: 12px;
  box-shadow: var(--shadow-modal);
  padding: 8px;
  z-index: 90;
  min-width: 280px;
}
.stage-group { padding: 4px 0; }
.stage-group + .stage-group { border-top: 1px solid var(--border-hairline); margin-top: 4px; padding-top: 8px; }
.stage-group-name {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 4px 10px 6px 10px;
  font-weight: 600;
}
.stage-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  width: 100%;
  text-align: left;
}
.stage-option:hover { background: var(--bg-canvas); }
.stage-option.current { background: var(--bg-canvas); }
.stage-option-rate { font-size: 11px; color: var(--text-muted); }

/* Tooltips */
.tooltip {
  position: absolute;
  background: #1a1a1a;
  color: white;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.5;
  z-index: 100;
  max-width: 320px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  pointer-events: none;
}
.tooltip-line { display: flex; justify-content: space-between; gap: 16px; }
.tooltip-line + .tooltip-line { margin-top: 4px; }
.tooltip-label { color: rgba(255,255,255,0.6); }

/* InfoTip rich content */
.tip-block { min-width: 200px; }
.tip-heading { font-weight: 600; font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; color: rgba(255,255,255,0.55); margin-bottom: 8px; }
.tip-row { display: flex; justify-content: space-between; gap: 24px; padding: 2px 0; white-space: nowrap; }
.tip-row span { color: rgba(255,255,255,0.7); }
.tip-row strong { color: white; font-weight: 600; }
.tip-divider { height: 1px; background: rgba(255,255,255,0.12); margin: 6px 0; }
.tip-formula { font-size: 10.5px; color: rgba(255,255,255,0.5); margin-top: 6px; font-style: italic; }

/* List view */
.list-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.list-table-wrap {
  flex: 1;
  overflow: auto;
  margin: 0 24px 24px 24px;
  border: 1px solid var(--border-hairline);
  border-radius: 10px;
}
.list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 1100px;
}
.list-table th {
  position: sticky;
  top: 0;
  background: var(--bg-subtle);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  font-weight: 600;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-hairline);
  white-space: nowrap;
  user-select: none;
  cursor: pointer;
}
.list-table th:hover { color: var(--text-primary); }
.list-table th .sort-arrow { font-size: 10px; margin-left: 4px; color: var(--text-muted); }
.list-table th.sorted .sort-arrow { color: var(--text-primary); }
.list-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-hairline);
  vertical-align: middle;
}
.list-table tr:last-child td { border-bottom: none; }
.list-table tr:hover { background: var(--bg-subtle); }
.list-table tr { cursor: pointer; }
.list-cell-title { font-weight: 600; }
.list-cell-client { font-size: 11px; color: var(--text-secondary); margin-bottom: 2px; }
.list-cell-num { font-variant-numeric: tabular-nums; }
.list-cell-stage { display: inline-flex; align-items: center; gap: 4px; }

/* Empty / loading / error */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 32px;
  text-align: center;
}
.empty-state-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-canvas);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  margin-bottom: 16px;
}
.empty-state-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.01em;
  margin: 0 0 6px 0;
}
.empty-state-body { color: var(--text-secondary); font-size: 13px; margin-bottom: 16px; max-width: 340px; }

.error-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #fdf2f2;
  border: 1px solid #f5d0d0;
  border-radius: 10px;
  margin: 0 32px 16px 32px;
  font-size: 13px;
  color: var(--priority-high-fg);
}
.error-banner button { margin-left: auto; color: var(--priority-high-fg); font-weight: 500; text-decoration: underline; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  z-index: 200;
  box-shadow: var(--shadow-modal);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: toast-in 0.2s ease-out;
}
@keyframes toast-in { from { transform: translate(-50%, 12px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.toast-action { color: white; text-decoration: underline; font-weight: 500; }

.skeleton-card {
  background: white;
  border: 1px solid var(--border-hairline);
  border-radius: 10px;
  padding: 14px;
  height: 156px;
}
.skeleton-line {
  height: 10px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--bg-canvas) 0%, #ebeae6 50%, var(--bg-canvas) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  margin-bottom: 8px;
}
@keyframes shimmer { from { background-position: -200% 0; } to { background-position: 200% 0; } }

/* Design notes block */
.design-notes-toggle {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: white;
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-pill);
  padding: 8px 14px;
  font-size: 12px;
  color: var(--text-secondary);
  z-index: 30;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.design-notes-toggle:hover { color: var(--text-primary); }
.design-notes-panel {
  position: fixed;
  bottom: 56px;
  right: 16px;
  width: 380px;
  max-height: 70vh;
  background: white;
  border: 1px solid var(--border-hairline);
  border-radius: 12px;
  box-shadow: var(--shadow-modal);
  z-index: 31;
  display: flex;
  flex-direction: column;
}
.design-notes-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.design-notes-body {
  padding: 16px 18px;
  overflow-y: auto;
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.55;
}
.design-notes-body h4 {
  font-size: 12px;
  margin: 16px 0 6px 0;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.design-notes-body h4:first-child { margin-top: 0; }
.design-notes-body p { margin: 0 0 10px 0; }
.design-notes-body ul { margin: 0 0 10px 18px; padding: 0; }
.design-notes-body li { margin-bottom: 4px; }

/* Saved view */
.save-view-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-hairline);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}
.save-view-input:focus { border-color: var(--text-primary); }
