:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17212b;
  --muted: #687381;
  --line: #dfe5eb;
  --primary: #126c71;
  --primary-dark: #0d5559;
  --accent: #b66b1c;
  --danger: #b42318;
  --ok: #147a48;
  --shadow: 0 14px 35px rgba(23, 33, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
}

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

button {
  border: 0;
  border-radius: 7px;
  padding: 10px 14px;
  color: #fff;
  background: var(--primary);
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  background: var(--primary-dark);
}

button.secondary {
  background: #edf3f3;
  color: var(--primary-dark);
}

button.danger {
  background: #fff1ef;
  color: var(--danger);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 104px;
  resize: vertical;
}

.sidebar {
  position: sticky;
  top: 0;
  min-height: 100vh;
  height: 100vh;
  overflow-y: auto;
  padding: 24px 18px;
  color: #fff;
  background: #17353a;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 30px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  color: #17353a;
  background: #d6f0ee;
  font-weight: 800;
}

.brand span:last-child {
  display: block;
  margin-top: 3px;
  color: #b9c9cc;
  font-size: 13px;
}

nav {
  display: grid;
  gap: 7px;
}

.nav-button {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #dce8ea;
  font-weight: 650;
}

.nav-button:hover,
.nav-button.active {
  background: rgba(255, 255, 255, 0.13);
}

main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-end;
  margin-bottom: 24px;
}

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

.eyebrow {
  margin: 0 0 5px;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
}

.top-actions {
  display: flex;
  gap: 10px;
  align-items: end;
}

.top-actions label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.view {
  display: none;
}

.db-status {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  margin: -10px 0 18px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 10px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.db-status.error {
  border-color: #f1b4ad;
  background: #fff1ef;
  color: var(--danger);
}

.db-status.ok {
  border-color: #b9e0cb;
  background: #e8f6ef;
  color: var(--ok);
}

.view.active {
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat,
.panel,
.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stat {
  padding: 18px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.stat strong {
  display: block;
  margin-top: 9px;
  font-size: 32px;
}

.panel {
  padding: 18px;
}

.panel-head {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.panel-grid,
.split,
.tour-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(420px, 1.55fr);
  gap: 18px;
  align-items: start;
}

.patient-area {
  display: block;
}

.patient-tab-panel:not(.active) {
  display: none !important;
}

.patient-tab-panel.active {
  display: grid;
}

.patient-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.patient-search-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.patient-table-wrap {
  overflow-x: auto;
  margin: 0 -18px -18px;
}

.patient-table {
  width: 100%;
  min-width: 1280px;
  border-collapse: collapse;
  font-size: 14px;
}

.patient-table th,
.patient-table td {
  border: 1px solid #dce3e7;
  padding: 8px 10px;
  vertical-align: middle;
}

.patient-table th {
  background: #fff;
  color: #31404d;
  text-align: left;
  font-weight: 600;
}

.patient-table tbody tr:nth-child(even) {
  background: #eef3f7;
}

.patient-table tbody tr:hover {
  background: #e1edf4;
}

.orders-layout {
  display: grid;
  grid-template-columns: minmax(620px, 1.35fr) minmax(320px, 0.65fr);
  gap: 18px;
  align-items: start;
}

.paper-order {
  border: 1px solid #8a4d58;
  border-radius: 3px;
  padding: 18px;
  background: #fae7e9;
  box-shadow: 0 12px 30px rgba(118, 52, 63, 0.14);
}

.muster12-page1 {
  display: grid;
  gap: 8px;
  border: 2px solid #7c3845;
  padding: 10px;
  background: #f4d5d9;
  color: #4a1f28;
}

.muster12-head {
  display: grid;
  grid-template-columns: 112px 1fr minmax(220px, 0.62fr);
  gap: 8px;
  align-items: stretch;
}

.muster12-no,
.muster12-title,
.muster12-head label,
.muster12-box {
  border: 1px solid #7c3845;
  background: #fff7f8;
}

.muster12-no {
  display: grid;
  place-items: center;
  min-height: 58px;
  font-size: 20px;
  font-weight: 900;
}

.muster12-title {
  display: grid;
  align-content: center;
  padding: 8px 10px;
}

.muster12-title strong {
  font-size: 18px;
}

.muster12-title span {
  color: #7c3845;
  font-weight: 700;
}

.muster12-head label {
  padding: 7px;
}

.muster12-insured {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 8px;
}

.muster12-box {
  margin: 0;
  border-radius: 0;
  padding: 9px;
}

.muster12-box legend {
  padding: 0 6px;
  color: #4a1f28;
  font-weight: 900;
}

.muster12-page1 label {
  color: #4a1f28;
  font-size: 12px;
  font-weight: 800;
}

.muster12-page1 input,
.muster12-page1 select,
.muster12-page1 textarea {
  min-height: 30px;
  border: 1px solid #b97884;
  border-radius: 0;
  background: #ffffff;
  color: #3d1820;
  padding: 6px 7px;
}

.muster12-page1 input[type="checkbox"],
.muster12-page1 input[type="radio"] {
  width: 15px;
  height: 15px;
  margin: 1px 0 0;
  flex: 0 0 15px;
}

.muster12-page1 textarea {
  min-height: 72px;
}

.muster12-mini-grid,
.muster12-diagnosis-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

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

.muster12-check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 7px 12px;
  margin-bottom: 8px;
}

.muster12-check-grid.three {
  grid-template-columns: repeat(3, minmax(160px, 1fr));
}

.muster12-check-grid.four {
  grid-template-columns: repeat(4, minmax(120px, 1fr));
}

.muster12-check-grid label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.muster12-diagnosis-grid {
  grid-template-columns: 1fr 160px 1fr;
}

.muster12-service-table {
  display: grid;
  grid-template-columns: 1.4fr 0.75fr 0.95fr;
  border: 1px solid #7c3845;
  border-bottom: 0;
  margin: 8px 0;
}

.muster12-service-table span {
  padding: 6px 7px;
  border-right: 1px solid #7c3845;
  border-bottom: 1px solid #7c3845;
  background: #ebbdc3;
  color: #4a1f28;
  font-size: 12px;
  font-weight: 900;
}

.muster12-service-table span:nth-child(3n) {
  border-right: 0;
}

.muster12-service-table input {
  border: 0;
  border-right: 1px solid #7c3845;
  border-bottom: 1px solid #7c3845;
  border-radius: 0;
}

.muster12-service-table input:nth-child(3n) {
  border-right: 0;
}

.muster12-treatment-grid {
  border: 1px solid #d9404d;
  background: #f8c6cb;
}

.muster12-treatment-left {
  display: grid;
}

.muster12-service-group {
  display: grid;
  gap: 5px;
  padding: 7px;
  border-bottom: 1px solid #e35b64;
}

.muster12-service-group strong {
  color: #e00016;
  font-size: 13px;
}

.muster12-service-group label {
  display: inline-flex;
  gap: 6px;
  align-items: flex-start;
  min-height: 24px;
}

.muster12-service-group .inline-field {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
}

.muster12-wound-grid {
  display: grid;
  grid-template-columns: 0.9fr 1.35fr 0.75fr;
  gap: 6px;
}

.compact-group {
  grid-template-columns: 1fr 90px;
  align-items: end;
}

.muster12-frequency-inline {
  display: grid;
  grid-template-columns: repeat(3, auto 42px) auto minmax(70px, 1fr) auto minmax(70px, 1fr);
  align-items: center;
  gap: 0;
  max-width: 560px;
  border: 1px solid #e35b64;
  background: #ffd7da;
}

.muster12-frequency-inline span,
.muster12-frequency-inline input {
  min-height: 26px;
  border: 0;
  border-right: 1px solid #e35b64;
  border-radius: 0;
  padding: 4px;
  font-size: 11px;
}

.muster12-frequency-inline span {
  display: flex;
  align-items: center;
  background: #ffe5e7;
  color: #e00016;
  font-weight: 800;
}

.muster12-frequency-inline input:last-child {
  border-right: 0;
}

.order-page-two {
  margin-top: 18px;
  border-top: 4px double #7c3845;
  padding-top: 14px;
}

.order-page-title {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  border: 2px solid #7c3845;
  padding: 10px;
  background: #ebbdc3;
}

.order-page-title strong {
  font-size: 20px;
}

.paper-order fieldset {
  margin: 0 0 12px;
  border: 1px solid #b97884;
  border-radius: 3px;
  padding: 12px;
  background: rgba(246, 251, 255, 0.72);
}

.paper-order legend {
  padding: 0 7px;
  color: #4a1f28;
  font-weight: 800;
}

.paper-order label {
  display: grid;
  gap: 5px;
  color: #4a1f28;
  font-size: 13px;
  font-weight: 700;
}

.paper-order input,
.paper-order select,
.paper-order textarea {
  border-color: #b97884;
  background: #fff;
}

.paper-order .checkbox-row label,
.plan-toggle {
  display: inline-flex;
  gap: 7px;
  align-items: center;
}

.order-topline {
  display: grid;
  grid-template-columns: 110px 1fr minmax(220px, 0.6fr);
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  border: 2px solid #7c3845;
  padding: 10px;
  background: #ebbdc3;
}

.order-topline strong {
  font-size: 22px;
}

.order-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 8px 0;
}

.paper-order input[type="checkbox"],
.paper-order input[type="radio"] {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
}

.order-lines {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 0.9fr;
  gap: 7px;
}

.page2-lines {
  grid-template-columns: 1.2fr 0.75fr 1fr;
}

.compact {
  gap: 5px;
}

.compact input {
  min-width: 0;
  padding-inline: 7px;
}

#coverageStatus {
  border-color: #b9e0cb;
  background: #e8f6ef;
  color: var(--ok);
  font-weight: 800;
}

#coverageStatus.coverage-bad {
  border-color: #f1b4ad;
  background: #fff1ef;
  color: var(--danger);
}

.order-line-head {
  display: contents;
}

.order-line-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.record-header {
  display: grid;
  grid-template-columns: minmax(240px, 360px) 1fr;
  gap: 18px;
  align-items: end;
  margin-bottom: 18px;
}

.record-header label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
}

.record-summary {
  display: grid;
  gap: 5px;
}

.record-summary span {
  color: var(--muted);
}

.record-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 16px;
}

.record-tab {
  border: 1px solid var(--line);
  background: #fff;
  color: #31404d;
}

.record-tab.active {
  border-color: #3a8585;
  background: #e7f4f2;
  color: #17353a;
}

.record-tab-panel {
  display: none;
}

.record-tab-panel.active {
  display: grid;
}

.record-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
}

.record-list-panel {
  margin-bottom: 28px;
}

.record-timeline {
  display: grid;
  gap: 10px;
}

.record-order-chain {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
}

.chain-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.chain-head h3 {
  margin: 0;
}

.order-accordion {
  border: 1px solid var(--line);
  border-left: 5px solid #8aa0b3;
  border-radius: 8px;
  background: #fff;
}

.order-accordion summary {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  cursor: pointer;
}

.accordion-body {
  display: grid;
  gap: 8px;
  padding: 0 14px 14px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.order-card.order-yellow,
.order-accordion.order-yellow {
  border-color: #f3c15d;
  border-left-color: #c77b00;
  background: #fff9ed;
}

.order-card.order-red,
.order-card.order-expired,
.order-accordion.order-red,
.order-accordion.order-expired {
  border-color: #ee9b92;
  border-left-color: var(--danger);
  background: #fff3f1;
}

.timeline-item {
  box-shadow: none;
}

.form-panel {
  display: grid;
  gap: 12px;
}

.record-grid > .record-tab-panel:not(.active),
.record-list-panel.record-tab-panel:not(.active),
.record-grid > .document-tab-panel:not(.active) {
  display: none !important;
}

.record-grid > .record-tab-panel.active,
.record-list-panel.record-tab-panel.active,
.record-grid > .document-tab-panel.active {
  display: grid;
}

.two-col,
.three-col,
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

.cards,
.list,
.drag-list {
  display: grid;
  gap: 10px;
}

.catalog-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr;
  gap: 10px;
  margin: 14px 0;
}

.catalog-note {
  margin-bottom: 12px;
  border: 1px solid #efdca7;
  border-radius: 7px;
  padding: 10px 12px;
  background: #fff8e6;
  color: #695114;
  font-size: 13px;
  font-weight: 700;
}

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

.catalog-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
  font-size: 14px;
}

.catalog-table th,
.catalog-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

.catalog-table th {
  background: #f4f7f7;
  color: #31404d;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.kva-positions {
  display: grid;
  gap: 6px;
  margin: 10px 0;
}

.kva-position {
  display: grid;
  grid-template-columns: minmax(180px, 2fr) repeat(7, 44px) minmax(100px, 1fr) minmax(90px, 1fr) 70px minmax(110px, 1fr) minmax(110px, 1fr);
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
  background: #f9fbfc;
  font-size: 13px;
  align-items: center;
}

.kva-position-head {
  background: #eef3f7;
  color: #31404d;
  font-weight: 800;
}

.modal.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 29, 35, 0.45);
}

.modal-panel {
  position: relative;
  width: min(980px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  margin: 18px auto;
  overflow: auto;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.25);
}

.modal-actions {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding: 10px;
  background: #fff;
}

.kva-print {
  padding: 28px;
  color: #172326;
  background: #fff;
}

.kva-print-head,
.kva-signatures {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 18px;
}

.kva-address {
  width: 220px;
  min-height: 92px;
  margin-top: 5px;
  border: 1px solid #cfd9df;
  padding: 8px;
}

.kva-address p {
  margin-bottom: 4px;
}

.kva-meta-lines {
  display: grid;
  gap: 5px;
  align-content: start;
}

.kva-meta-lines label {
  display: grid;
  grid-template-columns: 120px 1fr;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.kva-meta-lines input {
  border: 1px solid #cfd9df;
  padding: 4px 6px;
}

.kva-textline {
  margin: 22px -28px 0;
  border-top: 1px solid #cfd9df;
  border-bottom: 1px solid #cfd9df;
  padding: 10px 0;
  color: #31404d;
  font-size: 13px;
}

.kva-print-table-wrap {
  margin: 58px -28px 0;
  overflow-x: auto;
}

.kva-print-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1180px;
  font-size: 13px;
}

.kva-print-table th,
.kva-print-table td {
  border: 1px solid #dce3e7;
  padding: 7px;
  vertical-align: top;
}

.kva-print-table th {
  background: #fff;
  font-weight: 500;
}

.kva-print-table td:not(:first-child),
.kva-print-table th:not(:first-child) {
  text-align: center;
}

.kva-group-row td {
  background: #f7f7f7;
  color: #555;
  font-size: 17px;
  font-weight: 800;
  text-align: left !important;
}

.kva-print-table tr:nth-child(even):not(.kva-group-row):not(.kva-sum-row) {
  background: #eef3f7;
}

.kva-sum-row td {
  border-left: 0;
  border-right: 0;
  font-weight: 800;
}

.kva-sum-row td:first-child {
  text-align: right !important;
}

.kva-smallprint {
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
}

.kva-signatures {
  grid-template-columns: repeat(3, 1fr);
  margin-top: 46px;
}

.kva-signatures div {
  min-height: 72px;
  border-bottom: 1px solid #172326;
  display: flex;
  align-items: flex-end;
  padding-bottom: 6px;
}

.card {
  padding: 14px;
}

.card-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.card h3 {
  margin-bottom: 6px;
  font-size: 16px;
}

.meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  background: #eef3f7;
  color: #31404d;
  font-size: 12px;
  font-weight: 800;
}

.tag.ok {
  background: #e8f6ef;
  color: var(--ok);
}

.tag.warn {
  background: #fff4e5;
  color: #925207;
}

.tag.danger {
  background: #fff1ef;
  color: var(--danger);
}

.patient-chip {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 11px;
  background: #fff;
  cursor: grab;
}

.patient-chip.planned {
  border-color: #9ed2b5;
  background: #f0faf4;
}

.transfer-check {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 7px;
  padding: 6px 10px;
  background: #e8f6ef;
  color: var(--ok);
  font-size: 13px;
  font-weight: 800;
}

.transfer-check::before {
  content: "✓";
  margin-right: 6px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.tour-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(230px, 1fr));
  gap: 12px;
}

.tour-column {
  display: grid;
  min-height: 360px;
  grid-template-rows: auto auto 1fr;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfc;
}

.tour-column header {
  padding: 13px;
  border-bottom: 1px solid var(--line);
}

.tour-column header input,
.tour-column header select {
  margin-top: 8px;
}

.dropzone {
  display: grid;
  align-content: start;
  gap: 9px;
  min-height: 220px;
  padding: 12px;
}

.dropzone.over {
  outline: 2px dashed var(--primary);
  outline-offset: -8px;
}

.tour-stop {
  border: 1px solid #cdd8df;
  border-left: 4px solid var(--accent);
  border-radius: 7px;
  padding: 10px;
  background: #fff;
}

.tour-stop.shifted {
  border-color: #f3c15d;
  border-left-color: #c77b00;
  background: #fff9ed;
}

.tour-stop.conflict {
  border-color: #ee9b92;
  border-left-color: var(--danger);
  background: #fff3f1;
}

.tour-tools {
  display: flex;
  gap: 8px;
  padding: 0 12px 12px;
}

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

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

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

th {
  color: var(--muted);
  font-size: 13px;
}

.schedule-table input,
.schedule-table select {
  min-width: 150px;
}

.settings-panel {
  max-width: 920px;
}

.settings-grid label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
}

.wound-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 9px;
  margin: 12px 0;
}

.wound-grid span {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px;
  background: #fbfcfd;
  color: var(--muted);
  font-size: 13px;
}

.wound-grid strong {
  color: var(--ink);
}

@media (max-width: 1050px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  nav,
  .stats-grid,
  .tour-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split,
  .tour-layout,
  .orders-layout,
  .panel-grid,
  .record-header,
  .record-grid,
  .order-grid,
  .order-topline,
  .order-page-title {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  main {
    padding: 18px;
  }

  .topbar,
  .top-actions,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  nav,
  .stats-grid,
  .tour-board,
  .two-col,
  .three-col,
  .wound-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media print {
  body > .shell {
    display: none !important;
  }

  .modal,
  .modal-panel {
    position: static;
    display: block !important;
    width: auto;
    max-height: none;
    margin: 0;
    overflow: visible;
    box-shadow: none;
  }

  .modal-backdrop,
  .modal-actions {
    display: none !important;
  }

  .kva-print {
    padding: 0;
  }
}
 .app-version { padding: 16px 0; border-top: 1px solid #a8d4f2; color: #111; font-size: 12px; }
 .kva-letterhead { display:flex; justify-content:space-between; align-items:flex-start; gap:20px; margin-bottom:20px; break-inside:avoid; }
 .kva-letterhead img { width:160px; height:70px; object-fit:contain; }
 .kva-letter-text { white-space:pre-wrap; overflow-wrap:anywhere; }
 .kva-letter-footer { border-top:1px solid #ccc; margin-top:24px; padding-top:8px; font-size:10px; break-inside:avoid; }
 @media print { .kva-print thead { display:table-header-group; } .kva-print tr, .kva-signatures { break-inside:avoid; } }
 .database-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 16px; }
 #databaseForm input[type="checkbox"], #databaseConfirm { width: auto; }
 @media print { .app-version { display: none !important; } }
 [hidden] { display: none !important; }
 .access-matrix { width: 100%; table-layout: fixed; }
 .access-matrix select { width: 100%; min-width: 0; }
 .account-create input[type="checkbox"] { width: auto; }
 .client-portal { display: block; background: #fff; color: #111; }
 .client-portal main { margin: 0 auto; padding: 24px; max-width: 1100px; min-width: 0; width: 100%; box-sizing: border-box; }
 .client-portal h1 { font-size: 24px; }
 .portal-message, .portal-document { padding: 16px 0; border-bottom: 1px solid #a8d4f2; overflow-wrap: anywhere; }
 .message-text { white-space: pre-wrap; }
 .client-portal .table-wrap { overflow-x: auto; }
 @media (max-width: 600px) { .client-portal main { padding: 12px; } }
 .client-portal button { background: #fff; color: #111; border: 1px solid #a8d4f2; border-radius: 8px; }
 .client-portal nav { margin-bottom: 24px; }
 .client-portal dd { margin-bottom: 12px; }
 #woundPhotoDialog { width: min(900px, 94vw); max-height: 90vh; overflow: auto; border: 1px solid #a8d4f2; border-radius: 8px; padding: 20px; }
 #woundPhotoDialog input[type="checkbox"] { width: auto; }
 #woundPhotoGallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 16px; margin: 16px 0; }
 .wound-photo { margin: 0; min-width: 0; }
 .wound-photo img { width: 100%; aspect-ratio: 4/3; object-fit: contain; background: #fff; border: 1px solid #a8d4f2; }
 .wound-photo figcaption { font-size: 12px; overflow-wrap: anywhere; }
 #excelImportPanel .table-wrap { overflow: auto; max-height: 440px; }
 #excelImportPanel input[type="checkbox"] { width: auto; }
 #transferDialog { width: min(1100px, 95vw); max-height: 92vh; overflow: auto; border: 1px solid #a8d4f2; border-radius: 8px; padding: 20px; }
 #transferDialog .table-wrap { max-height: 400px; overflow: auto; margin: 16px 0; }
 #transferDialog input[type="checkbox"] { width: auto; }
 #transferDialog select { min-width: 170px; }
 .transfer-open { font-size: 12px; }
 .transfer-toolbar { margin-bottom: 16px; }
.client-detail-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 18px 0; }
.client-detail-fields div { border-bottom: 1px solid #c4dfee; padding: 8px 0; min-width: 0; }
.client-detail-fields dt { font-weight: 600; }
.client-detail-fields dd { margin: 4px 0 0; overflow-wrap: anywhere; white-space: pre-wrap; }
#clientDetails th, #clientDetails td { max-width: 260px; overflow-wrap: anywhere; }
#clientDetails .table-wrap { overflow-x: auto; }
#clientDetails { grid-template-columns: minmax(0, 1fr); min-width: 0; }
#clientDetailContent { min-width: 0; max-width: 100%; }
#clientDetails .record-tabs { min-width: 0; flex-wrap: wrap; }
#clientDetails table { width: max-content; min-width: 100%; }
#clientDetails th, #clientDetails td { min-width: 120px; white-space: normal; }
#clientEntryForm { margin-top: 20px; }
.company-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 16px 0; }
.company-fields label { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.directory-view table { width: 100%; font-size: 13px; }
.directory-view td { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.directory-view tr[data-directory-id] { cursor: pointer; }
.directory-view tr[data-directory-id]:hover, .directory-view tr[data-directory-id]:focus { background: #e8f4ff; }
.directory-view tbody tr:nth-child(even) { background-color: #f5f6f7; }
.directory-view form { margin-top: 20px; }
.directory-view .button-row { align-items: center; }
#company input { min-width: 0; max-width: 100%; }
