@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,500;12..96,700&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --bg: #eef4f8; --surface: #f6fafc; --card: #fff; --top: rgba(255, 255, 255, .85);
  --text: #14232e; --muted: #5a6e7c; --line: #d5e0e8; --pale: #c3e8f7;
  --brand: #29a9e1; --blue: #1477a8; --chip: #e8eff4; --on: #f1f9fd;
  --ok: #1f9d6b; --warn: #d98a1c; --off: #5a6e7c; --danger: #d1495b;
  --shadow: 0 4px 14px rgba(20, 35, 46, .08); --focus: 0 0 0 3px rgba(41, 169, 225, .35);
  --sans: 'IBM Plex Sans', system-ui, sans-serif; --display: 'Bricolage Grotesque', var(--sans); --mono: 'IBM Plex Mono', ui-monospace, monospace;
}
:root[data-theme=dark] {
  --bg: #0b1620; --surface: #101e2a; --card: #132331; --top: rgba(15, 28, 39, .85);
  --text: #e6eef4; --muted: #8fa6b6; --line: #223a4d; --pale: #1d4a64;
  --brand: #29a9e1; --blue: #5cc0ee; --chip: #1a3042; --on: #123043;
  --ok: #35c28a; --warn: #f0a53a; --off: #8fa6b6; --danger: #ef6b7d;
  --shadow: 0 4px 14px rgba(0, 0, 0, .4);
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 var(--sans); color: var(--text); background: var(--bg); padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* barra superior */
header { position: sticky; top: 0; z-index: 10; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding: 10px 24px; background: var(--top); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
header .brand { flex: 1 1 auto; display: flex; align-items: center; gap: 12px; min-width: 0; }
header .brand img { height: 53px; width: auto; flex: none; object-fit: contain; display: block; background: #fff; border-radius: 8px; padding: 2px 6px; } /* el logo trae fondo blanco */
header .brand span { font: 700 1.05rem var(--display); letter-spacing: -.01em; padding-left: 12px; border-left: 1px solid var(--line); }
header .who { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--chip); color: var(--blue); font-size: 12px; font-weight: 600; }

/* pestañas */
nav { display: flex; gap: 4px; overflow-x: auto; background: var(--card); border-bottom: 1px solid var(--line); padding: 6px 24px 0; scrollbar-width: none; }
nav button { border: 0; background: none; padding: 12px 16px; white-space: nowrap; color: var(--muted); font-weight: 500; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; transition: color .12s, border-color .12s; }
nav button:hover { color: var(--text); }
nav button.on { color: var(--blue); border-color: var(--brand); }

main { padding: 24px; max-width: 1240px; margin: 0 auto; }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.head h1 { margin: 0; font: 700 1.75rem var(--display); letter-spacing: -.02em; }
.head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.search { position: relative; display: flex; align-items: center; color: var(--muted); }
.search svg { position: absolute; left: 12px; pointer-events: none; }
.search input { padding-left: 36px; min-width: 240px; }

/* controles */
input, select, textarea { padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); width: 100%; transition: border-color .12s, box-shadow .12s; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--brand); box-shadow: var(--focus); }
header select, .search input, td select { width: auto; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--brand); color: #fff; border: 1px solid var(--brand); border-radius: 10px; padding: 8px 14px; font-weight: 500; cursor: pointer; transition: filter .12s; }
.btn:hover { filter: brightness(.94); }
.btn.alt { background: transparent; color: var(--blue); border-color: var(--line); }
.btn.alt:hover { background: var(--on); }
.btn.danger { background: transparent; color: var(--danger); border-color: transparent; padding: 6px 8px; }
.btn.ico { background: transparent; color: var(--muted); border-color: transparent; padding: 6px 8px; }
.btn.ico:hover { color: var(--blue); background: var(--on); }
.btn.danger:hover { background: var(--chip); }
header .btn { background: transparent; color: var(--muted); border-color: var(--line); }

/* tabla */
.card, .wrap { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface); }
td.mono { font: 400 12.5px var(--mono); font-variant-numeric: tabular-nums; color: var(--muted); }
td.act { text-align: right; width: 1%; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 500; background: var(--chip); }
.chip i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.bad { color: var(--danger); } .chip.ok { color: var(--ok); } .chip.warn { color: var(--warn); } .chip.off { color: var(--off); }
.role { padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 500; background: var(--chip); color: var(--blue); }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); }

/* dashboard */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { display: grid; gap: 4px; text-align: left; padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); cursor: pointer; transition: border-color .12s, transform .12s; }
.kpi:hover { border-color: var(--brand); transform: translateY(-1px); }
.kpi span { font-size: 12.5px; color: var(--muted); }
.kpi b { font: 700 1.9rem var(--display); letter-spacing: -.02em; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; margin-bottom: 8px; }
.card.pad { padding: 16px; }
.card h3, h3.sec { margin: 0 0 12px; font: 600 .95rem var(--display); }
h3.sec { margin: 24px 0 10px; }
.hbar { display: grid; grid-template-columns: 110px 1fr auto; align-items: center; gap: 10px; margin: 8px 0; font-size: 13px; }
.hbar:has(> div:first-child) { grid-template-columns: 1fr; }
.hbar > div { height: 8px; border-radius: 99px; background: var(--chip); overflow: hidden; }
.hbar i { display: block; height: 100%; border-radius: 99px; background: var(--brand); }
.hbar i.ok { background: var(--ok); } .hbar i.warn { background: var(--warn); } .hbar i.bad { background: var(--danger); } .hbar i.off { background: var(--off); }
.lic { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.lic b { font: 700 2rem var(--display); }
.lic span, .sub { color: var(--muted); font-size: 13px; }
tr.click { cursor: pointer; }

/* aviso push con la app abierta */
.push { position: fixed; top: calc(12px + env(safe-area-inset-top)); left: 12px; right: 12px; max-width: 420px; margin: 0 auto; z-index: 50; display: grid; gap: 2px; padding: 12px 16px; background: var(--card); border: 1px solid var(--brand); border-left-width: 5px; border-radius: 12px; box-shadow: 0 18px 44px rgba(0, 0, 0, .3); cursor: pointer; }
.push span { color: var(--muted); font-size: 13.5px; }

/* login y diálogo */
.login { max-width: 420px; margin: 12vh auto; padding: 28px; background: var(--card); border-radius: 16px; border: 1px solid var(--line); box-shadow: var(--shadow); display: grid; gap: 12px; }
.login img { width: min(354px, 100%); height: auto; align-self: start; justify-self: center; object-fit: contain; display: block; background: #fff; border-radius: 10px; }
.login h1 { margin: 0; font: 700 1.2rem var(--display); text-align: center; }
.err { color: var(--danger); min-height: 1.2em; font-size: 14px; }
dialog { border: 1px solid var(--line); border-radius: 16px; padding: 22px; width: min(540px, calc(100vw - 24px)); max-height: 90vh; background: var(--card); color: var(--text); box-shadow: 0 18px 44px rgba(0, 0, 0, .3); }
dialog::backdrop { background: rgba(8, 20, 30, .55); backdrop-filter: blur(2px); }
dialog form { display: grid; gap: 12px; }
dialog h2 { margin: 0; font: 700 1.2rem var(--display); }
dialog label { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
dialog .swbox { display: grid; gap: 6px; font-size: 12.5px; color: var(--muted); }
dialog .swrow { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; }
dialog .swrow .btn { padding: 6px 12px; font-size: 18px; line-height: 1; }
dialog .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-bottom: 16px; display: flex; flex-wrap: wrap; gap: 8px; box-shadow: var(--shadow); }
.panel > * { flex: 1 1 160px; }

@media (max-width: 720px) {
  dialog .swrow { grid-template-columns: 1fr auto; }
  dialog .swrow .sws { grid-column: 1 / 2; }
  header { padding: 10px 16px; }
  header .who span:last-child { display: none; }
  nav { padding: 4px 12px 0; }
  main { padding: 16px; }
  .bar, .search { width: 100%; }
  .search input { min-width: 0; width: 100%; }
}
