:root {
  --bg: #f4efe7;
  --panel: #fffdf8;
  --panel-alt: #f1e6d6;
  --line: #d9c8af;
  --text: #1f2a23;
  --muted: #566158;
  --brand: #193c32;
  --brand-soft: #2c5a4d;
  --accent: #c46a2d;
  --urgent: #c4472d;
  --high: #dd8a2d;
  --normal: #295f4d;
  --low: #5f776a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(196, 106, 45, 0.18), transparent 22rem),
    linear-gradient(180deg, #f8f3ec 0%, var(--bg) 100%);
  color: var(--text);
  font-family: "Manrope", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 19rem 1fr;
}

.sidebar {
  padding: 2rem 1.4rem;
  border-right: 1px solid rgba(25, 60, 50, 0.12);
  background: rgba(255, 253, 248, 0.72);
  backdrop-filter: blur(14px);
}

.brand {
  margin: 0.25rem 0 0;
  font-size: 2rem;
  line-height: 1;
}

.content {
  padding: 2rem;
}

.portal-page {
  background: #f7f8f5;
}

.portal-topbar {
  min-height: 4.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 2rem;
  border-bottom: 1px solid rgba(25, 60, 50, 0.12);
  background: rgba(255, 253, 248, 0.94);
}

.portal-topbar strong {
  display: block;
  font-size: 1.15rem;
}

.portal-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.portal-content {
  width: min(100%, 78rem);
  margin: 0 auto;
  padding: 2rem;
}

.portal-auth-card {
  width: min(100%, 34rem);
  margin: 4rem auto 0;
  padding: 1.4rem;
  border: 1px solid rgba(25, 60, 50, 0.1);
  border-radius: 1.2rem;
  background: var(--panel);
  box-shadow: 0 1rem 3rem rgba(25, 60, 50, 0.06);
}

.portal-stage-panel {
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(247, 248, 245, 0.92));
}

.portal-stage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.85rem;
  margin-top: 1rem;
}

.portal-stage-card {
  min-height: 7rem;
  display: grid;
  align-content: space-between;
  gap: 0.8rem;
  padding: 1rem;
  border: 1px solid rgba(25, 60, 50, 0.1);
  border-radius: 1rem;
  background: rgba(255, 252, 247, 0.9);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.portal-stage-card:disabled {
  cursor: default;
  opacity: 0.58;
}

.portal-stage-card-active:hover,
.portal-stage-card-active:focus-visible {
  border-color: rgba(25, 60, 50, 0.28);
  box-shadow: 0 0.8rem 1.6rem rgba(25, 60, 50, 0.08);
  outline: none;
}

.portal-stage-card span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.portal-stage-card strong {
  font-size: 2.1rem;
}

.portal-modal-list {
  display: grid;
  gap: 0.85rem;
}

.portal-case-summary {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(12rem, 1fr) minmax(10rem, 0.8fr);
  gap: 1rem;
  padding: 1rem;
  border: 1px solid rgba(25, 60, 50, 0.08);
  border-radius: 1rem;
  background: rgba(255, 252, 247, 0.88);
}

.portal-case-summary p {
  margin: 0.35rem 0 0;
}

.client-progress {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.client-progress-step {
  min-height: 5.5rem;
  display: grid;
  align-content: center;
  gap: 0.45rem;
  padding: 1rem;
  border: 1px solid rgba(25, 60, 50, 0.1);
  border-radius: 1rem;
  background: rgba(255, 252, 247, 0.88);
}

.client-progress-step span {
  width: 2rem;
  height: 2rem;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(25, 60, 50, 0.08);
  color: var(--muted);
  font-weight: 800;
}

.client-progress-step strong {
  font-size: 0.95rem;
}

.client-progress-done {
  border-color: rgba(15, 118, 110, 0.3);
}

.client-progress-done span,
.client-progress-current span {
  background: #0f766e;
  color: #fff;
}

.client-progress-current {
  border-color: rgba(15, 118, 110, 0.45);
  box-shadow: 0 0.85rem 2rem rgba(15, 118, 110, 0.1);
}

.eyebrow,
.subtle,
.mono {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.lead {
  max-width: 54rem;
  color: var(--muted);
  font-size: 1rem;
}

.nav {
  margin-top: 2rem;
  display: grid;
  gap: 0.75rem;
}

.nav a {
  padding: 0.9rem 1rem;
  border-radius: 1rem;
  background: rgba(25, 60, 50, 0.06);
  font-weight: 700;
}

.nav-user {
  margin-top: 2rem;
  padding-top: 1.4rem;
  border-top: 1px solid rgba(25, 60, 50, 0.12);
}

.hero,
.panel,
.metric-card,
.case-card {
  border: 1px solid rgba(25, 60, 50, 0.1);
  box-shadow: 0 1rem 3rem rgba(25, 60, 50, 0.06);
}

.hero {
  padding: 1.6rem;
  border-radius: 1.5rem;
  background: linear-gradient(135deg, rgba(25, 60, 50, 0.96), rgba(44, 90, 77, 0.92));
  color: #f7f3ed;
}

.hero-search {
  margin-top: 1rem;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.hero-search input {
  min-width: min(100%, 24rem);
  flex: 1 1 24rem;
  border: 0;
  border-radius: 999px;
  padding: 0.9rem 1rem;
  font: inherit;
}

.hero .eyebrow,
.hero .lead {
  color: rgba(247, 243, 237, 0.84);
}

.metrics-grid {
  margin-top: 1.4rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.metric-card,
.panel,
.case-card {
  background: var(--panel);
  border-radius: 1.3rem;
}

.metric-card {
  padding: 1.2rem;
}

.metric-card strong {
  display: block;
  margin-top: 0.4rem;
  font-size: 2rem;
}

.panel {
  margin-top: 1.4rem;
  padding: 1.3rem;
}

.panel-head,
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.button-link {
  padding: 0.8rem 1rem;
  border: 0;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.button-secondary {
  width: 100%;
  margin-top: 0.8rem;
  background: rgba(25, 60, 50, 0.1);
  color: var(--brand);
}

.inline-button {
  width: auto;
  margin-top: 0;
}

.case-table-wrap {
  margin-top: 1rem;
  overflow-x: auto;
}

.stage-view-panel {
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(244, 239, 231, 0.9)),
    radial-gradient(circle at top left, rgba(25, 60, 50, 0.08), transparent 14rem);
}

.stage-view-summary {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1rem;
}

.stage-view-card {
  padding: 1rem;
  border: 1px solid rgba(25, 60, 50, 0.1);
  border-radius: 1.1rem;
  background: rgba(255, 252, 247, 0.92);
}

.stage-view-card strong {
  display: block;
}

.stage-view-card p {
  margin: 0.45rem 0 0;
}

.case-table {
  width: 100%;
  border-collapse: collapse;
}

.case-table th,
.case-table td {
  padding: 0.9rem 0.7rem;
  text-align: left;
  border-bottom: 1px solid rgba(25, 60, 50, 0.08);
  vertical-align: top;
}

.stage-view-cell {
  display: grid;
  gap: 0.35rem;
}

.stage-view-cell p {
  margin: 0;
}

.case-link {
  color: var(--brand);
  font-weight: 800;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

.pill-urgent {
  background: rgba(196, 71, 45, 0.14);
  color: var(--urgent);
}

.pill-high {
  background: rgba(221, 138, 45, 0.18);
  color: #9a560f;
}

.pill-normal,
.pill-stage {
  background: rgba(41, 95, 77, 0.12);
  color: var(--normal);
}

.pill-low {
  background: rgba(95, 119, 106, 0.14);
  color: var(--low);
}

.pill-active {
  background: rgba(41, 95, 77, 0.12);
  color: var(--normal);
}

.pill-inactive {
  background: rgba(95, 119, 106, 0.14);
  color: var(--low);
}

.pill-prospect {
  background: rgba(221, 138, 45, 0.18);
  color: #9a560f;
}

.case-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: 1rem;
}

.case-card {
  padding: 1.2rem;
}

.case-card-top,
.header-pills {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.9rem;
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.8rem;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(25, 60, 50, 0.12);
  border-radius: 999px;
  background: rgba(255, 252, 247, 0.9);
  color: var(--brand);
  font-weight: 800;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.filter-pill:hover,
.filter-pill:focus-visible {
  border-color: rgba(25, 60, 50, 0.24);
  background: rgba(241, 230, 214, 0.52);
  transform: translateY(-1px);
  outline: none;
}

.filter-pill-active {
  border-color: rgba(25, 60, 50, 0.26);
  background: rgba(25, 60, 50, 0.1);
}

.action-row form {
  margin: 0;
}

.card-snippet {
  color: var(--muted);
}

.work-card {
  display: flex;
  flex-direction: column;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.stage-cockpit {
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(244, 239, 231, 0.92)),
    radial-gradient(circle at top right, rgba(196, 106, 45, 0.08), transparent 15rem);
}

.stage-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.stage-cockpit-hint {
  margin: 0.9rem 0 0;
  color: var(--muted);
  font-weight: 700;
}

.stage-card {
  display: grid;
  gap: 0.9rem;
  padding: 1rem;
  border: 1px solid rgba(25, 60, 50, 0.1);
  border-radius: 1.1rem;
  background: rgba(255, 252, 247, 0.92);
}

.stage-card-current {
  border-color: rgba(25, 60, 50, 0.26);
  box-shadow: inset 0 0 0 1px rgba(25, 60, 50, 0.08);
}

.stage-card-tracked {
  border-color: rgba(196, 106, 45, 0.22);
}

.stage-card-action {
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.stage-card-action:hover,
.stage-card-action:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(25, 60, 50, 0.24);
  box-shadow: 0 1rem 2rem rgba(25, 60, 50, 0.08);
  outline: none;
}

.stage-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.stage-card-head h4 {
  margin: 0;
}

.stage-card-head p {
  margin: 0.35rem 0 0;
}

.stage-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 5.75rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.stage-chip-current {
  background: rgba(25, 60, 50, 0.12);
  color: var(--brand);
}

.stage-chip-tracked {
  background: rgba(196, 106, 45, 0.15);
  color: #9a560f;
}

.stage-chip-pending {
  background: rgba(95, 119, 106, 0.14);
  color: var(--low);
}

.stage-facts {
  display: grid;
  gap: 0.7rem;
  margin: 0;
}

.stage-facts div {
  padding-top: 0.7rem;
  border-top: 1px solid rgba(25, 60, 50, 0.08);
}

.stage-facts dt {
  margin: 0 0 0.2rem;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stage-facts dd {
  margin: 0;
  font-weight: 700;
  line-height: 1.4;
}

.stage-card-cta {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(25, 60, 50, 0.08);
  color: var(--brand);
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stage-card-cta::after {
  content: "→";
  font-size: 1rem;
}

.stage-modal-source {
  display: none;
}

.stage-modal-shell[hidden] {
  display: none;
}

.stage-modal-shell {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.stage-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 32, 27, 0.56);
  backdrop-filter: blur(6px);
}

.stage-modal-dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 72rem);
  max-height: calc(100vh - 3rem);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid rgba(25, 60, 50, 0.12);
  border-radius: 1.5rem;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(244, 239, 231, 0.96)),
    radial-gradient(circle at top right, rgba(196, 106, 45, 0.08), transparent 18rem);
  box-shadow: 0 2rem 5rem rgba(20, 32, 27, 0.24);
  overflow: hidden;
}

.stage-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.35rem;
  border-bottom: 1px solid rgba(25, 60, 50, 0.08);
  background: rgba(255, 252, 247, 0.88);
}

.stage-modal-head h3 {
  margin: 0.2rem 0 0;
}

.stage-modal-close {
  padding: 0.8rem 1rem;
  border: 0;
  border-radius: 999px;
  background: rgba(25, 60, 50, 0.1);
  color: var(--brand);
  font-weight: 800;
  cursor: pointer;
}

.stage-modal-body {
  overflow: auto;
  padding: 0 1.35rem 1.35rem;
}

.stage-modal-body > * {
  margin-top: 1.1rem;
}

.stage-modal-body > :first-child {
  margin-top: 1.35rem;
}

body.modal-open {
  overflow: hidden;
}

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

.panel-wide {
  grid-column: 1 / -1;
}

.section-grid {
  display: grid;
  gap: 1rem;
}

.subpanel {
  padding: 1rem;
  border: 1px solid rgba(25, 60, 50, 0.08);
  border-radius: 1rem;
  background: rgba(241, 230, 214, 0.36);
}

.subpanel h4 {
  margin: 0 0 1rem;
}

.stage-ledger-shell {
  display: grid;
  grid-template-columns: minmax(0, 22rem) minmax(0, 1fr);
  gap: 1rem;
}

.stage-ledger-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.75rem;
}

.stage-ledger-list li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.95rem 1rem;
  border: 1px solid rgba(25, 60, 50, 0.08);
  border-radius: 0.95rem;
  background: rgba(255, 252, 247, 0.7);
}

.stage-ledger-list li p {
  margin: 0.25rem 0 0;
}

.stage-ledger-current {
  border-color: rgba(25, 60, 50, 0.2);
  background: rgba(241, 230, 214, 0.46);
}

.inline-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid rgba(25, 60, 50, 0.12);
  border-radius: 1rem;
  background: rgba(241, 230, 214, 0.46);
}

.requirements-table-wrap {
  overflow-x: auto;
}

.requirements-table {
  width: 100%;
  border-collapse: collapse;
}

.requirements-table th,
.requirements-table td {
  padding: 0.85rem 0.7rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid rgba(25, 60, 50, 0.08);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

.status-manquant {
  background: rgba(196, 71, 45, 0.14);
  color: var(--urgent);
}

.status-depose {
  background: rgba(221, 138, 45, 0.18);
  color: #9a560f;
}

.status-valide {
  background: rgba(41, 95, 77, 0.12);
  color: var(--normal);
}

.inline-upload-form,
.inline-form {
  margin: 0;
}

.file-trigger {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.file-trigger input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.text-action {
  margin-top: 0.55rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--brand);
  font-weight: 700;
  cursor: pointer;
}

.detail-list,
.activity-list,
.doc-list,
.stage-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.detail-list div,
.activity-list li,
.doc-list li,
.stage-list li {
  padding: 0.8rem 0;
  border-bottom: 1px solid rgba(25, 60, 50, 0.08);
}

.doc-list form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.detail-list dt {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.detail-list dd {
  margin: 0.2rem 0 0;
  font-weight: 700;
}

.timeline {
  display: grid;
  gap: 1rem;
}

.timeline-item {
  padding: 1rem;
  border-radius: 1rem;
  background: var(--panel-alt);
}

.timeline-item header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.65rem;
}

.form-stack {
  display: grid;
  gap: 0.9rem;
}

.form-stack label {
  display: grid;
  gap: 0.35rem;
}

.form-stack input,
.form-stack select,
.form-stack textarea {
  width: 100%;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(25, 60, 50, 0.12);
  border-radius: 1rem;
  background: #fffcf7;
  color: var(--text);
}

.form-stack textarea {
  resize: vertical;
  min-height: 8rem;
}

.compact-form {
  margin-bottom: 1rem;
}

.form-stack span {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.flash {
  margin: 0 0 1rem;
  padding: 0.9rem 1rem;
  border-radius: 1rem;
  font-weight: 700;
}

.flash-error {
  background: rgba(196, 71, 45, 0.12);
  color: var(--urgent);
}

.auth-page {
  min-height: 100vh;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.auth-card {
  width: min(100%, 32rem);
  padding: 2rem;
  border-radius: 1.6rem;
  background: var(--panel);
  border: 1px solid rgba(25, 60, 50, 0.1);
  box-shadow: 0 1rem 3rem rgba(25, 60, 50, 0.08);
}

.form-stack input,
.form-stack textarea,
.form-stack select {
  width: 100%;
  border: 1px solid rgba(25, 60, 50, 0.18);
  border-radius: 0.9rem;
  padding: 0.85rem 1rem;
  font: inherit;
  background: #fff;
  color: var(--text);
}

.form-stack textarea {
  resize: vertical;
  min-height: 6rem;
}

.mono {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8rem;
}

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

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

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid rgba(25, 60, 50, 0.12);
  }

  .metrics-grid,
  .detail-grid,
  .stage-ledger-shell,
  .portal-case-summary {
    grid-template-columns: 1fr;
  }

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

  .stage-modal-shell {
    padding: 0.75rem;
  }

  .stage-modal-dialog {
    width: 100%;
    max-height: calc(100vh - 1.5rem);
  }

  .stage-modal-head {
    flex-direction: column;
    align-items: stretch;
  }
}
