/* ===== C.O.M. Escuelas PBA — estilos comunes ===== */
:root {
  --pba: #085C9C; --pba-dark: #003E6B; --pba-light: #009FE3;
  --ok: #10b981; --warn: #f59e0b; --crit: #e11d48; --info: #3b82f6;
  --radius: 14px; --radius-sm: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Consolas, monospace;

  /* tema claro (portal escuela) */
  --bg: #f3f6fa; --surface: #ffffff; --surface-2: #f7f9fc; --border: #e2e8f0; --border-strong: #cbd5e1;
  --text: #0f172a; --text-2: #475569; --text-3: #94a3b8;
  --input-bg: #ffffff; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.05);
  --accent: var(--pba); --accent-hover: var(--pba-dark); --accent-soft: #e6f1fa;
}
[data-theme="dark"] {
  --bg: #0b1120; --surface: #111a2e; --surface-2: #0e1628; --border: #1e2a44; --border-strong: #2b3a5c;
  --text: #e8eef8; --text-2: #9fb0cc; --text-3: #64748b;
  --input-bg: #0b1324; --shadow: 0 1px 2px rgba(0,0,0,.3);
  --accent: #1f8fd6; --accent-hover: #3aa6ea; --accent-soft: rgba(31,143,214,.14);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
p { margin: 0; }
a { color: var(--accent); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.mono { font-family: var(--mono); }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack > * + * { margin-top: 14px; }
.stack-sm > * + * { margin-top: 8px; }
.grow { flex: 1; min-width: 0; }
.ico { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: -3px; }
.ico.lg { width: 22px; height: 22px; }

/* ===== Botones ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent;
  border-radius: var(--radius-sm); padding: 10px 16px; font-weight: 600; font-size: 14px; cursor: pointer;
  background: var(--surface-2); color: var(--text); border-color: var(--border); transition: background .15s, border-color .15s, transform .05s;
  min-height: 42px; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { background: var(--crit); color: #fff; border-color: var(--crit); }
.btn.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { padding: 6px 11px; min-height: 34px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.lg { min-height: 52px; font-size: 16px; }
.icon-btn { width: 40px; height: 40px; padding: 0; }

/* ===== Formularios ===== */
.field { display: block; }
.field > span, .label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.input, select.input, textarea.input { width: 100%; background: var(--input-bg); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 10px 12px; min-height: 44px; outline: none; transition: border-color .15s, box-shadow .15s; }
textarea.input { min-height: 88px; resize: vertical; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.big { font-size: 22px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 520px) { .grid-3 { grid-template-columns: 1fr; } }
.hint { font-size: 12px; color: var(--text-3); margin-top: 5px; }

.stepper { display: grid; grid-template-columns: 52px 1fr 52px; gap: 8px; }
.stepper .btn { min-height: 52px; font-size: 22px; padding: 0; }
.stepper .input { min-height: 52px; }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { flex: 1; min-width: 88px; text-align: center; padding: 10px 8px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  cursor: pointer; font-weight: 600; font-size: 14px; background: var(--input-bg); transition: all .15s; }
.seg input:checked + label { background: var(--accent); color: #fff; border-color: var(--accent); }
.seg input:focus-visible + label { box-shadow: 0 0 0 3px var(--accent-soft); }
.seg.prio input[value="Media"]:checked + label { background: var(--warn); border-color: var(--warn); color: #1f1300; }
.seg.prio input[value="Alta"]:checked + label { background: #ea580c; border-color: #ea580c; }
.seg.prio input[value="Crítica"]:checked + label { background: var(--crit); border-color: var(--crit); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border-strong); background: var(--surface-2); border-radius: 12px; padding: 6px 12px; font-size: 13px;
  cursor: pointer; font-weight: 500; text-align: left; }
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ===== Tarjetas ===== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-head h3 { font-size: 14px; font-weight: 700; letter-spacing: .02em; }
.section-title { font-size: 18px; font-weight: 800; }

/* ===== Badges ===== */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.badge.ok { background: rgba(16,185,129,.12); color: #059669; border-color: rgba(16,185,129,.3); }
.badge.warn { background: rgba(245,158,11,.14); color: #b45309; border-color: rgba(245,158,11,.35); }
.badge.high { background: rgba(234,88,12,.12); color: #c2410c; border-color: rgba(234,88,12,.3); }
.badge.crit { background: rgba(225,29,72,.12); color: #e11d48; border-color: rgba(225,29,72,.3); }
.badge.info { background: rgba(59,130,246,.12); color: #2563eb; border-color: rgba(59,130,246,.3); }
[data-theme="dark"] .badge.ok { color: #34d399; } [data-theme="dark"] .badge.warn { color: #fbbf24; }
[data-theme="dark"] .badge.high { color: #fb923c; } [data-theme="dark"] .badge.crit { color: #fb7185; }
[data-theme="dark"] .badge.info { color: #60a5fa; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: currentColor; }
.dot.pulse { animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }

/* ===== Toast ===== */
#toasts { position: fixed; z-index: 2000; left: 50%; transform: translateX(-50%); bottom: 88px; display: flex; flex-direction: column; gap: 8px;
  width: min(92vw, 420px); pointer-events: none; }
@media (min-width: 900px) { #toasts { left: auto; right: 24px; transform: none; bottom: 24px; } }
.toast { background: #0f172a; color: #f8fafc; border-radius: 12px; padding: 12px 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25);
  display: flex; gap: 10px; align-items: flex-start; font-size: 14px; animation: tin .2s ease-out; border-left: 4px solid var(--ok); }
.toast.err { border-left-color: var(--crit); } .toast.warn { border-left-color: var(--warn); }
.toast strong { display: block; }
.toast span { color: #cbd5e1; font-size: 13px; }
@keyframes tin { from { transform: translateY(10px); opacity: 0 } to { transform: none; opacity: 1 } }

/* ===== Modal ===== */
.modal { position: fixed; inset: 0; z-index: 1500; background: rgba(2,6,23,.6); display: flex; align-items: flex-end; justify-content: center; padding: 0; }
@media (min-width: 700px) { .modal { align-items: center; padding: 20px; } }
.modal-box { background: var(--surface); color: var(--text); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  border-radius: 20px 20px 0 0; border: 1px solid var(--border); box-shadow: 0 20px 60px rgba(0,0,0,.35); animation: tin .2s ease-out; }
@media (min-width: 700px) { .modal-box { border-radius: 18px; } }
.modal-box.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 18px; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
  position: sticky; bottom: 0; background: var(--surface); }

/* ===== Varios ===== */
.empty { text-align: center; padding: 28px 16px; color: var(--text-3); font-size: 14px; }
.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 14px; border: 1px solid; }
.alert.err { background: rgba(225,29,72,.08); border-color: rgba(225,29,72,.3); color: #be123c; }
.alert.warn { background: rgba(245,158,11,.1); border-color: rgba(245,158,11,.35); color: #92400e; }
.alert.info { background: var(--accent-soft); border-color: rgba(8,92,156,.25); color: var(--accent); }
.bar { height: 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--ok); transition: width .3s; }
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }
.thumb { width: 64px; height: 48px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); cursor: zoom-in; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, var(--pba), var(--pba-light)); color: #fff;
  display: grid; place-items: center; flex: none; }
.map-box { height: 300px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border-strong); position: relative; z-index: 0; }
.leaflet-container { font-family: var(--font); }

/* ===== Tablas ===== */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); font-weight: 700;
  padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl tr:hover td { background: var(--surface-2); }
.tbl .clip { max-width: 360px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
