:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #273549;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #0ea5e9;
  --danger: #f87171;
  --ok: #4ade80;
  --warn: #fbbf24;
  --border: #334155;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; height: 100%; }
#app { padding: 1rem; max-width: 1200px; margin: 0 auto; }

.topbar { display: flex; align-items: center; gap: 1rem; padding: .75rem 1rem; background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; }
.brand { font-weight: 700; }
#nav { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-left: auto; }
#nav button { background: transparent; color: var(--text); border: 1px solid transparent; padding: .4rem .75rem; border-radius: 6px; cursor: pointer; }
#nav button:hover { background: var(--panel-2); }
#nav button.active { background: var(--accent-2); color: #001018; }
.who { color: var(--muted); font-size: .85em; margin-left: .5rem; }
.link { background: none; color: var(--accent); border: none; cursor: pointer; padding: 0; text-decoration: underline; }

.view { animation: fade .15s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 1.25rem; margin-bottom: 1rem; }
.card.centered { max-width: 420px; margin: 3rem auto; }
h1, h2 { margin-top: 0; }
label { display: block; margin: .75rem 0; color: var(--muted); font-size: .9em; }
input, select, textarea, button {
  font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 6px; padding: .55rem .7rem; width: 100%;
}
input[type=checkbox] { width: auto; margin-right: .4rem; }
button { background: var(--accent-2); border: none; color: #001018; font-weight: 600; cursor: pointer; width: auto; }
button:hover { background: var(--accent); }
button[disabled] { opacity: .5; cursor: progress; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.inline { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.inline input { width: auto; flex: 1 1 200px; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: .75rem; margin: 1rem 0; }
legend { padding: 0 .4rem; color: var(--muted); }
.req { color: var(--danger); }
.muted { color: var(--muted); font-size: .9em; }
.hint { color: var(--muted); font-size: .85em; margin: 0 0 .5rem; }

/* Map view */
#view-map { display: grid; grid-template-columns: 1fr 340px; gap: 1rem; height: calc(100vh - 110px); }
#map { border-radius: 10px; min-height: 400px; }
#map-sidebar { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: .75rem; overflow-y: auto; }
#map-list { list-style: none; padding: 0; margin: 0; }
#map-list li { padding: .6rem; border-bottom: 1px solid var(--border); cursor: pointer; }
#map-list li:hover { background: var(--panel-2); }
#new-map { height: 300px; border-radius: 8px; margin-bottom: .5rem; }
@media (max-width: 800px) {
  #view-map { grid-template-columns: 1fr; height: auto; }
  #map { height: 50vh; }
  .row { grid-template-columns: 1fr; }
}

/* List */
.list-toolbar { display: flex; gap: .75rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.list-toolbar select { width: auto; }
.report-row { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: .8rem 1rem; margin-bottom: .6rem; cursor: pointer; display: grid; grid-template-columns: auto 1fr auto; gap: 1rem; align-items: center; }
.report-row:hover { border-color: var(--accent); }
.report-row .id { color: var(--muted); font-family: ui-monospace, monospace; font-size: .85em; }
.report-row .meta { color: var(--muted); font-size: .85em; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75em; font-weight: 600; text-transform: uppercase; }
.badge.sev-low { background: #334155; color: #cbd5e1; }
.badge.sev-medium { background: #a16207; color: #fef3c7; }
.badge.sev-high { background: #991b1b; color: #fee2e2; }
.badge.st-new { background: #0369a1; color: #e0f2fe; }
.badge.st-acknowledged { background: #7c3aed; color: #ede9fe; }
.badge.st-scheduled { background: #ca8a04; color: #fef9c3; }
.badge.st-in_progress { background: #ea580c; color: #ffedd5; }
.badge.st-resolved { background: #166534; color: #dcfce7; }
.badge.st-closed { background: #334155; color: #cbd5e1; }

/* Detail */
#detail .photos { display: flex; gap: .5rem; flex-wrap: wrap; margin: .75rem 0; }
#detail .photos img { width: 160px; height: 160px; object-fit: cover; border-radius: 8px; cursor: pointer; }
#detail .updates li { background: var(--panel-2); padding: .6rem .8rem; border-radius: 6px; margin-bottom: .4rem; list-style: none; }
.back-btn { margin-bottom: 1rem; }

/* Tables */
table { width: 100%; border-collapse: collapse; margin-top: .5rem; }
th, td { text-align: left; padding: .5rem; border-bottom: 1px solid var(--border); font-size: .9em; }
th { color: var(--muted); font-weight: 600; }

/* Toast */
.toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: var(--panel-2); padding: .75rem 1.25rem; border-radius: 8px; border: 1px solid var(--border); z-index: 999; }
.toast.err { border-color: var(--danger); }
.toast.ok { border-color: var(--ok); }

/* Leaflet marker color by severity */
.lm-high { filter: hue-rotate(-30deg) saturate(2); }
