/* Identidad de Monitoreo Inteligente: azul marino #001E60 y naranja #FF5000, los del logo. */
:root {
  --brand-navy: #001E60;
  --brand-navy-2: #0A3290;
  --brand-orange: #FF5000;
  --brand-orange-soft: #FFE4D6;
  /* Naranja sobre fondo marino (textos pequeños, subrayados). */
  --brand-teal: #FF7A33;
  --brand-teal-soft: #FFE4D6;
  --bg: #f3f6f9;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --border: #dde3ea;
  --text: #0f1b2d;
  --muted: #5a6678;
  --accent: #0B3EA8;
  --accent-text: #ffffff;
  --accent-soft: #e6edfb;
  --ok: #157f3b;
  --ok-soft: #e3f5e9;
  --warn: #9a5b00;
  --warn-soft: #fdf1dc;
  --bad: #b42318;
  --bad-soft: #fde8e7;
  --mark: #ffe58a;
  --shadow: 0 1px 2px rgba(11, 31, 58, .05), 0 2px 6px rgba(11, 31, 58, .06);
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #050f2a;
    --surface: #0c1a3d;
    --surface-2: #12234d;
    --border: #233766;
    --text: #e6edf5;
    --muted: #93a3b8;
    --accent: #8fb0ff;
    --accent-text: #001033;
    --accent-soft: #16295c;
    --ok: #4ade80;
    --ok-soft: #12301f;
    --warn: #fbbf24;
    --warn-soft: #3a2a08;
    --bad: #f87171;
    --bad-soft: #3b1414;
    --mark: #6b5a12;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; line-height: 1.3; overflow-wrap: anywhere; }
h2 { font-size: 15px; margin: 0 0 12px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.error { color: var(--bad); margin: 0; }
.boot { padding: 40px; text-align: center; color: var(--muted); }

/* -- botones y campos ---------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 500;
  cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }
input, select {
  height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; min-width: 0;
}
input:focus, select:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }

/* -- marca --------------------------------------------------------------- */
.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; }
.brand:hover { text-decoration: none; }
.brand-mark { display: block; flex: none; height: 28px; width: auto; }
.brand-logo { display: block; height: 44px; width: auto; max-width: 100%; align-self: flex-start; object-fit: contain; }
.brand-logo-sm { height: 34px; }
.hero-brand picture { align-self: flex-start; }
.brand-app {
  align-self: flex-start; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .4px;
  background: rgba(255, 255, 255, .1); color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
}
.brand-app-light { background: var(--accent-soft); color: var(--accent); box-shadow: none; }
.made-by { display: flex; align-items: center; justify-content: center; gap: 8px; }
.made-by img { height: 18px; width: auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 800; font-size: 16px; letter-spacing: .2px; }
.brand-sub { font-size: 10.5px; font-weight: 600; letter-spacing: 1.4px; text-transform: uppercase; color: var(--brand-teal); }
.brand-lg .brand-name { font-size: 20px; color: var(--text); }
.brand-lg .brand-sub { color: var(--accent); }

/* -- login --------------------------------------------------------------- */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.login-hero {
  position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 24px; padding: 40px 48px;
  background: radial-gradient(120% 90% at 85% 10%, var(--brand-navy-2) 0%, var(--brand-navy) 60%);
  color: #e6edf5;
}
.hero-brand { display: flex; flex-direction: column; gap: 14px; }
.hero-name { font-size: 22px; font-weight: 800; letter-spacing: .2px; }
.hero-sub { font-size: 11.5px; font-weight: 600; letter-spacing: 1.6px; text-transform: uppercase; color: var(--brand-teal); }
.hero-art {
  width: 100%; max-width: 560px; height: auto; margin: auto; display: block;
  -webkit-mask-image: radial-gradient(closest-side, #000 70%, transparent 100%);
  mask-image: radial-gradient(closest-side, #000 70%, transparent 100%);
}
.hero-copy h2 { font-size: 26px; line-height: 1.25; margin: 0 0 8px; color: #fff; }
.hero-copy p { margin: 0; color: #a9bad0; max-width: 460px; font-size: 15px; }
.login-panel { display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 32px; box-shadow: var(--shadow);
}
.login-card p { margin: 0; }
.login-title { font-size: 22px; margin-bottom: 4px; }
.login-card input { height: 42px; }
.login-card .btn { height: 42px; }
.login-foot { font-size: 12px; text-align: center; }
.login-mobile-brand { display: none; }

/* -- layout -------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 28px;
  padding: 0 24px; height: 60px; color: #e6edf5;
  background: linear-gradient(90deg, var(--brand-navy) 0%, #00267a 70%, var(--brand-navy-2) 100%);
  box-shadow: inset 0 -2px 0 var(--brand-orange);
}
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { padding: 7px 12px; border-radius: 8px; color: #a9bad0; font-weight: 500; }
.nav a:hover { background: rgba(255, 255, 255, .07); text-decoration: none; color: #fff; }
.nav a.active { color: #fff; background: rgba(255, 255, 255, .1); box-shadow: inset 0 -3px 0 var(--brand-orange); }
.user { display: flex; align-items: center; gap: 10px; }
.user-name { color: #cfd9e6; font-size: 13px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--brand-orange); color: #fff; font-weight: 800; font-size: 13px; text-transform: uppercase;
}
.topbar .btn-ghost { color: #cfd9e6; }
.topbar .btn-ghost:hover { background: rgba(255, 255, 255, .08); }
.view { max-width: 1280px; margin: 0 auto; padding: 24px; outline: none; }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 8px 16px 28px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* -- resumen ------------------------------------------------------------- */
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; }
.page-head p { margin: 2px 0 0; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { padding: 14px 16px; position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--accent); }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 24px; font-weight: 750; letter-spacing: -.3px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-hint { font-size: 12px; color: var(--muted); }

/* -- búsqueda ------------------------------------------------------------ */
.search-hero { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.search-main { display: flex; gap: 8px; }
.search-main input { flex: 1; height: 44px; font-size: 16px; padding: 0 14px; font-family: var(--mono); }
.search-main .btn { height: 44px; padding: 0 20px; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.more-filters > summary { cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 600; padding: 4px 0; }
.more-filters[open] > summary { margin-bottom: 10px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 12.5px; cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip .count { color: var(--muted); font-size: 11.5px; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

/* -- tablas -------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
th button { all: unset; cursor: pointer; }
th button:hover { color: var(--text); }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }
td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.actions { white-space: nowrap; text-align: right; }
.file-name { font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }
.when { white-space: nowrap; }
.when small { display: block; color: var(--muted); font-size: 12px; }

.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.fmt { font-family: var(--mono); font-weight: 500; }

.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.more { display: flex; justify-content: center; padding: 12px; }

/* -- detalle ------------------------------------------------------------- */
.crumbs { font-size: 13px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; }
.detail-head { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.detail-head > div:first-child { flex: 1; min-width: 240px; }
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 20px; margin-top: 16px; }
.meta dt { font-size: 12px; color: var(--muted); }
.meta dd { margin: 2px 0 0; word-break: break-all; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 8px; }
.tab { all: unset; cursor: pointer; padding: 10px 12px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.toolbar { display: flex; gap: 8px; padding: 12px 14px; flex-wrap: wrap; align-items: center; border-bottom: 1px solid var(--border); }
.toolbar input[type=search], .toolbar input[type=text] { flex: 1; min-width: 180px; }
.check { flex-direction: row; align-items: center; gap: 6px; font-size: 13px; color: var(--text); font-weight: 400; }
.check input { height: auto; }

.match-group { border-bottom: 1px solid var(--border); }
.match-group:last-child { border-bottom: none; }
.match-group h3 { margin: 0; padding: 10px 14px; font-size: 12.5px; font-family: var(--mono); background: var(--surface-2); word-break: break-all; }
.match { display: grid; grid-template-columns: 64px 1fr; gap: 10px; padding: 6px 14px; font-family: var(--mono); font-size: 12.5px; text-decoration: none; color: var(--text); }
.match:hover { background: var(--accent-soft); text-decoration: none; }
.match .ln { color: var(--muted); text-align: right; }
.match .tx { white-space: pre-wrap; word-break: break-all; }
.match .ctx { color: var(--muted); }
mark { background: var(--mark); color: inherit; border-radius: 2px; }

/* -- visor --------------------------------------------------------------- */
.viewer { margin: 0; padding: 14px 16px; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-all; overflow-x: auto; min-height: 200px; tab-size: 4; }
.viewer-status { padding: 8px 14px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* -- API ----------------------------------------------------------------- */
.doc p { margin: 0 0 10px; }
.doc pre { margin: 0 0 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow-x: auto; font-family: var(--mono); font-size: 12.5px; }
.doc table td, .doc table th { padding: 8px 10px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 20;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); max-width: calc(100vw - 32px);
}

tr.nested-head td { background: var(--surface-2); }
tr.nested-child td:first-child { padding-left: 34px; }

/* -- utilidades -------------------------------------------------------- */
.m0 { margin: 0; }
.mt6 { margin-top: 6px; }
.mt8 { margin-top: 8px; }
.mb12 { margin-bottom: 12px; }
.title-sm { font-size: 16px; }
.toolbar .w-260 { flex: 0 1 260px; min-width: 140px; }
.viewer-status.status-top { border-top: none; border-bottom: 1px solid var(--border); }

/* -- móvil --------------------------------------------------------------- */
@media (max-width: 980px) {
  .login { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .login-mobile-brand { display: flex; }
  .login-panel { background: radial-gradient(120% 70% at 80% 0%, var(--brand-navy-2) 0%, var(--brand-navy) 65%); }
}

@media (max-width: 760px) {
  .topbar { padding: 8px 16px 0; gap: 12px; height: auto; min-height: 56px; flex-wrap: wrap; }
  .user-name { display: none; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-value { font-size: 20px; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; padding-bottom: 8px; }
  .view { padding: 16px; }
  .search-main { flex-direction: column; }
  .hide-sm { display: none; }
  th, td { padding: 8px 10px; }
  .match { grid-template-columns: 44px 1fr; }

  /* Paquetes como tarjetas: fecha/estado, IMEI/tamaño, archivo y acción. */
  .pkg-table thead { display: none; }
  .pkg-table tr {
    display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 12px 14px;
    grid-template-areas: "when status" "imei size" "file file" "actions actions";
    border-bottom: 1px solid var(--border);
  }
  .pkg-table td { padding: 0; border: none; }
  .pkg-table .c-when { grid-area: when; }
  .pkg-table .c-status { grid-area: status; text-align: right; }
  .pkg-table .c-imei { grid-area: imei; }
  .pkg-table .c-size { grid-area: size; }
  .pkg-table .c-file { grid-area: file; }
  .pkg-table .c-actions { grid-area: actions; text-align: left; }
  .pkg-table .c-actions:empty { display: none; }
}
