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

/* ── Base ───────────────────────────────────────────────── */
body {
  font-family: system-ui, sans-serif;
  font-size: 15px;
  background: #f5f5f5;
  color: #222;
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────── */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #2c5f2e;
  color: white;
  padding: 0.75rem 1.5rem;
  height: 52px;
}
.site-title { font-weight: 700; font-size: 1.1rem; }
.site-nav { display: flex; gap: 1rem; align-items: center; }
.nav-link {
  color: white;
  text-decoration: none;
  font-size: 0.9rem;
  background: none;
  border: none;
  cursor: pointer;
}
.nav-link:hover { text-decoration: underline; }

/* ── Login ──────────────────────────────────────────────── */
.login-wrap {
  max-width: 360px;
  margin: 6rem auto;
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.login-wrap h1 { margin-bottom: 1.5rem; font-size: 1.3rem; }

/* ── Forms ──────────────────────────────────────────────── */
label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 1rem;
  font-weight: 500;
}
input, select, textarea {
  padding: 0.5rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.95rem;
  font-family: inherit;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid #2c5f2e;
  border-color: #2c5f2e;
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
}
.btn-primary   { background: #2c5f2e; color: white; }
.btn-secondary { background: #666;    color: white; }
.btn-outline   { background: white;   color: #2c5f2e; border: 1px solid #2c5f2e; }
.btn:hover { opacity: 0.85; }
.btn[disabled] { opacity: 0.4; pointer-events: none; }

/* ── Entry layout ───────────────────────────────────────── */
/* Two equal columns filling the screen below the header */
.entry-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 1rem;
  /* Fill remaining screen height after 52px header and 52px nav bar */
  height: calc(100vh - 104px);
}

/* Each panel scrolls independently */
.photo-panel, .form-panel {
  background: white;
  border-radius: 6px;
  padding: 1rem;
  overflow-y: auto;
  height: 100%;
}

/* ── Period tabs ────────────────────────────────────────── */
.period-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.tab-btn {
  padding: 0.4rem 0.9rem;
  border: 1px solid #ccc;
  background: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}
.tab-btn.active { background: #2c5f2e; color: white; border-color: #2c5f2e; }

/* ── Survey form ────────────────────────────────────────── */
.survey-form { padding-top: 0.5rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
fieldset {
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 1rem;
  margin-bottom: 1rem;
}
legend { font-weight: 600; padding: 0 0.5rem; }

/* ── Save status ────────────────────────────────────────── */
.form-actions { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; }
.save-status { font-size: 0.85rem; }

/* ── Record navigation bar ──────────────────────────────── */
.record-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: white;
  border-top: 1px solid #ddd;
  height: 52px;
}

/* ── Dashboard ──────────────────────────────────────────── */
.dashboard-wrap { max-width: 800px; margin: 2rem auto; padding: 0 1rem; }
.dashboard-wrap h1 { margin-bottom: 1.5rem; }

/* ── Buildings list ─────────────────────────────────────── */
.buildings-wrap { max-width: 960px; margin: 2rem auto; padding: 0 1rem; }
.buildings-wrap h1 { margin-bottom: 1rem; }
table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 6px;
  overflow: hidden;
}
th, td { text-align: left; padding: 0.65rem 1rem; border-bottom: 1px solid #eee; }
th { background: #f0f0f0; font-weight: 600; }
tr:hover td { background: #fafafa; }

/* ── Photo toolbar ──────────────────────────────────────── */
.photo-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.building-name { font-weight: 600; font-size: 1rem; }

/* ── Stats page ─────────────────────────────────────────── */
.stats-wrap { max-width: 960px; margin: 2rem auto; padding: 0 1rem; }
.stats-wrap h1 { margin-bottom: 1.5rem; }
.stats-section { margin-bottom: 2rem; }
.stats-section h2 { font-size: 1rem; font-weight: 600; margin-bottom: 0.75rem; color: #444; }
.section-count { font-weight: 400; font-size: 0.85rem; color: #888; margin-left: 0.5rem; }
.no-data { color: #888; font-style: italic; }
.btn-sm { padding: 0.25rem 0.75rem; font-size: 0.8rem; }

/* Progress bar */
.progress-bar {
  position: relative;
  background: #e8e8e8;
  border-radius: 4px;
  height: 20px;
  min-width: 120px;
}
.progress-fill {
  background: #2c5f2e;
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}
.progress-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.75rem;
  font-weight: 600;
  color: #333;
}
/* ── Loading state ──────────────────────────────────────── */
.loading { color: #888; font-style: italic; padding: 1rem; }

/* ── Photo grid ─────────────────────────────────────────── */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.photo-thumb {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid transparent;
}
.photo-thumb:hover { border-color: #2c5f2e; }
.upload-btn {
  display: inline-block;
  cursor: pointer;
  margin-top: 0.5rem;
}
