:root {
  --bg: #0c0d12;
  --surface: #16171f;
  --surface-2: #1d1f2a;
  --surface-hover: #23252f;
  --border: #2a2c38;
  --border-soft: #22242e;
  --text: #e9eaef;
  --text-muted: #8d90a3;
  --text-faint: #5c5f70;

  --primary: #7c6cf5;
  --primary-dark: #6a59e8;
  --primary-soft: rgba(124, 108, 245, 0.16);
  --primary-border: rgba(124, 108, 245, 0.35);

  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.14);
  --danger-border: rgba(248, 113, 113, 0.3);

  --success: #34d399;
  --success-bg: rgba(52, 211, 153, 0.14);

  --warning: #fbbf24;
  --warning-bg: rgba(251, 191, 36, 0.14);

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(124, 108, 245, 0.09), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: #9689f8; text-decoration: none; }

h1 { font-size: 1.5rem; margin: 0 0 1rem; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; margin: 0 0 0.9rem; font-weight: 600; color: var(--text); }

/* App shell: sidebar + content */
.app-shell {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}

.sidebar {
  flex: 0 0 236px;
  width: 236px;
  background: var(--surface);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  transition: flex-basis 0.15s ease, width 0.15s ease;
  z-index: 10;
}
.sidebar-collapsed .sidebar { flex-basis: 68px; width: 68px; }

.sidebar-top {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border-soft);
  flex: 0 0 auto;
}
.sidebar-brand { display: flex; align-items: center; justify-content: center; width: 100%; }
.sidebar-logo-full { height: 40px; width: auto; display: block; }
.sidebar-logo-icon { height: 40px; width: auto; display: none; }
.sidebar-collapsed .sidebar-top { padding: 0.9rem 0.4rem; }
.sidebar-collapsed .sidebar-logo-full { display: none; }
.sidebar-collapsed .sidebar-logo-icon { display: block; }

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.sidebar-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.56rem 0.65rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.87rem;
  font-weight: 500;
  font-family: inherit;
  white-space: nowrap;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.sidebar-link:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.sidebar-link.active { color: var(--text); background: var(--primary-soft); }
.sidebar-icon { flex: 0 0 20px; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; position: relative; }
.sidebar-icon svg { width: 20px; height: 20px; }
.sidebar-icon-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
}
.sidebar-label { overflow: hidden; text-overflow: ellipsis; }
.sidebar-collapsed .sidebar-label { display: none; }
.sidebar-collapsed .sidebar-link { justify-content: center; padding: 0.56rem; }

.sidebar-bottom {
  flex: 0 0 auto;
  border-top: 1px solid var(--border-soft);
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.sidebar-user { position: relative; display: flex; align-items: center; gap: 0.75rem; padding: 0.4rem 0.65rem; }
.sidebar-avatar {
  flex: 0 0 26px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary-soft); color: #a79bff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.76rem; font-weight: 700;
}
.sidebar-avatar-img { object-fit: cover; display: block; }
.sidebar-user-name { color: var(--text); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; }
.sidebar-logout-form, .sidebar-toggle-form { margin: 0; }

/* Collapsed-only hover tooltips (labels are hidden, so identity moves to a tooltip) */
.sidebar-collapsed .sidebar-link::after,
.sidebar-collapsed .sidebar-user::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translate(8px, -50%);
  background: var(--surface-hover);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 20;
}
.sidebar-collapsed .sidebar-link:hover::after,
.sidebar-collapsed .sidebar-link:focus-visible::after,
.sidebar-collapsed .sidebar-user:hover::after {
  opacity: 1;
  transform: translate(12px, -50%);
}

.page {
  flex: 1;
  min-width: 0;
  max-width: 1180px;
  margin: 0 auto;
  padding: 2rem 1.75rem 3.5rem;
}

/* Auth */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(900px 500px at 50% 0%, rgba(124, 108, 245, 0.14), transparent 60%),
    var(--bg);
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 2.5rem 2.25rem;
  width: 340px;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.auth-logo { width: 100%; max-width: 220px; margin: 0 auto 0.25rem; display: block; }
.auth-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin: 0 0 1.25rem;
}

/* Cards & layout */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.9rem;
}
.back-link:hover { color: var(--text); text-decoration: none; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.3rem;
  box-shadow: var(--shadow-sm);
}
.stat .value { font-size: 1.65rem; font-weight: 650; letter-spacing: -0.01em; }
.stat .label { color: var(--text-muted); font-size: 0.82rem; margin-top: 0.15rem; }

/* Forms */
label { display: block; font-size: 0.8rem; color: var(--text-muted); margin: 0.65rem 0 0.3rem; font-weight: 500; }
input, select, textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-family: inherit;
  background: var(--surface-2);
  color: var(--text);
  transition: border-color 0.12s ease, background 0.12s ease;
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-border);
  background: var(--surface-hover);
}
textarea { resize: vertical; min-height: 80px; }
form.stacked { display: flex; flex-direction: column; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.btn {
  display: inline-block;
  padding: 0.58rem 1.15rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.87rem;
  font-weight: 600;
  text-align: center;
  font-family: inherit;
  transition: background 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 2px 10px rgba(124, 108, 245, 0.35); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-hover); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.btn-danger:hover { background: rgba(248, 113, 113, 0.22); }
.btn-block { width: 100%; margin-top: 1.35rem; }
.btn-sm { padding: 0.32rem 0.7rem; font-size: 0.78rem; }
.actions-row { display: flex; gap: 0.6rem; margin-top: 1rem; align-items: center; }
.actions-row-tight { display: flex; gap: 0.5rem; align-items: center; }

/* Filtros de estatus: pills fantasma (transparentes hasta seleccionar) */
.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 1.25rem;
}
.filter-pill {
  border: 1px solid transparent;
  background: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.38rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.filter-pill:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.filter-pill.active {
  background: var(--primary-soft);
  color: #a79bff;
  border-color: var(--primary-border);
  font-weight: 650;
}

/* Interruptor de vista (Tabla/Kanban): a proposito distinto de las pills de
   filtro de arriba (fondo solido en vez de fantasma) para que no se
   confundan siendo dos controles con el mismo look. */
.view-switch {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
  margin-bottom: 1.25rem;
}
.view-switch-option {
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.view-switch-option:hover { color: var(--text); text-decoration: none; }
.view-switch-option.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(124, 108, 245, 0.35);
}

.client-search {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1.75rem;
}
.page-header .client-search { margin-bottom: 0; }
.client-search input[type="search"] {
  width: 320px;
  height: 2.5rem;
}
.client-search .btn {
  height: 2.5rem;
  padding-top: 0;
  padding-bottom: 0;
  display: inline-flex;
  align-items: center;
}

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.7rem 0.8rem; border-bottom: 1px solid var(--border-soft); font-size: 0.9rem; }
th { color: var(--text-muted); font-weight: 600; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; }
th.text-right, td.text-right { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { transition: background 0.1s ease; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }

/* Badges */
.badge {
  display: inline-block;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.badge-neutral { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-primary { background: var(--primary-soft); color: #a79bff; }

/* Kanban (pipeline de clientes) */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.kanban-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.85rem; }
.kanban-col h3 { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin: 0 0 0.7rem; font-weight: 650; }
.kanban-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.6rem;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.kanban-card:hover { border-color: var(--primary-border); }
.kanban-card .kc-name { display: block; font-weight: 600; font-size: 0.88rem; color: var(--text); text-decoration: none; }
.kanban-card .kc-name:hover { text-decoration: underline; }
.kanban-card .kc-meta { color: var(--text-muted); font-size: 0.76rem; margin-top: 0.15rem; }

.kc-tasks-toggle { margin-top: 0.5rem; }
.kc-tasks-toggle summary {
  cursor: pointer;
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 600;
  list-style: none;
}
.kc-tasks-toggle summary::-webkit-details-marker { display: none; }
.kc-tasks-toggle summary::before { content: '▸ '; }
.kc-tasks-toggle[open] summary::before { content: '▾ '; }
.kc-tasks { list-style: none; margin: 0.4rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.kc-task { display: flex; align-items: center; gap: 0.35rem; font-size: 0.78rem; color: var(--text); }
.kc-task-title { flex: 1; }
.kc-task-done .kc-task-title { color: var(--text-muted); text-decoration: line-through; }

/* Task checklist */
.task-list { list-style: none; margin: 0; padding: 0; }
.task-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border-soft);
}
.task-edit-form { flex-basis: 100%; margin-top: 0.5rem; }
.task-item:last-child { border-bottom: none; }
.task-title { flex: 1; }
.task-title.done { text-decoration: line-through; color: var(--text-muted); }
.task-meta { color: var(--text-muted); font-size: 0.78rem; }

.alert { padding: 0.65rem 0.85rem; border-radius: var(--radius-sm); font-size: 0.87rem; margin-bottom: 0.6rem; }
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(52, 211, 153, 0.3); }

/* Profile page */
.profile-avatar-row { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.profile-avatar-preview {
  width: 84px; height: 84px; border-radius: 50%; object-fit: cover;
  border: 1px solid var(--border); flex: 0 0 auto;
}
.profile-avatar-placeholder {
  width: 84px; height: 84px; border-radius: 50%; flex: 0 0 auto;
  background: var(--primary-soft); color: #a79bff;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-weight: 700;
}
.profile-avatar-actions { display: flex; flex-direction: column; gap: 0.6rem; }
.profile-avatar-actions input[type="file"] { font-size: 0.82rem; color: var(--text-muted); }

/* Team list avatars */
.team-row-name { display: flex; align-items: center; gap: 0.6rem; }
.team-avatar {
  width: 26px; height: 26px; border-radius: 50%; object-fit: cover; flex: 0 0 auto;
}
.team-avatar-placeholder {
  background: var(--primary-soft); color: #a79bff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.76rem; font-weight: 700;
}

.empty-state { color: var(--text-faint); padding: 1.5rem 0; text-align: center; font-size: 0.9rem; }

.subsection-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 650;
  margin: 1rem 0 0.4rem;
}
.subsection-label:first-child { margin-top: 0; }

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.5rem;
}

/* Formularios colapsables (<details>): ocultos por defecto, se abren al clic */
.inline-form { margin-bottom: 1rem; }
.inline-form > summary {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  list-style: none;
  width: fit-content;
  padding: 0.38rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--border);
  transition: background 0.12s ease;
}
.inline-form > summary::-webkit-details-marker,
.inline-form > summary::marker { display: none; content: ""; }
.inline-form > summary:hover { background: var(--surface-hover); }
.inline-form > summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.inline-form[open] > summary { margin-bottom: 1rem; }
.inline-form > form { margin-top: 0; }

/* Variante: el summary ES el encabezado de la tarjeta (h2 a la izquierda,
   boton a la derecha), igual que .section-title en el resto de tarjetas. */
.inline-form > summary.section-title {
  display: flex;
  width: auto;
  padding: 0;
  margin-top: 0;
  background: none;
  border: none;
  font-weight: normal;
}
.inline-form > summary.section-title:hover { background: none; }
.inline-form > summary.section-title h2 { margin: 0; }
.inline-form > summary.section-title .btn { pointer-events: none; }

/* Focus visibility (keyboard nav, incl. chart rows) */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, .chart-row:focus-visible, .kanban-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Charts */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

/* Bento grid del dashboard: tiles de distinto tamano en vez de filas parejas.
   20 columnas (mcm de 4, 5 y 2) para poder expresar los KPIs parejos
   (5 tiles de 4 cols c/u) y la fila Leads/Cuentas cobradas en 40/60 (8/12
   cols). El orden de las tarjetas en el HTML tiene que coincidir con el
   orden visual por fila, porque ya no se usa grid-template-areas. */
.bento {
  display: grid;
  grid-template-columns: repeat(20, 1fr);
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}
.bento > * { margin-bottom: 0; }
.bento-kpi1, .bento-kpi2, .bento-kpi3, .bento-kpi4, .bento-kpi5 { grid-column: span 4; }
.bento-leads { grid-column: span 8; }
.bento-revenue { grid-column: span 12; }
.bento-projs, .bento-leadsmonth { grid-column: span 10; }
.bento-clientsmonth { grid-column: span 20; }
.bento-activity { grid-column: span 20; }
.bento .stat { display: flex; flex-direction: column; justify-content: center; margin-bottom: 0; }
.bento-leads, .bento-projs, .bento-leadsmonth, .bento-revenue { display: flex; flex-direction: column; }
.bento-leads > .card, .bento-projs > .card, .bento-leadsmonth > .card, .bento-revenue > .card { flex: 1; }
.bento-leads .donut-svg { width: 170px; height: 170px; }

@media (max-width: 900px) {
  .bento-kpi1, .bento-kpi2, .bento-kpi3, .bento-kpi4, .bento-kpi5 { grid-column: span 10; }
  .bento-leads, .bento-revenue, .bento-projs, .bento-leadsmonth { grid-column: span 20; }
}
.chart-card { margin-bottom: 0; }
.chart { display: flex; flex-direction: column; gap: 0.7rem; }
.chart-row {
  position: relative;
  display: grid;
  grid-template-columns: 88px 1fr auto;
  align-items: center;
  gap: 0.7rem;
  border-radius: var(--radius-sm);
  padding: 0.15rem 0.3rem;
  margin: -0.15rem -0.3rem;
  cursor: default;
}
.chart-row:hover, .chart-row:focus-visible { background: var(--surface-2); }
.chart-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chart-track {
  height: 18px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
  display: block;
}
.chart-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 0 4px 4px 0;
  transition: width 0.25s ease;
}
.chart-fill-neutral { background-color: var(--text-muted); }
.chart-fill-primary { background-color: var(--primary); }
.chart-fill-warning { background-color: var(--warning); }
.chart-fill-success { background-color: var(--success); }
.chart-fill-danger { background-color: var(--danger); }

/* Ancho en pasos de 5%: clases fijas para no depender de style="" inline (CSP sin unsafe-inline) */
.w-0 { width: 0%; }
.w-5 { width: 5%; }
.w-10 { width: 10%; }
.w-15 { width: 15%; }
.w-20 { width: 20%; }
.w-25 { width: 25%; }
.w-30 { width: 30%; }
.w-35 { width: 35%; }
.w-40 { width: 40%; }
.w-45 { width: 45%; }
.w-50 { width: 50%; }
.w-55 { width: 55%; }
.w-60 { width: 60%; }
.w-65 { width: 65%; }
.w-70 { width: 70%; }
.w-75 { width: 75%; }
.w-80 { width: 80%; }
.w-85 { width: 85%; }
.w-90 { width: 90%; }
.w-95 { width: 95%; }
.w-100 { width: 100%; }

/* Alto en pasos de 5%: para columnas verticales (mismo motivo que .w-*) */
.h-0 { height: 0%; }
.h-5 { height: 5%; }
.h-10 { height: 10%; }
.h-15 { height: 15%; }
.h-20 { height: 20%; }
.h-25 { height: 25%; }
.h-30 { height: 30%; }
.h-35 { height: 35%; }
.h-40 { height: 40%; }
.h-45 { height: 45%; }
.h-50 { height: 50%; }
.h-55 { height: 55%; }
.h-60 { height: 60%; }
.h-65 { height: 65%; }
.h-70 { height: 70%; }
.h-75 { height: 75%; }
.h-80 { height: 80%; }
.h-85 { height: 85%; }
.h-90 { height: 90%; }
.h-95 { height: 95%; }
.h-100 { height: 100%; }

/* Barra de progreso de tareas (proyectos) */
.progress-row { display: flex; align-items: center; gap: 0.55rem; }
.progress-track {
  height: 6px;
  min-width: 56px;
  flex: 1;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
  display: block;
}
.progress-fill {
  display: block;
  height: 100%;
  background-color: var(--primary);
  border-radius: 4px;
  transition: width 0.25s ease;
}
.progress-fill.progress-complete { background-color: var(--success); }
.progress-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Drag and drop: kanban de proyectos y reordenar tareas */
[draggable="true"] { cursor: grab; }
[draggable="true"]:active { cursor: grabbing; }
.dragging { opacity: 0.4; }
.drag-over { outline: 2px dashed var(--primary); outline-offset: -2px; }
.kanban-col.drag-over { background: var(--surface-hover); }
.task-drag-handle {
  cursor: grab;
  color: var(--text-faint);
  flex: 0 0 auto;
  padding: 0 0.15rem;
  font-size: 0.95rem;
  line-height: 1;
  user-select: none;
}
.task-drag-handle:active { cursor: grabbing; }

/* Tarjetas kanban de proyectos */
.kc-progress { margin-top: 0.4rem; }
.kc-badges { display: flex; gap: 0.3rem; margin-top: 0.3rem; flex-wrap: wrap; }
.chart-value {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 3.5em;
  text-align: right;
}

/* Tooltip: CSS-only, driven by data-tooltip so labels never go through innerHTML */
.chart-row::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translate(-50%, -6px) scale(0.98);
  background: var(--surface-hover);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 500;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 5;
}
.chart-row:hover::after, .chart-row:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, -10px) scale(1);
}

/* Donut (leads por etapa) */
.donut-wrap { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.donut-svg { flex: 0 0 auto; width: 120px; height: 120px; transform: rotate(0deg); }
.donut-track { fill: none; stroke: var(--surface-2); stroke-width: 5; }
.donut-seg { fill: none; stroke-width: 5; transition: stroke-dasharray 0.3s ease; }
.donut-seg-neutral { stroke: var(--text-muted); }
.donut-seg-primary { stroke: var(--primary); }
.donut-seg-warning { stroke: var(--warning); }
.donut-seg-success { stroke: var(--success); }
.donut-seg-danger { stroke: var(--danger); }
.donut-legend { display: flex; flex-direction: column; gap: 0.55rem; flex: 1; min-width: 140px; }
.donut-legend-row { display: flex; align-items: center; gap: 0.55rem; font-size: 0.84rem; }
.donut-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; }
.donut-dot-neutral { background: var(--text-muted); }
.donut-dot-primary { background: var(--primary); }
.donut-dot-warning { background: var(--warning); }
.donut-dot-success { background: var(--success); }
.donut-dot-danger { background: var(--danger); }
.donut-legend-label { color: var(--text-muted); flex: 1; }
.donut-legend-val { font-weight: 650; font-variant-numeric: tabular-nums; }

/* Columnas verticales con gradiente (facturacion cobrada por mes) */
.col-chart { display: flex; align-items: flex-end; gap: 0.7rem; height: 150px; padding-top: 0.5rem; }
.col-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  height: 100%;
  justify-content: flex-end;
  position: relative;
  border-radius: var(--radius-sm);
}
.col-bar-wrap { flex: 1; display: flex; align-items: flex-end; width: 100%; justify-content: center; }
.col-bar {
  width: 70%;
  min-height: 3px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, #9689f8, var(--primary-dark));
  box-shadow: 0 0 0 1px rgba(124, 108, 245, 0.25) inset;
  transition: height 0.3s ease;
}
.col-bar-peak { background: linear-gradient(180deg, #b3a9ff, var(--primary)); }
.col-bar-neutral { background: var(--text-muted); box-shadow: none; }
.col-bar-primary { background: var(--primary); box-shadow: none; }
.col-bar-warning { background: var(--warning); box-shadow: none; }
.col-bar-success { background: var(--success); box-shadow: none; }
.col-bar-danger { background: var(--danger); box-shadow: none; }
.col-val { font-size: 0.74rem; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.col-month { font-size: 0.74rem; color: var(--text-faint); }
.col-item::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translate(-50%, -6px) scale(0.98);
  background: var(--surface-hover);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 500;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 5;
}
.col-item:hover::after, .col-item:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, -10px) scale(1);
}

/* Panel de vencidos / actividad reciente */
.attention-item { border-left: 2px solid var(--danger); padding-left: 0.7rem; }
.activity-item { border-left: 2px solid var(--border); padding-left: 0.7rem; }
.attention-row td:first-child { border-left: 2px solid var(--danger); padding-left: 0.7rem; }

/* Barras horizontales (proyectos por estatus) */
.hbars { display: flex; flex-direction: column; gap: 0.65rem; }
.hbar-row { display: grid; grid-template-columns: 92px 1fr 34px; align-items: center; gap: 0.6rem; }
.hbar-label { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { display: block; background: var(--surface-2); border-radius: 5px; height: 10px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; border-radius: 5px; transition: width 0.3s ease; }
.hbar-fill-neutral { background: var(--text-muted); }
.hbar-fill-primary { background: var(--primary); }
.hbar-fill-warning { background: var(--warning); }
.hbar-fill-success { background: var(--success); }
.hbar-fill-danger { background: var(--danger); }
.hbar-n { font-size: 0.8rem; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }

/* Grafica de area (facturacion cobrada por mes) */
.area-svg { width: 100%; height: auto; display: block; overflow: visible; }
.area-fill { opacity: 0.55; }
.area-line { fill: none; stroke: var(--primary); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.area-dot { fill: var(--surface); stroke: var(--primary); stroke-width: 2.2; }
.area-dot.peak { fill: var(--primary); }
.area-grid-line { stroke: var(--border-soft); stroke-width: 1; }
.area-month { font-size: 9px; fill: var(--text-faint); }
.area-peak-label { font-size: 10.5px; fill: var(--text); font-weight: 650; }

@media (max-width: 900px) {
  .kanban { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .chart-row { grid-template-columns: 70px 1fr auto; }
  .donut-wrap { flex-direction: column; align-items: flex-start; }
}

/* Below this width the sidebar always renders icon-only, regardless of the
   collapse cookie, so it doesn't eat the viewport on phones/small tablets. */
@media (max-width: 680px) {
  .sidebar { flex-basis: 64px; width: 64px; }
  .sidebar-label { display: none; }
  .sidebar-logo-full { display: none; }
  .sidebar-logo-icon { display: block; }
  .sidebar-link { justify-content: center; padding: 0.56rem; }
  .sidebar-link::after, .sidebar-user::after { content: attr(data-tooltip); }
  .sidebar-link:hover::after, .sidebar-link:focus-visible::after, .sidebar-user:hover::after {
    opacity: 1;
    transform: translate(12px, -50%);
  }
  .page { padding: 1.5rem 1rem 3rem; }
}
