:root {
  --ink: #1a1a18;
  --blue: #2a5785;
  --blue-deep: #183d63;
  --mist: #e8eff5;
  --paper: #fbfaf7;
  --warm: #d8cdbb;
  --line: rgba(26, 26, 24, 0.14);
  --ok: #2f7d58;
  --no: #a9463d;
  --skip: #75716a;
  --shadow: 0 18px 48px rgba(26, 26, 24, 0.13);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(216, 205, 187, 0.42), transparent 34rem),
    linear-gradient(180deg, #ffffff 0%, var(--paper) 62%, #eef4f8 100%);
  min-height: 100vh;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 920px);
  margin: 0 auto;
  padding: env(safe-area-inset-top) 14px calc(92px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 0 10px;
  background: rgba(251, 250, 247, 0.88);
  backdrop-filter: blur(16px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 32px;
  height: 34px;
  flex: 0 0 auto;
}

.brand-logo {
  width: 128px;
  height: auto;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  display: grid;
  place-content: center;
  gap: 4px;
}

.icon-button span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--blue);
}

.audit-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 18px 0 14px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 9vw, 4.6rem);
  line-height: 0.98;
}

.score-ring {
  width: 104px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--blue) var(--score, 0deg), var(--mist) 0);
  display: grid;
  place-items: center;
  position: relative;
  box-shadow: var(--shadow);
}

.score-ring::after {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: #fff;
}

.score-ring strong,
.score-ring span {
  position: relative;
  z-index: 1;
  display: block;
  text-align: center;
}

.score-ring strong {
  align-self: end;
  font-size: 1.3rem;
}

.score-ring span {
  align-self: start;
  color: #66625c;
  font-size: 0.78rem;
}

.details-panel,
.area-manager,
.controls-panel {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 34px rgba(42, 87, 133, 0.08);
}

.details-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
}

label span,
.field-label {
  display: block;
  margin-bottom: 5px;
  color: #5f5b55;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

input,
textarea {
  width: 100%;
  border: 1px solid rgba(26, 26, 24, 0.18);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input {
  min-height: 42px;
  padding: 9px 11px;
}

textarea {
  min-height: 86px;
  padding: 11px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(42, 87, 133, 0.16);
}

.area-manager {
  margin-top: 12px;
  padding: 14px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-heading h2 {
  margin-bottom: 2px;
  font-size: 1rem;
}

.section-heading p {
  margin-bottom: 0;
  color: #66625c;
  font-size: 0.9rem;
}

.text-button {
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  background: var(--blue);
  color: #fff;
  padding: 0 14px;
  font-weight: 800;
}

.area-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-top: 12px;
}

.area-chip {
  min-width: max-content;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 8px 11px;
}

.area-chip input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--blue);
}

.area-name,
.area-edit {
  border: 0;
  background: transparent;
  color: #4f4b46;
  font-weight: 900;
}

.area-name {
  padding: 0;
  text-transform: uppercase;
}

.area-edit {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
}

.area-edit:hover,
.area-edit:focus-visible {
  background: var(--mist);
  outline: none;
}

.area-edit svg {
  width: 15px;
  height: 15px;
  fill: var(--blue);
}

.section-progress {
  display: grid;
  grid-template-columns: repeat(4, minmax(132px, 1fr));
  gap: 9px;
  overflow-x: auto;
  padding: 12px 0;
}

.section-pill {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.8);
  padding: 10px;
}

.section-pill strong {
  display: block;
  font-size: 0.84rem;
}

.section-pill span {
  color: #66625c;
  font-size: 0.78rem;
}

.meter {
  height: 6px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--mist);
}

.meter > i {
  display: block;
  width: var(--w, 0%);
  height: 100%;
  background: var(--blue);
}

.controls-panel {
  position: sticky;
  top: 66px;
  z-index: 10;
  display: grid;
  gap: 10px;
  padding: 12px;
}

.search-wrap {
  position: relative;
}

.search-wrap svg {
  position: absolute;
  top: 50%;
  left: 12px;
  width: 20px;
  height: 20px;
  transform: translateY(-50%);
  fill: var(--blue);
  pointer-events: none;
}

.search-wrap input {
  padding-left: 40px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  background: var(--mist);
}

.segmented button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--blue-deep);
  font-weight: 800;
}

.segmented button.is-active {
  background: #fff;
  box-shadow: 0 4px 14px rgba(42, 87, 133, 0.14);
}

.scorecard {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.section-block {
  display: grid;
  gap: 10px;
}

.section-title {
  padding: 6px 2px 0;
}

.section-title h2 {
  margin-bottom: 3px;
  font-size: 1.35rem;
}

.section-title p {
  margin-bottom: 0;
  color: #66625c;
}

.criterion-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 36px rgba(42, 87, 133, 0.08);
  overflow: hidden;
}

.criterion-summary {
  width: 100%;
  min-height: 78px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  border: 0;
  background: #fff;
  padding: 14px;
  text-align: left;
}

.criterion-summary h3 {
  margin-bottom: 4px;
  font-size: 1.02rem;
}

.criterion-summary p {
  margin-bottom: 0;
  color: #66625c;
  font-size: 0.88rem;
}

.status-badge {
  min-width: 54px;
  border-radius: 999px;
  background: var(--mist);
  padding: 6px 9px;
  color: var(--blue-deep);
  font-size: 0.78rem;
  font-weight: 900;
  text-align: center;
}

.criterion-body {
  display: none;
  padding: 0 14px 14px;
}

.criterion-card.is-open .criterion-body {
  display: block;
}

.definition {
  margin-bottom: 14px;
  border-left: 4px solid var(--warm);
  padding-left: 12px;
  color: #34312d;
  line-height: 1.45;
}

.area-score-list {
  display: grid;
  gap: 10px;
}

.area-score {
  display: grid;
  gap: 8px;
  border: 1px solid rgba(26, 26, 24, 0.12);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfd;
}

.area-score-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-weight: 800;
}

.area-score-head span:last-child {
  color: #66625c;
  font-size: 0.84rem;
}

.choice-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.choice-row button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: #34312d;
  font-weight: 900;
}

.choice-row button[data-choice="yes"].is-selected {
  border-color: var(--ok);
  background: rgba(47, 125, 88, 0.12);
  color: var(--ok);
}

.choice-row button[data-choice="no"].is-selected {
  border-color: var(--no);
  background: rgba(169, 70, 61, 0.12);
  color: var(--no);
}

.choice-row button[data-choice="na"].is-selected {
  border-color: var(--skip);
  background: rgba(117, 113, 106, 0.13);
  color: #514d47;
}

.notes-field {
  margin-top: 12px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 28px 18px;
  background: rgba(255, 255, 255, 0.74);
  text-align: center;
}

dialog {
  width: min(92vw, 420px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(26, 26, 24, 0.36);
}

.dialog-panel {
  padding: 16px;
}

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

.dialog-head h2 {
  margin-bottom: 0;
}

.close-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.action-row {
  width: 100%;
  min-height: 48px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
  text-align: left;
  padding: 0 12px;
}

.action-row.danger {
  color: var(--no);
}

@media (max-width: 620px) {
  .app-shell {
    padding-inline: 12px;
  }

  .audit-header {
    grid-template-columns: 1fr;
  }

  .score-ring {
    width: 94px;
  }

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

  .controls-panel {
    top: 62px;
  }
}

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

  .topbar,
  .controls-panel,
  .area-manager,
  .icon-button,
  dialog {
    display: none !important;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .criterion-body {
    display: block;
  }

  .criterion-card {
    break-inside: avoid;
    box-shadow: none;
  }
}
