:root {
  --ink: #1a1d23;
  --ink-soft: #2d3340;
  --muted: #6b7280;
  --muted-2: #9ca3af;
  --line: #e8eaed;
  --line-soft: #f0f1f3;
  --bg: #f5f6f8;
  --card: #ffffff;
  --sidebar: #ffffff;
  --accent: #7a1f2b;
  --accent-hover: #651822;
  --accent-soft: #f6e8ea;
  --accent-mid: #c45a68;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --warn: #c2410c;
  --warn-soft: #ffedd5;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --blue: #1d4ed8;
  --blue-soft: #dbeafe;
  --purple: #6d28d9;
  --purple-soft: #ede9fe;
  --yellow-soft: #fef9c3;
  --yellow: #a16207;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 12px rgba(16, 24, 40, 0.04);
  --sidebar-w: 248px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
body.nav-open { overflow: hidden; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* —— Shell —— */
.app-shell {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 40;
}

/* —— Sidebar —— */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 1rem 0.85rem 1.25rem;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  z-index: 50;
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding: 0 0.35rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.05rem;
}
.brand:hover { text-decoration: none; color: var(--ink); }
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand-text { letter-spacing: -0.01em; }
.sidebar-close {
  display: none;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 8px;
}
.sidebar-close:hover { background: var(--line-soft); color: var(--ink); }
.sidebar-cta {
  width: 100%;
  text-align: center;
  margin-bottom: 1rem;
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  position: relative;
}
.nav-item svg { flex-shrink: 0; opacity: 0.85; }
.nav-item:hover {
  background: var(--bg);
  color: var(--ink);
  text-decoration: none;
}
.nav-item.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.nav-item.active svg { opacity: 1; }
.nav-item.active:hover { background: var(--accent-hover); color: #fff; }
.nav-badge {
  margin-left: auto;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nav-item.active .nav-badge {
  background: rgba(255,255,255,0.22);
  color: #fff;
}
.nav-chevron {
  margin-left: auto;
  font-size: 1.1rem;
  opacity: 0.9;
  line-height: 1;
}
.nav-item.active .nav-badge + .nav-chevron,
.nav-item .nav-badge ~ .nav-chevron { margin-left: 0.35rem; }
.sidebar-footnote {
  margin: 1rem 0.35rem 0;
  font-size: 0.72rem;
  color: var(--muted-2);
  line-height: 1.35;
}

/* —— Main —— */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.main-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem 1.75rem 0.75rem;
  flex-wrap: wrap;
}
.main-header-left {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  min-width: 0;
}
.hamburger {
  display: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 0.45rem;
  cursor: pointer;
  color: var(--ink);
  margin-top: 0.15rem;
}
.hamburger:hover { background: var(--bg); }
.welcome-title {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.2;
}
.welcome-sub {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}
.main-header-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}
.header-search {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  min-width: 200px;
}
.header-search .search-icon { color: var(--muted-2); flex-shrink: 0; }
.header-search input {
  border: none;
  outline: none;
  background: transparent;
  padding: 0.2rem 0;
  font: inherit;
  font-size: 0.88rem;
  width: 100%;
  min-width: 0;
}
.header-search .search-hint {
  font-size: 0.7rem;
  color: var(--muted-2);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.1rem 0.35rem;
  font-family: inherit;
}
.main-body {
  padding: 0.5rem 1.75rem 2.5rem;
  flex: 1;
}

/* —— Flash —— */
.flash { list-style: none; padding: 0; margin: 0 0 1rem; }
.flash li {
  padding: 0.7rem 0.95rem;
  border-radius: 10px;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  font-weight: 500;
}
.flash .ok { background: var(--ok-soft); color: var(--ok); }
.flash .error { background: var(--danger-soft); color: var(--danger); }

/* —— Cards & grid —— */
.grid { display: grid; gap: 0.9rem; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-2-wide { grid-template-columns: 1.35fr 1fr; }
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .grid-4, .grid-3, .grid-2, .grid-2-wide { grid-template-columns: 1fr; }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
}
.card h1, .card h2 { margin: 0 0 0.7rem; }
.card h1 { font-size: 1.25rem; font-weight: 750; letter-spacing: -0.015em; }
.card h2 { font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.card-header h1, .card-header h2 { margin: 0; }

/* —— KPI —— */
.kpi-stack {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.kpi-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line-soft);
}
.kpi-row:last-child { border-bottom: none; padding-bottom: 0.15rem; }
.kpi-row:first-child { padding-top: 0.15rem; }
.kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.kpi-icon.blue { background: var(--blue-soft); color: var(--blue); }
.kpi-icon.purple { background: var(--purple-soft); color: var(--purple); }
.kpi-icon.teal { background: #cffafe; color: #0e7490; }
.kpi-icon.green { background: var(--ok-soft); color: var(--ok); }
.kpi-icon.orange { background: var(--warn-soft); color: var(--warn); }
.kpi-icon.pink { background: var(--accent-soft); color: var(--accent); }
.kpi-icon.slate { background: #e2e8f0; color: #475569; }
.kpi-meta { flex: 1; min-width: 0; }
.kpi-meta .label {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
  margin: 0;
}
.kpi-meta .value {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0.1rem 0 0;
}
.kpi-meta .sub {
  font-size: 0.78rem;
  color: var(--muted-2);
  margin-top: 0.1rem;
}
.kpi-grid .card.kpi {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1.1rem;
}
.kpi-grid .kpi .label {
  font-size: 0.75rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
  font-weight: 500;
}
.kpi-grid .kpi .value {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.kpi-grid .kpi .sub { font-size: 0.78rem; color: var(--muted-2); }
.kpi .label { font-size: 0.75rem; color: var(--muted); font-weight: 500; }
.kpi .value { font-size: 1.5rem; font-weight: 800; color: var(--ink); letter-spacing: -0.02em; }
.kpi .sub { font-size: 0.8rem; color: var(--muted); }

/* —— Tables —— */
.table-card { padding: 0; overflow: hidden; }
.table-card .table-toolbar {
  padding: 0.95rem 1.15rem 0.65rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line-soft);
}
.table-tabs {
  display: flex;
  gap: 0.15rem;
  flex-wrap: wrap;
}
.table-tabs a, .table-tabs span {
  padding: 0.45rem 0.65rem;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.table-tabs a:hover { color: var(--ink); text-decoration: none; }
.table-tabs a.active, .table-tabs .active {
  color: var(--ink);
  font-weight: 650;
  border-bottom-color: var(--ink);
}
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th, td {
  text-align: left;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
th {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  background: #fafbfc;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafbfc; }
.cell-primary { font-weight: 600; color: var(--ink); }
.cell-primary a { color: var(--ink); font-weight: 600; }
.cell-primary a:hover { color: var(--accent); }
.cell-id { font-size: 0.75rem; color: var(--muted-2); margin-top: 0.15rem; }
.cell-strong { font-weight: 700; }

/* —— Status pills (pastel + dot) —— */
.badge, .status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: none;
  padding: 0.28rem 0.6rem 0.28rem 0.5rem;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  line-height: 1.2;
  white-space: nowrap;
}
.badge::before, .status-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  opacity: 0.95;
}
.badge.new { background: #f1f5f9; color: #475569; }
.badge.queued { background: #e0f2fe; color: #0369a1; }
.badge.approved { background: #ede9fe; color: #6d28d9; }
.badge.sent { background: var(--blue-soft); color: var(--blue); }
.badge.replied { background: #cffafe; color: #0e7490; }
.badge.call_booked { background: var(--ok-soft); color: var(--ok); }
.badge.won { background: var(--ok-soft); color: #166534; }
.badge.lost { background: var(--danger-soft); color: var(--danger); }
.badge.stop { background: #fecaca; color: #991b1b; }
.badge.high { background: var(--warn-soft); color: #9a3412; }
.badge.medium { background: var(--yellow-soft); color: var(--yellow); }
.badge.low { background: #f1f5f9; color: #64748b; }
.badge.slot { background: var(--purple-soft); color: var(--purple); }
.badge.note { background: var(--accent-soft); color: var(--accent); }
.badge.done { background: var(--ok-soft); color: var(--ok); }
.badge.open { background: var(--yellow-soft); color: var(--yellow); }

/* —— Buttons —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: none;
  border-radius: 999px;
  padding: 0.55rem 1rem;
  font-weight: 600;
  font-size: 0.875rem;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  background: var(--accent);
  color: #fff !important;
  line-height: 1.2;
  white-space: nowrap;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; filter: none; }
.btn-primary, .btn.btn-primary { background: var(--accent); color: #fff !important; }
.btn-outline, .btn.btn-outline {
  background: transparent;
  color: var(--accent) !important;
  border: 1.5px solid var(--accent);
}
.btn-outline:hover { background: var(--accent-soft); }
.btn.secondary {
  background: #fff;
  color: var(--ink) !important;
  border: 1px solid var(--line);
}
.btn.secondary:hover { background: var(--bg); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #991b1b; }
.btn.small { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

.row-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; }

/* —— Forms —— */
.filters { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.85rem; align-items: end; }
.filters > div { min-width: 7rem; }
label { display: block; font-size: 0.8rem; color: var(--muted); font-weight: 600; margin-bottom: 0.25rem; }
input, select, textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.form-grid .full { grid-column: 1 / -1; }
.muted { color: var(--muted); font-size: 0.9rem; }
.pre {
  white-space: pre-wrap;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem;
  font-size: 0.85rem;
}
.toolbar { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.85rem; align-items: center; }
.bulk-bar {
  background: #fafbfc;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
}
.check-all { margin: 0; display: flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; }
.check-all input { width: auto; }
.sep { border: none; border-top: 1px solid var(--line); margin: 1rem 0; }

.activity-feed { list-style: none; padding: 0; margin: 0; }
.activity-feed li {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.88rem;
}
.activity-feed li:last-child { border-bottom: none; }
.activity-feed li.overdue { background: #fff7f7; margin: 0 -0.5rem; padding-left: 0.5rem; padding-right: 0.5rem; border-radius: 8px; }

.progress {
  height: 8px;
  background: #e8eaed;
  border-radius: 999px;
  overflow: hidden;
  max-width: 280px;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-mid));
  border-radius: 999px;
  transition: width 0.2s ease;
}

.queue-item {
  margin-bottom: 0.75rem;
  background: #fafbfc;
  box-shadow: none;
}

/* —— Kanban (compact) —— */
.pipeline-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}
.kanban {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.75rem;
  align-items: flex-start;
}
.kanban-col {
  flex: 0 0 220px;
  width: 220px;
  background: #eef0f3;
  border-radius: var(--radius);
  padding: 0.5rem;
  min-height: 140px;
  max-height: calc(100vh - 210px);
  display: flex;
  flex-direction: column;
}
.kanban-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
  padding: 0.1rem 0.15rem;
  flex-shrink: 0;
}
.kanban-count {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  background: #fff;
  border-radius: 999px;
  min-width: 1.4rem;
  text-align: center;
  padding: 0.1rem 0.35rem;
}
.kanban-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-height: 0;
  flex: 1;
}
.kanban-card {
  position: relative;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.6rem 0.5rem;
  font-size: 0.82rem;
  box-shadow: none;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.kanban-card:hover {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  box-shadow: var(--shadow);
}
.kanban-title {
  display: block;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  line-height: 1.25;
  letter-spacing: -0.01em;
}
.kanban-title:hover { color: var(--accent); }
.kanban-meta {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kanban-footer {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.4rem;
  flex-wrap: wrap;
  min-height: 1.1rem;
}
.kanban-prob {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
  background: #f3f4f6;
  border-radius: 999px;
  padding: 0.08rem 0.4rem;
}
.kanban-chips { gap: 0.2rem; }
.kanban-chips .chip {
  font-size: 0.62rem;
  padding: 0.05rem 0.35rem;
}
.kanban-more {
  font-size: 0.65rem;
  color: var(--muted);
  font-weight: 650;
}
.kanban-card .pipeline-move {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  margin: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}
.kanban-card:hover .pipeline-move,
.kanban-card:focus-within .pipeline-move {
  opacity: 1;
  pointer-events: auto;
}
.kanban-card .pipeline-move select {
  margin: 0;
  font-size: 0.68rem;
  padding: 0.15rem 0.25rem;
  max-width: 7.2rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

code {
  background: #eef0f3;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85em;
}
.chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.chip {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 650;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--chip, var(--accent)) 16%, #fff);
  color: var(--chip, var(--accent));
  border: 1px solid color-mix(in srgb, var(--chip, var(--accent)) 30%, #fff);
  line-height: 1.3;
}
.chip-btn { cursor: pointer; font: inherit; }
.crm-side { display: grid; gap: 0.85rem; align-content: start; }
.task-list { list-style: none; padding: 0; margin: 0; }
.task-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: flex-start;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.88rem;
}
.task-list li.done { opacity: 0.65; }
.task-list li.overdue, .overdue-row { background: #fff7f7; }
.overdue-row td { background: #fff7f7; }
.overdue-val { color: var(--danger) !important; }
.timeline .timeline-head { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.timeline .timeline-body { margin-top: 0.25rem; white-space: pre-wrap; }
.timeline li.pinned {
  background: #fffbeb;
  margin: 0 -0.4rem;
  padding: 0.55rem 0.4rem;
  border-radius: 8px;
}
input[type="color"] { height: 2.3rem; padding: 0.15rem; }
input[type="checkbox"] { width: auto; }

.page-title {
  margin: 0 0 0.25rem;
  font-size: 1.25rem;
  font-weight: 750;
  letter-spacing: -0.015em;
}
.page-sub { margin: 0 0 1rem; color: var(--muted); font-size: 0.9rem; }

/* —— Mobile —— */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 8px 0 24px rgba(0,0,0,0.08);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay:not([hidden]) { display: block; }
  .sidebar-close { display: inline-flex; }
  .hamburger { display: inline-flex; }
  .main-header { padding: 1.1rem 1rem 0.5rem; }
  .main-body { padding: 0.35rem 1rem 2rem; }
  .welcome-title { font-size: 1.35rem; }
  .header-search { min-width: 140px; flex: 1; }
}
@media (max-width: 700px) {
  .task-list li { flex-direction: column; }
  .main-header-right { width: 100%; }
  .header-search { width: 100%; }
}

/* —— Brevo conversation thread —— */
.help-box {
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}
.help-box code { font-size: 0.85em; word-break: break-all; }
.msg-thread {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: 28rem;
  overflow-y: auto;
  padding: 0.15rem 0;
}
.msg-bubble {
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  background: #f8fafc;
}
.msg-bubble.out {
  background: var(--accent-soft);
  border-color: #e8c5cb;
  align-self: flex-end;
  width: 92%;
}
.msg-bubble.in {
  background: #fff;
  align-self: flex-start;
  width: 92%;
}
.msg-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
  align-items: center;
  margin-bottom: 0.35rem;
  font-size: 0.8rem;
}
.msg-subject { font-size: 0.85rem; color: var(--ink-soft); }
.msg-body {
  white-space: pre-wrap;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--ink);
}

/* —— Command centre / power features —— */
.command-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}
.command-stat .value {
  font-size: 1.75rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.command-snip { margin-top: 0.65rem; }
.snip-text {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}
.progress-bar.warn { background: var(--warn); }
.kpi-secondary {
  margin: 0.5rem 0 0;
  padding: 0.65rem 0.85rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.kpi-secondary summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink-soft);
  font-size: 0.9rem;
}
.digest-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.65rem;
}
.digest-grid-lg { grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); }
.digest-cell {
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
}
.digest-cell .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
}
.digest-cell .value {
  font-size: 1.45rem;
  font-weight: 750;
  margin-top: 0.2rem;
}
.digest-cell .sub { font-size: 0.75rem; color: var(--muted); margin-top: 0.15rem; }

/* Inbox */
.inbox-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.inbox-row {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0.9rem 1.15rem;
  border-top: 1px solid var(--line-soft);
}
.inbox-main { flex: 1; min-width: 0; }
.inbox-actions { flex-shrink: 0; }

/* Pitch pack */
.pitch-pack .pitch-dl {
  margin: 0 0 0.75rem;
  display: grid;
  gap: 0.45rem;
}
.pitch-pack .pitch-dl > div {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 0.35rem;
  font-size: 0.9rem;
}
.pitch-pack dt { color: var(--muted); font-weight: 600; margin: 0; }
.pitch-pack dd { margin: 0; word-break: break-word; }
.pitch-field input {
  border-color: #e8c5cb;
  background: #fffafb;
}
.pitch-actions { flex-wrap: wrap; }

/* Today focus + kbd */
.queue-item.queue-focused {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.queue-item:focus { outline: none; }
.kbd-hint { font-size: 0.8rem; margin: 0.65rem 0 0; }
kbd {
  display: inline-block;
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #fff;
  font-size: 0.75rem;
  font-family: var(--font);
  color: var(--ink-soft);
}
.kbd-help-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.kbd-help-modal[hidden] { display: none !important; }
.kbd-help-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  max-width: 22rem;
  width: 100%;
  box-shadow: var(--shadow);
}
.kbd-help-list {
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.4rem;
  font-size: 0.9rem;
}

@media (max-width: 900px) {
  .digest-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inbox-row {
    flex-direction: column;
    gap: 0.55rem;
  }
  .inbox-actions { width: 100%; }
  .inbox-actions .btn { flex: 1; }
  .crm-side .msg-thread { max-height: 18rem; }
  .reply-form textarea,
  .reply-form input,
  .reply-form .btn,
  .reply-form .row-actions { width: 100%; }
  .reply-form .row-actions { display: flex; }
  .reply-form .row-actions .btn { flex: 1; justify-content: center; }
  .pitch-pack .pitch-dl > div { grid-template-columns: 1fr; }
  .main-body { padding: 0.25rem 0.75rem 1.75rem; }
  .card { padding-left: 0.9rem; padding-right: 0.9rem; }
  .queue-item .toolbar { flex-direction: column; align-items: stretch; }
  .queue-item .row-actions { width: 100%; flex-wrap: wrap; }
  .queue-item .row-actions .btn { flex: 1 1 auto; }
  .command-cta-row .btn { flex: 1 1 auto; text-align: center; }
}

@media (max-width: 700px) {
  .grid-2-wide { grid-template-columns: 1fr; }
  .digest-grid { grid-template-columns: 1fr 1fr; }
  .pitch-actions { width: 100%; }
  .pitch-actions .btn { flex: 1; }
}

@media print {
  .sidebar, .main-header, .command-cta-row, .flash, .kbd-hint { display: none !important; }
  .main { margin: 0 !important; }
  .digest-page { box-shadow: none; border: 0; }
}


/* Today queue: keep subject separate from body preview */
.email-preview { display: flex; flex-direction: column; gap: 0.55rem; }
.email-preview-row { display: flex; flex-direction: column; gap: 0.25rem; }
.email-preview-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #7c6a72;
}
.email-preview-subject {
  white-space: pre-wrap;
  font-weight: 650;
  color: #3b1f2b;
  padding: 0.75rem;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.35;
}
.email-preview-body { margin: 0; }
