/* PATRIMONIO JAGS 360 — estilos */
:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --ink: #17233b;
  --ink-2: #5a6b87;
  --line: #e3e8f0;
  --brand: #1f3a5f;
  --brand-2: #2b4d7a;
  --accent: #c9a34e;
  --ok: #1e9e5a;
  --warn: #e0a10b;
  --info: #2f6fd6;
  --bad: #d64541;
  --purple: #7a5fd3;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(23,35,59,.08), 0 4px 14px rgba(23,35,59,.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 14.5px; }
.hidden { display: none !important; }

/* ---------- login ---------- */
.login-screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #17233b 0%, #1f3a5f 55%, #2b4d7a 100%); z-index: 50; }
.login-card { background: #fff; border-radius: 16px; padding: 40px 44px; width: 380px; box-shadow: 0 24px 60px rgba(0,0,0,.35); text-align: center; }
.login-logo { font-size: 44px; }
.login-card h1 { font-size: 21px; letter-spacing: 2px; margin: 8px 0 2px; color: var(--brand); }
.login-sub { color: var(--ink-2); font-size: 13px; margin-bottom: 24px; }
.login-card form { text-align: left; display: grid; gap: 14px; }
.login-card label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); display: grid; gap: 5px; }
.login-card input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; }
.login-error { background: #fdecec; color: var(--bad); border-radius: 8px; padding: 9px 12px; font-size: 13px; }
.login-foot { margin-top: 22px; font-size: 11.5px; color: #9aa7bb; }

/* ---------- layout ---------- */
.app { display: flex; height: 100vh; }
.sidebar { width: 218px; background: #17233b; color: #cfd9e8; display: flex; flex-direction: column; flex-shrink: 0; }
.brand { padding: 20px 18px 16px; font-size: 15px; color: #fff; letter-spacing: 1px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand b { color: var(--accent); }
#nav { flex: 1; padding: 12px 8px; display: grid; gap: 2px; align-content: start; }
#nav a { display: flex; align-items: center; gap: 4px; padding: 10px 12px; border-radius: 8px; color: #cfd9e8; text-decoration: none; font-size: 14px; }
#nav a:hover { background: rgba(255,255,255,.07); }
#nav a.active { background: var(--accent); color: #17233b; font-weight: 700; }
.badge { background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; border-radius: 20px; padding: 1px 7px; margin-left: auto; }
#nav a.active .badge { background: #17233b; color: #fff; }
.sidebar-foot { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); display: grid; gap: 8px; }
.user-name { font-size: 12.5px; color: #9fb0c8; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; gap: 14px; padding: 14px 22px; background: var(--surface); border-bottom: 1px solid var(--line); align-items: center; }
#global-search { flex: 1; max-width: 520px; padding: 9px 14px; border: 1px solid var(--line); border-radius: 24px; font-size: 14px; background: var(--bg); }
main#view { flex: 1; overflow-y: auto; padding: 22px 26px 60px; }

/* ---------- componentes ---------- */
.btn { border: none; border-radius: 8px; padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: #2b4d7a; }
.btn-accent { background: var(--accent); color: #17233b; }
.btn-ghost { background: transparent; color: inherit; border: 1px solid var(--line); }
.sidebar .btn-ghost { border-color: rgba(255,255,255,.2); color: #cfd9e8; }
.btn-danger { background: var(--bad); color: #fff; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .cols-4 { grid-template-columns: 1fr 1fr; } .cols-3 { grid-template-columns: 1fr; } .cols-2 { grid-template-columns: 1fr; } }

.page-title { font-size: 20px; margin-bottom: 4px; }
.page-sub { color: var(--ink-2); font-size: 13px; margin-bottom: 18px; }

.kpi { display: grid; gap: 3px; }
.kpi .kpi-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--ink-2); font-weight: 700; }
.kpi .kpi-value { font-size: 25px; font-weight: 800; color: var(--brand); }
.kpi .kpi-foot { font-size: 12px; color: var(--ink-2); }
.kpi .up { color: var(--ok); font-weight: 700; }
.kpi .down { color: var(--bad); font-weight: 700; }
.kpi.clickable { cursor: pointer; }
.kpi.clickable:hover .kpi-value { color: var(--info); }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.pill.ok { background: #e2f5ea; color: var(--ok); }
.pill.warn { background: #fdf3d9; color: #a87908; }
.pill.info { background: #e3edfb; color: var(--info); }
.pill.bad { background: #fdecec; color: var(--bad); }
.pill.purple { background: #efeafc; color: var(--purple); }
.pill.gray { background: #eef1f6; color: var(--ink-2); }

.sev-critica { border-left: 4px solid var(--bad); }
.sev-alta { border-left: 4px solid var(--warn); }
.sev-media { border-left: 4px solid var(--info); }
.sev-baja { border-left: 4px solid #b9c3d4; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; padding: 9px 10px; border-bottom: 2px solid var(--line); font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-2); }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
.tbl tr:hover td { background: #f8fafd; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

/* tarjetas de activos */
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.asset-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; cursor: pointer; transition: transform .12s; }
.asset-card:hover { transform: translateY(-2px); }
.asset-photo { height: 140px; background: linear-gradient(135deg, #dfe6f0, #c6d2e3); display: flex; align-items: center; justify-content: center; font-size: 48px; position: relative; }
.asset-photo img { width: 100%; height: 100%; object-fit: cover; }
.asset-photo .pill { position: absolute; top: 10px; left: 10px; }
.asset-body { padding: 12px 14px; display: grid; gap: 4px; }
.asset-body .name { font-weight: 700; font-size: 15px; }
.asset-body .meta { font-size: 12.5px; color: var(--ink-2); }
.asset-body .value { font-weight: 800; color: var(--brand); font-size: 15px; }
.asset-alert { font-size: 12px; color: var(--bad); font-weight: 600; }
.asset-ok { font-size: 12px; color: var(--ok); }

/* filtros laterales */
.layout-filters { display: grid; grid-template-columns: 215px 1fr; gap: 18px; align-items: start; }
.filters { display: grid; gap: 14px; font-size: 13px; position: sticky; top: 0; }
.filters h4 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .7px; color: var(--ink-2); margin-bottom: 6px; }
.filters label { display: flex; gap: 7px; align-items: center; padding: 2px 0; cursor: pointer; }
.filters select, .filters input[type=text] { width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; font-family: inherit; }

/* ficha */
.ficha-head { display: flex; gap: 20px; margin-bottom: 18px; }
.ficha-photo { width: 230px; height: 160px; border-radius: var(--radius); overflow: hidden; background: linear-gradient(135deg,#dfe6f0,#c6d2e3); display:flex; align-items:center; justify-content:center; font-size: 54px; flex-shrink: 0; }
.ficha-photo img { width: 100%; height: 100%; object-fit: cover; }
.ficha-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ficha-title h2 { font-size: 22px; }
.ficha-meta { color: var(--ink-2); font-size: 13.5px; margin-top: 4px; }
.ficha-kpis { display: flex; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.mini-kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 8px 14px; }
.mini-kpi .l { font-size: 10.5px; text-transform: uppercase; color: var(--ink-2); font-weight: 700; letter-spacing: .5px; }
.mini-kpi .v { font-size: 16px; font-weight: 800; color: var(--brand); }

.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { border: none; background: none; padding: 9px 15px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; font-family: inherit; }
.tabs button.active { color: var(--brand); border-bottom-color: var(--accent); }

.dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px 22px; }
.dl > div { display: grid; gap: 1px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.dl .k { font-size: 11.5px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .4px; font-weight: 700; }
.dl .v { font-size: 14.5px; }

/* formularios */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: grid; gap: 4px; }
.field > span { font-size: 12px; font-weight: 700; color: var(--ink-2); }
.field .req { color: var(--bad); }
.field input, .field select, .field textarea { padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; font-size: 14px; font-family: inherit; width: 100%; }
.field textarea { min-height: 64px; resize: vertical; }
fieldset.fs { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
fieldset.fs legend { font-size: 12px; font-weight: 800; color: var(--brand); text-transform: uppercase; letter-spacing: .6px; padding: 0 8px; }
.chkrow { display: flex; gap: 14px; flex-wrap: wrap; }
.chkrow label { display: flex; gap: 5px; align-items: center; font-size: 13.5px; }

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 40; display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 40px 16px; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 760px; padding: 24px 28px; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.modal h3 { margin-bottom: 16px; font-size: 17px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* mapa */
.map-layout { display: grid; grid-template-columns: 235px 1fr; gap: 16px; height: calc(100vh - 130px); }
#map { border-radius: var(--radius); box-shadow: var(--shadow); height: 100%; min-height: 400px; z-index: 1; }
.map-side { overflow-y: auto; display: grid; gap: 14px; align-content: start; }
.marker-pin { display:flex; align-items:center; justify-content:center; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); width: 34px; height: 34px; box-shadow: 0 2px 6px rgba(0,0,0,.4); border: 2px solid #fff; }
.marker-pin span { transform: rotate(45deg); font-size: 15px; }
.leaflet-popup-content { margin: 12px 14px; min-width: 230px; }
.popup-card img { width: 100%; height: 110px; object-fit: cover; border-radius: 7px; }
.popup-card .t { font-weight: 800; font-size: 15px; margin: 6px 0 2px; }
.popup-card .m { font-size: 12px; color: var(--ink-2); }
.popup-card .row { display: flex; justify-content: space-between; margin-top: 4px; font-size: 12.5px; }

/* alertas */
.alert-item { display: flex; gap: 14px; align-items: center; padding: 13px 16px; }
.alert-item .grow { flex: 1; min-width: 0; }
.alert-item .t { font-weight: 700; }
.alert-item .d { font-size: 12.5px; color: var(--ink-2); }
.alert-item .monto { font-weight: 800; color: var(--brand); white-space: nowrap; }

/* gráficas */
.chart-bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 10px; }
.chart-bars .bar-group { flex: 1; display: flex; gap: 2px; align-items: flex-end; height: 100%; position: relative; }
.chart-bars .bar { flex: 1; border-radius: 3px 3px 0 0; min-height: 2px; }
.chart-bars .bar.in { background: var(--brand); }
.chart-bars .bar.out { background: #d0894a; }
.chart-labels { display: flex; gap: 6px; margin-top: 6px; }
.chart-labels span { flex: 1; text-align: center; font-size: 10px; color: var(--ink-2); }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--ink-2); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; }

.donut { display: flex; gap: 20px; align-items: center; }
.donut .ring { width: 130px; height: 130px; border-radius: 50%; flex-shrink: 0; position: relative; }
.donut .ring::after { content: attr(data-center); position: absolute; inset: 22px; background: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; color: var(--brand); text-align: center; white-space: pre-line; }
.donut ul { list-style: none; display: grid; gap: 5px; font-size: 13px; }
.donut li i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }

.hbar { display: grid; gap: 8px; }
.hbar .row2 { display: grid; grid-template-columns: 130px 1fr 90px; gap: 10px; align-items: center; font-size: 13px; }
.hbar .track { background: #eef1f6; border-radius: 5px; height: 14px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--brand); border-radius: 5px; }
.hbar .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.progress { background: #eef1f6; border-radius: 6px; height: 9px; overflow: hidden; }
.progress .fill { height: 100%; background: var(--ok); }

/* toast */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: #17233b; color: #fff; padding: 11px 22px; border-radius: 10px; font-size: 14px; z-index: 60; box-shadow: 0 8px 26px rgba(0,0,0,.35); }
.toast.err { background: var(--bad); }

.empty { text-align: center; color: var(--ink-2); padding: 34px 10px; font-size: 14px; }
.muted { color: var(--ink-2); }
.right { text-align: right; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.flex { display: flex; gap: 10px; align-items: center; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
a.link { color: var(--info); text-decoration: none; font-weight: 600; cursor: pointer; }
a.link:hover { text-decoration: underline; }
