:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #222831;
  --muted: #687385;
  --line: #d9dee7;
  --primary: #0f766e;
  --accent: #b45309;
  --danger: #b42318;
  --shadow: rgba(20, 31, 43, .08);
  --column: #eef1f5;
  --taskbar: #26313d;
  --input-bg: #ffffff;
}

:root[data-theme="dark"] {
  --bg: #101418;
  --panel: #171d23;
  --text: #e7edf3;
  --muted: #9ba8b7;
  --line: #2a3440;
  --primary: #14b8a6;
  --accent: #f59e0b;
  --danger: #f87171;
  --shadow: rgba(0, 0, 0, .35);
  --column: #151b22;
  --taskbar: #0b1117;
  --input-bg: #10161c;
}

* { box-sizing: border-box; }
html, body, #app {
  height: 100%;
  overflow: hidden;
}
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
}

button, input, select, textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  padding: 9px 12px;
  background: var(--primary);
  color: white;
  cursor: pointer;
}

button.secondary { background: #46515f; }
button.danger { background: #b42318; }
button:disabled {
  cursor: not-allowed;
  opacity: .45;
}
button.link-button {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--primary);
  text-align: left;
  text-decoration: underline;
}
.hidden { display: none !important; }
.error { color: var(--danger); min-height: 20px; margin: 0; }

/* Sin texto de error, el parrafo no debe reservar alto: asi la grilla
   llega hasta el fondo de la ventana y no queda espacio muerto debajo. */
.error:empty { display: none; min-height: 0; }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 12px 30px var(--shadow);
}

label {
  display: grid;
  gap: 5px;
  margin: 9px 0;
  color: var(--muted);
  font-size: 14px;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: var(--input-bg);
  color: var(--text);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 28%, transparent);
}

textarea {
  resize: vertical;
}

.board-shell {
  height: 100%;
  min-height: 0;
  /* Flexbox column en vez de grid posicional: cuando el banner readonly esta
     oculto (display:none) NO ocupa celda, y con grid-template-rows posicional
     eso corria el desktop a una fila 'auto' y la taskbar a la fila '1fr',
     dejando la barra flotando a media altura. Con flex + flex:1 en .desktop,
     el escritorio siempre toma el espacio sobrante sin importar los ocultos. */
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.readonly-banner {
  flex: 0 0 auto;
  padding: 8px 14px;
  background: color-mix(in srgb, var(--accent) 18%, var(--panel));
  color: var(--accent);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
}

.topbar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(320px, 1fr);
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.topbar h1 { margin: 0; font-size: 22px; }
.topbar p { margin: 2px 0 0; color: var(--muted); }
.brand-area {
  min-width: 0;
}
.actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.toggle { display: flex; align-items: center; gap: 7px; margin: 0; color: var(--text); }
.toggle input { width: auto; }
.tag-filter-input {
  width: 130px;
  padding: 8px 10px;
}
.global-search-input {
  width: 190px;
  padding: 8px 10px;
}
.trash-drop {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  background: #46515f;
}
.trash-drop::before {
  content: "\1F5D1";
  font-size: 15px;
  line-height: 1;
}
.trash-drop.dragover {
  background: var(--danger);
  outline: 2px solid color-mix(in srgb, var(--danger) 40%, white);
  outline-offset: 2px;
}

.ticket-indicator {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.ticket-indicator:hover {
  filter: brightness(.95);
}

.confidentiality-badge {
  display: inline-flex;
  align-items: center;
  width: max-content;
  padding: 2px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--danger) 16%, var(--panel));
  color: var(--danger);
  font-size: 11px;
  font-weight: 700;
  vertical-align: middle;
}

.notification-window {
  display: grid;
  gap: 12px;
  height: 100%;
  min-height: 0;
  padding: 14px;
}

.notification-table {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
}

.notification-row {
  display: grid;
  grid-template-columns: 160px 90px 70px minmax(260px, 1fr);
  gap: 10px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.notification-unread {
  border-left: 4px solid var(--primary);
  font-weight: 700;
}

.pagination-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  flex-wrap: wrap;
}

.pagination-controls button {
  padding: 7px 10px;
}

.message-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(9, 14, 20, .52);
}

.message-box {
  width: min(430px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 22px 54px rgba(0, 0, 0, .34);
}

.message-box h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.message-box p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.message-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.desktop {
  position: relative;
  overflow: hidden;
  min-height: 0;
  flex: 1 1 auto;
}

.board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(260px, 1fr);
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 16px;
  height: 100%;
  min-height: 0;
  align-items: stretch;
}

.column {
  height: 100%;
  min-height: 0;
  background: var(--column);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-rows: auto 1fr;
}

.column header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.column h2 { margin: 0; font-size: 15px; }
.count { color: var(--muted); font-size: 13px; }
.task-list {
  padding: 10px;
  min-height: 0;
  overflow-y: auto;
}

.task {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
  cursor: grab;
}

.task h3 {
  margin: 0 0 8px;
  font-size: 15px;
  line-height: 1.25;
}

.task p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.assignee-link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border-bottom: 1px dashed color-mix(in srgb, var(--primary) 50%, transparent);
}
.assignee-link:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.task-project {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.project-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
  display: inline-block;
}
.project-filter {
  max-width: 190px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
}

.priority-urgent, .priority-high { border-left-color: var(--accent); }
.task.is-overdue { border-left-color: var(--danger); }
.task.is-due-today { border-left-color: var(--accent); }
.task.is-on-time { border-left-color: var(--primary); }
.task.escalated-item { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent), 0 10px 18px rgba(0,0,0,.08); }
.escalation-badge {
  width: fit-content;
  border-radius: 999px;
  padding: 3px 8px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}
.task-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 0 8px;
}
.task-tags span {
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, var(--panel));
  font-size: 11px;
  line-height: 1.35;
}
.task-dates {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
}
.subtask-progress {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px;
  align-items: center;
  margin: 0 0 8px;
}
.subtask-progress span {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}
.subtask-progress i {
  display: block;
  height: 100%;
  background: var(--primary);
}
.subtask-progress em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}
.drop-target { outline: 2px solid var(--primary); outline-offset: -4px; }

dialog {
  border: 0;
  border-radius: 8px;
  padding: 0;
  width: min(560px, calc(100% - 24px));
}

dialog::backdrop { background: rgba(18, 25, 38, .35); }
.dialog-form { padding: 18px; }
.dialog-form h2 { margin: 0 0 12px; }
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}
.dialog-actions .danger:first-child {
  margin-right: auto;
}
.window-form {
  padding: 16px;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.window-form:has(.tab-page[data-page="datos"].active) {
  overflow: hidden;
}

.window-form:not(:has(.tabs)) {
  overflow: auto;
}
.window-form h2 {
  margin: 0 0 10px;
  font-size: 18px;
}
.window-form section h3 {
  margin: 14px 0 8px;
  font-size: 14px;
}
.form-grid {
  display: grid;
  gap: 0 12px;
}
.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.task-data-grid {
  grid-template-columns: 1.35fr .9fr .8fr 1fr;
  align-items: end;
}
.task-data-grid label {
  margin: 7px 0;
}
.field-title {
  grid-column: span 2;
}
.field-project,
.field-status,
.field-priority,
.field-assignee {
  grid-column: span 1;
}
.field-created,
.field-due {
  grid-column: span 1;
}
.field-tags {
  grid-column: span 2;
}
.field-external-system,
.field-external-ref {
  grid-column: span 2;
}
.span-two {
  grid-column: 1 / -1;
}
.stretch-field {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(90px, 1fr);
}
.stretch-field textarea {
  min-height: 90px;
  height: 100%;
  resize: none;
}
.tabs {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  margin: -4px 0 12px;
}
.tab {
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-bottom: 0;
}
.tab.active {
  color: white;
  background: var(--primary);
}
.tab-page {
  display: none;
  min-height: 0;
  overflow: auto;
}
.tab-page.active {
  display: grid;
  flex: 1 1 auto;
  align-content: start;
}
.tab-page[data-page="datos"].active {
  grid-template-rows: auto minmax(90px, 1fr);
  overflow: hidden;
  align-content: stretch;
}
.hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.form-toggle {
  display: flex;
  justify-content: flex-start;
}
.api-token {
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: color-mix(in srgb, var(--primary) 12%, var(--panel));
  color: var(--text);
  font-size: 12px;
}
.detail-description { color: var(--muted); line-height: 1.4; }
.plain-list { list-style: none; padding: 0; margin: 8px 0 14px; display: grid; gap: 6px; }
.plain-list li {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: var(--input-bg);
  font-size: 13px;
}

.dialog-actions {
  flex: 0 0 auto;
}

.activity-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.activity-list li {
  display: grid;
  grid-template-columns: 120px 1fr 150px;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px;
  background: var(--input-bg);
  font-size: 13px;
}

.activity-list time {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 96px;
  margin-bottom: 12px;
  border: 2px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: color-mix(in srgb, var(--primary) 5%, var(--panel));
  text-align: center;
}

.dropzone.dragover {
  border-color: var(--primary);
  color: var(--text);
}

.dropzone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}

.attachment-card {
  display: grid;
  grid-template-rows: 110px auto auto;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--input-bg);
}

.attachment-preview {
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 6px;
  background: color-mix(in srgb, var(--primary) 10%, var(--panel));
  color: var(--muted);
  font-weight: 700;
}

.thumb-fit-box,
.image-fit-box {
  position: absolute;
  inset: 0;
  display: block;
  overflow: hidden;
  background: #05080c;
}

.attachment-preview {
  position: relative;
}

.attachment-preview .thumb-fit-box img,
.preview-window .image-fit-box img {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: none;
  max-height: none;
  object-fit: contain !important;
  object-position: center center;
}

.pdf-preview,
.md-preview {
  position: relative;
  font-size: 28px;
  letter-spacing: 0;
}

.pdf-preview::before {
  content: "";
  width: 52px;
  height: 66px;
  border-radius: 6px;
  background:
    linear-gradient(135deg, transparent 0 16px, rgba(255,255,255,.45) 17px 24px, transparent 25px),
    #b42318;
  box-shadow: inset 0 -18px 0 rgba(0,0,0,.14);
  position: absolute;
}

.pdf-preview::after {
  content: "PDF";
  position: relative;
  color: white;
  font-size: 15px;
  font-weight: 700;
}

.md-preview::before {
  content: "#";
  font-size: 44px;
  font-weight: 700;
  color: var(--primary);
}

.attachment-info {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.attachment-info strong,
.attachment-info span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-info span {
  color: var(--muted);
  font-size: 12px;
}

.attachment-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.attachment-actions button {
  flex: 1;
  padding: 7px 8px;
}

.preview-window {
  position: relative;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--bg);
}

.preview-window iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.image-fit-box.fill img {
  object-fit: cover !important;
}

.fit-toggle {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  background: rgba(15, 118, 110, .92);
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
}

.markdown-preview {
  width: 100%;
  height: 100%;
  overflow: auto;
  padding: 22px;
  line-height: 1.55;
  background: var(--panel);
  color: var(--text);
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3 {
  margin: 0 0 12px;
}

.markdown-preview p {
  margin: 0 0 10px;
}

.markdown-preview code {
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--input-bg);
  border: 1px solid var(--line);
}

.file-placeholder {
  display: grid;
  gap: 8px;
  text-align: center;
  color: var(--muted);
}

.empty-state {
  color: var(--muted);
  margin: 0;
}

.subtask-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-bottom: 12px;
}

.subtask-list {
  display: grid;
  gap: 8px;
}

.subtask-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
}

.subtask-item input {
  width: auto;
}

.subtask-item span {
  outline: none;
}

.subtask-item:has(input:checked) span {
  color: var(--muted);
  text-decoration: line-through;
}

.users-window {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
  padding: 14px;
}

.window-toolbar {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.users-table {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.users-row {
  display: grid;
  grid-template-columns: 1.1fr .9fr 1.4fr .7fr .8fr .7fr 150px;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.projects-table .users-row {
  grid-template-columns: 1.2fr 1.8fr .6fr .7fr 150px;
}

.users-row:last-child {
  border-bottom: 0;
}

.users-head {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
  font-weight: 700;
}

.users-head button,
.tickets-head button {
  padding: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-weight: 700;
}

.users-head button[data-sort-dir="asc"]::after,
.tickets-head button[data-sort-dir="asc"]::after {
  content: " ↑";
}

.users-head button[data-sort-dir="desc"]::after,
.tickets-head button[data-sort-dir="desc"]::after {
  content: " ↓";
}

.history-window {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 10px;
  padding: 14px;
  overflow: hidden;
}

.history-toolbar,
.history-filters {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
}

.history-filters label {
  margin: 0;
  min-width: 150px;
  flex: 1 1 150px;
}

.history-filters label:first-child {
  flex-basis: 280px;
}

.history-table {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.history-row {
  display: grid;
  grid-template-columns: 70px minmax(280px, 1.8fr) 160px 170px 170px 110px 110px 160px;
  gap: 10px;
  align-items: center;
  min-width: 1240px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.history-row[data-task-id] {
  cursor: pointer;
}

.history-row[data-task-id]:hover {
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}

.history-row:last-child {
  border-bottom: 0;
}

.history-head {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
  font-weight: 700;
}

.history-head button {
  padding: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-weight: 700;
}

.history-head button[data-sort-dir="asc"]::after {
  content: " ^";
}

.history-head button[data-sort-dir="desc"]::after {
  content: " v";
}

.history-title {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.row-actions button {
  padding: 6px 8px;
}

.tickets-window {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  min-height: 0;
  padding: 14px;
  overflow: hidden;
}

.tickets-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
}

.ticket-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ticket-summary-item {
  min-width: 112px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.ticket-summary-item strong {
  display: block;
  font-size: 19px;
  line-height: 1;
}

.ticket-summary-item span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.ticket-summary-item.highlight {
  border-color: var(--primary);
}

.ticket-summary-item.danger-summary {
  border-color: var(--danger);
}

.ticket-summary-item.warning-summary {
  border-color: var(--accent);
}

.ticket-filter {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex: 0 0 auto;
  flex-wrap: wrap;
}

.ticket-filter label {
  margin: 0;
  min-width: 150px;
}

.ticket-filter button {
  height: 38px;
  padding: 8px 12px;
}

.tickets-table {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.external-ticket-window {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  min-height: 0;
  padding: 14px;
  overflow: hidden;
}

.external-ticket-table {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.external-ticket-row {
  display: grid;
  grid-template-columns: 64px 150px 130px 130px 100px minmax(250px, 1.4fr) 170px 150px 540px;
  gap: 10px;
  align-items: center;
  min-width: 1500px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.external-ticket-row.sla-overdue {
  border-left: 4px solid var(--danger);
  background: color-mix(in srgb, var(--danger) 8%, var(--input-bg));
}

.external-ticket-row.sla-soon {
  border-left: 4px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--input-bg));
}

.sla-label {
  font-weight: 700;
  color: var(--muted);
}

.sla-overdue .sla-label { color: var(--danger); }
.sla-soon .sla-label { color: var(--accent); }

.external-ticket-row:last-child {
  border-bottom: 0;
}

.external-ticket-head {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
  font-weight: 700;
}

.external-ticket-head button {
  padding: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-weight: 700;
}

.external-ticket-head button[data-sort-dir="asc"]::after {
  content: " ^";
}

.external-ticket-head button[data-sort-dir="desc"]::after {
  content: " v";
}

.external-ticket-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.external-ticket-actions button {
  padding: 6px 8px;
}

.ticket-followup-box {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--input-bg);
}

.ticket-followup-box > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.ticket-followup-box span,
.ticket-followup-box p {
  color: var(--muted);
}

.ticket-followup-box p {
  margin: 0;
  white-space: pre-wrap;
}

.ticket-followup-list {
  min-height: 120px;
  overflow: auto;
}

.ticket-followup-list em {
  display: inline-block;
  margin-right: 8px;
  padding: 2px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  color: var(--primary);
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
}

.ticket-internal-update em {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
}

.ticket-audit-event em {
  background: color-mix(in srgb, var(--muted) 18%, transparent);
  color: var(--muted);
}

.update-attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.update-attachment-link {
  padding: 4px 8px;
  font-size: 12px;
}

.section-title {
  margin: 4px 0 0;
  font-size: 15px;
}

.token-window,
.metrics-window {
  display: grid;
  gap: 12px;
  height: 100%;
  min-height: 0;
  padding: 14px;
  overflow: auto;
}

.token-table {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.token-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 150px 150px 95px 170px;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.token-row:last-child {
  border-bottom: 0;
}

.token-head {
  background: var(--column);
}

.token-status {
  font-weight: 700;
}

.token-expiring_soon .token-status,
.token-expired .token-status {
  color: var(--accent);
}

.token-revoked {
  opacity: 0.7;
}

.token-actions,
.webhook-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.metrics-grid section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--input-bg);
}

.metrics-grid h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.metric-list {
  list-style: none;
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.metric-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 7px;
}

.global-search-window {
  display: grid;
  gap: 10px;
  height: 100%;
  min-height: 0;
  padding: 14px;
  overflow: hidden;
}

.global-search-table {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.global-search-row {
  display: grid;
  grid-template-columns: 90px 70px minmax(260px, 1fr) 130px 110px 150px 180px;
  gap: 10px;
  align-items: center;
  min-width: 990px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.global-search-row:last-child {
  border-bottom: 0;
}

.global-search-head {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
}

.template-window {
  display: grid;
  gap: 12px;
  height: 100%;
  min-height: 0;
  padding: 14px;
  overflow: hidden;
}

.template-table {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow: auto;
}

.template-row {
  display: grid;
  grid-template-columns: 180px 170px minmax(260px, 1fr) 100px 90px;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--input-bg);
}

.template-row textarea {
  min-height: 42px;
  resize: vertical;
}

.import-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.import-summary ul {
  flex-basis: 100%;
  margin: 0;
  padding-left: 20px;
  color: var(--danger);
}

.archive-window,
.attachment-audit-window {
  display: grid;
  gap: 10px;
  height: 100%;
  min-height: 0;
  padding: 14px;
  overflow: hidden;
}

.archive-layout {
  display: grid;
  grid-template-columns: minmax(520px, 1.5fr) minmax(280px, 0.8fr);
  gap: 12px;
  min-height: 0;
}

.archive-table,
.archive-detail {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
}

.archive-detail {
  padding: 12px;
}

.archive-detail h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.archive-detail p {
  white-space: pre-wrap;
}

.archive-row,
.attachment-audit-row {
  display: grid;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.archive-row {
  grid-template-columns: 70px 70px minmax(220px, 1fr) 130px 150px 150px 160px;
  min-width: 950px;
  cursor: pointer;
}

.attachment-audit-row {
  grid-template-columns: 150px 120px minmax(220px, 1fr) minmax(220px, 1fr) 100px;
}

.archive-row:hover {
  background: color-mix(in srgb, var(--primary) 8%, var(--input-bg));
}

.archive-head {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
  cursor: default;
}

.readonly-detail {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px 10px;
  margin: 0;
}

.readonly-detail dt {
  color: var(--muted);
  font-weight: 700;
}

.readonly-detail dd {
  margin: 0;
}

.notification-pref-window {
  display: grid;
  gap: 12px;
  height: 100%;
  min-height: 0;
  padding: 14px;
  overflow: auto;
}

.notification-pref-table {
  display: grid;
  gap: 8px;
}

.notification-pref-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 130px 130px;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--input-bg);
}

.notification-pref-row em {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  color: var(--danger);
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
}

.project-activity-window,
.trace-window {
  display: grid;
  gap: 12px;
  height: 100%;
  min-height: 0;
  padding: 14px;
  overflow: hidden;
}

.project-activity-table {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
}

.project-activity-row {
  display: grid;
  grid-template-columns: 80px 70px minmax(220px, 1fr) 150px minmax(300px, 1.2fr) 160px;
  gap: 10px;
  align-items: center;
  min-width: 980px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.project-activity-head {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
}

.trace-window {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: auto;
}

.trace-card {
  display: grid;
  gap: 8px;
  align-content: start;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: var(--input-bg);
  min-width: 0;
}

.trace-main {
  grid-column: 1 / -1;
}

.trace-card h3 {
  margin: 0;
  font-size: 16px;
}

.trace-card p {
  margin: 0;
  white-space: pre-wrap;
  color: var(--muted);
}

.trace-task-row,
.trace-attachment-row {
  display: grid;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.trace-task-row {
  grid-template-columns: 70px minmax(180px, 1fr) 120px 130px 130px;
  cursor: pointer;
}

.trace-attachment-row {
  grid-template-columns: 80px minmax(180px, 1fr) 130px 80px 150px;
}

.trace-task-row:hover {
  background: color-mix(in srgb, var(--primary) 8%, var(--input-bg));
}

.deleted-task-window,
.member-role-window,
.priority-rule-window {
  display: grid;
  gap: 12px;
  height: 100%;
  min-height: 0;
  padding: 14px;
  overflow: hidden;
}

.deleted-task-table,
.member-role-table,
.priority-rule-table {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
}

.integrity-window,
.capacity-window,
.admin-audit-window,
.retention-window {
  display: grid;
  gap: 12px;
  height: 100%;
  min-height: 0;
  padding: 14px;
  overflow: hidden;
}

.integrity-table,
.capacity-table,
.admin-audit-table,
.retention-table {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
}

.integrity-row,
.capacity-row,
.admin-audit-row,
.retention-row {
  display: grid;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.integrity-row {
  grid-template-columns: 90px 190px 80px minmax(260px, 1fr) minmax(260px, 1fr);
  min-width: 980px;
}

.capacity-row {
  grid-template-columns: minmax(210px, 1fr) 70px 80px 80px 120px 110px 220px;
  min-width: 920px;
}

.admin-audit-row {
  grid-template-columns: 160px 150px 190px 180px minmax(320px, 1fr);
  min-width: 1000px;
}

.integration-error-table .admin-audit-row {
  grid-template-columns: 150px 70px 150px 130px 210px minmax(260px, 1fr) 180px;
  min-width: 1160px;
}

.integration-quality-table .integration-quality-row {
  grid-template-columns: minmax(150px, 1fr) 80px 80px 80px 80px 80px 80px 90px 120px;
  min-width: 980px;
}

.retention-row {
  grid-template-columns: minmax(220px, 1fr) 100px minmax(220px, 1fr);
  min-width: 620px;
}

.integrity-head,
.capacity-head,
.admin-audit-head,
.retention-head {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
}

.integrity-high,
.capacity-risk {
  border-left: 4px solid var(--danger);
}

.integrity-row code,
.admin-audit-row code {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--muted);
}

.retention-policy {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--input-bg);
}

.retention-policy h3 { margin: 0 0 8px; }
.retention-policy ul,
.retention-policy li {
  margin: 0;
  padding: 0;
  list-style: none;
}

.retention-policy li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  color: var(--muted);
}

.deleted-task-row,
.member-role-row,
.priority-rule-row {
  display: grid;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.deleted-task-row {
  grid-template-columns: 70px minmax(240px, 1fr) 160px 150px 170px 110px;
  min-width: 900px;
}

.member-role-row {
  grid-template-columns: minmax(190px, 1fr) minmax(180px, 1fr) 110px 190px;
  min-width: 760px;
}

.priority-rule-row {
  grid-template-columns: 160px minmax(180px, 1fr) minmax(180px, 1fr) 90px;
  min-width: 720px;
}

.deleted-task-head,
.member-role-head,
.project-status-head,
.priority-rule-head {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
}

.project-status-window {
  display: grid;
  gap: 12px;
  height: 100%;
  min-height: 0;
  padding: 14px;
}

.project-status-table {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.project-status-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 100px 110px;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
}

.project-status-row:last-child {
  border-bottom: 0;
}

.webhook-window {
  display: grid;
  gap: 12px;
  height: 100%;
  min-height: 0;
  padding: 14px;
  overflow: auto;
}

.webhook-table {
  display: grid;
  gap: 8px;
}

.webhook-row {
  display: grid;
  grid-template-columns: 160px minmax(320px, 1fr) 100px 220px;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--input-bg);
}

.webhook-simulator {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--input-bg);
}

.webhook-simulator pre {
  min-height: 120px;
  max-height: 260px;
  overflow: auto;
  margin: 0;
  padding: 10px;
  border-radius: 8px;
  background: var(--column);
  white-space: pre-wrap;
}

.linked-task-list {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--input-bg);
}

.linked-task-list strong {
  flex-basis: 100%;
}

.linked-task-list button {
  padding: 6px 8px;
}

.tickets-row {
  display: grid;
  grid-template-columns: 62px 150px 150px minmax(260px, 1.5fr) 150px 160px 430px;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  min-width: 1330px;
}

.tickets-row:last-child {
  border-bottom: 0;
}

.tickets-head {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
  font-weight: 700;
}

.ticket-title {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ticket-empty {
  padding: 18px;
  color: var(--muted);
}

.ticket-controls {
  display: grid;
  grid-template-columns: 132px 152px 56px 76px;
  gap: 6px;
  align-items: center;
}

.ticket-controls select,
.ticket-controls button {
  padding: 7px 8px;
  min-width: 0;
}

.taskbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  max-height: 40px;
  padding: 6px 10px;
  background: var(--taskbar);
  color: white;
}

.task-start {
  flex: 0 0 auto;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, .12);
}

.start-wrap {
  position: relative;
  flex: 0 0 auto;
}

.start-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 60;
  width: 240px;
  padding: 8px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 34px var(--shadow);
}

.start-menu button {
  width: 100%;
  padding: 9px 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.start-menu button span {
  display: inline-block;
  width: 22px;
}

.start-menu button:hover,
.start-menu button:focus {
  background: var(--column);
}

.start-menu hr {
  margin: 7px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

/* Categorias con submenu flyout: agrupan opciones para acortar el menu. */
.menu-group {
  position: relative;
}

.menu-cat {
  display: flex !important;
  align-items: center;
}

.menu-cat::after {
  content: "\25B8"; /* ▸ */
  margin-left: auto;
  padding-left: 8px;
  opacity: .55;
  font-size: 12px;
}

.submenu {
  position: absolute;
  left: 100%;
  top: -9px;
  min-width: 230px;
  padding: 8px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 34px var(--shadow);
  z-index: 70;
  display: none;
}

.menu-group:hover > .submenu,
.menu-group.open > .submenu {
  display: block;
}

.menu-group:hover > .menu-cat,
.menu-group.open > .menu-cat {
  background: var(--column);
}

.taskbar-items {
  display: flex;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
}

.task-item {
  flex: 0 0 auto;
  max-width: 220px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  background: rgba(255, 255, 255, .12);
  color: white;
  border: 1px solid rgba(255, 255, 255, .16);
}

.task-item.active {
  background: var(--primary);
}

.jsPanel-content {
  display: flex;
  flex-direction: column;
  height: 100% !important;
  min-height: 0;
  background: var(--panel);
  color: var(--text);
  overflow: hidden !important;
}

.jsPanel-content > * {
  flex: 1 1 auto;
  min-height: 0;
}

.jsPanel[id$="-min"] {
  display: none !important;
}

:root[data-theme="dark"] .jsPanel {
  background: var(--panel);
  color: var(--text);
}

:root[data-theme="dark"] .jsPanel-hdr,
:root[data-theme="dark"] .jsPanel-headerbar {
  color: #fff;
}

@media (max-width: 780px) {
  .topbar {
    grid-template-columns: 1fr auto;
    align-items: flex-start;
  }
  .brand-area {
    width: 100%;
  }
  .actions { grid-column: 1 / -1; justify-content: flex-start; }
  .board { grid-auto-columns: minmax(240px, 86vw); }
  .form-grid.two,
  .task-data-grid { grid-template-columns: 1fr; }
  .field-title,
  .field-project,
  .field-status,
  .field-priority,
  .field-assignee,
  .field-created,
  .field-due,
  .field-tags,
  .field-external-system,
  .field-external-ref { grid-column: auto; }
  .tickets-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
  .ticket-filter {
    justify-content: flex-start;
  }
  .activity-list li,
  .users-row {
    grid-template-columns: 1fr;
  }
  .activity-list time,
  .row-actions {
    text-align: left;
    justify-content: flex-start;
  }
}
