/* ==================== RESET & BASE ==================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Light theme */
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #eef0f4;
  --border: #e2e5ea;
  --border-strong: #cfd3da;
  --text: #14161a;
  --text-muted: #6b7280;
  --text-faint: #9aa1ac;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #e6efff;
  --success: #16a34a;
  --success-soft: #e6f5ec;
  --warning: #d97706;
  --warning-soft: #fdf1e0;
  --danger: #dc2626;
  --danger-soft: #fdeaea;
  --purple: #7c3aed;

  --sidebar-bg: #111318;
  --sidebar-text: #c7cbd3;
  --sidebar-text-muted: #7d8492;
  --sidebar-active: #2563eb;
  --sidebar-hover: rgba(255,255,255,0.07);

  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(16,24,40,0.06), 0 1px 3px rgba(16,24,40,0.08);
  --shadow-md: 0 4px 12px rgba(16,24,40,0.10);
  --shadow-lg: 0 12px 32px rgba(16,24,40,0.16);

  --gantt-day-px: 28px;
  --gp-row-h: 34px;
  --gp-head-h: 46px;

  /* Paleta tipo Microsoft Project */
  --msp-task: #4a90d9;
  --msp-task-stroke: #2f6cb0;
  --msp-summary: #1f2430;
  --msp-critical: #e74c3c;
  --msp-grid: #e6e8ec;
  --msp-weekend: rgba(74,144,217,0.07);
}

[data-theme="dark"] {
  --bg: #0e1014;
  --surface: #171a21;
  --surface-2: #1d212a;
  --surface-3: #242a35;
  --border: #2a2f3a;
  --border-strong: #3a414f;
  --text: #e7eaf0;
  --text-muted: #9aa3b2;
  --text-faint: #6b7382;

  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-soft: #16233d;
  --success: #22c55e;
  --success-soft: #10281a;
  --warning: #f59e0b;
  --warning-soft: #2a2011;
  --danger: #ef4444;
  --danger-soft: #2c1616;

  --sidebar-bg: #0a0c10;
  --sidebar-text: #c7cbd3;
  --sidebar-active: #3b82f6;
  --sidebar-hover: rgba(255,255,255,0.06);

  --shadow: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 6px 18px rgba(0,0,0,0.45);
  --shadow-lg: 0 16px 40px rgba(0,0,0,0.55);

  /* Paleta tipo Microsoft Project (modo oscuro) */
  --msp-task: #5a9be0;
  --msp-task-stroke: #7fb3ea;
  --msp-summary: #e7eaf0;
  --msp-critical: #f26a5c;
  --msp-grid: #2a2f3a;
  --msp-weekend: rgba(90,155,224,0.10);
}

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s ease, color 0.25s ease;
}

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

.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }

/* ==================== APP SHELL ==================== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
  width: 244px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 0;
  z-index: 50;
  transition: width 0.2s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1.15rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand img {
  height: 42px;
  width: 42px;
  object-fit: cover;
  object-position: top;
  background: #fff;
  border-radius: 9px;
  padding: 2px;
  flex-shrink: 0;
}

.sidebar-brand .brand-text {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
  color: #fff;
  line-height: 1.1;
}
.sidebar-brand .brand-text small {
  display: block;
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-text);
  opacity: 0.6;
}

.sidebar-nav {
  flex: 1;
  padding: 0.85rem 0.7rem;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--sidebar-text);
  opacity: 0.45;
  padding: 0.9rem 0.75rem 0.35rem;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, color 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--sidebar-active); color: #fff; }
.nav-item .nav-icon { font-size: 1.05rem; width: 20px; text-align: center; flex-shrink: 0; }
.nav-item .nav-badge {
  margin-left: auto;
  background: rgba(255,255,255,0.14);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.05rem 0.45rem;
  border-radius: 20px;
}

/* Submenu */
.nav-sub {
  margin: 0.15rem 0 0.35rem 0.6rem;
  padding-left: 0.5rem;
  border-left: 1px solid rgba(255,255,255,0.10);
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.nav-subitem {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.42rem 0.7rem;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 0.82rem;
  cursor: pointer;
  opacity: 0.85;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background 0.15s;
}
.nav-subitem:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; opacity: 1; }
.nav-subitem.active { color: #fff; opacity: 1; font-weight: 600; }
.nav-subitem .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

.sidebar-footer {
  padding: 0.85rem 0.9rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.82rem;
}
.sidebar-user .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.8rem; flex-shrink: 0;
}
.sidebar-user .u-name { font-weight: 600; color: #fff; line-height: 1.1; }
.sidebar-user .u-role { font-size: 0.68rem; opacity: 0.55; }

/* ==================== MAIN CONTENT ==================== */
.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 62px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.6rem;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-left { display: flex; align-items: center; gap: 0.8rem; min-width: 0; }
.topbar h1 { font-size: 1.18rem; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .breadcrumb-sep { color: var(--text-faint); }
.topbar-right { display: flex; align-items: center; gap: 0.6rem; }

.hamburger {
  display: none;
  background: none; border: none; cursor: pointer;
  font-size: 1.3rem; color: var(--text); padding: 0.2rem 0.4rem;
}

/* Theme toggle */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: 0.32rem 0.55rem;
  cursor: pointer;
  color: var(--text);
  font-size: 0.85rem;
  transition: background 0.15s;
}
.theme-toggle:hover { background: var(--surface-2); }
.theme-toggle .toggle-track {
  width: 34px; height: 18px; border-radius: 20px;
  background: var(--border-strong); position: relative; transition: background 0.2s;
}
.theme-toggle .toggle-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; transition: transform 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
[data-theme="dark"] .theme-toggle .toggle-track { background: var(--accent); }
[data-theme="dark"] .theme-toggle .toggle-thumb { transform: translateX(16px); }

.view-container {
  padding: 1.6rem;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
}

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-small { padding: 0.4rem 0.7rem; font-size: 0.8rem; }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text-muted);
  padding: 0.3rem 0.4rem;
  border-radius: var(--radius-sm);
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.btn-icon:hover { background: var(--surface-3); color: var(--text); }

/* ==================== CARDS ==================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem;
  box-shadow: var(--shadow);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.section-header h2 { font-size: 1.15rem; font-weight: 700; }
.section-header h3 { font-size: 1rem; font-weight: 700; }

/* ==================== FORMS ==================== */
.form-card { margin-bottom: 1.2rem; }
.form-card h3, .form-card h4 { margin-bottom: 0.9rem; }
.form-group { margin-bottom: 0.9rem; display: flex; flex-direction: column; }
.form-group label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.form-row { display: flex; gap: 0.9rem; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 140px; }
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

input[type="text"], input[type="password"], input[type="date"], input[type="number"],
select, textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="color"] { padding: 0.2rem; height: 38px; cursor: pointer; }
textarea { resize: vertical; }

.form-actions { display: flex; gap: 0.6rem; margin-top: 0.5rem; }

/* ==================== BADGES ==================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.18rem 0.55rem;
  border-radius: 20px;
  line-height: 1.4;
}
.badge-total { background: var(--surface-3); color: var(--text-muted); }
.badge-done { background: var(--success-soft); color: var(--success); }
.badge-blocked { background: var(--danger-soft); color: var(--danger); }
.badge-shared { background: rgba(255,255,255,0.15); color: #fff; }

.status-badge-pending { background: var(--surface-3); color: var(--text-muted); }
.status-badge-in_progress { background: var(--accent-soft); color: var(--accent); }
.status-badge-blocked { background: var(--danger-soft); color: var(--danger); }
.status-badge-completed { background: var(--success-soft); color: var(--success); }

.priority-badge-low { background: var(--surface-3); color: var(--text-muted); }
.priority-badge-medium { background: var(--warning-soft); color: var(--warning); }
.priority-badge-high { background: #fde4d0; color: #c2410c; }
.priority-badge-critical { background: var(--danger-soft); color: var(--danger); }
[data-theme="dark"] .priority-badge-high { background: #33220f; color: #fb923c; }

.ms-status-pending { background: var(--surface-3); color: var(--text-muted); }
.ms-status-in_progress { background: var(--accent-soft); color: var(--accent); }
.ms-status-at_risk { background: var(--danger-soft); color: var(--danger); }
.ms-status-completed { background: var(--success-soft); color: var(--success); }

/* ==================== KPI CARDS (DASHBOARD) ==================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  position: relative;
  overflow: hidden;
}
.kpi-card .kpi-icon {
  position: absolute; right: 0.9rem; top: 0.9rem;
  font-size: 1.3rem; opacity: 0.25;
}
.kpi-card .kpi-value { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.kpi-card .kpi-label { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; }
.kpi-card.accent { border-left: 3px solid var(--accent); }
.kpi-card.success { border-left: 3px solid var(--success); }
.kpi-card.warning { border-left: 3px solid var(--warning); }
.kpi-card.danger { border-left: 3px solid var(--danger); }
.kpi-card.purple { border-left: 3px solid var(--purple); }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 1.2rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 900px) { .dashboard-grid { grid-template-columns: 1fr; } }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.15rem; }
.panel-title { font-size: 0.95rem; font-weight: 700; margin-bottom: 0.9rem; display: flex; align-items: center; gap: 0.4rem; }

.chart-container { position: relative; height: 240px; }
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 700px) { .charts-grid { grid-template-columns: 1fr; } }
.chart-card { padding: 1rem; }
.chart-title { font-size: 0.9rem; font-weight: 700; margin-bottom: 0.75rem; }

/* Upcoming / recent lists */
.mini-list { display: flex; flex-direction: column; gap: 0.5rem; }
.mini-item {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.6rem 0.7rem; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  cursor: pointer; transition: background 0.15s;
}
.mini-item:hover { background: var(--surface-3); }
.mini-item .mi-main { flex: 1; min-width: 0; }
.mini-item .mi-title { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-item .mi-sub { font-size: 0.74rem; color: var(--text-muted); }
.mini-item .mi-date { font-size: 0.74rem; font-weight: 600; white-space: nowrap; }
.mi-date.overdue { color: var(--danger); }
.mi-date.soon { color: var(--warning); }

/* ==================== PROJECTS GRID ==================== */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.1rem;
}
.project-card {
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.15s, border-color 0.15s;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.project-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.project-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; }
.project-card-header h3 { font-size: 1.02rem; font-weight: 700; }
.project-stats { display: flex; gap: 1.2rem; margin-top: 0.2rem; }
.stat { display: flex; flex-direction: column; }
.stat-number { font-size: 1.3rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }

.progress-bar { height: 7px; background: var(--surface-3); border-radius: 20px; overflow: hidden; }
.progress-bar-large { height: 12px; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 20px; transition: width 0.3s ease; }

/* ==================== TASKS ==================== */
.filters-bar { display: flex; gap: 0.7rem; margin-bottom: 1.1rem; flex-wrap: wrap; align-items: center; }
.filters-bar select { width: auto; min-width: 150px; }
.filters-bar .spacer { flex: 1; }

.tasks-list { display: flex; flex-direction: column; gap: 0.7rem; }
.task-card {
  border-left: 3px solid var(--border-strong);
  display: flex; flex-direction: column; gap: 0.55rem;
}
/* El borde izquierdo lo define el SEMÁFORO (--task-color), no el estado.
   Antes había reglas .status-* que lo sobreescribían; se quitaron a propósito. */

.task-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.6rem; }
.task-title-row { display: flex; align-items: center; gap: 0.55rem; min-width: 0; }
.task-title-row h4 { font-size: 0.96rem; font-weight: 600; }
.task-actions { display: flex; gap: 0.2rem; flex-shrink: 0; }
.priority-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
/* Colores del semáforo: Baja amarillo · Media naranja · Alta naranja fuerte · Crítica rojo */
.priority-low { background: #eab308; }
.priority-medium { background: #fb923c; }
.priority-high { background: #f97316; }
.priority-critical { background: #ef4444; }

.task-meta { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; font-size: 0.78rem; color: var(--text-muted); }
.task-assigned, .task-due { font-size: 0.78rem; color: var(--text-muted); }
.task-notes, .task-desc { font-size: 0.83rem; color: var(--text-muted); }
.task-project-tag {
  font-size: 0.72rem; font-weight: 600; color: var(--accent);
  background: var(--accent-soft); padding: 0.12rem 0.5rem; border-radius: 20px;
}

/* Subtasks */
.subtasks-section { border-top: 1px solid var(--border); padding-top: 0.55rem; }
.subtasks-list { display: flex; flex-direction: column; gap: 0.2rem; margin-bottom: 0.4rem; }
.subtask-item { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.15rem 0; }
.subtask-left { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.subtask-text { font-size: 0.83rem; }
.subtask-done { text-decoration: line-through; color: var(--text-faint); }
.semaphore { width: 13px; height: 13px; border-radius: 50%; cursor: pointer; flex-shrink: 0; border: 2px solid transparent; transition: transform 0.1s; }
.semaphore:hover { transform: scale(1.2); }
.semaphore-pending { background: var(--text-faint); }
.semaphore-in_progress { background: var(--warning); }
.semaphore-done { background: var(--success); }
.subtask-delete { opacity: 0.5; }
.subtask-delete:hover { opacity: 1; }
.add-subtask-row { display: flex; gap: 0.4rem; align-items: center; }
.add-subtask-row input { flex: 1; padding: 0.35rem 0.6rem; font-size: 0.82rem; }
.add-subtask-btn { font-size: 1.1rem; font-weight: 700; padding: 0.2rem 0.55rem; }

/* ==================== GLOBAL TASKS TABLE ==================== */
.data-table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.data-table th {
  text-align: left; padding: 0.7rem 0.9rem; font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-muted); background: var(--surface-2);
  border-bottom: 1px solid var(--border); font-weight: 700; white-space: nowrap;
}
.data-table td { padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { cursor: pointer; transition: background 0.12s; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table .cell-title { font-weight: 600; }

/* ==================== SHARE SECTION ==================== */
.share-section { background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 0.9rem 1.1rem; margin-bottom: 1.2rem; }
.share-label { font-size: 0.8rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--text-muted); }
.share-link-container { display: flex; gap: 0.5rem; }
.share-input { flex: 1; font-family: monospace; font-size: 0.82rem; background: var(--surface); }

/* ==================== DOCUMENTS ==================== */
.documents-section { margin: 1.5rem 0; }
.btn-upload { position: relative; overflow: hidden; }
.files-list { display: flex; flex-direction: column; gap: 0.5rem; }
.file-item { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; padding: 0.6rem 0.8rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.file-info { display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.file-icon { font-size: 1.4rem; }
.file-name { font-weight: 600; font-size: 0.86rem; }

/* ==================== TABS ==================== */
.tabs { display: flex; gap: 0.3rem; border-bottom: 1px solid var(--border); margin-bottom: 1.2rem; overflow-x: auto; }
.tab {
  padding: 0.65rem 1rem; font-size: 0.86rem; font-weight: 600; color: var(--text-muted);
  cursor: pointer; border: none; background: none; border-bottom: 2px solid transparent;
  white-space: nowrap; transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ==================== MS PROJECT (GANTT PRO) ==================== */
.msp-toolbar { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.9rem; flex-wrap: wrap; }
.msp-toolbar .spacer { flex: 1; }
.msp-legend { display: flex; gap: 0.9rem; flex-wrap: wrap; font-size: 0.74rem; color: var(--text-muted); align-items: center; }
.msp-legend .lg { display: inline-flex; align-items: center; gap: 0.35rem; }
.msp-legend .lg .swatch { width: 14px; height: 10px; border-radius: 3px; }
.msp-legend .lg .swatch.task { background: var(--msp-task); }
.msp-legend .lg .swatch.summary { background: var(--msp-summary); height: 7px; border-radius: 1px; }
.msp-legend .lg .swatch.milestone { background: var(--msp-summary); transform: rotate(45deg); width: 10px; height: 10px; border-radius: 2px; }
.msp-legend .lg .swatch.critical { background: var(--msp-critical); }
.msp-legend .lg .swatch.done { background: var(--success); }
.msp-legend .lg .swatch.today { background: var(--msp-critical); width: 3px; height: 14px; border-radius: 2px; }

.gp-zoom { display: inline-flex; align-items: center; gap: 0.15rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.1rem 0.25rem; }
.gp-zoom .btn { padding: 0.1rem 0.5rem; min-width: 26px; font-weight: 700; }
.gp-zoom-ico { font-size: 0.8rem; opacity: 0.7; }

.gantt-pro {
  display: flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}

/* ---- Grilla izquierda (hoja de tareas) ---- */
.gp-table {
  flex-shrink: 0;
  width: 466px;
  border-right: 2px solid var(--border-strong);
  overflow: hidden;
}
.gp-thead, .gp-trow {
  display: grid;
  grid-template-columns: 34px 1fr 60px 62px 62px 44px;
  align-items: center;
}
.gp-thead {
  height: var(--gp-head-h);
  background: var(--surface-2);
  border-bottom: 2px solid var(--border-strong);
}
.gp-thead > div { padding: 0 0.5rem; font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); font-weight: 700; }
.gp-trow {
  height: var(--gp-row-h);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}
.gp-trow:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.gp-trow.is-summary { background: color-mix(in srgb, var(--text) 4%, transparent); }
.gp-trow.is-summary .gp-cell-name { font-weight: 700; }
.gp-trow.is-critical .gp-cell-name .gp-name-text { color: var(--msp-critical); }
.gp-trow > div { padding: 0 0.5rem; font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gp-cell-num { text-align: center; color: var(--text-faint); font-size: 0.68rem; padding: 0 !important; border-right: 1px solid var(--border); height: 100%; display: flex; align-items: center; justify-content: center; }
.gp-cell-name { position: relative; display: flex; align-items: center; gap: 0.3rem; font-weight: 600; }
.gp-cell-name .type-ico { font-size: 0.78rem; flex-shrink: 0; color: var(--text-muted); display: inline-flex; align-items: center; }
.gp-ico-diamond { width: 9px; height: 9px; background: var(--msp-summary); transform: rotate(45deg); display: inline-block; }
.gp-twisty { width: 13px; flex-shrink: 0; color: var(--text-muted); font-size: 0.62rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.gp-twisty.empty { cursor: default; }
.gp-twisty:hover { color: var(--accent); }
.gp-cell-dur { color: var(--text-muted); font-size: 0.72rem; text-align: right; }
.gp-cell-date { color: var(--text-muted); font-size: 0.72rem; }
.gp-cell-prog { text-align: right; font-weight: 700; font-size: 0.72rem; }

/* ---- Timeline ---- */
.gp-timeline { flex: 1; overflow-x: auto; overflow-y: hidden; position: relative; }
.gp-timeline-inner { position: relative; }

.gp-scale { height: var(--gp-head-h); border-bottom: 2px solid var(--border-strong); position: relative; background: var(--surface-2); }
.gp-scale-months { height: 18px; position: relative; border-bottom: 1px solid var(--border); }
.gp-scale-month { position: absolute; top: 0; height: 100%; padding: 0 6px; font-size: 0.66rem; font-weight: 700; color: var(--text); text-transform: capitalize; border-left: 1px solid var(--border-strong); display: flex; align-items: center; white-space: nowrap; overflow: hidden; }
.gp-scale-days { height: 28px; position: relative; }
.gp-scale-day { position: absolute; top: 0; height: 100%; border-left: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05; }
.gp-scale-day b { font-size: 0.5rem; font-weight: 600; color: var(--text-faint); text-transform: uppercase; }
.gp-scale-day span { font-size: 0.6rem; color: var(--text-muted); }
.gp-scale-day.weekend { background: var(--msp-weekend); }

.gp-rows { position: relative; }
.gp-grid-line { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--msp-grid); opacity: 0.7; }
.gp-grid-line.weekend { background: var(--msp-weekend); opacity: 1; }
.gp-tl-row { height: var(--gp-row-h); border-bottom: 1px solid var(--border); position: relative; }
.gp-tl-row:hover { background: color-mix(in srgb, var(--accent) 4%, transparent); }

.gp-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--msp-critical); z-index: 6; }

/* Flechas de dependencia */
.gp-links { position: absolute; top: 0; left: 0; z-index: 4; pointer-events: none; overflow: visible; }
.gp-link { fill: none; stroke: var(--text-muted); stroke-width: 1.3; opacity: 0.8; }
.gp-links marker path { fill: var(--text-muted); }

/* Barra de tarea */
.gp-bar {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  height: 16px;
  border-radius: 3px;
  background: var(--bar, var(--msp-task));
  border: 1px solid color-mix(in srgb, var(--bar, var(--msp-task)) 65%, #000);
  box-shadow: 0 1px 2px rgba(0,0,0,0.22);
  overflow: hidden;
  z-index: 3;
  cursor: pointer;
}
.gp-bar .gp-bar-prog { position: absolute; top: 0; left: 0; height: 100%; background: rgba(0,0,0,0.32); }
.gp-bar.is-done { background: var(--msp-task); }
.gp-bar.is-critical { background: var(--msp-critical); border-color: color-mix(in srgb, var(--msp-critical) 65%, #000); }
.gp-out-label { position: absolute; top: 50%; transform: translateY(-50%); font-size: 0.7rem; font-weight: 600; color: var(--text-muted); white-space: nowrap; z-index: 3; pointer-events: none; }

/* Barra resumen (padre) con topes triangulares */
.gp-summary-bar {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  height: 9px;
  background: var(--msp-summary);
  border-radius: 1px;
  z-index: 3;
  cursor: pointer;
}
.gp-summary-bar::before, .gp-summary-bar::after {
  content: ''; position: absolute; bottom: -4px; width: 0; height: 0;
  border-left: 5px solid transparent; border-right: 5px solid transparent;
  border-top: 6px solid var(--msp-summary);
}
.gp-summary-bar::before { left: 0; }
.gp-summary-bar::after { right: 0; }

/* Diamante de hito/entrega */
.gp-milestone {
  position: absolute;
  top: 50%; margin-top: -8px;
  width: 16px; height: 16px;
  background: var(--msp-summary);
  transform: rotate(45deg);
  z-index: 5;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
  cursor: pointer;
}
.gp-milestone.completed { background: var(--success); }
.gp-milestone.in_progress { background: var(--msp-task); }
.gp-milestone.at_risk, .gp-milestone.is-critical { background: var(--msp-critical); }

/* Legacy simple gantt (kept for shared basic view fallback) */
.gantt-card { margin-top: 1rem; overflow-x: auto; }
.gantt-chart { min-width: 560px; }

/* ==================== MILESTONES LIST ==================== */
.milestones-list { display: flex; flex-direction: column; gap: 0.6rem; }
.milestone-item { display: flex; align-items: flex-start; gap: 0.75rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.85rem 1rem; box-shadow: var(--shadow); }
.milestone-color-dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 0.35rem; flex-shrink: 0; }
.milestone-info { flex: 1; min-width: 0; }
.milestone-top { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.milestone-title { font-weight: 600; font-size: 0.95rem; }
.milestone-desc { font-size: 0.82rem; color: var(--text-muted); margin: 0.2rem 0; }
.milestone-meta { display: flex; justify-content: space-between; align-items: center; font-size: 0.78rem; color: var(--text-muted); margin: 0.35rem 0 0.3rem; gap: 0.5rem; }
.milestone-progress-label { font-weight: 600; color: var(--text); }
.milestone-actions { display: flex; gap: 0.25rem; flex-shrink: 0; }

/* ==================== EMPTY STATES ==================== */
.empty-state { text-align: center; padding: 3.5rem 1rem; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 0.5rem; }
.empty-state p { margin: 0.2rem 0; }
.empty-state-small { text-align: center; padding: 1.5rem 1rem; color: var(--text-muted); background: var(--surface-2); border-radius: var(--radius); border: 1px dashed var(--border-strong); }

/* ==================== MODAL ==================== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 1rem; }
.modal-panel { background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.3rem; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 1.05rem; font-weight: 700; }
.modal-body { padding: 1.3rem; }
.add-user-form { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1.2rem; }
.users-list { display: flex; flex-direction: column; gap: 0.5rem; }
.user-item { display: flex; align-items: center; justify-content: space-between; padding: 0.6rem 0.8rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.user-item-info { display: flex; flex-direction: column; }
.user-item-name { font-weight: 600; font-size: 0.88rem; }
.user-item-username { font-size: 0.75rem; color: var(--text-muted); }

/* ==================== TOAST ==================== */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg);
  padding: 0.7rem 1.2rem; border-radius: var(--radius); font-size: 0.86rem; font-weight: 600;
  box-shadow: var(--shadow-lg); z-index: 300; opacity: 0; transition: opacity 0.25s, transform 0.25s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-error { background: var(--danger); color: #fff; }
.toast-success { background: var(--success); color: #fff; }

/* ==================== SHARED VIEW ==================== */
.shared-body { background: var(--bg); }
.header-shared { background: var(--sidebar-bg); color: #fff; padding: 1.1rem 2rem; position: sticky; top: 0; z-index: 100; }
.header-shared .header-content { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; }
.header-shared .logo { display: flex; align-items: center; gap: 0.6rem; font-size: 1.2rem; font-weight: 700; color: #fff; }
.header-shared .logo-img { height: 40px; width: 40px; object-fit: cover; object-position: top; background: #fff; border-radius: 8px; padding: 2px; }
.container { max-width: 1200px; margin: 0 auto; padding: 1.6rem; }
.shared-project-header h2 { font-size: 1.4rem; font-weight: 700; }
.shared-progress-card { margin: 1.2rem 0; }
.progress-overview { margin-bottom: 1rem; }
.progress-label { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.4rem; font-weight: 600; }
.stats-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.stat-box { flex: 1; min-width: 90px; text-align: center; padding: 0.7rem; background: var(--surface-2); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.stat-completed { border-bottom: 2px solid var(--success); }
.stat-progress { border-bottom: 2px solid var(--accent); }
.stat-pending { border-bottom: 2px solid var(--text-faint); }
.stat-blocked { border-bottom: 2px solid var(--danger); }
.shared-filters select { width: auto; }
.loading-spinner { text-align: center; padding: 4rem 1rem; color: var(--text-muted); }
.shared-footer { text-align: center; padding: 2rem 1rem 1rem; color: var(--text-muted); font-size: 0.8rem; border-top: 1px solid var(--border); margin-top: 2rem; }

.planning-section { margin: 1.5rem 0 2rem; }

/* ==================== RESPONSIVE ==================== */
.sidebar-backdrop { display: none; }
@media (max-width: 860px) {
  .sidebar {
    position: fixed; left: 0; top: 0; height: 100vh;
    transform: translateX(-100%); transition: transform 0.22s ease; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .hamburger { display: block; }
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 45; }
  .gp-table { width: 210px; }
  .gp-thead, .gp-trow { grid-template-columns: 26px 1fr 42px; }
  .gp-cell-date, .gp-cell-dur { display: none; }
}

/* ==================== WALLPAPER ==================== */
#wallpaper-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.app-shell { position: relative; z-index: 1; }
body.has-wallpaper .main-content { background: transparent; }
body.has-wallpaper .topbar { background: color-mix(in srgb, var(--surface) 86%, transparent); backdrop-filter: blur(6px); }

.wallpaper-menu { position: relative; }
.wallpaper-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 230px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0.8rem;
  z-index: 120;
}
.wallpaper-dropdown input[type="range"] { accent-color: var(--accent); }

/* ==================== NOTIFICACIONES (campanita) ==================== */
.notif-menu { position: relative; }
.notif-btn { position: relative; }
.notif-badge {
  position: absolute; top: -4px; right: -4px; background: #ef4444; color: #fff;
  font-size: 0.62rem; font-weight: 700; min-width: 17px; height: 17px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px; border: 2px solid var(--surface);
}
.notif-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0; width: min(340px, 86vw);
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.35); z-index: 130; overflow: hidden;
}
.notif-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 0.9rem;
}
.notif-head-actions { display: flex; gap: 0.6rem; }
.btn-link { background: none; border: none; color: var(--accent); font-size: 0.74rem; cursor: pointer; padding: 0; }
.btn-link:hover { text-decoration: underline; }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-item {
  display: flex; gap: 0.6rem; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--border);
  cursor: default; transition: background 0.15s;
}
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.notif-ico { font-size: 1.1rem; flex-shrink: 0; }
.notif-body-wrap { min-width: 0; }
.notif-title { font-size: 0.82rem; font-weight: 600; color: var(--text); }
.notif-text { font-size: 0.76rem; color: var(--text-muted); margin-top: 0.1rem; }
.notif-time { font-size: 0.68rem; color: var(--text-faint); margin-top: 0.15rem; }
.notif-empty { padding: 1.4rem 0.9rem; text-align: center; color: var(--text-muted); font-size: 0.82rem; }

/* ==================== GANTT: NESTING ==================== */
.task-title-done { text-decoration: line-through; color: var(--text-faint); }

/* ==================== GANTT ROW ACTIONS (nesting) ==================== */
.gp-cell-name { position: relative; display: flex; align-items: center; gap: 0.4rem; overflow: hidden; }
.gp-name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gp-row-actions {
  position: absolute;
  right: 0; top: 0; bottom: 0;
  display: none;
  align-items: center;
  gap: 1px;
  padding-left: 0.4rem;
  background: linear-gradient(to right, transparent, var(--surface-2) 22%, var(--surface-2));
}
.gp-trow:hover .gp-row-actions { display: flex; }
.gp-row-actions button {
  border: none;
  background: var(--surface-3);
  color: var(--text-muted);
  width: 22px; height: 22px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.12s, color 0.12s;
}
.gp-row-actions button:hover { background: var(--accent); color: #fff; }

/* ==================== BI / AVANCE ==================== */
.bi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
}
.bi-grid .bi-wide { grid-column: 1 / -1; }
@media (max-width: 780px) { .bi-grid { grid-template-columns: 1fr; } }
.gauge-wrap { height: 240px; }
#bi-progress-wrap { min-height: 220px; }

/* ==================== LIKES (corazones) ==================== */
.like-btn {
  display: inline-flex; align-items: center; gap: 0.35rem;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 999px; padding: 0.3rem 0.7rem;
  cursor: pointer; font-weight: 700; font-size: 0.82rem;
  transition: transform 0.15s, background 0.15s, border-color 0.15s;
}
.like-btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.like-btn .like-heart { color: #e0245e; font-size: 0.95rem; line-height: 1; }
.like-btn .like-count { min-width: 1ch; }
.like-btn.pop { transform: scale(1.18); }
.like-btn.pop .like-heart { animation: heartPulse 0.32s ease; }
@keyframes heartPulse { 0% { transform: scale(1); } 50% { transform: scale(1.5); } 100% { transform: scale(1); } }

/* ==================== USERS MODAL (ampliado) ==================== */
.add-user-form .chk-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.82rem; color: var(--text-muted); cursor: pointer; }
.add-user-form .chk-row input { width: auto; }
.users-tools { margin: 0.4rem 0 1rem; }
.user-item-actions { display: flex; gap: 0.25rem; flex-shrink: 0; }
.user-item-mail { font-size: 0.74rem; color: var(--text-muted); display: inline-flex; align-items: center; gap: 0.35rem; margin-top: 0.15rem; }
.user-item-ws { font-size: 0.72rem; color: var(--accent, #a78bfa); display: inline-flex; align-items: center; gap: 0.3rem; margin-top: 0.15rem; }
.notify-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); display: inline-block; }
.notify-dot.on { background: var(--success); }

/* ==================== CHECKLIST / SUBTAREAS (tipo Planner) ==================== */
.checklist { margin-top: 0.7rem; border-top: 1px dashed var(--border); padding-top: 0.6rem; }
.checklist-head { font-size: 0.74rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 0.4rem; }
.checklist-head .chk-count { color: var(--accent); }
.checklist-items { display: flex; flex-direction: column; gap: 0.15rem; margin-bottom: 0.4rem; }
.checklist-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.25rem 0.4rem; border-radius: var(--radius-sm); font-size: 0.86rem; cursor: pointer; transition: background 0.12s; }
.checklist-item:hover { background: var(--surface-2); }
.checklist-item input[type="checkbox"] { width: 16px; height: 16px; flex-shrink: 0; accent-color: var(--accent); cursor: pointer; }
.checklist-item .chk-text { flex: 1; }
.checklist-item.done .chk-text { text-decoration: line-through; color: var(--text-faint); }
.checklist-item .chk-del { border: none; background: transparent; color: var(--text-faint); cursor: pointer; font-size: 1.1rem; line-height: 1; padding: 0 0.2rem; opacity: 0; transition: opacity 0.12s, color 0.12s; }
.checklist-item:hover .chk-del { opacity: 1; }
.checklist-item .chk-del:hover { color: var(--danger); }
.checklist-add { display: flex; gap: 0.4rem; align-items: center; }
.checklist-add input { flex: 1; padding: 0.4rem 0.6rem; font-size: 0.84rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); }
.checklist-add input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.checklist-add .btn-icon { background: var(--accent); color: #fff; border-radius: var(--radius-sm); width: 30px; height: 30px; flex-shrink: 0; }

/* ==================== CONFIG DE CORREO (modal usuarios) ==================== */
.mail-settings { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); margin-bottom: 1rem; }
.mail-settings > summary { cursor: pointer; padding: 0.6rem 0.8rem; font-weight: 700; font-size: 0.85rem; color: var(--text); list-style: none; }
.mail-settings > summary::-webkit-details-marker { display: none; }
.mail-settings[open] > summary { border-bottom: 1px solid var(--border); }
.mail-settings-body { padding: 0.8rem; display: flex; flex-direction: column; gap: 0.5rem; }
.mail-settings-body input, .mail-settings-body select { padding: 0.5rem 0.7rem; font-size: 0.85rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
.form-row-mini { display: flex; align-items: center; gap: 0.5rem; }
.form-row-mini label { font-size: 0.8rem; color: var(--text-muted); min-width: 72px; }
.form-row-mini select { flex: 1; }
.mail-settings-actions { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.mail-status { font-size: 0.78rem; color: var(--text-muted); }
.mail-status.ok { color: var(--success); font-weight: 700; }

/* ==================== COLOR DE TARJETAS DE TAREA ==================== */
.task-colored {
  --tc: var(--task-color, #7c5cff);
  border: 1.5px solid color-mix(in srgb, var(--tc) 75%, transparent);
  border-left: 4px solid var(--tc);
  /* relleno sutil solo del lado izquierdo para no apagar el color */
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--tc) 20%, transparent), transparent 46%),
    var(--surface);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--tc) 45%, transparent),
    0 0 16px -3px color-mix(in srgb, var(--tc) 60%, transparent);
  transition: box-shadow 0.18s, transform 0.18s, border-color 0.18s;
}
.task-colored:hover {
  border-color: var(--tc);
  /* contorno neón intenso en el color real de la paleta */
  box-shadow:
    0 0 0 1.5px var(--tc),
    0 0 22px -1px color-mix(in srgb, var(--tc) 85%, transparent),
    0 10px 30px -6px color-mix(in srgb, var(--tc) 55%, transparent);
  transform: translateY(-2px);
}

/* ==================== LOGO EN SIDEBAR ==================== */
.sidebar-brand .sb-logo-icon { width: 34px; height: 34px; flex-shrink: 0; filter: drop-shadow(0 3px 8px rgba(43,127,255,0.4)); }
.sb-logo-tx { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.sb-wordmark {
  font-size: 1.18rem; font-weight: 800; letter-spacing: -0.02em;
  background: linear-gradient(90deg, #4f9bff 0%, #7c5cff 48%, #ec4899 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent; white-space: nowrap;
}
.sb-sub { font-size: 0.52rem; font-weight: 800; letter-spacing: 0.12em; color: #19b6e6; margin-top: 2px; white-space: nowrap; }

/* Paleta en el formulario de tarea */
.color-swatches { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin-top: 0.2rem; }
.color-swatches .swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; background: var(--sw); cursor: pointer; padding: 0; box-shadow: 0 1px 3px rgba(0,0,0,0.25); transition: transform 0.12s, border-color 0.12s; }
.color-swatches .swatch:hover { transform: scale(1.12); }
.color-swatches .swatch.sel { border-color: var(--text); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sw) 45%, transparent); }
.color-swatches .swatch.custom { background: conic-gradient(#ef4444,#f59e0b,#eab308,#10b981,#06b6d4,#2b7fff,#7c3aed,#ec4899,#ef4444); position: relative; overflow: hidden; display: inline-flex; }
.color-swatches .swatch.custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* Dots de recolor rápido en cada tarjeta (aparecen al pasar el mouse) */
.task-palette { display: flex; gap: 5px; margin-top: 0.7rem; opacity: 0; transition: opacity 0.15s; }
.task-card:hover .task-palette { opacity: 1; }
.task-palette .dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid transparent; background: var(--sw); cursor: pointer; padding: 0; transition: transform 0.12s; }
.task-palette .dot:hover { transform: scale(1.25); }
.task-palette .dot.sel { border-color: var(--text); }
@media (max-width: 860px) { .task-palette { opacity: 1; } }

/* ==================== WIDGET DE MÚSICA (SPOTIFY) ==================== */
.music-widget { position: fixed; right: 18px; bottom: 18px; z-index: 150; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.music-fab { width: 54px; height: 54px; border-radius: 50%; border: none; cursor: pointer; background: #1DB954; color: #fff; box-shadow: 0 8px 24px rgba(29,185,84,0.45); display: flex; align-items: center; justify-content: center; transition: transform 0.15s, box-shadow 0.2s; }
.music-fab:hover { transform: scale(1.08); box-shadow: 0 10px 28px rgba(29,185,84,0.6); }
.music-fab svg { width: 28px; height: 28px; }
.music-panel { width: 330px; max-width: calc(100vw - 36px); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 12px; display: flex; flex-direction: column; gap: 10px; animation: rise .25s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.music-widget.collapsed .music-panel { display: none; }
.music-head { display: flex; align-items: center; justify-content: space-between; }
.music-title { display: flex; align-items: center; gap: 7px; font-weight: 700; font-size: 0.92rem; color: var(--text); }
.music-title svg { width: 18px; height: 18px; color: #1DB954; }
.music-form { display: flex; gap: 6px; }
.music-form input { flex: 1; min-width: 0; padding: 0.5rem 0.6rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); font-size: 0.82rem; outline: none; }
.music-form input:focus { border-color: #1DB954; }
.music-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.music-presets button { border: 1px solid var(--border); background: var(--surface-2); color: var(--text-muted); border-radius: 999px; padding: 0.25rem 0.6rem; font-size: 0.72rem; cursor: pointer; transition: border-color 0.12s, color 0.12s; }
.music-presets button:hover { border-color: #1DB954; color: #1DB954; }
#music-embed { min-height: 2px; }
#music-embed iframe { display: block; }
.music-tabs { display: flex; gap: 5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.music-tab { flex: 1; border: none; background: transparent; color: var(--text-muted); font-weight: 700; font-size: 0.78rem; padding: 0.38rem; border-radius: 7px; cursor: pointer; transition: background 0.12s, color 0.12s; }
.music-tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.music-src { display: flex; flex-direction: column; gap: 10px; }
.music-hint { font-size: 0.68rem; color: var(--text-muted); margin: 0; line-height: 1.4; }

/* ==================== CREAR VARIAS TAREAS ==================== */
#bulk-text {
  width: 100%; resize: vertical; min-height: 150px;
  padding: 0.8rem 0.9rem; font-size: 0.9rem; line-height: 1.5;
  font-family: 'Consolas', ui-monospace, monospace;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); outline: none; margin-bottom: 0.9rem;
}
#bulk-text:focus { border-color: var(--accent); background: var(--surface); }
#bulk-form-container code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; font-size: 0.82em; }

/* ==================== TAREAS: CUADRÍCULA FLEXIBLE ==================== */
/* Por defecto (laptop): tarjetas cómodas y grandes (2 por fila en pantallas típicas) */
.tasks-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); gap: 1rem; align-items: start; }
.tasks-list.cols-1 { grid-template-columns: 1fr; }
.tasks-list.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tasks-list.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
/* En teléfonos siempre 1 columna para que la tarea se vea completa */
@media (max-width: 640px) { .tasks-list, .tasks-list.cols-2, .tasks-list.cols-3 { grid-template-columns: 1fr; } }

/* ==================== MODO "TELÉFONO" (botón de la barra superior) ==================== */
body.force-phone .view-container { max-width: 480px; margin: 0 auto; padding: 1rem; }
body.force-phone .tasks-list,
body.force-phone .tasks-list.cols-2,
body.force-phone .tasks-list.cols-3 { grid-template-columns: 1fr !important; }
body.force-phone .dashboard-grid,
body.force-phone .charts-grid,
body.force-phone .bi-grid { grid-template-columns: 1fr !important; }
body.force-phone .kpi-grid { grid-template-columns: 1fr 1fr !important; }
body.force-phone .cols-toggle { display: none; }
body.force-phone .section-header { flex-direction: column; align-items: stretch; gap: 0.6rem; }
body.force-phone .section-header > div { display: flex; width: 100%; gap: 0.5rem; }
body.force-phone .section-header > div .btn { flex: 1; }

/* Selector de columnas (1 / 2 / auto) y de vista (Lista / Tablero) */
.cols-toggle, .view-toggle { display: inline-flex; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.cols-toggle button, .view-toggle button { border: none; background: transparent; color: var(--text-muted); font-weight: 700; font-size: 0.75rem; padding: 0.3rem 0.6rem; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.cols-toggle button.active, .view-toggle button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
/* El selector de COLUMNAS se oculta en móvil; el de VISTA (Lista/Tablero) NO. */
@media (max-width: 640px) {
  .cols-toggle { display: none; }
  #view-toggle { display: none; }      /* en móvil queda el de arriba (view-toggle-top) */
}

/* Anti-desborde horizontal (gráficas y contenido) en móvil */
.main-content { overflow-x: hidden; }
.chart-container { width: 100%; }
.chart-container canvas { max-width: 100% !important; }

/* Mosaicos con forma: título legible (hasta 2 líneas) */
.task-tile .tile-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.task-tile.shape-heart, .task-tile.shape-cat { padding-left: 34px; padding-right: 34px; }

/* Foto de perfil */
.sidebar-user .avatar { overflow: hidden; cursor: pointer; }
.sidebar-user .avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Selector de forma en el formulario */
.shape-swatches { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.2rem; }
.shape-sw { display: flex; flex-direction: column; align-items: center; gap: 3px; background: none; border: 1.5px solid var(--border); border-radius: 10px; padding: 7px 9px; cursor: pointer; color: var(--text-muted); transition: border-color 0.12s, color 0.12s; }
.shape-sw small { font-size: 0.62rem; }
.shape-sw:hover { border-color: var(--accent); }
.shape-sw.sel { border-color: var(--accent); color: var(--text); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.shape-prev { width: 26px; height: 26px; background: linear-gradient(135deg, #7c5cff, #ec4899); display: block; }
.shape-prev.shape-card { border-radius: 6px; }

/* Formas (compartidas por preview y tiles) */
.shape-hex { clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); }
.shape-shield { clip-path: polygon(50% 0, 100% 20%, 100% 60%, 50% 100%, 0 60%, 0 20%); }
.shape-heart, .shape-cat, .shape-bat { -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; -webkit-mask-position: center; mask-position: center; -webkit-mask-size: 100% 100%; mask-size: 100% 100%; }
.shape-heart { -webkit-mask-image: var(--m-heart); mask-image: var(--m-heart); }
.shape-cat { -webkit-mask-image: var(--m-cat); mask-image: var(--m-cat); }
.shape-bat { -webkit-mask-image: var(--m-bat); mask-image: var(--m-bat); }

/* Tile con forma (compacto) */
.task-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  min-height: 175px; padding: 30px 26px; cursor: pointer; color: #fff; border: none !important;
  background: var(--task-color, #7c5cff);
  filter: drop-shadow(0 3px 10px color-mix(in srgb, var(--task-color, #7c5cff) 55%, transparent));
  transition: transform 0.15s, filter 0.2s;
}
.task-tile:hover { transform: translateY(-3px) scale(1.02); filter: drop-shadow(0 0 15px color-mix(in srgb, var(--task-color, #7c5cff) 90%, transparent)); }
.task-tile .tile-ico { font-size: 1.3rem; margin-bottom: 4px; }
.task-tile .tile-title { font-weight: 800; font-size: 0.95rem; line-height: 1.15; text-shadow: 0 1px 3px rgba(0,0,0,0.45); word-break: break-word; max-width: 100%; }
.task-tile .tile-meta { font-size: 0.68rem; opacity: 0.95; margin-top: 6px; text-shadow: 0 1px 2px rgba(0,0,0,0.4); }
.task-tile.is-done { opacity: 0.78; }
.task-tile.shape-bat { min-height: 150px; }

/* ==================== RESPONSIVE FINO (móvil / tablet / iPhone) ==================== */
/* Altura real en Safari móvil (evita saltos con la barra de direcciones) */
@supports (height: 100dvh) {
  .app-shell { min-height: 100dvh; }
  .sidebar { height: 100dvh; }
}
/* La navegación del sidebar hace scroll si hay muchos proyectos */
.sidebar-nav { overflow-y: auto; }

/* Áreas seguras del iPhone (notch arriba, barra inferior) */
.topbar { padding-left: max(1.4rem, env(safe-area-inset-left)); padding-right: max(1.4rem, env(safe-area-inset-right)); }
.music-widget { right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); }

/* Tablets */
@media (max-width: 1024px) {
  .view-container { padding: 1.2rem; }
}

/* Teléfonos */
@media (max-width: 860px) {
  .sidebar { width: min(84vw, 300px); }
  .sidebar-nav { padding-bottom: 1rem; }
  .topbar { height: auto; min-height: 56px; padding-top: max(0.45rem, env(safe-area-inset-top)); padding-bottom: 0.45rem; }
  .topbar h1 { font-size: 1.05rem; }
  .topbar-right { gap: 0.3rem; }
  .theme-toggle .toggle-track { display: none; } /* compacta el switch de tema en móvil */
  .view-container { padding: 1rem; padding-bottom: 2rem; }

  /* Encabezados de sección: título arriba, acciones abajo a lo ancho */
  .section-header { flex-direction: column; align-items: stretch; gap: 0.6rem; }
  .section-header > div { display: flex; width: 100%; gap: 0.5rem; }
  .section-header > div .btn { flex: 1; }
  .section-header > .btn { width: 100%; }

  .filters-bar select { flex: 1; min-width: 0; }
  .modal-overlay { padding: 0.6rem; }
  .modal-panel { max-height: 92vh; }
}

/* Teléfonos chicos */
@media (max-width: 520px) {
  .form-row { flex-direction: column; gap: 0.6rem; }
  .form-row .form-group { min-width: 0; width: 100%; }
  .topbar h1 { font-size: 0.98rem; }
  .wallpaper-dropdown { width: min(230px, 78vw); }
  .music-panel { width: calc(100vw - 28px); }
  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); }
  .project-view .tabs .tab { padding: 0.6rem 0.7rem; font-size: 0.8rem; }
}

/* ==================== DASHBOARD REORGANIZADO ==================== */
.dash-section { margin-bottom: 1.25rem; }
.dash-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.dash-chart { min-width: 0; }
.dash-chart .chart-title { font-size: 0.86rem; font-weight: 700; margin-bottom: 0.6rem; color: var(--text-muted); text-align: center; }
/* Altura cómoda para que las gráficas NO se aplasten */
.dash-chart .chart-container { height: 300px; }
#home-projects-wrap { height: 300px; }

.dash-lists { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-bottom: 1.25rem; }

/* En pantallas medianas/chicas, cada bloque pasa a una sola columna */
@media (max-width: 900px) {
  .dash-charts { grid-template-columns: 1fr; gap: 1.25rem; }
  .dash-lists { grid-template-columns: 1fr; }
  .dash-chart .chart-container, #home-projects-wrap { height: 260px; }
}
/* Modo teléfono forzado: todo en una columna */
body.force-phone .dash-charts, body.force-phone .dash-lists { grid-template-columns: 1fr !important; }

/* ==================== SWITCH AUTO-PROGRAMAR (cronograma) ==================== */
.autosched-switch { display: inline-flex; align-items: center; gap: 0.45rem; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); border-radius: 999px; padding: 0.3rem 0.7rem; font-size: 0.78rem; font-weight: 700; cursor: pointer; transition: color 0.15s, border-color 0.15s; }
.autosched-switch:hover { border-color: var(--border-strong); }
.autosched-switch .sw-track { width: 32px; height: 18px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background 0.18s; flex-shrink: 0; }
.autosched-switch .sw-thumb { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform 0.18s; box-shadow: 0 1px 2px rgba(0,0,0,0.3); }
.autosched-switch.on { color: var(--accent); border-color: var(--accent); }
.autosched-switch.on .sw-track { background: var(--accent); }
.autosched-switch.on .sw-thumb { transform: translateX(14px); }

/* ==================== BÚSQUEDA RÁPIDA (topbar) ==================== */
.topbar-search { position: relative; flex: 1; max-width: 420px; margin: 0 1rem; }
.topbar-search .ts-ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); font-size: 0.85rem; opacity: 0.6; pointer-events: none; }
.topbar-search input { width: 100%; padding: 0.5rem 0.8rem 0.5rem 2.1rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); color: var(--text); font-size: 0.86rem; outline: none; }
.topbar-search input:focus { border-color: var(--accent); background: var(--surface); }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); max-height: 60vh; overflow-y: auto; z-index: 130; padding: 4px; }
.search-results .sr-head { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); font-weight: 700; padding: 0.4rem 0.6rem 0.2rem; }
.search-results .sr-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.6rem; border-radius: var(--radius-sm); cursor: pointer; font-size: 0.86rem; }
.search-results .sr-item:hover { background: var(--surface-2); }
.search-results .sr-ico { font-size: 0.9rem; }
.search-results .sr-sub { margin-left: auto; font-size: 0.72rem; color: var(--text-muted); }
.search-results .sr-empty { padding: 0.8rem; text-align: center; color: var(--text-muted); font-size: 0.85rem; }
@media (max-width: 860px) { .topbar-search { display: none; } }

/* ==================== ETIQUETAS ==================== */
.tag-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.1rem; }
.tag-chip { font-size: 0.72rem; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 0.12rem 0.55rem; cursor: pointer; }
.tag-chip:hover { filter: brightness(0.95); }
.task-remind { font-size: 0.74rem; color: var(--warning); }

/* ==================== VISTA HOY ==================== */
.today-item.overdue .mi-date { color: var(--danger); font-weight: 700; }
.today-item.today .mi-date { color: var(--warning); font-weight: 700; }

/* ==================== REPORTES PDF ==================== */
.report-card { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.9rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); margin-bottom: 0.8rem; }
.report-title { font-weight: 700; font-size: 0.92rem; }
.report-sub { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.2rem; }

/* ==================== BADGE DE TAREA COMPARTIDA ==================== */
.shared-badge { font-size: 0.7rem; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 0.1rem 0.5rem; white-space: nowrap; }

/* ==================== CHAT ENTRE USUARIOS (tipo messenger) ==================== */
.chat-widget { position: fixed; left: 18px; bottom: 18px; z-index: 150; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.chat-widget { left: max(18px, env(safe-area-inset-left)); bottom: max(18px, env(safe-area-inset-bottom)); }
.chat-fab { position: relative; width: 54px; height: 54px; border-radius: 50%; border: none; cursor: pointer; background: linear-gradient(135deg, #2b7fff, #7c5cff); color: #fff; box-shadow: 0 8px 24px rgba(124,92,255,0.5); display: flex; align-items: center; justify-content: center; transition: transform 0.15s; }
.chat-fab:hover { transform: scale(1.08); }
.chat-fab svg { width: 26px; height: 26px; }
.chat-badge { position: absolute; top: -3px; right: -3px; background: #ef4444; color: #fff; font-size: 0.66rem; font-weight: 700; min-width: 18px; height: 18px; border-radius: 999px; display: flex; align-items: center; justify-content: center; padding: 0 4px; border: 2px solid var(--surface); }
.chat-panel {
  position: absolute; left: 0; bottom: 66px;
  width: 340px; max-width: calc(100vw - 36px);
  height: min(500px, calc(100vh - 150px));
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; animation: rise .25s ease both;
}
.chat-widget.collapsed .chat-panel { display: none; }

/* Modo GLASS + contorno NEÓN (se activa con el botón del chat) */
body.chat-glass .chat-panel {
  background: color-mix(in srgb, var(--surface) 55%, transparent);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1.5px solid rgba(124,92,255,0.6);
  box-shadow: 0 0 0 1px rgba(124,92,255,0.25), 0 0 22px rgba(124,92,255,0.5), 0 0 48px rgba(43,127,255,0.35), var(--shadow-lg);
}
body.chat-glass .chat-messages { background: transparent; }
body.chat-glass .chat-bubble { backdrop-filter: blur(4px); }
.chat-glass-btn.on { color: #a98bff; }
.chat-panel.buzzing { animation: buzz 0.6s linear; }
@keyframes buzz { 0%,100%{transform:translate(0,0)} 10%{transform:translate(-4px,2px)} 20%{transform:translate(4px,-2px)} 30%{transform:translate(-5px,-2px)} 40%{transform:translate(5px,2px)} 50%{transform:translate(-3px,3px)} 60%{transform:translate(3px,-3px)} 70%{transform:translate(-4px,1px)} 80%{transform:translate(4px,-1px)} 90%{transform:translate(-2px,2px)} }
.chat-head { display: flex; align-items: center; gap: 0.5rem; padding: 0.7rem 0.9rem; background: linear-gradient(135deg, #2b7fff, #7c5cff); color: #fff; cursor: move; touch-action: none; }
.chat-head .btn-icon { color: #fff; }
.chat-title { font-weight: 700; font-size: 0.95rem; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-contacts { flex: 1; overflow-y: auto; }
.chat-contact { display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem 0.9rem; cursor: pointer; border-bottom: 1px solid var(--border); }
.chat-contact:hover { background: var(--surface-2); }
.chat-avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg,#2b7fff,#7c5cff); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.chat-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.chat-contact-main { flex: 1; min-width: 0; }
.chat-contact-name { font-weight: 600; font-size: 0.88rem; }
.chat-contact-sub { font-size: 0.74rem; color: var(--text-muted); }
.chat-unread { background: #ef4444; color: #fff; font-size: 0.68rem; font-weight: 700; min-width: 18px; height: 18px; border-radius: 999px; display: flex; align-items: center; justify-content: center; padding: 0 5px; }
.chat-empty { padding: 1.5rem 1rem; text-align: center; color: var(--text-muted); font-size: 0.85rem; }
.chat-convo { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-messages { flex: 1; overflow-y: auto; padding: 0.8rem; display: flex; flex-direction: column; gap: 0.4rem; background: var(--surface-2); }
.chat-msg { display: flex; }
.chat-msg.mine { justify-content: flex-end; }
.chat-bubble { max-width: 78%; background: var(--surface); border: 1px solid var(--border); padding: 0.5rem 0.7rem; border-radius: 14px; font-size: 0.86rem; line-height: 1.35; position: relative; word-break: break-word; }
.chat-msg.mine .chat-bubble { background: linear-gradient(135deg,#2b7fff,#7c5cff); color: #fff; border: none; }
.chat-time { display: block; font-size: 0.62rem; opacity: 0.7; margin-top: 3px; text-align: right; }
.chat-mention { font-weight: 700; color: #2b7fff; text-decoration: underline; cursor: pointer; }
.chat-msg.mine .chat-mention { color: #fff; }
.chat-buzz-msg { text-align: center; font-size: 0.76rem; font-weight: 700; color: var(--warning); padding: 0.2rem; }
.chat-input { display: flex; align-items: center; gap: 4px; padding: 0.5rem; border-top: 1px solid var(--border); }
.chat-input input { flex: 1; min-width: 0; padding: 0.5rem 0.7rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); color: var(--text); font-size: 0.86rem; outline: none; }
.chat-input input:focus { border-color: var(--accent); }
.chat-input button { border: none; background: transparent; cursor: pointer; font-size: 1.1rem; padding: 4px 6px; border-radius: 8px; }
.chat-emoji-btn:hover, .chat-buzz-btn:hover { background: var(--surface-3); }
.chat-send-btn { color: var(--accent); font-size: 1.2rem !important; }
.chat-emoji-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 0.4rem; border-top: 1px solid var(--border); background: var(--surface); }
.chat-emoji-bar button { border: none; background: transparent; cursor: pointer; font-size: 1.2rem; padding: 3px 5px; border-radius: 6px; }
.chat-emoji-bar button:hover { background: var(--surface-2); }
@media (max-width: 520px) { .chat-panel { width: calc(100vw - 28px); } }

/* ==================== BADGE "CREADOR" (coronita) ==================== */
.badge-creator { background: linear-gradient(135deg,#f59e0b,#eab308); color: #3a2a00; font-weight: 700; }

/* ==================== VISTA DETALLE DE TAREA (modal lectura) ==================== */
.task-detail-meta { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.3rem 0 0.9rem; }
.td-check { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0.1rem; font-size: 0.9rem; }
.td-check input { width: 16px; height: 16px; accent-color: var(--accent); }
.td-check.done span { text-decoration: line-through; color: var(--text-faint); }
.td-section-title { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); font-weight: 700; margin: 0.8rem 0 0.3rem; }
.td-progress-wrap { margin: 0.5rem 0; }

/* ==================== CHAT: GIFs y arrastrable ==================== */
.chat-gif-btn { font-size: 0.72rem !important; font-weight: 800; color: var(--accent); border: 1px solid var(--border) !important; border-radius: 6px; }
.chat-gif-bar { border-top: 1px solid var(--border); background: var(--surface); padding: 0.5rem; max-height: 220px; overflow-y: auto; }
.chat-gif-search { display: flex; gap: 6px; margin-bottom: 0.4rem; }
.chat-gif-search input { flex: 1; min-width: 0; padding: 0.4rem 0.6rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); font-size: 0.82rem; outline: none; }
.chat-gif-results { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 4px; }
.chat-gif-results img { width: 100%; height: 66px; object-fit: cover; border-radius: 6px; cursor: pointer; transition: transform 0.12s; }
.chat-gif-results img:hover { transform: scale(1.05); }
.chat-gif-bubble img { max-width: 180px; border-radius: 12px; display: block; }
.chat-fab { touch-action: none; }
.music-fab { touch-action: none; }
.chat-widget, .music-widget { user-select: none; }

/* ==================== AYUDA DE BÚSQUEDA YOUTUBE ==================== */
.yt-help { font-size: 0.82rem; color: var(--text-muted); line-height: 1.4; }
.yt-help p { margin-bottom: 0.5rem; }
.yt-help .btn { display: inline-block; }

/* ==================== ESTADOS / LEDs y CORONA EN EL CHAT ==================== */
.led { width: 10px; height: 10px; border-radius: 50%; display: inline-block; border: 2px solid var(--surface); flex-shrink: 0; }
.led-green { background: #22c55e; box-shadow: 0 0 6px #22c55e; }
.led-yellow { background: #eab308; box-shadow: 0 0 6px #eab308; }
.led-red { background: #ef4444; box-shadow: 0 0 7px #ef4444; animation: ledPulse 1.1s ease-in-out infinite; }
.led-black { background: #4b5563; box-shadow: none; }
@keyframes ledPulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

.crown { color: #eab308; filter: drop-shadow(0 0 2px rgba(234,179,8,0.5)); }
.crown.mini { font-size: 0.7rem; }

/* LED sobre el avatar del contacto (completo, sin encimarse ni cortarse) */
.chat-avatar { position: relative; overflow: visible; }
.chat-avatar .led { position: absolute; bottom: -2px; right: -2px; width: 12px; height: 12px; z-index: 2; }

/* Barra de "mi estado" arriba de los contactos */
.my-status-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.my-status-bar .mys-label { font-size: 0.72rem; font-weight: 700; color: var(--text-muted); width: 100%; }
.mys-opt { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); border-radius: 999px; padding: 0.22rem 0.55rem; font-size: 0.72rem; cursor: pointer; }
.mys-opt.active { border-color: var(--accent); color: var(--text); font-weight: 700; box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }

/* Encabezado del chat con avatar + estado */
.chat-head-avatar { position: relative; width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,0.25); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.chat-head-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.chat-head-avatar .led { position: absolute; bottom: -1px; right: -1px; border-color: #3b63e0; }
.chat-title { display: flex; align-items: center; gap: 0.5rem; }
.chat-head-name { display: flex; flex-direction: column; line-height: 1.1; }
.chat-head-name small { font-size: 0.66rem; opacity: 0.85; font-weight: 400; }

/* Avatares junto a las burbujas */
.chat-msg { align-items: flex-end; gap: 6px; }
.chat-msg-avatar { position: relative; width: 26px; height: 26px; border-radius: 50%; overflow: visible; background: linear-gradient(135deg,#2b7fff,#7c5cff); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 0.72rem; font-weight: 700; flex-shrink: 0; }
.chat-msg-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.chat-msg-avatar .crown.mini { position: absolute; top: -8px; right: -4px; }
.chat-msg.mine { flex-direction: row-reverse; }

/* ==================== BUSCADOR DE MÚSICA (Jamendo / Deezer) ==================== */
.mus-source-row { display: flex; gap: 0.8rem; margin: 0.4rem 0; flex-wrap: wrap; }
.mus-radio { display: inline-flex; align-items: center; gap: 5px; font-size: 0.74rem; color: var(--text-muted); cursor: pointer; }
.mus-radio input { width: auto; }
.mus-results { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; }
.mus-loading { padding: 0.8rem; text-align: center; color: var(--text-muted); font-size: 0.82rem; }
.mus-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem; border-radius: 8px; cursor: pointer; }
.mus-item:hover { background: var(--surface-2); }
.mus-cover { width: 36px; height: 36px; border-radius: 6px; background: var(--surface-3); display: flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0; }
.mus-cover img { width: 100%; height: 100%; object-fit: cover; }
.mus-meta { flex: 1; min-width: 0; }
.mus-title { font-size: 0.82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mus-artist { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mus-play { color: var(--accent); font-size: 0.9rem; }
.mus-player { margin-top: 0.6rem; border-top: 1px solid var(--border); padding-top: 0.6rem; }
.mus-now { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem; }
.mus-now img { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; }

/* ==================== SECCIÓN "MI MÚSICA" ==================== */
#music-service-tabs { flex-wrap: wrap; }
.music-tab-panel { margin-top: 0.4rem; }
#music-view .music-form { display: flex; gap: 0.5rem; margin-bottom: 0.4rem; }
#music-view .music-form input { flex: 1; min-width: 0; padding: 0.6rem 0.8rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); outline: none; }
#music-view .music-form input:focus { border-color: var(--accent); background: var(--surface); }
#music-view .mus-results { max-height: 340px; }
.connect-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
@media (max-width: 640px) { .connect-grid { grid-template-columns: 1fr; } }
.connect-card { display: flex; align-items: center; gap: 0.7rem; padding: 0.9rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.connect-card .connect-ico { font-size: 1.4rem; }
.connect-card b { display: block; font-size: 0.9rem; }
.connect-card small { display: block; font-size: 0.74rem; color: var(--text-muted); margin-top: 0.15rem; }

/* ==================== CHAT: GRUPOS Y STICKERS ==================== */
.chat-section-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); font-weight: 700; padding: 0.5rem 0.9rem 0.2rem; }
.group-avatar { background: linear-gradient(135deg,#f59e0b,#ec4899) !important; }
.chat-group-btn { font-size: 0.78rem !important; }
.chat-newgroup { padding: 0.8rem; display: flex; flex-direction: column; gap: 0.6rem; overflow-y: auto; }
.group-name-input { padding: 0.55rem 0.7rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); outline: none; }
.group-name-input:focus { border-color: var(--accent); }
.group-members { display: flex; flex-direction: column; gap: 2px; max-height: 240px; overflow-y: auto; }
.group-pick { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.5rem; border-radius: 8px; font-size: 0.85rem; cursor: pointer; }
.group-pick:hover { background: var(--surface-2); }
.group-pick input { width: auto; }
.group-pick small { color: var(--text-muted); }
.group-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }
.chat-from { display: block; font-size: 0.68rem; font-weight: 700; color: var(--accent); margin-bottom: 2px; }
.chat-msg.mine .chat-from { display: none; }

.chat-sticker-btn { font-size: 1.1rem !important; }
.chat-sticker-bar { display: flex; flex-wrap: wrap; gap: 4px; padding: 0.5rem; border-top: 1px solid var(--border); background: var(--surface); max-height: 160px; overflow-y: auto; }
.chat-sticker-bar button { border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; font-size: 0.82rem; padding: 0.4rem 0.6rem; border-radius: 10px; white-space: nowrap; }
.chat-sticker-bar button:hover { border-color: var(--accent); background: var(--surface-3); }
.chat-sticker-bubble { font-size: 1.5rem; padding: 0.3rem 0.1rem; letter-spacing: 1px; }

/* ==================== KANBAN (tablero) ==================== */
.kanban-board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.9rem; align-items: stretch; }
.kanban-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); min-height: 60vh; display: flex; flex-direction: column; transition: background 0.15s, box-shadow 0.15s; }
.kanban-col.drag-over { background: color-mix(in srgb, var(--accent) 12%, var(--surface-2)); box-shadow: inset 0 0 0 2px var(--accent); }
.kanban-col-head { display: flex; align-items: center; gap: 0.45rem; padding: 0.7rem 0.8rem; font-weight: 700; font-size: 0.85rem; border-bottom: 1px solid var(--border); }
.kanban-col-head .kc-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--kc); }
.kanban-col-head .kc-count { margin-left: auto; background: var(--surface-3); color: var(--text-muted); border-radius: 999px; font-size: 0.72rem; padding: 0.05rem 0.5rem; }
.kanban-col-body { padding: 0.6rem; display: flex; flex-direction: column; gap: 0.5rem; flex: 1; min-height: 100px; }
.kanban-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-faint); text-align: center; font-size: 0.9rem; padding: 0.5rem; border: 2px dashed var(--border); border-radius: 8px; }
.kanban-card { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--task-color, #7c5cff); border-radius: 8px; padding: 0.6rem 0.7rem; cursor: grab; box-shadow: var(--shadow); transition: transform 0.1s, box-shadow 0.15s; }
.kanban-card:hover { box-shadow: 0 4px 14px color-mix(in srgb, var(--task-color, #7c5cff) 30%, transparent); }
.kanban-card:active { cursor: grabbing; }
.kanban-card { position: relative; }
.kc-actions { position: absolute; top: 5px; right: 5px; display: flex; gap: 2px; opacity: 0; transition: opacity 0.12s; }
.kanban-card:hover .kc-actions { opacity: 1; }
.kc-btn { border: none; background: var(--surface-2); color: var(--text-muted); width: 24px; height: 24px; border-radius: 6px; cursor: pointer; font-size: 0.78rem; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.kc-btn:hover { background: var(--surface-3); color: var(--text); }
.kc-del:hover { background: var(--danger); color: #fff; }
.kanban-card .kc-title { font-size: 0.86rem; font-weight: 600; margin-bottom: 0.35rem; padding-right: 54px; }
@media (max-width: 860px) { .kc-actions { opacity: 1; } }
.kanban-card .kc-meta { display: flex; align-items: center; gap: 0.4rem; font-size: 0.72rem; color: var(--text-muted); }
.kanban-card .kc-due { }
.kanban-card .tag-chips { margin-top: 0.4rem; }
/* En pantallas chicas y en modo teléfono: columnas en FILA con scroll lateral
   (estilo Trello), para que se vean los encabezados de todas y no quede la
   primera columna vacía ocupando la pantalla. */
@media (max-width: 920px) {
  .kanban-board {
    display: flex; grid-template-columns: none;
    overflow-x: auto; gap: 0.7rem; padding-bottom: 0.5rem;
    scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
  }
  .kanban-board .kanban-col { flex: 0 0 82%; max-width: 320px; min-height: 55vh; scroll-snap-align: start; }
}
body.force-phone .kanban-board {
  display: flex !important; grid-template-columns: none !important;
  overflow-x: auto; gap: 0.7rem; padding-bottom: 0.5rem;
  scroll-snap-type: x proximity;
}
body.force-phone .kanban-board .kanban-col { flex: 0 0 82%; max-width: 320px; scroll-snap-align: start; }
/* Mientras arrastras: resalta todas las columnas como zonas de soltado */
body.kanban-dragging .kanban-col { outline: 1px dashed color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: -4px; }
body.kanban-dragging .kanban-card { cursor: grabbing; }

/* ==================== ORGANIZACIONES (workspaces) ==================== */
.ws-form { display: flex; gap: 0.4rem; margin-bottom: 0.6rem; }
.ws-form input { flex: 1; min-width: 0; padding: 0.5rem 0.7rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); outline: none; }
.ws-form input:focus { border-color: var(--accent); }
.ws-list { display: flex; flex-direction: column; gap: 0.3rem; }
.ws-item { display: flex; align-items: center; justify-content: space-between; padding: 0.45rem 0.6rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.ws-name { font-size: 0.85rem; font-weight: 600; }
.ws-count { font-size: 0.72rem; color: var(--text-muted); }

/* ==================== MINI-EDITOR (popover rápido) ==================== */
.quick-edit-pop {
  position: absolute; z-index: 300; width: min(320px, 92vw);
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.4); padding: 0.9rem;
  display: flex; flex-direction: column; gap: 0.6rem;
}
.quick-edit-pop .qe-row { display: flex; flex-direction: column; gap: 0.3rem; }
.quick-edit-pop .qe-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.quick-edit-pop label { font-size: 0.72rem; color: var(--text-muted); display: flex; flex-direction: column; gap: 0.2rem; }
.quick-edit-pop input, .quick-edit-pop select {
  width: 100%; padding: 0.4rem 0.5rem; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface-2); color: var(--text); font-size: 0.85rem;
}
.quick-edit-pop .qe-title { font-size: 0.95rem; font-weight: 600; }
.quick-edit-pop .qe-prog { font-size: 0.78rem; color: var(--text); display: flex; flex-direction: column; gap: 0.1rem; background: var(--surface-2); padding: 0.45rem 0.6rem; border-radius: 8px; }
.quick-edit-pop .qe-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.2rem; }

/* Barra de progreso en la tarjeta Kanban + porcentaje numérico */
.kc-progress-row { display: flex; align-items: center; gap: 0.4rem; margin-top: 0.4rem; }
.kc-progress { flex: 1; height: 5px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.kc-progress-fill { height: 100%; background: var(--task-color, var(--accent)); border-radius: 999px; transition: width 0.3s; }
.kc-progress-pct { font-size: 0.68rem; font-weight: 700; color: var(--text-muted); min-width: 30px; text-align: right; }

/* ==================== DETALLE DE TAREA EDITABLE ==================== */
.td-title-input {
  flex: 1; font-size: 1.1rem; font-weight: 700; color: var(--text);
  background: transparent; border: 1px solid transparent; border-radius: 8px;
  padding: 0.3rem 0.5rem; min-width: 0;
}
.td-title-input:hover:not(:read-only) { border-color: var(--border); }
.td-title-input:focus { outline: none; border-color: var(--accent); background: var(--surface-2); }
.td-title-input:read-only { cursor: default; }

.td-prio-select {
  border: 1px solid var(--border); border-radius: 999px; padding: 0.25rem 0.6rem;
  font-size: 0.78rem; font-weight: 600; background: var(--surface-2); color: var(--text); cursor: pointer;
}
.td-prio-select.priority-critical { color: #ef4444; border-color: #ef4444; }
.td-prio-select.priority-high { color: #f97316; border-color: #f97316; }
.td-prio-select.priority-medium { color: #fb923c; border-color: #fb923c; }
.td-prio-select.priority-low { color: #eab308; border-color: #eab308; }

.td-check { display: flex; align-items: center; gap: 0.5rem; padding: 0.3rem 0; }
.td-check-del {
  margin-left: auto; background: none; border: none; color: var(--text-faint);
  font-size: 1.1rem; cursor: pointer; line-height: 1; padding: 0 0.3rem;
}
.td-check-del:hover { color: var(--danger); }

.td-add-item { display: flex; gap: 0.4rem; margin-top: 0.6rem; }
.td-add-item input {
  flex: 1; padding: 0.5rem 0.7rem; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface-2); color: var(--text); font-size: 0.85rem;
}
.td-add-item input:focus { outline: none; border-color: var(--accent); }

/* Pista del modo de estado automático en el chat */
.mys-hint { width: 100%; font-size: 0.66rem; color: var(--text-faint); margin-top: 0.3rem; line-height: 1.3; }

/* ==================== ROLES (etiqueta y selector) ==================== */
.role-tag { display: inline-block; padding: 0.05rem 0.4rem; border-radius: 999px; font-size: 0.68rem; font-weight: 700; }
.role-tag.role-creator { background: color-mix(in srgb, #f59e0b 22%, transparent); color: #f59e0b; }
.role-tag.role-admin { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); }
.role-tag.role-user { background: var(--surface-3); color: var(--text-muted); }
.role-select {
  border: 1px solid var(--border); border-radius: 6px; padding: 0.1rem 0.35rem;
  font-size: 0.7rem; font-weight: 600; background: var(--surface-2); color: var(--text); cursor: pointer;
}
#new-role { padding: 0.5rem 0.6rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); font-size: 0.85rem; }

/* ==================== "ESCRIBIENDO..." en el chat ==================== */
.chat-typing { display: flex; align-items: center; gap: 0.4rem; padding: 0.3rem 0.6rem; font-size: 0.72rem; color: var(--text-muted); font-style: italic; }
.chat-typing-dots { display: inline-flex; gap: 3px; }
.chat-typing-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); display: inline-block; animation: typingBlink 1.2s infinite ease-in-out; }
.chat-typing-dots i:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBlink { 0%, 60%, 100% { opacity: 0.25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
