:root {
  --navy: #143352;
  --green: #6dbe45;
  --bg: #f4f6f8;
  --border: #d7dde3;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: #1a1a1a;
}

.topbar {
  background: var(--navy);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand { font-size: 20px; font-weight: 600; text-transform: lowercase; }
.badge {
  background: var(--green);
  color: #fff;
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 700;
  letter-spacing: 1px;
}

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
}

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 16px;
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.field-row > label, .field-row > fieldset {
  flex: 1 1 200px;
}

.field-row select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 15px;
  font-weight: 400;
  color: #1a1a1a;
  background: #fff;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #45536a;
  margin-bottom: 12px;
}

input[type="text"], input[type="date"], textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 15px;
  font-weight: 400;
  color: #1a1a1a;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
}

legend {
  font-size: 13px;
  font-weight: 600;
  color: #45536a;
  padding: 0 4px;
}

.radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 16px;
  font-weight: 400;
  color: #1a1a1a;
}
.radio input { margin: 0; }

.sections-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

.section-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.section-header {
  background: var(--navy);
  color: #fff;
  padding: 10px 14px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.section-header .subtitle {
  font-weight: 400;
  font-size: 13px;
  opacity: 0.85;
  display: block;
}

.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.item-row:last-of-type { border-bottom: none; }

.item-row label {
  margin: 0;
  font-weight: 400;
  color: #1a1a1a;
  font-size: 12px;
}

.item-row input[type="number"] {
  width: 64px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-align: center;
}

.item-row-spacer { visibility: hidden; }
.item-row-spacer-label { font-size: 14px; }
.item-row-spacer-input {
  display: inline-block;
  width: 64px;
  height: 29px;
  border: 1px solid transparent;
  border-radius: 6px;
  text-align: center;
  font-size: inherit;
}

.section-footer {
  background: var(--green);
  color: #fff;
  text-align: right;
  padding: 8px 14px;
  font-weight: 700;
}

.total-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--navy);
  color: #fff;
}
.total-label { font-weight: 700; letter-spacing: 1px; }
.total-value { font-size: 24px; font-weight: 700; }

.errors {
  background: #fdecea;
  border: 1px solid #f3b3ac;
  color: #9c2b1f;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 16px;
}
.errors ul { margin: 0; padding-left: 18px; }

.actions { text-align: right; margin-bottom: 40px; }

button {
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }

.zones-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.secondary-btn {
  background: #fff;
  color: var(--navy);
  border: 1px solid var(--navy);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.zone-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.zone-row:last-child { border-bottom: none; }

.zone-row-main {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.zone-row-main label { flex: 1; margin-bottom: 0; min-width: 100px; }
.zone-row-main input, .zone-row-main select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 400;
}
.zone-row .collapse-zone-btn {
  padding: 8px 10px;
  height: 38px;
  line-height: 1;
  font-size: 11px;
}
.zone-row--collapsed .zone-row-main { margin-bottom: 0; }
.zone-row .remove-zone-btn {
  background: #fdecea;
  color: #9c2b1f;
  border: 1px solid #f3b3ac;
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 700;
  height: 38px;
}
.zones-empty { color: #8a94a3; font-size: 14px; font-style: italic; }

.zone-deficiencies { margin: 10px 0; padding-top: 10px; border-top: 1px dashed var(--border); }
.zone-deficiencies-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #45536a;
}
.deficiency-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}
.deficiency-row:last-child { margin-bottom: 0; }
.deficiency-row select {
  flex: 0 0 200px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}
.deficiency-row input {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}
.deficiency-row .remove-deficiency-btn {
  background: #fdecea;
  color: #9c2b1f;
  border: 1px solid #f3b3ac;
  border-radius: 6px;
  padding: 4px 9px;
  cursor: pointer;
  font-weight: 700;
}

#zone-details-list .zone-detail-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 10px;
  font-size: 14px;
}
#zone-details-list .zone-detail-card h4 { margin: 0 0 6px; font-size: 14px; }
#zone-details-list .zone-detail-card ul { margin: 6px 0; padding-left: 18px; }

.zc-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.zc-status { font-size: 12px; color: #6b7684; }

.zc-canvas {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fafbfc;
  cursor: crosshair;
  display: block;
  max-width: 100%;
}

.zc-head-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.zc-head-list-empty {
  padding: 10px;
  font-size: 12px;
  color: #8a94a3;
  font-style: italic;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fafbfc;
}
.zc-head-list-item {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: 6px;
  background: #fff;
}
.zc-head-list-item.selected { border-left-color: var(--green); background: #f6fbf3; }
.zc-head-list-heading {
  display: flex;
  align-items: center;
  gap: 10px;
}
.zc-head-list-heading strong { flex: 1; font-size: 14px; color: var(--navy); }
.zc-head-list-detail { margin-top: 10px; }

#narrative-text {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  background: #fafbfc;
}

#result h3 { margin-bottom: 6px; margin-top: 20px; }
#result ul { padding-left: 20px; margin: 0; }
#result li { margin-bottom: 6px; font-size: 14px; }
.upgrade-source { display: block; color: #6b7684; font-size: 12px; margin-top: 2px; }
.disclaimer { font-size: 12px; color: #8a94a3; margin-top: 10px; }

#sm-search-results { font-size: 14px; }
#sm-search-results .sm-result {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-top: 6px;
  cursor: pointer;
}
#sm-search-results .sm-result.selected {
  border-color: var(--green);
  background: #f0f9ec;
}
