/* Estilo global de GUAPA. Se carga después de los estilos de cada pantalla para unificar la apariencia. */
:root {
    --g900: #12341d;
    --g800: #1a4628;
    --g700: #1f5130;
    --g600: #277040;
    --g500: #1f8a3b;
    --g100: #e6f2e9;
    --bg: #f1f4f0;
    --card: #ffffff;
    --line: #e1e7df;
    --text: #1b2a1e;
    --muted: #6b786d;
    --warn: #c77d00;
    --danger: #b3261e;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(18, 52, 29, .06), 0 4px 14px rgba(18, 52, 29, .06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    margin: 0; background: var(--bg); color: var(--text); line-height: 1.45; font-size: 15px;
}
h1, h2, h3, h4 { color: var(--g900); letter-spacing: -.01em; }
h2 { font-size: 1.45em; } h3 { font-size: 1.1em; } h4 { font-size: 1em; }
a { color: var(--g600); }
a:hover { color: var(--g500); }

/* Encabezado y navegación */
header.top-nav {
    position: sticky; top: 0; z-index: 1000;
    background: #fff; border-bottom: 3px solid var(--g600);
    color: var(--text); padding: 8px 24px; min-height: 64px;
    display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
    box-shadow: 0 3px 12px rgba(18, 52, 29, .12);
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1em; }
.brand:hover { color: #fff; }
.brand .logo-img { height: 50px; width: auto; display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.brand .logo {
    width: 30px; height: 30px; border-radius: 9px; background: #fff; color: var(--g700);
    display: grid; place-items: center; font-weight: 800; font-size: .95em;
}
.brand small { display: block; font-weight: 400; font-size: .68em; opacity: .75; margin-top: -2px; }
nav.main-nav { display: flex; gap: 4px; flex-wrap: wrap; padding: 8px 0; }
nav.main-nav a {
    color: var(--g700); text-decoration: none; padding: 7px 14px; border-radius: 999px;
    font-size: .93em; font-weight: 500; transition: background .15s, color .15s;
}
nav.main-nav a:hover { background: var(--g100); color: var(--g800); }
nav.main-nav a.active { background: var(--g700); color: #fff; font-weight: 600; }
.userbox { display: flex; align-items: center; gap: 10px; margin: 0; font-size: .9em; }
.userbox .who { color: var(--muted); }
.userbox button {
    background: #fff; border: 1px solid var(--g600); color: var(--g700);
    padding: 6px 14px; cursor: pointer; border-radius: 999px; font: inherit; font-size: .92em;
}
.userbox button:hover { background: var(--g100); }

main { max-width: 1320px; margin: 24px auto 48px; padding: 0 18px; }

/* Tarjetas */
.card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px 22px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }

/* Tablas */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
thead th {
    font-size: .76em; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
    background: #f7f9f6; font-weight: 600; white-space: nowrap;
}
tbody tr:hover td { background: #f8fbf7; }
table.cal tbody tr:hover td { background: inherit; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Textos auxiliares */
.muted { color: var(--muted); font-size: .9em; }
.err { color: var(--danger); }

/* Formularios */
input, select, textarea {
    font: inherit; color: inherit; background: #fff; border: 1px solid #cdd6cb; border-radius: 8px;
    padding: 8px 10px; transition: border-color .15s, box-shadow .15s;
}
input { width: 100%; margin: 4px 0 12px; }
input[type=checkbox], input[type=radio], input[type=range] { width: auto; margin: 0; padding: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--g500); box-shadow: 0 0 0 3px rgba(31, 138, 59, .18); }
label { display: block; font-size: .9em; color: #3b4a3e; }

/* Botones */
.btn, .btnl, button.act {
    background: var(--g700); color: #fff; border: 0; padding: 9px 16px; border-radius: 8px; cursor: pointer;
    font: inherit; font-weight: 600; font-size: .93em; text-decoration: none; display: inline-block;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .15); transition: background .15s, transform .05s;
}
.btn:hover, .btnl:hover, button.act:hover { background: var(--g600); color: #fff; }
.btn:active, .btnl:active, button.act:active { transform: translateY(1px); }
.btn:disabled, button.act:disabled { opacity: .55; cursor: not-allowed; }
.btnl.sec { background: #eef2ec; color: var(--g800); box-shadow: none; border: 1px solid #d3dcd1; }
.btnl.sec:hover { background: #e2e9df; color: var(--g900); }

/* Indicadores */
.k, .kpi > div {
    background: linear-gradient(180deg, #f9fbf8, #f1f5f0); border: 1px solid var(--line);
    border-left: 4px solid var(--g500); border-radius: 10px; padding: 11px 14px;
}
.k span, .kpi span { font-size: .78em; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.k b, .kpi b { color: var(--g900); }
.kv { border-bottom: 1px dashed var(--line) !important; padding: 5px 0 !important; }
.kv span { color: #3b4a3e; }
.kv:last-child { border-bottom: 0 !important; }

.pill, .badge, .tag, .sbadge { border-radius: 999px !important; }
.alert { border-radius: 8px; }
.warn { border-radius: 8px; }
#map { border: 1px solid var(--line); box-shadow: var(--shadow); }
.sensor { background: #fbfcfb; }

/* Etiquetas con descripción (ver public/js/glosario.js) */
[data-tip] { cursor: help; }
.has-tip { text-decoration: underline dotted rgba(31, 81, 48, .45); text-underline-offset: 3px; }
#gtip {
    position: fixed; z-index: 99999; max-width: 340px; pointer-events: none;
    background: #14261a; color: #f2f7f3; padding: 10px 13px; border-radius: 9px;
    font-size: .86rem; line-height: 1.45; font-weight: 400; text-transform: none; letter-spacing: 0;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .28); opacity: 0; transform: translateY(4px);
    transition: opacity .12s, transform .12s;
}
#gtip.show { opacity: 1; transform: none; }
#gtip b { display: block; color: #9fe0b1; margin-bottom: 3px; font-size: .92em; }

@media (max-width: 800px) {
    header.top-nav { padding: 6px 12px; }
    main { padding: 0 10px; }
    .card { padding: 14px; }
}
@media print {
    header.top-nav { display: none; }
    body { background: #fff; }
}
