/* Pilas — tema visual. Profesional, limpio, sin adornos. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-soft: #475467;
  --text-faint: #98a2b3;
  --primary: #2f5fde;
  --primary-hover: #2650c0;
  --primary-soft: #eef2ff;
  --danger: #d92d20;
  --danger-soft: #fef3f2;
  --warn: #b54708;
  --warn-soft: #fffaeb;
  --ok: #067647;
  --ok-soft: #ecfdf3;
  --purple: #6941c6;
  --purple-soft: #f4ebff;
  --sidebar-bg: #101828;
  --sidebar-text: #98a2b3;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-lg: 0 20px 48px rgba(16, 24, 40, .22);
  --sidebar-w: 232px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: clip;
}
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
svg.ic { width: 17px; height: 17px; stroke: currentColor; stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; vertical-align: -3px; }

/* ---------- Autenticación ---------- */
.auth-wrap {
  min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(160deg, #101828 0%, #1d2939 55%, #2f5fde 140%);
}
.auth-card {
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg);
  padding: 40px; width: 100%; max-width: 420px;
}
.auth-card .logo { display: flex; align-items: center; gap: 10px; font-size: 26px; font-weight: 700; margin-bottom: 6px; letter-spacing: -.02em; }
.auth-card .logo .mark { width: 34px; height: 34px; }
.auth-card .logo .wordmark { color: var(--text); }
.auth-card .logo .wordmark span { color: var(--primary); }
.auth-card .tagline { color: var(--text-soft); margin-bottom: 26px; font-size: 14px; }
.auth-card label { display: block; font-weight: 600; font-size: 13px; margin: 15px 0 5px; }
.auth-card input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff;
}
.auth-card input:focus { outline: 3px solid var(--primary-soft); border-color: var(--primary); }
.auth-switch { margin-top: 20px; text-align: center; color: var(--text-soft); font-size: 13.5px; }
.auth-legal { margin-top: 16px; text-align: center; color: var(--text-faint); font-size: 11.5px; line-height: 1.5; }
.legal-text { max-height: 60vh; overflow-y: auto; font-size: 13.5px; line-height: 1.6; color: var(--text-soft); }
.legal-text p { margin-bottom: 10px; }
.legal-text b { color: var(--text); }
.auth-error { background: var(--danger-soft); color: var(--danger); padding: 10px 12px; border-radius: 8px; margin-top: 14px; font-size: 13.5px; display: none; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); border-radius: 8px; padding: 8px 14px; font-weight: 600; font-size: 13.5px;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #f9fafb; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--danger); }
.btn-block { width: 100%; justify-content: center; margin-top: 24px; padding: 11px; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: #f2f4f7; color: var(--text); }

/* ---------- Estructura ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: var(--sidebar-bg); color: var(--sidebar-text); padding: 20px 14px;
  display: flex; flex-direction: column; gap: 3px; position: fixed; top: 0; bottom: 0; z-index: 40;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 700; color: #fff;
  padding: 2px 10px 20px; letter-spacing: -.02em;
}
.sidebar .brand .mark { width: 26px; height: 26px; }
.sidebar .brand .wordmark { color: #fff; }
.sidebar .brand .wordmark span { color: #7ea0ff; }
.sidebar a.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 8px;
  color: var(--sidebar-text); font-weight: 500; font-size: 13.5px;
}
.sidebar a.nav-item svg.ic { width: 18px; height: 18px; }
.sidebar a.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar a.nav-item.active { background: var(--primary); color: #fff; }
.sidebar .nav-org { margin-top: auto; padding: 12px 10px 4px; font-size: 12.5px; color: #667085; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar .nav-org b { color: #d0d5dd; }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex; align-items: center; gap: 14px; padding: 11px 28px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30;
}
.topbar .search { flex: 1; max-width: 440px; position: relative; }
.topbar .search input {
  width: 100%; padding: 8.5px 12px 8.5px 36px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); font-size: 13.5px;
}
.topbar .search input:focus { outline: 3px solid var(--primary-soft); border-color: var(--primary); background: #fff; }
.topbar .search .icon { position: absolute; left: 11px; top: 9px; color: var(--text-faint); pointer-events: none; }
.search-results {
  position: absolute; top: 44px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-lg); max-height: 420px; overflow-y: auto; z-index: 60;
}
.search-results .sr-item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border); }
.search-results .sr-item:hover { background: var(--primary-soft); }
.search-results .sr-item .sr-meta { font-size: 12px; color: var(--text-faint); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.notif-btn { position: relative; }
.notif-badge {
  position: absolute; top: -3px; right: -3px; background: var(--danger); color: #fff; border-radius: 20px;
  font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12px; flex-shrink: 0;
}
.avatar.sm { width: 25px; height: 25px; font-size: 10.5px; }

.content { padding: 26px 28px; max-width: 1320px; width: 100%; }
.page-title { font-size: 21px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 3px; }
.page-sub { color: var(--text-soft); margin-bottom: 20px; font-size: 13.5px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }

/* ---------- Filtros ---------- */
.filters {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px;
}
.filters .f-label { font-size: 12px; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: .05em; margin-right: 2px; }
.filters select, .filters input {
  padding: 6.5px 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); font-size: 13px; color: var(--text-soft);
}
.filters select:focus, .filters input:focus { outline: 3px solid var(--primary-soft); border-color: var(--primary); }
.filters .f-clear { color: var(--text-faint); font-size: 12.5px; border: none; background: none; padding: 6px; }
.filters .f-clear:hover { color: var(--danger); }

/* ---------- Tarjetas / stats ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat { padding: 16px 18px; border-top: 3px solid var(--border-strong); }
.stat .num { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.stat .lbl { color: var(--text-soft); font-size: 12.5px; margin-top: 2px; }
.stat.primary { border-top-color: var(--primary); }
.stat.warn { border-top-color: #f79009; }
.stat.warn .num { color: var(--warn); }
.stat.danger { border-top-color: var(--danger); }
.stat.danger .num { color: var(--danger); }
.stat.ok { border-top-color: #12b76a; }
.stat.ok .num { color: var(--ok); }
.stat.purple { border-top-color: var(--purple); }
.stat.purple .num { color: var(--purple); }

/* minmax(0,1fr) + min-width:0 evitan que el contenido interno ensanche la página en pantallas angostas */
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.grid-2 > * { min-width: 0; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

.card h3 { font-size: 14px; font-weight: 700; padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 9px; }
.card h3 svg.ic { color: var(--text-faint); }
.card .card-body { padding: 12px 18px 16px; }

/* ---------- Insignias ---------- */
.badge { display: inline-block; padding: 2.5px 9px; border-radius: 6px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge.st-pendiente { background: #f2f4f7; color: #475467; }
.badge.st-en_progreso { background: var(--primary-soft); color: var(--primary); }
.badge.st-bloqueada { background: var(--danger-soft); color: var(--danger); }
.badge.st-en_revision { background: var(--purple-soft); color: var(--purple); }
.badge.st-completada { background: var(--ok-soft); color: var(--ok); }
.badge.pr-baja { background: #f2f4f7; color: #475467; }
.badge.pr-media { background: var(--primary-soft); color: var(--primary); }
.badge.pr-alta { background: var(--warn-soft); color: var(--warn); }
.badge.pr-urgente { background: var(--danger-soft); color: var(--danger); }
.badge.pj-planificado { background: #f2f4f7; color: #475467; }
.badge.pj-activo { background: var(--ok-soft); color: var(--ok); }
.badge.pj-en_riesgo { background: var(--danger-soft); color: var(--danger); }
.badge.pj-pausado { background: var(--warn-soft); color: var(--warn); }
.badge.pj-completado { background: var(--primary-soft); color: var(--primary); }
.badge.pj-cancelado { background: #f2f4f7; color: #98a2b3; }
.badge.tag { background: #f8f9fc; color: #475467; border: 1px solid var(--border); }

/* Selects editables con apariencia de insignia (edición directa tipo monday) */
select.badge-select {
  -webkit-appearance: none; appearance: none; border: 1px solid transparent; border-radius: 6px;
  padding: 3px 22px 3px 9px; font-size: 11.5px; font-weight: 600; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2398a2b3' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 7px center;
}
select.badge-select:hover { border-color: var(--border-strong); }
select.badge-select.st-pendiente { background-color: #f2f4f7; color: #475467; }
select.badge-select.st-en_progreso { background-color: var(--primary-soft); color: var(--primary); }
select.badge-select.st-bloqueada { background-color: var(--danger-soft); color: var(--danger); }
select.badge-select.st-en_revision { background-color: var(--purple-soft); color: var(--purple); }
select.badge-select.st-completada { background-color: var(--ok-soft); color: var(--ok); }
select.badge-select.pr-baja { background-color: #f2f4f7; color: #475467; }
select.badge-select.pr-media { background-color: var(--primary-soft); color: var(--primary); }
select.badge-select.pr-alta { background-color: var(--warn-soft); color: var(--warn); }
select.badge-select.pr-urgente { background-color: var(--danger-soft); color: var(--danger); }
select.person-select, input.date-inline {
  border: 1px solid transparent; border-radius: 7px; padding: 4px 6px; font-size: 12.5px; background: transparent; color: var(--text-soft); cursor: pointer; max-width: 150px;
}
select.person-select:hover, input.date-inline:hover { border-color: var(--border-strong); background: #fff; }
input.date-inline.overdue { color: var(--danger); font-weight: 700; }

.due { font-size: 12.5px; color: var(--text-soft); white-space: nowrap; }
.due.done { color: var(--ok); font-weight: 600; }
.due.overdue { color: var(--danger); font-weight: 700; }
.due.today { color: var(--warn); font-weight: 700; }
.due.none { color: var(--warn); }

/* ---------- Tabla de tareas (vista lista) ---------- */
.task-table { width: 100%; border-collapse: collapse; }
.task-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-faint); padding: 10px 12px; border-bottom: 1px solid var(--border); font-weight: 600;
}
.task-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.task-table tr.task-row:hover { background: #f9fafb; }
.task-table .t-title { font-weight: 600; cursor: pointer; }
.task-table .t-title:hover { color: var(--primary); }
.task-table .t-title .subinfo { font-weight: 500; font-size: 11.5px; color: var(--text-faint); margin-left: 4px; }
.section-row td {
  background: #f8f9fc; font-weight: 700; font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-soft); padding: 7px 12px; border-left: 3px solid var(--section-color, var(--border-strong));
}
.check-btn {
  width: 20px; height: 20px; border-radius: 50%; border: 1.6px solid #c3c9d4; background: transparent;
  display: inline-flex; align-items: center; justify-content: center; color: transparent; font-size: 11px; flex-shrink: 0;
}
.check-btn:hover { border-color: var(--ok); color: var(--ok); }
.check-btn.done { background: #12b76a; border-color: #12b76a; color: #fff; }

/* ---------- Kanban ---------- */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 14px; align-items: flex-start; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; }
.kanban-col { scroll-snap-align: start; }
.kanban-col { min-width: 272px; width: 272px; flex-shrink: 0; background: #f2f4f7; border-radius: 10px; padding: 10px; border-top: 3px solid var(--col-color, var(--border-strong)); }
.kanban-col h4 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-soft);
  padding: 4px 6px 10px; display: flex; align-items: center; gap: 8px;
}
.kanban-col h4 .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--col-color, var(--border-strong)); }
.kanban-col h4 .count { margin-left: auto; color: var(--text-faint); font-weight: 600; }
.kanban-col.drag-over { outline: 2px dashed var(--primary); outline-offset: -4px; background: var(--primary-soft); }
.kanban-cards { min-height: 30px; display: flex; flex-direction: column; gap: 8px; }
.kcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 11px 12px;
  cursor: grab; box-shadow: var(--shadow);
}
.kcard:hover { border-color: var(--border-strong); }
.kcard:active { cursor: grabbing; }
.kcard .kt { font-weight: 600; margin-bottom: 8px; font-size: 13.5px; }
.kcard .kmeta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kcard.dragging { opacity: .45; }

/* ---------- Proyectos ---------- */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.pcard { padding: 18px; cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.pcard:hover { border-color: var(--primary); box-shadow: 0 4px 14px rgba(16, 24, 40, .08); }
.pcard .pname { font-weight: 700; font-size: 15.5px; margin-bottom: 5px; letter-spacing: -.01em; }
.pcard .pdesc { color: var(--text-soft); font-size: 13px; margin-bottom: 12px; min-height: 18px; }
.progress-bar { height: 7px; border-radius: 4px; background: #eaecf0; overflow: hidden; margin: 10px 0 6px; }
.progress-bar > div { height: 100%; background: var(--primary); border-radius: 4px; transition: width .2s; }
.progress-bar.ok > div { background: #12b76a; }
.pcard .pfoot { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; color: var(--text-soft); }

/* Barra de avance editable del proyecto */
.progress-editor { display: flex; align-items: center; gap: 12px; margin: 4px 0 18px; max-width: 560px; }
.progress-editor input[type=range] { flex: 1; accent-color: var(--primary); height: 6px; cursor: pointer; }
.progress-editor .pct { font-weight: 700; font-size: 15px; min-width: 46px; text-align: right; }
.progress-editor .mode { font-size: 11.5px; color: var(--text-faint); }

/* ---------- Pestañas ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  border: none; background: none; padding: 9px 16px; font-weight: 600; color: var(--text-soft); font-size: 13.5px;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Panel de tarea ---------- */
.overlay { position: fixed; inset: 0; background: rgba(16, 24, 40, .5); z-index: 90; }
.task-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100vw); background: var(--surface);
  z-index: 100; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slideIn .16s ease;
}
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.task-panel .tp-head { display: flex; align-items: center; gap: 10px; padding: 13px 18px; border-bottom: 1px solid var(--border); }
.task-panel .tp-body { flex: 1; overflow-y: auto; padding: 18px 24px; }
.tp-title-input {
  width: 100%; border: 1px solid transparent; border-radius: 8px; font-size: 18px; font-weight: 700; padding: 6px 8px; margin-left: -8px; letter-spacing: -.01em;
}
.tp-title-input:hover, .tp-title-input:focus { border-color: var(--border); background: #f9fafb; outline: none; }
.tp-grid { display: grid; grid-template-columns: 140px 1fr; gap: 10px 12px; align-items: center; margin: 16px 0; }
.tp-grid .lbl { color: var(--text-soft); font-size: 12.5px; font-weight: 600; }
.tp-grid select, .tp-grid input[type=date], .tp-grid input[type=number] {
  padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff; max-width: 250px; font-size: 13px;
}
.tp-section { margin-top: 24px; }
.tp-section > h4 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); margin-bottom: 10px; font-weight: 700; }
.tp-section > h4 .hint { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--text-faint); }
.tp-desc {
  width: 100%; min-height: 72px; border: 1px solid var(--border-strong); border-radius: 8px; padding: 10px; background: #fff; resize: vertical;
}
.subtask-row { display: flex; align-items: center; gap: 9px; padding: 7px 4px; border-bottom: 1px solid var(--border); }
.subtask-row .st-title { flex: 1; }
.subtask-row .st-title.done { text-decoration: line-through; color: var(--text-faint); }
.inline-add { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.inline-add input, .inline-add select { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 8px; font-size: 13px; }

.comment { display: flex; gap: 10px; padding: 10px 0; }
.comment .c-body { flex: 1; }
.comment .c-head { font-size: 12.5px; color: var(--text-faint); margin-bottom: 2px; }
.comment .c-head b { color: var(--text); }
.comment .c-text { white-space: pre-wrap; overflow-wrap: break-word; }
.comment .mention { color: var(--primary); font-weight: 600; }

.hist-item { padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.hist-item .h-when { color: var(--text-faint); font-size: 11.5px; }
.hist-item .h-change { color: var(--text-soft); }
.hist-item .h-change b { color: var(--text); }

.attach-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; flex-wrap: wrap; }
.attach-row svg.ic { color: var(--text-faint); }
.attach-row .a-meta { color: var(--text-faint); font-size: 12px; }
.file-origin { font-size: 11.5px; color: var(--text-faint); background: #f2f4f7; border-radius: 5px; padding: 1px 7px; }

.dep-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 13.5px; flex-wrap: wrap; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 56px 16px; }
.modal .modal-card {
  background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); width: 100%; max-width: 540px;
  max-height: calc(100vh - 96px); overflow-y: auto; animation: pop .14s ease;
}
@keyframes pop { from { transform: scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal .modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 15.5px; }
.modal .modal-body { padding: 18px 22px; }
.modal label { display: block; font-weight: 600; font-size: 12.5px; margin: 13px 0 5px; }
.modal input, .modal select, .modal textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff; font-size: 13.5px;
}
.modal input:focus, .modal select:focus, .modal textarea:focus { outline: 3px solid var(--primary-soft); border-color: var(--primary); }
.modal textarea { min-height: 70px; resize: vertical; }
.modal .modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- Notificaciones ---------- */
.notif-panel {
  position: fixed; top: 58px; right: 20px; width: min(400px, calc(100vw - 32px)); background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 95; max-height: 70vh; overflow-y: auto;
}
.notif-panel .np-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 700; }
.notif-item { padding: 11px 16px; border-bottom: 1px solid var(--border); font-size: 13.5px; cursor: pointer; }
.notif-item:hover { background: #f9fafb; }
.notif-item.unread { background: var(--primary-soft); }
.notif-item .n-when { color: var(--text-faint); font-size: 11.5px; margin-top: 2px; }

/* ---------- Equipo ---------- */
.team-table { width: 100%; border-collapse: collapse; }
.team-table th, .team-table td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--border); }
.team-table th { font-size: 11px; text-transform: uppercase; color: var(--text-faint); letter-spacing: .05em; font-weight: 600; }

/* ---------- Reportes ---------- */
.bar-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 13.5px; }
.bar-row .bar-lbl { width: 140px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bar-track { flex: 1; height: 16px; background: #f2f4f7; border-radius: 5px; overflow: hidden; display: flex; }
.bar-row .bar-fill { background: var(--primary); height: 100%; }
.bar-row .bar-fill.ok { background: #12b76a; }
.bar-row .bar-fill.danger { background: var(--danger); }
.bar-row .bar-num { width: 44px; text-align: right; color: var(--text-soft); font-size: 12.5px; }
.report-note { font-size: 12px; color: var(--danger); margin: -2px 0 6px 150px; }

/* ---------- Archivos de proyecto ---------- */
.upload-box {
  border: 1.5px dashed var(--border-strong); border-radius: 10px; padding: 18px; display: flex; gap: 12px;
  align-items: center; justify-content: center; color: var(--text-soft); background: #fcfcfd; margin-bottom: 16px; flex-wrap: wrap;
}

/* ---------- Selector de miembros ---------- */
.member-picker {
  display: flex; flex-wrap: wrap; gap: 8px; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px; background: #fcfcfd;
}
.member-chip {
  display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border-strong); border-radius: 20px;
  padding: 5px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer; background: #fff; margin: 0 !important;
}
.member-chip:has(input:checked) { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.member-chip input { width: auto !important; accent-color: var(--primary); margin: 0; }

/* ---------- Cronograma (Timeline / Gantt) ---------- */
.gantt-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; cursor: pointer; }
.gantt-row:hover .gantt-label { color: var(--primary); }
.gantt-label {
  width: 210px; flex-shrink: 0; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gantt-label svg.ic { width: 13px; height: 13px; color: var(--danger); }
.gantt-track { flex: 1; position: relative; height: 30px; background: #f8f9fc; border-radius: 6px; }
.gantt-bar {
  position: absolute; top: 4px; bottom: 4px; background: var(--primary); border-radius: 6px; min-width: 14px;
  display: flex; align-items: center; padding: 0 3px; box-shadow: var(--shadow);
}
.gantt-bar.ok { background: #12b76a; }
.gantt-bar.danger { background: var(--danger); }
.gantt-bar .avatar.sm { width: 20px; height: 20px; font-size: 9px; background: rgba(255,255,255,.28); }
.gantt-today { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--danger); opacity: .6; z-index: 2; }
.gantt-tick { position: absolute; top: 4px; font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }

/* ---------- Plantillas de proyecto ---------- */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 10px; margin-bottom: 6px; max-height: 300px; overflow-y: auto; padding: 2px; }
.tpl-card {
  border: 1.5px solid var(--border); border-radius: 10px; padding: 12px; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.tpl-card:hover { border-color: var(--border-strong); background: #f9fafb; }
.tpl-card.selected { border-color: var(--primary); background: var(--primary-soft); }
.tpl-card .tpl-name { font-weight: 700; font-size: 13px; margin-bottom: 3px; }
.tpl-card .tpl-desc { font-size: 11.5px; color: var(--text-soft); line-height: 1.35; }
.tpl-card .tpl-meta { font-size: 10.5px; color: var(--text-faint); margin-top: 7px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }

/* ---------- Mi día ---------- */
.myday-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.myday-grid > * { min-width: 0; }
@media (max-width: 1000px) { .myday-grid { grid-template-columns: minmax(0, 1fr); } }
.quick-add {
  display: flex; align-items: center; gap: 10px; border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 4px 12px; background: #fff; margin-bottom: 12px;
}
.quick-add input { flex: 1; border: none; padding: 9px 0; background: transparent; }
.quick-add input:focus { outline: none; }
.quick-add:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.md-item { display: flex; align-items: center; gap: 11px; padding: 9px 4px; border-bottom: 1px solid var(--border); }
.md-item:last-child { border-bottom: none; }
.md-item .md-title { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.md-item .md-title.done { text-decoration: line-through; color: var(--text-faint); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #101828; color: #fff;
  padding: 11px 20px; border-radius: 10px; box-shadow: var(--shadow-lg); z-index: 200; font-size: 13.5px;
  animation: pop .15s ease; display: flex; gap: 14px; align-items: center;
}
.toast button { background: none; border: none; color: #7ea0ff; font-weight: 700; }

.empty { color: var(--text-faint); text-align: center; padding: 32px 10px; }
.mini-list-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.mini-list-item:hover { background: #f9fafb; }
.mini-list-item .m-title { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Responsive (móvil: iPhone / Android / iPad vertical) ---------- */
.menu-btn { display: none; }
.sidebar-backdrop { display: none; }
.filters #flt-q { width: 180px; }
.quick-add input { flex: 2 1 160px; }
.quick-add select, .quick-add input[type=date] { min-width: 0; }
.bar-note { font-size: 12px; color: var(--text-faint); margin: -2px 0 8px 150px; }

@media (max-width: 800px) {
  /* Menú lateral deslizable con fondo oscuro para cerrarlo al tocar afuera */
  .sidebar {
    transform: translateX(-100%); transition: transform .2s ease; width: min(300px, 82vw);
    padding-top: max(20px, env(safe-area-inset-top)); padding-left: max(14px, env(safe-area-inset-left));
  }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(16, 24, 40, .4); }
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(16, 24, 40, .5); z-index: 39;
    opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  .sidebar.open + .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .sidebar a.nav-item { padding: 12px; }
  .main { margin-left: 0; }
  .menu-btn { display: inline-flex; }

  .topbar {
    gap: 8px; padding: 8px 10px;
    padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right));
  }
  .topbar .search { max-width: none; }
  .topbar .search .icon { top: 11px; }
  .content {
    padding: 16px 12px 40px;
    padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right));
  }
  .page-title { font-size: 19px; }

  /* iOS hace zoom automático si un campo tiene letra menor a 16px */
  input, select, textarea { font-size: 16px; }
  .topbar .search input { font-size: 16px; }

  /* Objetivos táctiles más cómodos */
  .btn { min-height: 40px; }
  .btn-sm { min-height: 34px; }
  .check-btn { width: 24px; height: 24px; }
  .tabs button { padding: 11px 14px; }

  /* Tablas de tareas: en pantallas angostas se oculta la columna Proyecto/Responsable
     para que el título respire. La prioridad se mantiene siempre visible: es la
     señal principal para decidir qué atender primero. Esos datos ocultos siguen
     disponibles al abrir la tarea. */
  .task-table:not(.cal-table) th:nth-child(3), .task-table:not(.cal-table) td:nth-child(3) { display: none; }
  .task-table th, .task-table td { padding: 9px 8px; }

  /* Panel de tarea a pantalla completa, etiquetas encima de cada campo */
  .task-panel { width: 100%; }
  .task-panel .tp-body { padding: 14px 14px calc(24px + env(safe-area-inset-bottom)); }
  .tp-grid { grid-template-columns: 1fr; gap: 3px 0; }
  .tp-grid .lbl { margin-top: 10px; }
  .tp-grid select, .tp-grid input[type=date], .tp-grid input[type=number] { max-width: none; }

  /* Modales y paneles flotantes */
  .modal { padding: 14px; padding-top: max(14px, env(safe-area-inset-top)); }
  .modal .modal-card { max-height: calc(100dvh - 28px); }
  .form-row { grid-template-columns: 1fr; }
  .notif-panel { left: 8px; right: 8px; width: auto; top: 54px; max-height: 75dvh; }
  .toast {
    left: 12px; right: 12px; transform: none; justify-content: space-between;
    bottom: calc(12px + env(safe-area-inset-bottom));
  }

  /* Filtros y alta rápida en columna fluida */
  .filters #flt-q { flex: 1 1 150px; width: auto; }
  .filters select { flex: 1 1 40%; min-width: 0; }
  .quick-add { flex-wrap: wrap; padding: 8px 12px; }
  .quick-add input { flex: 1 1 100%; }
  .quick-add select, .quick-add input[type=date] { flex: 1 1 45%; }

  /* Kanban: columnas casi a lo ancho, se navega deslizando */
  .kanban-col { min-width: min(272px, 84vw); width: min(272px, 84vw); }

  /* Cronograma y reportes */
  .gantt-label { width: 120px; }
  .bar-row .bar-lbl { width: 96px; }
  .report-note, .bar-note { margin-left: 0; }

  .progress-editor { max-width: none; }
  .projects-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .auth-card { padding: 28px 20px; }
}

/* Teléfonos (pantalla angosta): completar + título + prioridad + fecha en las listas
   (se oculta Estado, no Prioridad — ver nota arriba) */
@media (max-width: 600px) {
  .task-table:not(.cal-table) th:nth-child(4), .task-table:not(.cal-table) td:nth-child(4) { display: none; }
  input.date-inline { max-width: 96px; padding: 4px 2px; }
  .task-table .badge-select.pr-baja, .task-table .badge-select.pr-media,
  .task-table .badge-select.pr-alta, .task-table .badge-select.pr-urgente { max-width: 74px; }
  .task-table th, .task-table td { padding: 9px 6px; }
}

/* Teléfonos muy angostos */
@media (max-width: 380px) {
  .stat .num { font-size: 22px; }
  .content { padding-left: 10px; padding-right: 10px; }
}

/* ==================== Asistente con IA ==================== */
.ai-box { display: flex; flex-direction: column; gap: 12px; }
.ai-box textarea {
  width: 100%; border: 1.5px solid var(--border-strong); border-radius: 10px;
  padding: 12px 14px; font: inherit; font-size: 15px; resize: vertical; min-height: 76px;
  background: var(--surface); color: var(--text);
}
.ai-box textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.ai-actions { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.ai-chips { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; min-width: 200px; }
.ai-chip {
  border: 1px solid var(--border); background: var(--bg); color: var(--text-soft);
  border-radius: 20px; padding: 5px 12px; font-size: 12px; cursor: pointer;
}
.ai-chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.ai-thinking { color: var(--text-soft); padding: 18px; }
.ai-proposal { margin-top: 14px; }
.ai-summary { display: flex; align-items: center; gap: 8px; font-size: 15px; margin-bottom: 6px; }
.ai-summary .ic { color: var(--primary); }
.ai-task {
  display: flex; gap: 10px; align-items: flex-start;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px;
  background: var(--surface);
}
.ai-task .ai-check { margin-top: 9px; width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.ai-task-fields { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ai-title {
  width: 100%; border: 1px solid transparent; border-radius: 6px; padding: 4px 6px;
  font: inherit; font-size: 14.5px; font-weight: 600; color: var(--text); background: transparent;
}
.ai-title:hover, .ai-title:focus { border-color: var(--border-strong); background: var(--surface); outline: none; }
.ai-desc { font-size: 12.5px; color: var(--text-soft); padding: 0 6px; }
.ai-props { display: flex; gap: 6px; flex-wrap: wrap; }
.ai-props select, .ai-props input[type="date"] {
  border: 1px solid var(--border); border-radius: 7px; padding: 4px 8px;
  font: inherit; font-size: 12.5px; color: var(--text-soft); background: var(--bg); max-width: 180px;
}
.ai-proj-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ai-proj-head .ai-title { flex: 1; font-size: 17px; min-width: 200px; }
.ai-proj-head input[type="date"] { border: 1px solid var(--border); border-radius: 7px; padding: 6px 8px; font: inherit; font-size: 13px; }
.ai-section { margin: 14px 0 4px; }
.ai-section-name {
  font-weight: 700; font-size: 13px; margin-bottom: 8px; padding-left: 10px;
  border-left: 3px solid var(--section-color, var(--primary));
}
.ai-confirm { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.ai-done { padding: 18px; font-size: 15px; }

/* ==================== Pilas AI: ¿Que hago ahora? ==================== */
.ahora-card {
  display: flex; align-items: stretch; gap: 24px;
  background: linear-gradient(120deg, var(--primary-soft) 0%, var(--surface) 42%);
  border: 1px solid var(--border); border-radius: 14px;
  padding: 20px 24px; margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(16,24,40,.05), 0 8px 24px rgba(47,95,222,.07);
}
.ahora-main { flex: 1; min-width: 0; }
.ahora-label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--primary); margin-bottom: 8px;
}
.ahora-label .ic { width: 14px; height: 14px; }
.ahora-title {
  font-size: 20px; font-weight: 700; letter-spacing: -.015em; line-height: 1.3;
  cursor: pointer; overflow-wrap: anywhere;
}
.ahora-title:hover { color: var(--primary); }
.ahora-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.ahora-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 11px; font-size: 12px; font-weight: 600; color: var(--text-soft);
}
.ahora-chip .ic { width: 13px; height: 13px; }
.ahora-chip.chip-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.ahora-why { margin-top: 10px; font-size: 13px; color: var(--text-soft); }
.ahora-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.ahora-go { padding: 9px 20px; box-shadow: 0 2px 8px rgba(47,95,222,.28); }
.ahora-empty { font-size: 13.5px; color: var(--text-soft); margin-top: 6px; }

/* Anillo de prioridad */
.ahora-side {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding-left: 24px; border-left: 1px solid var(--border); cursor: default;
}
.ahora-ring { position: relative; width: 74px; height: 74px; }
.ahora-ring svg { width: 74px; height: 74px; display: block; }
.ahora-ring .ring-bg { fill: none; stroke: var(--border); stroke-width: 4; }
.ahora-ring .ring-val { fill: none; stroke: var(--primary); stroke-width: 4; stroke-linecap: round; }
.ahora-ring .ring-num {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 21px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums;
}
.ring-lbl { font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text-faint); }

@media (max-width: 800px) {
  .ahora-card { flex-direction: column; gap: 14px; padding: 18px; }
  .ahora-side { flex-direction: row; padding-left: 0; border-left: none; border-top: 1px solid var(--border); padding-top: 12px; justify-content: flex-start; gap: 10px; }
  .ahora-ring, .ahora-ring svg { width: 54px; height: 54px; }
  .ahora-ring .ring-num { font-size: 16px; }
  .ahora-actions .btn { flex: 1; justify-content: center; }
}

/* Pie del panel de tarea: boton Guardar siempre visible */
.task-panel .tp-foot {
  border-top: 1px solid var(--border); background: var(--surface);
  padding: 12px 18px; padding-bottom: max(12px, env(safe-area-inset-bottom));
  display: flex; justify-content: flex-end;
}

/* Etapas del tablero como etiquetas (modal de nuevo proyecto) */
.stage-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.stage-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 7px;
  padding: 5px 11px; font-size: 12.5px; font-weight: 600; color: var(--text-soft);
}
.stage-chip::before {
  content: ''; width: 8px; height: 8px; border-radius: 2px;
  background: var(--section-color, var(--primary));
}
