/* =====================================================================
   Activos de TI — estilos
   ===================================================================== */
/* Tipografías de la identidad de EFTS Group (efts-group.com) */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@600;700&family=Titillium+Web:wght@400;600;700&display=swap');
:root {
  --brand: #15243a;
  --accent: #1f5f8b;
  --font-texto: "Titillium Web", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-titulos: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --accent-ink: #ffffff;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --line: #e2e5ea;
  --line-2: #cfd4db;
  --ink: #18212d;
  --ink-2: #4b5563;
  --ink-3: #6b7280;
  --good: #0a7d0a;  --good-bg: #e7f5e7;
  --warn: #8a5a00;  --warn-bg: #fff4d6;  --warn-mark: #fab219;
  --serious: #a8461e; --serious-bg: #fde9df;
  --crit: #b42323;  --crit-bg: #fbe5e5;
  --info: #255d9e;  --info-bg: #e6eef9;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --sidebar: 232px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.45 var(--font-texto);
  color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-family: var(--font-titulos); font-size: 28px; font-weight: 700; letter-spacing: 0; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.oculto { display: none !important; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

/* ---------- Estructura ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  background: var(--brand); color: #dfe6ee; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; padding: 18px 12px; gap: 4px; overflow-y: auto;
}
.marca { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; }
.marca img { max-height: 34px; max-width: 120px; }
.marca .mono-logo {
  width: 34px; height: 34px; border-radius: 8px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; letter-spacing: .02em;
}
.marca .t1 { font-weight: 650; font-size: 14px; line-height: 1.1; }
.marca .t2 { font-size: 11.5px; opacity: .7; }
.marca.con-logo { flex-direction: column; align-items: flex-start; gap: 6px; }
.marca.con-logo img { max-height: none; max-width: 100%; width: 190px; height: auto; }
.marca.con-logo .t2 { font-family: var(--font-titulos); font-size: 17px; font-weight: 600; opacity: .85; letter-spacing: .01em; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: #c9d3de; font-weight: 500; text-decoration: none;
}
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav a.activo { background: rgba(255, 255, 255, .13); color: #fff; }
.nav .sep { height: 1px; background: rgba(255, 255, 255, .1); margin: 10px 6px; }
.sidebar .pie { margin-top: auto; padding: 12px 8px 0; font-size: 12px; color: #9fb0c2; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar .pie b { color: #fff; font-weight: 600; display: block; }
.sidebar .pie button { margin-top: 8px; }

.principal { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar .menu-btn { display: none; }
.buscador { position: relative; flex: 1; max-width: 560px; }
.buscador input, .buscador input[type=search] { width: 100%; padding-left: 34px; }
.buscador svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; color: var(--ink-3); }
.resultados {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(16,24,40,.14); max-height: 420px; overflow: auto; z-index: 30;
}
.resultados a { display: block; padding: 9px 12px; color: var(--ink); border-bottom: 1px solid var(--line); text-decoration: none; }
.resultados a:hover, .resultados a.sel { background: var(--surface-2); }
.resultados .grupo { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); padding: 8px 12px 4px; }
.topbar .rol { margin-left: auto; }

main.contenido { padding: 24px 28px 48px; max-width: 1480px; width: 100%; }
.encabezado { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.encabezado .sub { color: var(--ink-3); margin-top: 4px; }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Tarjetas ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > .card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card > .card-b { padding: 16px 18px; }
.card + .card, .grid + .card, .card + .grid, .grid + .grid { margin-top: 16px; }
.grid { display: grid; gap: 16px; align-items: start; }
.grid > .card, .grid > div > .card:first-child { margin-top: 0; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .k-t { font-size: 12px; color: var(--ink-3); font-weight: 500; }
.kpi .k-v { font-size: 24px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi .k-s { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
a.kpi { color: inherit; text-decoration: none; }
a.kpi:hover { border-color: var(--line-2); }

/* Ficha de datos */
.datos { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 20px; }
.datos > div > span:first-child { display: block; font-size: 12px; color: var(--ink-3); }
.datos div b { font-weight: 550; word-break: break-word; }

/* ---------- Controles ---------- */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 10px; background: #fff; min-height: 36px; width: 100%;
}
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; border-color: var(--accent); }
label.campo { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
label.campo .ayuda { font-weight: 400; color: var(--ink-3); font-size: 12px; }
label.check { display: flex; gap: 8px; align-items: center; font-size: 13.5px; }
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form .full { grid-column: 1 / -1; }
.form h4 { grid-column: 1 / -1; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.form h4:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.req::after { content: " *"; color: var(--crit); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center; border: 1px solid var(--line-2); background: #fff;
  padding: 7px 13px; border-radius: 8px; cursor: pointer; font-weight: 550; min-height: 36px; white-space: nowrap; color: var(--ink);
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn.primario { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primario:hover { filter: brightness(.94); }
.btn.peligro { color: var(--crit); border-color: #e7b4b4; }
.btn.peligro:hover { background: var(--crit-bg); }
.btn.chico { padding: 4px 9px; min-height: 28px; font-size: 12.5px; }
.btn.link { border-color: transparent; background: transparent; color: var(--accent); padding-inline: 6px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.sidebar .btn { background: transparent; color: #dfe6ee; border-color: rgba(255,255,255,.25); }

.filtros { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filtros input[type=search] { width: 260px; }
.filtros select { width: auto; min-width: 150px; }
.chips { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; background: #fff; }
.chips button { border: 0; background: transparent; padding: 7px 12px; cursor: pointer; font-weight: 500; color: var(--ink-2); border-right: 1px solid var(--line); }
.chips button:last-child { border-right: 0; }
.chips button.activo { background: var(--brand); color: #fff; }
.chips button .c { opacity: .7; font-size: 12px; margin-left: 4px; }

/* ---------- Tablas ---------- */
.tabla-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--ink-3); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; z-index: 1; }
th.ord { cursor: pointer; user-select: none; }
th.ord:hover { color: var(--ink); }
th .flecha { opacity: .6; font-size: 10px; margin-left: 3px; }
tbody tr:last-child td { border-bottom: 0; }
tr.clic { cursor: pointer; }
tr.clic:hover td { background: #f7f9fb; }
tr.sel td { background: #eef6f7 !important; }
td .sub { display: block; font-size: 12px; color: var(--ink-3); }
.vacio { padding: 28px; text-align: center; color: var(--ink-3); }
td input[type=checkbox], th input[type=checkbox] { width: 16px; height: 16px; }

/* ---------- Insignias ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.nodot::before { display: none; }
.b-disponible { background: var(--info-bg); color: var(--info); }
.b-asignado { background: var(--good-bg); color: var(--good); }
.b-reparacion { background: var(--warn-bg); color: var(--warn); }
.b-baja { background: #eceef1; color: #4b5563; }
.b-critica { background: var(--crit-bg); color: var(--crit); }
.b-alta { background: var(--serious-bg); color: var(--serious); }
.b-media { background: var(--warn-bg); color: var(--warn); }
.b-info { background: var(--info-bg); color: var(--info); }
.b-ok { background: var(--good-bg); color: var(--good); }
.b-neutro { background: #eceef1; color: #4b5563; }

/* Barra de uso de licencias */
.uso { display: flex; align-items: center; gap: 8px; min-width: 150px; }
.uso .barra { flex: 1; height: 8px; border-radius: 4px; background: #e9ecf0; overflow: hidden; display: flex; gap: 2px; }
.uso .barra i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.uso .barra i.lleno { background: #6b7280; }
.uso span { font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink-2); }

/* ---------- Alertas ---------- */
.alerta { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.alerta:last-child { border-bottom: 0; }
.alerta .ico { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; }
.alerta .ico svg { width: 16px; height: 16px; }
.alerta .t { font-weight: 600; }
.alerta .d { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.sev-critica .ico { background: var(--crit-bg); color: var(--crit); }
.sev-alta .ico { background: var(--serious-bg); color: var(--serious); }
.sev-media .ico { background: var(--warn-bg); color: var(--warn); }
.sev-info .ico { background: var(--info-bg); color: var(--info); }

/* Línea de tiempo */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.timeline li::after { content: ""; position: absolute; left: 9px; top: 18px; bottom: 0; width: 1px; background: var(--line-2); }
.timeline li:last-child::after { display: none; }
.timeline .f { font-size: 12px; color: var(--ink-3); }
.timeline li.ev-baja::before { background: #6b7280; }
.timeline li.ev-reparacion::before { background: var(--warn-mark); }
.timeline li.ev-devolucion::before { background: #94a3b8; }

/* ---------- Modal ---------- */
.modal-fondo { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: grid; place-items: start center; padding: 6vh 16px; z-index: 100; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 14px; width: min(640px, 100%); box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal.ancho { width: min(920px, 100%); }
.modal .m-h { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal .m-b { padding: 18px 20px; max-height: 70vh; overflow-y: auto; }
.modal .m-f { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 14px 14px; }
.modal .cerrar { border: 0; background: transparent; font-size: 22px; line-height: 1; cursor: pointer; color: var(--ink-3); padding: 2px 6px; }
.modal .error { color: var(--crit); background: var(--crit-bg); padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }

/* Avisos flotantes */
#toast { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: 420px; }
#toast div { background: #1f2937; color: #fff; padding: 11px 14px; border-radius: 10px; box-shadow: 0 8px 20px rgba(0,0,0,.2); font-size: 13.5px; }
#toast div.ok { background: #0b6b3a; }
#toast div.bad { background: #a12020; }

/* Graficas */
.grafica { position: relative; height: 280px; }
.grafica.alta { height: 360px; }
.vista-tabla { margin-top: 10px; }
.leyenda { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); }
.leyenda i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* Avisos dentro de página */
.aviso { padding: 10px 14px; border-radius: 8px; background: var(--info-bg); color: var(--info); font-size: 13.5px; }
.aviso.warn { background: var(--warn-bg); color: var(--warn); }
.aviso.bad { background: var(--crit-bg); color: var(--crit); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, var(--brand), color-mix(in srgb, var(--brand) 70%, var(--accent))); }
.login .card { width: min(400px, 100%); padding: 28px; }
.login h1 { margin-bottom: 4px; }
.login form { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.login .o { text-align: center; color: var(--ink-3); font-size: 12px; margin: 4px 0; }

/* Firma */
.pad { border: 1px dashed var(--line-2); border-radius: 10px; background: #fff; touch-action: none; width: 100%; height: 200px; display: block; }

/* Solo lectura: ocultar acciones de edición */
body.solo-lectura [data-edita] { display: none !important; }
body:not(.es-admin) [data-admin] { display: none !important; }

/* ---------- Adaptable ---------- */
@media (max-width: 1100px) {
  .g3 { grid-template-columns: 1fr 1fr; }
  .g-21 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; z-index: 50; }
  .sidebar.abierta { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .topbar { padding: 10px 16px; }
  .topbar .menu-btn { display: inline-flex; }
  .topbar .rol { display: none; }
  main.contenido { padding: 16px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .form { grid-template-columns: 1fr; }
  .filtros input[type=search] { width: 100%; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .k-v { font-size: 20px; }
}

@media print {
  .sidebar, .topbar, .no-print, .acciones, .filtros { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
  main.contenido { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
}
