/* ---- Basic look & feel, tuned for phone screens ---- */
:root {
  --blue: #0b5d8f;
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1a2330;
  --muted: #6b7785;
  --line: #e2e7ec;
  /* Priority / viability colors, 3 (highest) -> 0 (lowest) */
  --p3: #c0392b;
  --p2: #e67e22;
  --p1: #2e86c1;
  --p0: #95a5a6;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  /* leave room for phone notches */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---- Top bar ---- */
.topbar {
  position: sticky;
  top: 0;
  background: var(--blue);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 10;
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 600; }
.topbar .back {
  background: rgba(255,255,255,0.18);
  border: none;
  color: #fff;
  font-size: 16px;
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
}
.topbar .spacer { flex: 1; }

.content { padding: 12px 14px 90px; max-width: 720px; margin: 0 auto; }

/* ---- Controls (sort / filter) ---- */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}
.controls label { font-size: 13px; color: var(--muted); }
select, .chip, button {
  font-family: inherit;
}
select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--muted);
}
.chip.active { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ---- Booth list ---- */
.booth {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}
.booth:active { background: #f0f4f8; }
.booth .info { flex: 1; min-width: 0; }
.booth .company { font-weight: 600; font-size: 16px; }
.booth .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.booth .visited-tag {
  font-size: 11px;
  color: #1e8449;
  font-weight: 600;
}

/* Round badge showing a 0-3 number */
.badge {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}
.badge.lab { width: auto; height: auto; border-radius: 8px; padding: 4px 8px; font-size: 12px; }
.badge.p3 { background: var(--p3); }
.badge.p2 { background: var(--p2); }
.badge.p1 { background: var(--p1); }
.badge.p0 { background: var(--p0); }

.badge-stack { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.badge-stack small { font-size: 10px; color: var(--muted); }

/* ---- Detail screen ---- */
.section { margin-bottom: 22px; }
.section h2 { font-size: 15px; margin: 0 0 8px; }
.field-note { font-size: 12px; color: var(--muted); margin: 0 0 8px; }

.scale {
  display: flex;
  gap: 8px;
}
.scale button {
  flex: 1;
  padding: 12px 0;
  border: 2px solid var(--line);
  background: #fff;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
}
.scale button .lbl { display: block; font-size: 10px; font-weight: 500; color: var(--muted); margin-top: 2px; }
.scale button.sel-3 { border-color: var(--p3); background: var(--p3); color: #fff; }
.scale button.sel-2 { border-color: var(--p2); background: var(--p2); color: #fff; }
.scale button.sel-1 { border-color: var(--p1); background: var(--p1); color: #fff; }
.scale button.sel-0 { border-color: var(--p0); background: var(--p0); color: #fff; }
.scale button.sel-3 .lbl, .scale button.sel-2 .lbl,
.scale button.sel-1 .lbl, .scale button.sel-0 .lbl { color: rgba(255,255,255,0.85); }

textarea {
  width: 100%;
  min-height: 110px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font-size: 15px;
  font-family: inherit;
  resize: vertical;
}

/* Photos — single list, each with a type */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.photo-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.photo-card .thumb {
  width: 100%;
  height: 120px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.photo-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.ptype-row { display: flex; align-items: center; gap: 6px; }
.ptype { flex: 1; width: 100%; }
.ai-badge {
  background: var(--blue);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 5px;
  padding: 2px 5px;
  flex-shrink: 0;
}
.classifying {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  padding: 8px 0;
}
.hint { font-size: 11px; color: var(--p2); }
.pdel {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  align-self: flex-start;
  padding: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
}
.btn.primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn.add { width: 72px; height: 72px; flex-direction: column; font-size: 26px; color: var(--blue); border-style: dashed; }
.btn.add small { font-size: 10px; font-weight: 600; }
.btn.rec { background: #fff; }
.btn.rec.on { background: var(--p3); color: #fff; border-color: var(--p3); }
.btn.block { width: 100%; margin-top: 6px; }
.btn.ghost { background: transparent; border: none; color: var(--blue); }

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

/* Floating add-booth button */
.fab {
  position: fixed;
  right: 18px;
  bottom: 22px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  border: none;
  font-size: 30px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  cursor: pointer;
  z-index: 20;
}

.empty { text-align: center; color: var(--muted); padding: 40px 20px; }

input[type="text"], input[type="number"] {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
}
.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  background: #1a2330;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
  z-index: 30;
}
.toast.show { opacity: 1; }
