:root {
  --bg-tree: #f6f6f6;
  --border-soft: #e5e5e5;
  --selected-bg: #e3e3fd;
  --selected-border: #6a6af4;
  --hover-bg: #f4f4fc;
}

.panel-card {
  background: #fff;
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 1.5rem;
  height: 100%;
}

.panel-detail {
  position: sticky;
  top: 1rem;
}

/* Tree */
.tree {
  font-size: 0.875rem;
  line-height: 1.5;
}

.tree ul {
  list-style: none;
  margin: 0;
  padding-left: 1.25rem;
  border-left: 1px dashed var(--border-soft);
}

.tree > ul {
  padding-left: 0;
  border-left: 0;
}

.tree li {
  margin: 0.125rem 0;
}

.node-row {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}

.node-row:hover {
  background: var(--hover-bg);
}

.node-row.selected {
  background: var(--selected-bg);
  border-color: var(--selected-border);
}

.node-row.dim {
  opacity: 0.35;
}

.node-toggle {
  background: none;
  border: 0;
  padding: 0;
  width: 1rem;
  height: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-mention-grey, #666);
  font-size: 0.75rem;
  flex-shrink: 0;
}

.node-toggle.placeholder {
  visibility: hidden;
}

.node-label {
  flex: 1;
  font-weight: 500;
}

.node-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
}

.type-pill {
  font-size: 0.6875rem;
  padding: 0.0625rem 0.5rem;
  border-radius: 999px;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid transparent;
}

.priority-pill {
  font-size: 0.625rem;
  padding: 0 0.375rem;
  border-radius: 2px;
  font-weight: 700;
  letter-spacing: 0.03em;
  background: #f6f6f6;
  color: #666;
  border: 1px solid #ddd;
  text-transform: uppercase;
}

.priority-pill.mvp { background: #b8fec9; color: #18753c; border-color: #18753c; }
.priority-pill.v1  { background: #fee7fc; color: #6e445a; border-color: #6e445a; }
.priority-pill.v2  { background: #fff6e3; color: #716043; border-color: #b8a684; }
.priority-pill.v3  { background: #f4f4fc; color: #3a3a8c; border-color: #6a6af4; }

.complexity-pill {
  font-size: 0.625rem;
  padding: 0 0.375rem;
  border-radius: 2px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  text-transform: uppercase;
}

.complexity-pill.low    { background: #dffee2; color: #297254; border-color: #82c8a3; }
.complexity-pill.medium { background: #fff1d6; color: #8a6a3a; border-color: #d4b078; }
.complexity-pill.high   { background: #ffe4dd; color: #a93f1d; border-color: #d68a72; }

.auth-pill {
  font-size: 0.625rem;
  padding: 0 0.375rem;
  border-radius: 2px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: #efeae3;
  color: #5e5045;
  border: 1px solid #a8998a;
  text-transform: uppercase;
}

/* Type colors */
.type-hub        { background: #f4f4fc; color: #3a3a8c; border-color: #6a6af4; }
.type-editorial  { background: #fff; color: #444; border-color: #ddd; }
.type-service    { background: #e8edff; color: #2a3994; border-color: #8b9ed9; }
.type-simulator  { background: #fee7fc; color: #6e445a; border-color: #d28aa3; }
.type-map        { background: #b8fec9; color: #18753c; border-color: #5cba7a; }
.type-external   { background: #fff6e3; color: #716043; border-color: #d4be91; }
.type-marketplace{ background: #ffe8e5; color: #b34000; border-color: #e8a08a; }
.type-kit        { background: #fef7da; color: #716043; border-color: #d4c891; }
.type-form       { background: #e0f3ff; color: #0063cb; border-color: #88b8e0; }
.type-private    { background: #efeae3; color: #5e5045; border-color: #a8998a; }

/* Legend */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-soft);
}

/* Panel form */
.panel-empty {
  color: var(--text-mention-grey, #666);
  font-style: italic;
  padding: 1rem 0;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-soft);
}

.panel-actions--top {
  margin-top: 0;
  margin-bottom: 1rem;
  padding-top: 0;
  padding-bottom: 1rem;
  border-top: 0;
  border-bottom: 1px solid var(--border-soft);
}

.panel-id {
  font-family: monospace;
  font-size: 0.75rem;
  color: var(--text-mention-grey, #666);
  margin-bottom: 1rem;
}

.export-textarea {
  width: 100%;
  min-height: 220px;
  font-family: monospace;
  font-size: 0.75rem;
  padding: 0.5rem;
  border: 1px solid var(--border-soft);
  border-radius: 4px;
}

dialog.app-dialog {
  padding: 1.5rem;
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  max-width: min(1200px, 95vw);
  width: 95vw;
  max-height: 90vh;
  overflow: auto;
}

dialog.app-dialog::backdrop {
  background: rgba(22, 22, 22, 0.5);
}

.graph-container {
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 1rem;
  margin-top: 1rem;
  overflow: auto;
  background: #fff;
  max-height: 70vh;
}

.graph-container svg {
  max-width: none;
  height: auto;
}

/* Cartography list */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 70vh;
  overflow-y: auto;
}

.item-card {
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 0.75rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  background: #fff;
}

.item-card:hover { background: var(--hover-bg); }

.item-card.selected {
  background: var(--selected-bg);
  border-color: var(--selected-border);
}

.item-card__head {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  margin-bottom: 0.375rem;
}

.item-card__id {
  font-family: monospace;
  font-size: 0.6875rem;
  color: var(--text-mention-grey, #666);
  flex-shrink: 0;
}

.item-card__name {
  font-size: 0.9375rem;
  line-height: 1.3;
}

.item-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0.25rem;
}

.item-card__porteur {
  font-size: 0.75rem;
  color: var(--text-mention-grey, #666);
  margin: 0;
}

.item-badge {
  font-size: 0.6875rem;
  padding: 0.0625rem 0.5rem;
  border-radius: 999px;
  border: 1px solid #ddd;
  background: #f6f6f6;
  color: #444;
  white-space: nowrap;
}

.badge-cat   { background: #f4f4fc; color: #3a3a8c; border-color: #6a6af4; }
.badge-aud   { background: #e0f3ff; color: #0063cb; border-color: #88b8e0; }
.badge-type  { background: #fff6e3; color: #716043; border-color: #d4be91; }
.badge-prob  { background: #fef7da; color: #716043; border-color: #d4c891; }
.badge-imp   { background: #ffe4dd; color: #8a3919; border-color: #d68a72; }

.crit-low      { background: #dffee2; color: #297254; border-color: #82c8a3; font-weight: 700; }
.crit-medium   { background: #fff1d6; color: #8a6a3a; border-color: #d4b078; font-weight: 700; }
.crit-high     { background: #ffe4dd; color: #a93f1d; border-color: #d68a72; font-weight: 700; }
.crit-critical { background: #ce0500; color: #fff;    border-color: #ce0500; font-weight: 700; }

/* ---- Collaboration: identity, status, comments, history ---- */

.identity-zone {
  font-size: 0.8125rem;
  color: var(--text-mention-grey, #666);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-right: 1rem;
}

.identity-zone .identity-name {
  font-weight: 600;
  color: var(--text-default, #161616);
}

.save-status {
  font-size: 0.75rem;
  margin-top: 0.5rem;
  min-height: 1rem;
  color: var(--text-mention-grey, #666);
}

.save-status--saving { color: #716043; }
.save-status--saved  { color: #18753c; }
.save-status--error,
.save-status--conflict { color: #b34000; font-weight: 600; }

.comment-pill {
  font-size: 0.6875rem;
  padding: 0 0.375rem;
  border-radius: 999px;
  border: 1px solid #d6d6f0;
  background: #f4f4fc;
  color: #3a3a8c;
  white-space: nowrap;
}

.comments-section {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-soft);
}

.comment-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.comment-item {
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  background: #fafafa;
}

.comment-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  margin-bottom: 0.25rem;
}

.comment-head strong { color: #3a3a8c; }

.comment-head .comment-date {
  font-size: 0.75rem;
  color: var(--text-mention-grey, #666);
  margin-left: auto;
}

.comment-body {
  font-size: 0.875rem;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.comment-form textarea {
  font-size: 0.875rem;
}

/* ---- History dialog ---- */

.history-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1rem;
  min-height: 400px;
}

@media (max-width: 720px) {
  .history-layout { grid-template-columns: 1fr; }
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 70vh;
  overflow-y: auto;
  border-right: 1px solid var(--border-soft);
  padding-right: 0.5rem;
}

.history-item {
  text-align: left;
  background: #fff;
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.history-item:hover { background: var(--hover-bg); }

.history-item--head {
  background: #f4f4fc;
  border-color: #6a6af4;
}

.history-item__head {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-mention-grey, #666);
  margin-bottom: 0.25rem;
}

.history-item__id { font-family: monospace; font-weight: 700; color: #3a3a8c; }

.history-item__msg {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-default, #161616);
}

.history-item__date {
  font-size: 0.6875rem;
  color: var(--text-mention-grey, #666);
  margin-top: 0.25rem;
}

.history-detail {
  max-height: 70vh;
  overflow-y: auto;
  padding-left: 0.5rem;
}

.history-meta { font-size: 0.875rem; }

/* ---- Diff ---- */

.diff-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.diff-item {
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  background: #fff;
}

.diff-added   { border-left: 3px solid #18753c; }
.diff-removed { border-left: 3px solid #b34000; }
.diff-changed { border-left: 3px solid #6a6af4; }

.diff-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
}

.diff-badge {
  font-size: 0.6875rem;
  padding: 0.0625rem 0.5rem;
  border-radius: 2px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.diff-badge-added   { background: #b8fec9; color: #18753c; }
.diff-badge-removed { background: #ffe4dd; color: #b34000; }
.diff-badge-changed { background: #f4f4fc; color: #3a3a8c; }

.diff-label { font-weight: 500; flex: 1; }

.diff-id {
  font-family: monospace;
  font-size: 0.6875rem;
  color: var(--text-mention-grey, #666);
}

.diff-details {
  font-size: 0.8125rem;
  margin-top: 0.25rem;
  padding-top: 0.25rem;
  border-top: 1px dashed var(--border-soft);
}

.diff-field {
  margin: 0.125rem 0;
  font-family: monospace;
  font-size: 0.75rem;
  word-wrap: break-word;
}

.diff-field-name {
  font-weight: 700;
  color: #3a3a8c;
}

.diff-field del {
  background: #ffe4dd;
  color: #b34000;
  text-decoration: line-through;
  padding: 0 0.125rem;
}

.diff-field ins {
  background: #b8fec9;
  color: #18753c;
  text-decoration: none;
  padding: 0 0.125rem;
}

.identify-dialog {
  max-width: 480px;
}

/* ---- Decision tree (dispositifs page) ---- */

.decision-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
}

.decision-breadcrumb__step {
  background: none;
  border: 0;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  color: #3a3a8c;
  font-weight: 500;
  font-size: inherit;
}

.decision-breadcrumb__step:hover { background: var(--hover-bg); }

.decision-breadcrumb__step--active {
  color: var(--text-default, #161616);
  cursor: default;
}

.decision-breadcrumb__step--active:hover { background: none; }

.decision-breadcrumb__sep {
  color: var(--text-mention-grey, #666);
  font-size: 1rem;
}

.decision-breadcrumb__restart {
  margin-left: auto;
}

.decision-step { padding: 0.5rem 0; }

.decision-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
}

.decision-card {
  text-align: left;
  background: #fff;
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 1rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  font: inherit;
  color: inherit;
}

.decision-card:hover {
  background: var(--hover-bg);
  border-color: var(--selected-border);
}

.decision-card:active { transform: scale(0.99); }

.decision-card__title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: #3a3a8c;
}

.decision-card__sub {
  font-size: 0.8125rem;
  color: var(--text-mention-grey, #666);
}

/* Questions */

.decision-questions {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.decision-question__label {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.decision-question__options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.decision-option {
  background: #fff;
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 0.5rem 0.875rem;
  cursor: pointer;
  font: inherit;
  color: inherit;
  font-size: 0.875rem;
  transition: background 0.15s, border-color 0.15s;
}

.decision-option:hover {
  background: var(--hover-bg);
  border-color: var(--selected-border);
}

.decision-option--selected {
  background: var(--selected-bg);
  border-color: var(--selected-border);
  color: #3a3a8c;
  font-weight: 600;
}

/* Outcomes */

.outcome-card {
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  background: #fff;
  border-left-width: 4px;
}

.outcome-card--p0 { border-left-color: #6a6af4; background: #fafaff; }
.outcome-card--p1 { border-left-color: #18753c; }
.outcome-card--p2 { border-left-color: #b8a684; }

.outcome-card__head {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.outcome-card__title {
  margin: 0;
  flex: 1;
}

.outcome-priority {
  font-size: 0.6875rem;
  padding: 0.125rem 0.5rem;
  border-radius: 2px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.outcome-priority.priority-pre  { background: #e3e3fd; color: #3a3a8c; border: 1px solid #6a6af4; }
.outcome-priority.priority-main { background: #b8fec9; color: #18753c; border: 1px solid #18753c; }
.outcome-priority.priority-sec  { background: #fff6e3; color: #716043; border: 1px solid #b8a684; }

.outcome-card__explanation {
  font-size: 0.875rem;
  color: var(--text-default, #161616);
  margin: 0 0 0.75rem;
}

.outcome-dispositifs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.outcome-dispositif {
  border-top: 1px dashed var(--border-soft);
  padding-top: 0.5rem;
}

.outcome-dispositif__head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: baseline;
  margin-bottom: 0.25rem;
}

.outcome-dispositif__ref {
  font-family: monospace;
  font-size: 0.6875rem;
  background: #f4f4fc;
  color: #3a3a8c;
  padding: 0 0.375rem;
  border-radius: 2px;
  white-space: nowrap;
}

.outcome-dispositif__name {
  font-size: 0.9375rem;
  color: var(--text-default, #161616);
}

.outcome-dispositif__role {
  font-size: 0.75rem;
  color: var(--text-mention-grey, #666);
  font-style: italic;
}

.outcome-dispositif__tldr {
  font-size: 0.8125rem;
  margin: 0.25rem 0;
  color: var(--text-default, #161616);
}

.outcome-dispositif__note {
  font-size: 0.75rem;
  color: var(--text-mention-grey, #666);
  font-style: italic;
  margin: 0.25rem 0;
}
