:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #1d2733;
  --muted: #6b7785;
  --line: #dde3ea;
  --brand: #1f5fbf;
  --brand-ink: #ffffff;
  --ok: #1e8e3e;
  --warn: #b26a00;
  --bad: #c5221f;
  --p1: #b3261e;
  --p2: #e8710a;
  --p3: #1f5fbf;
  --p4: #5f6b7a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0f141a;
    --panel: #18202a;
    --text: #e6ebf1;
    --muted: #93a0ae;
    --line: #2a3644;
    --brand: #6ea8fe;
    --brand-ink: #0f141a;
    --ok: #5bd17b;
    --warn: #f0b04a;
    --bad: #ff7b72;
  }
}
:root[data-theme='dark'] {
  --bg: #0f141a;
  --panel: #18202a;
  --text: #e6ebf1;
  --muted: #93a0ae;
  --line: #2a3644;
  --brand: #6ea8fe;
  --brand-ink: #0f141a;
  --ok: #5bd17b;
  --warn: #f0b04a;
  --bad: #ff7b72;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font:
    15px/1.45 system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    sans-serif;
  background: var(--bg);
  color: var(--text);
}
header {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 2;
}
header .brand {
  font-weight: 700;
  margin-right: auto;
}
header a {
  color: var(--brand);
  text-decoration: none;
  padding: 4px 6px;
  border-radius: 6px;
}
header a.active {
  background: var(--brand);
  color: var(--brand-ink);
}
main {
  padding: 16px;
  max-width: 1200px;
  margin: 0 auto;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}
.grid {
  display: grid;
  gap: 12px;
}
.stats {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.stat .n {
  font-size: 26px;
  font-weight: 700;
}
.stat .l {
  color: var(--muted);
  font-size: 13px;
}
.stat.bad .n {
  color: var(--bad);
}
.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}
@media (min-width: 900px) {
  .split {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  }
}
label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 10px 0 4px;
}
input,
select,
textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
}
textarea {
  min-height: 110px;
  resize: vertical;
}
.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.row > * {
  flex: 1 1 160px;
}
.row > .auto {
  flex: 0 0 auto;
}
button {
  font: inherit;
  border: 0;
  border-radius: 8px;
  padding: 9px 14px;
  background: var(--brand);
  color: var(--brand-ink);
  cursor: pointer;
  font-weight: 600;
}
button.ghost {
  background: transparent;
  color: var(--brand);
  border: 1px solid var(--line);
}
button.danger {
  background: var(--bad);
  color: #fff;
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}
.msg {
  padding: 10px 12px;
  border-radius: 8px;
  margin: 10px 0;
}
.msg.ok {
  background: rgba(30, 142, 62, 0.12);
  color: var(--ok);
}
.msg.err {
  background: rgba(197, 34, 31, 0.12);
  color: var(--bad);
}
.muted {
  color: var(--muted);
  font-size: 13px;
}
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--line);
  white-space: nowrap;
}
.p1 {
  color: var(--p1);
  border-color: var(--p1);
}
.p2 {
  color: var(--p2);
  border-color: var(--p2);
}
.p3 {
  color: var(--p3);
  border-color: var(--p3);
}
.p4 {
  color: var(--p4);
}
.breach {
  color: var(--bad);
  font-weight: 700;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 14px;
}
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
tr.click {
  cursor: pointer;
}
tr.click:hover td {
  background: rgba(127, 127, 127, 0.08);
}
tr.sel td {
  background: rgba(31, 95, 191, 0.08);
}
.comment {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 8px 0;
  background: var(--bg);
}
.comment.internal {
  border-style: dashed;
  border-color: var(--warn);
}
.comment .who {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.comment .body {
  white-space: pre-wrap;
}
.hide {
  display: none !important;
}
.tblwrap {
  overflow-x: auto;
}
.code {
  font-family: ui-monospace, Menlo, monospace;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  word-break: break-all;
}
h2 {
  margin: 4px 0 12px;
  font-size: 20px;
}
h3 {
  margin: 16px 0 8px;
  font-size: 16px;
}
.ev {
  font-size: 13px;
  color: var(--muted);
  padding: 4px 0;
  border-bottom: 1px dashed var(--line);
}

/* Utilidades: reemplazan estilos en línea (la CSP no permite style="") */
.mt-8 {
  margin-top: 8px;
}
.mt-10 {
  margin-top: 10px;
}
.mt-12 {
  margin-top: 12px;
}
.mt-14 {
  margin-top: 14px;
}
.my-8 {
  margin: 8px 0;
}
.narrow {
  margin: 0 auto;
}
.narrow-sm {
  max-width: 420px;
}
.narrow-md {
  max-width: 460px;
}
.narrow-lg {
  max-width: 720px;
}
.cb {
  width: auto;
  flex: 0 0 auto;
}

/* Adjuntos */
.atts {
  margin: 6px 0 10px;
  padding-left: 18px;
}
.atts li {
  margin: 4px 0;
}
button.link {
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.areas {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 6px;
}
.areas label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
}
.areas input[type='checkbox'] {
  width: auto;
  margin: 0;
  padding: 0;
  accent-color: #2f6fe0;
}
.agent-box label {
  display: block;
  margin: 10px 0 4px;
}
.agent-box input[type='email'] {
  margin-bottom: 8px;
}
details summary {
  cursor: pointer;
  list-style-position: outside;
}
details[open] {
  padding-bottom: 6px;
}

/* Indicadores de la consola */
.kpi {
  border-top: 4px solid #1d3752;
}
.kpi.ok {
  border-top-color: #2e7d32;
}
.kpi.warn {
  border-top-color: #e65100;
}
.kpi.bad {
  border-top-color: #c62828;
}
.ind-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 900px) {
  .ind-grid {
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  }
}
.ind-table td,
.ind-table th {
  text-align: right;
}
.ind-table td.izq,
.ind-table th:first-child {
  text-align: left;
}
.ind-table tr.total td {
  font-weight: 700;
  border-top: 2px solid var(--line);
}
.bars-row {
  display: grid;
  grid-template-columns: minmax(110px, 180px) minmax(0, 1fr) 44px;
  gap: 8px;
  align-items: center;
  margin: 6px 0;
}
.bars-row b {
  text-align: right;
}
.track {
  display: flex;
  height: 16px;
  background: #eef2f6;
  border-radius: 4px;
  overflow: hidden;
}
.track .seg {
  height: 100%;
  display: block;
}
.track .bar {
  height: 100%;
  display: block;
  background: #1565c0;
  border-radius: 4px;
}
.seg-new {
  background: #1565c0;
}
.seg-in_progress {
  background: #e65100;
}
.seg-pending {
  background: #8d6e63;
}
.seg-resolved {
  background: #2e7d32;
}
.seg-closed {
  background: #37474f;
}
.chip {
  color: #fff;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  display: inline-block;
  margin: 0 6px 6px 0;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}
.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: middle;
}

/* Logo AP en la cabecera (el SVG está diseñado para fondo oscuro) */
.logo-pill {
  display: inline-flex;
  align-items: center;
  background: #0b2545;
  border-radius: 8px;
  padding: 4px 10px;
  margin-right: 10px;
  vertical-align: middle;
}
.logo-pill img {
  display: block;
  height: 30px;
  width: auto;
}

/* Casos relacionados en el detalle */
.rel {
  border-top: 1px solid var(--line);
  padding: 8px 0;
}
.rel .sol {
  margin-top: 4px;
  white-space: pre-wrap;
}

th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
th .sa {
  font-size: 0.75em;
  opacity: 0.8;
}
