/* DVTrace EDI — Consola de administración (mismo tema que /monitor) */
:root {
  --bg: #0d1117; --surface: #161b22; --surface2: #21262d; --surface3: #2b313a; --border: #30363d;
  --text: #e6edf3; --muted: #8b949e;
  --green: #2ea043; --green-dim: #122119; --yellow: #d29922; --yellow-dim: #2e2007;
  --red: #f85149; --red-dim: #2d1315; --blue: #388bfd; --blue-dim: #0c2d6b; --purple: #a371f7;
  --radius: 8px; --mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif; background: var(--bg);
  color: var(--text); font-size: 14px; line-height: 1.5; min-height: 100vh; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
.boot { padding: 48px; color: var(--muted); text-align: center; }

/* Layout */
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--border); padding: 16px 0; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; }
.brand { padding: 0 18px 16px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.brand b { font-size: 17px; letter-spacing: -.4px; }
.brand b span { color: var(--blue); }
.brand small { display: block; color: var(--muted); font-size: 11px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 18px; color: var(--text); border-left: 3px solid transparent; }
.nav a:hover { background: var(--surface2); text-decoration: none; }
.nav a.active { background: var(--surface2); border-left-color: var(--blue); color: #fff; font-weight: 600; }
.nav .ico { width: 18px; text-align: center; opacity: .85; }
.side-foot { margin-top: auto; padding: 12px 18px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.side-foot .btn { width: 100%; margin-top: 8px; }
.main { padding: 22px 28px 60px; min-width: 0; }
.page-h { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-h h1 { font-size: 20px; margin: 0; }
.page-h .sub { color: var(--muted); font-size: 13px; }
.page-h .sp { flex: 1; }

/* Cards / grids */
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: 1fr; } }
@media (max-width: 800px) { .layout { grid-template-columns: 1fr; } .side { position: static; height: auto; } .g2, .g4 { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card h3 { margin: 0 0 10px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.card .muted, .muted { color: var(--muted); }
.card.up { border-color: #1f5f2c; } .card.down { border-color: #6e2227; } .card.warn { border-color: #6c4f10; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.section { margin-top: 22px; }
.section > h2 { font-size: 15px; margin: 0 0 10px; }
.help { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; color: #c9d1d9; font-size: 13px; }
.help b { color: #fff; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 12px;
  background: var(--surface3); color: var(--text); white-space: nowrap; }
.badge.ok { background: var(--green-dim); color: #56d364; } .badge.err { background: var(--red-dim); color: #ff7b72; }
.badge.warn { background: var(--yellow-dim); color: #e3b341; } .badge.info { background: var(--blue-dim); color: #79c0ff; }
.badge.mute { background: var(--surface2); color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); }
.dot.ok { background: var(--green); box-shadow: 0 0 6px var(--green); } .dot.err { background: var(--red); box-shadow: 0 0 6px var(--red); }
.dot.warn { background: var(--yellow); }

/* Tables */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; background: var(--surface2); position: sticky; top: 0; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; } tbody tr.click:hover { background: var(--surface2); }
td.nowrap, th.nowrap { white-space: nowrap; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* Forms */
.btn { background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 6px 12px; border-radius: 6px;
  font-size: 13px; cursor: pointer; font-family: inherit; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { background: var(--surface3); text-decoration: none; }
.btn.primary { background: #1f6feb; border-color: #1f6feb; color: #fff; } .btn.primary:hover { background: #388bfd; }
.btn.danger { color: #ff7b72; border-color: #6e2227; } .btn.danger:hover { background: var(--red-dim); }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 6px; padding: 6px 9px;
  font-size: 13px; font-family: inherit; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px rgba(56,139,253,.25); }
textarea { font-family: var(--mono); font-size: 12.5px; resize: vertical; }
input[type=checkbox] { width: auto; }
label.fld { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
label.fld > span b { color: var(--red); }
label.chk { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; }
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.fgrid .full { grid-column: 1 / -1; }
.fgrid.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 800px) { .fgrid, .fgrid.g3 { grid-template-columns: 1fr; } }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px 14px; margin: 0 0 14px; }
legend { padding: 0 6px; font-weight: 600; font-size: 13px; }
.hint { font-size: 11.5px; color: var(--muted); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.filters > * { width: auto; }
.filters input, .filters select { min-width: 140px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.err-box { background: var(--red-dim); border: 1px solid #6e2227; color: #ffa198; padding: 9px 12px; border-radius: 6px; font-size: 13px; }
.ok-box { background: var(--green-dim); border: 1px solid #1f5f2c; color: #7ee787; padding: 9px 12px; border-radius: 6px; font-size: 13px; }

/* Modal / drawer */
.modal-bg { position: fixed; inset: 0; background: rgba(1,4,9,.7); z-index: 500; display: flex; justify-content: flex-end; }
.drawer { background: var(--surface); border-left: 1px solid var(--border); width: min(920px, 100vw); height: 100vh; overflow-y: auto;
  padding: 18px 22px 40px; }
.drawer.narrow { width: min(560px, 100vw); }
.drawer-h { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; position: sticky; top: -18px; background: var(--surface);
  padding: 8px 0; z-index: 2; border-bottom: 1px solid var(--border); }
.drawer-h h2 { margin: 0; font-size: 16px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: 12px 0; flex-wrap: wrap; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 7px 12px; cursor: pointer;
  font-size: 13px; font-family: inherit; }
.tabs button.active { color: var(--text); border-bottom-color: var(--blue); font-weight: 600; }

pre.code { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; overflow: auto; max-height: 520px;
  margin: 0; white-space: pre; }
pre.code.wrap { white-space: pre-wrap; word-break: break-all; }

/* Explicación */
.expl h4 { margin: 14px 0 6px; font-size: 13px; color: #79c0ff; text-transform: capitalize; }
.expl .card { margin-bottom: 10px; }
.expl table td:first-child { color: #c9d1d9; font-weight: 600; white-space: nowrap; }
.expl table td:last-child { color: var(--muted); }

/* Timeline */
.tl { position: relative; padding-left: 22px; }
.tl::before { content: ''; position: absolute; left: 7px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.tl-i { position: relative; padding: 0 0 14px; }
.tl-i::before { content: ''; position: absolute; left: -19px; top: 5px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--blue); border: 2px solid var(--surface); }
.tl-i.ok::before { background: var(--green); } .tl-i.err::before { background: var(--red); } .tl-i.warn::before { background: var(--yellow); }
.tl-i .t { font-size: 12px; color: var(--muted); }

/* Toast */
#toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 900; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--surface2); border: 1px solid var(--border); border-left: 4px solid var(--blue); padding: 10px 14px;
  border-radius: 6px; max-width: 420px; box-shadow: 0 8px 24px rgba(0,0,0,.4); font-size: 13px; }
.toast.ok { border-left-color: var(--green); } .toast.err { border-left-color: var(--red); }

/* Login */
.login { max-width: 360px; margin: 12vh auto; }
.login .card { padding: 26px; }
.login h1 { font-size: 20px; margin: 0 0 4px; } .login h1 span { color: var(--blue); }
.login form { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { background: var(--surface2); border: 1px solid var(--border); border-radius: 14px; padding: 2px 10px; font-size: 12px; cursor: pointer; }
.chip.active { border-color: var(--blue); color: #79c0ff; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }
