:root {
  --bg: #f4f5f7; --card: #fff; --text: #1d2330; --muted: #646b7a; --line: #dfe2e8;
  --primary: #1f5fae; --primary-ink: #fff; --ok: #1d7a46; --err: #b3261e;
  --radius: 10px; font-size: 16px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; line-height: 1.45; }
a { color: var(--primary); }
main { max-width: 1150px; margin: 0 auto; padding: 1rem; }
h1 { font-size: 1.45rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.2rem 0 .5rem; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .9rem; margin: .25rem 0; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.big { font-size: 1.15rem; }

/* cabecera */
.top { background: #17233a; color: #fff; display: flex; flex-wrap: wrap; align-items: center; gap: .3rem 1rem;
  padding: .6rem 1rem; }
.top a { color: #fff; text-decoration: none; }
.brand { font-weight: 700; font-size: 1.1rem; margin-right: auto; }
.top nav { display: flex; flex-wrap: wrap; gap: .2rem .9rem; order: 3; width: 100%; }
.top nav a { opacity: .9; padding: .2rem 0; }
.top nav a:hover { opacity: 1; text-decoration: underline; }
.who { display: flex; gap: .7rem; align-items: center; font-size: .9rem; }
.who form { margin: 0; }
@media (min-width: 900px) { .top nav { order: 0; width: auto; } }

/* tarjetas y formularios */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; margin-bottom: 1rem; }
.narrow { max-width: 460px; margin-left: auto; margin-right: auto; }
label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: .7rem; }
label.inline { display: inline-flex; align-items: center; gap: .35rem; font-weight: 400; margin: 0 1rem .5rem 0; }
p.label { font-weight: 600; font-size: .92rem; margin: .5rem 0 .2rem; }
input, select, textarea { display: block; width: 100%; margin-top: .25rem; padding: .6rem .65rem; font: inherit;
  font-weight: 400; border: 1px solid #c3c8d2; border-radius: 8px; background: #fff; color: inherit; }
input[type=checkbox], input[type=radio] { display: inline-block; width: 1.15rem; height: 1.15rem; margin: 0; }
input[type=file] { padding: .45rem; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 3px solid #8db4ea; outline-offset: 1px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem .4rem; margin: 0 0 .8rem; }
legend { font-weight: 700; padding: 0 .3rem; }
.grid { display: grid; grid-template-columns: 1fr; gap: 0 1rem; }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(2, 1fr); } .grid > .wide { grid-column: 1 / -1; } }
@media (min-width: 1000px) { .filters .grid { grid-template-columns: repeat(4, 1fr); } }
.checks, .radios { display: flex; flex-wrap: wrap; margin-bottom: .5rem; }

button, .button { display: inline-block; font: inherit; font-weight: 600; padding: .6rem 1rem; border-radius: 8px;
  border: 1px solid #b8bfcc; background: #fff; color: var(--text); cursor: pointer; text-decoration: none;
  min-height: 44px; line-height: 1.5; }
button.primary, .button.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
button.link { background: none; border: 0; color: #fff; padding: 0; min-height: 0; text-decoration: underline; font-weight: 400; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.head-row { display: flex; flex-wrap: wrap; gap: .5rem 1rem; justify-content: space-between; align-items: center; }
.head-row h1 { margin-bottom: .5rem; }
.inline-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; }
.inline-form label { margin: 0; }
.inline-form.row { padding: .4rem 0; border-bottom: 1px solid var(--line); align-items: center; }
.inline-form.row input[name=name] { flex: 1 1 220px; width: auto; margin: 0; }

.flash { padding: .7rem .9rem; border-radius: 8px; background: #e7f4ec; color: var(--ok); border: 1px solid #b9dfc8; }
.flash.error { background: #fbeaea; color: var(--err); border-color: #f0c2bf; }

/* chips de estado */
.chips { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 1rem; }
.chips a { display: inline-block; padding: .35rem .75rem; border-radius: 999px; background: #fff; border: 1px solid var(--line);
  text-decoration: none; color: var(--text); font-size: .9rem; }
.chips a.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.filters summary { cursor: pointer; font-weight: 600; }
.filters form { margin-top: .8rem; }

/* insignias */
.badge, .tag { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .82rem; font-weight: 600;
  white-space: nowrap; background: #eceef2; }
.tag { background: #e8e2f8; color: #4b2f91; }
.st-nueva { background: #e3edfb; color: #1f4f8f; }
.st-en_curso { background: #fff1d6; color: #7a4b00; }
.st-esperando { background: #f3e6fa; color: #6a2d86; }
.st-resuelta { background: #e2f3e8; color: #1d6a3e; }
.st-cerrada { background: #e9eaed; color: #4a505c; }
.pr-baja { background: #eef0f3; color: #4a505c; }
.pr-media { background: #e3edfb; color: #1f4f8f; }
.pr-alta { background: #fde7d4; color: #8a3b00; }
.pr-critica { background: #fadbd8; color: #9b1c14; }

/* tablas: en móvil cada fila es una tarjeta */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table.list th, table.list td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.list th { font-size: .85rem; color: var(--muted); background: #fafbfc; }
tr.inactive, .inactive { opacity: .6; }
@media (max-width: 699px) {
  table.list, table.list tbody, table.list tr, table.list td { display: block; width: 100%; }
  table.list thead { display: none; }
  table.list { border: 0; background: none; }
  table.list tr { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .6rem; padding: .3rem .2rem; }
  table.list td { border: 0; padding: .2rem .6rem; }
  table.list td::before { content: attr(data-l) ": "; color: var(--muted); font-size: .85rem; }
}
.pager { display: flex; gap: 1rem; align-items: center; justify-content: center; margin: 1rem 0; }

/* detalle */
dl.meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .6rem 1rem; margin: 0 0 1rem; }
dl.meta .wide { grid-column: 1 / -1; }
dt { font-size: .82rem; color: var(--muted); }
dd { margin: 0; }
.solution { background: #eef7f1; border-left: 4px solid var(--ok); padding: .6rem .8rem; border-radius: 6px; }
.comment { border-top: 1px solid var(--line); padding: .6rem 0; }
.comment.staff header strong { color: var(--primary); }
.files { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .8rem; }
.files li { max-width: 100%; }
.files img { display: block; max-width: 240px; max-height: 180px; border: 1px solid var(--line); border-radius: 6px; margin-bottom: .2rem; }
.history { list-style: none; padding: 0; margin: 0; font-size: .92rem; }
.history li { padding: .25rem 0; border-bottom: 1px dashed var(--line); }

/* estadísticas */
.stats-grid { display: grid; grid-template-columns: 1fr; gap: 0 1rem; }
@media (min-width: 900px) { .stats-grid { grid-template-columns: 1fr 1fr; } }
table.bars { width: 100%; border-collapse: collapse; }
table.bars th { text-align: left; font-weight: 400; padding: .2rem .5rem .2rem 0; width: 40%; font-size: .92rem; }
table.bars td { padding: .2rem 0; }
table.bars td.num { width: 3rem; text-align: right; font-variant-numeric: tabular-nums; }
progress { width: 100%; height: 14px; accent-color: var(--primary); }

/* fase 2 */
.m-probable { background: #fadbd8; color: #9b1c14; }
.m-posible { background: #fff1d6; color: #7a4b00; }
.m-reconexión { background: #e2f3e8; color: #1d6a3e; }
.m-contexto { background: #eceef2; color: #4a505c; }
code { font-family: ui-monospace, Consolas, monospace; background: #eef0f3; padding: .1rem .3rem; border-radius: 4px; }
code.token { display: block; padding: .6rem; overflow-wrap: anywhere; user-select: all; font-size: 1rem; }
.token-new { border-color: #e0b000; background: #fffbea; }
