* {
  box-sizing: border-box;
}

:root {
  --crepe: #f3ebe0;
  --crepe-dark: #e8ddd0;
  --crepe-border: #d4c4b0;
  --text: #3d3229;
  --text-muted: #6b5d4f;
  --accent: #8b6914;
  --live: #2d6a4f;
  --error: #b42318;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--crepe);
  color: var(--text);
}

#app {
  display: grid;
  grid-template-columns: 320px 1fr;
  grid-template-rows: 1fr;
  height: 100vh;
}

main {
  min-height: 0;
}

header {
  padding: 0 0 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--crepe-border);
  background: transparent;
}

header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text);
}

.status {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.status.live { color: var(--live); }
.status.error { color: var(--error); }

#panel {
  padding: 1rem;
  border-right: 1px solid var(--crepe-border);
  overflow-y: auto;
  background: var(--crepe);
}

.koda-hero {
  margin-bottom: 1rem;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--crepe-border);
  background: #fff;
  box-shadow: 0 2px 8px rgba(61, 50, 41, 0.08);
}

.koda-hero img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
}

#telemetry {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem 0.75rem;
  font-size: 0.875rem;
}

#telemetry dt {
  color: var(--text-muted);
  margin: 0;
}

#telemetry dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

#telemetry dd.wide {
  grid-column: 2;
  word-break: break-word;
}

#map {
  width: 100%;
  height: 100%;
}

.device-marker--dog {
  width: 36px;
  height: 36px;
  cursor: pointer;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(61, 50, 41, 0.45);
  overflow: hidden;
  background: #fff;
}

.device-marker--dog img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---- Cards / feature panels ------------------------------------------- */
.card {
  background: #fff;
  border: 1px solid var(--crepe-border);
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
  margin-bottom: 0.85rem;
  box-shadow: 0 1px 4px rgba(61, 50, 41, 0.06);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.card-title {
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.03em;
  color: var(--text);
  cursor: default;
}

details.card > summary {
  list-style: none;
  cursor: pointer;
}
details.card > summary::-webkit-details-marker { display: none; }

.badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  color: #fff;
}
.badge--resting { background: #6b5d4f; }
.badge--walking { background: #2d6a4f; }
.badge--running { background: #b9770e; }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.stat {
  display: flex;
  flex-direction: column;
  background: var(--crepe);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
}
.stat-val {
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.stat-lbl {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

/* ---- Buttons ---------------------------------------------------------- */
.btn {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--crepe-border);
  background: var(--crepe);
  color: var(--text);
  border-radius: 7px;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
}
.btn:hover { background: var(--crepe-dark); }
.btn--primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn--primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--danger { color: var(--error); border-color: transparent; background: transparent; padding: 0.2rem 0.4rem; }

/* ---- Zone form + list ------------------------------------------------- */
.zone-form { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.6rem; }
.zone-form label { font-size: 0.78rem; color: var(--text-muted); display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.zone-form input { font: inherit; font-size: 0.8rem; padding: 0.25rem 0.4rem; border: 1px solid var(--crepe-border); border-radius: 6px; width: 60%; }
.zone-actions { display: flex; gap: 0.4rem; }
.hint { font-size: 0.75rem; color: var(--accent); margin: 0 0 0.2rem; }

.zone-list, .event-list, .walk-list { list-style: none; margin: 0; padding: 0; font-size: 0.8rem; }
.zone-list li, .event-list li, .walk-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--crepe-border);
}
.zone-list li:last-child, .event-list li:last-child, .walk-list li:last-child { border-bottom: 0; }
.muted { color: var(--text-muted); }

.event-list .ev-alert { color: var(--error); font-weight: 600; }
.event-list .ev-time { color: var(--text-muted); font-size: 0.7rem; white-space: nowrap; margin-left: 0.5rem; }

/* ---- Mini bar chart --------------------------------------------------- */
.chart { display: flex; align-items: flex-end; gap: 4px; height: 70px; margin-bottom: 0.6rem; }
.chart .bar { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; opacity: 0.85; }
.chart .bar span { position: absolute; bottom: -16px; left: 0; right: 0; text-align: center; font-size: 0.6rem; color: var(--text-muted); }
.chart-wrap { padding-bottom: 16px; }

/* ---- Breach banner ---------------------------------------------------- */
.banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  background: var(--error);
  color: #fff;
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  box-shadow: 0 4px 14px rgba(180, 35, 24, 0.4);
}
main { position: relative; }

@media (max-width: 900px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  #panel {
    border-right: 0;
    border-bottom: 1px solid var(--crepe-border);
  }
  #map { min-height: 50vh; }
}

/* ---- Landing / login page (full-page photo) -------------------------- */
.landing {
  position: fixed;
  inset: 0;
  z-index: 1000;
  overflow: hidden;
  background: var(--crepe);
}

.landing-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

/* Centre the card horizontally, push it toward the top of the page. */
.landing-content {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  padding-top: 8vh;
  padding-left: 6vw;
  height: 100%;
}

.login-card {
  width: min(360px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: 1.75rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(9px) saturate(120%);
  -webkit-backdrop-filter: blur(9px) saturate(120%);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 12px 40px rgba(30, 22, 14, 0.35);
  text-align: center;
}

.landing-brand {
  margin: 0;
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}
.landing-brand span { font-weight: 300; opacity: 0.85; }

.login-tagline {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: left;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* `display: flex` above would otherwise override the [hidden] attribute. */
.login-card label[hidden] { display: none; }

.login-card input {
  padding: 0.6rem 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  font: inherit;
  font-weight: 400;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
}

.btn--block { width: 100%; padding: 0.7rem; font-size: 0.95rem; }

.link-btn {
  background: none;
  border: 0;
  color: #fff;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.link-btn:hover { text-decoration: underline; }

.login-error {
  color: #fff;
  background: rgba(180, 35, 24, 0.85);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  margin: 0;
}

/* ---- Dashboard empty state ------------------------------------------- */
.empty-state { text-align: center; }
.empty-state .empty-icon { font-size: 2rem; }
.empty-state p { font-size: 0.85rem; line-height: 1.4; }

@media (max-width: 760px) {
  .landing-content { padding-top: 6vh; }
  .landing-brand { font-size: 1.9rem; }
}

.device-select {
  margin-top: 0.5rem;
  width: 100%;
  padding: 0.35rem;
  border: 1px solid var(--crepe-border);
  border-radius: 6px;
  background: white;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.account-email {
  margin: 0.1rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn--ghost {
  background: transparent;
  border: 1px solid var(--crepe-border);
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
}

.pet-card .pet-head {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.pet-photo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.pet-photo--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--crepe-dark);
  font-size: 1.8rem;
}

.pet-id {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.pet-name {
  font-size: 1.15rem;
  font-weight: 700;
}

.pet-breed {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.pet-username {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.pet-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1rem;
  margin: 0.9rem 0 0;
}

.pet-meta div {
  display: flex;
  flex-direction: column;
}

.pet-meta dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.pet-meta dd {
  margin: 0.1rem 0 0;
  font-weight: 600;
}

.pet-collars {
  margin-top: 0.9rem;
  border-top: 1px solid var(--crepe-border);
  padding-top: 0.6rem;
}

.collar-list {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
}

.collar-list li {
  display: flex;
  justify-content: space-between;
  padding: 0.25rem 0;
  font-size: 0.9rem;
}

.collar-status {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.soon-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.soon {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  opacity: 0.75;
}

.soon-icon {
  font-size: 1.4rem;
  width: 2rem;
  text-align: center;
  flex-shrink: 0;
}

.soon-title {
  display: block;
  font-weight: 600;
}

.soon-msg {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
}
