:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17212b;
  background: #f4f7fa;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --surface: #ffffff;
  --soft: #edf2f7;
  --line: #d9e1e8;
  --text-muted: #627282;
  --blue: #1769aa;
  --blue-dark: #10578f;
  --red: #bd3135;
  --shadow: 0 12px 32px rgb(23 45 66 / 7%);
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse at 12% 0%, rgb(211 231 247 / 48%), transparent 40rem),
    #f4f7fa;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid rgb(23 105 170 / 35%);
  outline-offset: 2px;
}

.app-shell {
  width: min(1180px, calc(100% - 36px));
  margin: 26px auto 20px;
}

.hero, .filters, .camera-card, .about-card {
  background: var(--surface);
  border: 1px solid rgb(213 224 233 / 85%);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 14px 24px;
  padding: 24px 28px 0;
}

.hero-copy { grid-column: 1; grid-row: 1; }
.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}
h1 { margin: 0; font-size: clamp(1.65rem, 4vw, 2.25rem); letter-spacing: -0.04em; }
.subtitle { margin: 8px 0 0; color: var(--text-muted); }

.language-picker {
  display: flex;
  align-items: center;
  justify-self: end;
  align-self: start;
  grid-column: 2;
  grid-row: 1;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}
.language-picker button, .tabs button {
  border: 0;
  border-radius: 8px;
  color: #465768;
  background: transparent;
  font-weight: 650;
}
.language-picker button {
  min-height: 34px;
  padding: 6px 10px;
  white-space: nowrap;
}
.language-picker button[aria-pressed="true"] {
  color: #fff;
  background: var(--blue);
}

.tabs {
  display: flex;
  grid-column: 1 / -1;
  grid-row: 2;
  gap: 6px;
  margin-top: 2px;
}
.tabs button {
  position: relative;
  padding: 12px 15px;
  color: var(--text-muted);
}
.tabs button[aria-current="page"] { color: var(--blue-dark); }
.tabs button[aria-current="page"]::after {
  position: absolute;
  right: 12px;
  bottom: -1px;
  left: 12px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--blue);
  content: "";
}

.filters { display: grid; gap: 12px; margin: 16px 0; padding: 16px; }
.filter-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.search-box { flex: 1 1 260px; }
.search-box input, .district-control select {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: inherit;
  background: #fbfcfd;
}
.district-control { flex: 0 1 220px; }
.chip {
  min-height: 37px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #435363;
  background: var(--surface);
  font-size: 0.9rem;
}
.chip[aria-pressed="true"] { border-color: var(--blue); color: #fff; background: var(--blue); }
.status-filters .chip:first-child[aria-pressed="true"] { border-color: #c68121; background: #b87920; }
.status-filters .chip:nth-child(2)[aria-pressed="true"] { border-color: var(--red); background: var(--red); }
.chip:disabled { cursor: not-allowed; opacity: 0.55; }

.notice {
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid #b6d6ee;
  border-radius: 10px;
  color: #124f7c;
  background: #edf7ff;
}
.notice.warning { border-color: #efc8a2; color: #79480d; background: #fff7ed; }
.notice.error { border-color: #e7b6b8; color: #922b30; background: #fff1f1; }

.content-view { min-height: 150px; }
.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 18px 3px 12px;
}
.list-toolbar h2 { margin: 0; font-size: 1.05rem; }
.list-toolbar p { margin: 4px 0 0; color: var(--text-muted); font-size: 0.88rem; }
.pager { display: flex; align-items: center; gap: 8px; }
.pager button, .action-button {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: #243646;
  background: var(--surface);
}
.pager button:disabled { cursor: default; opacity: 0.45; }

.camera-list { display: grid; gap: 10px; }
.camera-card {
  display: grid;
  grid-template-columns: minmax(160px, 225px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 15px;
  padding: 12px;
  border-radius: 14px;
}
.snapshot {
  display: grid;
  width: 100%;
  aspect-ratio: 16 / 9;
  place-items: center;
  overflow: hidden;
  border-radius: 10px;
  color: var(--text-muted);
  background: #e7edf2;
  text-align: center;
}
.snapshot img { display: block; width: 100%; height: 100%; object-fit: cover; }
.snapshot span { padding: 8px; font-size: 0.87rem; }
.camera-info { min-width: 0; }
.camera-info h3 { margin: 0 0 6px; overflow-wrap: anywhere; font-size: 1.02rem; }
.camera-info p { margin: 3px 0; color: var(--text-muted); font-size: 0.9rem; }
.camera-id { font-size: 0.77rem !important; }
.camera-actions { display: flex; flex-direction: column; gap: 7px; }
.icon-action {
  display: grid;
  min-width: 42px;
  min-height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--blue);
  background: var(--surface);
  font-size: 1.16rem;
  text-decoration: none;
}
.icon-action.favorite[aria-pressed="true"] { color: #c17916; }

.empty-state, .loading-state {
  padding: 34px 18px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--text-muted);
  background: rgb(255 255 255 / 55%);
  text-align: center;
}
.scan-progress { margin-top: 7px; color: var(--blue); font-size: 0.88rem; }

.map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 2px;
}
.zoom-controls { display: flex; align-items: center; gap: 7px; }
.zoom-controls button {
  width: 40px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--blue-dark);
  background: var(--surface);
  font-size: 1.2rem;
}
.map-canvas {
  position: relative;
  height: min(68vh, 700px);
  min-height: 410px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #e3e7de;
  box-shadow: var(--shadow);
  cursor: grab;
  touch-action: none;
}
.map-canvas.dragging { cursor: grabbing; }
.map-tile { position: absolute; width: 256px; height: 256px; max-width: none; user-select: none; pointer-events: none; }
.map-marker {
  position: absolute;
  z-index: 2;
  width: 26px;
  height: 26px;
  padding: 0;
  transform: translate(-50%, -50%);
  border: 3px solid #fff;
  border-radius: 50% 50% 50% 4px;
  color: #fff;
  background: #c52e35;
  box-shadow: 0 2px 8px rgb(0 0 0 / 40%);
  rotate: -45deg;
}
.map-marker span { display: block; transform: rotate(45deg); font-size: 0.62rem; }
.map-attribution {
  position: absolute;
  right: 5px;
  bottom: 4px;
  padding: 3px 6px;
  border-radius: 4px;
  color: #293a48;
  background: rgb(255 255 255 / 86%);
  font-size: 0.7rem;
}
.map-popup {
  position: absolute;
  z-index: 5;
  width: min(270px, calc(100% - 24px));
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 8px 28px rgb(0 0 0 / 23%);
}
.map-popup h3 { margin: 0 0 8px; font-size: 0.96rem; }
.map-popup-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.map-popup-actions button, .map-popup-actions a {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--blue-dark);
  background: #fff;
  text-decoration: none;
  font-size: 0.82rem;
}

.about-card { padding: 20px; line-height: 1.65; }
.about-card h2 { margin-top: 0; }
.about-card a { color: var(--blue-dark); overflow-wrap: anywhere; }
footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 20px 3px;
  color: var(--text-muted);
  font-size: 0.78rem;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 680px) {
  .app-shell { width: min(100% - 20px, 1180px); margin-top: 10px; }
  .hero { grid-template-columns: minmax(0, 1fr) auto; gap: 12px 10px; padding: 18px 16px 0; border-radius: 14px; }
  .hero-copy { grid-column: 1 / -1; grid-row: 1; }
  .language-picker { grid-column: 1 / -1; grid-row: 2; justify-self: start; }
  .tabs { grid-row: 3; gap: 1px; }
  .tabs button { flex: 1; padding: 11px 5px; font-size: 0.9rem; }
  .filters { padding: 12px; border-radius: 14px; }
  .district-control { flex: 1 1 140px; }
  .camera-card { grid-template-columns: 120px minmax(0, 1fr) auto; gap: 10px; padding: 9px; }
  .camera-actions { gap: 5px; }
  .icon-action { min-width: 36px; min-height: 36px; }
  .camera-info h3 { font-size: 0.93rem; }
  .camera-info p { font-size: 0.8rem; }
  .map-canvas { min-height: 55vh; }
  .list-toolbar { align-items: flex-start; }
  .pager { flex-shrink: 0; }
  .pager button { padding: 7px; }
  footer { flex-direction: column; }
}

@media (max-width: 430px) {
  .camera-card { grid-template-columns: 92px minmax(0, 1fr) 34px; gap: 8px; }
  .camera-actions .icon-action { min-width: 32px; min-height: 34px; }
  .camera-actions { gap: 4px; }
  .camera-id { display: none; }
  .list-toolbar { flex-direction: column; }
  .map-toolbar { align-items: flex-start; flex-direction: column; }
}
