/* ============================================================
   SimpleCRM — design system
   ============================================================ */

:root {
  /* Color */
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-hover: #f9fafb;
  --border: #e6e9ef;
  --border-strong: #d6dae2;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --primary-border: #c7d2fe;

  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-soft: #fef2f2;
  --danger-border: #fecaca;

  --success: #16a34a;
  --success-soft: #ecfdf5;
  --success-border: #a7f3d0;

  --warning: #b45309;
  --warning-soft: #fffbeb;
  --warning-border: #fde68a;

  /* Shape */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.07), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 20px -4px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.06);

  /* Motion */
  --fast: 120ms ease;
  --normal: 180ms ease;
}

* { box-sizing: border-box; }

html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Top nav ─────────────────────────────────────────────── */
header.topnav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1.75rem;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
header.topnav .brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--text);
  flex-shrink: 0;
}
header.topnav .brand::before {
  content: '';
  width: 22px;
  height: 22px;
  border-radius: 7px;
  display: inline-block;
  background: linear-gradient(135deg, var(--primary), #818cf8);
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.4);
}
header.topnav nav {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}
header.topnav nav a {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  transition: background var(--fast), color var(--fast);
  white-space: nowrap;
}
header.topnav nav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
header.topnav nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
header.topnav .nav-user {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding-right: 0.25rem;
  white-space: nowrap;
}
header.topnav nav .nav-disabled {
  display: inline-block;
  color: var(--text-faint);
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.4rem 0.7rem;
  cursor: default;
  white-space: nowrap;
}

header.topnav .nav-right { display: flex; align-items: center; gap: 0.4rem; margin-left: auto; flex-shrink: 0; }

/* ── Global item search (SimpleCRM nav-search pattern) ──────── */
.nav-search { position: relative; }
.nav-search input[type="search"] {
  width: 200px; padding: 0.4rem 0.7rem; font-size: 0.85rem;
  border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface);
  transition: width var(--fast);
}
.nav-search input[type="search"]:focus { width: 260px; }
.nav-search-results {
  display: none; position: absolute; left: 0; top: calc(100% + 6px);
  min-width: 300px; max-width: 380px; max-height: 420px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); padding: 0.35rem; z-index: 50;
}
.nav-search-results.open { display: block; }
.nav-search-row {
  display: flex; flex-direction: column; padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm); color: var(--text); cursor: pointer;
}
.nav-search-row:hover, .nav-search-row.active { background: var(--bg); text-decoration: none; }
.nav-search-label { font-size: 0.875rem; font-weight: 600; font-family: monospace; }
.nav-search-sub { font-size: 0.78rem; color: var(--text-muted); }
.nav-search-empty { padding: 0.6rem; font-size: 0.85rem; color: var(--text-muted); }

/* ── Right-side dropdowns (Views / user-profile / hamburger) ── */
.nav-dropdown { position: relative; }
.nav-dropdown-toggle {
  display: flex; align-items: center; gap: 0.3rem;
  background: none; border: none; cursor: pointer; box-shadow: none;
  color: var(--text-muted); font: inherit; font-weight: 500; font-size: 0.875rem;
  padding: 0.4rem 0.7rem; border-radius: 999px;
  transition: background var(--fast), color var(--fast);
}
.nav-dropdown-toggle:hover { background: var(--bg); color: var(--text); }
.nav-dropdown-toggle .caret { font-size: 0.65em; opacity: 0.7; }
.nav-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary), #818cf8);
  color: #fff; font-size: 0.8rem; font-weight: 700; flex-shrink: 0;
}
.nav-dropdown-menu {
  display: none;
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 190px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  padding: 0.35rem; z-index: 50;
}
.nav-dropdown.open .nav-dropdown-menu { display: block; }
.nav-dropdown-menu a, .nav-dropdown-menu button {
  display: block; width: 100%; text-align: left;
  padding: 0.45rem 0.7rem; border-radius: var(--radius-sm);
  color: var(--text); font-size: 0.875rem; font-weight: 500;
  background: none; border: none; font-family: inherit; cursor: pointer; box-shadow: none;
}
.nav-dropdown-menu a:hover, .nav-dropdown-menu button:hover { background: var(--bg); text-decoration: none; }
.nav-dropdown-menu a.active { background: var(--primary-soft); color: var(--primary); }
.nav-dropdown-menu hr { border: none; border-top: 1px solid var(--border); margin: 0.3rem 0.2rem; }
.nav-dropdown-user-label { padding: 0.3rem 0.7rem 0.5rem; color: var(--text-muted); font-size: 0.78rem; }

/* ── Tablet/narrow desktop (≤1200px): hamburger nav ──────────
   Same threshold SimpleCRM uses — the pillar nav (7 links) + search +
   avatar needs real room; below it, collapse to one hamburger menu
   instead of wrapping link-by-link. */
.nav-hamburger { display: none; }
@media (max-width: 1200px) {
  header.topnav { gap: 0.5rem; padding: 0.6rem 0.9rem; }
  header.topnav nav { display: none; }
  .nav-hamburger { display: block; }
  .nav-hamburger .nav-dropdown-toggle {
    width: 40px; height: 40px; padding: 0; justify-content: center; font-size: 1.15rem;
  }
  header.topnav .nav-right { gap: 0.15rem; }
  .nav-search { flex: 1 1 auto; min-width: 0; }
  .nav-search input[type="search"] { width: 100%; }
  .nav-search input[type="search"]:focus { width: 100%; }
  .nav-search-results.open {
    position: fixed; left: 0.75rem; right: 0.75rem; top: 60px;
    width: auto; max-width: none; min-width: 0;
  }
}
@media (max-width: 700px) {
  header.topnav { flex-wrap: wrap; row-gap: 0.5rem; }
}

main {
  max-width: 1160px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 3rem;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0.25rem 0 1.25rem;
  color: var(--text);
}
h2 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 1.75rem 0 1rem;
  color: var(--text);
}

/* ── Cards / panels ──────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

/* ── Forms ───────────────────────────────────────────────── */
form.inline-form { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field label { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); }

/* ── Two-column activity form (company detail) ──────────────*/
form.activity-form { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.activity-form-col { display: flex; flex-direction: column; gap: 0.75rem; }
.activity-form-actions { grid-column: 1 / -1; }
@media (max-width: 700px) {
  form.activity-form { grid-template-columns: 1fr; }
}

/* ── Read-only detail grid (profile / tenant info) ──────────*/
.detail-grid { display: flex; flex-wrap: wrap; gap: 1.25rem 2rem; margin: 0.75rem 0; }
.detail-grid .field { min-width: 11rem; }
.detail-grid .field > div { font-size: 0.9rem; }

input, select, textarea {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  min-width: 10rem;
  transition: border-color var(--fast), box-shadow var(--fast);
}
input:hover, select:hover, textarea:hover { border-color: var(--text-faint); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
textarea { min-height: 4rem; }
::placeholder { color: var(--text-faint); }

/* ── Buttons ─────────────────────────────────────────────── */
button, .btn {
  font: inherit;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.55rem 1.05rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.25);
  transition: background var(--fast), box-shadow var(--fast), transform var(--fast), border-color var(--fast);
}
button:hover, .btn:hover { background: var(--primary-hover); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

button.secondary, .btn.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: none;
}
button.secondary:hover, .btn.secondary:hover { background: var(--bg); border-color: var(--text-faint); }

button.danger, .btn.danger {
  background: var(--surface);
  color: var(--danger);
  border: 1px solid var(--danger-border);
  box-shadow: none;
}
button.danger:hover, .btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.error { color: var(--danger); margin: 0.5rem 0; font-size: 0.875rem; font-weight: 500; }
.hint { color: var(--text-muted); font-size: 0.85rem; }

/* ── Tables ──────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  text-transform: uppercase;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0 0.6rem 0.65rem;
  border-bottom: 1px solid var(--border);
}
td {
  text-align: left;
  padding: 0.7rem 0.6rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.885rem;
}
tbody tr { transition: background var(--fast); }
tbody tr:hover { background: var(--surface-hover); }
tr:last-child td { border-bottom: none; }

.truncate-cell {
  display: inline-block;
  max-width: 220px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

/* ── Kanban deals board ──────────────────────────────────── */
.board { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: 0.75rem; }
.board-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  min-width: 230px;
  flex: 1 1 230px;
  padding: 0.9rem;
  box-shadow: var(--shadow-sm);
}
.board-col h3 {
  margin: 0 0 0.75rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.deal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin-bottom: 0.65rem;
  font-size: 0.88rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--normal), transform var(--normal), border-color var(--normal);
}
.deal-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); border-color: var(--border-strong); }
.deal-card .value { color: var(--success); font-weight: 700; }
.deal-card select { width: 100%; margin-top: 0.5rem; min-width: 0; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}
.badge-meeting { background: var(--primary-soft); border-color: var(--primary-border); color: var(--primary); }
.badge-action_item { background: var(--warning-soft); border-color: var(--warning-border); color: var(--warning); }
.badge-lesson_learned { background: var(--success-soft); border-color: var(--success-border); color: var(--success); }
.badge-completed { background: var(--success-soft); border-color: var(--success-border); color: var(--success); }
.badge-ai-sourced { background: var(--warning-soft); border-color: var(--warning-border); color: var(--warning); }

/* ── Row actions / inline edit ──────────────────────────────*/
.row-actions { display: flex; gap: 0.4rem; }
.row-actions button { padding: 0.4rem 0.75rem; font-size: 0.8rem; }
td input, td select { width: 100%; min-width: 8rem; }

/* ── Search box ──────────────────────────────────────────── */
.search-box { margin-bottom: 1rem; }
.search-box input { width: 100%; max-width: 340px; }

/* ── Notes ───────────────────────────────────────────────── */
.notes-panel {
  margin-top: 0.65rem;
  padding: 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.note { padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.note:last-of-type { border-bottom: none; }
.note-meta { font-size: 0.78rem; color: var(--text-muted); display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.note-meta button { padding: 0.15rem 0.5rem; font-size: 0.72rem; margin-left: auto; }
.note-body { font-size: 0.9rem; margin-top: 0.3rem; white-space: pre-wrap; color: var(--text); }
.note-form { display: flex; gap: 0.5rem; margin-top: 0.65rem; align-items: flex-start; flex-wrap: wrap; }
.note-form textarea { flex: 1; min-height: 2.4rem; min-width: 12rem; }
.note-form select { min-width: 9rem; }
.note-form input[type="date"] { min-width: 9rem; }
.note-form input[type="text"] { min-width: 9rem; }

/* ── Dashboard stat tiles ────────────────────────────────── */
.stats-grid { display: flex; flex-wrap: wrap; gap: 1rem; }
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.3rem;
  min-width: 150px;
  flex: 1 1 150px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--normal), transform var(--normal), border-color var(--normal);
}
.stat-tile .stat-value { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.stat-tile .stat-label { color: var(--text-muted); font-size: 0.82rem; font-weight: 500; margin-top: 0.25rem; }
a.stat-tile { display: block; color: inherit; text-decoration: none; }
a.stat-tile:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-2px); text-decoration: none; }
.stage-breakdown { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.85rem; }

/* ── CRM Agent chat ──────────────────────────────────────── */
.chat-window {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  min-height: 16rem;
  max-height: 32rem;
  overflow-y: auto;
  padding: 0.25rem 0.25rem 0.5rem;
}
.chat-message { max-width: 80%; }
.chat-message.chat-user { align-self: flex-end; }
.chat-message.chat-assistant { align-self: flex-start; }
.chat-role { font-size: 0.72rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.2rem; }
.chat-message.chat-user .chat-role { text-align: right; }
.chat-bubble { border-radius: var(--radius); padding: 0.6rem 0.85rem; font-size: 0.9rem; white-space: pre-wrap; }
.chat-user .chat-bubble { background: var(--primary); color: #fff; }
.chat-assistant .chat-bubble { background: var(--bg); border: 1px solid var(--border); color: var(--text); }
.chat-form { display: flex; gap: 0.6rem; margin-top: 1rem; align-items: flex-end; }
.chat-form textarea { flex: 1; min-height: 2.6rem; resize: vertical; }
.budget-bar { height: 6px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); overflow: hidden; margin-top: 0.4rem; }
.budget-bar-fill { height: 100%; background: var(--primary); transition: width var(--normal); }
.budget-bar-fill.budget-full { background: var(--danger); }

/* ── Item Workspace (Checkpoint H1) ─────────────────────────
   Pillar accents — distinct from the semantic colors above,
   used only to tint which of PLAN/SOURCE/STOCK/FULFILL a
   canonical journey stage belongs to. */
:root {
  --plan: #4f46e5;    --plan-soft: #eef2ff;
  --source: #ea580c;  --source-soft: #fff7ed;
  --stock: #0d9488;   --stock-soft: #f0fdfa;
  --fulfill: #9333ea; --fulfill-soft: #faf5ff;
}

.item-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.item-header h1 { margin: 0 0 0.15rem; font-size: 1.3rem; }
.item-identity { font-family: monospace; font-size: 0.8rem; color: var(--text-faint); }

.tabstrip { display: flex; gap: 0.15rem; border-bottom: 2px solid var(--border); margin: 1rem 0 1.25rem; flex-wrap: wrap; }
.tabstrip a, .tabstrip span {
  padding: 0.55rem 0.85rem; font-weight: 600; font-size: 0.88rem; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.tabstrip a.active { color: var(--primary); border-color: var(--primary); }
.tabstrip a:hover { color: var(--text); text-decoration: none; }
.tabstrip span.tab-disabled { color: var(--text-faint); cursor: default; }

.journey-compact { display: flex; align-items: center; gap: 0; flex-wrap: wrap; font-family: monospace; font-size: 0.68rem; margin: 0.4rem 0 1rem; }
.journey-compact .node {
  border: 1px solid var(--border); border-radius: 4px; padding: 0.1rem 0.4rem; font-weight: 600;
  white-space: nowrap; background: var(--surface); color: var(--text-faint);
}
.journey-compact .node.reached { color: #fff; border-color: transparent; }
.journey-compact .node.reached.jp-plan { background: var(--plan); }
.journey-compact .node.reached.jp-source { background: var(--source); }
.journey-compact .node.reached.jp-stock { background: var(--stock); }
.journey-compact .node.reached.jp-fulfill { background: var(--fulfill); }
.journey-compact .arrow { color: var(--text-faint); padding: 0 0.1rem; font-size: 0.6rem; }

.op-line { font-size: 0.95rem; color: var(--text); margin: 0.25rem 0; }
.op-line b { font-variant-numeric: tabular-nums; }
.op-sep { color: var(--text-faint); margin: 0 0.45rem; }
.op-ok { color: var(--success); font-weight: 600; }
.op-warn { color: var(--warning); font-weight: 700; }

.next-action {
  display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.78rem; font-weight: 700;
  padding: 0.25rem 0.65rem; border-radius: 999px; background: var(--primary-soft);
  border: 1px solid var(--primary-border); color: var(--primary); white-space: nowrap;
}

.empty-state { border: 1.5px dashed var(--border-strong); border-radius: var(--radius); padding: 1.25rem 1.1rem; text-align: center; background: var(--bg); }
.empty-state p { margin: 0 0 0.6rem; font-size: 0.85rem; color: var(--text-muted); }
.budget-bar-fill.budget-full { background: var(--danger); }

/* ── Compact inline empty state (a single plain sentence, no box) ──
   SimpleCRM's .workspace-empty pattern — absence gets no space. */
.line-empty { color: var(--text-muted); font-size: 0.88rem; margin: 0; }

/* ── Dashboard: Needs Attention worklist (SimpleCRM Sales Command
   Center pattern) — compact clickable rows, not KPI tiles. ────── */
.attention-row {
  display: flex; align-items: baseline; gap: 0.4rem;
  padding: 0.55rem 0; border-bottom: 1px solid var(--border); color: inherit;
}
.attention-row:last-child { border-bottom: none; }
a.attention-row:hover { color: var(--primary); text-decoration: none; }
.attention-row .attention-count { font-weight: 700; font-size: 1rem; min-width: 1.4rem; }
.attention-row .p-tag { margin-right: 0.3rem; }
.dashboard-summary-line { font-size: 0.95rem; color: var(--text); margin: -0.4rem 0 1rem; }
.dashboard-summary-line strong { font-weight: 700; }
.dashboard-summary-line .sep { color: var(--text-faint); margin: 0 0.5rem; }

/* ── Pillar tag (compact context label, e.g. on a dashboard row) ── */
.p-tag {
  display: inline-flex; align-items: center; font-family: monospace; font-size: 0.62rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em; padding: 0.1rem 0.4rem; border-radius: 4px; border: 1px solid;
}
.p-tag.p-plan { background: var(--plan-soft, var(--primary-soft)); border-color: var(--plan-border, var(--primary-border)); color: var(--plan, var(--primary)); }
.p-tag.p-source { background: var(--source-soft); border-color: var(--source-border); color: var(--source); }
.p-tag.p-stock { background: var(--stock-soft); border-color: var(--stock-border); color: var(--stock); }
.p-tag.p-fulfill { background: var(--fulfill-soft); border-color: var(--fulfill-border); color: var(--fulfill); }

/* ── Fact strip: compact labeled facts inline (Item Workspace header) ── */
.fact-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0; margin: 0.35rem 0 0; }
.fact-strip .fact { display: flex; align-items: center; gap: 0.4rem; padding: 0 0.85rem; font-size: 0.82rem; color: var(--text-muted); }
.fact-strip .fact:first-child { padding-left: 0; }
.fact-strip .fact + .fact { border-left: 1px solid var(--border-strong); }

/* ── Workspace section: heading -> content -> divider, not another
   elevated card (SimpleCRM's Company Workspace pattern). ──────── */
.workspace-section { border-top: 1px solid var(--border); margin-top: 1rem; padding-top: 0.9rem; min-width: 0; }
.workspace-section.workspace-section-first { border-top: none; margin-top: 0; padding-top: 0; }
.workspace-section > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 0.6rem; padding: 0 0 0.5rem;
}
.workspace-section > summary::-webkit-details-marker { display: none; }
.workspace-section > summary .chevron { color: var(--text-muted); font-size: 0.75rem; transition: transform var(--fast); flex-shrink: 0; }
.workspace-section[open] > summary .chevron { transform: rotate(90deg); }
.workspace-section > summary h2 { margin: 0; font-size: 1rem; }
.workspace-section > summary .secondary { margin-left: auto; padding: 0.3rem 0.65rem; font-size: 0.78rem; }
.workspace-section > .details-body { padding: 0; }
.section-count { font-weight: 500; color: var(--text-muted); font-size: 0.85em; margin-left: 0.15rem; }

/* ── Item Workspace two-column layout (main + reference rail) ─── */
.item-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.5rem; align-items: start; margin-top: 1rem; }
.item-main, .item-side { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.item-side { border-left: 1px solid var(--border); padding-left: 1.5rem; }
@media (max-width: 900px) {
  .item-grid { grid-template-columns: 1fr; }
  .item-side { border-left: none; padding-left: 0; }
}
.side-section-heading { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.6rem; }
.side-section-heading h2 { margin: 0; font-size: 0.92rem; font-weight: 600; color: var(--text); }
.side-section + .side-section { margin-top: 1.1rem; padding-top: 1.1rem; border-top: 1px solid var(--border); }

/* ── Peer-row list (Sources, Stock-by-location, etc.) — a working
   surface, not a database grid: one obvious action visible per row. ── */
.peer-row {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.55rem 0; border-top: 1px solid var(--border); flex-wrap: wrap;
}
.peer-row:first-child { border-top: none; padding-top: 0; }
.peer-row-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; font-size: 0.88rem; }
.peer-row-main .name { font-weight: 600; }
.peer-row-main .meta { color: var(--text-muted); font-size: 0.82rem; }
.peer-row-actions { flex-shrink: 0; display: flex; gap: 0.4rem; align-items: center; }
.peer-row-actions .secondary { padding: 0.3rem 0.65rem; font-size: 0.78rem; }
