:root {
  --nav: #0e1726;
  --nav-2: #14243a;
  --gold: #c9a227;
  --gold-dark: #8b6a10;
  --line: #c6ccd6;
  --field: #fffdf6;
  --paper: #ffffff;
  --faint: #f8fafc;
  --mist: #eef2f6;
  --text: #101827;
  --muted: #5d6673;
  --teal: #4da3a8;
  --rose: #b56a72;
}

* {
  box-sizing: border-box;
}

html {
  background: #eef2f6;
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

body {
  margin: 0;
}

.topbar {
  align-items: center;
  background: linear-gradient(90deg, var(--nav), var(--nav-2));
  border-bottom: 3px solid var(--gold);
  color: white;
  display: flex;
  gap: 28px;
  justify-content: space-between;
  min-height: 86px;
  padding: 16px clamp(18px, 4vw, 54px);
}

.top-controls {
  align-items: center;
  display: flex;
  gap: 10px;
}

.brand {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.brand-name {
  font-size: clamp(26px, 4vw, 40px);
  font-weight: 800;
  letter-spacing: 0;
  position: relative;
}

.tm {
  color: var(--gold);
  font-size: 12px;
  left: 4px;
  position: relative;
  top: -18px;
}

.brand-subtitle {
  color: rgba(255, 255, 255, 0.78);
  font-size: clamp(17px, 2vw, 26px);
}

.logo-slot {
  border: 1px solid rgba(255, 255, 255, 0.72);
  color: rgba(255, 255, 255, 0.72);
  display: grid;
  font-size: 15px;
  height: 48px;
  min-width: 150px;
  place-items: center;
}

main {
  margin: 0 auto;
  max-width: 1320px;
  padding: 22px clamp(14px, 3vw, 42px) 42px;
}

.client-panel,
.summary-panel,
.scale-strip,
.instructions-panel,
.concerns,
.domain {
  background: var(--paper);
  border: 1px solid var(--line);
  margin-bottom: 18px;
}

.instructions-panel {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border-left: 5px solid var(--gold);
  box-shadow: 0 10px 24px rgba(16, 24, 39, 0.06);
  padding: 16px 18px 14px;
}

.instructions-panel h2 {
  color: var(--text);
  font-size: 18px;
  margin-bottom: 9px;
}

.instructions-panel ol {
  color: var(--text);
  display: grid;
  gap: 6px 24px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  line-height: 1.36;
  margin: 0;
  padding-left: 20px;
}

.instructions-panel li {
  padding-left: 2px;
}

.instructions-panel li::marker {
  color: var(--gold-dark);
  font-weight: 800;
}

.client-panel {
  display: grid;
  gap: 0;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.field-block {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 9px;
}

.field-block label {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 5px;
}

input,
select,
textarea {
  background: var(--field);
  border: 1px solid #b9c2cf;
  border-radius: 0;
  color: var(--text);
  font: inherit;
  min-height: 32px;
  padding: 5px 8px;
  width: 100%;
}

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

.score-input {
  text-align: center;
}

input.invalid {
  border-color: #b42318;
  box-shadow: inset 0 0 0 1px #b42318;
}

.summary-panel {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr auto;
  padding: 18px;
}

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

h1 {
  font-size: 23px;
}

.summary-panel p {
  color: var(--muted);
  font-size: 14px;
  margin: 6px 0 0;
}

.summary-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

button {
  background: var(--nav);
  border: 1px solid var(--nav);
  color: white;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  min-height: 36px;
  padding: 7px 12px;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.primary-download {
  background: linear-gradient(135deg, #f8d66d 0%, var(--gold) 45%, #a77c13 100%);
  border: 1px solid #f4dc8c;
  border-radius: 6px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.45);
  color: #101827;
  min-height: 42px;
  padding: 9px 16px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.34);
}

.primary-download:hover {
  background: linear-gradient(135deg, #ffe28a 0%, #d6ad2d 45%, #b48717 100%);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.54);
  transform: translateY(-1px);
}

.primary-download:active {
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.28), inset 0 2px 4px rgba(65, 48, 4, 0.28);
  transform: translateY(0);
}

button.secondary {
  background: white;
  border-color: var(--line);
  color: var(--text);
}

button.dark {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.65);
  color: white;
}

.summary-table,
.status-grid {
  grid-column: 1 / -1;
}

.summary-table table,
.domain table,
.concern-grid table {
  border-collapse: collapse;
  table-layout: fixed;
  width: 100%;
}

th {
  background: var(--nav);
  color: white;
  font-size: 13px;
  padding: 8px 7px;
  text-align: left;
}

td {
  border: 1px solid var(--line);
  padding: 6px;
  vertical-align: middle;
}

.summary-table td:not(:first-child),
.summary-table th:not(:first-child),
.subtotal-cell {
  text-align: center;
}

.composite-row td {
  background: #fff7dd;
  font-weight: 800;
}

.composite-row td:first-child {
  background: var(--gold);
  color: white;
  text-align: left;
}

.status-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.status {
  background: var(--faint);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  min-height: 48px;
  padding: 8px;
}

.status strong {
  color: var(--text);
  display: block;
  font-size: 13px;
  margin-bottom: 3px;
}

.scale-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}

.scale-strip div {
  border-right: 1px solid var(--line);
  min-height: 58px;
  padding: 10px;
}

.scale-strip div:nth-child(1) { background: var(--faint); }
.scale-strip div:nth-child(2) { background: #e7f2f8; }
.scale-strip div:nth-child(3) { background: #cadfeb; }
.scale-strip div:nth-child(4) { background: #8fbbd7; }
.scale-strip div:nth-child(5) { background: var(--nav); color: white; }

.scale-strip strong {
  display: block;
  font-size: 18px;
}

.scale-strip span {
  display: block;
  font-size: 13px;
  margin-top: 2px;
}

.concerns {
  padding: 16px;
}

.concerns h2 {
  font-size: 18px;
  margin-bottom: 12px;
}

.domain-header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 14px;
  padding: 15px 16px 12px;
}

.domain-header img {
  height: 42px;
  width: 42px;
}

.domain-header h2 {
  font-size: 22px;
}

.domain-header p {
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 0;
}

.section-row td {
  background: var(--mist);
  font-weight: 800;
}

.symptom-label {
  min-width: 260px;
}

.score-col {
  width: 92px;
}

.context-col {
  width: 270px;
}

.marker {
  display: inline-block;
  font-size: 15px;
  font-weight: 800;
  margin-left: 5px;
  vertical-align: 1px;
}

.marker.priority {
  color: var(--gold);
  filter: drop-shadow(0 1px 0 #6d5309) drop-shadow(0 0 2px rgba(247, 215, 115, 0.75));
  font-size: 17px;
  line-height: 1;
}

.marker.sex {
  color: var(--nav);
  font-size: 16px;
  line-height: 1;
}

.marker.female {
  color: var(--rose);
}

.marker.male {
  color: #426e8d;
}

.domain-subtotal td {
  background: #fff7dd;
  font-weight: 800;
}

.domain-subtotal td:first-child {
  background: var(--gold);
  color: white;
}

footer {
  color: var(--muted);
  display: flex;
  font-size: 12px;
  gap: 18px;
  justify-content: space-between;
  margin: 24px auto;
  max-width: 1320px;
  padding: 0 clamp(14px, 3vw, 42px);
}

@media (max-width: 980px) {
  .client-panel,
  .scale-strip,
  .status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .instructions-panel ol {
    grid-template-columns: 1fr;
  }

  .summary-panel {
    grid-template-columns: 1fr;
  }

  .domain {
    overflow-x: auto;
  }

  .domain table {
    min-width: 1040px;
  }
}

@media (max-width: 640px) {
  .client-panel,
  .scale-strip,
  .status-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-controls {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .logo-slot {
    width: 100%;
  }
}

@media print {
  @page {
    size: A4 landscape;
    margin: 10mm;
  }

  html,
  body {
    background: white;
  }

  .no-print,
  .summary-actions {
    display: none !important;
  }

  main {
    max-width: none;
    padding: 12px 0 0;
  }

  .topbar {
    min-height: 62px;
    padding: 10px 16px;
  }

  .brand-name {
    font-size: 28px;
  }

  .brand-subtitle {
    font-size: 18px;
  }

  .logo-slot {
    height: 36px;
  }

  .client-panel,
  .summary-panel,
  .scale-strip,
  .concerns,
  .domain {
    break-inside: avoid;
    box-shadow: none;
    margin-bottom: 12px;
  }

  .domain {
    break-before: page;
  }

  input,
  select,
  textarea {
    min-height: 24px;
    padding: 2px 4px;
  }

  td {
    padding: 3px 5px;
  }

  .domain-header h2 {
    font-size: 18px;
  }
}
