.document-kind.consultation, .document-kind.discharge { background: var(--teal-soft); color: #276e67; }
.document-kind.lab_result { background: #eef3fa; color: #496785; }
.document-kind.examination { background: #f0eef8; color: #655687; }
.document-kind.summary { background: #f5f0e6; color: #816536; }
.document-catalog-card .document-card-top { align-items: flex-start; }
.document-catalog-card .document-card-top > :last-child { white-space: normal; }
.document-catalog-card .document-card-foot { flex-wrap: nowrap; }
.document-card-meta { min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.document-ai-label { color: #77559b; font-weight: 700; }
.document-edit-button { position: relative; z-index: 2; display: inline-flex; align-items: center; justify-content: center; gap: 5px; flex: 0 0 auto; min-width: 32px; min-height: 32px; margin: -5px -5px -5px 0; padding: 5px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font: inherit; cursor: pointer; }
.document-edit-button svg { width: 16px; height: 16px; }
.document-inbox { border-color: var(--line); background: var(--surface-soft, #f3f6f4); }
.document-inbox > .document-group-head { border-color: var(--line); }
.document-inbox > .document-group-head b { color: var(--muted); }
.document-state.processing { color: var(--muted); }
.document-state.processing i { background: #81908d; }
.document-edit-button:hover { color: var(--ink); background: var(--surface-soft, #f3f6f4); }
.document-edit-button:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.document-catalog-empty { width: 100%; margin: auto; padding: 32px 16px; color: var(--muted); text-align: center; }
.document-catalog-empty strong { display: block; margin-bottom: 8px; color: var(--ink); }
.document-classification-dialog { width: min(620px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; }
.document-classification-dialog .dialog-head h2 { font: 650 24px/1.25 var(--font-family, sans-serif); }
.document-classification-field { display: grid; gap: 7px; margin-top: 16px; color: var(--ink); font-size: var(--font-small, 14px); font-weight: 600; }
.document-classification-field input, .document-classification-field select { min-width: 0; font: inherit; font-weight: 400; }
.document-classification-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 14px; }
.document-classification-help { margin: 7px 0 0; color: var(--muted); font-size: var(--font-caption, 13px); line-height: 1.45; }
.document-additional-topics { margin-top: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.document-additional-topics summary { color: var(--muted); font-size: var(--font-small, 14px); cursor: pointer; }
.document-topic-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; margin: 12px 0 8px; }
.document-topic-options label { display: flex; align-items: center; gap: 8px; min-height: 32px; font-size: var(--font-caption, 13px); line-height: 1.35; cursor: pointer; }
.document-classification-dialog .document-topic-options input { flex: 0 0 auto; width: 17px; min-height: 17px; height: 17px; margin: 0; padding: 0; accent-color: var(--teal); box-shadow: none; }
.document-topic-options label:has(input:disabled) { opacity: .5; cursor: default; }
.document-classification-error { margin: 16px 0 0; color: var(--rose, #a13e43); font-size: var(--font-small, 14px); line-height: 1.5; }
.document-classification-dialog [hidden] { display: none !important; }
.document-classification-dialog :disabled { cursor: default; }
@media (max-width: 600px) {
  .document-classification-dialog { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); margin: auto; }
  .document-classification-row { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .document-classification-dialog .dialog-head h2 { font-size: 21px; }
  .document-topic-options { grid-template-columns: minmax(0, 1fr); gap: 4px; }
}
/* View switch and flat list: the same filtered documents in one table, newest first. */
.document-view-switch { display: inline-flex; flex: 0 0 auto; gap: 3px; padding: 4px; border: 1px solid var(--line); border-radius: 11px; background: #e8ede9; }
.document-view-switch [data-document-view] { min-height: 36px; padding: 0 13px; border: 0; border-radius: 7px; background: transparent; color: #546661; font: inherit; font-size: var(--font-caption); font-weight: 700; white-space: nowrap; cursor: pointer; }
.document-view-switch [data-document-view]:hover { color: var(--deep); background: rgba(255,255,255,.5); }
.document-view-switch [data-document-view][aria-pressed="true"] { background: white; color: var(--deep); box-shadow: 0 1px 4px rgba(25,57,48,.12); }
.document-view-switch [data-document-view]:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.document-groups.is-list { display: block; overflow-x: hidden; overflow-y: auto; padding: 0; background: white; scroll-snap-type: none; scrollbar-width: thin; scrollbar-color: #a5b5af transparent; container: document-list / inline-size; }
.base-intro .document-view-switch { align-self: end; }
.document-list { display: grid; grid-template-columns: max-content minmax(180px, 3fr) minmax(120px, 1fr) max-content max-content 32px; column-gap: 18px; }
.document-list-head, .document-row { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; align-items: center; padding: 0 16px; }
.document-list-head { position: sticky; top: 0; z-index: 3; min-height: 42px; border-bottom: 1px solid var(--line); background: #f7f9f7; color: var(--muted); font-size: var(--font-caption); font-weight: 600; }
.document-sort { display: inline-flex; align-items: center; gap: 4px; margin: 0 -6px; padding: 5px 6px; border: 0; border-radius: 6px; background: none; color: inherit; font: inherit; cursor: pointer; white-space: nowrap; }
.document-sort i { min-width: .75em; font-style: normal; color: var(--teal); }
.document-sort:hover { color: var(--deep); background: rgba(25,57,48,.06); }
.document-sort.is-active { color: var(--deep); }
.document-sort:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }
.document-row { position: relative; min-height: 54px; padding-block: 9px; border-bottom: 1px solid var(--line-soft); color: var(--muted); font-size: var(--font-caption); line-height: 1.4; }
.document-row:last-child { border-bottom: 0; }
.document-row.is-clickable { cursor: pointer; }
.document-row.is-clickable:hover { background: #f5f9f7; }
.document-row.is-inbox { background: #faf8f1; }
.document-row.is-inbox:hover { background: #f7f2e4; }
.document-row .document-card-hit { border-radius: 0; }
.document-row .document-card-hit:focus-visible { outline-offset: -3px; }
.document-row:focus-visible { outline: 2px solid var(--teal); outline-offset: -2px; }
.document-row > span { min-width: 0; }
.document-row-title strong { display: block; color: var(--ink); font-size: 1rem; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.document-row-title small { display: block; margin-top: 2px; color: var(--muted); font-size: var(--font-caption); overflow-wrap: anywhere; }
.document-row-date { white-space: nowrap; }
.document-row-state { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; }
.document-row-action { display: flex; justify-content: flex-end; }
.document-row .document-edit-button { margin: -5px; }
@media (max-width: 900px) {
  #documentsView .base-intro { align-items: center; }
  .base-intro .document-view-switch { align-self: center; padding: 3px; }
  .base-intro .document-view-switch [data-document-view] { min-height: 34px; padding: 0 11px; }
  .document-groups.is-list { margin-right: 0; padding-right: 0; border-right: 1px solid var(--line); border-radius: 14px; }
}
/* Too narrow for six aligned columns (phones and a desktop sidebar beside a small window): two-line rows. */
@container document-list (max-width: 860px) {
  .document-list { display: block; }
  /* Columns are gone, so the header becomes one row of sort choices. */
  .document-list-head { display: flex; flex-wrap: wrap; gap: 2px 6px; min-height: 0; padding: 6px 8px; }
  .document-list-head > span:empty, .document-sort i:empty { display: none; }
  .document-sort { margin: 0; }
  .document-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-height: 0; padding: 11px 12px; }
  .document-row-title { order: 0; flex: 1 1 calc(100% - 48px); }
  .document-row-action { order: 1; flex: 0 0 auto; margin-left: auto; }
  .document-row-kind, .document-row-topic, .document-row-date, .document-row-state { order: 2; }
  .document-row .is-empty { display: none; }
}
