* { box-sizing: border-box; }

/* Several elements below set their own `display` (flex/grid) for when
   they're shown, which otherwise beats the browser's default
   `[hidden]{display:none}` — an author rule always overrides a user-agent
   one regardless of order/specificity. This makes `el.hidden = true`
   reliable everywhere. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.app {
  position: absolute;
  inset: 0;
  display: flex;
}

#map {
  position: relative;
  flex: 1;
}

/* --- sidebar shell --- */

.sidebar {
  width: 380px;
  flex-shrink: 0;
  background: #ffffff;
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  box-shadow: 2px 0 10px rgba(16, 24, 40, 0.06);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px 15px;
  border-bottom: 1px solid #eef0f2;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: #2563eb;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
  color: #111827;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 1px;
}

.steps {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --- step cards --- */

.step-card {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 14px 16px;
  background: #fff;
  transition: opacity 0.15s ease;
}

.step-card.active {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.10);
}

.step-card.done {
  border-color: #bbf0d1;
  background: #f4fdf8;
}

.step-card.locked {
  opacity: 0.5;
}

.step-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #e5e7eb;
  color: #6b7280;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-num.active { background: #2563eb; color: #fff; }
.step-num.done { background: #16a34a; color: #fff; }

.step-title {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  flex: 1;
}

.step-sub {
  font-size: 12.5px;
  color: #6b7280;
  margin: 6px 0 0 32px;
  line-height: 1.55;
}

.link {
  font-size: 12px;
  color: #2563eb;
  font-weight: 500;
  cursor: pointer;
}
.link:hover { text-decoration: underline; }

/* --- buttons --- */

.btn {
  border: 1px solid #d1d5db;
  background: #fff;
  color: #111827;
  font-size: 13px;
  font-weight: 500;
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.btn:hover:not(:disabled) { background: #f9fafb; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: #1d4ed8; }

.btn-primary.active {
  background: #ea580c;
  border-color: #ea580c;
}

.btn-block { width: 100%; margin-top: 12px; }

/* --- imagery grid --- */

.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 12px 0 8px 32px;
}
.toolbar-row .count { font-size: 12.5px; color: #374151; font-weight: 500; }

.grid {
  margin-left: 32px;
  width: calc(100% - 32px);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.card {
  border: 2px solid transparent;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  cursor: pointer;
}
.card.selected {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.thumb {
  height: 82px;
  position: relative;
  background: #e5e7eb;
}
.thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cloud-pill {
  position: absolute;
  top: 5px;
  right: 5px;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 999px;
  color: #fff;
}

.card-meta { padding: 6px 8px 8px; }
.card-date { font-size: 11.5px; font-weight: 600; color: #111827; }
.card-sub { font-size: 10.5px; color: #9ca3af; margin-top: 1px; }

.mini-selected {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 10px;
  margin-left: 32px;
}
.mini-thumb {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  background: #e5e7eb;
}
.mini-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mini-selected-text { font-size: 12.5px; color: #111827; font-weight: 500; flex: 1; }

/* --- SAM3 panel --- */

.sam-card {
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.06);
}
.sam-card.locked { opacity: 0.5; }

.sam-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 16px;
  background: #eff6ff;
}
.sam-head-title { font-size: 13.5px; font-weight: 600; color: #1e3a8a; flex: 1; }

.sam-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-label {
  font-size: 11px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.res-line {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 11.5px;
  color: #6b7280;
  background: #f9fafb;
  border: 1px solid #eef0f2;
  border-radius: 7px;
  padding: 8px 10px;
  line-height: 1.5;
}
.res-line strong { color: #374151; font-weight: 600; }

.slider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: #374151;
  font-weight: 600;
}
.slider-input { width: 100%; margin-top: 8px; accent-color: #2563eb; }

.divider-label {
  font-size: 11px;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 8px;
}

#results-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
}

.result-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border: 1px solid #f0d5d3;
  background: #fef4f3;
  border-radius: 8px;
}
.result-row.dimmed { opacity: 0.4; }
.result-swatch { width: 11px; height: 11px; border-radius: 3px; background: #dc2626; flex-shrink: 0; }
.result-text { flex: 1; font-size: 12px; color: #111827; }
.result-text .sub { color: #9ca3af; font-size: 10.5px; }
.icon-btn {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  cursor: pointer;
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 0;
}
.icon-btn:hover { color: #dc2626; background: #fde8e8; }

/* --- auth gate --- */

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(17, 24, 39, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  width: 320px;
  background: #fff;
  border-radius: 14px;
  padding: 28px 26px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(16, 24, 40, 0.25);
}

.auth-title {
  font-size: 16px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 6px;
}

.auth-sub {
  font-size: 12.5px;
  color: #6b7280;
  line-height: 1.5;
  margin-bottom: 18px;
}

.auth-sub.denied { color: #dc2626; }

/* --- footer / status --- */

.footer-note {
  padding: 12px 20px;
  border-top: 1px solid #eef0f2;
  font-size: 11.5px;
  color: #6b7280;
  line-height: 1.5;
}
