:root {
  --bg: #0a0d12;
  --surface: #11161d;
  --surface2: #161d27;
  --line: #1e2631;
  --txt: #e6edf3;
  --muted: #8b98a5;
  --accent: #4c8dff;
  --accent2: #1f6feb;
  --ok: #3fb950;
  --mid: #d29922;
  --bad: #f85149;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--txt);
  font: 14.5px/1.55 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- shell */
.shell { display: flex; min-height: 100vh; }

.side {
  width: 238px;
  flex: 0 0 238px;
  position: sticky;
  top: 0;
  height: 100vh;
  background: #0d1218;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  gap: 18px;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 650;
  padding: 0 8px;
}
.logo-mark {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, #1f6feb, #7c3aed);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .5px;
}

.side-nav { display: flex; flex-direction: column; gap: 3px; }

.side-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 14px;
}
.side-item svg { width: 18px; height: 18px; flex: 0 0 18px; }
.side-item:hover { background: #141b24; color: var(--txt); text-decoration: none; }
.side-item.on {
  background: rgba(76, 141, 255, .13);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--accent);
}

.side-search {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #0a0f15;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 10px;
}
.side-search svg { width: 15px; height: 15px; color: var(--muted); }
.side-search input {
  border: 0;
  background: none;
  color: var(--txt);
  font: inherit;
  font-size: 13px;
  width: 100%;
  outline: none;
}

.side-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  padding: 0 10px;
}
.live {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(63,185,80,.55); }
  70%  { box-shadow: 0 0 0 7px rgba(63,185,80,0); }
  100% { box-shadow: 0 0 0 0 rgba(63,185,80,0); }
}

.main { flex: 1; min-width: 0; padding: 24px 30px 70px; }

/* ---------------------------------------------------------------- header */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 21px; font-weight: 650; letter-spacing: -.2px; }
.brand a { color: var(--txt); }
.who { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.who form { margin: 0; }

button.link {
  background: none; border: 0; color: var(--muted);
  font: inherit; cursor: pointer; padding: 0;
}
button.link:hover { color: var(--txt); text-decoration: underline; }

.badge {
  font-size: 12px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted);
}
.badge.ok { color: var(--ok); border-color: #1f6f33; }

/* ---------------------------------------------------------------- bloques */
main { max-width: 1220px; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 15px 17px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: var(--txt);
}
.stat:hover { border-color: #2b3644; text-decoration: none; }
.stat b { font-size: 23px; font-weight: 650; letter-spacing: -.4px; }
.stat span { font-size: 12px; color: var(--muted); }
.stat.hot b { color: var(--mid); }
.stat.alarm b { color: var(--bad); }

.hero {
  background: linear-gradient(160deg, #121a26, #0e141c);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
  margin-bottom: 22px;
}
.hero h2 { margin: 0 0 4px; font-size: 19px; }
.hero .hint { margin: 0 0 14px; }

.panel-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 18px;
}
.panel-card h2 { margin: 0 0 8px; font-size: 16px; }
.panel-card details { margin-top: 12px; }
.panel-card summary { cursor: pointer; font-size: 13px; }
.panel-card pre.out {
  margin: 8px 0 0;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

h2.sec, .sec {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--muted);
  font-weight: 600;
  margin: 26px 0 10px;
}

.hint { color: var(--muted); font-size: 13px; }
.meta {
  color: var(--muted);
  font-size: 12.5px;
  margin: 0 0 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---------------------------------------------------------------- tablas */
table.grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
table.grid th, table.grid td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
  vertical-align: top;
}
table.grid thead th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  font-weight: 600;
  background: #0f141b;
}
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover { background: #151c26; }
table.grid tr.missed { background: rgba(248, 81, 73, .05); }

td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
td.mono, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
td.dim, .dim { color: var(--muted); }
td.empty, .empty { color: var(--muted); text-align: center; padding: 26px 14px; }
td.right { text-align: right; }
td.appcell { max-width: 24ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.valcell { max-width: 32ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.wrap { white-space: pre-wrap; word-break: break-word; }
pre.authlog { font-size: 12px; background: #10151d; color: #8b949e;
  padding: 8px 10px; border-radius: 6px; overflow-x: auto;
  max-height: 180px; overflow-y: auto; white-space: pre-wrap;
  word-break: break-word; margin: 4px 0 10px; }
td.ckv code.ckmask { display: inline-block; max-width: 34em;
  overflow-wrap: anywhere; vertical-align: middle; }
td.ckv .mini { margin-left: 6px; vertical-align: middle; }
td.ckv { max-width: 40em; word-break: break-all; }

/* ---------------------------------------------------------------- pills */
.pill {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  white-space: nowrap;
}
.pill.ok { color: #b7f0c3; background: #12351d; border-color: #1f6f33; }
.pill.high { color: #ffd9d5; background: #3d1518; border-color: #7f2a30; }
.pill.mid, .pill.medium { color: #f4e0b3; background: #3a2d10; border-color: #6b5518; }
.pill.low { color: #c3dcff; background: #132a44; border-color: #24496f; }

mark { background: none; color: inherit; border-radius: 3px; padding: 0 1px; }
mark.sev-high { background: #5c1a1f; color: #ffdcd8; outline: 1px solid #8b2c33; }
mark.sev-medium { background: #4a3a12; color: #f0d9a8; outline: 1px solid #6b5518; }
mark.sev-low { background: #16324f; color: #b9d8ff; outline: 1px solid #24496f; }

/* ---------------------------------------------------------------- botones */
.btn, .mini {
  font: inherit;
  border-radius: 9px;
  cursor: pointer;
  padding: 9px 16px;
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--txt);
  font-size: 13.5px;
  font-weight: 550;
}
.btn:hover, .mini:hover { border-color: #33404f; text-decoration: none; }
.btn.primary { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.btn.primary:hover { background: #388bfd; }
.btn.ghost { background: transparent; color: var(--muted); }
.mini { padding: 4px 10px; font-size: 12px; font-weight: 500; }

input, select, textarea {
  font: inherit;
  color: var(--txt);
  background: #0b1017;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 11px;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(76,141,255,.15); }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin-top: 12px; }
.form-grid label, form label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); }

.searchbig { display: flex; gap: 10px; margin-bottom: 14px; }
.searchbig input { flex: 1; font-size: 16px; padding: 13px 16px; }

/* ---------------------------------------------------------------- log / consola */
.log, .console {
  background: #05080c;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  height: calc(100vh - 260px);
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
}
.console { height: calc(100vh - 340px); }
.console.small { height: 140px; margin: 0 0 16px; }

.row { display: flex; gap: 10px; padding: 3px 0; align-items: baseline; }
.row .t { color: #6e7681; flex: 0 0 auto; }
.row .who { color: var(--accent); flex: 0 0 auto; }
.row .app { color: var(--mid); flex: 0 0 auto; max-width: 30ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .k { color: var(--txt); white-space: pre-wrap; word-break: break-word; }

.res { border-bottom: 1px solid #10161f; padding: 9px 0; }
.res:last-child { border-bottom: 0; }
.reshead { margin-bottom: 4px; }
.res pre.out { margin: 6px 0 0; white-space: pre-wrap; word-break: break-word; color: #c9d1d9; }
.res img.shot { max-width: 100%; border: 1px solid var(--line); border-radius: 8px; margin-top: 8px; }
.note { color: #6e7681; padding: 4px 0; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.cmdrow { display: flex; gap: 8px; margin-top: 10px; }
.cmdrow input { flex: 1; }

/* ---------------------------------------------------------------- ataques */
.atkform {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}
.atkform label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.atkform input#a-target { width: 200px; }
.atkform input[type=number] { width: 92px; }
.atkform button {
  background: #b62324;
  border: 0;
  border-radius: 9px;
  color: #fff;
  font: inherit;
  font-weight: 600;
  padding: 9px 18px;
  cursor: pointer;
}
.atkform button:hover { background: #da3633; }

.prog { height: 4px; width: 92px; background: var(--line); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.prog i { display: block; height: 100%; background: var(--accent); transition: width .4s ease; }

/* ---------------------------------------------------------------- tabs */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 14px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.tab:hover { color: var(--txt); }
.tab.on { color: #fff; background: var(--accent2); border-color: var(--accent2); }
.tab b { font-weight: 600; opacity: .85; margin-left: 4px; }

.vsec h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; margin: 8px 0 10px; }

.uri {
  background: #0b1017;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 11.5px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------- flota */
.botgrid { display: grid; grid-template-columns: 240px 1fr; gap: 18px; }
.botside { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; align-self: start; }
.botside h3 { margin: 0 0 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.botside ul { list-style: none; margin: 0; padding: 0; }
.botside li { display: flex; justify-content: space-between; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.botside li:last-child { border-bottom: 0; }
.botmain { min-width: 0; }

/* ---------------------------------------------------------------- toasts */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast {
  background: var(--surface2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 11px 15px;
  font-size: 13px;
  max-width: 340px;
  box-shadow: 0 10px 30px rgba(0,0,0,.55);
  animation: slide .22s ease-out;
}
.toast.high { border-left-color: var(--bad); }
@keyframes slide { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------------------------------------------------------- login */
body.login {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 20% -10%, #12233a 0%, #080b10 55%);
  padding: 24px;
}
.login-wrap {
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  width: 100%;
  max-width: 880px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,.55);
}
.login-brand {
  padding: 44px 38px;
  background: linear-gradient(165deg, #0f1d2e, #0a111a);
  border-right: 1px solid var(--line);
}
.login-brand h1 { margin: 18px 0 4px; font-size: 27px; letter-spacing: -.4px; }
.login-brand p { margin: 0; color: var(--muted); font-size: 13.5px; }
.login-list { margin: 26px 0 0; padding: 0 0 0 16px; color: var(--muted); font-size: 13px; }
.login-list li { margin-bottom: 9px; }
.login-brand .logo-mark { width: 40px; height: 40px; font-size: 15px; border-radius: 12px; }

.card { padding: 40px 36px; display: flex; flex-direction: column; justify-content: center; }
.card h2 { margin: 0 0 6px; font-size: 19px; }
.card .sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.card label { display: block; margin-bottom: 14px; font-size: 12.5px; color: var(--muted); }
.card input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 11px 12px;
}
.card button {
  width: 100%;
  padding: 12px;
  margin-top: 6px;
  background: var(--accent2);
  border: 0;
  border-radius: 9px;
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.card button:hover { background: #388bfd; }
.err {
  color: #ffb3ae;
  background: #2d1214;
  border: 1px solid #5c1a1f;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  margin: 0 0 14px;
}

/* ---------------------------------------------------------------- chats */
.chatlog {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 300px);
  min-height: 220px;
  overflow-y: auto;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.chat-msg {
  max-width: min(78%, 720px);
  padding: 9px 12px;
  border-radius: 12px;
  background: #182436;
  border: 1px solid var(--line);
}
.chat-msg.chat-out {
  align-self: flex-end;
  background: #123a2a;
  border-color: #1d5c42;
}
.chat-meta {
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 3px;
}
.chat-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 13.5px;
  line-height: 1.45;
}

/* ---------------------------------------------------------------- medios */
.mediagrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  margin: 12px 0 20px;
}
.mediacard {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.mediacard a { display: block; }
.mediacard img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
  background: #0b0f16;
}
.mediacard figcaption {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px 10px;
}
.mediacard figcaption b {
  font-size: 12.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mediacard figcaption span {
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mediacard.pending { padding: 8px; }
.mediacard.pending .mediaph {
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mediaph {
  color: var(--muted);
  font-size: 12px;
  background: #0b0f16;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}
.audiolist {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0 20px;
}
.audiocard {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.audiocard .audiotitle {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 200px;
  flex: 1 1 200px;
}
.audiocard .audiotitle b {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.audiocard .audiotitle span {
  color: var(--muted);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.audiocard audio { flex: 2 1 300px; min-width: 220px; }
.audiocard.pending .mediaph { flex: 2 1 300px; }

/* ---------------------------------------------------------------- capturas */
.shotgrid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 20px;
}
.shotgrid a.shotcard {
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.shotgrid a.shotcard img {
  width: 110px;
  height: 185px;
  object-fit: cover;
  display: block;
  background: #0b0f16;
}
.minput {
  min-width: 260px;
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--fg);
  font-size: 13px;
}

/* ---------------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .side {
    width: 100%;
    flex: 0 0 auto;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    overflow-x: auto;
  }
  .side-brand span:last-child { display: none; }
  .side-nav { flex-direction: row; gap: 2px; }
  .side-item { padding: 8px 10px; }
  .side-item span { display: none; }
  .side-search { margin: 0; min-width: 150px; }
  .side-foot { display: none; }
  .main { padding: 18px 16px 50px; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .log, .console { height: calc(100vh - 220px); }
  .console.small { height: 140px; margin: 0 0 16px; }
  .botgrid { grid-template-columns: 1fr; }
}
