*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --header-h: 52px;
}

body {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  color: #1a1a1a;
  background: #f4f4f4;
}

#app { display: flex; flex-direction: column; min-height: 100vh; }

/* Header */
#form-header {
  background: #003366;
  color: white;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
}
#form-header h1 { font-size: 18px; }
#form-header p { font-size: 12px; opacity: 0.85; }
#header-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
#header-actions button {
  background: white;
  color: #003366;
  border: none;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12px;
  font-weight: bold;
  border-radius: 3px;
}
#header-actions button:hover { background: #e0e8f0; }
#save-indicator { font-size: 11px; opacity: 0.8; min-width: 80px; text-align: right; }

/* Layout */
#layout { display: flex; flex: 1; }

/* Nav */
#section-nav {
  width: 160px;
  flex-shrink: 0;
  background: #1a3a5c;
  padding: 16px 0;
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
}
.nav-item {
  display: block;
  padding: 10px 16px;
  color: #b0c8e0;
  text-decoration: none;
  font-size: 13px;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: white; }
.nav-item.active { color: white; border-left-color: #4da6ff; background: rgba(255,255,255,0.05); }

/* Main form area */
#form-main { flex: 65; padding: 24px; min-width: 0; }

/* Form sections */
.form-section { margin-bottom: 48px; padding-bottom: 32px; border-bottom: 1px solid #d0d0d0; }
.section-title {
  font-size: 16px;
  font-weight: bold;
  color: #003366;
  margin-bottom: 16px;
  padding-bottom: 6px;
  border-bottom: 2px solid #003366;
}
.section-subtitle { font-size: 12px; color: #666; margin-bottom: 16px; }

/* Form fields */
.field-group { margin-bottom: 14px; }
.field-row { display: flex; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.field-row .field-group { flex: 1; min-width: 140px; margin-bottom: 0; }

label { display: block; font-size: 12px; font-weight: bold; color: #333; margin-bottom: 4px; }
label .required { color: #cc0000; margin-left: 2px; }

input[type="text"], input[type="email"], input[type="tel"], input[type="number"],
select, textarea {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #aaa;
  font-size: 13px;
  font-family: inherit;
  border-radius: 2px;
  background: white;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid #4da6ff;
  border-color: #4da6ff;
}
textarea { resize: vertical; min-height: 64px; }

/* Radio / checkbox groups */
.radio-group, .checkbox-group { display: flex; gap: 16px; flex-wrap: wrap; }
.radio-group label, .checkbox-group label {
  display: flex; align-items: center; gap: 6px;
  font-weight: normal; cursor: pointer;
}
.radio-group input, .checkbox-group input { width: auto; }

/* Conditional reveal */
.conditional { margin-top: 10px; padding: 10px; background: #f0f4f8; border-left: 3px solid #4da6ff; }

/* Dynamic tables */
.dyn-table { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.dyn-table th {
  background: #e8eef4;
  padding: 6px 8px;
  font-size: 12px;
  text-align: left;
  border: 1px solid #ccc;
}
.dyn-table td { padding: 4px; border: 1px solid #ddd; vertical-align: top; }
.dyn-table td input, .dyn-table td select { border: none; background: transparent; padding: 4px; }
.dyn-table td input:focus, .dyn-table td select:focus { background: white; }

.btn-add {
  margin-top: 8px; padding: 5px 12px; background: #003366; color: white;
  border: none; cursor: pointer; font-size: 12px; border-radius: 2px;
}
.btn-add:hover { background: #004488; }
.btn-remove {
  padding: 2px 8px; background: #cc0000; color: white;
  border: none; cursor: pointer; font-size: 11px; border-radius: 2px;
}
.btn-remove:hover { background: #aa0000; }

/* Coordination warnings (legacy, kept for coordination panel) */
.coord-warning {
  margin-top: 4px; padding: 4px 8px; background: #fff3cd; border: 1px solid #ffc107;
  font-size: 11px; border-radius: 2px;
}
.coord-warning.error { background: #f8d7da; border-color: #dc3545; }

/* Inline coordination chips */
.chip-row { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0 2px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 9px; border-radius: 10px; font-size: 11px; font-weight: 600;
  white-space: nowrap; line-height: 1.7;
}
.chip.clear    { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.chip.warning  { background: #fff8e1; color: #b45309; border: 1px solid #fbbf24; }
.chip.required { background: #fde8e8; color: #b91c1c; border: 1px solid #fca5a5; }
.chip.gap      { background: #f5f5f5; color: #6b7280; border: 1px solid #d1d5db; font-weight: normal; font-style: italic; }
.chip.loading  { background: #eff6ff; color: #1d4ed8; border: 1px solid #93c5fd; font-weight: normal; }
.chip-detail {
  font-size: 11px; color: #333; line-height: 1.5; margin: 3px 0 8px 2px;
  padding: 5px 10px; border-radius: 0 3px 3px 0;
}
.chip-detail.warning  { background: #fffde7; border-left: 3px solid #fbbf24; }
.chip-detail.required { background: #fff5f5; border-left: 3px solid #f87171; }
.chip-detail.gap      { background: #fafafa; border-left: 3px solid #d1d5db; }
.uls-csv-btn {
  font-size: 10px; padding: 1px 7px; border-radius: 8px;
  background: #e8f0fe; color: #1a56db; border: 1px solid #93c5fd;
  cursor: pointer; font-weight: 600; white-space: nowrap; line-height: 1.7;
}
.uls-csv-btn:hover { background: #dbeafe; }

/* Info sidebar */
#info-panel {
  flex: 35;
  min-width: 300px;
  background: white;
  border-left: 1px solid #d0d0d0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}
#info-tabs {
  display: flex;
  border-bottom: 2px solid #003366;
  flex-shrink: 0;
  background: white;
}
.info-tab {
  flex: 1;
  padding: 9px 4px;
  font-size: 11px;
  font-weight: bold;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  color: #888;
  transition: color 0.15s;
}
.info-tab:hover { color: #003366; }
.info-tab.active { color: #003366; border-bottom-color: #003366; }
.info-pane {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}
.info-pane[hidden] { display: none; }
.info-placeholder {
  font-size: 12px;
  color: #aaa;
  font-style: italic;
  text-align: center;
  padding: 40px 12px;
  line-height: 1.6;
}

/* Coordination / Validation results (now inside info-pane) */
.coord-step { margin-bottom: 12px; padding: 10px 12px; border: 1px solid #ddd; border-radius: 4px; font-size: 12px; }
.coord-step.warning  { border-color: #ffc107; background: #fffdf0; }
.coord-step.required { border-color: #dc3545; background: #fff5f5; }
.coord-step.clear    { border-color: #c8e6c9; background: #f5fff7; }
.coord-step.gap      { border-color: #ccc;    background: #f8f8f8; font-style: italic; }

/* Coordinate fields */
.coord-toggle { font-size: 11px; color: #0055aa; cursor: pointer; margin-left: 8px; text-decoration: underline; }
.coord-dms { display: flex; gap: 4px; align-items: center; }
.coord-dms input { flex: 1; }
.coord-dms select { flex: 0 0 50px; }
.geocode-btn {
  padding: 4px 10px; font-size: 11px; background: #0055aa; color: white;
  border: none; cursor: pointer; border-radius: 2px; white-space: nowrap;
}
.geocode-btn:hover { background: #003388; }
.datum-note { font-size: 11px; color: #cc6600; margin-top: 2px; }

/* Footnote content (inside info-pane) */
#info-pane-fn h3 { font-size: 13px; color: #003366; margin-bottom: 8px; }
#info-pane-fn p  { font-size: 12px; line-height: 1.6; color: #333; margin-bottom: 8px; }
#info-pane-fn table { border-collapse: collapse; font-size: 11px; margin: 8px 0; width: 100%; }
#info-pane-fn table th, #info-pane-fn table td { border: 1px solid #ccc; padding: 3px 6px; }
#info-pane-fn table th { background: #e8eef4; }
.fat-fn { cursor: pointer; }
.fat-fn:hover { background: #fde047; }
.fat-fn.active { background: #fbbf24; border-color: #b45309; color: #1c0a00; }

/* FAT band info table */
.fat-table { width: 100%; border-collapse: collapse; font-size: 11px; margin-top: 4px; }
.fat-table th { background: #e8eef4; padding: 4px 6px; text-align: left; border: 1px solid #ccc; font-size: 11px; }
.fat-table td { padding: 3px 6px; border: 1px solid #e0e0e0; vertical-align: top; }
.fat-range { white-space: nowrap; color: #555; font-size: 10px; }
.fat-service { display: inline-block; margin: 1px 2px; padding: 1px 4px; border-radius: 2px; font-size: 10px; }
.fat-primary { background: #dbeafe; color: #1e3a5f; }
.fat-secondary { background: #f3f4f6; color: #555; font-style: italic; }
.fat-fn {
  display: inline-block; margin: 1px 2px; padding: 1px 4px;
  background: #fef9c3; color: #7c5e00; border-radius: 2px; font-size: 10px;
  cursor: help; border: 1px solid #e6d800;
}

@media print {
  #section-nav, #header-actions, #info-panel { display: none !important; }
  #form-header { position: static; background: none; color: black; border-bottom: 2px solid black; }
  #form-main { max-width: 100%; }
  .form-section { page-break-inside: avoid; }
}
