/* Estilos de la página. Colores, tamaños, radios y sombras salen de tokens.css (Design System «Admin IO»). */
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--app-bg); color: var(--text-body); font: 500 14px/1.4 var(--font-display); }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.ms { font-family: "Material Symbols Outlined"; font-weight: normal; font-style: normal; font-size: 20px; line-height: 1;
  display: inline-block; white-space: nowrap; font-feature-settings: "liga"; -webkit-font-smoothing: antialiased; }

/* Topbar */
.topbar { position: sticky; top: 0; z-index: 20; height: var(--topbar-h); display: flex; align-items: center; gap: 16px;
  padding: 0 var(--topbar-pad-x); background: var(--tb-bg); border-bottom: 1px solid var(--tb-border); }
.topbar-left { display: flex; align-items: center; gap: 9px; min-width: 0; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.crumb, .crumb-sep { font: 400 13px var(--font-body); color: var(--text-muted); }
.crumb-sep { font-family: "Material Symbols Outlined"; font-size: 18px; }
.page-icon { width: 36px; height: 36px; flex: none; border-radius: var(--radius-page-icon); background: var(--page-icon-bg);
  color: var(--page-icon-fg); display: flex; align-items: center; justify-content: center; }
.page-icon .ms { font-size: 21px; }
.page-title { font: 600 18px/1.2 var(--font-display); color: var(--tb-fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.round-btn { width: var(--topbar-btn); height: var(--topbar-btn); border-radius: 50%; border: 0; background: var(--iconbtn-bg);
  color: var(--iconbtn-fg); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.round-btn:hover { background: var(--iconbtn-hover); }

/* Contenido */
.content { padding: var(--content-pad); max-width: 100%; }
.title-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--title-gap); justify-content: space-between; }
.list-title { margin: 0; font: 600 26px/1.2 var(--font-display); color: var(--text-body); }
.subtitle { margin: 6px 0 0; font: 400 12px/1.4 var(--font-display); color: var(--text-muted); max-width: 760px; }
.note { margin: 4px 0 12px; font: 400 12.5px/1.4 var(--font-display); color: var(--text-note); }

/* Botones */
.btn { height: var(--button-h); display: inline-flex; align-items: center; gap: 4px; padding: 0 14px; border-radius: var(--radius-btn);
  font: 600 13px var(--font-display); cursor: pointer; white-space: nowrap; }
.btn .ms { font-size: 18px; }
.btn.ghost { height: 34px; background: var(--surface); border: 1px solid var(--input-border); color: var(--action-ghost-fg); }
.btn.primary { background: var(--action-primary); border: 0; color: #fff; }
.btn.primary:hover { background: var(--action-primary-hover); }
.icon-btn { width: 36px; height: 36px; flex: none; border: 0; border-radius: var(--radius-icon-btn); background: var(--iconbtn-bg);
  color: var(--iconbtn-fg); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-btn:hover { background: var(--iconbtn-hover); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Barra de filtros */
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--toolbar-gap-y) var(--toolbar-gap-x); margin: 20px 0 6px; }
.field { position: relative; display: flex; flex-direction: column; }
.field-label { position: absolute; top: -8px; left: 10px; padding: 0 4px; background: var(--surface);
  font: 400 12px var(--font-material); color: var(--text-muted); z-index: 1; }
.field input, .field select { height: var(--control-h); min-width: 150px; padding: 0 12px; border: 1px solid var(--input-border);
  border-radius: var(--radius-chip); background: var(--surface); color: var(--input-fg); font: 400 14px var(--font-material); }
.field select { padding-right: 28px; }
.field.search input { width: var(--search-w); max-width: calc(100vw - 2 * var(--content-pad)); padding-right: 38px; }
.field-icon { position: absolute; right: 10px; bottom: 12px; color: var(--text-muted); pointer-events: none; }
.field input:focus, .field select:focus { outline: none; border-color: var(--focus); }

/* Estado (carga, error, vacío) */
.state { margin-top: 24px; padding: 32px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-btn);
  display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; color: var(--text-body); }
.state > .ms { font-size: 32px; color: var(--text-muted); }
.progress { width: 220px; height: 6px; border-radius: var(--radius-pill); background: var(--progress-track); overflow: hidden; }
.progress::after { content: ""; display: block; width: 40%; height: 100%; background: var(--action-primary); animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@media (prefers-reduced-motion: reduce) { .progress::after { animation: none; } }

/* Secciones */
.section { margin-top: 28px; }
.section-head { margin: 0; font: 600 16px/1.2 var(--font-display); color: var(--text-body); }
.section-head .count { color: var(--text-muted); font-weight: 500; }

/* Tabla (DataTable) */
.table-wrap { overflow-x: auto; box-shadow: var(--shadow-table); }
.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th { position: sticky; top: 0; text-align: left; padding: 10px var(--cell-pad); background: var(--table-head-bg); color: var(--table-head-fg);
  font: 600 14px var(--font-display); border-bottom: 1px solid var(--table-head-border); white-space: nowrap; }
.table td { padding: var(--cell-pad); border-bottom: 1px solid var(--border); color: var(--text-table); font: 500 14px var(--font-display); vertical-align: middle; }
.table tbody tr:nth-child(odd) { background: var(--table-row-odd); }
.table tbody tr:nth-child(even) { background: var(--table-row-even); }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--table-row-hover); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.table .second { display: block; font: 400 12px var(--font-display); color: var(--text-muted); max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table .empty td { text-align: center; color: var(--text-muted); cursor: default; }

/* Chips de estado (StatusChip) */
.chip { display: inline-block; padding: 3px 10px; border-radius: var(--radius-chip); font: 700 12px/1.2 var(--font-display); white-space: nowrap; }
.chip.success { background: var(--chip-success-bg); color: var(--chip-success-fg); }
.chip.neutral { background: var(--chip-neutral-bg); color: var(--chip-neutral-fg); }
.chip.warning { background: var(--chip-warning-bg); color: var(--chip-warning-fg); }
.chip.danger { background: var(--chip-danger-bg); color: var(--chip-danger-fg); }
.chip.info { background: var(--chip-info-bg); color: var(--chip-info-fg); }

/* Prioridad: barra a la izquierda de la tarjeta y punto en tabla y leyenda. Tono por significado. */
.prio-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; background: var(--input-border); }
.p-highest { --prio: var(--chip-danger-fg); } .p-high { --prio: var(--chip-warning-fg); } .p-medium, .p-low, .p-lowest, .p-none { --prio: var(--input-border); }
.prio-dot { background: var(--prio); }

/* Leyenda */
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin: 0 0 14px; font: 400 12px var(--font-display); color: var(--text-muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend svg { overflow: visible; }

/* Cadenas */
.lanes { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.lane { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-btn); max-width: 100%; }
.lane-head { display: flex; align-items: baseline; gap: 10px; padding: 14px var(--panel-pad-x) 10px; border-bottom: 1px solid var(--border); }
.lane-title { margin: 0; font: 600 14px/1.3 var(--font-display); color: var(--text-body); }
.lane-meta { font: 400 12px var(--font-display); color: var(--text-muted); white-space: nowrap; }
.lane-scroll { overflow-x: auto; padding: 16px var(--panel-pad-x) 18px; }
.canvas { position: relative; }
.canvas svg { position: absolute; inset: 0; overflow: visible; pointer-events: none; }
.edge { fill: none; stroke: var(--text-muted); stroke-width: 1.4; opacity: .75; transition: opacity .15s; }
.edge.on { stroke: var(--action-primary); stroke-width: 2.2; opacity: 1; }
.edge.off { opacity: .12; }
.mk path { fill: var(--text-muted); } .mk-on path { fill: var(--action-primary); }

/* Tarjeta de ticket */
.card { position: absolute; width: 256px; height: 104px; display: flex; flex-direction: column; gap: 4px; padding: 9px 10px 9px 16px;
  background: var(--surface); border: 1px solid var(--input-border); border-radius: var(--radius-btn); cursor: pointer; overflow: hidden;
  transition: opacity .15s; }
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--prio); }
.card:hover { background: var(--table-row-hover); }
.card.ext { border-style: dashed; }
.card.sel { border-color: var(--focus); box-shadow: 0 0 0 2px var(--focus); }
.card.dim { opacity: .28; }
.card-top { display: flex; align-items: center; gap: 8px; }
.card-key { font: 700 13px var(--font-display); color: var(--action-ghost-fg); }
.card-flag { margin-left: auto; font: 600 11px var(--font-display); color: var(--text-muted); white-space: nowrap; display: inline-flex; align-items: center; gap: 2px; }
.card-flag .ms { font-size: 15px; }
.card-title { font: 500 12.5px/1.3 var(--font-display); color: var(--text-table); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; min-width: 0; }
.card-foot .chip { font-size: 11px; padding: 2px 8px; }
.card-meta { font: 400 11.5px var(--font-display); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Sin dependencias */
.prio-group { margin-top: 10px; }
.prio-group > summary { cursor: pointer; padding: 8px 0; font: 600 13px var(--font-display); color: var(--text-body); list-style: none; display: flex; align-items: center; gap: 6px; }
.prio-group > summary::before { content: "chevron_right"; font-family: "Material Symbols Outlined"; font-size: 20px; transition: transform .15s; }
.prio-group[open] > summary::before { transform: rotate(90deg); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(256px, 1fr)); gap: 12px; padding: 4px 0 8px; }
.grid .card { position: relative; width: auto; }

/* Panel de detalle */
.panel { position: fixed; top: var(--topbar-h); right: 0; bottom: 0; z-index: 30; width: 420px; max-width: 100vw; display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-dialog-soft); }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 20px 24px 12px; border-bottom: 1px solid var(--border); }
.panel-title { margin: 0; flex: 1; font: 600 16px/1.3 var(--font-display); color: var(--dialog-title); }
.panel-body { padding: 18px 24px 24px; overflow-y: auto; }
.panel-summary { margin: 0 0 14px; font: 500 14px/1.45 var(--font-display); color: var(--text-table); }
.panel-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.dl { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; margin: 0 0 18px; font-size: 13px; }
.dl dt { color: var(--text-muted); font-weight: 400; }
.dl dd { margin: 0; color: var(--text-table); }
.rel-title { margin: 16px 0 8px; font: 600 13px var(--font-display); color: var(--text-body); }
.rel { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rel button { width: 100%; text-align: left; display: flex; gap: 10px; align-items: baseline; padding: 8px 10px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-chip); cursor: pointer; font: 500 12.5px/1.35 var(--font-display); color: var(--text-table); }
.rel button:hover { background: var(--table-row-hover); }
.rel b { color: var(--action-ghost-fg); white-space: nowrap; }
.rel-none { font: 400 12.5px var(--font-display); color: var(--text-muted); margin: 0; }
.panel-actions { margin-top: 20px; }
.panel-actions a { text-decoration: none; }

@media (max-width: 720px) {
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .field, .field input, .field select, .field.search input { width: 100%; }
  .toolbar > * { flex: 1 1 100%; }
  .panel { width: 100vw; }
}
.swatch-ext { display: inline-block; width: 28px; height: 16px; border: 1px dashed var(--input-border); border-radius: var(--radius-chip); background: var(--surface); }

/* ===== Tablero de estado ===== */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-top: 20px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-btn); box-shadow: var(--shadow-table); overflow: hidden; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 0; border-right: 1px solid var(--border);
  background: transparent; text-align: left; cursor: pointer; color: var(--text-body); }
.stat:last-child { border-right: 0; }
.stat:hover { background: var(--table-row-hover); }
.stat[aria-pressed="true"] { box-shadow: inset 0 -3px 0 var(--action-primary); }
.stat-num { font: 600 26px/1.15 var(--font-display); font-variant-numeric: tabular-nums; }
.stat-label { font: 400 12px/1.3 var(--font-display); color: var(--text-muted); }
.stat.alert .stat-num { color: var(--chip-danger-fg); }
.stat.warn .stat-num { color: var(--chip-warning-fg); }
.stat.ok .stat-num { color: var(--chip-success-fg); }

/* Pestañas */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 8px 0 16px; overflow-x: auto; }
.tab { height: var(--button-h); padding: 0 16px; border: 0; background: transparent; cursor: pointer; white-space: nowrap;
  font: 600 13px var(--font-display); color: var(--text-muted); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tab[aria-selected="true"] { color: var(--action-ghost-fg); border-bottom-color: var(--action-primary); }

/* Barra de avance */
.bar { position: relative; display: flex; height: 8px; border-radius: var(--radius-pill); background: var(--progress-track); overflow: hidden; min-width: 120px; }
.bar span { display: block; height: 100%; }
.seg-done { background: var(--chip-success-fg); } .seg-deploy { background: var(--chip-warning-fg); } .seg-wip { background: var(--chip-info-fg); }
.bar-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 12px; font: 400 12px var(--font-display); color: var(--text-muted); }
.bar-legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 8px; border-radius: 2px; display: inline-block; }
.sw.todo { background: var(--progress-track); border: 1px solid var(--input-border); }

/* Grupos */
.group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-btn); margin-bottom: 12px; }
.group-head { width: 100%; display: grid; grid-template-columns: 24px minmax(220px, 1fr) minmax(220px, 340px) minmax(0, 1fr); gap: 14px; align-items: center;
  padding: 14px var(--panel-pad-x); border: 0; background: transparent; cursor: pointer; text-align: left; color: var(--text-body); }
.group-head:hover { background: var(--table-row-hover); }
.group-head .chev { transition: transform .15s; color: var(--text-muted); }
.group[open-state="1"] > .group-head .chev, .sub[open-state="1"] > .sub-head .chev { transform: rotate(90deg); }
.g-name { font: 600 16px/1.3 var(--font-display); }
.g-key { font: 400 12px var(--font-display); color: var(--text-muted); margin-left: 6px; }
.g-progress { display: flex; flex-direction: column; gap: 4px; }
.g-pct { font: 400 12px var(--font-display); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.g-signals { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.group-body { border-top: 1px solid var(--border); padding: 4px 0 8px; }
.sub { border-bottom: 1px solid var(--border); }
.sub:last-child { border-bottom: 0; }
.sub-head { width: 100%; display: grid; grid-template-columns: 24px minmax(204px, 1fr) minmax(220px, 340px) minmax(0, 1fr); gap: 14px; align-items: center;
  padding: 10px var(--panel-pad-x) 10px calc(var(--panel-pad-x) + 16px); border: 0; background: transparent; cursor: pointer; text-align: left; color: var(--text-body); }
.sub-head:hover { background: var(--table-row-hover); }
.s-name { font: 600 14px/1.3 var(--font-display); }
.s-count { font: 400 12px var(--font-display); color: var(--text-muted); margin-left: 6px; }
.sub-body, .group-tickets { padding: 0 var(--panel-pad-x) 12px calc(var(--panel-pad-x) + 16px); overflow-x: auto; }
.group-tickets { padding-top: 8px; }

/* Tabla de tickets dentro de un grupo */
.tickets { width: 100%; border-collapse: collapse; }
.tickets th { text-align: left; padding: 8px var(--cell-pad); background: var(--table-head-bg); color: var(--table-head-fg);
  font: 600 13px var(--font-display); border-bottom: 1px solid var(--table-head-border); white-space: nowrap; }
.tickets td { padding: 7px var(--cell-pad); border-bottom: 1px solid var(--border); font: 500 13px var(--font-display); color: var(--text-table); vertical-align: middle; }
.tickets tbody tr { cursor: pointer; }
.tickets tbody tr:nth-child(even) { background: var(--table-row-even); }
.tickets tbody tr:hover { background: var(--table-row-hover); }
.tickets .t-key { font-weight: 700; color: var(--action-ghost-fg); white-space: nowrap; }
.tickets .t-title { display: block; font: 400 12px var(--font-display); color: var(--text-muted); max-width: 560px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tickets .t-days { white-space: nowrap; font-variant-numeric: tabular-nums; }
.tickets .t-days.late { color: var(--chip-danger-fg); font-weight: 600; }
.tickets tr.more td { text-align: center; color: var(--action-ghost-fg); font-weight: 600; background: var(--surface); }
.sig { display: flex; flex-wrap: wrap; gap: 4px; }
.sig .chip { font-size: 11px; padding: 2px 8px; }

/* Personas */
.table tr.person-detail { cursor: default; }
.table tr.person-detail > td { background: var(--surface); padding: 6px var(--cell-pad) 14px; }
.table td.num.zero { color: var(--text-muted); font-weight: 400; }
.table td.num.alert { color: var(--chip-danger-fg); }

/* Historial en el panel */
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.timeline li { position: relative; font: 400 12.5px/1.35 var(--font-display); color: var(--text-table); }
.timeline li::before { content: ""; position: absolute; left: -20px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--input-border); }
.timeline li:last-child::before { border-color: var(--action-primary); background: var(--action-primary); }
.timeline time { display: block; color: var(--text-muted); font-size: 11.5px; }
.rel button .chip { margin-left: auto; font-size: 11px; padding: 2px 8px; }
.rel a { text-decoration: none; }

@media (max-width: 900px) {
  .group-head, .sub-head { grid-template-columns: 24px 1fr; }
  .g-progress, .g-signals { grid-column: 2; justify-content: flex-start; }
}
.timeline .via { color: var(--text-muted); }
.field select { max-width: 320px; }

/* Login */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-dialog-md);
  box-shadow: var(--shadow-dialog-soft); padding: 24px; }
.login-head { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; }
.login-head .note { margin: 2px 0 0; }
.login form { display: flex; flex-direction: column; gap: 14px; }
.login .field input { width: 100%; }
.login .btn { justify-content: center; }
.login .btn:disabled { opacity: .45; cursor: default; }
.login-error { margin: -4px 0 0; font: 400 12px var(--font-display); color: var(--danger); }
.topbar-sep { width: 1px; height: 30px; background: var(--tb-border); margin: 0 4px; }
