:root {
  --bg: #f6f8fa;
  --card: #ffffff;
  --text: #1c2530;
  --muted: #5b6b7c;
  --accent: #0d5c8f;
  --accent-dark: #0a4a74;
  --border: #d6dee6;
  --danger: #b3261e;
  --warn-bg: #fdf3d7;
  --warn-border: #e5c96a;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12181f;
    --card: #1b232d;
    --text: #e8edf2;
    --muted: #9aa9b8;
    --accent: #4da3d8;
    --accent-dark: #77b9e2;
    --border: #33404d;
    --danger: #e58a84;
    --warn-bg: #3a3115;
    --warn-border: #8a7326;
  }
}

* { box-sizing: border-box; }

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

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}

#welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}

/* Author-origin display:flex above would otherwise beat the UA stylesheet's
   [hidden] { display: none }, leaving a full-screen click-blocker in place. */
#welcome-overlay[hidden] {
  display: none;
}

#welcome-banner {
  background: var(--card);
  border: 1px solid var(--accent);
  border-left: 5px solid var(--accent);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

#welcome-banner h2 { margin: 0 0 0.3rem; font-size: 1.15rem; }
#welcome-banner p { margin: 0 0 0.4rem; }
#welcome-banner ul { margin: 0 0 0.8rem; padding-left: 1.2rem; }
#welcome-banner li { margin-bottom: 0.3rem; font-size: 0.92rem; }

h1 { font-size: 1.7rem; margin-bottom: 0.2rem; }
.logo { display: block; height: 120px; width: auto; max-width: 100%; }

form, #result, #history {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-top: 1.25rem;
}

fieldset {
  border: none;
  padding: 0;
  margin: 0 0 1rem;
}

legend {
  font-weight: 600;
  padding: 0;
  margin-bottom: 0.5rem;
}

.addr-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.field { display: flex; flex-direction: column; position: relative; flex: 1 1 140px; }
.field.addr { flex: 3 1 260px; }
.field.post { flex: 0 1 110px; }

label { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.2rem; }

input, select, button {
  font: inherit;
  color: inherit;
}

input, select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
}

input:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.6rem 1.2rem;
  cursor: pointer;
  font-weight: 600;
}

button:hover { background: var(--accent-dark); }
button:disabled { opacity: 0.6; cursor: wait; }
button.danger { background: var(--danger); }

.suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 10;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
  max-height: 230px;
  overflow-y: auto;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.suggestions button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  color: var(--text);
  border: none;
  border-radius: 0;
  padding: 0.45rem 0.6rem;
  font-weight: 400;
}

.suggestions button:hover, .suggestions button:focus { background: var(--bg); }

#status {
  margin-top: 1rem;
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
}

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

.warning {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: 8px;
  padding: 0.5rem 0.8rem;
  margin: 0.6rem 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
  font-size: 0.95rem;
}

th, td {
  text-align: left;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text);
  margin-top: 0.25rem;
  cursor: pointer;
}

.checkbox-row input { accent-color: var(--accent); }

tr.waived td { color: var(--muted); text-decoration: line-through; }
tr.waived td:last-child { text-decoration: none; }

#map {
  height: 380px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 0.75rem 0;
  z-index: 0;
}

.total { font-size: 1.15rem; }
.disclaimer { color: var(--muted); font-size: 0.82rem; }

.filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.filters input[type="text"] { flex: 2 1 160px; }
.filters select, .filters input[type="date"] { flex: 1 1 120px; }

.row-del {
  background: none;
  border: none;
  color: var(--danger);
  font-weight: 700;
  cursor: pointer;
  padding: 0.1rem 0.4rem;
}

.badge-rush {
  font-size: 0.72rem;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: 4px;
  padding: 0 0.3rem;
  margin-left: 0.3rem;
}

@media (max-width: 560px) {
  th:nth-child(2), td:nth-child(2) { display: none; }
}
