:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #273449;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 12px;
}

* { box-sizing: border-box; }

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

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

button {
  background: var(--accent);
  color: #0b1220;
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
}
button.secondary { background: var(--panel-2); color: var(--text); }
button.danger { background: var(--bad); color: #fff; }
button:disabled { opacity: .5; cursor: default; }

input, select, textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 9px 10px;
}

label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }

.card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 16px;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1.2em; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--panel-2);
}
.badge.ok { background: rgba(34,197,94,.2); color: var(--ok); }
.badge.warn { background: rgba(245,158,11,.2); color: var(--warn); }
.badge.bad { background: rgba(239,68,68,.2); color: var(--bad); }
.badge.info { background: rgba(56,189,248,.2); color: var(--accent); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-wrap .card { width: 100%; max-width: 360px; }
.login-wrap h1 { margin: 0 0 4px; font-size: 22px; }
.login-wrap button { width: 100%; margin-top: 16px; }

/* ---------- App del oficial ---------- */
.officer { display: flex; flex-direction: column; height: 100dvh; }
.officer header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--panel);
}
.officer header strong { font-size: 16px; }
.officer #map { flex: 1; min-height: 200px; }
.officer .sheet { padding: 16px; background: var(--panel); display: grid; gap: 12px; }
.officer .target-name { font-size: 22px; font-weight: 700; margin: 0; }
.officer .big { width: 100%; padding: 16px; font-size: 18px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--panel-2); border-radius: 10px; padding: 8px; text-align: center; }
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 12px; color: var(--muted); }
.banner { padding: 10px 12px; border-radius: 10px; font-weight: 600; }
.banner.ok { background: rgba(34,197,94,.18); color: var(--ok); }
.banner.warn { background: rgba(245,158,11,.18); color: var(--warn); }
.banner.bad { background: rgba(239,68,68,.18); color: var(--bad); }
.banner.info { background: rgba(56,189,248,.15); color: var(--accent); }
.progress { height: 10px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--ok); transition: width .5s; }
.progress.indeterminate > div { width: 30%; animation: slide 1.4s infinite ease-in-out; }
@keyframes slide { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }

/* ---------- Administración ---------- */
.admin header {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--panel);
}
.admin header h1 { font-size: 18px; margin: 0; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.tabs button { background: transparent; color: var(--muted); padding: 8px 12px; }
.tabs button.active { background: var(--panel-2); color: var(--text); }
.admin main { padding: 16px; }
.split { display: grid; grid-template-columns: 1fr 380px; gap: 16px; }
.admin #adminMap, .admin #roundMap { height: calc(100vh - 110px); min-height: 420px; border-radius: var(--radius); }
.admin #roundMap { height: 420px; }
.side { display: grid; gap: 16px; align-content: start; max-height: calc(100vh - 110px); overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid #334155; }
th { color: var(--muted); font-weight: 500; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--panel-2); }
.list-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid #334155; }
.list-item:last-child { border-bottom: 0; }
.list-item button { padding: 6px 10px; font-size: 13px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 16px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.filters > div { min-width: 170px; }
.filter-actions { display: flex; gap: 8px; }
.table-scroll { overflow-x: auto; }
.table-scroll td { white-space: nowrap; }
.hour-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.hour {
  background: var(--panel); border-radius: 10px; padding: 10px; border-left: 5px solid #475569;
  font-size: 13px; line-height: 1.45; min-height: 92px;
}
.hour.clickable { cursor: pointer; }
.hour.clickable:hover { background: var(--panel-2); }
.hour b { font-size: 16px; }
.hour .st { font-weight: 600; }
.st-cumplida { border-color: var(--ok) !important; background: var(--ok); }
.st-incompleta { border-color: var(--warn) !important; background: var(--warn); }
.st-no_realizada, .st-atrasada { border-color: var(--bad) !important; background: var(--bad); }
.st-en_curso, .st-pendiente { border-color: var(--accent) !important; background: var(--accent); }
.st-futura, .st-programada, .st-sin_datos { border-color: #475569 !important; background: #475569; }
.hour[class*="st-"] { background: var(--panel); }
.hour.st-cumplida .st { color: var(--ok); }
.hour.st-incompleta .st { color: var(--warn); }
.hour.st-no_realizada .st, .hour.st-atrasada .st { color: var(--bad); }
.hour.st-en_curso .st, .hour.st-pendiente .st { color: var(--accent); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.big-number { font-size: 28px; font-weight: 700; }
.coords { color: var(--accent); font-size: 13px; text-decoration: none; }
.coords:hover { text-decoration: underline; }

@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
  .admin #adminMap { height: 55vh; }
  .side { max-height: none; }
}
