:root {
  --bg: #f5f7f6; --surface: #fff; --surface-2: #eef2f0; --text: #17201c; --muted: #5d6b65; --border: #dce3df;
  --primary: #0e6b4c; --primary-ink: #fff; --primary-soft: #e1f1ea; --accent: #c98a12; --danger: #b42318; --ok: #157f3b; --info: #1f5fbf;
  --radius: 12px; --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 4px 16px rgb(0 0 0 / .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1412; --surface: #171e1b; --surface-2: #1f2824; --text: #e7eeea; --muted: #9aa9a2; --border: #2b3631;
    --primary: #3fb98a; --primary-ink: #06130e; --primary-soft: #183229; --accent: #e3a83a; --danger: #f07167; --ok: #4cc27a; --info: #7aa7f0; color-scheme: dark; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Botones y formularios */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4em; padding: .6em 1.1em; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; min-height: 42px; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.sm { min-height: 32px; padding: .3em .7em; font-size: .85rem; }
.btn:disabled { opacity: .6; cursor: wait; }
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3em; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .6em .75em; min-height: 42px; }
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: 2px solid var(--primary-soft); }
.field { margin-bottom: 1rem; }
.row { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.check { display: flex; gap: .5em; align-items: center; font-weight: 500; }
.check input { width: auto; min-height: 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }
.alert { padding: .8em 1em; border-radius: 10px; margin: 0 0 1rem; background: var(--primary-soft); }
.alert.error { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }

/* Estados */
.badge { display: inline-block; padding: .15em .6em; border-radius: 99px; font-size: .78rem; font-weight: 700; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.e-recibido { background: color-mix(in srgb, var(--info) 15%, transparent); color: var(--info); }
.e-en_revision, .e-en_proceso { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.e-observado { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.e-resuelto { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.p-alta { background: var(--danger); color: #fff; }

.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 1rem 1.1rem; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: .35em; width: 12px; height: 12px; border-radius: 50%; background: var(--primary); }

.map { height: 300px; border-radius: 10px; border: 1px solid var(--border); z-index: 0; }
.toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: .7em 1.2em; border-radius: 10px; z-index: 1000; box-shadow: var(--shadow); }

/* ---------- Sitio público ---------- */
.topbar { background: var(--primary); color: var(--primary-ink); }
.topbar .wrap { display: flex; align-items: center; gap: .75rem; padding: .75rem 16px; }
.topbar img { width: 36px; height: 36px; }
.topbar b { display: block; font-size: 1rem; } .topbar span { font-size: .78rem; opacity: .85; }
.tabs { display: flex; gap: .25rem; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; overflow-x: auto; }
.tabs a { padding: .85em 1em; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a[aria-current="page"] { color: var(--primary); border-color: var(--primary); }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 1.5rem; padding-bottom: 3rem; }
.hero { padding: 1.5rem 0 1rem; }
.grid-units { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.unit h3 { color: var(--primary); }
.unit ul { list-style: none; padding: 0; margin: 0; }
.unit li a { display: flex; justify-content: space-between; gap: .5em; padding: .45em 0; border-top: 1px solid var(--border); text-decoration: none; color: var(--text); }
.unit li a:hover { color: var(--primary); }
.kind { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.codigo { font: 700 1.6rem/1.2 ui-monospace, Consolas, monospace; letter-spacing: .05em; color: var(--primary); }
.foto-prev { max-width: 160px; border-radius: 8px; margin-top: .5rem; }

/* ---------- Panel administrativo ---------- */
.admin { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--border); padding: 1rem; display: flex; flex-direction: column; gap: .25rem; position: sticky; top: 0; height: 100vh; }
.side .brand { display: flex; gap: .6rem; align-items: center; padding: .25rem .25rem 1rem; font-weight: 700; line-height: 1.2; }
.side .brand img { width: 34px; }
.side nav a { display: flex; align-items: center; gap: .6rem; padding: .6em .75em; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 500; }
.side nav a:hover { background: var(--surface-2); }
.side nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.side .me { margin-top: auto; border-top: 1px solid var(--border); padding-top: .75rem; font-size: .85rem; }
.content { padding: 1.5rem 2rem; min-width: 0; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.head h1 { margin: 0; }
.kpis { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 1.25rem; }
.kpi .n { font-size: 2rem; font-weight: 800; line-height: 1.1; }
.kpi .l { color: var(--muted); font-size: .85rem; }
.kpi.warn .n { color: var(--danger); }
.cols { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); margin-bottom: 1rem; }
.bars { display: grid; gap: .55rem; }
.bar { display: grid; grid-template-columns: minmax(110px, 38%) 1fr auto; gap: .6rem; align-items: center; font-size: .88rem; }
.bar .track { background: var(--surface-2); border-radius: 6px; height: 12px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--primary); border-radius: 6px; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 110px; }
.spark div { flex: 1; background: var(--primary); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }
.filters { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters > * { width: auto; flex: 1 1 160px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .65em .75em; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--surface-2); }
tbody tr { cursor: pointer; } tbody tr:hover { background: var(--surface-2); }
td.mono, .mono { font-family: ui-monospace, Consolas, monospace; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; }
.detail { display: grid; gap: 1rem; grid-template-columns: 1.4fr 1fr; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.foto { max-width: 100%; border-radius: 10px; border: 1px solid var(--border); }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(400px, 100%); }
.menu-btn { display: none; }

@media (max-width: 860px) {
  .admin { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: var(--shadow); }
  .menu-btn { display: inline-flex; }
  .content { padding: 1rem 16px; }
  .detail { grid-template-columns: 1fr; }
  .cols { grid-template-columns: 1fr; }
}
@media print { .side, .filters, .no-print { display: none !important; } .admin { display: block; } .card { box-shadow: none; } }
