:root {
  --bg: #0f172a;
  --card: #1e293b;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --line: #334155;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--accent); text-decoration: none; }

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.25rem;
}

.wrap.scan-layout { padding: 0.45rem 0.6rem 0.35rem; }

.page-locator {
  max-width: none;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding-bottom: 0;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

h1 { margin: 0; font-size: 1.35rem; }
.sub { color: var(--muted); margin: 0.25rem 0 0; }

.grid {
  display: grid;
  gap: 0.75rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.1rem;
}

.card h2 { margin: 0 0 0.35rem; font-size: 1.05rem; }
.card p { margin: 0; color: var(--muted); font-size: 0.95rem; }

.soon { opacity: 0.55; pointer-events: none; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

input, select, button {
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0b1220;
  color: var(--text);
  padding: 0.65rem 0.75rem;
}

input { flex: 1 1 180px; min-width: 0; }

button {
  background: var(--accent);
  color: #0f172a;
  font-weight: 700;
  border: 0;
  cursor: pointer;
}

#flash {
      position: fixed;
      top: env(safe-area-inset-top, 12px);
      right: 0;
      bottom: env(safe-area-inset-bottom, 12px);
      left: 0;
      background: rgba(22, 163, 74, 0.82);
      pointer-events: none;
      opacity: 0;
      z-index: 9999;
    }
    
  #flash.on {
    animation: flashGreen 0.55s ease-out forwards;
  }
  @keyframes flashGreen {
    0% { opacity: 1; }
    100% { opacity: 0; }
  }

#map {
  flex: 1;
  width: 100%;
  min-height: 360px;
  border-radius: 12px;
  margin-top: 0.5rem;
}

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

.list-wrap {
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
}

.list-toggle {
  background: #1e293b;
  color: #f1f5f9;
  margin-bottom: 0.5rem;
}

.scan-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}

.scan-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.scan-list li:last-child { border-bottom: 0; }
.scan-list li:hover,
.scan-list li.active { background: #334155; }

.scan-list .num {
  font-weight: 700;
  min-width: 2.2rem;
}

.scan-list .latest { color: #4ade80; }

@media (min-width: 900px) {
  .page-locator {
    display: grid;
    grid-template-columns: 1fr 320px;
    grid-template-rows: auto auto auto 1fr;
    column-gap: 0.75rem;
  }
  .page-locator .top,
  .page-locator .toolbar,
  .page-locator .status {
    grid-column: 1 / -1;
  }
  #map {
    grid-column: 1;
    grid-row: 4;
    margin-top: 0;
  }
  .page-locator.no-list #map {
    grid-column: 1 / -1;
  }
  .list-wrap {
    grid-column: 2;
    grid-row: 4;
    margin-top: 0;
    flex-direction: column;
  }
  .list-wrap[hidden] {
    display: none !important;
  }
  .list-wrap:not([hidden]) {
    display: flex;
  }
  .scan-list { max-height: none; flex: 1; }

  .scan-layout {
    max-width: none;
    min-height: 100%;
  }

  .scan-panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.9rem;
    margin-bottom: 0.75rem;
  }

  #reader {
    width: 100%;
    min-height: 240px;
    background: #0b1220;
    border-radius: 12px;
    overflow: hidden;
  }

  #scanMap {
    height: 240px;
    width: 100%;
    border-radius: 12px;
  }

  .row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
  }

  .ok { color: #4ade80; }
  .warn { color: #fbbf24; }
  .bad { color: #f87171; }
}

