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

:root {
  --accent:    #007aff;
  --green:     #34c759;
  --red:       #ff3b30;
  --orange:    #ff9500;
  --bg:        #f2f2f7;
  --card-bg:   #ffffff;
  --text:      #000000;
  --secondary: #6c6c70;
  --border:    rgba(0,0,0,0.1);
  --panel-bg:  #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:       #1c1c1e;
    --card-bg:  #2c2c2e;
    --panel-bg: #2c2c2e;
    --text:     #ffffff;
    --secondary:#aeaeb2;
    --border:   rgba(255,255,255,0.1);
  }
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── App shell ─────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  height: 100vh; /* fallback */
}

/* ── Header ────────────────────────────────────────────────────────────────── */
#header {
  flex-shrink: 0;
  padding: 12px 16px 10px;
  background: rgba(242,242,247,0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
}

@media (prefers-color-scheme: dark) {
  #header { background: rgba(28,28,30,0.9); }
}

#title {
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
  letter-spacing: -0.3px;
}

/* ── Status banner ─────────────────────────────────────────────────────────── */
#status-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px 16px;
  background: var(--panel-bg);
  border-radius: 10px;
  border: 1px solid var(--border);
  min-height: 34px;
  font-size: 13px;
  font-weight: 500;
}

#status-banner.all-clear  { color: var(--green); }
#status-banner.has-issues { color: var(--text);  }
#status-banner.loading    { color: var(--secondary); }

/* ── Map ───────────────────────────────────────────────────────────────────── */
#map-container {
  flex: 1 1 0;
  min-height: 0;
  position: relative;
}

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

.leaflet-control-attribution {
  font-size: 9px !important;
  background: rgba(255,255,255,0.7) !important;
}

/* ── Report panel ──────────────────────────────────────────────────────────── */
#report-panel {
  flex-shrink: 0;
  height: 260px;
  background: var(--panel-bg);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

#panel-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 8px auto 4px;
}

#panel-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 2px 16px 8px;
}

#panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--secondary);
}

#report-count {
  font-size: 12px;
  color: var(--secondary);
}

/* ── Report list ───────────────────────────────────────────────────────────── */
#report-list {
  padding: 0 12px 16px;
}

.loading-msg,
.empty-msg {
  text-align: center;
  color: var(--secondary);
  padding: 24px;
  font-size: 14px;
}

/* ── Report card ───────────────────────────────────────────────────────────── */
.report-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 11px;
  background: var(--bg);
  border-radius: 10px;
  margin-bottom: 7px;
  border: 1px solid var(--border);
}

.report-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}

.report-icon.road-blocked { background: rgba(255, 59, 48, 0.12); }
.report-icon.road-plowed  { background: rgba( 52,199, 89, 0.12); }
.report-icon.power-out    { background: rgba(255,149,  0, 0.12); }

.report-content {
  flex: 1;
  min-width: 0;
}

.report-title {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.report-meta {
  font-size: 12px;
  color: var(--secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.report-note {
  font-size: 12px;
  color: var(--secondary);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.report-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  flex-shrink: 0;
  white-space: nowrap;
}

.badge-verified    { background: rgba( 52,199, 89, 0.15); color: var(--green);  }
.badge-mixed       { background: rgba(255,149,  0, 0.15); color: var(--orange); }
.badge-unconfirmed { background: rgba(  0,122,255, 0.12); color: var(--accent); }

/* ── Desktop layout ────────────────────────────────────────────────────────── */
@media (min-width: 768px) {
  #app {
    flex-direction: column;
  }

  #header {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
  }

  #title {
    margin-bottom: 0;
    font-size: 17px;
    white-space: nowrap;
  }

  #status-banner {
    flex: 1;
    max-width: 500px;
  }

  #map-container {
    flex: 1 1 0;
  }

  #report-panel {
    position: absolute;
    right: 0;
    bottom: 0;
    top: 0;
    width: 320px;
    height: auto;
    border-radius: 0;
    border-top: none;
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 20px rgba(0,0,0,0.06);
    z-index: 500;
  }

  #panel-handle { display: none; }

  #map {
    width: calc(100% - 320px);
  }
}
