:root {
  color-scheme: light;
  --ink: #17201f;
  --muted: #60706b;
  --soft: #eef2ef;
  --line: #d7ded9;
  --panel: #ffffff;
  --panel-alt: #f7f9f6;
  --brand: #0f766e;
  --brand-strong: #0b5f5a;
  --accent: #b45309;
  --warn: #9a3412;
  --danger: #b42318;
  --ok: #197447;
  --shadow: 0 16px 38px rgba(28, 39, 35, 0.1);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: #edf1ed;
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.app-header {
  min-height: 72px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: #e3f1ed;
  border: 1px solid #c7e1dc;
  border-radius: var(--radius);
  flex: 0 0 auto;
}

.brand-mark svg,
button svg,
.empty-state svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-mark svg {
  color: var(--brand);
}

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

h1 {
  font-size: 1.08rem;
  line-height: 1.2;
}

.brand-block p,
.panel-heading p,
.reference-title-row p,
.result-toolbar p,
.empty-state p {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.header-actions,
.action-row,
.result-toolbar,
.reference-title-row,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header-actions {
  justify-content: flex-end;
}

.icon-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  border-radius: var(--radius);
}

.icon-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.section-tabs button:hover {
  background: var(--soft);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.88fr) minmax(520px, 1.12fr);
  gap: 18px;
  padding: 18px;
  max-width: 1680px;
  margin: 0 auto;
}

.input-panel,
.result-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}

.input-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  align-self: start;
}

.result-panel {
  min-height: calc(100vh - 108px);
  display: flex;
  flex-direction: column;
}

.panel-heading {
  align-items: flex-start;
}

.panel-heading h2,
.result-toolbar h2 {
  font-size: 1.05rem;
}

.status-pill,
.score-strip span,
.quality-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--soft);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.status-pill.is-done,
.quality-badge.good {
  color: var(--ok);
  background: #e8f5ed;
  border-color: #c1dfce;
}

.quality-badge.medium {
  color: var(--accent);
  background: #fff4de;
  border-color: #f2d39a;
}

.quality-badge.low {
  color: var(--danger);
  background: #fff0ed;
  border-color: #f1c7bf;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: #2a3633;
  font-size: 0.86rem;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd6d0;
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

textarea {
  min-height: 280px;
  resize: vertical;
  line-height: 1.5;
}

.full-field {
  min-width: 0;
}

.reference-panel {
  border: 1px solid var(--line);
  background: var(--panel-alt);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  gap: 12px;
}

.reference-title-row {
  align-items: flex-start;
}

.reference-title-row h3 {
  font-size: 0.98rem;
}

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

.check-tile {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  font-weight: 600;
  color: var(--ink);
}

.check-tile input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

.reference-notes textarea {
  min-height: 90px;
}

.catalog-manager {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.catalog-manager-head,
.catalog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.catalog-manager-head {
  align-items: flex-start;
}

.catalog-manager h4 {
  margin: 0;
  font-size: 0.94rem;
}

.catalog-manager p {
  margin: 0;
}

.catalog-manager-head p {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.catalog-controls {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(0, auto);
  align-items: end;
  gap: 8px;
  padding-top: 2px;
}

.catalog-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.catalog-status {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
  min-width: 0;
}

.catalog-status.is-loaded {
  color: var(--ok);
  font-weight: 700;
}

.catalog-status.is-error {
  color: var(--danger);
  font-weight: 700;
}

.catalog-status-list {
  display: grid;
  gap: 6px;
}

.catalog-row {
  display: grid;
  grid-template-columns: minmax(145px, 0.9fr) minmax(0, 1.6fr) minmax(88px, auto);
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-alt);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.catalog-row strong {
  color: var(--ink);
}

.catalog-row.is-loaded {
  background: #f3faf6;
  border-color: #c1dfce;
}

.catalog-row-count {
  text-align: right;
  white-space: nowrap;
  color: var(--ink);
  font-weight: 700;
}

.is-hidden {
  display: none !important;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 9px 12px;
  font-weight: 700;
  white-space: nowrap;
}

.primary-button {
  background: var(--brand);
  color: #ffffff;
  border-color: var(--brand);
}

.primary-button:hover {
  background: var(--brand-strong);
}

.secondary-button,
.ghost-button {
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
}

.secondary-button.danger {
  color: var(--danger);
}

.ghost-button.danger {
  color: var(--danger);
}

.result-toolbar {
  padding: 18px;
  border-bottom: 1px solid var(--line);
  align-items: flex-start;
}

.score-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.section-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.section-tabs button {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--muted);
  border-radius: var(--radius);
  padding: 8px 10px;
  min-height: 36px;
  white-space: nowrap;
  font-weight: 700;
}

.section-tabs button.active {
  border-color: #b4d9d3;
  background: #e3f1ed;
  color: var(--brand-strong);
}

.report-output {
  flex: 1;
  overflow: auto;
  padding: 18px;
  background: #fbfcfa;
}

.empty-state {
  min-height: 420px;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  gap: 10px;
  color: var(--muted);
}

.empty-state svg {
  width: 82px;
  height: 82px;
  color: #8aa19a;
}

.report-section {
  scroll-margin-top: 150px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.report-section:first-child {
  padding-top: 0;
}

.report-section:last-child {
  border-bottom: 0;
}

.report-section h3 {
  font-size: 1.02rem;
  margin-bottom: 12px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.summary-item {
  min-height: 84px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 12px;
}

.summary-item span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.summary-item strong {
  display: block;
  margin-top: 6px;
  font-size: 1rem;
}

.notice {
  border: 1px solid #e1c18a;
  background: #fff8e8;
  border-radius: var(--radius);
  color: #6b3d08;
  padding: 10px 12px;
  line-height: 1.45;
  font-size: 0.9rem;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  font-size: 0.86rem;
}

th,
td {
  text-align: left;
  vertical-align: top;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  line-height: 1.45;
}

th {
  background: #eef2ef;
  color: #293632;
  font-size: 0.78rem;
  text-transform: uppercase;
}

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

.section-note,
.report-list,
.draft-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 12px;
  line-height: 1.55;
}

.section-note {
  margin-bottom: 10px;
}

.report-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 28px;
}

.report-list li {
  padding-left: 2px;
}

.draft-block {
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.88rem;
}

.subsection-title {
  margin: 14px 0 8px;
  font-size: 0.92rem;
}

.copy-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: #17201f;
  color: #ffffff;
  padding: 10px 12px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 50;
  font-weight: 700;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .result-panel {
    min-height: 720px;
  }
}

@media (max-width: 760px) {
  .app-header {
    position: static;
    padding: 12px;
  }

  .brand-block p {
    display: none;
  }

  .workspace {
    padding: 10px;
  }

  .form-grid,
  .reference-grid,
  .catalog-controls,
  .catalog-row,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .action-row,
  .catalog-actions,
  .catalog-manager-head,
  .result-toolbar,
  .panel-heading,
  .reference-title-row {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-button,
  .secondary-button,
  .ghost-button {
    width: 100%;
  }

  .catalog-row-count {
    text-align: left;
  }

  .score-strip {
    justify-content: flex-start;
  }
}

@media print {
  .app-header,
  .input-panel,
  .section-tabs {
    display: none;
  }

  body {
    background: #ffffff;
  }

  .workspace {
    display: block;
    padding: 0;
  }

  .result-panel {
    box-shadow: none;
    border: 0;
  }

  .report-output {
    padding: 0;
    overflow: visible;
  }

  .report-section {
    break-inside: avoid;
  }
}
