:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f7f7f9;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --border: #d2d2d7;
  --primary: #0071e3;
  --primary-dark: #005bb5;
  --ok: #248a3d;
  --warn: #bf6a02;
  --bad: #d70015;
  --info: #0066cc;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  align-items: center;
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  display: flex;
  justify-content: space-between;
  padding: 14px clamp(16px, 3vw, 32px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 {
  font-size: clamp(22px, 3vw, 34px);
  font-weight: 600;
  margin: 2px 0 0;
}

.eyebrow {
  color: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  margin: 0;
  text-transform: uppercase;
}

.status-pill {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  padding: 7px 11px;
  white-space: nowrap;
}

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

.topnav a {
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 11px;
  text-decoration: none;
}

.topnav a:hover {
  background: var(--surface-2);
}

.workspace {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  padding: 16px clamp(12px, 2vw, 28px) 28px;
}

.input-panel,
.result-panel article,
.hero-result,
.handoff,
.mentor-scope {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.input-panel {
  align-self: start;
  padding: 16px;
  position: sticky;
  top: 78px;
}

.section-heading h2,
.hero-result h2,
article h3,
.handoff h3 {
  font-weight: 500;
  margin: 0;
}

.section-heading p {
  color: var(--muted);
  margin: 5px 0 14px;
}

article h3,
.handoff h3 {
  font-size: 16px;
}

form {
  display: grid;
  gap: 12px;
}

.registry-search {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: grid;
  gap: 8px;
  padding: 10px;
}

.registry-search p {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.candidate-list {
  display: grid;
  gap: 8px;
}

.registry-progress {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  list-style: none;
  margin: 0;
  padding: 0;
}

.registry-progress li {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 9px;
  display: flex;
  justify-content: space-between;
  margin: 0;
  padding: 7px 9px;
}

.registry-progress span,
.registry-progress strong {
  font-size: 13px;
}

.registry-progress strong {
  color: var(--muted);
  font-weight: 500;
}

.registry-progress .active {
  border-color: var(--info);
}

.registry-progress .active strong {
  color: var(--info);
}

.registry-progress .done strong {
  color: var(--ok);
}

.registry-progress .error strong {
  color: var(--bad);
}

.registry-progress .timeout strong {
  color: var(--warn);
}

.candidate-filter {
  display: grid;
  gap: 6px;
}

.candidate-filter label {
  color: var(--muted);
  font-size: 13px;
}

.candidate-button {
  background: #ffffff;
  border: 1px solid var(--border);
  color: var(--text);
  display: grid;
  gap: 3px;
  justify-items: start;
  min-height: auto;
  padding: 9px 10px;
  text-align: left;
}

.candidate-button:hover {
  border-color: var(--primary);
}

.candidate-button strong {
  font-weight: 500;
}

.candidate-button span {
  color: var(--muted);
  font-size: 13px;
}

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

.demo-cases p {
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  grid-column: 1 / -1;
  margin: 0;
}

.demo-button {
  background: #f7faf8;
  border: 1px solid var(--border);
  color: var(--primary-dark);
  min-height: 34px;
  padding: 7px 8px;
}

.demo-button:hover {
  border-color: var(--primary);
}

label {
  display: grid;
  gap: 7px;
}

label span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

input,
select,
textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font: inherit;
  min-width: 0;
  padding: 9px 10px;
}

textarea {
  resize: vertical;
}

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

button {
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  min-height: 38px;
  padding: 9px 12px;
}

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

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

.secondary-button {
  background: #e8f1fb;
  color: var(--primary-dark);
}

.result-panel {
  display: grid;
  gap: 14px;
}

.hero-result {
  border-left: 5px solid var(--warn);
  padding: 16px;
}

.hero-result[data-state="ok"] {
  border-left-color: var(--ok);
}

.hero-result[data-state="warn"] {
  border-left-color: var(--warn);
}

.hero-result[data-state="bad"] {
  border-left-color: var(--bad);
}

.parcel-title {
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  margin: 8px 0 0;
}

.hero-result p:last-child {
  color: var(--muted);
  margin: 8px 0 0;
}

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

.map-card {
  grid-column: span 2;
}

.map-wrap {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-top: 10px;
  min-height: 220px;
  overflow: hidden;
}

.map-wrap p {
  color: var(--muted);
  margin: 16px;
}

.map-wrap svg {
  display: block;
  height: auto;
  width: 100%;
}

.map-label {
  fill: var(--muted);
  font-size: 12px;
}

article,
.handoff {
  padding: 14px;
}

dl {
  display: grid;
  gap: 7px 10px;
  grid-template-columns: minmax(105px, 0.7fr) minmax(0, 1.3fr);
  margin: 10px 0 0;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
}

ul,
ol {
  margin: 10px 0 0;
  padding-left: 18px;
}

li {
  margin: 6px 0;
}

.check-list li,
.risk-list li,
.restriction-list li,
.building-list li,
.legal-list li,
.planning-list li {
  padding-left: 2px;
}

.restriction-list strong,
.building-list strong,
.planning-list strong {
  display: block;
}

.restriction-meta,
.building-meta,
.planning-meta {
  color: var(--muted);
  display: block;
  font-size: 14px;
  margin-top: 2px;
}

.building-summary-grid {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 6px;
}

.building-summary-grid span {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  display: grid;
  gap: 2px;
  padding: 7px 8px;
}

.building-summary-grid strong {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
}

.building-summary-notes {
  display: grid;
  gap: 3px;
  margin-top: 7px;
}

.building-summary-note {
  color: var(--muted);
  display: block;
  font-size: 14px;
}

.building-metrics {
  color: var(--muted);
  display: grid;
  font-size: 14px;
  gap: 2px;
  margin-top: 4px;
}

.building-metrics span {
  display: block;
}

.building-metrics strong {
  color: var(--text);
  display: inline;
  font-weight: 600;
}

.source-list {
  list-style: none;
  padding-left: 0;
}

.source-list li {
  border-bottom: 1px solid var(--border);
  display: grid;
  gap: 1px;
  margin: 0;
  padding: 7px 0;
}

.source-list li:last-child {
  border-bottom: 0;
}

.link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.link-row a {
  background: #e8f1fb;
  border-radius: 999px;
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 9px;
  text-decoration: none;
}

.link-row a:hover {
  text-decoration: underline;
}

.source-name {
  font-weight: 500;
}

.source-detail {
  color: var(--muted);
  font-size: 13px;
}

.source-date,
.legal-source,
.planning-list .planning-value {
  color: var(--text);
  display: block;
  font-size: 14px;
  margin-top: 2px;
}

.confidence-text,
.legal-role-list {
  color: var(--muted);
  font-size: 13px;
}

.confidence-text {
  margin: 10px 0 0;
}

.legal-role-list {
  list-style: none;
  margin-top: 8px;
  padding-left: 0;
}

.legal-role-list li {
  margin: 4px 0;
}

.condition-badge,
.control-badge {
  border: 1px solid currentColor;
  border-radius: 999px;
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  margin: 3px 4px 0 0;
  padding: 2px 6px;
  vertical-align: 1px;
}

.control-badge {
  background: rgba(0, 0, 0, 0.03);
  min-width: 74px;
  text-align: center;
}

.pass {
  color: var(--ok);
}

.review {
  color: var(--warn);
}

.fail {
  color: var(--bad);
}

.info {
  color: var(--info);
}

.handoff {
  display: grid;
  gap: 12px;
}

.mentor-scope {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.mentor-scope h2 {
  font-size: 22px;
  margin: 0;
}

.scope-metrics {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  list-style: none;
  margin: 0;
  padding: 0;
}

.scope-metrics li {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font-size: 13px;
  margin: 0;
  padding: 8px 10px;
}

.scope-question {
  border: 1px solid var(--border);
  border-radius: 9px;
  display: grid;
  gap: 8px;
  padding: 10px;
}

.scope-question h3,
.scope-question p {
  margin: 0;
}

.scope-question p {
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

.scope-question button {
  justify-self: start;
}

.scope-details {
  color: var(--muted);
}

.scope-details ul {
  margin-top: 8px;
}

.handoff textarea {
  min-height: 150px;
}

.handoff-print {
  display: none;
}

details summary {
  cursor: pointer;
  font-weight: 600;
}

.nested-planning-list {
  margin-top: 8px;
}

.building-details summary {
  cursor: pointer;
}

.building-details span,
.building-details .building-metrics {
  margin-top: 4px;
}

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

  .input-panel {
    position: static;
  }

  .result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .scope-metrics {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .field-grid,
  .demo-cases,
  .registry-progress,
  .scope-metrics,
  .result-grid,
  dl {
    grid-template-columns: 1fr;
  }
}

@media print {
  @page {
    margin: 14mm;
  }

  * {
    color: #111111 !important;
    background: transparent !important;
  }

  body {
    background: #ffffff;
    font-size: 10.5pt;
    line-height: 1.35;
  }

  .topbar,
  .input-panel,
  .topnav,
  .handoff button,
  .scope-question button,
  .scope-details,
  .status-pill {
    display: none;
  }

  .workspace {
    display: block;
    padding: 0;
    max-width: none;
  }

  .result-panel {
    display: block;
  }

  .hero-result,
  .result-panel article,
  .handoff,
  .mentor-scope {
    border: 1px solid #c9d3cf;
    box-shadow: none;
    break-inside: avoid;
    margin-bottom: 8px;
    padding: 9px 10px;
  }

  .result-grid {
    display: grid;
    gap: 8px;
    grid-template-columns: 1fr 1fr;
  }

  .map-card,
  .handoff,
  .mentor-scope {
    grid-column: 1 / -1;
  }

  article h3,
  .handoff h3,
  .scope-question h3 {
    font-size: 11.5pt;
    margin-bottom: 4px;
  }

  ul,
  ol,
  dl {
    margin-top: 5px;
  }

  li {
    margin: 3px 0;
  }

  .planning-meta,
  .building-meta,
  .restriction-meta,
  .source-detail,
  .source-date,
  .legal-source {
    font-size: 9pt;
  }

  .check-list li,
  .legal-list li,
  .risk-list li,
  .restriction-list li,
  .building-list li,
  .planning-list li,
  .source-list li,
  #nextSteps li {
    break-inside: avoid;
    border-color: #d8dfdc;
  }

  .map-wrap {
    min-height: 0;
  }

  .handoff {
    border: 0;
    break-before: auto;
    break-inside: auto;
    margin-top: 8px;
    padding: 0;
  }

  .handoff h3 {
    display: none;
  }

  .mentor-scope {
    break-before: page;
    page-break-before: always;
    break-inside: avoid;
    clear: both;
    margin-top: 0;
  }

  .mentor-scope h2 {
    font-size: 14pt;
  }

  .scope-metrics {
    display: grid;
    gap: 4px;
    grid-template-columns: 1fr;
  }

  .scope-metrics li,
  .scope-question {
    border: 1px solid #d8dfdc;
    break-inside: avoid;
    padding: 6px 8px;
  }

  .scope-question {
    margin-top: 6px;
  }

  .scope-question p {
    font-size: 9.5pt;
  }

  .handoff textarea {
    display: none;
  }

  .handoff-print {
    border: 0;
    break-before: page;
    page-break-before: always;
    break-inside: auto;
    display: block;
    font-family: inherit;
    font-size: 9pt;
    line-height: 1.35;
    overflow: visible;
    padding: 0;
  }

  .brief-block {
    break-inside: auto;
    page-break-inside: auto;
    margin: 0 0 7px;
    white-space: pre-wrap;
    word-break: break-word;
  }

  .brief-block:first-child {
    break-after: avoid;
  }

  a {
    color: #17211f;
    text-decoration: underline;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 8.5pt;
    word-break: break-all;
  }
}
