:root {
  color-scheme: light;
  --ink: #1d2528;
  --muted: #657174;
  --line: #d7dee0;
  --paper: #f6f8f6;
  --panel: #ffffff;
  --green: #16725f;
  --green-dark: #0f5144;
  --amber: #b46b0d;
  --red: #b63535;
  --blue: #2f5f95;
  --shadow: 0 14px 34px rgba(31, 49, 54, 0.12);
  --review-panel-height: min(760px, calc(100vh - 168px));
}

* {
  box-sizing: border-box;
}

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1600px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 34px;
}

.topbar,
.generate-band,
.result-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.topbar {
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.1;
}

h2 {
  margin-bottom: 16px;
  font-size: 18px;
}

.status-pill {
  min-width: 116px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  background: #fff;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

.status-pill[data-tone="busy"] {
  border-color: #d0a14f;
  color: #8a5b0b;
}

.status-pill[data-tone="ok"] {
  border-color: #8fc7ba;
  color: var(--green-dark);
}

.status-pill[data-tone="error"] {
  border-color: #df9c9c;
  color: var(--red);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(340px, 0.95fr) minmax(430px, 1.1fr) minmax(360px, 0.95fr);
  gap: 18px;
  align-items: stretch;
}

.panel,
.generate-band,
.result-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: 22px;
}

.upload-panel,
.findings-panel,
.remarks-panel {
  height: var(--review-panel-height);
}

.upload-panel,
.remarks-panel {
  overflow-y: auto;
}

.findings-panel {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

.dropzone,
.template-picker {
  position: relative;
  display: grid;
  cursor: pointer;
  border: 1px dashed #a9b8bb;
  border-radius: 8px;
  background: #fbfcfc;
}

.dropzone {
  min-height: 132px;
  place-items: center;
  margin-bottom: 18px;
  padding: 20px;
  text-align: center;
}

.pdf-preview-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: -4px 0 18px;
  border: 1px solid #c9d8dc;
  border-radius: 6px;
  padding: 8px 10px;
  background: #f7fbfb;
  color: var(--blue);
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
}

.pdf-preview-link:hover {
  text-decoration: underline;
}

.dropzone:hover,
.template-picker:hover {
  border-color: var(--green);
}

.drop-icon,
.template-picker span {
  display: inline-grid;
  place-items: center;
  min-width: 46px;
  height: 32px;
  border-radius: 6px;
  background: #e4f2ef;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 900;
}

.dropzone strong,
.template-picker strong {
  margin-top: 10px;
}

.dropzone small {
  color: var(--muted);
  line-height: 1.4;
}

.dropzone input,
.template-picker input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.field-grid,
.mode-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.mode-fields {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.extra-fields {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.extra-fields h2 {
  margin-bottom: 14px;
}

.extra-section {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfc;
}

.extra-section h3 {
  margin-bottom: 12px;
  color: var(--green-dark);
  font-size: 14px;
}

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

.compact-extra-fields {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.compact-extra-fields h2 {
  margin-bottom: 8px;
  color: var(--green-dark);
  font-size: 14px;
}

.simple-remarks {
  margin-top: 0;
}

.simple-remarks textarea {
  min-height: 120px;
  padding: 7px 9px;
  font-size: 12px;
}

.compact-extra-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 10px;
  margin-top: 10px;
}

.compact-extra-grid label span {
  margin-bottom: 4px;
  font-size: 10px;
  line-height: 1.2;
}

.compact-extra-grid textarea {
  min-height: 34px;
  max-height: 70px;
  padding: 6px 8px;
  font-size: 12px;
  line-height: 1.25;
}

.remarks-panel .compact-extra-grid {
  grid-template-columns: 1fr;
}

.remarks-panel .compact-extra-grid textarea {
  min-height: 38px;
  max-height: 90px;
}

label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #c7d1d4;
  border-radius: 6px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
  line-height: 1.35;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  outline: 3px solid rgba(22, 114, 95, 0.14);
}

.full-width {
  display: block;
  margin-top: 14px;
}

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

.section-heading span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.findings-empty {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

.findings-list {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-auto-rows: max-content;
  align-content: start;
  gap: 14px;
  max-height: none;
  overflow: auto;
  padding-right: 4px;
}

.match-warning {
  border-left: 4px solid var(--amber);
  border-radius: 6px;
  background: #fff7ea;
  padding: 10px 12px;
  color: #80530d;
  font-size: 13px;
  font-weight: 700;
}

.finding-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.finding-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 13px;
  background: #eef5f3;
}

.finding-header h3 {
  margin: 0;
  font-size: 15px;
}

.finding-header span {
  min-width: 28px;
  border-radius: 999px;
  background: #fff;
  padding: 3px 8px;
  color: var(--green-dark);
  text-align: center;
  font-size: 12px;
  font-weight: 900;
}

.finding-section ol {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.finding-list-inner {
  display: grid;
}

.finding-section li {
  padding: 12px 13px;
  border-top: 1px solid var(--line);
}

.finding-section li p {
  margin: 0;
  line-height: 1.45;
}

.point-card {
  border-top: 1px solid var(--line);
  padding: 12px 13px;
  background: #fff;
}

.point-card.needs-review {
  background: #fffaf1;
}

.point-card-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 12px;
  align-items: start;
}

.point-title {
  margin: 0 0 3px;
  font-weight: 900;
  line-height: 1.35;
}

.point-card-top span,
.point-parameter {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.point-parameter {
  margin: 9px 0 0;
}

.template-row-field span {
  margin-bottom: 4px;
  font-size: 10px;
}

.template-row-field input {
  min-height: 34px;
  padding: 6px 8px;
  text-align: center;
}

.observation-table-wrap {
  margin-top: 14px;
}

.mini-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.mini-heading h3 {
  margin: 0;
  color: var(--green-dark);
  font-size: 13px;
}

.mini-heading span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.observation-empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  text-align: center;
}

.observation-rows {
  display: grid;
  gap: 10px;
}

.observation-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 3fr) minmax(0, 2fr);
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfc;
}

.observation-row strong {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: #e4f2ef;
  color: var(--green-dark);
  font-size: 12px;
}

.observation-row label {
  min-width: 0;
}

.observation-row textarea {
  min-height: 46px;
  max-height: 130px;
  padding: 7px 9px;
  font-size: 12px;
  line-height: 1.3;
}

.generate-band {
  margin-top: 18px;
  padding: 18px 20px;
}

.generate-band h2 {
  margin-bottom: 4px;
}

.generate-band p {
  margin-bottom: 0;
  color: var(--muted);
}

.template-select-wrap {
  min-width: min(360px, 100%);
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 7px;
}

button {
  min-height: 46px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  background: var(--green);
  color: #fff;
  cursor: pointer;
  font-weight: 900;
}

button:hover:not(:disabled) {
  background: var(--green-dark);
}

button:disabled {
  cursor: not-allowed;
  background: #a9b8bb;
}

.result-panel {
  margin-top: 16px;
  padding: 15px 18px;
}

.result-panel a {
  color: var(--blue);
  font-weight: 900;
}

@media (max-width: 1180px) {
  .workspace-grid,
  .generate-band,
  .topbar,
  .result-panel {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .generate-band {
    display: grid;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 24px, 1380px);
    padding-top: 18px;
  }

  .field-grid,
  .extra-grid,
  .compact-extra-grid,
  .mode-fields,
  .point-card-top,
  .finding-section li {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 24px;
  }
}
