:root {
  --bg: #f5ede8;
  --paper: #ffffff;
  --paper-soft: #faf6f4;
  --ink: #2a1f1f;
  --ink-soft: #7a5242;
  --accent: #6b1f2a;
  --accent-deep: #4a1520;
  --line: rgba(107, 31, 42, 0.18);
  --danger: #a52e28;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 9% 8%, rgba(107, 31, 42, 0.08), transparent 42%),
    radial-gradient(ellipse at 92% 2%, rgba(196, 154, 24, 0.09), transparent 38%),
    linear-gradient(170deg, #fdf3ef, var(--bg) 58%);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

h1,
h2,
h3 {
  font-family: "Fraunces", "Georgia", serif;
}

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 16px 34px;
}

header {
  margin-bottom: 12px;
}

.brand {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 20px;
  align-items: center;
  border-radius: 24px;
  padding: 22px 24px;
  background: linear-gradient(116deg, rgba(42, 15, 22, 0.97), rgba(74, 21, 32, 0.95));
  color: #f5ece8;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 16px 30px rgba(74, 21, 32, 0.22);
}

.brand-logo {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

header h1 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.8rem);
  line-height: 1.08;
}

header p {
  margin: 7px 0 0;
  color: #d4a090;
}

.tagline {
  font-size: 0.9rem;
  color: #c09080;
}

.brand-actions {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.source-button {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.14);
  color: #f5ece8;
  border: 1px solid rgba(245, 236, 232, 0.38);
  border-radius: 8px;
  padding: 9px 14px;
  font-weight: 700;
  min-height: 40px;
  letter-spacing: 0.02em;
  transition: background 90ms ease;
}

.brand-actions .source-button {
  margin-right: 0;
}

.source-button:hover {
  background: rgba(255, 255, 255, 0.18);
}

.source-button:active {
  background: rgba(255, 255, 255, 0.08);
}

.back-to-top {
  position: fixed;
  right: 16px;
  bottom: 20px;
  z-index: 1200;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: #6b1f2a;
  color: #ffffff;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  box-shadow: 0 3px 0 #4a1520, 0 6px 14px rgba(74, 21, 32, 0.22);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease, visibility 160ms ease;
}

.back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}


.hint {
  color: var(--ink-soft);
  margin: 0;
  line-height: 1.4;
}

.runtime-notice {
  margin-top: 8px;
  color: #f5ece8;
  background: rgba(42, 15, 22, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  padding: 8px 10px;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 12px 22px rgba(74, 21, 32, 0.08);
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 1.3rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}

.between {
  justify-content: space-between;
  align-items: center;
}

.field-label {
  min-width: 290px;
  font-weight: 600;
  color: var(--ink-soft);
}

input:not([type="checkbox"]):not([type="radio"]),
select,
button {
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.92rem;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus {
  outline: 2px solid rgba(107, 31, 42, 0.45);
  outline-offset: 1px;
}

input:not([type="checkbox"]):not([type="radio"]),
select {
  background: #fff;
  color: var(--ink);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237a5242' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
  cursor: pointer;
}

input:not([type="checkbox"]):not([type="radio"]) {
  min-width: 290px;
}

button {
  border: 0;
  background: #6b1f2a;
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.02em;
  min-height: 40px;
  border-radius: 8px;
  box-shadow: 0 3px 0 #4a1520, inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: background 90ms ease, transform 70ms ease, box-shadow 70ms ease;
}

button:hover {
  background: #8b2535;
}

button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #4a1520, inset 0 1px 0 rgba(0, 0, 0, 0.06);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.44;
  box-shadow: none;
  transform: none;
}

.hidden,
[hidden] {
  display: none !important;
}

.download-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.download-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  background: #fdf3ef;
  border: 1px solid rgba(107, 31, 42, 0.2);
  color: #6b1f2a;
  font-weight: 700;
  border-radius: 8px;
  padding: 8px 11px;
  min-height: 38px;
  box-shadow: 0 2px 0 rgba(107, 31, 42, 0.25);
  transition: background 90ms ease, transform 70ms ease, box-shadow 70ms ease;
  letter-spacing: 0.01em;
}

.download-link:hover {
  background: #f9e8e3;
}

.download-link:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 rgba(107, 31, 42, 0.25);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  background: #fff;
}

th,
td {
  padding: 9px;
  border: 1px solid var(--line);
  text-align: left;
  font-size: 0.87rem;
  vertical-align: top;
}

th {
  background: var(--paper-soft);
  color: #5a1e28;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.73rem;
}

.multiline-cell {
  white-space: normal;
}

.debridement-line {
  color: #b42318;
  font-weight: 700;
}

.safety-line {
  color: #7e1114;
  font-weight: 700;
}

.data-quality-line {
  display: inline-block;
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 0.76rem;
  font-weight: 700;
  color: #8b3a04;
  background: #fff3e8;
  border: 1px solid #f2c7a5;
}

.confidence-line {
  display: inline-block;
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 0.76rem;
  font-weight: 700;
  color: #5a1e28;
  background: #f5e8e4;
  border: 1px solid #e8d0cb;
}

.response-line {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.response-pill {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.74rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.response-pill.improving {
  color: #2a5a30;
  background: #d8f4ea;
  border-color: #9ad9c2;
}

.response-pill.worsening {
  color: #8b1d18;
  background: #fde7e5;
  border-color: #f3bbb4;
}

.response-pill.mixed {
  color: #6b4b00;
  background: #fff4d8;
  border-color: #f1db9d;
}

.response-pill.indeterminate {
  color: #375166;
  background: #f5e4df;
  border-color: #c4d9ea;
}

.response-metric {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.72rem;
  background: #f1f8fd;
  border: 1px solid #ead8d3;
  color: #23465e;
}

.qa-box {
  border: 1px solid #e8d0cb;
  border-radius: 9px;
  background: #fdf9f7;
  padding: 7px 8px;
}

.qa-title {
  margin: 0 0 5px;
  font-size: 0.74rem;
  font-weight: 700;
  color: #5a1e28;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.qa-grid {
  display: grid;
  gap: 4px;
}

.qa-line {
  display: grid;
  grid-template-columns: minmax(118px, 160px) minmax(0, 1fr);
  gap: 8px;
  font-size: 0.78rem;
}

.qa-label {
  font-weight: 700;
  color: #6b2030;
}

.qa-value {
  color: #5a2030;
}

.qa-value.qa-muted {
  color: #547088;
}

.qa-drawer summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
}

.qa-drawer summary::-webkit-details-marker {
  display: none;
}

.qa-drawer summary::before,
.qa-drawer summary::after {
  color: #5a1e28;
  font-size: 0.78rem;
  line-height: 1;
}

.qa-drawer summary::before {
  content: "\25B8";
}

.qa-drawer summary::after {
  content: "\25C2";
}

.qa-drawer[open] summary::before,
.qa-drawer[open] summary::after {
  content: "\25BE";
}

.qa-drawer .qa-box {
  margin-top: 8px;
}

.qa-drawer .qa-title {
  text-align: center;
}

.qa-drawer .qa-line {
  grid-template-columns: 1fr;
  gap: 2px;
  text-align: center;
  justify-items: center;
}

.why-drawer-wrap {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}

.why-drawer {
  border: 1px dashed #b8d4e4;
  border-radius: 8px;
  padding: 6px 8px;
  background: #fdfaf8;
}

.why-drawer summary {
  cursor: pointer;
  font-weight: 700;
  color: #5a1e28;
}

.why-drawer ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.why-drawer li {
  margin-bottom: 5px;
}

.step-spacer {
  display: inline-block;
  height: 10px;
  width: 100%;
}

.manual-field {
  display: grid;
  gap: 5px;
  color: #245b75;
  font-weight: 700;
  font-size: 0.84rem;
}

.manual-field input,
.manual-field select,
.manual-field textarea {
  width: 100%;
  min-width: 0;
}

.manual-field textarea {
  min-height: 72px;
  resize: vertical;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

.manual-wound-list {
  display: grid;
  gap: 10px;
}

.manual-wound-card {
  border: 1px solid rgba(107, 31, 42, 0.18);
  border-radius: 10px;
  background: #fdf9f7;
  padding: 10px;
}

.manual-wound-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.manual-wound-title {
  margin: 0;
  font-size: 1.05rem;
}

.manual-remove-btn,
.manual-secondary-btn {
  background: #f0f8fd;
  color: #5a1e28;
  border: 1px solid rgba(107, 31, 42, 0.2);
  box-shadow: 0 2px 0 rgba(107, 31, 42, 0.25);
}

.manual-remove-btn:hover,
.manual-secondary-btn:hover {
  background: #e2f0f9;
}

.manual-remove-btn {
  padding: 7px 10px;
  border-radius: 9px;
  font-size: 0.82rem;
}

.manual-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
}

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

.manual-measure-grid,
.manual-check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

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

.manual-check-section {
  border: 1px dashed #dcc7c2;
  border-radius: 10px;
  padding: 8px;
  background: #fdfbf9;
}

.manual-check-section h4 {
  margin: 0 0 7px;
  font-size: 0.82rem;
  color: #5a1e28;
}

.manual-check-grid label {
  display: grid;
  grid-template-columns: 15px 1fr;
  gap: 6px;
  align-items: start;
  color: #5a1e28;
  font-size: 0.8rem;
  font-weight: 600;
}

.manual-check-grid input {
  min-width: 0;
  margin: 3px 0 0;
}

.manual-prior {
  margin-top: 10px;
  border-top: 1px solid rgba(107, 31, 42, 0.14);
  padding-top: 10px;
}

.manual-prior summary {
  cursor: pointer;
  font-weight: 800;
  color: #5a1e28;
}

.manual-actions {
  display: flex;
  justify-content: stretch;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.manual-actions button {
  flex: 1 1 160px;
}

.manual-empty {
  margin: 0;
  padding: 10px;
  border: 1px dashed #dcc7c2;
  border-radius: 10px;
  color: var(--ink-soft);
  background: #fdfaf8;
}

.jump-target {
  animation: jumpFlash 2100ms ease;
}

.panel,
.brand {
  animation: liftIn 540ms ease both;
}

@keyframes liftIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes jumpFlash {
  0% {
    background: #fff8de;
    outline: 2px solid #f2b200;
    outline-offset: -2px;
  }
  100% {
    background: transparent;
    outline: 0 solid transparent;
    outline-offset: 0;
  }
}

@media (max-width: 800px) {
  .brand {
    grid-template-columns: 64px 1fr;
    gap: 14px;
  }

  .brand-logo {
    width: 56px;
    height: 56px;
  }

  .back-to-top {
    right: 12px;
    bottom: 14px;
    padding: 9px 12px;
  }

  header h1 {
    font-size: 1.75rem;
  }

  .field-label {
    min-width: 100%;
  }

  input:not([type="checkbox"]):not([type="radio"]),
  select {
    min-width: 100%;
    width: 100%;
  }

  .manual-grid {
    grid-template-columns: 1fr;
  }

  .manual-actions button {
    width: 100%;
  }

  .settings-danger-actions {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .narrative-controls {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .narrative-controls select {
    min-width: 0;
    flex: 1 1 160px;
  }

  .hipaa-actions {
    flex-wrap: wrap;
  }

  .hipaa-actions button {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
  }

  .settings-item-actions {
    flex-wrap: wrap;
  }

  .settings-item-actions input {
    min-width: 0;
    flex: 1 1 auto;
  }

  .download-group {
    gap: 6px;
  }
}

/* ── Small phones (≤ 480 px) ─────────────────────────────── */
@media (max-width: 480px) {
  .app {
    padding: 14px 10px 44px;
  }

  .brand {
    padding: 14px 12px;
    border-radius: 18px;
    gap: 8px;
  }

  .brand-logo {
    width: 48px;
    height: 48px;
  }

  header h1 {
    font-size: 1.45rem;
    line-height: 1.12;
  }

  header p {
    font-size: 0.86rem;
  }

  .tagline {
    font-size: 0.8rem;
  }

  .brand-actions {
    margin-top: 8px;
    gap: 7px;
  }

  .source-button {
    padding: 10px 12px;
    font-size: 0.86rem;
    min-height: 44px;
  }

  .panel {
    padding: 12px 10px;
    border-radius: 14px;
    margin-bottom: 10px;
  }

  .panel h2 {
    font-size: 1.12rem;
  }

  button {
    min-height: 44px;
    padding: 11px 12px;
    font-size: 0.9rem;
  }

  .download-link {
    min-height: 44px;
    font-size: 0.88rem;
    padding: 10px 10px;
    flex: 1 1 calc(50% - 4px);
    justify-content: center;
    text-align: center;
  }

  .download-group {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .meta-grid {
    grid-template-columns: 1fr;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .hipaa-actions button {
    flex: 1 1 100%;
  }

  .manual-wound-head {
    flex-wrap: wrap;
    gap: 8px;
  }

  .manual-measure-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .manual-check-grid {
    grid-template-columns: 1fr;
  }

  .qa-line {
    grid-template-columns: 1fr;
    gap: 1px;
  }

  .qa-label {
    margin-bottom: 1px;
  }

  .supplies-grid {
    grid-template-columns: 1fr;
  }

  .audit-summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .narrative-view {
    min-height: 180px;
    font-size: 0.9rem;
  }

  th {
    font-size: 0.68rem;
    padding: 7px 6px;
  }

  td {
    font-size: 0.82rem;
    padding: 7px 6px;
  }

  .response-pill {
    font-size: 0.72rem;
    padding: 2px 7px;
  }

  .row.between {
    align-items: flex-start;
  }
}

/* ── Safe area for notched/dynamic-island phones ─────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  @media (max-width: 800px) {
    .app {
      padding-bottom: max(34px, env(safe-area-inset-bottom));
    }

    .back-to-top {
      bottom: max(14px, env(safe-area-inset-bottom));
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .panel,
  .brand {
    animation: none;
  }

  .jump-target {
    animation: none;
  }
}


.sources-list {
  margin: 0;
  padding-left: 20px;
}

.sources-list li {
  margin-bottom: 6px;
}

#sourcesPanel h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.narrative-view {
  width: 100%;
  min-height: 220px;
  max-height: 640px;
  overflow: auto;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
}

.narrative-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.narrative-controls label {
  font-weight: 700;
  color: #5a1e28;
  font-size: 0.84rem;
}

.narrative-controls select {
  min-width: 180px;
  padding: 7px 9px;
  font-size: 0.84rem;
}

.narrative-empty {
  margin: 0;
  color: var(--ink-soft);
}

.narrative-patient {
  padding: 10px 0 12px;
  border-bottom: 1px solid #ead8d3;
}

.narrative-patient:last-child {
  border-bottom: 0;
}

.narrative-patient-header {
  font-size: 1.08rem;
  font-weight: 800;
  color: #4a1520;
  margin-bottom: 8px;
  line-height: 1.35;
}

.narrative-patient-header strong {
  font-size: 1.13rem;
  font-weight: 800;
}

.narrative-wound {
  margin: 0 0 9px;
  line-height: 1.48;
}

.narrative-wound:last-child {
  margin-bottom: 0;
}

.narrative-summary {
  margin: 0;
  line-height: 1.52;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.settings-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fdf9f7;
  padding: 10px;
  display: grid;
  gap: 10px;
}

.settings-item h3 {
  margin: 0 0 4px;
  font-size: 0.98rem;
}

.settings-item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.settings-item-actions button {
  padding: 8px 11px;
  font-size: 0.84rem;
  border-radius: 9px;
}

.settings-item-actions input {
  min-width: 0;
}

.settings-danger {
  border-color: rgba(165, 46, 40, 0.38);
  background: #fff5f4;
}

.settings-danger h3 {
  color: var(--danger);
}

.settings-danger-actions {
  display: grid;
  grid-template-columns: 1fr auto;
}

.settings-danger-actions input {
  width: 100%;
  min-width: 220px;
}

.settings-danger-actions button {
  background: #8f2318;
  box-shadow: 0 3px 0 #5c1410, inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.settings-danger-actions button:hover {
  background: #a12920;
}


.hipaa-policy-grid {
  display: grid;
  gap: 8px;
}

.hipaa-field {
  display: grid;
  gap: 4px;
  font-size: 0.82rem;
  color: #5a1e28;
}

.hipaa-field input[type="number"],
.hipaa-field input[type="password"] {
  width: 100%;
}

.hipaa-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: #5a1e28;
}

.hipaa-actions button {
  min-width: 120px;
}

.audit-log-meta {
  margin: 8px 0 6px;
  font-size: 0.82rem;
  color: #6b2030;
}

.supplies-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.audit-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin: 8px 0 4px;
}

.audit-summary-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fdf9f7;
}

.audit-summary-card .label {
  display: block;
  font-size: 0.74rem;
  color: #7a4048;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.audit-summary-card .value {
  display: block;
  margin-top: 2px;
  font-size: 1.03rem;
  font-weight: 800;
  color: #103e56;
}

.audit-warning-list {
  margin: 8px 0 0;
  padding-left: 20px;
  color: #7e1114;
}

.audit-warning-list li {
  margin-bottom: 4px;
}

.print-packet-content {
  display: none;
}

.print-patient {
  background: #fff;
  border: 1px solid #ead8d3;
  border-radius: 12px;
  padding: 16px 18px;
  margin: 0 0 14px;
  break-after: page;
  page-break-after: always;
}

.print-patient:last-child {
  break-after: auto;
  page-break-after: auto;
}

.print-patient-header {
  margin-bottom: 8px;
  border-bottom: 1px solid #e8d5d0;
  padding-bottom: 7px;
}

.print-patient-name {
  margin: 0;
  font-size: 1.1rem;
  color: #4a1520;
}

.print-patient-meta {
  margin: 3px 0 0;
  color: #7a4048;
  font-size: 0.8rem;
}

.print-wound {
  margin: 0 0 10px;
  padding: 8px 9px;
  border: 1px dashed #e5cec9;
  border-radius: 8px;
  background: #fbfdff;
}

.print-wound:last-child {
  margin-bottom: 0;
}

.print-wound h4 {
  margin: 0 0 4px;
  font-size: 0.9rem;
  color: #5a1e28;
}

.print-wound p {
  margin: 3px 0;
  font-size: 0.8rem;
  line-height: 1.35;
}

body.print-packet-mode .back-to-top {
  display: none !important;
}

body.print-packet-mode main > section,
body.print-packet-mode main > header {
  display: none !important;
}

body.print-packet-mode #printPacketPanel {
  display: block !important;
}

body.print-packet-mode #printPacketContent {
  display: block !important;
}

@media print {
  body {
    background: #fff !important;
  }

  .app {
    max-width: none;
    padding: 0;
  }

  .back-to-top {
    display: none !important;
  }
}

.tissue-pct-alert {
  display: none;
  margin-top: 6px;
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 700;
  background: #fff3f2;
  border: 1px solid #f5b8b5;
  color: #8f2318;
}

.tissue-pct-alert.is-visible {
  display: block;
}

.tissue-pct-total {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.76rem;
  color: #7a4048;
  font-weight: 600;
}

.phrase-grid {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.phrase-field {
  border: 1px solid #e8d5d0;
  border-radius: 10px;
  padding: 8px;
  background: #fdfaf8;
  display: grid;
  gap: 5px;
}

.phrase-field label {
  font-size: 0.8rem;
  font-weight: 800;
  color: #5a1e28;
}

.phrase-field textarea {
  width: 100%;
  min-height: 64px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.83rem;
  line-height: 1.35;
  resize: vertical;
}

.phrase-field .phrase-help {
  margin: 0;
  color: #4f6a7d;
  font-size: 0.75rem;
  line-height: 1.35;
}

.supply-group {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #fdf9f8;
}

.supply-group h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.supply-option {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 7px;
  align-items: start;
  margin-bottom: 6px;
}

.supply-option input {
  min-width: 0;
  margin-top: 2px;
}

.wound-type-cell {
  min-width: 370px;
}



    
/* ── Name Gate & Terms Dialog ─────────────────────────── */
body.name-gate-active {
  overflow: hidden;
}

body.name-gate-active .back-to-top {
  display: none !important;
}

.name-gate-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: rgba(42, 15, 22, 0.52);
  backdrop-filter: blur(8px);
}

.name-gate-overlay[hidden] {
  display: none !important;
}

.name-gate-card {
  width: min(100%, 560px);
  max-height: calc(100vh - 48px);
  overflow: auto;
  display: grid;
  gap: 14px;
  border: 1px solid rgba(107, 31, 42, 0.2);
  border-radius: 18px;
  padding: 22px;
  background: linear-gradient(180deg, #fffdfc, #fdf6f3);
  box-shadow: 0 28px 70px rgba(42, 15, 22, 0.32);
}

.name-gate-top {
  display: flex;
  gap: 12px;
  align-items: center;
}

.name-gate-mark {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 14px;
  background: linear-gradient(116deg, rgba(42, 15, 22, 0.97), rgba(74, 21, 32, 0.95));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.name-gate-kicker {
  display: block;
  color: #7a4048;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.name-gate-card h2 {
  margin: 2px 0 0;
  color: #4a1520;
  font-size: 1.45rem;
  line-height: 1.15;
}

.name-gate-copy {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.45;
}

.name-gate-field {
  display: grid;
  gap: 6px;
  color: #5a1e28;
  font-weight: 800;
}

.name-gate-field input {
  width: 100%;
  min-width: 0;
}

.name-gate-acks {
  display: grid;
  gap: 9px;
}

.name-gate-check {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  padding: 10px;
  border: 1px solid rgba(107, 31, 42, 0.16);
  border-radius: 10px;
  background: #fffaf8;
  color: #5a1e28;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.38;
}

.name-gate-check input {
  min-width: 0;
  margin: 3px 0 0;
}

.name-gate-terms {
  margin: -3px 0 0;
  font-size: 0.84rem;
}

.name-gate-terms a {
  color: #6b1f2a;
  font-weight: 800;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.name-gate-card button {
  width: 100%;
}

.name-gate-error {
  min-height: 1.2em;
  margin: -4px 0 0;
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 800;
}

.terms-dialog {
  position: fixed;
  inset: 0;
  z-index: 2100;
  display: grid;
  place-items: center;
  padding: 20px 16px;
  background: rgba(42, 15, 22, 0.62);
}

.terms-dialog[hidden] {
  display: none !important;
}

.terms-card {
  width: min(100%, 760px);
  max-height: min(760px, calc(100vh - 40px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  border: 1px solid rgba(107, 31, 42, 0.22);
  border-radius: 18px;
  padding: 18px;
  background: #fffdfc;
  box-shadow: 0 28px 70px rgba(42, 15, 22, 0.35);
}

.terms-card h2 {
  margin: 0;
  color: #4a1520;
  font-size: 1.35rem;
}

.terms-content {
  overflow: auto;
  padding-right: 6px;
  color: #3a2b2b;
  line-height: 1.5;
}

.terms-content h3 {
  margin: 18px 0 5px;
  color: #5a1e28;
  font-size: 1rem;
}

.terms-content h3:first-child { margin-top: 0; }

.terms-content p { margin: 0 0 10px; }

.terms-content ul {
  margin: 0 0 10px 20px;
  padding: 0;
}

.terms-content li { margin-bottom: 5px; }

.terms-card button {
  justify-self: end;
  min-width: 120px;
}

@media (max-width: 480px) {
  .name-gate-overlay {
    align-items: start;
    padding: 18px 12px;
  }
  .name-gate-card {
    padding: 18px 14px;
    border-radius: 16px;
  }
  .name-gate-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
  }
}
/* ── Coding Block (ICD-10 + CPT) ─────────────────────────── */
.coding-section {
  margin-top: 10px;
  border: 1px solid rgba(107, 31, 42, 0.18);
  border-radius: 10px;
  overflow: hidden;
}

.coding-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  background: #fdf9f7;
  cursor: pointer;
  list-style: none;
  user-select: none;
  -webkit-user-select: none;
}

.coding-toggle::-webkit-details-marker { display: none; }

.coding-toggle::after {
  content: "▸";
  color: #7a4048;
  font-size: 0.8rem;
  flex-shrink: 0;
  transition: transform 180ms ease;
}

.coding-section[open] > .coding-toggle::after {
  transform: rotate(90deg);
}

.coding-toggle:hover {
  background: #f9f0ed;
}

.coding-toggle-label {
  font-size: 0.78rem;
  font-weight: 800;
  color: #5a1e28;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.coding-toggle-meta {
  font-size: 0.75rem;
  color: #7a5242;
  font-weight: 600;
  text-align: right;
  line-height: 1.3;
}

.code-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.code-type-header {
  padding: 5px 10px;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #7a4048;
  background: #f5ede8;
  border-top: 1px solid rgba(107, 31, 42, 0.1);
}

.code-row td {
  padding: 6px 10px;
  border-bottom: 1px solid rgba(107, 31, 42, 0.07);
  vertical-align: top;
}

.code-row:last-child td {
  border-bottom: none;
}

.code-row td:first-child {
  width: 110px;
  white-space: nowrap;
  vertical-align: middle;
}

.code-chip {
  display: inline-block;
  border-radius: 5px;
  padding: 2px 7px;
  font-weight: 800;
  font-family: monospace;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.chip-icd10 {
  background: #6b1f2a;
  color: #fff;
}

.chip-cpt {
  background: #1a4a6b;
  color: #fff;
}

.code-desc {
  color: #3a2b2b;
  line-height: 1.45;
}

.code-note {
  color: #7a5242;
  font-style: italic;
  font-size: 0.76rem;
}

@media (max-width: 480px) {
  .coding-toggle { padding: 7px 10px; flex-wrap: wrap; }
  .code-chip { font-size: 0.75rem; }
  .code-row td:first-child { width: 90px; }
  .code-type-header { padding: 4px 8px; }
}
/* ── PUSH Score Block ──────────────────────────────────────── */
.push-block {
  margin: 10px 0;
  border: 1px solid rgba(107, 31, 42, 0.18);
  border-radius: 10px;
  overflow: hidden;
  background: #fdf9f7;
}

.push-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #f5ede8;
  border-bottom: 1px solid rgba(107, 31, 42, 0.12);
}

.push-title {
  font-size: 0.72rem;
  font-weight: 800;
  color: #7a4048;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.push-total-row {
  font-size: 0.95rem;
}

.push-total {
  font-size: 1.3rem;
  font-weight: 900;
  color: #4a1520;
}

.push-total.push-partial {
  color: #9ea3a7;
}

.push-max {
  color: #7a5242;
  font-size: 0.78rem;
  font-weight: 600;
}

.push-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.push-row td {
  padding: 7px 10px;
  border-bottom: 1px solid rgba(107, 31, 42, 0.07);
  vertical-align: middle;
}

.push-row:last-child td { border-bottom: none; }

.push-label {
  font-weight: 700;
  color: #5a1e28;
  width: 130px;
}

.push-detail {
  color: #4a3a3a;
  font-size: 0.8rem;
}

.push-score-cell {
  text-align: right;
  width: 110px;
}

.push-chip {
  display: inline-block;
  background: #6b1f2a;
  color: #fff;
  border-radius: 5px;
  padding: 2px 7px;
  font-weight: 800;
  font-size: 0.8rem;
  font-family: monospace;
  margin-bottom: 3px;
}

.push-bar-bg {
  height: 4px;
  background: rgba(107, 31, 42, 0.12);
  border-radius: 2px;
  overflow: hidden;
}

.push-bar-fill {
  height: 100%;
  background: #6b1f2a;
  border-radius: 2px;
  transition: width 0.4s ease;
}

.push-interpretation {
  margin: 0;
  padding: 7px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #4a1520;
  border-top: 1px solid rgba(107, 31, 42, 0.1);
}

.push-note {
  margin: 0;
  padding: 5px 12px 7px;
  font-size: 0.72rem;
  color: #9ea3a7;
  font-style: italic;
}

/* ── Copy Narrative Button ─────────────────────────────────── */
.narrative-patient-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.copy-narrative-btn {
  font-size: 0.75rem;
  padding: 4px 12px;
  border-radius: 6px;
  background: #6b1f2a;
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 2px 0 #4a1520;
  transition: background 80ms;
}

.copy-narrative-btn:hover { background: #4a1520; }
.copy-narrative-btn:active { transform: translateY(1px); box-shadow: 0 1px 0 #4a1520; }
.copy-narrative-btn:disabled { opacity: 0.7; cursor: default; transform: none; }

@media (max-width: 480px) {
  .push-label { width: 100px; }
  .push-score-cell { width: 80px; }
  .copy-narrative-btn { font-size: 0.72rem; padding: 3px 9px; }
}
