/* TRB — paleta tomada de teseoconsulting.com.ar */
:root {
  --navy: #001f49;
  --navy-deep: #00122b;
  --purple: #5e17eb;
  --purple-soft: #efe7fd;
  --teal: #00b6a6;
  --teal-soft: #dcf6f3;
  --bg: #faf9f8;
  --surface: #ffffff;
  --column: #f1eff0;
  --ink: #1a1a1a;
  --muted: #6f6a6a;
  --line: #e2e2e3;
  --danger: #d13b3b;
  --warn: #e08a00;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 31, 73, .08), 0 2px 8px rgba(0, 31, 73, .06);
  --font: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 var(--font);
  display: flex;
  flex-direction: column;
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- Barra superior ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 20px;
  /* Mismo azul que el fondo del logo, para que la imagen se funda con la barra. */
  background: var(--navy);
  color: #fff;
  border-bottom: 3px solid var(--purple);
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; flex-shrink: 0; }
.brand-mark { width: 56px; height: 56px; margin: -6px 0; }
.brand-text { padding-left: 12px; border-left: 1px solid rgba(255, 255, 255, .2); }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 800; font-size: 20px; letter-spacing: .06em; }
.brand-sub { font-size: 10px; font-weight: 600; letter-spacing: .22em; text-transform: uppercase; color: var(--teal); }

.board-tabs { display: flex; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.board-tabs button {
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, .72);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 600;
}
.board-tabs button:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.board-tabs button[aria-current="true"] { background: rgba(94, 23, 235, .35); color: #fff; box-shadow: inset 0 -2px 0 var(--teal); }

.topbar-actions { display: flex; gap: 8px; align-items: center; }
.menu { position: relative; }
.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .18);
  padding: 6px;
  min-width: 240px;
  z-index: 20;
}
.menu-panel button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  padding: 9px 12px;
  border-radius: 6px;
  cursor: pointer;
}
.menu-panel button:hover { background: var(--purple-soft); }
.menu-panel hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; }

/* ---------- Botones ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 600;
  cursor: pointer;
  background: none;
  transition: background .15s, border-color .15s;
}
.btn-primary { background: var(--purple); color: #fff; }
.btn-primary:hover { background: #4c0fd0; }
.btn-secondary { background: var(--teal); color: #fff; }
.btn-secondary:hover { background: #009c8e; }
.btn-ghost { border-color: var(--line); background: var(--surface); }
.btn-ghost:hover { border-color: var(--purple); }
.btn-ghost-light { border-color: rgba(255, 255, 255, .25); color: #fff; }
.btn-ghost-light:hover { background: rgba(255, 255, 255, .1); }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover { background: #fdecec; }
.btn-link { color: var(--purple); padding: 4px 6px; }
.btn-link:hover { text-decoration: underline; }
.icon-btn { border: 0; background: none; cursor: pointer; font-size: 18px; line-height: 1; padding: 6px 10px; border-radius: 6px; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px 6px;
}
.board-title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.board-title h1 { margin: 0; font-size: 22px; color: var(--navy); font-weight: 800; }
.board-client {
  font-size: 12px;
  font-weight: 600;
  color: var(--teal);
  background: var(--teal-soft);
  padding: 2px 10px;
  border-radius: 999px;
}
.board-client:empty { display: none; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters input, .filters select {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 7px 10px;
}
.filters input[type="search"] { width: 220px; }
.filters input:focus, .filters select:focus { outline: 2px solid var(--purple); outline-offset: -1px; }
.toggle { display: flex; gap: 6px; align-items: center; color: var(--muted); cursor: pointer; }

/* ---------- Tablero ---------- */
main { flex: 1; min-height: 0; display: flex; }
.board {
  flex: 1;
  display: flex;
  gap: 14px;
  padding: 10px 20px 20px;
  overflow-x: auto;
  align-items: flex-start;
}
.column {
  background: var(--column);
  border-radius: 12px;
  width: 280px;
  flex: 0 0 280px;
  display: flex;
  flex-direction: column;
  max-height: 100%;
  border-top: 4px solid var(--navy);
}
.column:last-child { border-top-color: var(--teal); }
.column.over-wip { border-top-color: var(--danger); }
.column-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
  padding: 12px 12px 8px;
}
.column-head h2 { margin: 0; font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; line-height: 1.25; color: var(--navy); }
.wip { font-size: 30px; font-weight: 800; line-height: 1.1; color: var(--navy); font-variant-numeric: tabular-nums; }
.wip small { font-size: 15px; font-weight: 700; color: var(--muted); }
.over-wip .wip, .over-wip .wip small { color: var(--danger); }
.card-list {
  list-style: none;
  margin: 0;
  padding: 4px 8px 8px;
  overflow-y: auto;
  min-height: 40px;
  flex: 1;
}
.card-list.drag-over { background: rgba(94, 23, 235, .06); border-radius: 8px; }
.add-card {
  margin: 0 8px 10px;
  border: 1px dashed #cdc8cf;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  font-weight: 600;
}
.add-card:hover { border-color: var(--purple); color: var(--purple); background: #fff; }
.quick-add textarea {
  width: calc(100% - 16px);
  margin: 0 8px 6px;
  border: 1px solid var(--purple);
  border-radius: 8px;
  padding: 8px;
  resize: none;
}
.quick-add .actions { display: flex; gap: 6px; margin: 0 8px 10px; }

/* ---------- Tarjeta ---------- */
.card {
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 10px 12px 10px 14px;
  margin-bottom: 8px;
  cursor: grab;
  position: relative;
  border-left: 4px solid var(--type-color, var(--purple));
}
.card:hover { box-shadow: 0 0 0 2px rgba(94, 23, 235, .35), var(--shadow); }
.card.dragging { opacity: .4; }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.card-key { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .03em; }
.card-title { font-weight: 600; word-break: break-word; }
.card-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; align-items: center; }
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 999px;
  background: #f0eef2;
  color: #4a4550;
}
.badge.type { background: color-mix(in srgb, var(--type-color) 14%, white); color: var(--type-color); }
.badge.tag { background: var(--purple-soft); color: var(--purple); }
.badge.due.overdue { background: #fdecec; color: var(--danger); }
.badge.due.soon { background: #fff3dd; color: var(--warn); }
.prio { font-size: 11px; font-weight: 700; text-transform: uppercase; }
.prio-baja { color: #8f8989; }
.prio-normal { color: var(--navy); }
.prio-alta { color: var(--warn); }
.prio-urgente { color: #fff; background: var(--danger); padding: 0 6px; border-radius: 4px; }
.card-foot { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.avatar {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}


.card-ext { font-size: 11px; font-weight: 600; color: var(--purple); margin-left: 6px; }
.badge.check { background: #eef7f6; color: #007d72; }
.badge.check.complete { background: var(--teal); color: #fff; }
.muted { color: var(--muted); font-weight: 500; text-transform: none; letter-spacing: 0; }

/* Checklist y campos del tablero (modal) */
.checklist h3, .custom-fields h3, .classification h3, .dependencies h3 { margin: 0 0 8px; font-size: 13px; color: var(--navy); text-transform: uppercase; letter-spacing: .05em; }
.checklist ul { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.checklist li { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; }
.checklist li:hover { background: #f7f6f5; }
.checklist li input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--teal); padding: 0; }
.checklist li span { flex: 1; }
.checklist li.done span { text-decoration: line-through; color: var(--muted); }
.checklist li .icon-btn { font-size: 13px; color: var(--muted); visibility: hidden; }
.checklist li:hover .icon-btn { visibility: visible; }
.checklist-new input { width: 100%; }
.fields-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.fields-grid .wide { grid-column: 1 / -1; }
.fields-grid .field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.fields-grid textarea { resize: vertical; min-height: 38px; }
.type-color { width: 42px; height: 36px; padding: 2px !important; cursor: pointer; }

/* ---------- Archivados ---------- */
.archive { flex: 1; padding: 10px 20px 20px; overflow: auto; }
.archive table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.archive th, .archive td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.archive th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: #f6f5f4; }
.archive tr:hover td { background: #fbf9ff; cursor: pointer; }

/* ---------- Vacío ---------- */
.empty { margin: auto; text-align: center; max-width: 420px; padding: 40px 20px; }
.empty h2 { color: var(--navy); margin: 16px 0 6px; }
.empty p { color: var(--muted); margin: 0 0 20px; }

/* ---------- Diálogos ---------- */
.dialog {
  border: 0;
  border-radius: 14px;
  padding: 0;
  width: min(560px, calc(100vw - 32px));
  box-shadow: 0 20px 60px rgba(0, 18, 43, .35);
}
.dialog-wide { width: min(920px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(0, 18, 43, .55); backdrop-filter: blur(2px); }
.dialog-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, var(--purple-soft), #fff 60%);
}
.dialog-head h2 { margin: 0; font-size: 18px; color: var(--navy); flex: 1; }
.dialog-head .close { margin-left: auto; color: var(--muted); }
.title-input { flex: 1; border: 1px solid transparent; border-radius: 6px; padding: 6px 8px; font-size: 18px; font-weight: 700; color: var(--navy); background: transparent; }
.title-input:hover, .title-input:focus { border-color: var(--line); background: #fff; outline: none; }
.dialog-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; max-height: 70vh; overflow-y: auto; }
.two-col { flex-direction: row; gap: 24px; }
.col-main { flex: 1; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.col-side { width: 250px; display: flex; flex-direction: column; gap: 12px; }
.dialog label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.dialog input, .dialog select, .dialog textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  background: #fff;
}
.dialog textarea { resize: vertical; }
.dialog label small { font-weight: 500; }
.dialog input:focus, .dialog select:focus, .dialog textarea:focus { outline: 2px solid var(--purple); outline-offset: -1px; }
.dialog .title-input { font-size: 18px; font-weight: 700; color: var(--navy); }
.row { display: flex; gap: 12px; }
.row label { flex: 1; }
.row .narrow { flex: 0 0 110px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin: 0; }
legend { font-size: 12px; font-weight: 700; color: var(--navy); padding: 0 4px; }
legend small { font-weight: 500; color: var(--muted); }
.column-editor { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.column-editor li { display: flex; gap: 6px; align-items: center; }
.column-editor input[name="colName"] { flex: 1; }
.column-editor input[name="colWip"] { width: 70px; }
.column-editor .icon-btn { font-size: 14px; color: var(--muted); }
.column-editor .icon-btn:hover { color: var(--ink); background: var(--column); }
.dialog-foot { display: flex; justify-content: space-between; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: #fcfbfb; }
.dialog-foot .left, .dialog-foot .right { display: flex; gap: 8px; }
.meta { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

.comments h3 { margin: 0 0 8px; font-size: 13px; color: var(--navy); text-transform: uppercase; letter-spacing: .05em; }
.comments ul { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.comments li { background: #f7f6f5; border-radius: 8px; padding: 8px 10px; }
.comments li .who { font-size: 12px; font-weight: 700; color: var(--navy); }
.comments li .when { font-size: 11px; color: var(--muted); margin-left: 6px; }
.comments li p { margin: 4px 0 0; white-space: pre-wrap; word-break: break-word; }
.comment-new { display: flex; gap: 8px; align-items: flex-end; }
.comment-new textarea { flex: 1; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translate(-50%, 20px);
  background: var(--navy);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  border-left: 4px solid var(--teal);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-left-color: var(--danger); }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .brand-sub { display: none; }
  .board-tabs { order: 3; flex-basis: 100%; }
  .toolbar { padding: 12px 16px 4px; }
  .filters input[type="search"] { width: 100%; }
  .board { padding: 10px 16px 16px; }
  .two-col { flex-direction: column; }
  .col-side { width: auto; }
  .fields-grid { grid-template-columns: 1fr; }
}

/* ---------- Selectores de campos con lista ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; border: 1px solid var(--line); border-radius: 8px; background: #fff; min-height: 40px; }
.chip {
  border: 1px solid var(--line);
  background: #f7f6f5;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
}
.chip:hover { border-color: var(--purple); }
.chip[aria-pressed="true"] { background: var(--purple); border-color: var(--purple); color: #fff; }
.chips-empty { font-size: 12px; color: var(--muted); font-weight: 500; padding: 4px; }
.badge.module { background: #e8eef8; color: var(--navy); }

/* ---------- Administración ---------- */
.admin-login { display: flex; flex-direction: column; gap: 12px; max-width: 360px; }

/* Selector de consultores: elegidos + combo para agregar */
.picker { display: flex; flex-direction: column; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.picked { display: flex; flex-wrap: wrap; gap: 6px; }
.picked:empty::before { content: attr(data-empty); font-size: 12px; font-weight: 500; color: var(--muted); }
.picked .chip { display: inline-flex; align-items: center; gap: 6px; background: var(--purple); border-color: var(--purple); color: #fff; cursor: default; }
.picked .chip button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0 2px; font-size: 12px; opacity: .8; }
.picked .chip button:hover { opacity: 1; }
.picker select { max-width: 320px; }

/* Progreso: color del rojo (0 %) al verde (100 %) */
.progress-row { display: flex; align-items: center; gap: 10px; }
.progress-row input[type="range"] {
  flex: 1;
  padding: 0 !important;
  border: 0 !important;
  height: 8px;
  border-radius: 999px;
  appearance: none;
  -webkit-appearance: none;
  background: linear-gradient(90deg, var(--progress-color) var(--progress), #e7e4e6 var(--progress));
  cursor: pointer;
}
.progress-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 3px solid var(--progress-color);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}
.progress-row input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 3px solid var(--progress-color);
}
.progress-row output { min-width: 42px; text-align: right; font-weight: 700; color: var(--progress-color); font-size: 13px; }
.card-progress { height: 5px; border-radius: 999px; background: #eceaeb; margin-top: 8px; overflow: hidden; }
.card-progress span { display: block; height: 100%; border-radius: 999px; }

/* Dependencias */
.picked.deps .chip { background: var(--navy); border-color: var(--navy); }

.dep-link { color: inherit; text-decoration: underline; cursor: pointer; background: none; border: 0; padding: 0; font: inherit; }
.picker input[list] { max-width: 420px; }
.badge.dep { background: #e8eef8; color: var(--navy); }

/* Clasificación, dependencias y listas bloqueadas */
.classification, .dependencies { display: flex; flex-direction: column; gap: 10px; }
.classification h3, .dependencies h3 { margin-bottom: 0; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.badge.difficulty { background: color-mix(in srgb, var(--dif-color) 14%, white); color: var(--dif-color); }
.option-list.locked .column-editor input,
.option-list.locked .column-editor button { pointer-events: none; opacity: .55; }
.option-list.locked .add-option { display: none; }
.option-list:not(.locked) .lock-note { display: none; }
.lock-note { margin: 6px 0 0; }
.admin-unlock { padding: 0 4px; font-size: 12px; }

/* ---------- Administradores ---------- */
.admin-panel { display: flex; flex-direction: column; gap: 14px; }
.admin-who { margin: 0; color: var(--muted); }
.admin-who strong { color: var(--navy); }
.admin-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin-bottom: 10px; }
.admin-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.admin-table th, .admin-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.admin-table th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.admin-table .actions { white-space: nowrap; text-align: right; }
.badge.root { background: var(--navy); color: #fff; }
.badge.me { background: var(--teal-soft); color: #007d72; }
.audit-list { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; font-size: 13px; }
.audit-list li { padding: 5px 0; border-bottom: 1px solid var(--line); }
.audit-list time { color: var(--muted); font-size: 12px; margin-right: 6px; }
@media (max-width: 720px) { .admin-form { grid-template-columns: 1fr; } }

/* ---------- Sesión y permisos ---------- */
.login-screen {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 16px;
  background: var(--navy);
  grid-template-rows: auto auto;
  align-content: center;
  gap: 8px;
}
body:not(.logged-out) .login-screen { display: none; }
body.logged-out .topbar-actions, body.logged-out .board-tabs, body.logged-out #toolbar, body.logged-out main { visibility: hidden; }
.login-card {
  width: min(360px, 100%); background: #fff; border-radius: 16px; padding: 28px 28px 24px;
  display: flex; flex-direction: column; gap: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
  border-top: 4px solid var(--purple);
}
.login-logo { width: min(240px, 60vw, 32vh); height: auto; justify-self: center; }
.empty-logo { width: 140px; height: 140px; border-radius: 20px; }
.login-card h1 { margin: 0; text-align: center; color: var(--navy); font-size: 26px; letter-spacing: .08em; }
.login-sub { margin: -8px 0 8px; text-align: center; color: var(--teal); font-size: 11px; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.login-card input { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.login-card input:focus { outline: 2px solid var(--purple); outline-offset: -1px; }
.login-version { margin: 4px 0 0; text-align: center; color: var(--muted); font-size: 11px; }
.login-error { margin: 0; min-height: 18px; color: var(--danger); font-size: 13px; }
.user-badge { color: rgba(255, 255, 255, .85); font-size: 12px; font-weight: 600; text-align: right; line-height: 1.2; }
.user-badge small { display: block; color: var(--teal); font-weight: 700; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }

/* Lo que cada rol no puede hacer se oculta (el servidor igual lo valida). */
body:not(.role-admin) .admin-only { display: none !important; }
body.role-admin .not-admin { display: none; }
body.role-viewer .can-edit, body.role-viewer .add-card { display: none !important; }
.read-only-note { display: none; align-self: center; }
body.role-viewer .read-only-note { display: inline; }
.role-help { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0; }
.role-help div { background: #f7f6f5; border-radius: 8px; padding: 10px 12px; }
.role-help dt { font-weight: 700; color: var(--navy); font-size: 13px; }
.role-help dd { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.badge.role-admin { background: var(--purple-soft); color: var(--purple); }
.badge.role-manager { background: var(--teal-soft); color: #007d72; }
.badge.role-viewer { background: #f0eef2; color: #4a4550; }
@media (max-width: 720px) { .role-help { grid-template-columns: 1fr; } .user-badge { display: none; } }
body.role-viewer .picker select, body.role-viewer .picker input[list],
body.role-viewer .picked .chip button, body.role-viewer .checklist li .icon-btn { display: none; }

/* Mail y contraseñas temporales */
.temp-notice { margin-top: 12px; padding: 12px 14px; border-radius: 8px; background: #fff3dd; border: 1px solid #f1d39b; }
.temp-notice p { margin: 0 0 8px; }
.temp-pass { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.temp-pass code { font: 600 16px/1.2 Menlo, Consolas, monospace; letter-spacing: .04em; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; user-select: all; }
.mail-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.mail-actions input { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 220px; }
.toggle.inline { flex-direction: row !important; align-items: center; gap: 6px !important; margin-top: 8px; }
.password-notice { margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--purple-soft); color: var(--navy); font-weight: 600; }
.badge.pending { background: #fff3dd; color: var(--warn); }
.badge.warn { background: #fdecec; color: var(--danger); }
#passwordDialog.forced [data-dismiss] { display: none; }
#passwordDialog:not(.forced) .forced-only { display: none; }
.admin-table .badge { white-space: nowrap; display: inline-block; margin: 0 4px 2px 0; }

/* Consultor y avisos por mail */
body.role-consultant .add-card { display: none !important; }
.consultant-only { display: none; }
body.role-consultant .consultant-only { display: block; }
body.role-consultant .not-consultant { display: none; }
.role-help { grid-template-columns: repeat(2, 1fr); }
.badge.role-consultant { background: #e8eef8; color: var(--navy); }
.done-toggle { display: flex !important; flex-direction: row !important; align-items: center; gap: 4px !important; font-size: 12px; white-space: nowrap; }
.done-toggle input { width: 16px; height: 16px; accent-color: var(--teal); }
.opt-email { flex: 1; min-width: 160px; }
.column-editor li { flex-wrap: wrap; }

/* ---------- Reportes ---------- */
.reports-btn { padding: 5px 12px; font-size: 13px; }
.dialog-reports { width: min(1120px, calc(100vw - 32px)); }
.dialog-reports .dialog-body { max-height: 76vh; }
.dialog-reports .dialog-head select { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: #fff; }
.reports-body { gap: 18px; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat-tile { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.stat-tile .stat-value { font-size: 30px; font-weight: 800; color: var(--navy); line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-tile .stat-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.stat-tile .stat-sub { font-size: 11px; color: var(--muted); }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 14px; }
.chart { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; min-width: 0; }
.chart h3 { margin: 0; font-size: 14px; color: var(--navy); }
.chart .chart-sub { margin: 2px 0 10px; font-size: 12px; color: var(--muted); }
.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 38%) 1fr 64px; align-items: center; gap: 8px; padding: 3px 4px; border-radius: 6px; cursor: default; }
.bar-row:hover, .bar-row:focus-visible { background: #f7f6f5; outline: none; }
.bar-label { font-size: 12px; line-height: 1.25; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.bar-track { height: 14px; border-left: 1px solid var(--line); }
.bar { display: block; height: 14px; border-radius: 0 4px 4px 0; background: var(--purple); min-width: 2px; }
.bar.muted { background: #c9c5c8; }
.bar-value { font-size: 12px; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; text-align: right; }
.bar-value small { font-weight: 500; color: var(--muted); }
.chart-empty { font-size: 12px; color: var(--muted); }
.chart-tip { position: fixed; z-index: 200; pointer-events: none; background: var(--navy); color: #fff; font-size: 12px; padding: 6px 10px; border-radius: 6px; box-shadow: 0 4px 14px rgba(0, 0, 0, .2); max-width: 280px; }
.report-list h3 { margin: 0 0 8px; font-size: 14px; color: var(--navy); }
.report-list tr.clickable { cursor: pointer; }
.report-list tr.clickable:hover td { background: #fbf9ff; }
@media (max-width: 720px) { .charts { grid-template-columns: 1fr; } }
/* Solo Administrador y Gestión de tickets */
body.role-viewer .manager-only, body.role-consultant .manager-only { display: none !important; }
.bar-row.clickable { cursor: pointer; } .bar-row.clickable:hover .bar-label { text-decoration: underline; }

/* ---------- Etapas contraíbles ---------- */
.small-btn { padding: 5px 10px; font-size: 13px; }
.collapse-controls { display: inline-flex; gap: 6px; }
.column { position: relative; transition: width .15s, flex-basis .15s; }
.column-collapse {
  position: absolute; top: 6px; right: 6px;
  border: 0; background: transparent; color: var(--muted);
  width: 26px; height: 26px; border-radius: 6px; cursor: pointer; font-size: 16px; line-height: 1;
}
.column-collapse:hover, .column-collapse:focus-visible { background: #fff; color: var(--navy); outline: none; }
.column-head h2 { padding: 0 22px; }
.column.collapsed { width: 56px; flex: 0 0 56px; align-self: stretch; max-height: 100%; }
.column-expand {
  border: 0; background: transparent; cursor: pointer; width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 10px 0 14px;
  color: var(--navy); border-radius: 0 0 12px 12px;
}
.column-expand:hover, .column-expand:focus-visible { background: rgba(94, 23, 235, .06); outline: none; }
.column.collapsed .wip { font-size: 22px; display: flex; flex-direction: column; align-items: center; }
.column.collapsed .wip small { font-size: 11px; }
.collapsed-name {
  writing-mode: vertical-rl; transform: rotate(180deg);
  font-size: 13px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap;
  max-height: 60vh; overflow: hidden; text-overflow: ellipsis;
}
.column.collapsed.drag-over { background: rgba(94, 23, 235, .12); }

/* ---------- Historial de cambios ---------- */
.history h3 { margin: 0 0 8px; font-size: 13px; color: var(--navy); text-transform: uppercase; letter-spacing: .05em; }
.history-list { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.history-list > li { position: relative; font-size: 13px; }
.history-list > li::before { content: ''; position: absolute; left: -20px; top: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--purple); border: 2px solid #fff; }
.history-list > li.meta::before { display: none; }
.history-head time { color: var(--muted); font-size: 12px; margin-right: 6px; font-variant-numeric: tabular-nums; }
.history-head strong { color: var(--navy); }
.history-changes { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.history-changes li { font-size: 12px; color: var(--ink); word-break: break-word; }
.history-field { color: var(--muted); font-weight: 600; }
.history-changes del { color: #a14545; text-decoration: line-through; text-decoration-color: rgba(161, 69, 69, .5); }
.history-changes ins { color: #0f6b3c; text-decoration: none; font-weight: 600; }
#archiveCardBtn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.history-changes em { color: var(--muted); }

/* ---------- Campos obligatorios y etiquetas ---------- */
[data-req].required > .field-label::after { content: ' *'; color: var(--danger); font-weight: 800; }
[data-req].missing .picker, [data-req].missing .chips, label[data-req].missing input { outline: 2px solid var(--danger); outline-offset: 1px; border-radius: 8px; }
label[data-req].missing .progress-row { outline: 2px solid var(--danger); outline-offset: 4px; border-radius: 8px; }
.card-notice { margin: 0; padding: 10px 20px; background: #fdecec; color: #8a1f1f; font-weight: 600; font-size: 13px; border-bottom: 1px solid #f3c2c2; }
.tag-suggest { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.tag-suggest:empty { display: none; }
.tag-suggest button { border: 1px dashed var(--purple); background: var(--purple-soft); color: var(--purple); border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; cursor: pointer; }
.tag-suggest button:hover { background: var(--purple); color: #fff; }
.picked .chip.tag-chip { background: var(--purple-soft); border-color: var(--purple-soft); color: var(--purple); }
.picker input[list] { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
body.role-viewer .tag-suggest, body.role-viewer #tagInput { display: none; }

/* ---------- Panel de control ---------- */
#controlDialog .dialog-head select { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: #fff; }
.rules-table th.center, .rules-table td.center { text-align: center; }
.rules-table th { white-space: normal; vertical-align: bottom; }
.rules-table td.rule-name { font-weight: 600; color: var(--navy); }
.rules-table input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--purple); }
.rules-table .rule-wip { width: 64px; border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; text-align: center; }
.rule-all { display: block; margin: 2px auto 0; padding: 0; font-size: 11px; font-weight: 600; text-transform: none; letter-spacing: 0; }
.card-notice.info { background: #e8f6f4; color: #0b5e56; border-bottom-color: #bfe6e1; }
#columnEditor input[name="colName"] { width: 100%; min-width: 200px; }
.rules-table .nowrap { white-space: nowrap; }
.rules-table .icon-btn { font-size: 14px; color: var(--muted); padding: 4px 6px; }
.rules-help { margin-top: 10px; grid-template-columns: repeat(2, 1fr); }

/* Especialidades y sugerencia de consultor */
.spec-chips { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 2px 0 6px; }
.spec-chips .spec-label { font-size: 11px; font-weight: 700; color: var(--muted); margin-right: 2px; }
.spec-chips .chip { font-size: 11px; padding: 1px 8px; }
.consultant-suggest { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.consultant-suggest:empty { display: none; }
.consultant-suggest button { border: 1px dashed var(--teal); background: var(--teal-soft); color: #075e56; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 700; cursor: pointer; }
.consultant-suggest button small { font-weight: 500; color: #3c7d77; }
.consultant-suggest button:hover { background: var(--teal); color: #fff; }
.consultant-suggest button:hover small { color: #e9fffc; }

/* ---------- Observaciones (bitácora) ---------- */
.notes { border: 1px solid var(--line); border-radius: 10px; background: #fcfbfb; }
.notes > summary { cursor: pointer; padding: 10px 12px; list-style: none; display: flex; gap: 6px; align-items: baseline; }
.notes > summary::-webkit-details-marker { display: none; }
.notes > summary::before { content: '▸'; color: var(--purple); font-weight: 800; transition: transform .15s; }
.notes[open] > summary::before { transform: rotate(90deg); }
.notes-title { font-size: 13px; font-weight: 800; color: var(--navy); text-transform: uppercase; letter-spacing: .05em; }
.notes .note-new { display: flex; gap: 8px; align-items: flex-end; padding: 0 12px 10px; }
.notes .note-new textarea { flex: 1; }
.notes-list { list-style: none; margin: 0; padding: 0 12px 12px; display: flex; flex-direction: column; gap: 8px; max-height: 360px; overflow-y: auto; }
.notes-list li { background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--teal); border-radius: 8px; padding: 8px 10px; }
.note-head { display: flex; gap: 8px; align-items: baseline; font-size: 12px; }
.note-head time { color: var(--navy); font-weight: 700; font-variant-numeric: tabular-nums; }
.note-head strong { color: var(--muted); font-weight: 600; }
.notes-list p { margin: 4px 0 0; white-space: pre-wrap; word-break: break-word; font-size: 13px; }
.readonly-input { background: #f4f3f2 !important; color: var(--navy) !important; font-weight: 700 !important; cursor: default; }
.title-input.missing { outline: 2px solid var(--danger); }
.card-key + .card-ext { margin-left: 6px; }

/* ---------- Aging ---------- */
.aging { display: flex; flex-direction: column; gap: 12px; padding-top: 6px; border-top: 1px solid var(--line); }
.section-title { margin: 6px 0 0; font-size: 18px; color: var(--navy); }
.aging > .meta { margin: -6px 0 0; }
.aging-tables { display: grid; grid-template-columns: 1fr; gap: 14px; }
.aging-days { font-weight: 700; color: var(--navy); white-space: nowrap; font-variant-numeric: tabular-nums; }
.aging-days.old { color: var(--danger); }
.abap-hint { color: var(--danger); font-weight: 600; font-size: 11px; }

/* Configurar tablero: ventana ancha para ver los nombres completos de los estados y todas las reglas */
#boardDialog.dialog-wide { width: min(1500px, calc(100vw - 32px)); }
#boardDialog .dialog-body { max-height: 80vh; }
#columnEditor input[name="colName"] { min-width: 340px; }
.rules-table th { font-size: 10px; line-height: 1.25; padding: 6px 4px; }
.rules-table td { padding: 5px 4px; }
.rules-table th.center:not(:first-child) { min-width: 82px; max-width: 110px; }

/* Orden de las tarjetas */
.sort-rules { list-style: none; margin: 6px 0 8px 24px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.sort-rules li { display: flex; gap: 8px; align-items: center; }
.sort-rules select { min-width: 220px; }
.sort-rules.disabled { opacity: .5; }
.sort-level { font-weight: 800; color: var(--navy); width: 22px; }
.sort-config .toggle.inline { font-size: 13px; font-weight: 600; color: var(--ink); }
