:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-subtle: #fafbfd;
  --chip-bg: #f1f2f6;
  --chip-bg-hover: #e2e5ee;
  --accent-subtle: #eef2ff;
  --accent-subtle-hover: #e0e7ff;
  --border: #e2e6f0;
  --text: #1f2430;
  --text-muted: #6b7280;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --ok: #059669;
  --ok-bg: #d1fae5;
  --pending: #d97706;
  --pending-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --danger-bg-hover: #fecaca;
  --radius: 10px;
  --scrim: rgba(15, 18, 30, 0.35);
  --scrim-strong: rgba(15, 18, 30, 0.45);
  --shadow: rgba(15, 18, 30, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1e293b;
    --surface: #2a3b52;
    --surface-subtle: #253449;
    --chip-bg: #334155;
    --chip-bg-hover: #3e4f68;
    --accent-subtle: #2d3c58;
    --accent-subtle-hover: #37496b;
    --border: #3e4f68;
    --text: #e8ecf5;
    --text-muted: #9aa7bd;
    --primary: #818cf8;
    --primary-hover: #a5b4fc;
    --ok: #34d399;
    --ok-bg: #0f3d2e;
    --pending: #fbbf24;
    --pending-bg: #4a3411;
    --danger: #f87171;
    --danger-bg: #4c1d1d;
    --danger-bg-hover: #5c2424;
    --scrim: rgba(0, 0, 0, 0.55);
    --scrim-strong: rgba(0, 0, 0, 0.65);
    --shadow: rgba(0, 0, 0, 0.35);
  }
}

/* Tema elegido a mano (botón en la barra de navegación) — gana siempre por
   sobre la preferencia del sistema operativo, en cualquiera de los dos sentidos. */
:root[data-theme="dark"] {
  --bg: #1e293b;
  --surface: #2a3b52;
  --surface-subtle: #253449;
  --chip-bg: #334155;
  --chip-bg-hover: #3e4f68;
  --accent-subtle: #2d3c58;
  --accent-subtle-hover: #37496b;
  --border: #3e4f68;
  --text: #e8ecf5;
  --text-muted: #9aa7bd;
  --primary: #818cf8;
  --primary-hover: #a5b4fc;
  --ok: #34d399;
  --ok-bg: #0f3d2e;
  --pending: #fbbf24;
  --pending-bg: #4a3411;
  --danger: #f87171;
  --danger-bg: #4c1d1d;
  --danger-bg-hover: #5c2424;
  --scrim: rgba(0, 0, 0, 0.55);
  --scrim-strong: rgba(0, 0, 0, 0.65);
  --shadow: rgba(0, 0, 0, 0.35);
}
:root[data-theme="light"] {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-subtle: #fafbfd;
  --chip-bg: #f1f2f6;
  --chip-bg-hover: #e2e5ee;
  --accent-subtle: #eef2ff;
  --accent-subtle-hover: #e0e7ff;
  --border: #e2e6f0;
  --text: #1f2430;
  --text-muted: #6b7280;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --ok: #059669;
  --ok-bg: #d1fae5;
  --pending: #d97706;
  --pending-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --danger-bg-hover: #fecaca;
  --scrim: rgba(15, 18, 30, 0.35);
  --scrim-strong: rgba(15, 18, 30, 0.45);
  --shadow: rgba(15, 18, 30, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.navbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.navbar-brand a { font-weight: 700; font-size: 18px; color: var(--text); }
.navbar-links { display: flex; gap: 18px; flex: 1; }
.navbar-links a { color: var(--text-muted); font-weight: 500; }
.navbar-user { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 14px; }
.role-tag {
  display: inline-block;
  background: var(--accent-subtle);
  color: var(--primary);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  margin-left: 4px;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.page-head h1 { margin: 0; font-size: 24px; }
.page-head-actions { display: flex; align-items: center; gap: 12px; }

.view-switcher {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.view-switch-btn {
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  text-decoration: none;
}
.view-switch-btn:hover { background: var(--bg); text-decoration: none; }
.view-switch-btn + .view-switch-btn { border-left: 1px solid var(--border); }
.view-switch-btn.active { background: var(--primary); color: #fff; }
.view-switch-btn.active:hover { background: var(--primary); }

/* --- "+ Agregar" (proyecto / grupo) en /proyectos --- */
.add-dropdown { position: relative; }
.add-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  z-index: 30;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  padding: 6px;
}
.add-dropdown-menu.open { display: block; }
.add-dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.add-dropdown-item:hover { background: var(--chip-bg); }

/* --- Barra flotante de selección múltiple en /proyectos --- */
.bulk-bar {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 45;
  align-items: center;
  gap: 16px;
  font-size: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
  padding: 10px 16px;
}
.bulk-bar.open { display: flex; }
.bulk-bar-actions { display: flex; gap: 8px; }

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-number { font-size: 28px; font-weight: 700; }
.stat-label { color: var(--text-muted); font-size: 13px; }

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table th, .table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.table th {
  background: var(--surface-subtle);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.04em;
}
.table tr:last-child td { border-bottom: none; }
.empty-row { text-align: center; color: var(--text-muted); padding: 24px; }

.row-priority-baja { background: color-mix(in srgb, #0369a1 12%, var(--surface)); }
.row-priority-baja td:first-child { border-left: 3px solid #0369a1; }
.row-priority-media { background: var(--accent-subtle); }
.row-priority-media td:first-child { border-left: 3px solid var(--primary); }
.row-priority-alta { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); }
.row-priority-alta td:first-child { border-left: 3px solid var(--danger); }
.row-priority-critica { background: color-mix(in srgb, #831843 18%, var(--surface)); }
.row-priority-critica td:first-child { border-left: 3px solid #831843; }

.row-status-pendiente { background: var(--pending-bg); }
.row-status-pendiente td:first-child { border-left: 3px solid var(--pending); }
.row-status-en_desarrollo { background: color-mix(in srgb, #2563eb 14%, var(--surface)); }
.row-status-en_desarrollo td:first-child { border-left: 3px solid #2563eb; }
.row-status-resuelto { background: var(--ok-bg); }
.row-status-resuelto td:first-child { border-left: 3px solid var(--ok); }
.row-status-cerrado { background: var(--chip-bg); }
.row-status-cerrado td:first-child { border-left: 3px solid var(--text-muted); }

.category-group { margin-bottom: 16px; }
.category-group-header {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--accent-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 8px;
}
.category-group-header:hover { background: var(--accent-subtle-hover); }
.category-group[open] .category-group-header { border-radius: 8px 8px 0 0; margin-bottom: 0; }
.category-group[open] .table { border-top-left-radius: 0; border-top-right-radius: 0; }

.ticket-desc { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-pending { background: var(--pending-bg); color: var(--pending); }
.badge-empty { background: var(--chip-bg); color: var(--text-muted); }
.badge-priority-baja { background: color-mix(in srgb, #0369a1 20%, var(--surface)); color: #0369a1; }
.badge-priority-media { background: var(--accent-subtle); color: var(--primary-hover); }
.badge-priority-alta { background: var(--danger-bg); color: var(--danger); }
.badge-priority-critica { background: #831843; color: #fce7f3; }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--pending-bg); color: var(--pending); }
.badge-progress { background: color-mix(in srgb, #2563eb 20%, var(--surface)); color: #2563eb; }

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--chip-bg); color: var(--text); }
.btn-secondary:hover { background: var(--chip-bg-hover); }
.btn-small { padding: 6px 12px; font-size: 12px; }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg-hover); }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-reset-form { display: flex; gap: 6px; }
.inline-reset-form input {
  width: 130px;
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.link-button {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
}
.link-button:hover { text-decoration: underline; }

.form { display: flex; flex-direction: column; gap: 14px; }
.form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}
.form label[hidden] { display: none; }
input:not([type="checkbox"]):not([type="radio"]), textarea, select {
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
}
input:not([type="checkbox"]):not([type="radio"]):focus, textarea:focus, select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.auth-card {
  max-width: 380px;
  margin: 60px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}
.auth-card h1 { margin-top: 0; font-size: 22px; }
.auth-alt { margin-top: 16px; font-size: 13px; color: var(--text-muted); text-align: center; }

.alert {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
}
.alert-success { background: var(--ok-bg); color: var(--ok); }

.text-muted { color: var(--text-muted); font-size: 13px; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.card h3 { margin-top: 0; }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row label { flex: 1; min-width: 120px; }

.cliente-picker { display: flex; gap: 12px; flex-wrap: wrap; flex: 1; min-width: 120px; }
.cliente-picker label { flex: 1; min-width: 120px; }

.monday-fieldset {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.monday-fieldset legend {
  padding: 0 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

.checkbox-row { display: flex; gap: 14px; flex-wrap: wrap; }
.member-search-input { margin-bottom: -2px; }
.member-checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 4px;
}
.checkbox-label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  text-transform: none;
  color: var(--text);
}
.checkbox-label input { width: auto; padding: 0; }

.code-block {
  background: #101423;
  color: #e6e8f0;
  padding: 14px;
  border-radius: 8px;
  font-size: 12.5px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.ticket-meta-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.ticket-description { white-space: pre-wrap; margin-bottom: 16px; }
.attachment-list { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.attachment-link {
  color: var(--primary);
  text-decoration: none;
  font-size: 0.9em;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  width: fit-content;
}
.attachment-link:hover { text-decoration: underline; }
.ticket-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  font-size: 14px;
}

.comment-thread { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.comment {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--surface-subtle);
}
.comment-cliente { background: var(--accent-subtle); border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.comment-borrador { background: var(--pending-bg); border-color: color-mix(in srgb, var(--pending) 45%, var(--border)); }
.approval-actions { display: flex; gap: 10px; align-items: flex-end; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.approval-actions textarea { width: 100%; font-size: 13px; }
.comment-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 13px; }
.comment p { margin: 0; white-space: pre-wrap; font-size: 14px; }

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.side-panel-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--scrim);
  z-index: 50;
}
.side-panel-backdrop.open { display: block; }
.side-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 480px;
  max-width: 92vw;
  background: var(--surface);
  box-shadow: -8px 0 24px var(--shadow);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.2s ease;
}
.side-panel-backdrop.open .side-panel { transform: translateX(0); }
.side-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.side-panel-header h3 { margin: 0; font-size: 16px; }
.side-panel-close {
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
}
.side-panel-close:hover { color: var(--text); }
.side-panel-body { flex: 1; overflow-y: auto; padding: 20px; }

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--scrim-strong);
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 440px;
}
.modal h2 { margin-top: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

.dropzone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 18px;
  text-align: center;
  cursor: pointer;
  background: var(--surface-subtle);
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.dropzone-over {
  border-color: var(--primary);
  background: var(--accent-subtle);
}
.dropzone-input { display: none; }
.dropzone-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}
.dropzone-icon { font-size: 18px; }
.dropzone-browse { color: var(--primary); text-decoration: underline; }
.dropzone-filelist {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  text-align: left;
}
.dropzone-filelist li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
}

a.stat-card {
  text-decoration: none;
  color: inherit;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
a.stat-card:hover {
  text-decoration: none;
  transform: translateY(-3px);
  box-shadow: 0 6px 14px var(--shadow);
}
.stat-card-color { border: none; color: #fff; }
.stat-card-color .stat-label { color: rgba(255, 255, 255, 0.85); }
.stat-card-blue { background: linear-gradient(135deg, #60a5fa, #2563eb); }
.stat-card-red { background: linear-gradient(135deg, #f87171, #dc2626); }
.stat-card-yellow { background: linear-gradient(135deg, #fbbf24, #d97706); }
.stat-card-green { background: linear-gradient(135deg, #34d399, #059669); }
.stat-card-purple { background: linear-gradient(135deg, #a78bfa, #7c3aed); }
.stat-card-teal { background: linear-gradient(135deg, #2dd4bf, #0d9488); }

.board {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: 8px;
}
.board-column {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 280px;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 220px);
}
.board-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: var(--radius) var(--radius) 0 0;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
}
.board-col-pendiente { background: linear-gradient(135deg, #fbbf24, #d97706); }
.board-col-desarrollo { background: linear-gradient(135deg, #60a5fa, #2563eb); }
.board-col-resuelto { background: linear-gradient(135deg, #34d399, #059669); }
.board-col-cerrado { background: linear-gradient(135deg, #9ca3af, #6b7280); }
.board-column-count {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 12px;
}
.board-column-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  overflow-y: auto;
}
.board-column-empty { color: var(--text-muted); font-size: 13px; text-align: center; padding: 12px 0; }
.board-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 1px 2px var(--shadow);
}
.board-card-title { font-weight: 600; font-size: 14px; color: var(--text); }
.board-card-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.board-card-category, .board-card-assignee { font-size: 12px; color: var(--text-muted); }
.board-card-actions { display: flex; align-items: center; gap: 10px; margin-top: 2px; }
.board-card-actions form { display: inline; }
.board-card[draggable="true"] { cursor: grab; }
.board-card.dragging { opacity: 0.4; }
.board-card.board-card-moving { opacity: 0.5; pointer-events: none; }
.board-column-body-over { background: var(--accent-subtle); outline: 2px dashed var(--primary); outline-offset: -2px; }

.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.cal-nav-label { margin: 0; font-size: 17px; text-transform: capitalize; }

.cal-month-grid {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  table-layout: fixed;
}
.cal-month-grid th {
  background: var(--surface-subtle);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 10px;
  border-bottom: 1px solid var(--border);
}
.cal-day-cell {
  height: 84px;
  vertical-align: top;
  border: 1px solid var(--border);
  padding: 0;
}
.cal-day-empty { background: var(--surface-subtle); }
.cal-day-today { background: var(--accent-subtle); }
.cal-day-link {
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100%;
  padding: 8px;
  color: var(--text);
}
.cal-day-link:hover { background: var(--bg); text-decoration: none; }
.cal-day-number { font-weight: 600; font-size: 13px; }
.cal-day-badge { align-self: flex-start; }

.cal-week-scroll { overflow-x: auto; margin-bottom: 20px; }
.cal-week-grid {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.cal-week-grid th {
  background: var(--surface-subtle);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.cal-time-col { width: 60px; font-size: 12px; color: var(--text-muted); text-align: center; white-space: nowrap; }
.cal-slot-cell {
  border: 1px solid var(--border);
  padding: 4px 6px;
  height: 30px;
  font-size: 12px;
  vertical-align: top;
}
.cal-slot-free { text-align: center; }
.cal-slot-free a {
  display: block;
  color: var(--text-muted);
  opacity: 0;
}
.cal-slot-free:hover { background: var(--bg); }
.cal-slot-free:hover a { opacity: 1; }
.cal-slot-booked { background: var(--accent-subtle); }
.cal-slot-continuation { border-top: none; }
.cal-booking-title { font-weight: 600; font-size: 12px; }
.cal-booking-user { color: var(--text-muted); font-size: 11px; }
.cal-cancel-btn { font-size: 11px; }

@media (max-width: 640px) {
  .navbar { flex-wrap: wrap; gap: 10px; }
  .container { padding: 20px 12px 40px; }
  .table { display: block; overflow-x: auto; }
}

/* --- CRM ventas: extras --- */

.board-card-uf { font-weight: 700; font-size: 14px; color: var(--text); }
.board-card-cliente { font-size: 12px; color: var(--text-muted); }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kpi-label { color: var(--text-muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.kpi-value { font-size: 30px; font-weight: 700; }
.kpi-sub { font-size: 12px; color: var(--text-muted); }

.gauge-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.gauge-value { font-size: 22px; font-weight: 700; }
.gauge-target { font-size: 12px; color: var(--text-muted); }
.gauge-bar-track {
  width: 100%;
  height: 14px;
  border-radius: 999px;
  background: var(--chip-bg);
  overflow: hidden;
}
.gauge-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #34d399, #059669);
  transition: width 0.3s ease;
}

.especialidad-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}

.uf-cell { font-weight: 600; text-align: right; }
.table td.uf-cell, .table th.uf-cell { text-align: right; }

.meta-form { display: flex; gap: 10px; align-items: flex-end; margin-bottom: 20px; }
.meta-form label { flex: 1; max-width: 220px; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.detail-field { display: flex; flex-direction: column; gap: 4px; }
.detail-field-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); font-weight: 700; }
.detail-field-value { font-size: 14px; word-break: break-word; white-space: pre-wrap; }

.pipeline-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  color: var(--text);
}
.theme-toggle:hover { background: var(--chip-bg); }

.color-swatch-picker { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}
.color-swatch:hover { border-color: var(--text-muted); }
.color-swatch.selected { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--text); }
.color-swatch-auto {
  width: auto;
  height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 600;
  background: var(--chip-bg);
  color: var(--text-muted);
}

.editable-cell {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 6px;
  width: 100%;
  background: transparent;
  color: var(--text);
  font: inherit;
}
.editable-cell:hover { border-color: var(--border); }
.editable-cell:focus { border-color: var(--primary); outline: none; background: var(--surface); }
.editable-cell-saved { animation: editableSaved 0.9s ease; }
@keyframes editableSaved {
  0% { background: var(--ok-bg); }
  100% { background: transparent; }
}
td.editable-td { padding: 4px 6px; }

.layout-with-sidebar {
  display: flex;
  align-items: flex-start;
}
.layout-with-sidebar .container {
  flex: 1;
  min-width: 0;
  max-width: none;
  margin: 0;
}
.sidebar {
  /* Ancho ajustable arrastrando .sidebar-resize-handle; --sidebar-width lo
     fija un script inline en <head> (antes del primer paint, para no "saltar"
     al cargar) leyendo lo último guardado en localStorage. */
  width: var(--sidebar-width, 260px);
  min-width: 180px;
  max-width: 480px;
  flex-shrink: 0;
  position: relative;
  background: var(--surface);
  border-right: 1px solid var(--border);
  min-height: calc(100vh - 65px);
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-resize-handle {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 40;
}
.sidebar-resize-handle:hover, .sidebar-resize-handle.dragging { background: var(--primary); opacity: 0.35; }
.sidebar-header {
  padding: 0 20px 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.sidebar-nav { display: flex; flex-direction: column; }
.sidebar-nav form { display: contents; }
.sidebar-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-left: 3px solid transparent;
  padding: 10px 20px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}
.sidebar-item:hover { background: var(--chip-bg); }
.sidebar-item.active { background: var(--accent-subtle); border-left-color: var(--primary); font-weight: 600; color: var(--primary); }
.sidebar-manage-link {
  margin: 12px 20px 0;
  font-size: 12px;
  color: var(--text-muted);
}

@media (max-width: 780px) {
  .layout-with-sidebar { flex-direction: column; }
  .sidebar { width: 100%; min-width: 0; max-width: none; min-height: auto; flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border); padding: 10px 0; }
  .sidebar-resize-handle { display: none; }
  .sidebar-header { display: none; }
  .sidebar-item { border-left: none; border-bottom: 3px solid transparent; white-space: nowrap; }
  .sidebar-item.active { border-left-color: transparent; border-bottom-color: var(--primary); }
  .sidebar-manage-link { margin: 0 12px; white-space: nowrap; align-self: center; }
}

/* --- Equipos / acceso por tablero --- */
.sidebar-group-label {
  margin: 10px 20px 2px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 700;
}
.check-inline { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check-inline input { width: auto; margin: 0; }
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px 14px;
  margin: 6px 0 4px;
}
@media (max-width: 780px) {
  .sidebar-group-label { display: none; }
}

/* --- Menú lateral: equipos desplegables --- */
.sidebar-team { border-bottom: 1px solid var(--border); }
.sidebar-team > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 20px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  user-select: none;
}
.sidebar-team > summary::-webkit-details-marker { display: none; }
.sidebar-team > summary::before {
  content: "▸";
  font-size: 10px;
  transition: transform 0.15s ease;
  color: var(--text-muted);
}
.sidebar-team[open] > summary::before { transform: rotate(90deg); }
.sidebar-team > summary:hover { color: var(--text); background: var(--chip-bg); }
.sidebar-team-count {
  margin-left: auto;
  background: var(--chip-bg);
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 11px;
}
.sidebar-team[open] { padding-bottom: 6px; }
.sidebar-team-archived summary { opacity: 0.7; }
@media (max-width: 780px) {
  .sidebar-team { border-bottom: none; }
  .sidebar-team > summary { padding: 8px 12px; }
}

/* --- Menú "..." de cada tablero (mover/duplicar/archivar/eliminar/favorito) --- */
.sidebar-item-row { display: flex; align-items: stretch; }
.sidebar-item-row .sidebar-item { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-kebab-wrap { position: relative; flex-shrink: 0; }
.sidebar-kebab {
  height: 100%;
  padding: 0 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.sidebar-kebab:hover { background: var(--chip-bg); color: var(--text); }
.sidebar-kebab-menu {
  /* `fixed`, no `absolute`: el sidebar tiene overflow propio en mobile
     (ver media query más abajo) que recortaría el menú si dependiera de la
     posición de su contenedor. La posición real (top/right) la calcula
     app.js al abrirlo, relativa al botón "..." y al viewport. */
  display: none;
  position: fixed;
  z-index: 50;
  min-width: 210px;
  max-height: calc(100vh - 20px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  padding: 6px;
}
.sidebar-kebab-menu.open { display: block; }
.kebab-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}
.kebab-item:hover { background: var(--chip-bg); }
.kebab-item-danger { color: var(--danger); }
.kebab-select-label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-muted);
}
.kebab-select-label select { width: 100%; }
@media (max-width: 780px) {
  .sidebar-item-row { display: inline-flex; }
}

/* --- Menú ⋮ de encabezado de columna (vista Tabla) --- */
.th-col { display: flex; align-items: center; gap: 6px; }
.th-col-label { flex: 1; white-space: nowrap; }
.th-lock { font-size: 11px; }
.col-menu-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.12s ease, background 0.12s ease;
}
th:hover .col-menu-btn { opacity: 0.7; }
.col-menu-btn:hover { opacity: 1; background: var(--chip-bg); color: var(--text); }
.col-menu {
  position: absolute;
  z-index: 80;
  min-width: 210px;
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.col-menu[hidden] { display: none; }
.col-menu-item {
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.col-menu-item:hover { background: var(--chip-bg); }
.col-menu-item-danger { color: #dc2626; }
.col-menu-item-danger:hover { background: #dc26261a; }

/* ===== Barra superior unificada SolucionIT (switch de sistemas) ===== */
.topbar { display: flex; align-items: center; gap: 20px; padding: 10px 20px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 60; flex-wrap: wrap; }
.topbar-brand { font-weight: 700; font-size: 16px; white-space: nowrap; color: var(--text); }
.topbar-sys { display: flex; gap: 6px; flex-wrap: wrap; }
.topbar-sys a { padding: 7px 14px; border-radius: 8px; color: var(--text-muted); font-weight: 600; text-decoration: none; }
.topbar-sys a:hover { background: var(--chip-bg); }
.topbar-sys a.active { background: var(--primary); color: #fff; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 14px; flex-wrap: wrap; }
.topbar-link { color: var(--text-muted); font-weight: 600; text-decoration: none; }
.topbar-link:hover { color: var(--text); }
.topbar-user { white-space: nowrap; }
@media (max-width: 768px) {
  .topbar { gap: 10px; padding: 8px 12px; }
  .topbar-user { display: none; }
}

/* paginación de la Tabla (tableros grandes, ej. Cotizaciones) */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin: 14px 0; padding: 10px 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; }
.pager-btns { display: flex; gap: 6px; flex-wrap: wrap; }
