:root {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-secondary: #475467;
  --text-muted: #98a2b3;
  --accent: #b42318;
  --accent-hover: #912018;
  --accent-soft: #fef3f2;
  --accent-ring: rgba(180, 35, 24, 0.12);
  --good: #027a48;
  --good-bg: #ecfdf3;
  --good-border: #abefc6;
  --warn: #b54708;
  --warn-bg: #fffaeb;
  --warn-border: #fedf89;
  --bad: #b42318;
  --bad-bg: #fef3f2;
  --bad-border: #fecdca;
  --info: #175cd3;
  --info-bg: #eff8ff;
  --info-border: #b2ddff;
  --neutral-bg: #f2f4f7;
  --neutral-border: #eaecf0;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, 0.1), 0 2px 4px -2px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 12px 16px -4px rgba(16, 24, 40, 0.08), 0 4px 6px -2px rgba(16, 24, 40, 0.03);
  --shadow-xl: 0 20px 24px -4px rgba(16, 24, 40, 0.08), 0 8px 8px -4px rgba(16, 24, 40, 0.03);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --sidebar-width: min(560px, 100vw);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.appbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
}

.appbar-left { display: flex; align-items: center; gap: 14px; }
.logo {
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.08em;
  background: linear-gradient(135deg, var(--accent), #d92d20);
  color: #fff;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}
.appbar-title h1 { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; }
.appbar-sub { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.appbar-right { display: flex; align-items: center; gap: 8px; }
.save-state { font-size: 11px; color: var(--text-muted); }

.periodbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.periodbar label { font-size: 12px; font-weight: 500; color: var(--text-secondary); }
.period-sep { color: var(--text-muted); }

.tabs {
  display: flex;
  gap: 4px;
  padding: 8px 24px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.tab {
  background: none;
  border: none;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, background 0.15s;
}
.tab:hover { color: var(--text); background: var(--bg); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--bg);
}

.content {
  flex: 1;
  padding: 24px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}
.panel { display: none; animation: fadeIn 0.2s ease; }
.panel.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: all 0.15s;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--bg); border-color: var(--text-muted); }
.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.btn-ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--text-secondary);
}
.btn.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.danger { color: var(--bad); border-color: var(--bad-border); background: var(--bad-bg); }
.btn.danger:hover { background: #fee4e2; }
.btn.icon-btn { padding: 8px; min-width: 36px; }

.input {
  border: 1px solid var(--border-strong);
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  width: 100%;
  max-width: 280px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.input.textarea { max-width: 100%; resize: vertical; min-height: 80px; }
.search { max-width: 240px; }
.filter-select { max-width: 160px; }

.menu { position: relative; }
.menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 240px;
  z-index: 200;
  overflow: hidden;
}
.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}
.menu-item:hover { background: var(--bg); }

/* Project list */
.list-toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.projects-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.projects-card-wide { overflow-x: auto; }
.notes-cell { max-width: 220px; }
.notes-truncate {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 12px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr {
  transition: background 0.12s;
  border-left: 3px solid transparent;
}
.data-table tbody tr:hover { background: #fafbfc; }
.data-table tbody tr.row-active { border-left-color: #12b76a; background: #f6fef9; }
.data-table tbody tr.row-completed { border-left-color: #6172f3; }
.data-table tbody tr.row-on_hold { border-left-color: #f79009; background: #fffcf5; }
.data-table tbody tr.row-cancelled { border-left-color: #98a2b3; opacity: 0.7; }
.data-table.compact td, .data-table.compact th { padding: 8px 10px; font-size: 12px; }

.project-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  text-align: left;
  text-decoration: none;
}
.project-link:hover { text-decoration: underline; }

.mono { font-family: ui-monospace, "Cascadia Code", monospace; font-size: 12px; color: var(--text-secondary); }
.num { font-weight: 600; font-size: 14px; }
.bad-text { color: var(--bad); font-weight: 600; }

/* Pills & badges */
.pill, .badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.pill.status-active, .badge.status-active { background: var(--good-bg); color: var(--good); border-color: var(--good-border); }
.pill.status-completed, .badge.status-completed { background: var(--info-bg); color: var(--info); border-color: var(--info-border); }
.pill.status-on_hold, .badge.status-on_hold { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
.pill.status-cancelled, .badge.status-cancelled { background: var(--neutral-bg); color: var(--text-muted); border-color: var(--neutral-border); }

.pill.phase-onboarding { background: #f4f3ff; color: #5925dc; border-color: #d9d6fe; }
.pill.phase-implementation { background: var(--info-bg); color: var(--info); border-color: var(--info-border); }
.pill.phase-go_live { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
.pill.phase-stabilization { background: #f0fdf9; color: #107569; border-color: #99f6e0; }
.pill.phase-handed_off { background: var(--good-bg); color: var(--good); border-color: var(--good-border); }

.badge.q-excellent { background: var(--good-bg); color: var(--good); border-color: var(--good-border); }
.badge.q-good { background: var(--info-bg); color: var(--info); border-color: var(--info-border); }
.badge.q-watch { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
.badge.q-poor { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-border); }
.badge.q-none { background: var(--neutral-bg); color: var(--text-muted); border-color: var(--neutral-border); }

.pill.kpi-good { background: var(--good-bg); color: var(--good); border-color: var(--good-border); }
.pill.kpi-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
.pill.kpi-bad { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-border); }
.pill.kpi-neutral { background: var(--neutral-bg); color: var(--text-muted); }

/* Sidebar */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.4);
  backdrop-filter: blur(2px);
  z-index: 300;
  animation: fadeIn 0.2s ease;
}
.sidebar-backdrop[hidden] { display: none; }

.project-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--surface);
  box-shadow: var(--shadow-xl);
  z-index: 400;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.project-sidebar.open { transform: translateX(0); }
.project-sidebar[hidden] { display: none; }

.sidebar-inner {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.sidebar-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.sidebar-header h2 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
}
.sidebar-header-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.sidebar-actions { display: flex; gap: 6px; flex-shrink: 0; }

.sidebar-nav {
  display: flex;
  gap: 4px;
  padding: 12px 24px 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  background: var(--bg);
}
.sidebar-nav-btn {
  background: none;
  border: none;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  margin-bottom: -1px;
}
.sidebar-nav-btn:hover { color: var(--text); }
.sidebar-nav-btn.active { color: var(--accent); border-bottom-color: var(--accent); background: var(--surface); }

.sidebar-panel { display: none; padding: 20px 24px 32px; }
.sidebar-panel.active { display: block; }

.detail-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}
.detail-section h3 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 14px;
}
.field {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}
.field.full { grid-template-columns: 1fr; }
.field label { font-size: 12px; font-weight: 500; color: var(--text-secondary); }
.field .input { max-width: 100%; }

.chip-group { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.12s;
}
.chip:hover { border-color: var(--accent); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.lifecycle-timeline {
  display: flex;
  align-items: center;
  padding: 8px 0;
  overflow-x: auto;
}
.lifecycle-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 72px;
}
.lifecycle-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--surface);
}
.lifecycle-step.done .lifecycle-dot { background: var(--good); border-color: var(--good); }
.lifecycle-step.current .lifecycle-dot {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-ring);
}
.lifecycle-label { font-size: 10px; text-align: center; color: var(--text-muted); max-width: 80px; }
.lifecycle-step.current .lifecycle-label { color: var(--accent); font-weight: 600; }
.lifecycle-connector { flex: 1; height: 2px; background: var(--border); min-width: 16px; max-width: 32px; }
.lifecycle-connector.done { background: var(--good); }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 8px;
}

.quality-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.quality-score-big {
  font-size: 48px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  min-width: 72px;
  text-align: center;
  padding: 12px;
  border-radius: var(--radius);
}
.quality-score-big.q-excellent { background: var(--good-bg); color: var(--good); }
.quality-score-big.q-good { background: var(--info-bg); color: var(--info); }
.quality-score-big.q-watch { background: var(--warn-bg); color: var(--warn); }
.quality-score-big.q-poor { background: var(--bad-bg); color: var(--bad); }
.quality-score-big.q-none { background: var(--neutral-bg); color: var(--text-muted); }
.quality-band { font-size: 15px; font-weight: 600; }

.quality-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.quality-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.quality-card-label { font-size: 12px; font-weight: 500; margin-bottom: 2px; }
.quality-card-weight { font-size: 11px; color: var(--text-muted); margin-bottom: 8px; }

.incident-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

/* Comments */
.comment-compose {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
}
.comment-list { display: flex; flex-direction: column; gap: 10px; }
.comment-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.comment-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
}
.comment-role {
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.comment-role.role-implementation { background: var(--info-bg); color: var(--info); }
.comment-role.role-sales { background: #f4f3ff; color: #5925dc; }
.comment-role.role-csc { background: var(--good-bg); color: var(--good); }
.comment-time { color: var(--text-muted); margin-left: auto; }
.comment-text { font-size: 13px; color: var(--text); white-space: pre-wrap; }

.status-updates-panel .section-header { margin-top: 8px; }
.status-update-list { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.status-update-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  background: #fafbfc;
}
.status-update-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.status-update-edited { font-size: 11px; margin-right: auto; }
.recording-link-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.recording-link-row .input { flex: 1; min-width: 0; }
.recording-open-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--info);
  text-decoration: none;
  white-space: nowrap;
}
.recording-open-link:hover { text-decoration: underline; }

/* Attachments */
.attachment-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 16px;
}
.attachment-zone:hover { border-color: var(--accent); background: var(--accent-soft); }
.attachment-zone p { font-size: 13px; color: var(--text-secondary); margin-top: 6px; }
.attachment-list { display: flex; flex-direction: column; gap: 8px; }
.attachment-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.attachment-icon {
  width: 40px;
  height: 40px;
  background: var(--bad-bg);
  color: var(--bad);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}
.attachment-info { flex: 1; min-width: 0; }
.attachment-name { font-weight: 500; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-meta { font-size: 11px; color: var(--text-muted); }

.ticket-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.ticket-field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* Dashboard */
.kpi-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.kpi-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 14px 18px;
  background: var(--text);
  color: #fff;
}
.kpi-table td { padding: 14px 18px; border-bottom: 1px solid var(--border); }
.kpi-table tr:last-child td { border-bottom: none; }

.dash-header { margin-bottom: 24px; }
.dash-header h2 { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 4px; }
.muted { color: var(--text-muted); font-size: 13px; }
.empty-msg { color: var(--text-muted); padding: 48px 0; text-align: center; }

.chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.chart-title { font-size: 14px; font-weight: 600; margin-bottom: 16px; color: var(--text-secondary); }

.report-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.import-hint { margin: -8px 0 20px; font-size: 13px; }
.kpi-export-pre {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 16px;
  font-size: 11px;
  font-family: ui-monospace, monospace;
  overflow: auto;
  max-height: 300px;
  border-radius: var(--radius);
}

.appfoot {
  text-align: center;
  padding: 16px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.toast-host { position: fixed; bottom: 24px; right: 24px; z-index: 500; }
.toast {
  background: var(--text);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: fadeIn 0.2s ease;
}

@media (max-width: 800px) {
  .field { grid-template-columns: 1fr; }
  .chart-row { grid-template-columns: 1fr; }
  .ticket-grid { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .tabs, .periodbar, .appbar { padding-left: 16px; padding-right: 16px; }
}

@media print {
  .appbar, .periodbar, .tabs, .appfoot, .btn, .list-toolbar, .report-actions,
  .sidebar-backdrop, .project-sidebar, .stream-tabs, .stat-grid { display: none !important; }
  .content { max-width: 100%; padding: 0; }
  .panel { display: none !important; }
  #panel-kpis, #panel-overview { display: block !important; }
  body { background: white; }
}

/* ── Portfolio dashboard cards ── */
.section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 28px 0 12px;
}

.stat-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 8px;
}
.stat-grid-6 { grid-template-columns: repeat(6, 1fr); }
.stat-grid-5 { grid-template-columns: repeat(5, 1fr); }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, transform 0.15s;
  cursor: default;
  font-family: inherit;
  width: 100%;
}
.stat-card.clickable { cursor: pointer; }
.stat-card.clickable:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.stat-card.tone-good { border-top: 3px solid var(--good); }
.stat-card.tone-bad { border-top: 3px solid var(--bad); }
.stat-card.tone-warn { border-top: 3px solid var(--warn); }
.stat-card.accent-left { border-left: 4px solid var(--good); }

.stat-card-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
  line-height: 1.3;
}
.stat-card-value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 6px;
}
.stat-card-sub {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.35;
}

.jump-card .stat-card-value { font-size: 28px; }

.portfolio-progress-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
}
.portfolio-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 14px;
}

/* Progress bars */
.progress-bar {
  height: 8px;
  background: var(--neutral-bg);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 12px;
}
.progress-bar.progress-portfolio { height: 12px; margin-bottom: 16px; }
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--info);
  transition: width 0.3s ease;
}
.progress-fill.fill-excellent { background: var(--good); }
.progress-fill.fill-good { background: var(--info); }
.progress-fill.fill-watch { background: var(--warn); }
.progress-fill.fill-low { background: var(--bad); }

.progress-cell { min-width: 120px; }
.progress-pct {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 4px;
}

/* Workload charts */
.workload-card { min-height: 200px; }
.workload-row {
  display: grid;
  grid-template-columns: 120px 1fr 100px;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
  font-size: 12px;
}
.workload-row.clickable { cursor: pointer; }
.workload-row.clickable:hover .workload-label { color: var(--accent); }
.workload-label { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workload-bar {
  display: flex;
  height: 14px;
  background: var(--neutral-bg);
  border-radius: 4px;
  overflow: hidden;
}
.workload-seg { height: 100%; }
.workload-seg.fd { background: #344054; }
.workload-seg.fb { background: #98a2b3; }
.workload-count { font-size: 11px; color: var(--text-muted); text-align: right; }
.workload-legend {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  font-size: 11px;
  color: var(--text-muted);
}
.workload-legend .leg {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: -2px;
}
.workload-legend .leg.fd { background: #344054; }
.workload-legend .leg.fb { background: #98a2b3; }

/* Stream tabs (Projects) */
.stream-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.stream-tab {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.stream-tab:hover { border-color: var(--accent); color: var(--text); }
.stream-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.stream-summary-host { margin-bottom: 16px; }
.stream-summary-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-secondary);
}

.engineer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.engineer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}
.engineer-card.clickable { cursor: pointer; transition: box-shadow 0.15s; }
.engineer-card.clickable:hover { box-shadow: var(--shadow-md); }
.engineer-name { font-weight: 600; font-size: 13px; margin-bottom: 8px; }
.engineer-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.ebadge {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--neutral-bg);
  color: var(--text-secondary);
}
.ebadge.eb-good { background: var(--good-bg); color: var(--good); }
.ebadge.eb-bad { background: var(--bad-bg); color: var(--bad); }
.ebadge.eb-warn { background: var(--warn-bg); color: var(--warn); }

.filter-active-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--bad-border);
}

.badge.stream-fd { background: #f2f4f7; color: #344054; border-color: #d0d5dd; }
.badge.stream-fb { background: #fffaeb; color: #b54708; border-color: #fedf89; }

.data-table tbody tr.row-escalated { box-shadow: inset 3px 0 0 var(--bad); }
.data-table tbody tr.row-frozen { opacity: 0.85; }

/* Checklist / Milestones */
.checklist-progress-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 14px;
}
.checklist-date { margin-left: auto; font-size: 11px; color: var(--text-muted); flex-shrink: 0; }

.milestone-template-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.playbook-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--info);
  text-decoration: none;
  margin-left: auto;
}
.playbook-link:hover { text-decoration: underline; }

.milestone-phase-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.milestone-phase-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 1px solid var(--border);
}

.milestone-phase-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.milestone-phase-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.milestone-phase-note {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--warn-bg);
  border-bottom: 1px solid var(--warn-border);
  font-size: 12px;
  font-weight: 500;
  color: var(--warn);
}
.note-icon { font-size: 14px; }

.milestone-task-list { padding: 4px 0; }

.milestone-task {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 13px;
  line-height: 1.45;
}
.milestone-task:last-child { border-bottom: none; }
.milestone-task:hover { background: #fafbfc; }
.milestone-task.done { background: var(--good-bg); }
.milestone-task.done .milestone-task-label {
  color: var(--text-muted);
}
.milestone-task input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
}
.milestone-task-label { flex: 1; }

/* Manager approval */
.approval-box {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}
.approval-title { font-weight: 600; color: var(--warn); margin-bottom: 6px; }
.approval-actions { display: flex; gap: 8px; margin-top: 10px; }

@media (max-width: 1100px) {
  .stat-grid-6 { grid-template-columns: repeat(3, 1fr); }
  .stat-grid-5 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 800px) {
  .stat-grid-6, .stat-grid-5 { grid-template-columns: repeat(2, 1fr); }
  .workload-row { grid-template-columns: 1fr; gap: 4px; }
}
