:root {
  color-scheme: light;
  --bg: #eef3f8;
  --panel: #ffffff;
  --ink: #102540;
  --muted: #4b627e;
  --line: #c7d4e2;
  --line-strong: #9fb1c5;
  --blue: #0f4f86;
  --blue-soft: #e6eef7;
  --green: #2f6b56;
  --green-soft: #e7f3ee;
  --amber: #a96f14;
  --amber-soft: #fff3dc;
  --danger: #a51d2d;
  --danger-soft: #ffe9ed;
  --shadow: 0 14px 30px rgba(0, 33, 71, 0.1);
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: linear-gradient(160deg, #edf3f8 0%, #f7f8fb 42%, #eaf1f9 100%);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid #0b416f;
  border-radius: 6px;
  background: var(--blue);
  color: #ffffff;
  padding: 0 14px;
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  background: #0b416f;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(36, 95, 133, 0.22);
  outline-offset: 2px;
}

button.quiet,
button.icon-button {
  border-color: var(--line-strong);
  background: #ffffff;
  color: var(--ink);
}

button.quiet:hover,
button.icon-button:hover {
  background: var(--blue-soft);
}

button.icon-button {
  width: 34px;
  min-height: 32px;
  padding: 0;
}

.pccm-bar-wrap {
  padding: 24px 18px 0;
}

.pccm-bar {
  max-width: 1420px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 20px;
  border: 1px solid rgba(146, 166, 191, 0.95);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 14px 28px rgba(0, 33, 71, 0.08);
  backdrop-filter: blur(10px);
}

.pccm-home {
  color: #001a36;
  font-family: "Times New Roman", Times, serif;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
}

.pccm-tag {
  margin: 0;
  color: #314866;
  font-size: 0.95rem;
  line-height: 1.45;
  text-align: right;
}

.app-header {
  max-width: 1420px;
  margin: 26px auto 0;
  padding: 0 18px;
}

.app-header > div {
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    radial-gradient(1100px 300px at 100% -20%, rgba(15, 79, 134, 0.14), transparent 42%),
    radial-gradient(800px 240px at -10% 120%, rgba(184, 97, 0, 0.08), transparent 44%),
    rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.35rem, 2.5vw, 2rem);
  line-height: 1.15;
}

.hero-sub {
  max-width: 900px;
  margin: 10px auto 0;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.5;
}

h2 {
  font-size: 1.02rem;
  line-height: 1.25;
}

.app-layout {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  padding: 18px clamp(16px, 3vw, 34px) 26px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-heading p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

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

.field,
.import-box {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
}

.section-instructions,
.field-help {
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.field-help {
  margin: -2px 0 2px;
  font-size: 0.82rem;
  font-weight: 500;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
}

input {
  height: 36px;
  padding: 0 9px;
}

textarea {
  min-height: 80px;
  padding: 10px;
  resize: vertical;
  line-height: 1.45;
}

.table-shell {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 850px;
  border-collapse: collapse;
  table-layout: fixed;
}

.input-table-shell {
  overflow: visible;
  border: 0;
  border-radius: 0;
}

.data-entry-table {
  min-width: 0;
  border-collapse: separate;
  border-spacing: 0;
}

.data-entry-table thead {
  display: none;
}

.data-entry-table tbody {
  display: grid;
  gap: 10px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  vertical-align: middle;
  font-size: 0.86rem;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef4fa;
  color: #314866;
  font-size: 0.77rem;
  font-weight: 800;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:nth-child(even) td {
  background: #fbfcfb;
}

.data-entry-table tr {
  display: grid;
  grid-template-columns:
    42px minmax(142px, 1.35fr) minmax(82px, 0.82fr)
    minmax(82px, 0.82fr) minmax(92px, 0.9fr) minmax(96px, 0.9fr)
    minmax(76px, 0.72fr) auto;
  gap: 8px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(248, 251, 255, 0.94), rgba(255, 255, 255, 0.98));
  padding: 10px;
}

.data-entry-table tbody tr:nth-child(even) td {
  background: transparent;
}

.data-entry-table td {
  display: grid;
  width: auto;
  gap: 4px;
  border-bottom: 0;
  padding: 0;
}

.data-entry-table td::before {
  content: attr(data-label);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.data-entry-table .row-action {
  align-self: stretch;
  justify-self: end;
}

.data-entry-table .row-action::before {
  content: "Action";
  visibility: hidden;
}

.data-entry-table input {
  min-width: 0;
  height: 34px;
  padding: 0 8px;
}

.remove-button {
  min-height: 34px;
  border-color: #d79aa5;
  background: #ffffff;
  color: var(--danger);
  padding: 0 12px;
  font-size: 0.82rem;
  font-weight: 800;
}

.remove-button:hover {
  background: var(--danger-soft);
}

.visit-badge {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid #cbd9e8;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 800;
}

.import-box {
  margin-top: 14px;
}

.quality-messages {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.quality-message {
  border: 1px solid #edd39b;
  border-radius: 6px;
  background: var(--amber-soft);
  color: #704607;
  padding: 9px 10px;
  font-size: 0.86rem;
  line-height: 1.35;
}

.quality-message.error {
  border-color: #ebc3bd;
  background: var(--danger-soft);
  color: var(--danger);
}

.calculation-status {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  border: 1px solid #a8c6dc;
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(230, 238, 247, 0.95), rgba(255, 255, 255, 0.98));
  color: #15395c;
  padding: 12px 13px;
  font-size: 0.9rem;
  line-height: 1.4;
  box-shadow: 0 10px 22px rgba(15, 79, 134, 0.08);
}

.calculation-status[hidden] {
  display: none;
}

.loading-spinner {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border: 3px solid rgba(15, 79, 134, 0.18);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.calculation-status-copy {
  display: grid;
  gap: 2px;
}

.calculation-status-copy strong {
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 850;
}

.calculation-status-copy span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 600;
}

.current-estimate {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.current-estimate div {
  border: 1px solid #cbd9e8;
  border-radius: 8px;
  background: linear-gradient(180deg, #f8fbff, #ffffff);
  padding: 12px;
}

.current-estimate span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.current-estimate strong {
  display: block;
  margin-top: 2px;
  color: var(--blue);
  font-size: 1.55rem;
  line-height: 1.15;
  letter-spacing: 0;
}

.clinical-note-preview {
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px;
}

.clinical-note-preview p {
  margin: 0 0 5px;
  color: var(--ink);
  font-size: 0.86rem;
  line-height: 1.35;
}

.clinical-note-title {
  font-weight: 800;
}

.clinical-note-preview table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  table-layout: auto;
}

.clinical-note-preview th,
.clinical-note-preview td {
  border: 1px solid var(--line-strong);
  padding: 5px 7px;
  white-space: nowrap;
}

.clinical-note-preview th {
  position: static;
  text-align: center;
}

.clinical-note-preview td:not(:nth-child(2)) {
  text-align: right;
}

.note-source {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  min-height: 1px;
  opacity: 0;
}

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 20px;
}

.about-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 clamp(16px, 3vw, 34px) 34px;
}

.about-tool {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.about-tool summary {
  cursor: pointer;
  padding: 14px 16px;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 800;
}

.about-tool summary:focus-visible {
  outline: 3px solid rgba(36, 95, 133, 0.22);
  outline-offset: 2px;
}

.about-content {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding: 14px 16px 16px;
}

.about-content h2 {
  margin-top: 10px;
  font-size: 0.95rem;
}

.about-content h2:first-child {
  margin-top: 0;
}

.about-content p {
  margin: 0;
  max-width: 980px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.about-content .about-updated {
  color: var(--ink);
  font-weight: 700;
}

.about-content .odds-copyright-notice {
  max-width: 980px;
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.about-content .odds-copyright-notice p {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.about-content .odds-copyright-notice p + p {
  margin-top: 5px;
}

.about-content .about-resource {
  margin-top: 4px;
}

.about-evidence-link {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  padding: 8px 15px;
  font-size: 0.86rem;
  font-weight: 750;
  text-decoration: none;
}

.about-evidence-link:hover {
  border-color: var(--blue);
  background: #dbe8f4;
}

.about-evidence-link:focus-visible {
  outline: 3px solid rgba(36, 95, 133, 0.22);
  outline-offset: 3px;
}

.contributor-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  max-width: 980px;
}

.contributor-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
  padding: 12px;
}

.contributor-group h3 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.25;
}

.name-list {
  display: grid;
  gap: 2px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.citation-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.citation-list a {
  color: var(--blue);
}

.flash {
  animation: flash 0.9s ease;
}

@keyframes flash {
  0% {
    background: var(--green-soft);
  }
  100% {
    background: transparent;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .loading-spinner {
    animation: none;
  }
}

@media (max-width: 1100px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .panel {
    box-shadow: none;
  }
}

@media (min-width: 721px) and (max-width: 900px) {
  .data-entry-table tr {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .pccm-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .pccm-tag {
    text-align: left;
  }

  .app-header {
    margin-top: 18px;
  }

  .app-header > div {
    padding: 18px;
    text-align: left;
  }

  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .current-estimate {
    grid-template-columns: 1fr;
  }

  .data-entry-table tr {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .data-entry-table .row-action {
    justify-self: stretch;
  }

  .data-entry-table .row-action .remove-button {
    width: 100%;
  }

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

@media (max-width: 420px) {
  .data-entry-table tr {
    grid-template-columns: 1fr;
  }
}
