:root {
  --accent: #115e59;
  --accent-soft: #e6f4f3;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --danger: #b91c1c;
  --bg: #f8fafc;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, system-ui, sans-serif; background: var(--bg); color: var(--text); }
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: #fff; border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--accent); text-decoration: none; }
.container { max-width: 960px; margin: 0 auto; padding: 24px 16px 48px; flex: 1; width: 100%; }
.container.editor-wide { max-width: none; padding: 16px 20px 32px; }
.card {
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; margin-bottom: 16px;
}
h1 { font-size: 1.5rem; margin: 0 0 8px; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
.muted { color: var(--muted); font-size: 0.9rem; }
label { display: block; font-size: 0.85rem; font-weight: 600; margin: 12px 0 4px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font: inherit;
}
textarea { min-height: 120px; resize: vertical; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; font-weight: 600; cursor: pointer; font: inherit;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
.alert { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 0.9rem; }
.alert-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.alert-ok { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.wiz-step-err { margin-top: 12px; }
.wiz-step-err:empty { display: none; }
.consent-row { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 16px 0 0; cursor: pointer; }
.consent-row input { width: auto; margin-top: 3px; flex-shrink: 0; }
input[readonly] { background: #f1f5f9; color: var(--muted); }
.customize-hint { margin-top: 16px; background: var(--accent-soft); border-color: #b8e0de; }
.customize-hint h3 { margin: 0 0 8px; font-size: 1rem; }
.customize-hint .btn { margin-top: 8px; }
.loc-status.loc-error { color: var(--danger); font-weight: 600; margin: 6px 0 0; }
.alert-info { background: var(--accent-soft); color: var(--accent); }
.status { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; }
.status-queued, .status-generating, .status-pdf_queued { background: #fef3c7; color: #92400e; }
.status-ready_for_edit { background: #dbeafe; color: #1e40af; }
.status-pdf_ready { background: #d1fae5; color: #065f46; }
.status-failed { background: #fee2e2; color: var(--danger); }
.section-list { list-style: none; padding: 0; margin: 0; }
.section-list li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.section-list li.locked { opacity: 0.7; }
.emsal-item { border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 10px; }
.editor-layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  gap: 20px;
  align-items: start;
  min-height: calc(100vh - 140px);
}
.editor-panel { overflow-y: auto; max-height: calc(100vh - 120px); padding-right: 4px; }
.editor-preview {
  position: sticky;
  top: 12px;
  min-height: 400px;
}
.editor-preview h2 { margin: 0 0 8px; font-size: 1rem; }
.preview-frame {
  width: 100%;
  height: calc(100vh - 160px);
  min-height: 480px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
.sec-title { flex: 1; padding-right: 12px; font-weight: 600; }
@media (max-width: 900px) {
  .editor-layout { grid-template-columns: 1fr; }
  .editor-preview { position: static; order: -1; }
  .editor-panel { max-height: none; }
  .preview-frame { height: min(55vh, 560px); min-height: 360px; }
}
.steps { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.step { padding: 6px 10px; border-radius: 6px; background: #e2e8f0; font-size: 0.8rem; }
.step.active { background: var(--accent); color: #fff; }
.report-list { padding: 0; margin: 20px 0 0; list-style: none; }
.empty-state { margin-top: 20px; }
.loc-wrap { position: relative; }
.loc-dropdown {
  position: absolute; z-index: 20; left: 0; right: 0; top: 100%;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  max-height: 220px; overflow-y: auto; box-shadow: 0 8px 24px rgba(0,0,0,.08);
}
.loc-dropdown.hidden { display: none; }
.loc-item {
  display: block; width: 100%; text-align: left; padding: 10px 12px;
  border: none; background: #fff; cursor: pointer; font: inherit;
}
.loc-item:hover { background: var(--accent-soft); }
.property-form { display: grid; gap: 10px; margin-top: 12px; }
.property-form .form-section { margin: 18px 0 6px; font-size: 0.95rem; font-weight: 600; color: var(--text); border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.property-form label { display: block; margin-top: 4px; font-size: 0.85rem; color: var(--muted); }
.property-form input[type=text],
.property-form input[type=number],
.property-form select,
.property-form textarea { width: 100%; margin-bottom: 4px; }
.property-form .field-emphasis { font-weight: 600; color: var(--text); }
.property-form .field-hint { font-size: 0.8rem; margin: -2px 0 6px; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 12px; margin: 8px 0 12px; }
.checkbox-grid .group-label { grid-column: 1 / -1; font-weight: 600; font-size: 0.85rem; color: var(--text); }
.checkbox-grid .chk { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--text); margin: 0; }
.checkbox-grid .chk input { width: auto; margin: 0; }
.proximity-multi { margin-bottom: 12px; }
.proximity-multi-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.proximity-multi-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center; }
.proximity-multi-row select { margin-bottom: 0; }
.proximity-remove {
  width: 36px; height: 36px; padding: 0; border: 1px solid var(--border, #ccc);
  background: var(--surface, #fff); border-radius: 6px; cursor: pointer; font-size: 1.2rem; line-height: 1;
}
.proximity-add { margin-top: 4px; }
.empty-state p { margin: 0 0 8px; }

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
.spinner {
  border: 4px solid rgba(0, 0, 0, 0.1);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border-left-color: var(--accent);
  animation: spin 1s linear infinite;
}
.ai-status { margin-top: 12px; }
.ai-status.hidden { display: none; }
.ai-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 14px;
}
.ai-loading .spinner {
  width: 22px;
  height: 22px;
  border-width: 3px;
  flex-shrink: 0;
}
