/* ============================================
   RCAJO App — Domain-Specific Styles
   Built on design-kit (Swiss Rationalist).
   Only RCAJO tokens, components, and overrides here.
   Generic UI handled by /design-kit/index.css.
   ============================================ */

/* ── RCAJO Domain Tokens ── */
:root {
  /* Shadows (design-kit is flat — RCAJO keeps subtle depth for tooltips/modals) */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.04);
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.12);

  /* Resource Types */
  --color-human: #7c5cbf;
  --color-organisational: #2e8b8b;
  --color-tangible: #b87333;
  --color-intangible: #c05580;

  --color-human-dim: #f1edf9;
  --color-organisational-dim: #e4f3f3;
  --color-tangible-dim: #faf0e6;
  --color-intangible-dim: #faeef3;

  /* Consensus palette */
  --cons-all: #3b3494;
  --cons-most: #5950b3;
  --cons-some: #7e78cc;
  --cons-few: #a8a3dd;
  --cons-one: #ccc9ec;
}

[data-theme="dark"] {
  --color-human: #a590d8;
  --color-human-dim: #201a2e;
  --color-organisational: #4eb8b8;
  --color-organisational-dim: #142626;
  --color-tangible: #d4944e;
  --color-tangible-dim: #261c10;
  --color-intangible: #d87aa0;
  --color-intangible-dim: #261420;

  --cons-all: #6a60d0;
  --cons-most: #8078d8;
  --cons-some: #9a92e0;
  --cons-few: #b4aee8;
  --cons-one: #cec9f0;
}

/* ============================================
   NAV — Locked tab states & hover effects
   ============================================ */

/* Regular users: locked tabs are greyed out and not clickable */
.nav-link--locked {
  opacity: 0.35;
  pointer-events: none;
  cursor: default;
}

/* Admins: locked-for-users tabs appear dimmed but remain clickable */
.nav-link--dimmed {
  opacity: 0.45;
}

.nav-link--dimmed:hover {
  opacity: 0.7;
}

.nav-link--dimmed.active {
  opacity: 0.7;
}

/* ============================================
   TYPE-SPECIFIC CHIPS (filter pills with color)
   ============================================ */

.chip.type-human.active { background: var(--color-human); border-color: var(--color-human); color: white; }
.chip.type-org.active { background: var(--color-organisational); border-color: var(--color-organisational); color: white; }
.chip.type-tangible.active { background: var(--color-tangible); border-color: var(--color-tangible); color: white; }
.chip.type-intangible.active { background: var(--color-intangible); border-color: var(--color-intangible); color: white; }

[data-theme="dark"] .chip.type-human.active { background: var(--color-human); color: white; }
[data-theme="dark"] .chip.type-org.active { background: var(--color-organisational); color: white; }
[data-theme="dark"] .chip.type-tangible.active { background: var(--color-tangible); color: white; }
[data-theme="dark"] .chip.type-intangible.active { background: var(--color-intangible); color: white; }

/* ============================================
   RESOURCE TYPE BADGES
   ============================================ */

.badge-human { color: var(--color-human); }
.badge-organisational { color: var(--color-organisational); }
.badge-tangible { color: var(--color-tangible); }
.badge-intangible { color: var(--color-intangible); }

/* Domain badges */
.badge-domain-participant { color: var(--ok); }
.badge-domain-mandant { color: #3b6fcf; }
.badge-domain-animateur { color: var(--color-human); }
.badge-domain-organisation { color: var(--color-tangible); }
.badge-domain-external { color: #1a9a8a; }

/* Nature badges */
.badge-nature-assess { color: #5558d4; }
.badge-nature-decide { color: var(--color-human); }
.badge-nature-deliver { color: var(--ok); }
.badge-nature-communicate { color: var(--warn); }
.badge-nature-relate { color: var(--color-intangible); }
.badge-nature-improve { color: var(--color-organisational); }

[data-theme="dark"] .badge-domain-participant { color: #5cc08e; }
[data-theme="dark"] .badge-domain-mandant { color: #6898e0; }
[data-theme="dark"] .badge-domain-animateur { color: #a590d8; }
[data-theme="dark"] .badge-domain-organisation { color: #d4944e; }
[data-theme="dark"] .badge-domain-external { color: #4eb8b8; }

[data-theme="dark"] .badge-nature-assess { color: #7878e0; }
[data-theme="dark"] .badge-nature-decide { color: #a590d8; }
[data-theme="dark"] .badge-nature-deliver { color: #5cc08e; }
[data-theme="dark"] .badge-nature-communicate { color: #e8a545; }
[data-theme="dark"] .badge-nature-relate { color: #d87aa0; }
[data-theme="dark"] .badge-nature-improve { color: #4eb8b8; }

/* ============================================
   USER INITIALS
   ============================================ */

.user-initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--r-full);
  background: var(--accent-dim);
  color: var(--accent);
  font-size: var(--t-12);
  font-weight: 700;
}

.user-initials-sm {
  width: 20px;
  height: 20px;
  font-size: 11px;
}

/* ============================================
   SIDEBAR CAPABILITY LIST (Linking, MaturityScoring, etc.)
   ============================================ */

.cap-domain { margin-bottom: var(--s8); }

.cap-domain-label {
  padding: var(--s4) var(--s12);
  font-size: var(--t-10);
  font-weight: 500;
  color: var(--ink-3);
  letter-spacing: 0.02em;
}

.cap-item {
  display: flex;
  align-items: center;
  padding: var(--s8) var(--s12);
  border-radius: var(--r1);
  cursor: pointer;
  transition: background var(--dt-fast);
  gap: var(--s8);
}
.cap-item:hover { background: var(--bg-inset); }
.cap-item.selected,
.cap-item.active { background: var(--accent-dim); }
.cap-item.selected .cap-item-title,
.cap-item.active .cap-item-title {
  color: var(--accent);
  font-weight: 600;
}

.cap-item-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--r-full);
  flex-shrink: 0;
  background: var(--line);
}
.cap-item-dot.done,
.cap-item-dot.complete { background: var(--ok); }
.cap-item-dot.partial { background: var(--warn); }
.cap-item-dot.pending { background: var(--err); }

.cap-item-title {
  font-size: var(--t-13);
  color: var(--ink-1);
  line-height: 1.35;
  flex: 1;
  min-width: 0;
}

.cap-item-count {
  margin-left: auto;
  font-size: var(--t-11);
  font-family: var(--font-mono);
  color: var(--ink-3);
  font-weight: 500;
  flex-shrink: 0;
}

/* ============================================
   APP-SPECIFIC: Domain → category colour mapping
   Uses design-kit .meta-tag--cat-N system.
   ============================================ */

/* Participant=1, Mandant=2, Animateur=3, Organisation=4, External=5 */

/* ============================================
   MATRIX GRID — App Overrides
   Component styles live in design-kit/components/matrix-grid.css.
   Only RCAJO-specific concerns are here.
   ============================================ */

/* Panning gesture (V+drag on qualification pages) */
.matrix-grid-container.panning-ready {
  cursor: grab;
  user-select: none;
}
.matrix-grid-container.panning-ready:active {
  cursor: grabbing;
}
.matrix-grid-container.panning-ready * {
  pointer-events: none !important;
}

/* Color-coded column headers for resource type columns */
.matrix-grid-col.human-header    { color: var(--color-human); }
.matrix-grid-col.org-header      { color: var(--color-organisational); }
.matrix-grid-col.tangible-header { color: var(--color-tangible); }
.matrix-grid-col.intangible-header { color: var(--color-intangible); }

/* ============================================
   RESOURCE CARD
   ============================================ */

.resource-card {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--r2);
  padding: var(--s8) var(--s12);
  cursor: pointer;
  transition: all var(--dt-mid) var(--ease);
  position: relative;
  min-height: 52px;
  height: auto;
  width: 170px;
  min-width: 170px;
  flex: 0 0 170px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.resource-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.04);
}

.resource-card.selected { border-width: 2px; }
.resource-card.selected-human { border-color: var(--color-human); background: var(--color-human-dim); }
.resource-card.selected-organisational { border-color: var(--color-organisational); background: var(--color-organisational-dim); }
.resource-card.selected-tangible { border-color: var(--color-tangible); background: var(--color-tangible-dim); }
.resource-card.selected-intangible { border-color: var(--color-intangible); background: var(--color-intangible-dim); }

.resource-card-title {
  font-size: var(--t-13);
  font-weight: 600;
  line-height: 1.3;
  padding: 0 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.link-qual-page .resource-card-title { font-size: var(--t-13); font-weight: 600; }

.resource-card-info {
  position: absolute;
  bottom: 3px;
  right: 3px;
  background: var(--bg-inset);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  width: 20px;
  height: 20px;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
  transition: all var(--dt-fast);
  font-weight: 700;
  opacity: 0;
}
.resource-card:hover .resource-card-info { opacity: 1; }
.resource-card-info:hover { background: var(--accent); border-color: var(--accent); color: white; }

.resource-card-notes {
  position: absolute;
  bottom: 3px;
  left: 3px;
  background: var(--bg-inset);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  width: 20px;
  height: 20px;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
  transition: all var(--dt-fast);
  opacity: 0;
  line-height: 1;
}
.resource-card:hover .resource-card-notes { opacity: 1; }
.resource-card-notes.has-notes { opacity: 1; color: var(--accent); border-color: var(--accent-mid); }
.resource-card-notes:hover { background: var(--accent); border-color: var(--accent); color: white; }

.resource-card-contributors {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  font-size: 10px;
  font-weight: 500;
  font-family: var(--font-mono);
  color: var(--ink-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: var(--bg-inset);
  padding: 2px 6px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.resource-card.aggregate-view { cursor: default; padding-bottom: 24px; }
.resource-card.aggregate-view:hover { border-color: var(--line); }

.refinement-editor-textarea { min-height: 160px; resize: vertical; }

/* ============================================
   INFO TOOLTIP
   ============================================ */

.info-tooltip-overlay { position: fixed; inset: 0; z-index: 100; }

.info-tooltip {
  position: fixed;
  z-index: 101;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r2);
  box-shadow: 0 8px 30px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.05);
  padding: var(--s16);
  max-width: 300px;
  font-size: var(--t-13);
}

.info-tooltip-title { font-weight: 700; margin-bottom: var(--s8); font-size: var(--t-13); }
.info-tooltip-description { color: var(--ink-2); line-height: 1.4; }

/* ============================================
   RATING CARDS (Phase C — Criticality)
   ============================================ */

.rating-card-enhanced {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r2);
  padding: var(--s16);
  margin-bottom: var(--s12);
}

.rating-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--s16);
  margin-bottom: var(--s16);
  padding-bottom: var(--s16);
  border-bottom: 1px solid var(--line);
}

.rating-card-title { font-size: var(--t-15); font-weight: 700; margin: 0 0 var(--s4) 0; }
.rating-card-description { font-size: var(--t-13); color: var(--ink-2); line-height: 1.5; margin: 0; }
.rating-card-meta { display: flex; align-items: center; gap: var(--s8); font-size: var(--t-11); color: var(--ink-2); white-space: nowrap; }
.rating-section-label { font-size: var(--t-13); font-weight: 700; color: var(--ink-1); }
.rating-section-hint { font-size: var(--t-11); color: var(--ink-3); }

.rating-options-row { display: flex; gap: var(--s8); overflow: visible; }

.rating-option-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--s12) var(--s8);
  background: var(--bg);
  border: 1px solid transparent;
  border-radius: var(--r1);
  cursor: pointer;
  transition: all 0.1s;
  min-width: 0;
  position: relative;
  overflow: visible;
}
.rating-option-btn:hover { border-color: var(--line); }
.rating-option-btn.selected { background: var(--accent-dim); border-color: var(--accent); }

.rating-option-value { font-size: var(--t-15); font-weight: 700; color: var(--ink-1); }
.rating-option-btn.selected .rating-option-value { color: var(--accent); }
.rating-option-label { font-size: 11px; color: var(--ink-2); text-align: center; line-height: 1.2; }
.rating-option-btn.selected .rating-option-label { color: var(--accent); font-weight: 700; }

/* Criticality color gradient */
.rating-option-btn.criticality-0.selected { background: #f0f9f4; border-color: #34c759; }
.rating-option-btn.criticality-0.selected .rating-option-value,
.rating-option-btn.criticality-0.selected .rating-option-label { color: #2da44e; }
.rating-option-btn.criticality-1.selected { background: #fdf8ef; border-color: #e0a500; }
.rating-option-btn.criticality-1.selected .rating-option-value,
.rating-option-btn.criticality-1.selected .rating-option-label { color: #b88600; }
.rating-option-btn.criticality-2.selected { background: #fdf4ed; border-color: #d07020; }
.rating-option-btn.criticality-2.selected .rating-option-value,
.rating-option-btn.criticality-2.selected .rating-option-label { color: #b05a10; }
.rating-option-btn.criticality-3.selected { background: #fdf0f0; border-color: #d63031; }
.rating-option-btn.criticality-3.selected .rating-option-value,
.rating-option-btn.criticality-3.selected .rating-option-label { color: #b82020; }
.rating-option-btn.criticality-4.selected { background: #faeef4; border-color: #b84a7a; }
.rating-option-btn.criticality-4.selected .rating-option-value,
.rating-option-btn.criticality-4.selected .rating-option-label { color: #a03a6a; }

/* Maturity */
.rating-option-btn.maturity-1.selected { background: #fdf0f0; border-color: #d63031; }
.rating-option-btn.maturity-1.selected .rating-option-value,
.rating-option-btn.maturity-1.selected .rating-option-label { color: #b82020; }
.rating-option-btn.maturity-2.selected { background: #fdf4ed; border-color: #d07020; }
.rating-option-btn.maturity-2.selected .rating-option-value,
.rating-option-btn.maturity-2.selected .rating-option-label { color: #b05a10; }
.rating-option-btn.maturity-3.selected { background: #fdf8ef; border-color: #e0a500; }
.rating-option-btn.maturity-3.selected .rating-option-value,
.rating-option-btn.maturity-3.selected .rating-option-label { color: #b88600; }
.rating-option-btn.maturity-4.selected { background: #f0f9f4; border-color: #34c759; }
.rating-option-btn.maturity-4.selected .rating-option-value,
.rating-option-btn.maturity-4.selected .rating-option-label { color: #2da44e; }
.rating-option-btn.maturity-5.selected { background: #edf8f2; border-color: #28a745; }
.rating-option-btn.maturity-5.selected .rating-option-value,
.rating-option-btn.maturity-5.selected .rating-option-label { color: #1e8a3a; }

/* VRIO */
.rating-option-btn.vrio-0.selected { background: #fdf0f0; border-color: #d63031; }
.rating-option-btn.vrio-0.selected .rating-option-value,
.rating-option-btn.vrio-0.selected .rating-option-label { color: #b82020; }
.rating-option-btn.vrio-1.selected { background: #fdf4ed; border-color: #d07020; }
.rating-option-btn.vrio-1.selected .rating-option-value,
.rating-option-btn.vrio-1.selected .rating-option-label { color: #b05a10; }
.rating-option-btn.vrio-2.selected { background: #fdf8ef; border-color: #e0a500; }
.rating-option-btn.vrio-2.selected .rating-option-value,
.rating-option-btn.vrio-2.selected .rating-option-label { color: #b88600; }
.rating-option-btn.vrio-3.selected { background: #f0f9f4; border-color: #34c759; }
.rating-option-btn.vrio-3.selected .rating-option-value,
.rating-option-btn.vrio-3.selected .rating-option-label { color: #2da44e; }
.rating-option-btn.vrio-4.selected { background: #edf8f2; border-color: #28a745; }
.rating-option-btn.vrio-4.selected .rating-option-value,
.rating-option-btn.vrio-4.selected .rating-option-label { color: #1e8a3a; }

/* Rating info tooltip */
.rating-option-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 0;
  overflow: visible;
}
.rating-option-wrapper .rating-option-btn { width: 100%; flex: unset; }

.rating-option-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: var(--r-full);
  background: var(--line);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 3px;
  overflow: visible;
}
.rating-option-info:hover { background: var(--ink-2); color: white; }

.rating-option-btn .rating-option-info {
  position: absolute;
  bottom: 6px;
  right: 6px;
  margin-top: 0;
  z-index: 1;
}
.rating-option-btn .rating-option-info:hover { z-index: 9999; }

.rating-option-info .rating-option-tooltip {
  display: none;
  position: absolute;
  top: 100%;
  bottom: auto;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 8px;
  white-space: normal;
  width: 200px;
  height: auto;
  text-align: center;
  z-index: 9999;
  pointer-events: none;
  background: var(--ink-1);
  color: var(--surface);
  padding: 8px 12px;
  border-radius: var(--r2);
  font-size: var(--t-12);
  line-height: 1.4;
  box-shadow: 0 20px 60px rgba(0,0,0,0.12);
}
.rating-option-wrapper:last-child .rating-option-tooltip { left: auto; right: 0; transform: none; }
.rating-option-wrapper:first-child .rating-option-tooltip { left: 0; transform: none; }
.rating-option-info:hover .rating-option-tooltip { display: block; }

.rating-textarea {
  width: 100%;
  min-height: 60px;
  padding: var(--s12);
  font-size: var(--t-13);
  font-family: var(--font);
  border: 1px solid var(--line);
  border-radius: var(--r1);
  background: var(--surface);
  color: var(--ink-1);
  resize: vertical;
  transition: border-color 0.1s;
}
.rating-textarea:focus { outline: none; border-color: var(--accent); }
.rating-textarea::placeholder { color: var(--ink-3); }

.rating-section-enhanced { position: relative; margin-bottom: var(--s16); }
.rating-section-enhanced:last-child { margin-bottom: 0; }
.rating-section-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: var(--s12); }

/* ============================================
   STATS & DASHBOARD (setup grid)
   ============================================ */

.setup-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s12);
}
.setup-card { padding: var(--s12) !important; }

/* Composite score */
.composite-score {
  display: flex;
  align-items: center;
  gap: var(--s12);
  padding: var(--s12);
  background: var(--bg);
  border-radius: var(--r2);
}
.composite-value { font-size: var(--t-20); font-weight: 700; color: var(--accent); }
.composite-bar { flex: 1; height: 6px; background: var(--line); border-radius: var(--r-full); overflow: hidden; }
.composite-bar-fill { height: 100%; background: var(--accent); transition: width 0.3s; }

/* Aggregate bar */
.aggregate-bar { height: 4px; background: var(--bg); border-radius: var(--r-full); position: relative; margin-top: 2px; }
.aggregate-bar-fill { height: 100%; background: var(--accent); border-radius: var(--r-full); }

/* Discussion flag */
.discussion-flag {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 6px;
  background: var(--warn-dim);
  color: #8a6500;
  font-size: var(--t-11);
  font-weight: 400;
  border-radius: var(--r1);
  border: 1px solid var(--warn);
}
.shortlist-badge { background: var(--ok-dim); color: var(--ok); border: 1px solid var(--ok); }

.faded { opacity: 0.5; }

/* ============================================
   LINKING PAGE — Full Height
   ============================================ */

/*
 * Prevent body scroll — the root cause of the double-scroll.
 * .shell only had min-height (not height) and body had no overflow
 * control, so content taller than 100vh created a body scrollbar.
 */
body:has(.linking-page) {
  overflow: hidden;
}

/* Constrain .shell with explicit height (was only min-height before) */
.shell:has(.linking-page) {
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}

/* Content fills the constrained shell */
.content:has(.linking-page) {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Page wrapper fills content, overflow hidden to close the chain */
.content:has(.linking-page) > .page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Linking page fills remaining space */
.linking-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Grid container is the sole scroll target */
.linking-page .matrix-grid-container {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

body:has(.rating-page) {
  overflow: hidden;
}

.shell:has(.rating-page) {
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}

.content:has(.rating-page) {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.content:has(.rating-page) > .page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.rating-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.rating-page-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-top: var(--s12);
}

/* Empty state card — white bordered rectangle */
/* .empty-state-card is provided by design-kit/empty-state.css */

.two-column-fullheight { flex: 1; min-height: 0; }
.two-column-fullheight .panel { display: flex; flex-direction: column; height: 100%; }
.two-column-fullheight .panel-body { flex: 1; min-height: 0; max-height: none; overflow-y: auto; }

/* Collapsible capabilities */
.panel-capabilities { transition: width 0.15s ease, min-width 0.15s ease; }
.panel-capabilities.collapsed { min-width: 44px; width: 44px; }
.panel-capabilities.collapsed .panel-header { justify-content: center; }
.two-column.capabilities-collapsed { grid-template-columns: 44px 1fr; }

/* Collapse button */
.collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: var(--r1);
  background: transparent;
  cursor: pointer;
  font-size: var(--t-11);
  font-weight: 700;
  color: var(--ink-2);
  transition: all 0.1s;
}
.collapse-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Resource groups */
.resource-group-header {
  display: flex;
  align-items: center;
  gap: var(--s8);
  padding: var(--s8) 0;
  margin-top: var(--s12);
  margin-bottom: var(--s8);
  border-bottom: 1px solid var(--line);
}
.resource-group-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: var(--t-11);
  font-weight: 700;
}
.resource-group-label { font-size: var(--t-11); font-weight: 400; color: var(--ink-2); }

/* VRIO */
.vrio-dimension { margin-bottom: var(--s16); }
.vrio-dimension-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--s8); }
.vrio-dimension-label { font-weight: 700; font-size: var(--t-13); }
.vrio-info-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--ink-2);
  cursor: help;
  border: 1px solid var(--line);
}

/* File upload */
.file-upload {
  border: 1px dashed var(--line);
  border-radius: var(--r2);
  padding: var(--s20);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.1s;
}
.file-upload:hover { border-color: var(--accent); }
.file-upload.dragging { border-color: var(--accent); background: var(--accent-dim); }

/* ============================================
   MATURITY SCORING PAGE
   ============================================ */

/* ── Maturity Scoring — Full Height Layout ── */

body:has(.maturity-scoring-page) { overflow: hidden; }
.shell:has(.maturity-scoring-page) { height: calc(100vh - var(--topbar-h)); overflow: hidden; }
.content:has(.maturity-scoring-page) { height: 100%; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.content:has(.maturity-scoring-page) > .page { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }

.maturity-scoring-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Fixed header — never scrolls */
.maturity-scoring-header {
  flex-shrink: 0;
  display: flex;
  align-items: stretch;
  gap: var(--s12);
  padding: var(--s8) var(--s12);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  z-index: 10;
  position: relative;
}

.maturity-header-label {
  flex: 1;
  min-width: 200px;
  max-width: 550px;
  display: flex;
  align-items: center;
  gap: var(--s12);
  font-size: var(--t-13);
  font-weight: 600;
  color: var(--ink-1);
}

/* Status label next to "Resource" */
.maturity-header-status {
  font-size: var(--t-12);
  font-weight: 400;
  color: var(--ink-3);
  white-space: nowrap;
}
.maturity-header-status--done {
  color: #1e8a3a;
  font-weight: 500;
}
.maturity-header-status-icon {
  display: inline-block;
  margin-right: 3px;
  color: #34c759;
  font-weight: 700;
}

.maturity-header-scores { display: flex; gap: var(--s8); flex-shrink: 0; align-items: stretch; }
.maturity-header-col { width: 72px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: var(--s4) 0; position: relative; }
.maturity-header-num { font-size: var(--t-15); font-weight: 700; color: var(--ink-1); }
.maturity-header-name { flex: 1; display: flex; align-items: center; font-size: var(--t-11); color: var(--ink-1); text-align: center; line-height: 1.2; }

.maturity-header-info {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--line);
  color: var(--ink-3);
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  position: relative;
  flex-shrink: 0;
}
.maturity-header-info:hover { background: var(--accent); color: white; z-index: 20; }

.maturity-header-tooltip {
  display: none;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 6px;
  width: 200px;
  padding: 8px 12px;
  background: var(--ink-1);
  color: var(--surface);
  border-radius: var(--r2);
  font-size: var(--t-12);
  font-weight: 400;
  line-height: 1.4;
  text-align: left;
  box-shadow: 0 20px 60px rgba(0,0,0,0.12);
  z-index: 9999;
  pointer-events: none;
}
.maturity-header-info:hover .maturity-header-tooltip { display: block; }

/* Scrollable resource list — sole scroll target */
.maturity-resource-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  padding-top: var(--s8);
}
.maturity-resource-row {
  display: flex;
  align-items: center;
  gap: var(--s12);
  padding: var(--s12);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r2);
}
.maturity-resource-card { flex: 1; min-width: 200px; max-width: 550px; }
.maturity-resource-title { font-size: var(--t-20); font-weight: 700; color: var(--ink-1); line-height: 1.2; }
.maturity-resource-meta { display: flex; align-items: center; gap: var(--s4); font-size: var(--t-13); color: var(--ink-3); margin-top: var(--s4); }
.maturity-resource-divider { color: var(--line); }
.maturity-resource-desc { font-size: var(--t-13); color: var(--ink-2); margin-top: var(--s8); line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.maturity-score-buttons { display: flex; gap: var(--s8); flex-shrink: 0; align-items: center; }
.maturity-score-btn {
  width: 72px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--r1);
  background: var(--bg);
  color: var(--ink-1);
  font-size: var(--t-15);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.1s;
  font-family: var(--font-mono);
}
.maturity-score-btn:hover { border-color: var(--line); }
.maturity-score-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.maturity-score-btn.maturity-1.selected { background: #fdf0f0; border-color: #d63031; color: #b82020; }
.maturity-score-btn.maturity-2.selected { background: #fdf4ed; border-color: #d07020; color: #b05a10; }
.maturity-score-btn.maturity-3.selected { background: #fdf8ef; border-color: #e0a500; color: #b88600; }
.maturity-score-btn.maturity-4.selected { background: #f0f9f4; border-color: #34c759; color: #2da44e; }
.maturity-score-btn.maturity-5.selected { background: #edf8f2; border-color: #28a745; color: #1e8a3a; }

/* ============================================
   DARK MODE — RCAJO-specific overrides
   ============================================ */

[data-theme="dark"] .resource-card.selected-human { background: var(--color-human-dim); border-color: var(--color-human); }
[data-theme="dark"] .resource-card.selected-organisational { background: var(--color-organisational-dim); border-color: var(--color-organisational); }
[data-theme="dark"] .resource-card.selected-tangible { background: var(--color-tangible-dim); border-color: var(--color-tangible); }
[data-theme="dark"] .resource-card.selected-intangible { background: var(--color-intangible-dim); border-color: var(--color-intangible); }
[data-theme="dark"] .resource-card:not(.selected) { border-color: #555555; }
[data-theme="dark"] .resource-card-info { background: var(--bg-inset); }
[data-theme="dark"] .resource-card-notes { background: var(--bg-inset); }
[data-theme="dark"] .resource-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.2); }

[data-theme="dark"] .info-tooltip { box-shadow: 0 8px 30px rgba(0,0,0,0.4); }

[data-theme="dark"] .rating-option-btn { background: var(--bg); }
[data-theme="dark"] .rating-option-btn:hover { background: var(--surface); }

[data-theme="dark"] .rating-option-btn.criticality-0.selected { background: #0f2818; border-color: #34c759; }
[data-theme="dark"] .rating-option-btn.criticality-1.selected { background: #1a1400; border-color: #e0a500; }
[data-theme="dark"] .rating-option-btn.criticality-2.selected { background: #1a0d05; border-color: #d07020; }
[data-theme="dark"] .rating-option-btn.criticality-3.selected { background: #1a0505; border-color: #d63031; }
[data-theme="dark"] .rating-option-btn.criticality-4.selected { background: #1a0510; border-color: #b84a7a; }

[data-theme="dark"] .rating-option-btn.maturity-1.selected { background: #1a0505; border-color: #d63031; }
[data-theme="dark"] .rating-option-btn.maturity-2.selected { background: #1a0d05; border-color: #d07020; }
[data-theme="dark"] .rating-option-btn.maturity-3.selected { background: #1a1400; border-color: #e0a500; }
[data-theme="dark"] .rating-option-btn.maturity-4.selected { background: #0f2818; border-color: #34c759; }
[data-theme="dark"] .rating-option-btn.maturity-5.selected { background: #0f2818; border-color: #28a745; }

[data-theme="dark"] .rating-option-btn.vrio-0.selected { background: #1a0505; border-color: #d63031; }
[data-theme="dark"] .rating-option-btn.vrio-1.selected { background: #1a0d05; border-color: #d07020; }
[data-theme="dark"] .rating-option-btn.vrio-2.selected { background: #1a1400; border-color: #e0a500; }
[data-theme="dark"] .rating-option-btn.vrio-3.selected { background: #0f2818; border-color: #34c759; }
[data-theme="dark"] .rating-option-btn.vrio-4.selected { background: #0f2818; border-color: #28a745; }

[data-theme="dark"] .rating-textarea { background: var(--bg); }
[data-theme="dark"] .rating-textarea:focus { background: var(--surface); }

[data-theme="dark"] .maturity-header-status--done { color: #4ade80; }
[data-theme="dark"] .maturity-header-status-icon { color: #4ade80; }

[data-theme="dark"] .maturity-score-btn.maturity-1.selected { background: rgba(214, 48, 49, 0.15); border-color: #d63031; color: #ff6b6b; }
[data-theme="dark"] .maturity-score-btn.maturity-2.selected { background: rgba(208, 112, 32, 0.15); border-color: #d07020; color: #f0a060; }
[data-theme="dark"] .maturity-score-btn.maturity-3.selected { background: rgba(224, 165, 0, 0.15); border-color: #e0a500; color: #ffd060; }
[data-theme="dark"] .maturity-score-btn.maturity-4.selected { background: rgba(52, 199, 89, 0.15); border-color: #34c759; color: #4ade80; }
[data-theme="dark"] .maturity-score-btn.maturity-5.selected { background: rgba(40, 167, 69, 0.15); border-color: #28a745; color: #4ade80; }

/* ============================================
   RESPONSIVE
   ============================================ */

/* ============================================
   INVENTORY — Panel Detail Styles
   App-specific label/value layout inside
   design-kit's panel-slide component.
   ============================================ */

.panel-detail-section {
  margin-bottom: var(--s16);
}

.panel-detail-label {
  font-size: var(--t-11);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  margin-bottom: var(--s4);
}

.panel-detail-value {
  font-size: var(--t-13);
  color: var(--ink-1);
  line-height: 1.5;
}

/* ============================================
   INVENTORY PAGES — Full Height
   ============================================ */

body:has(.inventory-page) { overflow: hidden; }

.shell:has(.inventory-page) {
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}

.content:has(.inventory-page) {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.content:has(.inventory-page) > .page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.inventory-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.inventory-page .matrix-grid-container {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.inventory-card {
  width: 170px;
  min-width: 170px;
  flex: 0 0 170px;
  min-height: 52px;
  padding: var(--s8) var(--s12);
  border-radius: var(--r2);
  background: var(--surface);
  border: 1px solid var(--line);
  cursor: default;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: border-color var(--dt-fast) var(--ease);
}

.inventory-card:hover {
  border-color: var(--line-strong);
}

.inventory-card-title {
  font-size: var(--t-13);
  font-weight: 600;
  line-height: 1.3;
  padding: 0 14px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Outcome card variant ── */

.inventory-card--outcome {
  width: 200px;
  min-width: 200px;
  flex: 0 0 200px;
  min-height: 120px;
  flex-direction: column;
  align-items: stretch;
  text-align: center;
  padding: 0;
  overflow: hidden;
}

.inventory-card--outcome .inventory-card-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s12) var(--s12) var(--s8);
}

.inventory-card--outcome .inventory-card-title {
  -webkit-line-clamp: 3;
  padding: 0;
}

/* ── Info button (top-right) ── */

.inventory-card-info {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: var(--r-full);
  border: 1px solid var(--line);
  background: var(--bg-inset);
  color: var(--ink-3);
  font-size: var(--t-11);
  font-style: italic;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--dt-fast);
  z-index: 1;
}

.inventory-card:hover .inventory-card-info {
  opacity: 1;
}

.inventory-card-info:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Tag band (bottom of card) ── */

.inventory-card-tag-band {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  align-content: flex-start;
  gap: 3px;
  padding: 0 10px 10px;
  min-height: 22px;
}

.inventory-card-tag {
  display: inline-flex;
  align-items: center;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 0;
  background: #fff;
  border: 1.5px solid var(--ink-1);
  color: var(--ink-1);
  line-height: 1.5;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-theme="dark"] .inventory-card-tag {
  background: transparent;
  border-color: var(--ink-2);
  color: var(--ink-2);
}

.inventory-card-tag-x {
  border: none;
  background: none;
  color: var(--ink-3);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  margin-left: 3px;
  line-height: 1;
  opacity: 0;
  width: 0;
  overflow: hidden;
  transition: opacity var(--dt-fast), width var(--dt-fast);
}

.inventory-card-tag:hover .inventory-card-tag-x {
  opacity: 1;
  width: 10px;
}

.inventory-card-tag-x:hover {
  color: var(--err);
}

.inventory-card-tag-add {
  border: 1px dashed var(--line);
  background: none;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 600;
  height: 18px;
  min-width: 18px;
  padding: 0 2px;
  border-radius: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--dt-fast);
  opacity: 0;
}

.inventory-card-tag-add svg {
  width: 12px;
  height: 12px;
}

.inventory-card:hover .inventory-card-tag-add {
  opacity: 1;
}

.inventory-card-tag-add:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Inline tag input on cards */
.inventory-card-tag-input-wrap {
  flex: 1;
  min-width: 50px;
}

.inventory-card-tag-input {
  width: 100%;
  font-size: 10px;
  padding: 2px 4px;
  border: 1.5px solid var(--ink-1);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink-1);
  outline: none;
}

/* ── Panel tags ── */

.panel-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s4);
}

/* ── Form tags input (OutcomesPage modal) ── */

.form-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s4);
  padding: var(--s8);
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: var(--surface);
  min-height: 38px;
  align-items: center;
  cursor: text;
}

.form-tag {
  display: inline-flex;
  align-items: center;
  font-size: var(--t-12);
  font-weight: 500;
  padding: 2px 6px;
  border-radius: var(--r1);
  background: var(--bg-inset);
  border: 1px solid var(--line);
  color: var(--ink-2);
}

.form-tag-x {
  border: none;
  background: none;
  color: var(--ink-3);
  font-size: 14px;
  cursor: pointer;
  padding: 0;
  margin-left: 4px;
  line-height: 1;
}

.form-tag-x:hover {
  color: var(--err);
}

.form-tag-input {
  border: none;
  background: none;
  outline: none;
  font-size: var(--t-12);
  color: var(--ink-1);
  flex: 1;
  min-width: 80px;
  padding: 2px 0;
}

/* ── Responsive ── */

@media (max-width: 1024px) {
  .linking-page .matrix-grid { --matrix-cols: 48px repeat(4, minmax(155px, 1fr)); }
  .resource-card { width: 155px; min-width: 155px; flex: 0 0 155px; min-height: 48px; }
}

@media (max-width: 768px) {
  .two-column { grid-template-columns: 1fr; }
  .two-column-fullheight { height: auto; }
  body:has(.linking-page) { overflow: auto; }
  .shell:has(.linking-page) { height: auto; overflow: visible; }
  .content:has(.linking-page) { height: auto; overflow: visible; }
  .linking-page .matrix-grid { --matrix-cols: 40px repeat(2, 1fr); }
  .detail-card-title { padding-right: 0; }
  .detail-card-header-tags { position: static; margin-top: var(--s8); }
  body:has(.inventory-page) { overflow: auto; }
  .shell:has(.inventory-page) { height: auto; overflow: visible; }
  .content:has(.inventory-page) { height: auto; overflow: visible; }
}

@media (max-width: 480px) {
  .linking-page .matrix-grid { display: flex; flex-direction: column; gap: var(--s12); background: transparent; border: none; }
  .linking-page .matrix-grid-col, .linking-page .matrix-grid-corner { display: none; }
  .linking-page .matrix-grid-row { writing-mode: horizontal-tb; transform: none; text-align: left; position: static; padding: var(--s8) var(--s12); border-radius: var(--r1); letter-spacing: normal; text-transform: none; white-space: normal; }
  .linking-page .matrix-grid-cell { padding: var(--s8); border: none; }
  .resource-card { width: 100%; min-width: auto; flex: 1; }
  .rating-options-row { flex-wrap: wrap; }
  .rating-option-btn { flex: 1 1 calc(33.333% - var(--s8)); min-width: calc(33.333% - var(--s8)); }
  .rating-card-header { flex-direction: column; gap: var(--s12); }
}
