: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 {
  min-height: 100vh;
  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;
}

.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 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 {
  display: grid;
  grid-template-columns: minmax(460px, 1fr) 260px;
  gap: 0;
  border: 1px solid #d9404d;
  background: #f8c6cb;
}

.muster12-treatment-left {
  display: grid;
  border-right: 2px solid #e35b64;
}

.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: center;
  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 70px;
  align-items: end;
}

.muster12-frequency-box {
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 7px;
  background: #ffd7da;
}

.muster12-frequency-box strong {
  color: #e00016;
  font-size: 11px;
  line-height: 1.2;
}

.muster12-frequency-table {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, 34px) repeat(2, 48px);
  border: 1px solid #e35b64;
  border-bottom: 0;
}

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

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

.muster12-frequency-table span:nth-child(6n),
.muster12-frequency-table input:nth-child(6n) {
  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: auto;
}

.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-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;
}

.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;
}

.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;
}

.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-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;
  }
}
