/* Form-specific styles. Reuses tokens from styles.css */

.form-page {
  min-height: 100vh;
  padding-bottom: 100px;
}

.topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: linear-gradient(135deg, #0a3f70 0%, #0f5ea8 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(10, 63, 112, 0.18);
}
.topnav-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
}
.topnav-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.5px;
}
.topnav-links {
  display: flex;
  gap: 4px;
  flex: 1;
  align-items: center;
}
.topnav-page-title {
  color: rgba(255, 255, 255, 0.92);
  font-weight: 600;
  font-size: 14px;
  padding: 6px 14px;
  border-left: 1px solid rgba(255, 255, 255, 0.18);
  margin-left: 4px;
  letter-spacing: 0.01em;
}
@media (max-width: 480px) {
  .topnav-page-title { font-size: 12px; padding: 4px 8px; border-left: 0; margin-left: 0; }
}
.topnav-links a {
  padding: 8px 14px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.2s, color 0.2s;
}
.topnav-links a:hover { background: rgba(255, 255, 255, 0.10); color: #fff; }
.topnav-links a.active { background: rgba(255, 255, 255, 0.18); color: #fff; }
.conn-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 12px;
  font-weight: 700;
}
.conn-badge.online .conn-badge-dot { background: #4ade80; }
.conn-badge.offline { background: rgba(220, 38, 38, 0.35); color: #fca5a5; }
.conn-badge.offline .conn-badge-dot { background: #f87171; }
.conn-badge-dot { width: 8px; height: 8px; border-radius: 50%; }

.topnav-install-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border: 0;
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.15s;
}
.topnav-install-btn:hover { background: rgba(255, 255, 255, 0.30); }
.topnav-install-btn span { font-size: 14px; line-height: 1; }
@media (max-width: 480px) {
  .topnav-install-btn { padding: 5px 10px; font-size: 11.5px; }
}

.form-shell {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px;
}

.form-hero {
  margin-bottom: 18px;
}
.form-hero h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.form-hero p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.form-status {
  display: none;
  padding: 10px 14px;
  margin-bottom: 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
}
.form-status.show { display: block; }
.form-status.info { background: #e9f2fb; color: var(--brand-dark); }
.form-status.warn { background: #fff5e6; color: var(--amber); }
.form-status.error { background: #fde8e6; color: var(--red); }
.form-status.ok { background: #e7f6ec; color: var(--green); }

.form-card {
  background: var(--panel);
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 18px 18px 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.form-card h2 {
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.01em;
}
.form-card h2 small {
  color: var(--muted);
  font-weight: 500;
  font-size: 12.5px;
  margin-left: auto;
}
.form-card h2 .step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, #0f5ea8, #0a3f70);
  color: #fff;
  font-size: 12.5px;
  font-weight: 800;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--ink);
}
.field > span:first-child,
.field-label {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.field em { color: var(--red); font-style: normal; }

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font: inherit;
  background: #fff;
  color: var(--ink);
  min-height: 46px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 94, 168, 0.14);
}
.field textarea { min-height: 80px; resize: vertical; }
.field.error input,
.field.error select,
.field.error textarea {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(190, 58, 49, 0.12);
}
.field-error-msg {
  font-size: 12px;
  color: var(--red);
  font-weight: 600;
  margin-top: 4px;
}

.segmented {
  display: inline-flex;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
.segmented button {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
  min-height: 46px;
}
.segmented button.active {
  background: linear-gradient(135deg, #0f5ea8, #0a3f70);
  color: #fff;
}

.weather-row {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.weather-row .field-label { width: 100%; margin-bottom: 4px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  min-height: 40px;
}
.chip:hover { background: var(--panel-alt); }
.chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

#hujanDuration {
  flex: 1 1 200px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
}

/* Equipment section */
.equip-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  align-items: center;
}
.equip-search {
  flex: 1 1 220px;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font: inherit;
  min-height: 42px;
}
.equip-filter-types {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.equip-filter-types .chip { padding: 6px 12px; font-size: 12px; min-height: 32px; }

.equip-list {
  max-height: 480px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-alt);
}
.empty-state {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.equip-row {
  display: grid;
  grid-template-columns: 32px 1fr;
  align-items: start;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.equip-row:last-child { border-bottom: none; }
.equip-row.checked { background: linear-gradient(180deg, #f0f7ff 0%, #fff 100%); }
.equip-row input[type="checkbox"] {
  width: 22px; height: 22px;
  accent-color: var(--brand);
  margin-top: 2px;
}
.equip-row .equip-meta {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.equip-row .equip-meta-sub {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.equip-row .equip-inputs {
  display: none; /* legacy; jam di-edit di selected-units-table */
}
.equip-row-checked-note {
  grid-column: 1 / -1;
  margin-top: 8px;
  padding: 5px 10px;
  border-radius: 6px;
  background: rgba(15, 94, 168, 0.08);
  color: var(--brand-dark);
  font-size: 11.5px;
  font-weight: 600;
}
.equip-row .equip-inputs label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.equip-row .equip-inputs input {
  padding: 8px 10px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  min-height: 38px;
}
.equip-row .equip-inputs input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(15, 94, 168, 0.12);
}
.equip-row .equip-hm-summary {
  grid-column: 1 / -1;
  display: none;
  font-size: 12px;
  font-weight: 700;
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(15, 94, 168, 0.08);
  color: var(--brand-dark);
}
.equip-row.checked .equip-hm-summary { display: inline-block; }
.equip-row .equip-hm-summary.warn { background: rgba(194, 122, 26, 0.12); color: var(--amber); }
.equip-row .equip-hm-summary.error { background: rgba(190, 58, 49, 0.10); color: var(--red); }

/* Photo */
.photo-area { margin-bottom: 12px; }
.photo-pick-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.photo-pick-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  min-height: 50px;
  transition: all 0.15s;
}
.photo-pick-btn:hover { border-color: var(--brand); background: rgba(15, 94, 168, 0.06); }
.photo-pick-btn.primary {
  background: linear-gradient(135deg, #0f5ea8 0%, #0a3f70 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(10, 63, 112, 0.20);
}
.photo-pick-btn.primary:hover {
  background: linear-gradient(135deg, #0a3f70 0%, #062847 100%);
}
.photo-pick-btn span { font-size: 22px; line-height: 1; }
.photo-status-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 4px 8px;
  font-size: 12.5px;
}
.photo-status-row strong { color: var(--ink); font-weight: 700; }
.photo-status-row span { color: var(--muted); font-size: 12px; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.photo-thumb {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel-alt);
  aspect-ratio: 1;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb .photo-remove {
  position: absolute;
  top: 4px; right: 4px;
  width: 28px; height: 28px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  border: 0;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-thumb .photo-info {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  padding: 4px 8px;
  font-size: 10.5px;
  font-weight: 600;
}

/* Submit bar */
.submit-bar {
  position: sticky;
  bottom: 0;
  left: 0; right: 0;
  margin: 18px -16px -24px;
  padding: 14px 16px 18px;
  background: linear-gradient(180deg, rgba(247,250,252,0) 0%, var(--bg) 30%);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.submit-summary {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
  text-align: center;
}
.submit-summary.ready { color: var(--green); }

/* Validation error message di submit bar (bottom of form) */
.submit-error {
  background: #fde8e6;
  color: #c53030;
  border: 1.5px solid rgba(190, 58, 49, 0.30);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  animation: shake 0.35s ease;
}
.submit-error::before {
  content: '⚠️';
  font-size: 16px;
  flex-shrink: 0;
}
.submit-error[hidden] { display: none !important; }
.submit-error ul {
  margin: 4px 0 0 0;
  padding-left: 18px;
  flex: 1;
}
.submit-error ul li {
  margin-bottom: 2px;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}
.submit-actions {
  display: flex;
  gap: 8px;
}
.btn {
  flex: 1;
  border: 0;
  border-radius: 10px;
  padding: 14px 18px;
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
  min-height: 48px;
  transition: transform 0.1s, box-shadow 0.15s, background 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, #0f5ea8 0%, #0a3f70 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(10, 63, 112, 0.30);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #0a3f70 0%, #062847 100%);
  box-shadow: 0 6px 20px rgba(10, 63, 112, 0.42);
}
.btn-ghost {
  background: var(--panel);
  border: 1.5px solid var(--line);
  color: var(--muted);
}
.btn-ghost:hover { background: var(--panel-alt); border-color: var(--line-strong); }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 24, 40, 0.66);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
  animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal[hidden] { display: none !important; }
.modal-card {
  background: var(--panel);
  border-radius: 16px;
  padding: 24px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-strong);
}
.modal-icon-success {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1f7a4d, #15a36e);
  color: #fff;
  font-size: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.modal-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
}
.modal-card p {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}
.modal-actions {
  display: flex;
  gap: 8px;
}

/* Loading overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.92);
  z-index: 150;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.loading-overlay[hidden] { display: none !important; }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay p { color: var(--ink); font-weight: 600; font-size: 14px; }

/* Form hints & helpers */
.form-hint {
  margin: 0 0 12px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}

/* Quick actions row */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}
.btn-quick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1.5px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  min-height: 38px;
  transition: all 0.15s;
}
.btn-quick:hover { border-color: var(--brand); background: rgba(15, 94, 168, 0.06); }
.quick-badge {
  background: var(--amber);
  color: #fff;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 700;
}
.draft-status {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 500;
}
.draft-status.saved { color: var(--green); }
.draft-status.error { color: var(--red); }

/* Collapsible sections */
.collapsible .collapsible-trigger {
  cursor: pointer;
  user-select: none;
}
.collapsible .collapse-icon {
  margin-left: auto;
  transition: transform 0.2s;
  font-size: 11px;
  color: var(--muted);
}
.collapsible.collapsed .collapse-icon { transform: rotate(-90deg); }
.collapsible.collapsed .collapsible-body { display: none; }

/* Shift presets */
.shift-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.preset-btn {
  flex: 1 1 auto;
  padding: 10px 12px;
  border: 1.5px solid var(--brand);
  background: rgba(15, 94, 168, 0.08);
  color: var(--brand-dark);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  min-height: 38px;
}
.preset-btn:hover:not(:disabled) { background: rgba(15, 94, 168, 0.16); }
.preset-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: var(--panel-alt);
  border-color: var(--line);
  color: var(--muted);
}
.preset-btn.ghost {
  border-color: var(--line);
  background: var(--panel);
  color: var(--muted);
}
.preset-btn.ghost:disabled { opacity: 0.45; }

/* My reports panel */
.my-reports { max-height: 360px; overflow-y: auto; }
.my-report-item {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--panel-alt);
}
.my-report-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.my-report-meta {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
  font-weight: 500;
}

/* Offline queue banner */
.form-status .btn-link {
  background: none;
  border: 0;
  color: var(--brand-dark);
  text-decoration: underline;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  margin-left: 8px;
  padding: 0;
}

/* Markdown preview & WhatsApp button */
.markdown-preview-wrap {
  margin: 14px 0;
  text-align: left;
  background: var(--panel-alt);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
}
.markdown-preview-wrap summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: var(--brand-dark);
  padding: 4px 0;
}
.markdown-preview-wrap pre {
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  font-size: 11.5px;
  white-space: pre-wrap;
  max-height: 260px;
  overflow-y: auto;
  background: #fff;
  padding: 10px;
  border-radius: 6px;
  margin: 8px 0;
  color: var(--ink);
}
.btn-small { padding: 6px 10px; font-size: 12px; min-height: 32px; flex: 0 0 auto; }
.btn-wa {
  background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(18, 140, 126, 0.35);
}
.btn-wa:hover:not(:disabled) {
  background: linear-gradient(135deg, #1fb858 0%, #0e7368 100%);
}

/* PWA install prompt banner */
.install-banner {
  position: fixed;
  bottom: 16px;
  left: 16px;
  right: 16px;
  max-width: 480px;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow-strong);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 100;
  animation: slideUp 0.3s;
}
@keyframes slideUp { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.install-banner-text { flex: 1; font-size: 13px; line-height: 1.4; }
.install-banner-text strong { display: block; color: var(--ink); font-weight: 700; }
.install-banner-text span { color: var(--muted); font-size: 12px; }
.install-banner button { padding: 8px 14px; min-height: 36px; font-size: 13px; flex: 0 0 auto; }

/* Project detail panel (read-only) */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}
.detail-cell {
  background: var(--panel-alt);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}
.detail-cell-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.detail-cell-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin-top: 2px;
}

/* Sticky equipment toolbar */
.sticky-toolbar {
  position: sticky;
  top: 56px;
  z-index: 10;
  background: var(--panel);
  padding: 8px 0;
  margin: -8px 0 12px;
  border-bottom: 1px solid var(--line);
}
.equip-search-wrap {
  position: relative;
  flex: 1 1 220px;
}
.equip-search-count {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  background: var(--panel-alt);
  padding: 3px 8px;
  border-radius: 999px;
  pointer-events: none;
}

/* Highlighted matched text */
.equip-row mark {
  background: rgba(255, 230, 0, 0.45);
  color: inherit;
  padding: 0 2px;
  border-radius: 3px;
}
.equip-recent-badge {
  display: inline-block;
  color: var(--amber);
  font-size: 11px;
  margin-left: 4px;
}

/* Selected units table — pengawas isi jam di sini, list di bawah cuma untuk select */
.selected-units-table {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.selected-unit-card {
  background: var(--panel-alt);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  position: relative;
}
.selected-unit-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.selected-unit-header .unit-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  flex: 1;
}
.selected-unit-header .unit-sub {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 500;
  margin-top: 2px;
}
.selected-unit-remove {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 0;
  background: rgba(190, 58, 49, 0.10);
  color: var(--red);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
}
.selected-unit-remove:hover { background: rgba(190, 58, 49, 0.22); }
.selected-unit-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
}
.selected-unit-inputs label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.selected-unit-inputs input {
  padding: 9px 10px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 13.5px;
  min-height: 40px;
  background: #fff;
}
.selected-unit-inputs input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 94, 168, 0.14);
}
.selected-unit-inputs input.invalid {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(190, 58, 49, 0.10);
}
.selected-unit-summary {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(15, 94, 168, 0.08);
  color: var(--brand-dark);
  font-size: 12.5px;
  font-weight: 700;
}
.selected-unit-summary.warn { background: rgba(194, 122, 26, 0.14); color: var(--amber); }
.selected-unit-summary.error { background: rgba(190, 58, 49, 0.10); color: var(--red); }
#selectedUnitsSummary { color: var(--green); font-weight: 600; font-size: 12px; }
.selected-unit-card.highlight-new {
  animation: cardHighlight 1.5s ease;
}
@keyframes cardHighlight {
  0%   { box-shadow: 0 0 0 0 rgba(31, 122, 77, 0.0); transform: scale(1); }
  20%  { box-shadow: 0 0 0 4px rgba(31, 122, 77, 0.45); transform: scale(1.01); }
  100% { box-shadow: 0 0 0 0 rgba(31, 122, 77, 0); transform: scale(1); }
}
.equip-match-badge {
  display: inline-block;
  color: var(--green);
  font-size: 14px;
  margin-left: 4px;
  font-weight: 900;
  line-height: 1;
}
.equip-project-label {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--brand-dark);
  background: rgba(15, 94, 168, 0.10);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 4px;
  letter-spacing: 0.02em;
}
.equip-row.is-match {
  background: linear-gradient(180deg, rgba(31, 122, 77, 0.05) 0%, #fff 100%);
  border-left: 3px solid var(--green);
  padding-left: 11px;
}

/* Equipment recommendations */
.equip-recommend {
  background: linear-gradient(135deg, rgba(15, 94, 168, 0.06), rgba(31, 122, 77, 0.06));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.equip-recommend-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--brand-dark);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.equip-recommend-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.equip-recommend-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s;
}
.equip-recommend-chip:hover {
  border-color: var(--brand);
  background: rgba(15, 94, 168, 0.08);
}
.equip-recommend-chip.checked {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.equip-recommend-chip small {
  font-size: 10px;
  font-weight: 500;
  opacity: 0.7;
}

/* Btn link tiny */
.btn-link-tiny {
  background: none;
  border: 0;
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  padding: 0 0 0 8px;
  text-decoration: underline;
  margin-left: auto;
}
.btn-link-tiny:hover { color: var(--brand); }

/* Markdown mode toggle */
.markdown-mode-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin: 8px 0;
  background: #fff;
}
.markdown-mode-toggle .mode-btn {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  min-height: 32px;
}
.markdown-mode-toggle .mode-btn.active {
  background: var(--brand);
  color: #fff;
}

/* =========================================
   Responsive — phones, tablets, all sizes
   ========================================= */

/* Tablet & up (768+) — already optimized */

/* Phone large (481-767) */
@media (max-width: 767px) {
  .form-shell { max-width: 100%; padding: 18px 14px; }
  .form-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
  .form-card { padding: 18px 16px; }
}

/* Phone standard (≤480px, mostly Android & iPhone Plus) */
@media (max-width: 480px) {
  .form-shell { padding: 14px 10px; }
  .form-card { padding: 14px 12px; }
  .form-card h2 { font-size: 14px; gap: 8px; }
  .form-card h2 .step { width: 24px; height: 24px; font-size: 11.5px; }
  .topnav { padding: 10px 12px; gap: 10px; }
  .topnav-page-title { font-size: 12px; padding: 4px 0 4px 10px; border-left: 1px solid rgba(255,255,255,0.18); margin-left: 0; }
  .topnav-brand { font-size: 14px; gap: 8px; }
  .topnav-logo { width: 28px; height: 28px; font-size: 11px; }
  .conn-badge { padding: 5px 9px; font-size: 11px; }
  .topnav-install-btn { padding: 5px 10px; font-size: 11px; }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .btn { flex: 1 1 100%; }
  .sticky-toolbar { top: 48px; }
  .form-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .quick-actions { gap: 6px; }
  .btn-quick { font-size: 12px; padding: 7px 10px; }
  .draft-status { font-size: 11px; flex: 1 1 100%; margin-left: 0; }
  .photo-pick-row { gap: 8px; }
  .photo-pick-btn { padding: 12px 12px; font-size: 13px; }
  .selected-unit-inputs { grid-template-columns: 1fr 1fr; gap: 8px; }
  .selected-unit-card { padding: 11px 12px; }
  .equip-row { padding: 10px 12px; }
  .equip-row.is-match { padding-left: 9px; }
  .preset-btn { font-size: 11.5px; padding: 8px 10px; }
  .chips { gap: 4px; }
  .chip { padding: 7px 12px; font-size: 12.5px; }
}

/* Phone small (≤375px, iPhone SE, mini Android) */
@media (max-width: 375px) {
  .form-shell { padding: 12px 8px; }
  .form-card { padding: 12px 10px; border-radius: 12px; }
  .topnav { padding: 8px 10px; gap: 8px; }
  .topnav-brand span:not(.topnav-logo) { display: none; }  /* Hide brand text, keep logo */
  .topnav-page-title { font-size: 11.5px; padding-left: 8px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-card h2 { font-size: 13.5px; flex-wrap: wrap; }
  .form-card h2 small { width: 100%; margin-left: 36px; font-size: 11px; }
  .modal-card { padding: 18px 14px; }
  .selected-unit-inputs { grid-template-columns: 1fr 1fr; }
  .equip-search { font-size: 13px; padding: 10px 70px 10px 12px; }
  .equip-search-count { font-size: 10.5px; padding: 2px 6px; }
  .preset-btn { flex: 1 1 calc(50% - 4px); font-size: 11px; padding: 7px 8px; min-height: 36px; }
  .photo-pick-btn { padding: 11px 10px; font-size: 13px; min-height: 46px; }
  .photo-pick-btn span { font-size: 20px; }
  .btn { font-size: 13px; padding: 12px 14px; }
  .install-banner { left: 8px; right: 8px; padding: 10px 12px; }
  .install-banner-text strong { font-size: 13px; }
  .install-banner-text span { font-size: 11px; }
}

/* Phone extra-small (≤320px, original iPhone SE landscape, very old Android) */
@media (max-width: 320px) {
  .topnav { padding: 8px 8px; gap: 6px; }
  .topnav-page-title { display: none; }  /* Hide page title — keep just logo + install + badge */
  .form-shell { padding: 10px 6px; }
  .form-card { padding: 10px 8px; }
  .selected-unit-inputs { grid-template-columns: 1fr; }
  .preset-btn { flex: 1 1 100%; }
  .modal-card { padding: 16px 12px; }
  .modal-card h3 { font-size: 16px; }
  .form-card h2 { font-size: 13px; }
}

/* Landscape orientation tweaks */
@media (orientation: landscape) and (max-height: 500px) {
  .form-hero { display: none; }  /* Save vertical space */
  .topnav { padding: 6px 12px; }
}

/* Tablet (768+) — wider form */
@media (min-width: 768px) {
  .form-shell { max-width: 800px; padding: 28px 24px; }
  .form-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
  .selected-unit-inputs { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
}

/* Large tablet / desktop (1024+) */
@media (min-width: 1024px) {
  .form-shell { max-width: 920px; }
}

/* Very large screens (1280+) */
@media (min-width: 1280px) {
  .form-shell { max-width: 1024px; }
}

/* High DPI / retina — sharper borders */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .form-card, .selected-unit-card, .equip-row {
    border-width: 0.5px;
  }
}
