:root {
  --teal: #1a8a9a;
  --teal-dark: #136878;
  --teal-light: #e8f6f8;
  --teal-mid: #b2dde4;
  --cream: #faf8f3;
  --text: #2c2c2c;
  --muted: #666;
  --border: #dde8ea;
  --white: #fff;
  --danger: #c62828;
  --danger-light: #fdecea;
  --success: #2e7d32;
  --success-light: #e8f5e9;
  --warn: #e65100;
  --warn-light: #fff3e0;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--cream);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* ── Nav ───────────────────────────────────────────── */
.app-nav {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-nav__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--teal-dark);
  text-decoration: none;
  flex-shrink: 0;
}
.app-nav__logo:hover { text-decoration: none; }
.app-nav__logo img { height: 40px; width: auto; }
.app-nav__logo span { font-size: 1rem; white-space: nowrap; }

.app-nav__links {
  display: flex;
  gap: 4px;
  flex: 1;
}
.app-nav__links a {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
  padding: 6px 13px;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}
.app-nav__links a:hover,
.app-nav__links a.active {
  background: var(--teal-light);
  color: var(--teal-dark);
  text-decoration: none;
}

.app-nav__user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}
.app-nav__user > span { font-size: 0.88rem; color: var(--muted); }

.btn-logout {
  background: var(--teal-light);
  color: var(--teal-dark) !important;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none !important;
  transition: background 0.15s;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.btn-logout:hover { background: var(--teal-mid); }

/* ── Role badges ────────────────────────────────────── */
.role-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 10px;
  border-radius: 20px;
}
.role-superadmin { background: #fce4ec; color: #c62828; }
.role-head       { background: #e3f2fd; color: #1565c0; }
.role-member     { background: var(--teal-light); color: var(--teal-dark); }

/* ── Layout ─────────────────────────────────────────── */
.app-main { flex: 1; padding: 2rem; }
.container { max-width: 1100px; margin: 0 auto; }
.container--narrow { max-width: 680px; margin: 0 auto; }

/* ── Flash messages ─────────────────────────────────── */
.flash-container { max-width: 1100px; margin: 0 auto 1.5rem; }
.flash {
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 0.9rem;
  margin-bottom: 8px;
  font-weight: 500;
  border: 1px solid transparent;
}
.flash--success { background: var(--success-light); color: var(--success); border-color: #a5d6a7; }
.flash--error   { background: var(--danger-light); color: var(--danger); border-color: #ef9a9a; }
.flash--info    { background: var(--teal-light); color: var(--teal-dark); border-color: var(--teal-mid); }

/* ── Page header ────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 2rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-header h1 { font-size: 1.55rem; font-weight: 800; letter-spacing: -0.02em; }
.page-header p  { color: var(--muted); margin-top: 4px; font-size: 0.9rem; }
.page-header__actions { display: flex; gap: 0.75rem; align-items: center; flex-shrink: 0; }

/* ── Buttons ────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  line-height: 1.2;
  font-family: inherit;
}
.btn:hover { text-decoration: none; }

.btn-primary   { background: var(--teal); color: var(--white); }
.btn-primary:hover   { background: var(--teal-dark); color: var(--white); }

.btn-secondary { background: var(--teal-light); color: var(--teal-dark); border: 1px solid var(--teal-mid); }
.btn-secondary:hover { background: var(--teal-mid); color: var(--teal-dark); }

.btn-danger    { background: var(--danger-light); color: var(--danger); border: 1px solid #ef9a9a; }
.btn-danger:hover    { background: var(--danger); color: var(--white); }

.btn-success   { background: var(--success-light); color: var(--success); border: 1px solid #a5d6a7; }
.btn-success:hover   { background: var(--success); color: var(--white); }

.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; }

/* ── Cards ──────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
}

/* ── Dog cards ──────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}

.dog-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.15s;
  display: block;
  color: var(--text);
  text-decoration: none;
}
.dog-card:hover {
  box-shadow: 0 8px 24px rgba(26,138,154,0.13);
  transform: translateY(-2px);
  text-decoration: none;
  color: var(--text);
}
.dog-card__img {
  width: 100%;
  height: 190px;
  object-fit: cover;
  background: var(--teal-light);
}
.dog-card__body { padding: 1rem 1.1rem 1.1rem; }
.dog-card__title { font-size: 0.95rem; font-weight: 700; margin-bottom: 4px; }
.dog-card__meta  { font-size: 0.78rem; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.dog-card__badges { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

/* ── Badges ─────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid transparent;
}
.badge-mapped  { background: var(--success-light); color: var(--success); border-color: #a5d6a7; }
.badge-pending { background: var(--warn-light); color: var(--warn); border-color: #ffcc80; }

/* ── Stats ──────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  text-align: center;
}
.stat-card .num { font-size: 2.2rem; font-weight: 800; color: var(--teal); line-height: 1; }
.stat-card .lbl { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }

/* ── Table ──────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--white);
}
table { width: 100%; border-collapse: collapse; }
th {
  background: var(--cream);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 12px 16px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fdfd; }

/* ── Forms ──────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  font-size: 0.86rem;
  font-weight: 600;
  margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.93rem;
  font-family: inherit;
  background: var(--white);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(26,138,154,0.1);
}
.form-group textarea { resize: vertical; min-height: 90px; }
.form-hint { font-size: 0.78rem; color: var(--muted); margin-top: 5px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ── Section heading ────────────────────────────────── */
.section-heading {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.divider { border: none; border-top: 1px solid var(--border); margin: 1.75rem 0; }

/* ── Dog detail ─────────────────────────────────────── */
.dog-detail-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 2rem;
  align-items: start;
}

.dog-detail-photo {
  width: 100%;
  border-radius: 14px;
  object-fit: cover;
  max-height: 500px;
}

.dog-detail-info h1 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}
.dog-detail-meta {
  color: var(--muted);
  font-size: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 1rem;
}
.dog-detail-desc { color: var(--muted); font-size: 0.93rem; margin-bottom: 1.5rem; }

/* ── Map banner ─────────────────────────────────────── */
.map-banner {
  padding: 1rem 1.25rem;
  border-radius: 12px;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  border: 1px solid transparent;
}
.map-banner.is-mapped   { background: var(--success-light); border-color: #a5d6a7; color: var(--success); }
.map-banner.not-mapped  { background: var(--warn-light); border-color: #ffcc80; color: var(--warn); }
.map-banner strong { font-weight: 700; }
.map-banner p { font-size: 0.85rem; margin-top: 2px; }

/* ── Sight counts ───────────────────────────────────── */
.sight-counts {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.sight-count {
  flex: 1;
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
  border: 1px solid transparent;
}
.sight-count .num { font-size: 1.8rem; font-weight: 800; line-height: 1; }
.sight-count .lbl { font-size: 0.75rem; margin-top: 3px; }
.sight-yes { background: var(--success-light); border-color: #a5d6a7; }
.sight-yes .num, .sight-yes .lbl { color: var(--success); }
.sight-no  { background: var(--danger-light); border-color: #ef9a9a; }
.sight-no .num, .sight-no .lbl  { color: var(--danger); }

/* ── Sight form ─────────────────────────────────────── */
.sight-form {
  background: var(--teal-light);
  border: 1px solid var(--teal-mid);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}
.sight-form h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 1rem; }

.sight-radios { display: flex; gap: 0.75rem; margin-bottom: 1rem; }
.sight-radio-label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--white);
  transition: all 0.15s;
  user-select: none;
}
.sight-radio-label input[type="radio"] { display: none; }
.sight-radio-label.yes { border-color: #a5d6a7; }
.sight-radio-label.yes.selected { background: var(--success-light); color: var(--success); border-color: var(--success); }
.sight-radio-label.no  { border-color: #ef9a9a; }
.sight-radio-label.no.selected  { background: var(--danger-light); color: var(--danger); border-color: var(--danger); }

/* ── Sightings list ─────────────────────────────────── */
.sightings-list { display: flex; flex-direction: column; gap: 0.75rem; }
.sighting-item {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.sighting-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.icon-seen    { background: var(--success-light); color: var(--success); }
.icon-notseen { background: var(--danger-light); color: var(--danger); }
.sighting-name    { font-weight: 700; font-size: 0.9rem; }
.sighting-comment { font-size: 0.87rem; color: var(--muted); margin-top: 2px; }
.sighting-time    { font-size: 0.76rem; color: var(--muted); margin-top: 4px; }

/* ── Members list ───────────────────────────────────── */
.member-list { display: flex; flex-direction: column; gap: 0.6rem; }
.member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--white);
  border: 1px solid var(--border);
}
.member-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--teal);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.88rem;
  flex-shrink: 0;
}
.member-info { flex: 1; min-width: 0; }
.member-info .name  { font-size: 0.88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-info .email { font-size: 0.76rem; color: var(--muted); }

/* ── Empty state ────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3.5rem 1rem;
  color: var(--muted);
  border: 1.5px dashed var(--border);
  border-radius: 14px;
  background: var(--white);
}
.empty-state h3 { font-size: 1rem; font-weight: 600; margin-bottom: 0.4rem; color: var(--text); }
.empty-state p  { font-size: 0.88rem; }

/* ── Login ──────────────────────────────────────────── */
.login-page {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: linear-gradient(160deg, var(--teal-light) 0%, var(--cream) 60%);
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.5rem;
  box-shadow: 0 12px 40px rgba(0,0,0,0.07);
}
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo img { height: 80px; margin: 0 auto 0.75rem; }
.login-logo h1 { font-size: 1.3rem; font-weight: 800; color: var(--teal-dark); }
.login-logo p  { font-size: 0.84rem; color: var(--muted); }

/* ── Admin layout ───────────────────────────────────── */
.admin-layout {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 2rem;
  align-items: start;
}
.admin-sidebar {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  position: sticky;
  top: 76px;
}
.admin-sidebar__label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  padding: 0 8px;
  margin-bottom: 0.4rem;
}
.admin-sidebar a {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 500;
  transition: all 0.15s;
}
.admin-sidebar a:hover,
.admin-sidebar a.active {
  background: var(--teal-light);
  color: var(--teal-dark);
  text-decoration: none;
}

/* ── Region grid (admin overview) ───────────────────── */
.region-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}
.region-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.4rem;
  transition: box-shadow 0.2s;
}
.region-card:hover { box-shadow: 0 4px 16px rgba(26,138,154,0.1); }
.region-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 0.35rem; }
.region-card p  { font-size: 0.82rem; color: var(--muted); margin-bottom: 1rem; }
.region-card__stats { display: flex; gap: 1rem; }
.region-card__stat { font-size: 0.78rem; color: var(--muted); }
.region-card__stat strong { display: block; font-size: 1.2rem; font-weight: 800; color: var(--teal); }

/* ── Footer ─────────────────────────────────────────── */
.app-footer {
  background: var(--white);
  border-top: 1px solid var(--border);
  padding: 1rem 2rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
}

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 860px) {
  .dog-detail-grid { grid-template-columns: 1fr; }
  .admin-layout    { grid-template-columns: 1fr; }
  .admin-sidebar   { position: static; }
}
@media (max-width: 640px) {
  .app-nav { padding: 0 1rem; gap: 0.75rem; }
  .app-nav__links { display: none; }
  .app-main { padding: 1rem; }
  .form-row { grid-template-columns: 1fr; }
}
