/* ═══════════════════════════════════════════════════════════════
   COMPONENTS — Editorial / Notion style
═══════════════════════════════════════════════════════════════ */

/* ─── App shell ─────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  min-height: 100svh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  padding: var(--s-6) var(--s-4);
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--s-6);
  overflow-y: auto;
}

.sidebar-brand {
  padding: 0 var(--s-3);
}

.sidebar-profile {
  padding: 0 var(--s-3);
}

.sidebar-brand .brand-name {
  font-size: var(--t-md);
  font-weight: var(--w-semibold);
  letter-spacing: -0.02em;
  color: var(--text);
}
.sidebar-brand .brand-tag {
  font-size: var(--t-xs);
  color: var(--text-3);
  font-family: var(--font-mono);
  margin-top: 2px;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-section-label {
  font-size: var(--t-xs);
  font-weight: var(--w-medium);
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 var(--s-3);
  margin-bottom: var(--s-2);
}

.sidebar-bottom {
  margin-top: auto;
  padding-top: var(--s-4);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

/* Navigation items */
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 7px var(--s-3);
  border-radius: var(--r-md);
  font-size: var(--t-sm);
  font-weight: var(--w-medium);
  color: var(--text-2);
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background-color var(--d-fast) var(--ease-standard),
              color var(--d-fast) var(--ease-standard);
}
.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}
.nav-item.active {
  background: linear-gradient(90deg, var(--accent-soft), var(--surface-2));
  color: var(--accent);
  font-weight: var(--w-semibold);
  box-shadow: inset 2px 0 0 var(--accent);
}
.nav-item .nav-kbd {
  margin-left: auto;
  opacity: 0;
  transition: opacity var(--d-fast) var(--ease-standard);
}
.nav-item:hover .nav-kbd { opacity: 1; }

/* User pill in sidebar */
.user-pill {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
}
.user-pill-top {
  background: linear-gradient(180deg, var(--surface), color-mix(in srgb, var(--surface) 88%, var(--accent-soft)));
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

/* ── Vertical user pill (sidebar profile) ─────────────────── */
.user-pill-vertical {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-2) var(--s-2);
  border-radius: var(--r-lg);
  cursor: pointer;
  text-align: center;
  transition: background var(--d-fast) var(--ease-standard);
}
.user-pill-vertical:hover {
  background: var(--surface-2);
}
.user-pill-identity {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
  width: 100%;
}
.user-pill-vertical .user-name {
  font-size: var(--t-sm);
  font-weight: var(--w-semibold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.user-pill-vertical .user-role {
  font-size: var(--t-xs);
  color: var(--text-3);
}
.user-pill-vertical .user-status {
  font-size: var(--t-xs);
  color: var(--text-2);
  min-height: 14px;
}

/* ── Presence section ─────────────────────────────────────── */
.presence-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.presence-count {
  background: var(--accent-2-soft);
  color: var(--accent-2);
  border-radius: 999px;
  font-size: 10px;
  font-weight: var(--w-semibold);
  padding: 1px 6px;
  line-height: 16px;
}
.presence-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.presence-group + .presence-group {
  margin-top: var(--s-2);
  padding-top: var(--s-2);
  border-top: 1px solid var(--border);
}
.presence-group-label {
  padding: 3px var(--s-2);
  font-size: 10px;
  font-weight: var(--w-semibold);
  color: var(--text-3);
  text-transform: uppercase;
}
.presence-item {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 5px var(--s-2);
  border-radius: var(--r-md);
  min-width: 0;
  transition: background var(--d-fast) var(--ease-standard);
}
.presence-item:hover {
  background: var(--surface-2);
}
.presence-item.offline {
  opacity: 0.55;
}
.presence-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}
.presence-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: var(--w-semibold);
  overflow: hidden;
}
.presence-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 2px solid var(--bg);
}
.presence-dot.online { background: #22c55e; }
.presence-dot.idle   { background: #f59e0b; }
.presence-dot.offline { background: var(--text-3); }
.presence-item-info {
  min-width: 0;
  flex: 1;
}
.presence-item-name {
  font-size: var(--t-xs);
  font-weight: var(--w-medium);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.presence-item-role {
  font-size: 10px;
  color: var(--text-3);
}
.presence-item-info { flex: 1; min-width: 0; overflow: hidden; }
.user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--t-xs);
  font-weight: var(--w-semibold);
  flex-shrink: 0;
  overflow: hidden;
}
.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.user-avatar-xl {
  width: 112px;
  height: 112px;
  font-size: 2rem;
  border: 3px solid color-mix(in srgb, var(--accent) 25%, transparent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent-soft) 40%, transparent),
              0 4px 16px rgba(15, 23, 42, 0.10);
  transition: box-shadow 200ms ease, border-color 200ms ease;
}
.user-avatar-xl img {
  transition: filter 200ms ease;
}
.user-info { min-width: 0; flex: 1; }
.user-name {
  font-size: var(--t-sm);
  font-weight: var(--w-medium);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: var(--t-xs);
  color: var(--text-3);
}

.profile-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: var(--s-4);
  align-items: start;
}

.profile-avatar-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
}

.profile-avatar-preview {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-3);
  border-radius: 50%;
  background: linear-gradient(145deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  cursor: pointer;
}

.profile-avatar-preview:hover .user-avatar-xl {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 30%, transparent),
              0 6px 20px rgba(15, 23, 42, 0.15);
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
}

.profile-avatar-preview:hover .user-avatar-xl img {
  filter: brightness(0.8);
}

.profile-avatar-edit-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 200ms ease;
  pointer-events: none;
}

.profile-avatar-preview:hover .profile-avatar-edit-overlay {
  opacity: 1;
}

.profile-avatar-edit-overlay svg {
  width: 28px;
  height: 28px;
  color: #fff;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5));
}

.avatar-cropper {
  display: grid;
  gap: var(--s-4);
}

.avatar-crop-stage {
  position: relative;
  width: min(100%, 420px);
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 28px;
  overflow: hidden;
  background: radial-gradient(circle at 30% 25%, rgba(96, 165, 250, 0.12), transparent 35%), var(--surface-2);
  border: 1px solid var(--border);
  touch-action: none;
  user-select: none;
  cursor: grab;
}

.avatar-crop-stage:active { cursor: grabbing; }

.avatar-crop-stage img {
  position: absolute;
  top: 50%;
  left: 50%;
  transform-origin: center center;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

/* Prevent base.css max-width rules from constraining the image.
   Width/height are set via inline style by JS — do NOT add !important here
   or the zoom will stop working. */
.avatar-crop-stage img {
  max-width: none;
  max-height: none;
  min-width: 0;
  min-height: 0;
}

.avatar-crop-ring {
  position: absolute;
  inset: 14%;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.18);
  pointer-events: none;
}

.avatar-crop-controls {
  display: grid;
  gap: var(--s-2);
  max-width: 420px;
  margin: 0 auto;
}

.range-input {
  width: 100%;
}

/* Tooltip for avatar */
.avatar-tooltip {
  position: fixed;
  z-index: 1200;
  min-width: 220px;
  max-width: min(340px, calc(100vw - 24px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-3);
  box-shadow: var(--shadow-modal);
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 160ms var(--ease-standard), transform 160ms var(--ease-standard);
}
.avatar-tooltip.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.avatar-tooltip .avatar-tooltip-name { font-weight: var(--w-semibold); margin-bottom:4px; }
.avatar-tooltip .avatar-tooltip-role { font-size: var(--t-xs); color: var(--text-3); margin-bottom:6px; }
.avatar-tooltip .avatar-tooltip-status { font-size: var(--t-sm); color: var(--text-2); margin-bottom:8px; }
.avatar-tooltip .avatar-tooltip-actions { display:flex; gap:8px; justify-content:flex-end; }
.avatar-tooltip .btn { font-size: 0.85rem; padding:6px 8px; }

/* ─── Main content ──────────────────────────────────────── */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  height: var(--topbar-h);
  padding: 0 var(--s-7);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  background: rgba(248, 250, 252, 0.85);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}
[data-theme="dark"] .topbar {
  background: rgba(15, 23, 42, 0.85);
}

.topbar-title {
  font-size: var(--t-md);
  font-weight: var(--w-semibold);
  color: var(--text);
}
.topbar-breadcrumb {
  font-size: var(--t-sm);
  color: var(--text-3);
  font-family: var(--font-mono);
}

.content {
  padding: var(--s-7) var(--s-7) max(var(--s-9), env(safe-area-inset-bottom, 0px));
  max-width: var(--container-max);
  width: 100%;
  margin: 0 auto;
}

/* Page header */
.page-header {
  margin-bottom: var(--s-7);
}
.page-title {
  font-size: var(--t-xl);
  font-weight: var(--w-bold);
  letter-spacing: -0.025em;
  color: var(--text);
  margin-bottom: 6px;
}
.page-subtitle {
  font-size: var(--t-sm);
  color: var(--text-2);
}

/* ─── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  font-size: var(--t-sm);
  font-weight: var(--w-medium);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--d-fast) var(--ease-standard),
              border-color var(--d-fast) var(--ease-standard),
              color var(--d-fast) var(--ease-standard);
}
.btn:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--border-strong);
}
.btn:active:not(:disabled) {
  transform: translateY(0.5px);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
[data-theme="dark"] .btn-primary { color: var(--bg); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
  border-color: transparent;
}

.btn-danger {
  color: var(--danger);
  border-color: var(--border);
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.btn-sm  { height: 26px; padding: 0 10px; font-size: var(--t-xs); }
.btn-lg  { height: 38px; padding: 0 16px; font-size: var(--t-base); }

.btn-icon {
  width: 32px;
  padding: 0;
  flex-shrink: 0;
}
.btn-icon svg { width: 16px; height: 16px; }

.btn-block { width: 100%; }

/* Button cluster */
.btn-group {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 2px;
  gap: 0;
}
.btn-group .btn {
  height: 26px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--r-sm);
  padding: 0 10px;
  font-size: var(--t-xs);
}
.btn-group .btn.active {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--shadow-1);
}

/* ─── Forms ─────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-label {
  font-size: var(--t-xs);
  font-weight: var(--w-medium);
  color: var(--text-2);
  letter-spacing: 0.01em;
}
.field-hint {
  font-size: var(--t-xs);
  color: var(--text-3);
}
.field-error {
  font-size: var(--t-xs);
  color: var(--danger);
}

.input,
.select,
.textarea {
  width: 100%;
  height: 34px;
  padding: 0 12px;
  font-size: var(--t-sm);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: border-color var(--d-fast) var(--ease-standard),
              box-shadow var(--d-fast) var(--ease-standard);
}
.input::placeholder,
.textarea::placeholder { color: var(--text-3); }

/* ─── File input estilizado ─────────────────────────────── */
input[type="file"].input {
  height: auto;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  cursor: pointer;
}
input[type="file"].input::file-selector-button {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 4px 12px;
  font-size: var(--t-sm);
  font-family: var(--font-sans);
  color: var(--text);
  cursor: pointer;
  margin-right: 10px;
  transition: background var(--d-fast) var(--ease-standard);
}
input[type="file"].input::file-selector-button:hover {
  background: var(--border);
}

.input:hover, .select:hover, .textarea:hover {
  border-color: var(--border-strong);
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.textarea {
  height: auto;
  min-height: 88px;
  padding: 9px 12px;
  resize: vertical;
  line-height: var(--lh-normal);
}

.select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

/* Checkbox */
.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: var(--t-sm);
  color: var(--text);
}
.checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

/* Search input with icon */
.search-input {
  position: relative;
}
.search-input .input { padding-left: 32px; }
.search-input::before {
  content: '';
  position: absolute;
  left: 11px; top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
  background-repeat: no-repeat;
  pointer-events: none;
}

/* ─── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  transition: border-color var(--d-base) var(--ease-standard),
              box-shadow var(--d-base) var(--ease-standard);
}
.card:hover { border-color: color-mix(in srgb, var(--accent-2) 32%, var(--border-strong)); }

.card-flat {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
}

.card-section + .card-section {
  border-top: 1px solid var(--border);
  padding-top: var(--s-5);
  margin-top: var(--s-5);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}
.card-title {
  font-size: var(--t-md);
  font-weight: var(--w-semibold);
  letter-spacing: -0.01em;
  color: color-mix(in srgb, var(--text) 82%, var(--accent));
}
.card-subtitle {
  font-size: var(--t-sm);
  color: var(--text-2);
}

/* ─── Audit log scroll ─────────────────────────────────── */
.audit-scroll {
  max-height: 460px;
  overflow-y: auto;
  padding-right: var(--s-1);
}

/* ─── Category list scroll ──────────────────────────────── */
.category-scroll {
  max-height: 380px;
  overflow-y: auto;
  padding-right: var(--s-1);
}
.cat-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.cat-list-archived {
  margin-top: var(--s-3);
  opacity: 0.7;
}
.cat-archived-section { border: none; }
.cat-archived-summary {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: var(--t-sm);
  font-weight: var(--w-medium);
  color: var(--text-2);
  padding: var(--s-2) 0;
  user-select: none;
  list-style: none;
}
.cat-archived-summary::-webkit-details-marker { display: none; }
.cat-archived-summary::before {
  content: '▶';
  font-size: 9px;
  margin-right: var(--s-2);
  transition: transform var(--d-fast) var(--ease-standard);
  color: var(--text-3);
}
details[open] .cat-archived-summary::before { transform: rotate(90deg); }

/* ─── Portal público ────────────────────────────────────── */
.portal-code-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: var(--w-bold);
  letter-spacing: 0.05em;
  background: var(--surface-2);
  border: 2px solid var(--accent);
  border-radius: var(--r-lg);
  padding: var(--s-3) var(--s-5);
  color: var(--accent);
}

/* ─── Ticket externo ─────────────────────────────────────── */
.tag-external {
  background: rgba(14, 165, 233, 0.10);
  color: #0284C7;
  border: 1px solid rgba(14, 165, 233, 0.25);
}
[data-theme="dark"] .tag-external {
  background: rgba(56, 189, 248, 0.12);
  color: #38BDF8;
  border-color: rgba(56, 189, 248, 0.25);
}
.external-ticket-banner {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  background: rgba(14, 165, 233, 0.07);
  border-left: 3px solid #0284C7;
  border-radius: 0 var(--r-md) var(--r-md) 0;
  padding: var(--s-2) var(--s-3);
  margin-bottom: var(--s-3);
  font-size: var(--t-sm);
  color: var(--text-2);
}
[data-theme="dark"] .external-ticket-banner {
  background: rgba(56, 189, 248, 0.08);
  border-color: #38BDF8;
}

/* ─── Notas internas ────────────────────────────────────── */
.activity-internal {
  background: rgba(251, 191, 36, 0.07);
  border-radius: var(--r-md);
  padding: var(--s-2) var(--s-2);
  border-left: 3px solid var(--warn);
}
.activity-internal .activity-dot { background: var(--warn) !important; }
.internal-badge {
  font-size: 10px;
  color: var(--warn);
  font-weight: var(--w-semibold);
  margin-left: var(--s-2);
}

/* ─── Calificación de resolución ─────────────────────────── */
.satisfaction-request {
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--surface-2);
}
.star-rating {
  display: flex;
  gap: var(--s-2);
  margin: var(--s-2) 0;
}
.star-btn {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--text-3);
  transition: color var(--d-fast) var(--ease-standard),
              transform var(--d-fast) var(--ease-standard);
  padding: 0;
  line-height: 1;
}
.star-btn:hover,
.star-btn.star-active { color: #F59E0B; transform: scale(1.15); }
.satisfaction-done { border-left: 3px solid #F59E0B; }
.satisfaction-stars-display {
  font-size: 22px;
  color: #F59E0B;
  letter-spacing: 2px;
}

/* ─── Respuestas rápidas (picker) ────────────────────────── */
.canned-picker {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: var(--z-dropdown);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  min-width: 220px;
  max-width: 340px;
  max-height: 260px;
  overflow-y: auto;
  padding: var(--s-1);
}
.canned-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: var(--s-2) var(--s-3);
  font-size: var(--t-sm);
  color: var(--text);
  cursor: pointer;
  border-radius: var(--r-md);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background var(--d-fast) var(--ease-standard);
}
.canned-item:hover { background: var(--surface-2); }

/* ─── Swatches de color de acento ──────────────────────── */
.accent-swatch {
  width: 28px;
  height: 28px;
  border-radius: var(--r-pill);
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform var(--d-fast) var(--ease-standard),
              box-shadow var(--d-fast) var(--ease-standard);
  outline: none;
  flex-shrink: 0;
}
.accent-swatch:hover { transform: scale(1.15); }
.accent-swatch.accent-swatch-active {
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px currentColor;
  border-color: transparent;
  transform: scale(1.1);
}

/* ─── Config sub-tabs ───────────────────────────────────── */
.config-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--s-5);
  flex-wrap: wrap;
}
.config-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: var(--s-2) var(--s-4);
  font-size: var(--t-sm);
  font-weight: var(--w-medium);
  color: var(--text-2);
  cursor: pointer;
  transition: color var(--d-fast) var(--ease-standard),
              border-color var(--d-fast) var(--ease-standard);
  white-space: nowrap;
  margin-bottom: -1px;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
}
.config-tab:hover { color: var(--text); }
.config-tab.active {
  color: var(--accent-2);
  border-bottom-color: var(--accent-2);
  font-weight: var(--w-semibold);
}
.config-tab-panel {
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
}

/* ─── Status indicators (Editorial style — solo punto) ─── */
.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: var(--t-sm);
  font-weight: var(--w-medium);
  color: var(--text);
}
.status .dot.abierto    { color: var(--dot-abierto); }
.status .dot.asignado   { color: var(--dot-asignado); }
.status .dot.progreso   { color: var(--dot-progreso); }
.status .dot.espera     { color: var(--dot-espera); }
.status .dot.resuelto   { color: var(--dot-resuelto); }
.status .dot.cerrado    { color: var(--dot-cerrado); }
.status .dot.eliminado  { color: var(--dot-eliminado); }

/* Tag (Notion-like) — para prioridades/categorías */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  font-size: var(--t-xs);
  font-weight: var(--w-medium);
  letter-spacing: 0.01em;
  border-radius: var(--r-sm);
  background: var(--neutral-soft);
  color: var(--text-2);
  border: 1px solid transparent;
  white-space: nowrap;
}
.tag-info     { background: var(--info-soft);    color: var(--info); }
.tag-ok       { background: var(--ok-soft);      color: var(--ok); }
.tag-warn     { background: var(--warn-soft);    color: var(--warn); }
.tag-danger   { background: var(--danger-soft);  color: var(--danger); }
.tag-neutral  { background: var(--neutral-soft); color: var(--text-2); }
.tag-accent   { background: var(--accent-soft);  color: var(--accent); }

.tag-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text-2);
}

/* Priority specific */
.prio-baja      { background: var(--neutral-soft); color: var(--text-2); }
.prio-media     { background: var(--info-soft);    color: var(--info); }
.prio-alta      { background: var(--warn-soft);    color: var(--warn); }
.prio-critica   { background: var(--danger-soft);  color: var(--danger); }

/* ─── Metric (KPI) ──────────────────────────────────────── */
.metric {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--s-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 2px solid var(--accent);
  border-radius: var(--r-lg);
  transition: border-color var(--d-base) var(--ease-standard);
}
.metric:nth-child(even) { border-top-color: var(--accent-2); }
.metric:hover { border-color: color-mix(in srgb, var(--accent) 26%, var(--border-strong)); }

.metric-label {
  font-size: var(--t-xs);
  font-weight: var(--w-medium);
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.metric-value {
  font-size: var(--t-2xl);
  font-weight: var(--w-bold);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: color-mix(in srgb, var(--text) 88%, var(--accent-2));
  line-height: 1;
  margin-top: 6px;
}
.metric-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--t-xs);
  font-weight: var(--w-medium);
  color: var(--text-2);
  margin-top: 4px;
}
.metric-delta.up   { color: var(--ok); }
.metric-delta.down { color: var(--danger); }

.kpi-group-label {
  font-size: var(--t-xs);
  font-weight: var(--w-semibold);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-2);
  margin-bottom: var(--s-2);
  padding-left: 2px;
}

.metric-hero {
  padding: var(--s-7);
}
.metric-hero .metric-value {
  font-size: var(--t-3xl);
}

/* ─── Tables ────────────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-sm);
}
.table th {
  text-align: left;
  padding: 10px var(--s-4);
  font-size: var(--t-xs);
  font-weight: var(--w-medium);
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 12px var(--s-4);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr {
  transition: background-color var(--d-fast) var(--ease-standard);
  cursor: pointer;
}
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.selected { background: var(--accent-soft); }

.td-code {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  color: var(--text-2);
  letter-spacing: -0.01em;
}
.td-title {
  font-weight: var(--w-medium);
  color: var(--text);
}
.td-meta {
  color: var(--text-2);
  font-size: var(--t-xs);
}

/* ─── Kanban ────────────────────────────────────────────── */
.kanban {
  display: grid;
  /* auto-fill: cabe la máxima cantidad de columnas de 260 px;
     las sobrantes wrappean a la siguiente fila — sin scroll horizontal */
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--s-4);
  align-items: start;   /* cada columna crece solo hasta su contenido */
}

.kanban-col {
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-3);
  min-height: 160px;    /* suficiente para ser drop target incluso si está vacía */
  display: flex;
  flex-direction: column;
}
.kanban-col.drag-over {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  padding: 4px var(--s-2) var(--s-3);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--s-3);
}
.kanban-col-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: var(--t-xs);
  font-weight: var(--w-semibold);
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.kanban-count {
  font-size: var(--t-xs);
  font-weight: var(--w-medium);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.kanban-cards {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  flex: 1;
  min-height: 50px;
}

.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-3);
  cursor: grab;
  transition: border-color var(--d-fast) var(--ease-standard),
              box-shadow var(--d-fast) var(--ease-standard),
              transform var(--d-fast) var(--ease-standard);
}
.kanban-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-2);
}
.kanban-card.dragging {
  opacity: 0.5;
  cursor: grabbing;
}
.kanban-card-code {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  color: var(--text-3);
  margin-bottom: 4px;
}
.kanban-card-title {
  font-size: var(--t-sm);
  font-weight: var(--w-medium);
  color: var(--text);
  line-height: var(--lh-snug);
  margin-bottom: var(--s-2);
}
.kanban-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  margin-top: var(--s-2);
  font-size: var(--t-xs);
  color: var(--text-2);
}

.kanban-empty {
  padding: var(--s-5);
  text-align: center;
  font-size: var(--t-xs);
  color: var(--text-3);
  font-style: italic;
}

/* ─── Activity feed ─────────────────────────────────────── */
.activity {
  display: flex;
  flex-direction: column;
}
.activity-row {
  display: flex;
  gap: var(--s-3);
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--border);
}
.activity-row:last-child { border-bottom: none; }
.activity-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent-2);
  margin-top: 8px;
  flex-shrink: 0;
}
.activity-content { flex: 1; min-width: 0; }
.activity-meta {
  font-size: var(--t-xs);
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}
.activity-text {
  font-size: var(--t-sm);
  color: var(--text);
  line-height: var(--lh-snug);
}
.activity-actor {
  font-weight: var(--w-medium);
  color: var(--text);
}

/* ─── Ticket list (rows) ────────────────────────────────── */
.ticket-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.ticket-row {
  display: grid;
  grid-template-columns: 100px 1fr 120px 90px 130px 110px;
  gap: var(--s-4);
  align-items: center;
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background-color var(--d-fast) var(--ease-standard);
}
.ticket-row:last-child { border-bottom: none; }
.ticket-row:hover { background: var(--surface-2); }
.ticket-row.selected {
  background: var(--accent-soft);
  border-left: 2px solid var(--accent);
  padding-left: calc(var(--s-4) - 2px);
}

.ticket-row-code {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  color: var(--text-2);
}
.ticket-row-title {
  font-weight: var(--w-medium);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ticket-row-title .desc {
  font-weight: var(--w-regular);
  color: var(--text-2);
  margin-left: var(--s-2);
}
.ticket-row-meta {
  font-size: var(--t-xs);
  color: var(--text-2);
}

@media (max-width: 980px) {
  .ticket-row {
    grid-template-columns: 1fr auto;
    gap: var(--s-2);
  }
  .ticket-row > *:nth-child(n+3) { display: none; }
}

/* ─── Detail pane ───────────────────────────────────────── */
.detail-empty {
  padding: var(--s-9) var(--s-5);
  text-align: center;
  color: var(--text-3);
  font-size: var(--t-sm);
}

.detail-header {
  margin-bottom: var(--s-5);
}
.detail-code {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  color: var(--text-2);
  margin-bottom: 4px;
}
.detail-title {
  font-size: var(--t-lg);
  font-weight: var(--w-semibold);
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: var(--lh-snug);
}
.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  margin-top: var(--s-3);
  font-size: var(--t-xs);
  color: var(--text-2);
}

/* Property list */
.props {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: var(--s-2) var(--s-4);
  font-size: var(--t-sm);
}
.props dt {
  color: var(--text-2);
  font-weight: var(--w-regular);
  padding-top: 7px;
}
.props dd { color: var(--text); }

/* ─── Toolbar / Filters bar ─────────────────────────────── */
.toolbar {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-3) 0;
  margin-bottom: var(--s-4);
}
.filter-row-top {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
}
.filter-search { flex: 1; min-width: 180px; }
.filter-check { flex-shrink: 0; white-space: nowrap; font-size: var(--t-sm); }
.filter-actions { display: flex; gap: var(--s-1); align-items: center; margin-left: auto; flex-shrink: 0; }
.filter-row-bottom {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
}
.filter-select { flex: 1; min-width: 120px; max-width: 190px; font-size: var(--t-sm); }
@media (max-width: 640px) {
  .filter-select { max-width: none; flex: 1 1 45%; }
  .filter-btn-label { display: none; }
}

/* ─── Dashboard ticket quick-popup ──────────────────────── */
.dash-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.25);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-4);
}
.dash-popup-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-modal);
  padding: var(--s-6);
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}
.dash-popup-close {
  position: absolute;
  top: var(--s-3);
  right: var(--s-3);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-3);
  padding: 4px;
  border-radius: var(--r-sm);
  line-height: 1;
}
.dash-popup-close:hover { color: var(--text); background: var(--surface-2); }

/* ─── Pager ─────────────────────────────────────────────── */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--border);
  font-size: var(--t-sm);
  color: var(--text-2);
}
.pager-info { font-variant-numeric: tabular-nums; }

/* ─── Toast / Notifications ─────────────────────────────── */
.toast-container {
  position: fixed;
  top: var(--s-5);
  right: var(--s-5);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  min-width: 300px;
  max-width: 420px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  animation: slideUp var(--d-base) var(--ease-standard);
}
.toast.closing { animation: fadeOutDown var(--d-base) var(--ease-standard) forwards; }
@keyframes fadeOutDown {
  to { opacity: 0; transform: translateY(8px); }
}

.toast-bar {
  width: 3px;
  align-self: stretch;
  background: var(--neutral);
  border-radius: 2px;
}
.toast.success .toast-bar { background: var(--ok); }
.toast.error .toast-bar   { background: var(--danger); }
.toast.warn .toast-bar    { background: var(--warn); }
.toast.info .toast-bar    { background: var(--info); }

.toast-content { flex: 1; min-width: 0; }
.toast-title {
  font-size: var(--t-sm);
  font-weight: var(--w-semibold);
  color: var(--text);
  margin-bottom: 2px;
}
.toast-msg {
  font-size: var(--t-xs);
  color: var(--text-2);
  line-height: var(--lh-snug);
}
.toast-actions {
  display: flex;
  gap: var(--s-2);
  margin-top: var(--s-2);
}
.toast-close {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  align-self: flex-start;
}
.toast-close:hover { color: var(--text); }

/* ─── Modal ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: rgba(15, 23, 42, 0.50);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-5);
  animation: fadeIn var(--d-base) var(--ease-standard);
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 480px;
  max-height: 86vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: scaleIn var(--d-base) var(--ease-standard);
}
.modal-header {
  padding: var(--s-5);
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-size: var(--t-md);
  font-weight: var(--w-semibold);
}
.modal-body {
  padding: var(--s-5);
  overflow-y: auto;
  flex: 1;
  overscroll-behavior: contain;
}
/* Prevenir scroll de fondo cuando hay modal abierto */
body.modal-open { overflow: hidden; }
.modal-footer {
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--s-2);
  background: var(--surface-2);
}

/* ─── Command palette ───────────────────────────────────── */
.palette-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-palette);
  background: rgba(15, 23, 42, 0.50);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  padding-left: var(--s-4);
  padding-right: var(--s-4);
  animation: fadeIn var(--d-fast) var(--ease-standard);
}
.palette {
  width: 100%;
  max-width: 580px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  animation: scaleIn var(--d-fast) var(--ease-standard);
}
.palette-input {
  width: 100%;
  height: 48px;
  padding: 0 var(--s-5);
  font-size: var(--t-md);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.palette-input:focus { outline: none; }
.palette-input::placeholder { color: var(--text-3); }

.palette-list {
  max-height: 380px;
  overflow-y: auto;
  padding: var(--s-2);
}
.palette-section-label {
  padding: 8px var(--s-3) 6px;
  font-size: var(--t-xs);
  font-weight: var(--w-medium);
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.palette-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 8px var(--s-3);
  border-radius: var(--r-md);
  cursor: pointer;
  font-size: var(--t-sm);
  color: var(--text);
}
.palette-item:hover,
.palette-item.active {
  background: var(--surface-2);
}
.palette-item-icon {
  width: 16px; height: 16px;
  color: var(--text-3);
  flex-shrink: 0;
}
.palette-item-label { flex: 1; min-width: 0; }
.palette-item-label .sub {
  display: block;
  font-size: var(--t-xs);
  color: var(--text-3);
}
.palette-item-meta {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  color: var(--text-3);
}
.palette-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px var(--s-4);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  font-size: var(--t-xs);
  color: var(--text-3);
}
.palette-footer .cluster { gap: var(--s-3); }
.palette-footer .item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ─── Input contraseña con toggle ──────────────────────── */
.input-password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-password-wrap .input {
  width: 100%;
  padding-right: 2.5rem;
}
.input-password-toggle {
  position: absolute;
  right: var(--s-3);
  background: none;
  border: none;
  padding: 2px;
  cursor: pointer;
  color: var(--text-3);
  line-height: 0;
  transition: color var(--d-fast) var(--ease-standard);
  flex-shrink: 0;
}
.input-password-toggle:hover { color: var(--text-2); }

/* ─── Auth screen ───────────────────────────────────────── */
.auth-screen {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-5) var(--s-5) max(var(--s-5), env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--s-7);
  box-shadow: var(--shadow-3);
  animation: slideUp var(--d-base) var(--ease-standard);
}
.auth-brand {
  font-size: var(--t-lg);
  font-weight: var(--w-semibold);
  letter-spacing: -0.025em;
  text-align: center;
  margin-bottom: var(--s-2);
}
.auth-parent-department {
  margin: calc(-1 * var(--s-1)) 0 var(--s-2);
  text-align: center;
  color: var(--accent);
  font-size: var(--t-sm);
  font-weight: var(--w-medium);
}
.auth-tagline {
  font-size: var(--t-sm);
  color: var(--text-2);
  text-align: center;
  margin-bottom: var(--s-6);
}
.auth-public-actions {
  display: flex;
  justify-content: center;
  gap: var(--s-2);
  flex-wrap: wrap;
}
.auth-card .field { margin-bottom: var(--s-3); }
.auth-card .btn-primary { width: 100%; height: 36px; }
.auth-hint {
  font-size: var(--t-xs);
  color: var(--text-3);
  text-align: center;
  margin-top: var(--s-4);
}

/* ─── Empty state ───────────────────────────────────────── */
.empty {
  padding: var(--s-9) var(--s-5);
  text-align: center;
  color: var(--text-2);
}
.empty-icon {
  font-size: 28px;
  margin-bottom: var(--s-3);
  color: var(--text-3);
}
.empty-title {
  font-size: var(--t-md);
  font-weight: var(--w-semibold);
  color: var(--text);
  margin-bottom: 4px;
}
.empty-msg {
  font-size: var(--t-sm);
  color: var(--text-2);
  max-width: 340px;
  margin: 0 auto var(--s-4);
}

/* ─── Tab panels ────────────────────────────────────────── */
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn var(--d-base) var(--ease-standard); }

/* ─── Theme toggle ──────────────────────────────────────── */
.theme-toggle {
  width: 32px; height: 32px;
  border-radius: var(--r-md);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--d-fast) var(--ease-standard);
}
.theme-toggle:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}

/* ─── Charts container ──────────────────────────────────── */
.chart-wrap {
  position: relative;
  height: 280px;
}
.chart-wrap-tall { height: 360px; }

/* ─── Heatmap ───────────────────────────────────────────── */
.heatmap {
  display: grid;
  gap: 3px;
  font-size: var(--t-xs);
}
.heatmap-cell {
  height: 32px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
}
.heatmap-cell[data-level="0"] { background: var(--surface-2); color: var(--text-3); }
.heatmap-cell[data-level="1"] { background: var(--accent-soft); color: var(--accent); }
.heatmap-cell[data-level="2"] { background: rgba(37, 99, 235, 0.18); color: var(--accent); }
.heatmap-cell[data-level="3"] { background: rgba(37, 99, 235, 0.32); color: #fff; }
.heatmap-cell[data-level="4"] { background: var(--accent); color: #fff; }
.heatmap-label {
  display: flex;
  align-items: center;
  font-size: var(--t-xs);
  color: var(--text-2);
  padding-right: var(--s-2);
}

/* ─── Saved views ───────────────────────────────────────── */
.views-bar {
  display: flex;
  gap: var(--s-1);
  padding: var(--s-2) 0;
  flex-wrap: wrap;
  margin-bottom: var(--s-3);
}
.view-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  font-size: var(--t-xs);
  font-weight: var(--w-medium);
  color: var(--text-2);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: all var(--d-fast) var(--ease-standard);
}
.view-chip:hover {
  border-color: var(--border-strong);
  color: var(--text);
}
.view-chip.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

/* ─── Responsive ────────────────────────────────────────── */
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .content { padding: var(--s-5) var(--s-5) max(var(--s-7), env(safe-area-inset-bottom, 0px)); }
  .topbar { padding: 0 var(--s-5); }

  /* Bug fix: sidebar-collapsed se guarda en desktop — resetear en mobile
     para que el drawer siempre muestre texto y no solo íconos */
  .app.sidebar-collapsed .brand-name,
  .app.sidebar-collapsed .brand-tag,
  .app.sidebar-collapsed .sidebar-section-label,
  .app.sidebar-collapsed .nav-item > span,
  .app.sidebar-collapsed .nav-item .nav-kbd,
  .app.sidebar-collapsed .user-pill-identity,
  .app.sidebar-collapsed #presenceSection,
  .app.sidebar-collapsed #btnOpenPalette > span { display: revert; }
  .app.sidebar-collapsed .sidebar-brand > div:first-child { display: revert; }
  .app.sidebar-collapsed .sidebar-brand { justify-content: space-between; }
  .app.sidebar-collapsed .nav-item {
    width: auto; height: auto;
    padding: var(--s-2) var(--s-3);
    justify-content: flex-start;
  }
  .app.sidebar-collapsed .sidebar {
    padding: var(--s-6) var(--s-4);
    align-items: stretch;
    overflow-x: visible;
  }
  .app.sidebar-collapsed .sidebar-section { align-items: stretch; }
  .app.sidebar-collapsed .sidebar-profile { padding: 0; justify-content: flex-start; }
  .app.sidebar-collapsed .sidebar-bottom { align-items: stretch; }
  .app.sidebar-collapsed { grid-template-columns: 1fr; }
}

/* ─── Sidebar colapsable (desktop) ──────────────────────── */
.app.sidebar-collapsed {
  grid-template-columns: var(--sidebar-w-collapsed) 1fr;
}
.app.sidebar-collapsed .sidebar {
  padding: var(--s-4) var(--s-2);
  overflow-x: hidden;
  overflow-y: auto;
  align-items: center;
}
.app.sidebar-collapsed .brand-name,
.app.sidebar-collapsed .brand-tag,
.app.sidebar-collapsed .sidebar-section-label,
.app.sidebar-collapsed .nav-item > span,
.app.sidebar-collapsed .nav-item .nav-kbd,
.app.sidebar-collapsed .user-info,
.app.sidebar-collapsed .user-pill-identity,
.app.sidebar-collapsed #presenceSection,
.app.sidebar-collapsed #btnOpenPalette > span {
  display: none;
}
.app.sidebar-collapsed .sidebar-brand > div:first-child {
  display: none;
}
.app.sidebar-collapsed .sidebar-brand {
  justify-content: center;
}
.app.sidebar-collapsed .nav-item {
  width: 40px;
  height: 40px;
  padding: 0;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
}
.app.sidebar-collapsed .nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.app.sidebar-collapsed .sidebar-section {
  align-items: center;
}
.app.sidebar-collapsed .sidebar-profile {
  display: flex;
  justify-content: center;
  padding: 0;
}
.app.sidebar-collapsed .sidebar-bottom {
  align-items: center;
}
.app.sidebar-collapsed .user-pill,
.app.sidebar-collapsed .user-pill-vertical {
  justify-content: center;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-2) 0;
}
.app.sidebar-collapsed .user-pill-vertical .user-avatar-xl {
  width: 36px;
  height: 36px;
  font-size: var(--t-xs);
  border-width: 2px;
}
.app.sidebar-collapsed #btnOpenPalette {
  width: 40px;
  height: 40px;
  padding: 0;
  justify-content: center;
}
.app.sidebar-collapsed #btnOpenPalette svg {
  width: 18px;
  height: 18px;
}

#btnSidebarToggle { display: none; }
@media (min-width: 981px) {
  #btnSidebarToggle { display: flex; }
}

/* ─── Sidebar mobile drawer ─────────────────────────────── */
#sidebarOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: calc(var(--z-modal) - 10);
}

@media (max-width: 980px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: calc(var(--z-modal) - 5);
    transform: translateX(-100%);
    transition: transform var(--d-base) var(--ease-standard);
    border-right: 1px solid var(--border);
    border-bottom: none;
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
  }
  body.sidebar-open #sidebarOverlay {
    display: block;
  }
  #btnHamburger { display: flex; }
}

@media (min-width: 981px) {
  #btnHamburger { display: none; }
}

@media (max-width: 580px) {
  /* En móvil muy pequeño forzar una columna por si el minmax no alcanza */
  .kanban { grid-template-columns: 1fr; }
}

/* ─── Grid de tarjetas de tickets ───────────────────────── */
.ticket-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--s-3);
}
.ticket-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  cursor: pointer;
  transition: border-color var(--d-fast) var(--ease-standard),
              box-shadow var(--d-fast) var(--ease-standard);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.ticket-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-2);
}
.ticket-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.ticket-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
}
.ticket-card-code {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  color: var(--text-3);
  flex-shrink: 0;
}
.ticket-card-title {
  font-weight: var(--w-medium);
  font-size: var(--t-sm);
  line-height: var(--lh-snug);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ticket-card-desc {
  font-size: var(--t-xs);
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ticket-card-meta {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
  margin-top: var(--s-1);
}
.ticket-card-assignee {
  font-size: var(--t-xs);
  color: var(--text-3);
  margin-left: auto;
}
.ticket-source-chip {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--r-sm);
  font-size: var(--t-xs);
  font-weight: var(--w-semibold);
  border: 1px solid transparent;
}
.ticket-source-chip.source-reception {
  background: rgba(14, 165, 233, .14);
  color: #0369a1;
  border-color: rgba(14, 165, 233, .25);
}
.ticket-source-chip.source-admin,
.ticket-source-chip.source-department_admin {
  background: rgba(124, 58, 237, .14);
  color: #6d28d9;
  border-color: rgba(124, 58, 237, .25);
}
.ticket-source-chip.source-user {
  background: rgba(22, 163, 74, .13);
  color: #15803d;
  border-color: rgba(22, 163, 74, .25);
}
.ticket-source-chip.source-external {
  background: rgba(217, 119, 6, .15);
  color: #b45309;
  border-color: rgba(217, 119, 6, .28);
}
.ticket-card-attach {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--t-xs);
  color: var(--text-3);
  font-family: var(--font-mono);
}

/* ─── Dashboard layout ───────────────────────────────────── */
.dash-grid {
  grid-template-columns: 2fr 1fr;
}

.dashboard-scroll-list {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  padding-right: var(--s-1);
}
.dashboard-scroll-list-sla { height: 360px; }
.dashboard-scroll-list-activity { height: 300px; }
.dashboard-scroll-list-mine { height: 520px; }

.ticket-row.dashboard-sla-row {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-2);
  border-bottom: 1px solid var(--border);
}
.dashboard-ticket-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dashboard-sla-tags {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.dashboard-sla-tags .tag {
  width: max-content;
  max-width: 150px;
  white-space: nowrap;
}

.activity-user-group + .activity-user-group {
  margin-top: var(--s-3);
  padding-top: var(--s-2);
  border-top: 1px solid var(--border);
}
.activity-user-heading {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: var(--s-2) 0;
  background: var(--surface);
  color: var(--accent-2);
  font-size: var(--t-xs);
  font-weight: var(--w-semibold);
  text-transform: uppercase;
}

/* ─── Compact mis tickets (dashboard widget) ─────────────── */
.my-ticket-chip {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--d-fast) var(--ease-standard);
  font-size: var(--t-sm);
}
.my-ticket-chip:hover { background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface-2)); }
.my-ticket-chip-code {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  color: var(--accent);
  flex-shrink: 0;
  min-width: 0;
  font-weight: var(--w-medium);
}
.my-ticket-chip .tag { margin-left: auto; }

@media (max-width: 980px) {
  .ticket-grid { grid-template-columns: 1fr; }
  .dash-grid { grid-template-columns: 1fr; }
  .dash-grid > .stack-lg { order: 2; }
  .dash-grid > article:last-child { order: 1; }
  .dashboard-scroll-list-sla,
  .dashboard-scroll-list-activity,
  .dashboard-scroll-list-mine { height: 320px; }
}

/* ─── Responsive general: topbar y contenido ────────────── */
@media (max-width: 640px) {
  .topbar { padding: 0 var(--s-3); }
  .content { padding: var(--s-3); }
  .page-header { margin-bottom: var(--s-4); }
  .page-title { font-size: var(--t-lg); }
  .metric-value.num { font-size: var(--t-2xl); }
  .grid.g4 { grid-template-columns: repeat(2, 1fr); }
  .ticket-row {
    grid-template-columns: auto 1fr auto;
  }
  .ticket-row > :nth-child(4),
  .ticket-row > :nth-child(5) { display: none; }

  /* Modal — bottom sheet en mobile */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    margin: 0;
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    overflow-y: auto;
  }

  /* Kanban — scroll horizontal táctil */
  .kanban {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: var(--s-3);
    padding-bottom: var(--s-4);
  }
  .kanban-col {
    min-width: 280px;
    max-width: 320px;
    flex-shrink: 0;
    scroll-snap-align: start;
  }

  /* Bulk toolbar — apilar en columna */
  .bulk-toolbar { flex-direction: column; align-items: stretch; }
  .bulk-toolbar .btn, .bulk-toolbar select { width: 100%; }

  /* Notif panel — ancho completo */
  .notif-panel { width: calc(100vw - var(--s-4)); right: calc(var(--s-2) * -1); }

  /* Chat — pantalla completa en móvil */
  .chat-window {
    width: 100%;
    left: 0 !important;
    right: 0 !important;
    bottom: 0;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
  }
}

@media (max-width: 480px) {
  .grid.g3 { grid-template-columns: 1fr; }
  .grid.g4 { grid-template-columns: 1fr 1fr; }
  .modal-body { padding: var(--s-3); }
  .modal-footer { padding: var(--s-3); flex-direction: column; }
  .modal-footer .btn { width: 100%; }
}

/* ─── Adjuntos — lista en detalle de ticket ──────────────── */
.attach-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.attach-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  transition: background var(--d-fast) var(--ease-standard);
}
.attach-item:hover { background: var(--surface); }
.attach-icon { font-size: 1.25rem; flex-shrink: 0; line-height: 1; }
.attach-info { flex: 1; min-width: 0; }
.attach-name {
  font-weight: var(--w-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attach-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* Spinner para preview */
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════════
   CHAT — ventanas flotantes de mensajería directa
═══════════════════════════════════════════════════════════════ */

.chat-window {
  position: fixed;
  bottom: 0;
  width: 300px;
  height: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: 0 -4px 24px rgba(15,23,42,0.18);
  display: flex;
  flex-direction: column;
  z-index: 1150;
  transition: height 200ms var(--ease-standard);
  overflow: hidden;
}
.chat-window.minimized {
  height: 48px;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  flex-shrink: 0;
  gap: var(--s-2);
}
.chat-header-user {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
  flex: 1;
}
.chat-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: var(--w-semibold);
  flex-shrink: 0;
}
.chat-header-info { min-width: 0; }
.chat-header-name {
  font-size: var(--t-sm);
  font-weight: var(--w-semibold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.chat-header-role {
  font-size: 10px;
  color: var(--text-3);
}
.chat-header-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.chat-btn-minimize,
.chat-btn-close {
  width: 22px;
  height: 22px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--text-3);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background var(--d-fast) var(--ease-standard), color var(--d-fast) var(--ease-standard);
  line-height: 1;
}
.chat-btn-minimize:hover { background: var(--surface); color: var(--text); }
.chat-btn-close:hover    { background: rgba(220,38,38,.12); color: var(--danger); }

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-3);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  scroll-behavior: smooth;
}
.chat-loading {
  text-align: center;
  color: var(--text-3);
  font-size: var(--t-xs);
  padding: var(--s-4);
}
.chat-error {
  text-align: center;
  color: var(--danger);
  font-size: 10px;
  padding: 2px 0;
}

.chat-bubble {
  max-width: 85%;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.chat-bubble.mine    { align-self: flex-end; align-items: flex-end; }
.chat-bubble.theirs  { align-self: flex-start; align-items: flex-start; }
.chat-bubble-text {
  padding: 7px 11px;
  border-radius: 14px;
  font-size: var(--t-sm);
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}
.mine   .chat-bubble-text { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.theirs .chat-bubble-text { background: var(--surface-2); color: var(--text); border-bottom-left-radius: 4px; border: 1px solid var(--border); }
.chat-bubble-meta {
  display: flex;
  align-items: center;
  gap: 3px;
}
.chat-bubble-time {
  font-size: 10px;
  color: var(--text-3);
  padding: 0 4px;
}
.chat-load-more {
  text-align: center;
  padding: var(--s-2) 0;
}
.chat-load-more button { font-size: 11px; }

.chat-read-tick {
  font-size: 10px;
  color: var(--text-3);
  opacity: 0.5;
}
.chat-read-tick.seen {
  color: var(--accent, #2563EB);
  opacity: 1;
}

.chat-footer {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  padding: 7px 10px;
  font-size: var(--t-sm);
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color var(--d-fast) var(--ease-standard);
}
.chat-input:focus { border-color: var(--accent); }
.chat-btn-send {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: none;
  cursor: pointer;
  transition: background var(--d-fast) var(--ease-standard);
}
.chat-btn-send:hover { background: var(--accent-hover, #1d4ed8); }
.chat-btn-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Botones emoji y adjuntar ──────────────────────────────── */
.chat-btn-emoji,
.chat-btn-attach {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  font-size: 16px;
  transition: background var(--d-fast) var(--ease-standard), color var(--d-fast) var(--ease-standard);
  padding: 0;
}
.chat-btn-emoji:hover,
.chat-btn-attach:hover { background: var(--surface-2); color: var(--accent); }
.chat-btn-attach input[type="file"] { display: none; }

/* ── Emoji picker ─────────────────────────────────────────── */
.chat-emoji-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 8px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  max-height: 130px;
  overflow-y: auto;
  flex-shrink: 0;
}
.chat-emoji-picker.hidden { display: none; }
.chat-emoji-item {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  font-size: 17px;
  cursor: pointer;
  transition: background var(--d-fast);
  line-height: 1;
  padding: 0;
}
.chat-emoji-item:hover { background: var(--surface-2); }

/* ── Bubble de carga al subir archivo ─────────────────────── */
.chat-bubble-uploading {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-size: var(--t-sm);
  border-bottom-right-radius: 4px;
  max-width: 220px;
}
.chat-bubble-upload-icon { font-size: 18px; flex-shrink: 0; }
.chat-bubble-upload-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
}
.chat-bubble-upload-spin {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  flex-shrink: 0;
  animation: spin 0.7s linear infinite;
}

/* ── Imagen en bubble ─────────────────────────────────────── */
.chat-bubble-img-wrap {
  max-width: 210px;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  background: var(--surface-2);
}
.chat-bubble-img-placeholder {
  width: 180px;
  height: 120px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse-bg 1.2s ease-in-out infinite alternate;
}
@keyframes pulse-bg {
  from { opacity: 0.6; }
  to   { opacity: 1;   }
}
.chat-bubble-img {
  display: block;
  max-width: 210px;
  max-height: 200px;
  width: 100%;
  height: auto;
  object-fit: cover;
  border-radius: 10px;
  cursor: zoom-in;
  transition: opacity 0.2s;
}
.chat-bubble-img:hover { opacity: 0.9; }
.chat-bubble-img-name {
  display: block;
  font-size: 10px;
  padding: 3px 6px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--surface-2);
}

/* ── Documento en bubble ──────────────────────────────────── */
.chat-bubble-doc {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  max-width: 210px;
  transition: background var(--d-fast);
}
.mine .chat-bubble-doc {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.25);
  color: #fff;
}
.chat-bubble-doc:hover { background: var(--surface-3, var(--surface-2)); filter: brightness(0.95); }
.chat-bubble-doc-icon { font-size: 22px; flex-shrink: 0; }
.chat-bubble-doc-info { flex: 1; min-width: 0; }
.chat-bubble-doc-name {
  display: block;
  font-size: 12px;
  font-weight: var(--w-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-bubble-doc-size {
  display: block;
  font-size: 10px;
  color: var(--text-3);
  margin-top: 1px;
}
.mine .chat-bubble-doc-size { color: rgba(255,255,255,0.7); }
.chat-bubble-doc-dl {
  font-size: 14px;
  color: var(--text-3);
  flex-shrink: 0;
}
.mine .chat-bubble-doc-dl { color: rgba(255,255,255,0.8); }

/* ── Lightbox ─────────────────────────────────────────────── */
.chat-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9900;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms var(--ease-standard);
}
.chat-lightbox.active {
  opacity: 1;
  pointer-events: auto;
}
.chat-lightbox-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
}
.chat-lightbox-content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 90vw;
  max-height: 90vh;
}
.chat-lightbox-img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--r-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  display: block;
}
.chat-lightbox-close {
  position: absolute;
  top: -44px;
  right: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--d-fast);
}
.chat-lightbox-close:hover { background: rgba(255,255,255,0.3); }

/* Badge de no leídos en ventana minimizada */
.chat-min-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: var(--w-semibold);
  padding: 0 4px;
  margin-left: 6px;
  vertical-align: middle;
}

/* Badge de no leídos en el item de presencia */
.dm-badge {
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: var(--w-semibold);
  padding: 0 4px;
  margin-left: auto;
  flex-shrink: 0;
}

/* Botón "Enviar mensaje" visible al hacer hover en el item de presencia */
.presence-item .chat-open-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--r-sm);
  border: none;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--d-fast), color var(--d-fast);
}
.presence-item:hover .chat-open-btn { display: flex; }
.presence-item .chat-open-btn:hover { background: var(--surface-2); color: var(--accent); }

/* ── Presence avatar con foto ───────────────────────────────── */
.presence-avatar { position: relative; overflow: hidden; }
.presence-avatar-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}
/* Ocultar las iniciales cuando hay foto cargada */
.presence-avatar[data-has-photo="1"] { color: transparent; font-size: 0; }

/* Estado del día del usuario en el panel de presencia */
.presence-item-status {
  font-size: 10px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: italic;
}

/* ── Notificación DM: pulso en el punto de presencia ─────────── */
@keyframes presence-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.8); }
  60%  { box-shadow: 0 0 0 5px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
.presence-item.has-unread .presence-dot {
  background: #ef4444 !important;
  animation: presence-pulse 1.4s ease-in-out infinite;
}

/* ── Badge pop: escala al recibir nuevo mensaje ──────────────── */
@keyframes badge-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.45); }
  70%  { transform: scale(0.9); }
  100% { transform: scale(1); }
}
.dm-badge.dm-badge-pop {
  animation: badge-pop 0.35s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

/* ─── Time tracking ───────────────────────────────────────── */
.time-entries { display: flex; flex-direction: column; gap: var(--s-1); margin-bottom: var(--s-2); }
.time-entry {
  display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap;
  padding: var(--s-1) var(--s-2);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.time-entry-who { font-weight: var(--w-medium); }
.time-entry-val { color: var(--accent); font-weight: var(--w-semibold); }

/* ─── Relaciones ───────────────────────────────────────────── */
.relation-item {
  display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap;
  padding: var(--s-1) var(--s-2);
  border-radius: var(--radius);
  background: var(--surface-2);
  margin-bottom: var(--s-1);
}

/* ─── Bulk actions toolbar ────────────────────────────────── */
.bulk-toolbar {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
  padding: var(--s-2) var(--s-4);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: var(--s-3);
  animation: fadeIn 0.15s ease;
}
.bulk-checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
  flex-shrink: 0;
  margin-right: var(--s-1);
  accent-color: var(--accent);
}
.ticket-card.bulk-selected {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.select-sm {
  font-size: var(--t-sm);
  padding: 3px 6px;
  height: 28px;
}

/* ─── Autocomplete @menciones ─────────────────────────────── */
.mention-dropdown {
  z-index: var(--z-dropdown, 200);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg, 0 4px 16px rgba(0,0,0,.12));
  overflow: hidden;
  max-height: 200px;
  overflow-y: auto;
}
.mention-item {
  padding: var(--s-2) var(--s-3);
  font-size: var(--t-sm);
  cursor: pointer;
  transition: background 0.1s;
}
.mention-item:hover,
.mention-item.mention-active {
  background: var(--surface-2);
}

/* ─── Notificaciones in-app ───────────────────────────────── */
.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--danger, #DC2626);
  color: #fff;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  pointer-events: none;
  animation: badge-pop 0.35s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

.notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: var(--z-dropdown, 200);
  width: 340px;
  max-height: 420px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 10px);
  box-shadow: var(--shadow-lg, 0 8px 32px rgba(0,0,0,.15));
  overflow: hidden;
}

.notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.notif-list {
  overflow-y: auto;
  flex: 1;
}

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: color-mix(in srgb, var(--accent, #2563EB) 6%, transparent); }
.notif-item.unread:hover { background: color-mix(in srgb, var(--accent, #2563EB) 10%, transparent); }

.notif-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent, #2563EB);
  flex-shrink: 0;
  margin-top: 5px;
}
.notif-item:not(.unread) .notif-dot { background: transparent; }

.notif-item-body { flex: 1; min-width: 0; }
.notif-item-title { font-size: var(--t-sm); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-item-text  { font-size: var(--t-xs); color: var(--text-2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-item-time  { font-size: var(--t-xs); color: var(--text-3); margin-top: 4px; }

/* ─── Control de volumen de notificaciones ───────────────── */
.notif-volume-wrap {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
}
.notif-volume-row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  color: var(--text-3);
}
.notif-volume-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  cursor: pointer;
  accent-color: var(--accent);
}
.notif-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}
.notif-volume-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

/* ─── AI Chat — botón flotante y panel ──────────────────── */
.ai-chat-fab {
  position: fixed;
  bottom: calc(var(--s-5) + var(--chat-offset, 0px));
  right: var(--s-5);
  z-index: 500;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 0 var(--s-4);
  height: 44px;
  border-radius: 22px;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(37,99,235,0.35);
  font-size: var(--t-sm);
  font-weight: var(--w-semibold);
  transition: transform 0.15s, box-shadow 0.15s, bottom 0.2s ease;
  isolation: isolate;
}
.ai-chat-fab:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(37,99,235,0.45); }
.ai-chat-fab-label { font-size: 0.75rem; letter-spacing: 0.04em; }

.ai-chat-panel {
  position: fixed;
  bottom: calc(var(--s-5) + 52px + var(--chat-offset, 0px));
  right: var(--s-5);
  z-index: 501;
  width: 360px;
  max-height: min(520px, calc(100vh - var(--chat-offset, 0px) - 100px));
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.16);
  overflow: hidden;
}

.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.ai-chat-header-info { display: flex; align-items: center; gap: var(--s-2); }
.ai-chat-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ok);
  flex-shrink: 0;
}
.ai-chat-title { font-weight: var(--w-semibold); font-size: var(--t-sm); }
.ai-chat-model { font-size: var(--t-xs); color: var(--text-2); }

.ai-chat-log {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-4);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.ai-welcome {
  text-align: center;
  padding: var(--s-4) var(--s-2);
  color: var(--text-2);
}
.ai-welcome-icon {
  font-size: 1.8rem;
  margin-bottom: var(--s-3);
  color: var(--accent);
}
.ai-welcome p { font-size: var(--t-sm); margin-bottom: var(--s-2); }
.ai-suggestions {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  margin-top: var(--s-3);
}
.ai-suggestion {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-2) var(--s-3);
  font-size: var(--t-xs);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
}
.ai-suggestion:hover { background: var(--bg-hover); }

.ai-msg { display: flex; }
.ai-msg--user     { justify-content: flex-end; }
.ai-msg--assistant { justify-content: flex-start; }

.ai-bubble {
  max-width: 82%;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-lg);
  font-size: var(--t-sm);
  line-height: var(--lh-relaxed);
  white-space: pre-wrap;
  word-break: break-word;
}
.ai-msg--user .ai-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ai-msg--assistant .ai-bubble {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.ai-bubble code {
  background: rgba(0,0,0,0.08);
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 0.85em;
}
.ai-bubble ul { padding-left: var(--s-4); margin: var(--s-1) 0; }

/* Indicador de escritura */
.ai-typing { display: flex; gap: 4px; align-items: center; padding: var(--s-3) !important; }
.ai-typing span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-2);
  animation: ai-bounce 1.2s infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ai-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40%           { transform: translateY(-5px); opacity: 1; }
}

.ai-chat-form {
  display: flex;
  align-items: flex-end;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.ai-chat-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-2) var(--s-3);
  font-size: var(--t-sm);
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  max-height: 100px;
  overflow-y: auto;
  outline: none;
}
.ai-chat-input:focus { border-color: var(--accent); }
.ai-chat-send {
  flex-shrink: 0;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.ai-chat-send:hover { background: var(--accent-hover); filter: brightness(1.1); }
.btn-xs { padding: 2px 6px; font-size: 0.75rem; }

.ai-chat-attach {
  flex-shrink: 0;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: transparent;
  color: var(--text-2);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}
.ai-chat-attach:hover { color: var(--accent); }

/* Preview de imagen antes de enviar */
.ai-img-preview { padding: 0 var(--s-4); }
.ai-img-preview:empty { display: none; }
.ai-img-preview-wrap {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-2) var(--s-3);
  margin-bottom: var(--s-2);
}
.ai-img-thumb {
  width: 40px; height: 40px;
  object-fit: cover;
  border-radius: var(--r-sm);
  flex-shrink: 0;
}
.ai-img-name {
  font-size: var(--t-xs);
  color: var(--text-2);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-img-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-2);
  font-size: 0.9rem;
  padding: 2px;
  line-height: 1;
  flex-shrink: 0;
}
.ai-img-remove:hover { color: var(--danger); }

/* Imagen dentro de una burbuja de chat */
.ai-bubble-img {
  display: block;
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--r-sm);
  margin-bottom: var(--s-2);
  object-fit: contain;
}

@media (max-width: 640px) {
  .ai-chat-panel {
    width: calc(100vw - var(--s-5) * 2);
    right: var(--s-5);
    bottom: calc(var(--s-5) + 52px);
  }
  .notes-fab-panel {
    width: calc(100vw - var(--s-5) * 2);
    right: var(--s-5);
  }
}

/* ─── IA — botones de acción en detalle ─────────────────── */
.ai-action-btn {
  font-size: var(--t-xs);
  color: var(--accent);
  gap: var(--s-1);
}
.ai-action-btn:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }

/* ─── IA — panel de resumen inline ─────────────────────── */
.ai-summary-panel {
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  margin-bottom: var(--s-3);
}
.ai-key-points {
  margin: var(--s-2) 0 0 var(--s-4);
  padding: 0;
  font-size: var(--t-sm);
  color: var(--text-2);
}
.ai-key-points li { margin-bottom: var(--s-1); }

/* ─── IA — badges de acciones ejecutadas en chat ────────── */
.ai-actions-done {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
  margin-top: var(--s-2);
  padding-top: var(--s-2);
  border-top: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
}
.ai-action-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--t-xs);
  font-weight: var(--w-medium);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 9999px;
  padding: 2px 8px;
  cursor: default;
}
/* ═══════════════════════════════════════════════════════════
   NOTAS RÁPIDAS — FAB + Panel
═══════════════════════════════════════════════════════════ */
.notes-fab {
  position: fixed;
  bottom: calc(var(--s-5) + 52px + var(--chat-offset, 0px));
  right: var(--s-5);
  z-index: 500;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 0 var(--s-4);
  height: 44px;
  border-radius: 22px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.14), 0 0 0 1px var(--hairline);
  font-size: var(--t-sm);
  font-weight: var(--w-semibold);
  transition: transform 0.15s, box-shadow 0.15s, bottom 0.2s ease;
  isolation: isolate;
}
.notes-fab:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.20), 0 0 0 1px var(--border-strong); }
.notes-fab-label { font-size: 0.75rem; letter-spacing: 0.04em; }

.notes-fab-panel {
  position: fixed;
  bottom: calc(var(--s-5) + 52px + 52px + var(--chat-offset, 0px));
  right: var(--s-5);
  z-index: 501;
  width: 360px;
  max-height: min(500px, calc(100vh - var(--chat-offset, 0px) - 140px));
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.16);
  overflow: hidden;
}

.notes-fab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.notes-fab-header-info {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  color: var(--text-2);
}
.notes-fab-title { font-weight: var(--w-semibold); font-size: var(--t-sm); color: var(--text); }

.notes-fab-form {
  padding: var(--s-3) var(--s-4);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.notes-fab-body-input { resize: vertical; min-height: 80px; }
.notes-fab-form-actions { display: flex; gap: var(--s-2); }

.notes-fab-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-2) 0;
}

.notes-fab-item {
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border-subtle, var(--border));
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
}
.notes-fab-item:last-child { border-bottom: none; }
.notes-fab-item:hover { background: var(--surface); }
.notes-fab-item-title {
  font-size: var(--t-sm);
  font-weight: var(--w-medium);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 28px;
}
.notes-fab-item-body {
  font-size: var(--t-xs);
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.notes-fab-item-date {
  font-size: 0.7rem;
  color: var(--text-2);
  margin-top: 4px;
}
.notes-fab-item-delete {
  position: absolute;
  top: var(--s-3);
  right: var(--s-3);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-2);
  padding: 2px 4px;
  border-radius: var(--r-sm);
  font-size: 0.85rem;
  line-height: 1;
  display: none;
}
.notes-fab-item:hover .notes-fab-item-delete { display: block; }
.notes-fab-item-delete:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }

.notes-fab-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  padding: var(--s-6);
  color: var(--text-2);
  text-align: center;
  font-size: var(--t-sm);
}

@media (max-width: 640px) {
  .notes-fab-panel {
    width: calc(100vw - var(--s-5) * 2);
    right: var(--s-5);
  }
}

/* ═══════════════════════════════════════════════════════════════
   PLANIFICACIÓN — Calendario + Gantt
   ═══════════════════════════════════════════════════════════════ */
.planner-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}
.planner-range-label {
  font-weight: var(--w-semibold);
  font-size: var(--t-md);
  text-transform: capitalize;
  margin-left: var(--s-2);
  min-width: 9ch;
}

/* ─── Calendario ─────────────────────────────────────────────── */
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  margin-bottom: var(--s-1);
}
.cal-weekday {
  text-align: center;
  font-size: var(--t-xs);
  font-weight: var(--w-semibold);
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: var(--s-1) 0;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 130px;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.cal-cell {
  background: var(--surface);
  padding: var(--s-1) var(--s-2) var(--s-2);
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: 130px;
  overflow: hidden;
}
.cal-cell-muted { background: var(--surface-sunken); }
.cal-cell-muted .cal-daynum { color: var(--text-2); opacity: 0.6; }
.cal-cell-today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-cell-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.cal-daynum {
  font-size: var(--t-sm);
  font-weight: var(--w-semibold);
  color: var(--text-1);
}
.cal-cell-today .cal-daynum {
  background: var(--accent);
  color: #fff;
  border-radius: var(--r-pill);
  min-width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}
.cal-daycount {
  font-size: 0.65rem;
  color: var(--text-2);
  background: var(--surface-2);
  border-radius: var(--r-pill);
  padding: 0 6px;
  line-height: 16px;
}
.cal-cell-body { display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
.cal-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  text-align: left;
  border: none;
  border-left: 3px solid var(--text-2);
  background: var(--surface-2);
  border-radius: var(--r-sm);
  padding: 2px 6px;
  font-size: var(--t-xs);
  color: var(--text-1);
  cursor: pointer;
  transition: filter 0.12s ease;
}
.cal-chip:hover { filter: brightness(0.96); }
.cal-chip-dot { flex-shrink: 0; }
.cal-chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-chip-code { font-family: var(--font-mono, monospace); font-size: 0.67rem; font-weight: var(--w-semibold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-chip.prio-baja    { border-left-color: #16A34A; }
.cal-chip.prio-media   { border-left-color: #2563EB; }
.cal-chip.prio-alta    { border-left-color: #D97706; }
.cal-chip.prio-critica { border-left-color: #DC2626; }
.cal-chip-overdue { background: var(--danger-soft); }
.cal-chip-done { opacity: 0.55; text-decoration: line-through; }
.cal-more { font-size: var(--t-xs); color: var(--text-2); padding-left: 6px; }

/* ─── Gantt ──────────────────────────────────────────────────── */
.gantt-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.gantt-inner { min-width: max-content; }
.gantt-head {
  display: flex;
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.gantt-head-label,
.gantt-label {
  width: 200px;
  flex-shrink: 0;
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
}
.gantt-head-label {
  display: flex;
  align-items: center;
  padding: 0 var(--s-3);
  font-size: var(--t-xs);
  font-weight: var(--w-semibold);
  color: var(--text-2);
  text-transform: uppercase;
}
.gantt-head-days { display: flex; }
.gantt-daycol {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 0;
  border-right: 1px solid var(--border);
  font-size: 0.65rem;
  color: var(--text-2);
}
.gantt-weekend { background: var(--surface-sunken); }
.gantt-today-col { background: var(--accent-soft); }
.gantt-month { font-weight: var(--w-semibold); color: var(--accent); text-transform: capitalize; }
.gantt-daynum { font-weight: var(--w-semibold); color: var(--text-1); }
.gantt-row {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
  min-height: 38px;
}
.gantt-row:last-child { border-bottom: none; }
.gantt-label {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  padding: 4px var(--s-3);
  border: none;
  border-right: 1px solid var(--border);
  text-align: left;
  cursor: pointer;
}
.gantt-label:hover { background: var(--surface); }
.gantt-label-code { font-size: 0.65rem; color: var(--text-2); }
.gantt-label-title {
  font-size: var(--t-xs);
  color: var(--text-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 168px;
}
.gantt-track { position: relative; flex-shrink: 0; }
.gantt-bar {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 22px;
  border: none;
  border-radius: var(--r-pill);
  background: #2563EB;
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 8px;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.18);
  transition: filter 0.12s ease;
}
.gantt-bar:hover { filter: brightness(1.06); }
.gantt-bar-text {
  font-size: 0.65rem;
  font-weight: var(--w-semibold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gantt-bar.prio-baja    { background: #16A34A; }
.gantt-bar.prio-media   { background: #2563EB; }
.gantt-bar.prio-alta    { background: #D97706; }
.gantt-bar.prio-critica { background: #DC2626; }
.gantt-bar-overdue { box-shadow: 0 0 0 2px var(--danger); }
.gantt-bar-done { opacity: 0.5; }
.gantt-empty,
.notes-empty { padding: var(--s-8) var(--s-4); text-align: center; color: var(--text-2); }

/* ═══════════════════════════════════════════════════════════════
   NOTAS
   ═══════════════════════════════════════════════════════════════ */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--s-3);
  align-items: start;
}
.note-card {
  --note-accent: var(--border-strong);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--note-accent);
  border-radius: var(--r-lg);
  padding: var(--s-3);
  min-height: 120px;
  transition: box-shadow 0.12s ease;
}
.note-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.08); }
.note-pinned { box-shadow: 0 0 0 1px var(--accent-ring); }
.note-color-amarillo { --note-accent: #F59E0B; background: color-mix(in srgb, #F59E0B 12%, var(--surface)); }
.note-color-verde    { --note-accent: #10B981; background: color-mix(in srgb, #10B981 12%, var(--surface)); }
.note-color-azul     { --note-accent: #3B82F6; background: color-mix(in srgb, #3B82F6 12%, var(--surface)); }
.note-color-rosa     { --note-accent: #EC4899; background: color-mix(in srgb, #EC4899 12%, var(--surface)); }
.note-color-morado   { --note-accent: #8B5CF6; background: color-mix(in srgb, #8B5CF6 12%, var(--surface)); }
.note-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-2);
}
.note-card-title {
  font-size: var(--t-base);
  font-weight: var(--w-semibold);
  color: var(--text-1);
  margin: 0;
  word-break: break-word;
}
.note-pin-btn {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  padding: 2px;
  border-radius: var(--r-sm);
}
.note-pin-btn:hover { background: var(--surface-2); color: var(--text-1); }
.note-pin-btn.is-pinned { color: var(--accent); }
.note-card-body {
  flex: 1;
  font-size: var(--t-sm);
  color: var(--text-1);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow-y: auto;
  line-height: 1.45;
}

/* ── Imágenes dentro de notas ─────────────────────────────── */
.note-img {
  display: block;
  max-width: 100%;
  max-height: 160px;
  object-fit: cover;
  border-radius: var(--r-md);
  margin: var(--s-2) 0;
  cursor: zoom-in;
  transition: opacity 0.2s;
}
.note-img:hover { opacity: 0.88; }
.note-converted-badge {
  align-self: flex-start;
  font-size: var(--t-xs);
  font-weight: var(--w-semibold);
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-ring);
  border-radius: var(--r-pill);
  padding: 2px 10px;
  cursor: pointer;
}
.note-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  border-top: 1px solid var(--border);
  padding-top: var(--s-2);
}
.note-card-actions { display: flex; align-items: center; gap: 2px; }
.note-del-btn:hover { color: var(--danger); }
.notes-empty-icon { font-size: 2.5rem; }
.notes-empty-title { font-weight: var(--w-semibold); color: var(--text-1); margin: var(--s-2) 0 0; }

/* Directory */
.directory-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(190px, 280px) auto;
  gap: var(--s-3);
  align-items: center;
  margin-bottom: var(--s-4);
}
.directory-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
.directory-group {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}
.directory-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.directory-group-head h2 {
  margin: 0;
  font-size: var(--t-base);
  font-weight: var(--w-semibold);
  color: var(--text-1);
}
.directory-table-wrap { overflow-x: auto; }
.directory-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: var(--t-sm);
}
.directory-table th {
  padding: 8px 10px;
  text-align: left;
  color: var(--text-2);
  font-size: var(--t-xs);
  font-weight: var(--w-semibold);
  text-transform: uppercase;
}
.directory-table td {
  padding: 10px;
  border-top: 1px solid var(--border);
  vertical-align: top;
}
.directory-table tbody tr:first-child td { border-top: 0; }
.directory-table tr.is-inactive { opacity: .56; }
.directory-contact-name {
  font-weight: var(--w-semibold);
  color: var(--text-1);
}
.directory-contact-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-top: 2px;
  font-size: var(--t-xs);
  color: var(--text-2);
}
.directory-custom-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 340px;
}
.directory-mini-chip,
.directory-linked-chip,
.directory-child-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  padding: 2px 8px;
  font-size: var(--t-xs);
  color: var(--text-1);
}
.directory-actions {
  white-space: nowrap;
  text-align: right;
}
.directory-empty {
  padding: var(--s-8) var(--s-4);
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
}
.directory-config-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  margin-top: var(--s-3);
}
.directory-config-item {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-3);
  background: var(--surface);
}
.directory-config-item.is-inactive { opacity: .55; }
.directory-config-main {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--s-2);
}
.directory-config-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--s-2);
  margin-top: var(--s-2);
}
.directory-child-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
  margin-top: var(--s-2);
}
.directory-child-chip button,
.directory-linked-chip button {
  border: 0;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  padding: 0 2px;
}
.directory-child-chip button:hover,
.directory-linked-chip button:hover { color: var(--danger); }
.directory-field-form {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(140px, 1fr) 130px minmax(170px, 1fr) auto auto;
  gap: var(--s-2);
  align-items: center;
}
.directory-linked {
  margin-top: var(--s-3);
  padding-top: var(--s-3);
  border-top: 1px solid var(--border);
}
.directory-linked-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
  margin-top: var(--s-2);
}

/* ─── Selector de color en el modal de nota ──────────────────── */
.note-color-picker { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.note-color-swatch {
  width: 28px;
  height: 28px;
  border-radius: var(--r-pill);
  border: 2px solid var(--border);
  cursor: pointer;
  padding: 0;
  background: var(--surface-2);
}
.note-color-swatch[data-color="amarillo"] { background: #F59E0B; }
.note-color-swatch[data-color="verde"]    { background: #10B981; }
.note-color-swatch[data-color="azul"]     { background: #3B82F6; }
.note-color-swatch[data-color="rosa"]     { background: #EC4899; }
.note-color-swatch[data-color="morado"]   { background: #8B5CF6; }
.note-color-swatch.is-active {
  border-color: var(--text-1);
  box-shadow: 0 0 0 2px var(--accent-ring);
}

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  .cal-grid { grid-auto-rows: 90px; }
  .cal-cell { height: 90px; }
  .cal-chip-text { font-size: 0.65rem; }
  .gantt-head-label, .gantt-label { width: 130px; }
  .gantt-label-title { max-width: 100px; }
  .directory-toolbar { grid-template-columns: 1fr; }
  .directory-field-form { grid-template-columns: 1fr; }
}
