:root {
  --green: #007A4D;
  --green-dark: #0E1A14;
  --gold: #FFB612;
  --ink: #111;
  --muted: #5d6660;
  --line: #dfe3e0;
  --bg: #f4f6f5;
  --card: #fff;
  --advice: #1f6fb2;
  --watch: #d9820b;
  --emergency: #c62828;
  --critical: #6d0f0f;
  --radius: 10px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
h1, h2, h3 { margin: 0 0 12px; font-weight: 600; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
.muted { color: var(--muted); }
small.muted { font-weight: 400; }
.error { color: var(--emergency); min-height: 1em; margin: 6px 0; font-size: 14px; }
.warn { background: #fff4e0; border: 1px solid #f3c77a; padding: 10px 12px; border-radius: 8px; }

button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--line); background: #fff; padding: 8px 14px; }
button:hover { background: #f0f2f1; }
button.primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
button.primary:hover { background: #006840; }
button.danger { background: var(--emergency); border-color: var(--emergency); }
button.danger:hover { background: #a61f1f; }
button.ghost { background: transparent; }
button:disabled { opacity: .6; cursor: wait; }
input, select, textarea { font: inherit; width: 100%; padding: 8px 10px; border: 1px solid #c9cfcb; border-radius: 8px; background: #fff; margin-top: 4px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--green); }
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 12px; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
label.check input { width: auto; margin: 0; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; background: var(--green-dark); padding: 16px; }
.login-card { background: #fff; width: 100%; max-width: 380px; padding: 28px; border-radius: 14px; }
.login-card img { display: block; margin-bottom: 8px; }
.login-card button { width: 100%; padding: 10px; }

/* Top bar */
.topbar { display: flex; align-items: center; gap: 24px; padding: 8px 20px; background: var(--green-dark); color: #fff; flex-wrap: wrap; }
.topbar nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.tab { background: transparent; color: #cfd8d3; border: none; }
.tab:hover { background: rgba(255,255,255,.08); }
.tab.active { color: #fff; background: rgba(255,255,255,.12); box-shadow: inset 0 -2px 0 var(--gold); }
.who { font-size: 14px; color: #cfd8d3; }
.who .ghost { color: #fff; border-color: rgba(255,255,255,.3); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; padding: 16px 20px 0; }
.stats div { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.stats span { display: block; font-size: 22px; font-weight: 700; }
.stats small { color: var(--muted); }

/* Issue */
.issue { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 16px; padding: 16px 20px 24px; }
.map-wrap { display: flex; flex-direction: column; min-height: 560px; }
.map-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.tool.active { background: var(--green); color: #fff; border-color: var(--green); }
#radius { width: 140px; vertical-align: middle; margin: 0 6px; }
#map { flex: 1; min-height: 480px; border-radius: var(--radius); border: 1px solid var(--line); }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel.inline { max-width: 640px; margin-top: 16px; }

.levels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 14px; }
.lvl { margin: 0; }
.lvl input { position: absolute; opacity: 0; }
.lvl span { display: block; text-align: center; padding: 8px 4px; border-radius: 8px; border: 2px solid var(--c); color: var(--c); font-size: 13px; font-weight: 700; cursor: pointer; }
.lvl input:checked + span { background: var(--c); color: #fff; }
.lvl input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }
.lvl.advice { --c: var(--advice); } .lvl.watch { --c: var(--watch); } .lvl.emergency { --c: var(--emergency); } .lvl.critical { --c: var(--critical); }

.reach { background: #eef6f1; border: 1px solid #cfe5d8; border-radius: 8px; padding: 10px 12px; margin: 4px 0 8px; font-weight: 600; color: #0b5a39; }
.send { width: 100%; padding: 12px; font-size: 16px; }

/* Lists */
.list { padding: 16px 20px 32px; max-width: 1200px; }
.list-head { display: flex; justify-content: space-between; align-items: center; }
.alert-row { display: grid; grid-template-columns: 8px 1fr auto; gap: 14px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; }
.alert-row .bar { background: var(--c); }
.alert-row .body { padding: 12px 0; }
.alert-row .side { padding: 12px 14px; text-align: right; font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.alert-row h3 { margin: 0 0 4px; }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 99px; margin-right: 6px; background: #eef0ef; color: #333; }
.pill.lvl-advice { background: #e3effa; color: var(--advice); } .pill.lvl-watch { background: #fdf0dc; color: #9a5b00; }
.pill.lvl-emergency { background: #fbe4e4; color: var(--emergency); } .pill.lvl-critical { background: var(--critical); color: #fff; }
.pill.active { background: #e0f3e8; color: var(--green); } .pill.test { background: #fff4d1; color: #7a5a00; }
.table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; font-size: 14px; }
.table th, .table td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { background: #f7f9f8; font-weight: 600; }
.table code { font-size: 12px; color: var(--muted); word-break: break-word; }

/* Dialogs */
dialog { border: none; border-radius: 14px; padding: 22px; width: min(460px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .5); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.phone-preview { background: #1c1c1e; color: #fff; border-radius: 14px; padding: 12px 14px; font-size: 14px; }
.phone-preview .app { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #bbb; margin-bottom: 4px; }
.phone-preview b { display: block; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--green-dark); color: #fff; padding: 10px 16px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; }
#toast.show { opacity: 1; }

.vertex { background: #fff; border: 2px solid var(--emergency); border-radius: 50%; }
.vertex.first { background: var(--gold); cursor: pointer; }

@media (max-width: 960px) {
  .issue { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .map-wrap { min-height: 420px; }
  #map { min-height: 360px; }
}

/* Place search */
.place-search { display: flex; gap: 8px; margin-bottom: 8px; }
.place-search input { margin-top: 0; }
.place-results { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; max-height: 260px; overflow-y: auto; }
.place-results button { display: block; width: 100%; text-align: left; border: none; border-bottom: 1px solid var(--line); border-radius: 0; padding: 8px 12px; }
.place-results button:last-child { border-bottom: none; }
.place-results small { display: block; color: var(--muted); }
.place-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: #eef6f1; border: 1px solid #cfe5d8; border-radius: var(--radius); padding: 8px 10px; margin-bottom: 8px; }
.place-actions #place-name { font-weight: 600; flex: 1; min-width: 160px; }

/* Drafts */
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--gold); color: #111; font-size: 12px; font-weight: 700; text-align: center; margin-left: 4px; }
.draft-banner { background: #fff8e1; border: 1px solid #f3d27a; border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; }
.draft-banner p { margin: 4px 0 8px; font-size: 13px; }
.draft-actions { display: flex; gap: 8px; }
.draft-row .side .primary { margin-top: 4px; }

/* Reports */
.report-photos { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.report-photos img { width: 120px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; }
.list-head select { width: auto; margin: 0 6px 0 0; }

/* Forgot-password link on the sign-in card */
.link-btn { background: none; border: 0; padding: 4px 0; margin: 2px auto 0; color: inherit; opacity: .75; text-decoration: underline; cursor: pointer; font: inherit; font-size: .9em; box-shadow: none; }
.link-btn:hover { opacity: 1; }
#pw-dialog form { display: grid; gap: 10px; min-width: min(420px, 80vw); }
