:root {
  color-scheme: light;
  --bg: oklch(96% 0.012 177);
  --surface: oklch(99% 0.006 177);
  --surface-2: oklch(93.5% 0.018 177);
  --ink: oklch(21% 0.028 178);
  --muted: oklch(47% 0.028 178);
  --line: oklch(84% 0.024 178);
  --brand: oklch(39% 0.08 185);
  --brand-strong: oklch(31% 0.075 185);
  --amber: oklch(66% 0.14 72);
  --red: oklch(50% 0.16 28);
  --green: oklch(48% 0.11 150);
  --blue: oklch(48% 0.11 238);
  --violet: oklch(45% 0.1 300);
  --shadow: 0 14px 32px oklch(24% 0.032 178 / 0.10);
  --radius: 8px;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;
  --space-3xl: 48px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, oklch(92% 0.026 177) 0, var(--bg) 360px),
    var(--bg);
  color: var(--ink);
  font-family: Aptos, "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  line-height: 1.45;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 40px;
}

.app-shell {
  min-height: 100vh;
}

.boot {
  min-height: 100vh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: var(--space-lg);
  color: var(--muted);
}

.boot-mark {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  animation: spin .9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.layout {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: var(--space-xl);
  padding: var(--space-xl);
  background: oklch(21% 0.035 180);
  color: oklch(96% 0.01 180);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.brand-symbol {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: oklch(83% 0.085 180);
  color: oklch(22% 0.045 180);
  font-weight: 900;
}

.brand strong {
  display: block;
  font-size: 18px;
}

.brand span {
  display: block;
  color: oklch(78% 0.025 180);
  font-size: 12px;
}

.side-nav {
  display: grid;
  align-content: start;
  gap: var(--space-sm);
}

.side-nav button,
.role-select {
  width: 100%;
  color: inherit;
  background: transparent;
  border: 1px solid oklch(42% 0.035 180);
  border-radius: 7px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}

.side-nav button.active,
.side-nav button:hover {
  background: oklch(29% 0.045 180);
  border-color: oklch(55% 0.05 180);
}

.role-box {
  display: grid;
  gap: var(--space-sm);
  color: oklch(81% 0.025 180);
  font-size: 13px;
}

.role-select {
  min-height: 44px;
  background: oklch(26% 0.04 180);
}

.main {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  min-height: 72px;
  padding: var(--space-lg) var(--space-2xl);
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklch, var(--surface) 88%, transparent);
  backdrop-filter: blur(16px);
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.topbar p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.content {
  padding: var(--space-2xl);
  display: grid;
  gap: var(--space-xl);
  align-content: start;
}

.grid {
  display: grid;
  gap: var(--space-lg);
}

.grid.two {
  grid-template-columns: minmax(0, 1fr) minmax(320px, .45fr);
  align-items: start;
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.auto {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.panel,
.metric,
.list-item,
.form-band {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel {
  padding: var(--space-xl);
  box-shadow: var(--shadow);
}

.panel.tight {
  padding: var(--space-lg);
}

.section-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.section-title h2,
.section-title h3 {
  margin: 0;
  font-size: 18px;
}

.section-title p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.metric {
  padding: var(--space-lg);
}

.metric strong {
  display: block;
  font-size: 30px;
  line-height: 1;
}

.metric span {
  display: block;
  margin-top: var(--space-sm);
  color: var(--muted);
  font-size: 13px;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 13px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}

.btn:hover {
  border-color: color-mix(in oklch, var(--brand), var(--line) 45%);
}

.btn.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: oklch(98% 0.008 180);
}

.btn.primary:hover {
  background: var(--brand-strong);
}

.btn.danger {
  color: var(--red);
  border-color: color-mix(in oklch, var(--red), var(--line) 55%);
}

.btn.icon {
  width: 40px;
  padding: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.status {
  background: oklch(92% 0.018 180);
  color: var(--brand-strong);
}

.badge.low {
  background: oklch(91% 0.045 150);
  color: oklch(34% 0.09 150);
}

.badge.medium {
  background: oklch(92% 0.07 82);
  color: oklch(43% 0.105 68);
}

.badge.high {
  background: oklch(89% 0.075 52);
  color: oklch(42% 0.13 42);
}

.badge.critical {
  background: oklch(89% 0.07 28);
  color: oklch(39% 0.16 28);
}

.progress {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
}

.progress > span {
  display: block;
  height: 100%;
  background: var(--brand);
  border-radius: inherit;
}

.list {
  display: grid;
  gap: var(--space-md);
}

.list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-lg);
  padding: var(--space-lg);
  cursor: pointer;
}

.list-item:hover {
  border-color: color-mix(in oklch, var(--brand), var(--line) 45%);
}

.list-item h3 {
  margin: 0;
  font-size: 16px;
}

.list-item p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.tabs {
  display: flex;
  gap: var(--space-sm);
  overflow-x: auto;
  padding: var(--space-xs);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.tabs button {
  flex: 0 0 auto;
  border: 0;
  border-radius: 6px;
  padding: 9px 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.tabs button.active {
  background: var(--brand);
  color: oklch(98% 0.008 180);
}

.domain-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.domain-tabs button {
  min-height: 58px;
  display: grid;
  align-content: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 11px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.domain-tabs button:hover {
  border-color: color-mix(in oklch, var(--brand), var(--line) 45%);
}

.domain-tabs button.active {
  border-color: var(--brand);
  background: color-mix(in oklch, var(--brand), var(--surface) 86%);
}

.domain-tabs small {
  color: var(--muted);
  font-weight: 700;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-lg);
}

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 11px;
  background: oklch(99.5% 0.004 177);
  color: var(--ink);
}

.field textarea {
  resize: vertical;
  min-height: 92px;
}

.form-band {
  padding: var(--space-lg);
  background: color-mix(in oklch, var(--surface), var(--surface-2) 38%);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .02em;
  text-transform: uppercase;
  background: var(--surface-2);
}

tr:last-child td {
  border-bottom: 0;
}

.answer-grid {
  display: grid;
  gap: var(--space-md);
}

.question-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, .36fr);
  gap: var(--space-md);
  padding: var(--space-lg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.question-row p {
  margin: 0;
  font-weight: 700;
}

.question-note {
  width: 100%;
  min-height: 58px;
  margin-top: var(--space-md);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 11px;
  background: oklch(99.5% 0.004 177);
  color: var(--ink);
  resize: vertical;
}

.question-photo-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
  color: var(--muted);
  font-size: 13px;
}

.question-urgency {
  display: grid;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.question-urgency > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.urgency-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.urgency-options button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}

.urgency-options button.active.faible {
  background: oklch(91% 0.045 150);
  border-color: oklch(68% 0.08 150);
  color: oklch(34% 0.09 150);
}

.urgency-options button.active.moderee {
  background: oklch(92% 0.07 82);
  border-color: oklch(78% 0.1 82);
  color: oklch(43% 0.105 68);
}

.urgency-options button.active.importante {
  background: oklch(89% 0.075 52);
  border-color: oklch(72% 0.11 52);
  color: oklch(42% 0.13 42);
}

.urgency-options button.active.critique {
  background: oklch(89% 0.07 28);
  border-color: oklch(69% 0.12 28);
  color: oklch(39% 0.16 28);
}

.question-photo-btn {
  position: relative;
  overflow: hidden;
}

.question-photo-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.question-photo-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.question-photo-strip figure {
  display: grid;
  gap: var(--space-sm);
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: var(--space-sm);
  background: color-mix(in oklch, var(--surface), var(--surface-2) 28%);
}

.question-photo-strip img {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: block;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface-2);
}

.question-photo-strip figcaption {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.domain-summary {
  position: sticky;
  top: 96px;
}

.domain-summary h3 {
  margin: var(--space-lg) 0 var(--space-sm);
  font-size: 14px;
}

.clean-list {
  display: grid;
  gap: var(--space-sm);
  margin: 0 0 var(--space-lg);
  padding-left: 18px;
  color: var(--muted);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  align-self: start;
}

.segmented button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.segmented button.active {
  background: var(--brand);
  border-color: var(--brand);
  color: oklch(98% 0.008 180);
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-lg);
}

.photo-tile {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.photo-tile img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--surface-2);
}

.photo-tile div {
  padding: var(--space-md);
}

.empty,
.notice {
  border: 1px dashed color-mix(in oklch, var(--line), var(--brand) 20%);
  border-radius: var(--radius);
  padding: var(--space-xl);
  background: color-mix(in oklch, var(--surface), var(--surface-2) 35%);
  color: var(--muted);
}

.notice {
  border-style: solid;
}

.notice.warn {
  background: oklch(94% 0.046 80);
  border-color: oklch(80% 0.09 80);
  color: oklch(39% 0.09 68);
}

.mobile-bar {
  display: none;
}

.save-state {
  min-height: 24px;
  color: var(--muted);
  font-size: 13px;
}

.save-state.dirty {
  color: var(--amber);
  font-weight: 700;
}

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

  .sidebar {
    position: static;
    height: auto;
    grid-template-columns: 1fr;
    padding: var(--space-lg);
  }

  .side-nav {
    display: flex;
    overflow-x: auto;
  }

  .side-nav button {
    width: auto;
    white-space: nowrap;
  }

  .grid.two,
  .grid.three {
    grid-template-columns: 1fr;
  }

  .content,
  .topbar {
    padding-inline: var(--space-lg);
  }
}

@media (max-width: 740px) {
  body {
    background: var(--bg);
  }

  .content {
    padding: var(--space-lg);
    padding-bottom: 88px;
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .actions {
    width: 100%;
    justify-content: stretch;
  }

  .actions .btn {
    flex: 1 1 150px;
  }

  .form-grid,
  .form-grid.three {
    grid-template-columns: 1fr;
  }

  .list-item,
  .question-row {
    grid-template-columns: 1fr;
  }

  .domain-summary {
    position: static;
  }

  .segmented {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .urgency-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric strong {
    font-size: 24px;
  }

  .sidebar {
    display: none;
  }

  .mobile-bar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 8;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: color-mix(in oklch, var(--surface) 92%, transparent);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
  }

  .mobile-bar button {
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    cursor: pointer;
  }

  .mobile-bar button.active {
    background: var(--brand);
    color: oklch(98% 0.008 180);
  }
}
