:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  color: #16302b;
  background: #edf4f0;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.shell {
  width: min(42rem, 100%);
  padding: clamp(1.5rem, 5vw, 3rem);
  border: 1px solid #c9d8d1;
  border-radius: 1.25rem;
  background: #ffffff;
  box-shadow: 0 1rem 3rem rgb(22 48 43 / 10%);
}

.auth-shell {
  max-width: 31rem;
}

.profile-shell,
.message-shell {
  max-width: 38rem;
}

.admin-shell {
  width: min(70rem, 100%);
}

.eyebrow {
  margin: 0;
  color: #337968;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0.5rem 0 1rem;
  font-size: clamp(2rem, 7vw, 3.25rem);
  line-height: 1.05;
}

h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
}

p {
  line-height: 1.65;
}

.intro {
  margin-bottom: 1.5rem;
  color: #49635d;
}

.stacked-form {
  display: grid;
  gap: 1.15rem;
}

.form-field {
  display: grid;
  gap: 0.45rem;
}

label,
dt {
  color: #294840;
  font-size: 0.9rem;
  font-weight: 700;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"] {
  width: 100%;
  min-height: 3rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid #9bb4ab;
  border-radius: 0.65rem;
  color: #16302b;
  background: #fbfdfc;
  font: inherit;
}

input[type="date"] {
  width: 100%;
  min-height: 3rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid #9bb4ab;
  border-radius: 0.65rem;
  color: #16302b;
  background: #fbfdfc;
  font: inherit;
}

textarea {
  width: 100%;
  min-height: 7rem;
  resize: vertical;
  padding: 0.7rem 0.85rem;
  border: 1px solid #9bb4ab;
  border-radius: 0.65rem;
  color: #16302b;
  background: #fbfdfc;
  font: inherit;
}

select {
  width: 100%;
  min-height: 3rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid #9bb4ab;
  border-radius: 0.65rem;
  color: #16302b;
  background: #fbfdfc;
  font: inherit;
}

input:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgb(23 107 88 / 28%);
  outline-offset: 2px;
}

.primary-button,
.secondary-button,
.primary-link {
  display: inline-block;
  min-height: 3rem;
  padding: 0.8rem 1.1rem;
  border: 0;
  border-radius: 0.7rem;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.primary-button,
.primary-link {
  color: #ffffff;
  background: #176b58;
}

.primary-button:hover,
.primary-link:hover {
  background: #0f5143;
}

.secondary-button {
  width: 100%;
  color: #174f43;
  background: #dceae5;
}

.danger-button {
  min-height: 3rem;
  padding: 0.8rem 1.1rem;
  border: 0;
  border-radius: 0.7rem;
  color: #ffffff;
  background: #9b3d2f;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.secondary-button:hover {
  background: #c9ded6;
}

.text-link {
  display: inline-block;
  margin: 1rem 0 0 0.75rem;
  color: #176b58;
  font-weight: 700;
}

.alert {
  margin: 1rem 0 1.25rem;
  padding: 0.85rem 1rem;
  border: 1px solid #e6b6aa;
  border-radius: 0.65rem;
  color: #713326;
  background: #fff1ed;
  line-height: 1.5;
}

.alert-success {
  border-color: #a9d4c5;
  color: #174f43;
  background: #eaf6f1;
}

.action-grid {
  display: grid;
  gap: 0.75rem;
  margin: 1.5rem 0;
}

.catalog-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #d3e0db;
}

.catalog-nav a,
.catalog-card a {
  color: #176b58;
  font-weight: 700;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(18rem, 100%), 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.catalog-card {
  padding: 1.15rem;
  border: 1px solid #d3e0db;
  border-radius: 0.8rem;
  background: #f8fbfa;
}

.catalog-card dl,
.catalog-details {
  display: grid;
  gap: 0.75rem;
  margin: 1rem 0 0;
}

.catalog-card dl div,
.catalog-details div {
  display: grid;
  gap: 0.2rem;
}

.catalog-card dd,
.catalog-details dd {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.search-form {
  margin-top: 1rem;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  margin-top: 0.4rem;
}

.compact-button {
  width: auto;
}

.pagination,
.delete-form {
  margin-top: 1.5rem;
}

.field-error {
  color: #713326;
}

.empty-state {
  color: #59716b;
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.admin-panel {
  margin-top: 1.5rem;
  padding: 1.25rem;
  border: 1px solid #d3e0db;
  border-radius: 0.8rem;
  background: #f8fbfa;
}

.admin-panel h2 {
  margin-bottom: 1rem;
}

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

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

th,
td {
  padding: 0.8rem;
  border-bottom: 1px solid #d3e0db;
  text-align: left;
  vertical-align: top;
}

th {
  color: #294840;
  font-size: 0.82rem;
  text-transform: uppercase;
}

td a {
  color: #176b58;
  font-weight: 700;
}

.status {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  color: #174f43;
  background: #dceae5;
  font-size: 0.82rem;
  font-weight: 700;
}

.status-suspended,
.status-archived,
.status-abandoned {
  color: #713326;
  background: #fff1ed;
}

.status-resolved {
  color: #174f43;
  background: #cceadd;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

small {
  color: #59716b;
}

.profile-card {
  margin: 1.5rem 0;
  padding: 1.35rem;
  border: 1px solid #d3e0db;
  border-radius: 0.8rem;
  background: #f8fbfa;
}

.person-name {
  margin: 0.5rem 0 0;
  font-size: 1.4rem;
  font-weight: 750;
}

.muted {
  margin: 0.15rem 0 1.25rem;
  color: #59716b;
}

.identity-details {
  display: grid;
  gap: 0.9rem;
  margin: 0;
}

.identity-details div {
  display: grid;
  gap: 0.2rem;
}

.identity-details dd {
  margin: 0;
}

.technical-value {
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.9rem;
}

.intervention-shell {
  width: min(76rem, 100%);
}

.filter-panel,
.workflow-step,
.intervention-panel,
.context-card,
.chat-panel {
  margin-top: 1.25rem;
  padding: 1.15rem;
  border: 1px solid #d3e0db;
  border-radius: 0.85rem;
  background: #f8fbfa;
}

.filter-grid,
.context-grid,
.resolution-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(13rem, 100%), 1fr));
  gap: 0.85rem;
}

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

.filter-search {
  grid-column: span 2;
}

.filter-panel > button {
  margin-top: 0.85rem;
}

.intervention-section {
  margin-top: 2rem;
}

.intervention-section > h2,
.intervention-panel > h2,
.chat-panel h2 {
  margin-bottom: 0.85rem;
  font-size: 1.25rem;
}

.intervention-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(21rem, 100%), 1fr));
  gap: 1rem;
}

.intervention-card {
  padding: 1.1rem;
  border: 1px solid #d3e0db;
  border-radius: 0.8rem;
  background: #fff;
}

.card-heading,
.panel-heading,
.button-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.card-heading h3 {
  margin: 0;
  font-size: 1.05rem;
}

.card-heading a {
  color: #176b58;
}

.intervention-card dl,
.context-grid {
  margin: 1rem 0 0;
}

.intervention-card dl {
  display: grid;
  gap: 0.5rem;
}

.intervention-card dl div,
.context-grid div {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 0.5rem;
}

.intervention-card dd,
.context-grid dd {
  margin: 0;
}

.resolution-preview {
  margin-bottom: 0;
  padding-top: 0.7rem;
  border-top: 1px solid #d3e0db;
  color: #49635d;
}

.workflow-step {
  display: grid;
  gap: 1rem;
  margin: 0;
}

.workflow-step legend {
  padding: 0 0.45rem;
  color: #174f43;
  font-weight: 800;
}

.workflow-step legend span {
  display: inline-grid;
  width: 1.8rem;
  height: 1.8rem;
  margin-right: 0.35rem;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: #176b58;
}

.notice,
.readonly-banner,
.chat-warning {
  padding: 0.8rem 1rem;
  border-radius: 0.65rem;
  color: #4f4817;
  background: #fff6cf;
}

.compact-copy {
  margin: 0;
}

.document-picker,
.document-list {
  display: grid;
  gap: 0.65rem;
}

.document-choice,
.document-option {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem;
  border: 1px solid #cadbd4;
  border-radius: 0.65rem;
  background: #fff;
}

.document-choice {
  cursor: pointer;
}

.document-choice input {
  width: 1.2rem;
  height: 1.2rem;
  margin-top: 0.1rem;
}

.document-choice span,
.document-option > div {
  display: grid;
  flex: 1;
  gap: 0.25rem;
}

.inline-link {
  margin: 0;
}

.document-editor {
  margin-top: 1rem;
}

.document-editor summary {
  color: #176b58;
  font-weight: 750;
  cursor: pointer;
}

.document-editor form {
  margin-top: 0.85rem;
}

.intervention-heading {
  align-items: center;
}

.problem-description {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #d3e0db;
}

.problem-description p {
  margin-bottom: 0;
  white-space: pre-wrap;
}

.conversation {
  max-height: min(58vh, 38rem);
  overflow-y: auto;
  display: grid;
  gap: 0.85rem;
  padding: 0.5rem;
  scroll-behavior: smooth;
}

.message {
  width: min(88%, 46rem);
  padding: 0.85rem 1rem;
  border-radius: 0.85rem;
}

.message-user {
  justify-self: end;
  color: #fff;
  background: #176b58;
}

.message-assistant {
  justify-self: start;
  border: 1px solid #cadbd4;
  background: #fff;
}

.message-pending {
  opacity: 0.65;
}

.message-content {
  margin-top: 0.4rem;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.chat-actions {
  display: grid;
  gap: 0.7rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #d3e0db;
}

.chat-error,
.chat-warning {
  margin-bottom: 0;
}

.generation-state {
  min-height: 1.5rem;
  color: #337968;
  font-weight: 700;
}

.is-disabled {
  pointer-events: none;
  opacity: 0.6;
}

.mutation-panel {
  display: grid;
  gap: 1.5rem;
}

@media (max-width: 32rem) {
  body {
    padding: 0.75rem;
  }

  .shell {
    padding: 1.35rem;
    border-radius: 0.9rem;
  }

  .primary-button,
  .primary-link {
    width: 100%;
    text-align: center;
  }

  .text-link {
    margin-left: 0;
  }

  .page-heading {
    display: block;
  }

  .search-row {
    grid-template-columns: 1fr;
  }

  .compact-button,
  .danger-button {
    width: 100%;
  }

  .filter-search {
    grid-column: auto;
  }

  .card-heading,
  .panel-heading,
  .button-row,
  .document-option {
    align-items: stretch;
    flex-direction: column;
  }

  .intervention-card dl div,
  .context-grid div {
    grid-template-columns: 1fr;
  }

  .message {
    width: 96%;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  tr {
    padding: 0.65rem 0;
    border-bottom: 1px solid #d3e0db;
  }

  td {
    display: grid;
    grid-template-columns: 7rem 1fr;
    gap: 0.5rem;
    padding: 0.45rem 0;
    border: 0;
  }

  td[data-label]::before {
    content: attr(data-label);
    color: #294840;
    font-weight: 700;
  }
}
