/* DualAI CRM — premium neutral palette, Inter/Geist typography, layered. */

/* Paleta y tokens: definidos en design-system.css (CRM V2). Nombres legacy conservados allí. */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--canvas, var(--bg));
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.011em;
  text-rendering: optimizeLegibility;
}

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

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text);
  font-family: var(--font-display);
}

h1 { font-size: 1.75rem; line-height: 1.15; font-weight: 700; letter-spacing: -0.035em; }
h2 { font-size: 1.125rem; line-height: 1.3; font-weight: 600; }
h3 { font-size: 0.95rem; line-height: 1.3; font-weight: 600; }

p { margin: 0; }
.muted { color: var(--text-muted); }

/* --- Skip link (A11y) --- */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--primary);
  color: var(--primary-contrast);
  padding: 0.5rem 1rem;
  z-index: 1000;
  border-radius: 0 0 var(--radius) 0;
  font-weight: 500;
  transition: top 0.15s ease;
}
.skip-link:focus {
  top: 0;
  color: var(--primary-contrast);
}

/* --- Focus visible (A11y) --- */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* --- SR only utility --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ===== Topbar (cleaner than the legacy nav) ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar form button,
.topbar form input,
.topbar form select { color: inherit; font: inherit; }
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  font-size: 1.05rem;
  cursor: pointer;
  transition: all 0.15s ease;
}
.theme-toggle:hover {
  background: var(--bg-sunken);
  color: var(--text);
  border-color: var(--border);
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  height: 56px;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
}
.brand-mark {
  font-size: 0.85rem;
  color: var(--text);
  position: relative;
  top: -1px;
}
.brand-name { font-size: 0.95rem; letter-spacing: -0.02em; }
.brand-suffix { color: var(--text-muted); font-size: 0.85rem; font-weight: 400; }

.main-nav {
  display: flex;
  gap: 0.25rem;
  margin-left: 0.5rem;
  flex: 1;
}
.nav-link {
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.85rem;
  transition: all 0.15s ease;
}
.nav-link:hover {
  background: var(--bg-sunken);
  color: var(--text);
  text-decoration: none;
}
.nav-link.active {
  background: var(--bg-sunken);
  color: var(--text);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem 0.25rem 0.25rem;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}
.avatar-admin { background: var(--role-admin); }
.avatar-member { background: var(--role-member); }
.avatar-agent { background: var(--role-agent); }
.avatar-viewer { background: var(--role-viewer); }

.user-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  font-size: 1.05rem;
}
.btn-icon:hover {
  background: var(--bg-sunken);
  color: var(--text);
  border-color: var(--border);
  text-decoration: none;
}

/* ===== Container ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.bottom {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  letter-spacing: 0;
}

/* ===== Hero / page-head ===== */
.hero { margin-bottom: 2rem; }
.hero-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
}
.hero-eyebrow {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin: 0 0 0.4rem 0;
}
.hero-title {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  margin: 0 0 0.4rem 0;
  line-height: 1.1;
  font-family: var(--font-display);
}
.hero-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 600px;
}
.wave {
  display: inline-block;
  animation: wave 1.5s ease-in-out infinite;
  transform-origin: 70% 70%;
}
@keyframes wave {
  0%, 60%, 100% { transform: rotate(0deg); }
  10%, 30% { transform: rotate(14deg); }
  20% { transform: rotate(-8deg); }
  40% { transform: rotate(-4deg); }
}

.hero-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-head h1 { font-size: 1.625rem; }
.page-head p { margin: 0.25rem 0 0; color: var(--text-muted); font-size: 0.9rem; }
.page-head-actions { display: flex; gap: 0.5rem; }

.link-arrow {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}
.link-arrow:hover { color: var(--text); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn:hover {
  background: var(--bg-sunken);
  border-color: var(--border-strong);
  color: var(--text);
  text-decoration: none;
}
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-contrast);
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: var(--primary-contrast);
}
.btn-danger {
  color: var(--danger);
  border-color: var(--danger-border);
  background: var(--bg-elevated);
}
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.8rem; }

/* ===== KPI Grid ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.kpi {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.kpi:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}
.kpi-warn {
  border-color: var(--warn-border);
  background: linear-gradient(180deg, var(--warn-bg) 0%, var(--bg-elevated) 60%);
}
.kpi-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.kpi-icon { font-size: 1rem; }
.kpi-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.kpi-value {
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.035em;
  font-feature-settings: "tnum" 1, "ss01" 1;
  font-family: var(--font-display);
  margin: 0.25rem 0;
}
.kpi-foot {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: auto;
}

/* ===== Two-column layout for dashboard ===== */
.two-col {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

/* ===== Panel ===== */
.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
  padding: 1.5rem;
  box-shadow: var(--shadow-xs);
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
  gap: 1rem;
}
.panel-head h2 { margin: 0; font-family: var(--font-ui); }

.panel-head p { margin: 0.15rem 0 0; font-size: 0.85rem; }

/* ===== Day list (Tu día) ===== */
.day-list { list-style: none; padding: 0; margin: 0; }
.day-bucket { margin-bottom: 1rem; }
.day-bucket:last-child { margin-bottom: 0; }
.day-bucket-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.day-bucket-count {
  background: var(--bg-sunken);
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
}
.task-list { list-style: none; padding: 0; margin: 0; }
.task-item {
  border-radius: var(--radius-sm);
  transition: background 0.1s ease;
}
.task-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.5rem;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
}
.task-link:hover {
  background: var(--bg-sunken);
  text-decoration: none;
}
.task-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--border-strong);
}
.status-done { background: var(--success); }
.status-open { background: var(--accent); }
.status-in_progress { background: var(--warn); }
.status-overdue { background: var(--danger); }
.task-item.task-overdue .task-title { color: var(--danger); font-weight: 500; }
.task-title {
  flex: 1;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-feature-settings: "tnum" 1;
}

/* ===== Activity feed ===== */
.activity-list {
  list-style: none;
  padding: 0;
  margin: 0;
  position: relative;
}
.activity-list::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: var(--border);
}
.activity-item {
  position: relative;
  padding: 0.65rem 0;
  padding-left: 1.5rem;
  font-size: 0.88rem;
}
.activity-dot {
  position: absolute;
  left: 1px;
  top: 1.1rem;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 2px solid var(--border-strong);
}
.activity-login .activity-dot { border-color: var(--accent); }
.activity-task_completed .activity-dot { border-color: var(--success); }
.activity-task_created .activity-dot { border-color: var(--success); }
.activity-client_created .activity-dot { border-color: var(--role-member); }
.activity-body { display: flex; flex-direction: column; gap: 0.15rem; }
.activity-text { color: var(--text); line-height: 1.45; }
.activity-time { font-size: 0.75rem; }

/* ===== Load grid (carga del equipo) ===== */
.load-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}
.load-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}
.load-card-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.65rem;
}
.load-name { font-weight: 500; font-size: 0.9rem; }
.load-role { margin-top: 0.1rem; }
.role-pill {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.role-admin { background: #f5f3ff; color: var(--role-admin); }
.role-member { background: #ecfeff; color: var(--role-member); }
.role-agent { background: #fff7ed; color: var(--role-agent); }
.role-viewer { background: #f5f5f4; color: var(--role-viewer); }

.load-stats { display: flex; gap: 1.25rem; }
.load-stat { display: flex; flex-direction: column; }
.load-stat-value {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-feature-settings: "tnum" 1;
}
.load-stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ===== Empty state (clean) ===== */
.empty {
  text-align: center;
  padding: 2.5rem 1.5rem;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty-clean {
  background: transparent;
  border: none;
  padding: 2rem 1rem;
}
.empty-mark {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.75rem;
  filter: grayscale(0.2);
}
.empty h3 { margin: 0 0 0.4rem 0; font-size: 0.95rem; }
.empty p { color: var(--text-muted); margin: 0 0 1rem 0; font-size: 0.9rem; }

/* ===== Tables ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.data-table th, .data-table td {
  padding: 0.7rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg);
}
.data-table tbody tr:hover { background: var(--bg); }
.data-table .actions { text-align: right; white-space: nowrap; }
.data-table .check { width: 32px; }

/* ===== Filter bar ===== */
.filter-bar {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding: 0.25rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: inline-flex;
}
.filter-chip {
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  transition: all 0.15s ease;
}
.filter-chip:hover {
  color: var(--text);
  text-decoration: none;
  background: var(--bg-elevated);
}
.filter-chip.active {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}
.filter-banner {
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

/* ===== Bulk actions ===== */
.bulk-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--bg-sunken);
  color: var(--text-muted);
}
.badge-open { background: var(--accent-bg); color: var(--accent); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-done { background: var(--success-bg); color: var(--success); }
.badge-admin { background: #f5f3ff; color: var(--role-admin); }
.badge-member { background: #ecfeff; color: var(--role-member); }
.badge-agent { background: #fff7ed; color: var(--role-agent); }
.badge-viewer { background: #f5f5f4; color: var(--role-viewer); }

/* ===== Forms ===== */
.form-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-xs);
  max-width: 720px;
}
.form-field { display: flex; flex-direction: column; margin-bottom: 1rem; }
.form-field label { font-weight: 500; margin-bottom: 0.3rem; font-size: 0.85rem; color: var(--text); }
.form-field .required { color: var(--danger); }
.form-field input,
.form-field select,
.form-field textarea {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.9rem;
  background: var(--bg-elevated);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.form-field input[aria-invalid="true"],
.form-field select[aria-invalid="true"] {
  border-color: var(--danger);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}
.form-error {
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.88rem;
}
.form-actions { display: flex; gap: 0.5rem; margin-top: 1.5rem; }

/* --- Login form --- */
.auth-card {
  max-width: 380px;
  margin: 4rem auto;
  background: var(--bg-elevated);
  padding: 2.25rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}
.auth-card h1 {
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  margin-bottom: 0.4rem;
}
.auth-subtitle { color: var(--text-muted); margin-bottom: 1.5rem; font-size: 0.88rem; }

/* ===== KV (definition list) ===== */
.kv {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 0.6rem 1rem;
  margin: 0;
}
.kv dt { font-weight: 500; color: var(--text-muted); font-size: 0.85rem; padding-top: 0.15rem; }
.kv dd { margin: 0; font-size: 0.9rem; }

/* ===== Note list ===== */
.note-list { list-style: none; padding: 0; margin: 0 0 1rem 0; }
.note-item {
  padding: 0.85rem 1rem;
  border-left: 2px solid var(--border-strong);
  background: var(--bg);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 0.6rem;
}
.note-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  margin-bottom: 0.3rem;
}
.note-body { white-space: pre-wrap; font-size: 0.92rem; }
.note-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}
.note-form textarea {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  resize: vertical;
}

/* ===== Flash ===== */
.flash {
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  font-size: 0.9rem;
}
.flash-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.flash-error { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.flash-info { background: var(--accent-bg); border-color: var(--accent-border); color: var(--accent); }
.flash-warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn); }

/* ===== Inline forms (status select, etc.) ===== */
.inline-form { display: inline-flex; gap: 0.35rem; align-items: center; }
.inline-form-row { display: flex; gap: 0.5rem; margin-top: 1rem; align-items: stretch; }
.inline-form-row input[type="text"] {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.select-sm {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.85rem;
  background: var(--bg-elevated);
}

/* ===== Auth form ===== */
.auth-form { max-width: 360px; margin: 4rem auto; }
.auth-form h1 { margin: 0 0 0.5rem 0; }

/* ===== Mobile ===== */
@media (max-width: 720px) {
  .topbar-inner { padding: 0.75rem 1rem; gap: 0.75rem; height: auto; }
  .main-nav { margin-left: 0; order: 2; flex-basis: 100%; overflow-x: auto; }
  .container { padding: 1.25rem 1rem 3rem; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head-actions { width: 100%; }
  .hero-title { font-size: 1.5rem; }
  .two-col { grid-template-columns: 1fr; }
  .kpi-value { font-size: 1.875rem; }
  .kv { grid-template-columns: 1fr; }
  .data-table { font-size: 0.85rem; }
  .data-table th, .data-table td { padding: 0.5rem; }
  .form-card { padding: 1.25rem; }
}

/* ========================================================================
 * Cycle 7 polish: production-grade premium styling
 * ======================================================================== */

/* Confirm dialog via data-confirm attribute on forms */
[data-confirm] {
  position: relative;
}

.inline-form[data-confirm] .btn-danger,
.inline-form[data-confirm] button[type="submit"] {
  cursor: pointer;
}

/* Confirmation behavior is provided by ux-states.js. */

/* --- Icon buttons row (clientes / tareas / equipo) --- */
.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-md, 0.5rem);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  text-decoration: none;
  font-size: 1rem;
  color: var(--text);
  transition: all 0.15s ease;
  cursor: pointer;
}
.icon-btn:hover {
  background: var(--bg-sunken);
  border-color: var(--border-strong);
}
.icon-btn-danger:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

.actions-col {
  width: auto;
  white-space: nowrap;
  text-align: right !important;
}

/* --- Row link behaviour (clientes table) --- */
.data-table-cards tbody tr.row-link {
  cursor: pointer;
  transition: background 0.15s ease;
}
.data-table-cards tbody tr.row-link:hover {
  background: var(--bg-sunken);
}
.row-link-anchor {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}
.row-link-anchor:hover {
  color: var(--primary);
}

/* --- Bucket layout for tasks_list.html --- */
.tasks-bucket {
  margin: 1.25rem 0 1rem;
}
.bucket-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.75rem 0;
  padding: 0 0.5rem;
}
.bucket-head h2 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.bucket-icon { font-size: 1.1rem; }
.bucket-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.25rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--bg-sunken);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.task-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.task-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 0.875rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 0.625rem);
  transition: all 0.15s ease;
  position: relative;
}
.task-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-elevated);
  box-shadow: 0 1px 3px rgba(0,0,0,0.03), 0 1px 2px rgba(0,0,0,0.04);
}
.task-card-main {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}
.task-card-title {
  font-weight: 600;
  color: var(--text);
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
.task-card:hover .task-card-title {
  color: var(--primary);
}
.task-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-size: 0.8rem;
}
.task-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.1rem 0.45rem;
  background: var(--bg-sunken);
  border-radius: 0.375rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.task-chip-deadline.is-overdue {
  background: #fef2f2;
  color: #991b1b;
  font-weight: 600;
}
.check-left {
  display: inline-flex;
  align-items: center;
}
.task-card-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.task-done-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  background: #d1fae5;
  color: #047857;
  font-weight: 700;
}

/* Bucket colouring: subtle vertical accent */
.task-card-overdue {
  border-left: 3px solid #ef4444;
  background: linear-gradient(90deg, #fef2f2 0%, var(--bg-elevated) 30%);
}
.task-card-today {
  border-left: 3px solid #3b82f6;
}
.task-card-soon {
  border-left: 3px solid #f59e0b;
}
.task-card-later {
  border-left: 3px solid #a1a1aa;
}
.task-card-done {
  opacity: 0.7;
  border-left: 3px solid #10b981;
}
.task-card.is-overdue {
  border-color: #fca5a5;
}

/* Chip count on filter chip for overdue */
.filter-chip.has-overdue {
  color: #991b1b;
  font-weight: 600;
}
.filter-chip .chip-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.1rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.5);
  font-size: 0.7rem;
  margin-left: 0.3rem;
}
.filter-chip.active .chip-count {
  background: rgba(255,255,255,0.25);
}
.filter-chip .chip-icon { display: inline-block; opacity: 0.7; }

/* --- Cliente detail premium --- */
.client-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  color: white;
  font-weight: 700;
  font-size: 1.1rem;
  margin-right: 0.75rem;
  vertical-align: middle;
}

.kv-premium {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
}
.kv-row {
  display: grid;
  grid-template-columns: 12rem 1fr;
  align-items: start;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  margin: 0;
}
.kv-row:last-child { border-bottom: none; }
.kv-row dt {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
}
.kv-row dd {
  margin: 0;
  color: var(--text);
}

.badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.25rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--bg-sunken);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.job-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.job-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 0.5rem);
  flex-wrap: wrap;
}
.job-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-grow: 1;
}
.inline-form-row-add {
  margin-top: 1rem;
}
.input-grow {
  flex-grow: 1;
  min-width: 12rem;
}
.linked-tasks {
  list-style: none;
  padding: 0;
  margin: 0;
}
.linked-tasks li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.linked-tasks li:last-child { border-bottom: none; }
.linked-tasks a {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}
.linked-tasks a:hover {
  color: var(--primary);
}

.empty-mini {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
}

.code-inline {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace;
  font-size: 0.78rem;
  padding: 0.1rem 0.4rem;
  background: var(--bg-sunken);
  border-radius: 0.25rem;
  color: var(--text);
}

.badge-role-admin { background: #ddd6fe; color: #5b21b6; }
.badge-role-member { background: #d1fae5; color: #065f46; }
.badge-role-agent { background: #fed7aa; color: #9a3412; }
.badge-role-viewer { background: #e5e7eb; color: #374151; }
.badge-active { background: #d1fae5; color: #065f46; }
.badge-paused { background: #fef3c7; color: #92400e; }
.badge-churned { background: #f3f4f6; color: #4b5563; }
.badge-open { background: #dbeafe; color: #1e40af; }
.badge-in_progress { background: #fed7aa; color: #9a3412; }
.badge-done { background: #d1fae5; color: #065f46; }
.badge-warn { background: #fee2e2; color: #991b1b; }

.text-warn { color: #991b1b; }

.btn-danger {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}
.btn-danger:hover {
  background: #fecaca;
  border-color: #f87171;
}
.btn-success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #6ee7b7;
}
.btn-success:hover {
  background: #a7f3d0;
  border-color: #34d399;
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--bg-sunken);
}

.text-num, .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.small {
  font-size: 0.85rem;
}

.bulk-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-md, 0.5rem) var(--radius-md, 0.5rem);
  position: sticky;
  bottom: 1rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 600px) {
  .form-row { grid-template-columns: 1fr; }
}

/* ========================================================================
 * Auth: premium login page
 * ======================================================================== */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #fafaf9 0%, #e7e5e4 100%);
  padding: 2rem 1rem;
}
.auth-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}
.auth-card-premium {
  max-width: 26rem;
  width: 100%;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg, 0.875rem);
  box-shadow: 0 10px 40px -10px rgba(0,0,0,0.08), 0 4px 16px -4px rgba(0,0,0,0.04);
  padding: 2.5rem 2rem;
  border: 1px solid var(--border);
}
.auth-brand {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
  font-weight: 600;
}
.auth-brand .brand-mark {
  font-size: 1.5rem;
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.auth-brand-name {
  font-size: 1.3rem;
  letter-spacing: -0.01em;
}
.auth-brand-suffix {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.auth-card-premium h1 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.auth-subtitle {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
}
.auth-form {
  border: none;
  padding: 0;
  box-shadow: none;
  background: transparent;
}
.auth-form .form-field { margin-bottom: 1rem; }
.btn-full {
  width: 100%;
  margin-top: 0.5rem;
}
.auth-footer-note {
  margin-top: 1.5rem;
  font-size: 0.75rem;
  text-align: center;
}

/* ========================================================================
 * Dashboard quicklinks
 * ======================================================================== */
.quicklinks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-top: 1.5rem;
}
.quicklink {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 0.625rem);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  transition: all 0.15s ease;
}
.quicklink:hover {
  border-color: var(--primary);
  background: var(--bg-elevated);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px -2px rgba(37,99,235,0.1);
}

/* --- Calendar grid --------------------------------------------------------- */
.cal-stats {
  margin: 0 0 1rem 0;
  font-size: 0.9rem;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.cal-head {
  background: var(--bg-elevated);
  padding: 0.6rem 0.5rem;
  font-weight: 600;
  font-size: 0.85rem;
  text-align: center;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cal-cell {
  background: var(--bg);
  min-height: 110px;
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  position: relative;
  transition: background 0.1s ease;
}
.cal-cell-empty {
  background: var(--bg-elevated);
  opacity: 0.4;
}
.cal-cell-today {
  background: rgba(37, 99, 235, 0.08);
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}
.cal-day-num {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}
.cal-day-link {
  color: inherit;
  text-decoration: none;
}
.cal-day-link:hover { color: var(--primary); }
.cal-cell-today .cal-day-num { color: var(--primary); }
.cal-items {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  overflow: hidden;
}
.cal-item { font-size: 0.78rem; line-height: 1.3; }
.cal-item-link {
  display: block;
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  text-decoration: none;
  color: inherit;
  background: var(--bg-elevated);
  border-left: 3px solid var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-item-link:hover { filter: brightness(0.95); }
.cal-item-meeting .cal-item-link {
  border-left-color: #8b5cf6;
  background: rgba(139, 92, 246, 0.08);
}
.cal-item-task .cal-item-link {
  border-left-color: #3b82f6;
  background: rgba(59, 130, 246, 0.08);
}
.cal-item-task.is-overdue .cal-item-link {
  border-left-color: #ef4444;
  background: rgba(239, 68, 68, 0.10);
}
.cal-item-time {
  font-weight: 600;
  margin-right: 0.25rem;
  color: var(--primary);
}
.cal-item-title { font-weight: 500; }
.cal-item-meta { color: var(--text-muted); margin-left: 0.25rem; }
.cal-legend {
  display: flex;
  gap: 1.25rem;
  margin-top: 1rem;
  font-size: 0.85rem;
  flex-wrap: wrap;
}
.cal-legend-item::before {
  content: "·";
  margin-right: 0.5rem;
  color: var(--text-muted);
}
.cal-legend-item:first-child::before { content: ""; margin: 0; }
@media (max-width: 720px) {
  .cal-cell { min-height: 80px; padding: 0.25rem; }
  .cal-item { font-size: 0.7rem; }
  .cal-item-time { display: none; }
}

/* --- Meeting list (dashboard) --------------------------------------------- */
.meeting-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.meeting-row {
  background: var(--bg-elevated);
  border-radius: 6px;
  border-left: 3px solid #8b5cf6;
  transition: transform 0.1s ease;
}
.meeting-row:hover { transform: translateX(2px); }
.meeting-row-link {
  display: flex;
  gap: 1rem;
  padding: 0.75rem 1rem;
  text-decoration: none;
  color: inherit;
  align-items: center;
}
.meeting-row-date {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 56px;
  padding: 0.3rem 0.5rem;
  background: var(--bg);
  border-radius: 4px;
}
.meeting-day {
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary);
  line-height: 1.1;
}
.meeting-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}
.meeting-row-body { flex: 1; min-width: 0; }
.meeting-row-title { font-weight: 600; }
.meeting-row-meta { font-size: 0.85rem; margin-top: 0.2rem; }

/* --- Form grid (reunion_form) --------------------------------------------- */
.form-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 720px;
}
.form-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.form-row-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 600px) {
  .form-row-pair { grid-template-columns: 1fr; }
}
.form-label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.form-input {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: inherit;
  font: inherit;
}
.form-input:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  border-color: var(--primary);
}
.form-row-attendees {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem 1rem 1rem 1rem;
}
.form-checklist {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
}
.form-check:hover { background: var(--bg-elevated); }
.form-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* --- Task meta date chip (dashboard) -------------------------------------- */
.task-meta-date {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  margin-right: 0.3rem;
  background: var(--primary);
  color: var(--primary-contrast);
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Variables de tokens (calendario y tema): ahora en design-system.css (CRM V2). */

/* ── Dark mode: enforced overrides for surfaces that bypassed CSS vars ── */
[data-theme="dark"] body { background: var(--canvas, var(--bg)); color: var(--text); }
[data-theme="dark"] .panel,
[data-theme="dark"] .kpi-card,
[data-theme="dark"] .team-kpi-card,
[data-theme="dark"] article[class*="kpi"],
[data-theme="dark"] section[role="region"] {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text);
}
[data-theme="dark"] .panel-head h2,
[data-theme="dark"] .panel-head p,
[data-theme="dark"] .kpi-card-label,
[data-theme="dark"] .kpi-card-value {
  color: var(--text);
}
[data-theme="dark"] .kpi-card-label,
[data-theme="dark"] .panel-head p,
[data-theme="dark"] .kpi-section-header,
[data-theme="dark"] .kpi-section-footer {
  color: var(--text-muted);
}

.panel-cal { padding: 0; overflow: hidden; }
.panel-head-cal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.cal-title h2 { margin: 0; font-size: 1.4rem; }
.cal-title .muted { margin: 0.2rem 0 0 0; font-size: 0.85rem; }
.cal-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.cal-view-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg);
}
.cal-view-link {
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-right: 1px solid var(--border);
  transition: background 0.1s ease, color 0.1s ease;
}
.cal-view-link:last-child { border-right: 0; }
.cal-view-link:hover { background: var(--bg-elevated); color: var(--text); }
.cal-view-link.active {
  background: var(--primary);
  color: var(--primary-contrast);
}
.cal-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.15rem;
  background: var(--bg);
}
.cal-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  font-size: 1.1rem; line-height: 1;
  text-decoration: none;
  color: var(--text);
  border-radius: 4px;
}
.cal-nav-btn:hover { background: var(--bg-elevated); }
.cal-nav-today {
  padding: 0.3rem 0.7rem;
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--text);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.cal-nav-today:hover { background: var(--bg-elevated); }

/* --- GCal grid layout --------------------------------------------------- */
.gcal {
  display: grid;
  grid-template-columns: 64px repeat(7, 1fr);
  grid-template-rows: auto auto 1fr;
  background: var(--bg);
  min-height: 600px;
}
.gcal-day .gcal {
  grid-template-columns: 64px 1fr;
}
.gcal-corner {
  grid-column: 1;
  grid-row: 1;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  background: var(--bg-elevated);
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 0.3rem 0.5rem;
}
.gcal-tz {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.gcal-header {
  grid-column: 2 / span 7;
  grid-row: 1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}
.gcal-day .gcal-header {
  grid-column: 2;
  display: block;
}
.gcal-head-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 0.5rem;
  text-decoration: none;
  color: inherit;
  border-right: 1px solid var(--border);
  transition: background 0.1s ease;
  gap: 0.15rem;
}
.gcal-head-col:last-child { border-right: 0; }
.gcal-head-col:hover { background: var(--bg); }
.gcal-head-col.is-today { color: var(--primary); }
.gcal-head-col.is-today .gcal-head-daynum { color: var(--primary-contrast); background: var(--primary); border-radius: 50%; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; }
.gcal-head-weekday {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
.gcal-head-daynum { font-size: 1.4rem; font-weight: 400; line-height: 1.1; }
.gcal-head-month { font-size: 0.7rem; color: var(--text-muted); text-transform: lowercase; }

/* All-day row (tasks) */
.gcal-all-day-row {
  grid-column: 2 / span 7;
  grid-row: 2;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  min-height: 28px;
}
.gcal-day .gcal-all-day-row { grid-column: 2; display: block; }
.gcal-all-day-cell {
  border-right: 1px solid var(--border);
  padding: 0.25rem 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-height: 28px;
}
.gcal-all-day-cell:last-child { border-right: 0; }
.gcal-all-day-cell.is-today { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.gcal-day-col.is-today { background: color-mix(in srgb, var(--primary) 6%, var(--bg)); }
.gcal-hour-row:hover { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.gcal-day-col.is-today .gcal-hour-row { border-bottom-color: color-mix(in srgb, var(--primary) 28%, var(--border)); }
.gcal-task-chip {
  display: block;
  font-size: 0.72rem;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  background: var(--bg);
  border-left: 3px solid var(--primary);
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gcal-task-chip.is-overdue { border-left-color: #ef4444; background: rgba(239, 68, 68, 0.06); }
.gcal-task-chip:hover { filter: brightness(0.96); }

/* Body — time column + day columns */
.gcal-body {
  grid-column: 1 / span 8;
  grid-row: 3;
  display: grid;
  grid-template-columns: 64px repeat(7, 1fr);
  overflow-y: auto;
  max-height: 70vh;
  position: relative;
}
.gcal-day .gcal-body { grid-template-columns: 64px 1fr; }
.gcal-time-col {
  grid-column: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg);
}
.gcal-time-slot {
  height: var(--hour-height, 48px);
  padding: 0.15rem 0.4rem;
  text-align: right;
  font-size: 0.7rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  position: relative;
}
.gcal-time-label { background: var(--bg); padding-left: 0.2rem; }
.gcal-day-col {
  position: relative;
  border-right: 1px solid var(--border);
  min-height: calc(var(--hour-height, 48px) * 17);
}
.gcal-day-col:last-child { border-right: 0; }
.gcal-day-col.is-today { background: color-mix(in srgb, var(--primary) 6%, var(--bg)); }
.gcal-day-grid {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  pointer-events: none;
}
.gcal-hour-row {
  flex: 1 1 auto;
  height: var(--hour-height, 48px);
  border-bottom: 1px solid var(--border);
  display: block;
  pointer-events: auto;
  transition: background 0.1s ease;
}
.gcal-hour-row:hover { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.gcal-day-col.is-today .gcal-hour-row { border-bottom-color: color-mix(in srgb, var(--primary) 28%, var(--border)); }

/* Event blocks — absolute positioned */
.gcal-event {
  position: absolute;
  background: var(--gcal-event);
  color: white;
  border-radius: 4px;
  padding: 0.3rem 0.5rem;
  font-size: 0.78rem;
  text-decoration: none;
  overflow: hidden;
  z-index: 1;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  line-height: 1.25;
}
.gcal-event:hover { transform: scale(1.01); box-shadow: 0 3px 8px rgba(0,0,0,0.15); z-index: 2; }
.gcal-event-client { background: var(--gcal-event-client); }
.gcal-event-time { font-weight: 600; font-size: 0.72rem; opacity: 0.95; }
.gcal-event-title { font-weight: 600; }
.gcal-event-meta { font-size: 0.7rem; opacity: 0.9; margin-top: 0.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- Month grid (legacy) ------------------------------------------------- */
.cal-grid-month {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
  overflow: hidden;
  min-height: 500px;
}
.cal-head-month {
  background: var(--bg-elevated);
  padding: 0.5rem;
  font-weight: 600;
  font-size: 0.8rem;
  text-align: center;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cal-cell-month {
  background: var(--bg);
  min-height: 100px;
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  text-decoration: none;
  color: inherit;
  transition: background 0.1s ease;
}
.cal-cell-month:hover { background: var(--bg-elevated); }
.cal-cell-month.is-today { background: color-mix(in srgb, var(--primary) 8%, transparent); outline: 2px solid var(--primary); outline-offset: -2px; }
.cal-cell-empty { background: var(--bg-elevated); opacity: 0.4; }
.cal-cell-daynum { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); }
.cal-cell-month.is-today .cal-cell-daynum { color: var(--primary); }
.cal-cell-items { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.1rem; }
.cal-cell-meeting, .cal-cell-task {
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}
.cal-cell-meeting { background: rgba(139, 92, 246, 0.12); color: #6d28d9; }
.cal-cell-task { background: rgba(59, 130, 246, 0.10); color: #1d4ed8; }
.cal-cell-task.is-overdue { background: rgba(239, 68, 68, 0.10); color: #b91c1c; }
.cal-cell-more { font-size: 0.7rem; color: var(--text-muted); padding: 0.1rem 0.3rem; }

[data-theme="dark"] .cal-cell-meeting { color: #c4b5fd; }
[data-theme="dark"] .cal-cell-task { color: #93c5fd; }
[data-theme="dark"] .cal-cell-task.is-overdue { color: #fca5a5; }

@media (max-width: 720px) {
  .gcal { grid-template-columns: 48px repeat(7, minmax(80px, 1fr)); font-size: 0.8rem; }
  .gcal-week .gcal-body { grid-template-columns: 48px repeat(7, minmax(80px, 1fr)); }
  .gcal-time-col { font-size: 0.7rem; }
  .gcal-event-time { display: none; }
  .gcal-event-title { font-size: 0.72rem; }
  .gcal-event-meta { display: none; }
}

/* --- Topbar search + theme toggle (cycle 15) ------------------------------ */
.topbar-search {
  display: flex;
  align-items: center;
  flex: 0 1 280px;
  margin: 0 0.5rem;
}
.topbar-search-input {
  width: 100%;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: inherit;
  font: inherit;
  font-size: 0.85rem;
}
.topbar-search-input:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
}
.theme-toggle-form { margin: 0; padding: 0; }
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 1rem;
  margin-right: 0.5rem;
}
.theme-toggle:hover { background: var(--bg-elevated); }

/* --- Search results (cycle 15) ------------------------------------------- */
.search-form {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0 1.5rem 0;
}
.search-input {
  flex: 1;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  background: var(--bg);
  color: inherit;
}
.search-group { margin-top: 1.5rem; }
.search-list { list-style: none; padding: 0; margin: 0.5rem 0; display: flex; flex-direction: column; gap: 0.4rem; }
.search-link {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: var(--bg-elevated);
  border-radius: 6px;
  text-decoration: none;
  color: inherit;
}
.search-link:hover { background: var(--bg); }
.search-tag {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  font-size: 0.7rem;
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-contrast);
  text-transform: lowercase;
  letter-spacing: 0.04em;
}

/* --- Kanban (cycle 15) --------------------------------------------------- */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  align-items: flex-start;
}
@media (max-width: 900px) {
  .kanban-board { grid-template-columns: 1fr; }
}
.kanban-col {
  background: var(--bg-elevated);
  border-radius: 8px;
  padding: 0.75rem;
  min-height: 200px;
  border: 1px solid var(--border);
}
.kanban-col-head { margin: 0 0 0.75rem 0; display: flex; align-items: center; justify-content: space-between; }
.kanban-col-head h3 { font-size: 0.9rem; margin: 0; }
.kanban-count {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  background: var(--bg);
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}
.kanban-col-body { display: flex; flex-direction: column; gap: 0.5rem; }
.kanban-card {
  background: var(--bg);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  border-left: 3px solid var(--primary);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.kanban-card.is-overdue { border-left-color: #ef4444; background: rgba(239, 68, 68, 0.04); }
.kanban-card.is-done { opacity: 0.7; border-left-color: #10b981; }
.kanban-card.is-cancelled { opacity: 0.5; border-left-color: var(--text-muted); }
.kanban-card-link { text-decoration: none; color: inherit; }
.kanban-card-title { font-weight: 500; line-height: 1.3; }
.kanban-card-meta { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.3rem; }
.kanban-card-actions {
  display: flex;
  gap: 0.3rem;
  justify-content: flex-end;
  margin-top: 0.3rem;
  border-top: 1px solid var(--border);
  padding-top: 0.4rem;
}
.kanban-card-actions .inline-form { margin: 0; }
.kanban-empty { font-size: 0.85rem; padding: 0.5rem 0; }

/* --- Meeting comments (cycle 15) ----------------------------------------- */
.meeting-comments {
  margin-top: 2rem;
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
}
.comment-list { list-style: none; padding: 0; margin: 0.5rem 0 1rem 0; display: flex; flex-direction: column; gap: 0.75rem; }
.comment-item {
  background: var(--bg-elevated);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  border-left: 3px solid var(--primary);
}
.comment-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  margin-bottom: 0.3rem;
}
.comment-head .inline-form { margin-left: auto; }
.comment-body { line-height: 1.4; }
.comment-form { margin-top: 1rem; }
.comment-form textarea { width: 100%; }

/* --- Client timeline (cycle 15) ------------------------------------------ */
.timeline {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
  position: relative;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.timeline-item {
  position: relative;
  padding: 0.5rem 0 0.5rem 2.75rem;
  margin-bottom: 0.75rem;
}
.timeline-marker {
  position: absolute;
  left: 0;
  top: 0.5rem;
  width: 30px;
  height: 30px;
  background: var(--bg);
  border: 2px solid var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  z-index: 1;
}
.timeline-item.timeline-call .timeline-marker { border-color: #10b981; }
.timeline-item.timeline-email .timeline-marker { border-color: #3b82f6; }
.timeline-item.timeline-meeting .timeline-marker { border-color: #8b5cf6; }
.timeline-body {
  background: var(--bg-elevated);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
}
.timeline-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  margin-bottom: 0.3rem;
}
.timeline-head .inline-form { margin-left: auto; }
.timeline-text { line-height: 1.4; white-space: pre-wrap; }
.timeline-form { margin-top: 1rem; }

/* --- Metrics (cycle 15) -------------------------------------------------- */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}
.metric-card {
  background: var(--bg-elevated);
  border-radius: 8px;
  padding: 1rem;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.metric-card.is-warning { border-color: #f59e0b; background: rgba(245, 158, 11, 0.05); }
.metric-value { font-size: 1.8rem; font-weight: 700; line-height: 1.1; }
.metric-pct { font-size: 0.9rem; font-weight: 500; color: var(--text-muted); margin-left: 0.25rem; }
.metric-sub { font-size: 0.9rem; color: var(--text-muted); font-weight: 400; }
.metric-label { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.metric-bar { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; margin-top: 0.5rem; }
.metric-bar-fill { height: 100%; background: var(--primary); transition: width 0.3s ease; }

/* --- Task tags chips (cycle 15) ------------------------------------------ */
.task-tag {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  font-size: 0.7rem;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.12);
  color: #2563eb;
  text-decoration: none;
  margin-right: 0.2rem;
  font-weight: 500;
}
.task-tag.tag-red { background: rgba(239, 68, 68, 0.10); color: #b91c1c; }
.task-tag.tag-orange { background: rgba(245, 158, 11, 0.10); color: #b45309; }
.task-tag.tag-green { background: rgba(16, 185, 129, 0.10); color: #047857; }

/* --- Theme toggle View Transitions (midudev trick, theme-toggle.rdsx.dev) --- */
@keyframes theme-reveal {
  from { mask-size: 0; }
  to { mask-size: 250vmax; }
}
@keyframes theme-fade {
  from { opacity: 1; }
  to { opacity: 0; }
}
::view-transition-group(root) {
  animation-duration: 0.55s;
  animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
}
::view-transition-new(root) {
  mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40"><defs><filter id="b"><feGaussianBlur stdDeviation="1.5"/></filter></defs><circle cx="20" cy="20" r="18" fill="white" filter="url(%23b)"/></svg>') center / 0 no-repeat;
  animation: theme-reveal 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
}
::view-transition-old(root) {
  animation: theme-fade 0.25s ease-out both;
  z-index: -1;
}
@media (prefers-reduced-motion: reduce) {
  ::view-transition-new(root) { animation: none; }
  ::view-transition-old(root) { animation: none; }
}
.task-tag.tag-purple { background: rgba(139, 92, 246, 0.10); color: #6d28d9; }


/* --- Pipeline / Job tracking (cycle 17, 2026-07-15) ----------------------- */

.stage-strip {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 10px 0 14px; margin-bottom: 6px;
  border-bottom: 1px dashed var(--border, #e5e7eb);
}
.stage-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
  background: var(--surface-2, #f4f4f5);
  color: var(--text-muted, #52525b);
  border: 1px solid var(--border, #e5e7eb);
}
.stage-pill strong { font-weight: 700; color: var(--text, #18181b); }
.stage-pill.stage-discovery   { background: rgba(99, 102, 241, 0.10); color: #4338ca; border-color: rgba(99, 102, 241, 0.20); }
.stage-pill.stage-in_progress { background: rgba(59, 130, 246, 0.10); color: #1d4ed8; border-color: rgba(59, 130, 246, 0.20); }
.stage-pill.stage-in_review   { background: rgba(168, 85, 247, 0.10); color: #7e22ce; border-color: rgba(168, 85, 247, 0.20); }
.stage-pill.stage-demo        { background: rgba(245, 158, 11, 0.12); color: #b45309; border-color: rgba(245, 158, 11, 0.25); }
.stage-pill.stage-delivery    { background: rgba(20, 184, 166, 0.12); color: #0f766e; border-color: rgba(20, 184, 166, 0.25); }
.stage-pill.stage-done        { background: rgba(16, 185, 129, 0.12); color: #047857; border-color: rgba(16, 185, 129, 0.25); }
.stage-pill.stage-on_hold     { background: rgba(113, 113, 122, 0.12); color: #52525b; border-color: rgba(113, 113, 122, 0.25); }
.stage-pill.stage-cancelled   { background: rgba(239, 68, 68, 0.10); color: #b91c1c; border-color: rgba(239, 68, 68, 0.25); }

.job-list-tracked { display: grid; gap: 12px; }
.job-row-tracked {
  display: grid; gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  background: var(--surface-1, #fff);
  border-left: 4px solid var(--border, #e5e7eb);
}
.job-row-tracked.stage-discovery   { border-left-color: #6366f1; }
.job-row-tracked.stage-in_progress { border-left-color: #3b82f6; }
.job-row-tracked.stage-in_review   { border-left-color: #a855f7; }
.job-row-tracked.stage-demo        { border-left-color: #f59e0b; background: linear-gradient(180deg, rgba(245, 158, 11, 0.04), transparent 40%), var(--surface-1, #fff); }
.job-row-tracked.stage-delivery    { border-left-color: #14b8a6; }
.job-row-tracked.stage-done        { border-left-color: #10b981; opacity: 0.78; }
.job-row-tracked.stage-on_hold     { border-left-color: #71717a; }
.job-row-tracked.stage-cancelled   { border-left-color: #ef4444; opacity: 0.62; }

.job-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.job-title { font-size: 15px; font-weight: 600; color: var(--text, #18181b); }
.badge-stage { padding: 3px 9px; font-size: 11px; border-radius: 999px; font-weight: 600; }
.badge-stage.stage-discovery   { background: rgba(99, 102, 241, 0.12); color: #4338ca; }
.badge-stage.stage-in_progress { background: rgba(59, 130, 246, 0.12); color: #1d4ed8; }
.badge-stage.stage-in_review   { background: rgba(168, 85, 247, 0.12); color: #7e22ce; }
.badge-stage.stage-demo        { background: rgba(245, 158, 11, 0.16); color: #b45309; }
.badge-stage.stage-delivery    { background: rgba(20, 184, 166, 0.16); color: #0f766e; }
.badge-stage.stage-done        { background: rgba(16, 185, 129, 0.14); color: #047857; }
.badge-stage.stage-on_hold     { background: rgba(113, 113, 122, 0.14); color: #52525b; }
.badge-stage.stage-cancelled   { background: rgba(239, 68, 68, 0.12); color: #b91c1c; }
.badge-stage.stage-no_tracking { background: rgba(113, 113, 122, 0.10); color: #71717a; }

.progress-bar {
  position: relative;
  height: 18px;
  background: var(--surface-2, #f4f4f5);
  border-radius: 6px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.progress-fill.stage-discovery-fill   { background: linear-gradient(90deg, #6366f1, #818cf8); }
.progress-fill.stage-in_progress-fill { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.progress-fill.stage-in_review-fill   { background: linear-gradient(90deg, #a855f7, #c084fc); }
.progress-fill.stage-demo-fill        { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.progress-fill.stage-delivery-fill    { background: linear-gradient(90deg, #14b8a6, #2dd4bf); }
.progress-fill.stage-done-fill        { background: linear-gradient(90deg, #10b981, #34d399); }
.progress-fill.stage-on_hold-fill     { background: linear-gradient(90deg, #71717a, #a1a1aa); }
.progress-fill.stage-cancelled-fill   { background: linear-gradient(90deg, #ef4444, #f87171); }
.progress-fill.stage-no_tracking-fill { background: var(--surface-3, #d4d4d8); }
.progress-label {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--text, #18181b);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}

.job-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 6px 16px; margin: 4px 0 0; }
.job-meta-row { display: flex; gap: 6px; font-size: 12.5px; line-height: 1.4; margin: 0; }
.job-meta-row dt { color: var(--text-muted, #71717a); font-weight: 500; min-width: 110px; }
.job-meta-row dd { color: var(--text, #18181b); margin: 0; }
.job-meta-demo dd, .job-meta-delivered dd { color: var(--text, #111827); }
.job-meta-blockers dd { color: #b45309; font-weight: 500; }
.job-meta-muted { opacity: 0.65; }

.job-edit summary {
  cursor: pointer; list-style: none; user-select: none;
  width: fit-content;
}
.job-edit summary::-webkit-details-marker { display: none; }
.job-edit[open] summary { margin-bottom: 8px; }
.job-tracking-form {
  display: grid; gap: 8px;
  padding: 12px; margin-top: 4px;
  background: var(--surface-2, #f9fafb);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
}



/* ── Mini agente conversacional — panel premium (cycle 18, 2026-07-15) ── */

.panel-cuenta {
  background:
    radial-gradient(1100px 380px at 0% 0%, rgba(99, 102, 241, 0.10), transparent 60%),
    radial-gradient(900px 320px at 100% 100%, rgba(20, 184, 166, 0.08), transparent 60%),
    var(--surface-1, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 16px;
  padding: 18px 22px 20px;
  position: relative;
  overflow: hidden;
}
.panel-cuenta::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, #6366f1, #3b82f6, #14b8a6, #f59e0b);
  opacity: 0.85;
}
.panel-cuenta .panel-head { border: none; padding: 0 0 6px; }
.panel-cuenta h2 { display: flex; align-items: center; gap: 8px; font-size: 17px; }
.badge-soft {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  background: rgba(99, 102, 241, 0.10);
  color: #4338ca;
  border-radius: 999px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.cuenta-hint {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--text-muted, #6b7280);
  font-style: italic;
}
.cuenta-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 10px;
}
@media (max-width: 920px) { .cuenta-layout { grid-template-columns: 1fr; } }
.cuenta-input-col, .cuenta-preview-col { display: flex; flex-direction: column; gap: 10px; }
.cuenta-textarea {
  min-height: 96px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.55;
  padding: 12px 14px;
  border: 1.5px solid var(--border, #e5e7eb);
  border-radius: 10px;
  background: var(--surface-0, #fafafa);
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.cuenta-textarea:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.cuenta-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
}
.btn-success:hover:not(:disabled) {
  background: linear-gradient(135deg, #059669, #047857);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.35);
}
.btn-success:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: white;
  border: none;
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #4f46e5, #4338ca);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35);
}
.cuenta-status { font-size: 12.5px; }

.cuenta-preview-empty {
  padding: 30px;
  border: 2px dashed var(--border, #e5e7eb);
  border-radius: 12px;
  text-align: center;
  background: var(--surface-2, #fafafa);
  min-height: 200px;
  display: flex; align-items: center; justify-content: center;
}
.cuenta-preview-card {
  padding: 16px 18px;
  border-radius: 12px;
  background: var(--surface-0, #fff);
  border: 1px solid var(--border, #e5e7eb);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.06);
  animation: slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.cuenta-preview-card h3 {
  margin: 0 0 12px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted, #6b7280);
}
.cuenta-fields { display: grid; gap: 8px; margin: 0; }
.cuenta-field {
  display: grid;
  grid-template-columns: 120px 1fr;
  align-items: baseline;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border, #f3f4f6);
}
.cuenta-field:last-child { border-bottom: none; }
.cuenta-field.is-empty { opacity: 0.4; }
.cuenta-field dt {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted, #6b7280);
  margin: 0;
}
.cuenta-field dd {
  margin: 0;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.cuenta-field dd small { font-size: 11px; }
.cuenta-confidence {
  margin: 12px 0 0;
  font-size: 11.5px;
  text-align: right;
  font-weight: 500;
}
.hidden { display: none !important; }

@keyframes slide-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Premium global refinements (cycle 18, 2026-07-15) ────────────────── */

/* Smoother focus rings across the whole app */
*:focus-visible {
  outline: 2px solid rgba(99, 102, 241, 0.55);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Soft, layered shadows for panels */
.panel {
  border-radius: 14px;
  background: var(--surface-1, #fff);
  border: 1px solid var(--border, #e5e7eb);
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 2px 8px rgba(15, 23, 42, 0.03);
  transition: box-shadow 0.2s, transform 0.2s;
}
.panel:hover {
  box-shadow:
    0 2px 4px rgba(15, 23, 42, 0.05),
    0 8px 24px rgba(15, 23, 42, 0.05);
}

/* Topbar gets a subtle gradient */
.topbar {
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  background: linear-gradient(180deg, var(--surface-1, rgba(255,255,255,0.92)), var(--surface-1, rgba(255,255,255,0.78)));
  border-bottom: 1px solid var(--border, #e5e7eb);
}

/* Stage pills: tiny gradient + glow on hover */
.stage-pill {
  transition: transform 0.18s, box-shadow 0.18s;
}
.stage-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

/* Job rows: lift slightly on hover to invite interaction */
.job-row-tracked {
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
  cursor: default;
}
.job-row-tracked:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
}

/* Progress fill: smoother color transition */
.progress-fill {
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1), background 0.3s;
}

/* Page heading: stronger typography */
.page-head h1 {
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Sidebar nav links: smoother hover */
.nav-link {
  transition: background 0.15s, color 0.15s, transform 0.15s;
}
.nav-link:hover {
  transform: translateX(2px);
}

/* Buttons base: gentle hover for all */
.btn {
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}
.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}
.btn:active:not(:disabled) {
  transform: translateY(0);
}

/* Empty states: less boring */
.empty {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 8px);
  padding: 24px 16px;
  text-align: center;
}
.empty h3 { color: var(--text); }
.empty p, .empty .muted { color: var(--text-muted); }

/* Timeline marker: subtle pulse on newest */
.timeline-marker {
  transition: transform 0.2s, box-shadow 0.2s;
}
.timeline-item:first-child .timeline-marker {
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.18);
}

/* Form inputs: cleaner */
.form-input, .select-sm {
  border-radius: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus, .select-sm:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

/* Reduced motion respect */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}



/* ── Pipeline kanban (cycle 19, 2026-07-15) ─────────────────────────────── */

.kpi-grid-pipeline { margin: 16px 0 20px; }

.pipeline-board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(240px, 1fr);
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 14px;
  scroll-snap-type: x mandatory;
}
.pipeline-col {
  background: var(--surface-2, #fafafa);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  display: flex; flex-direction: column;
  min-height: 280px;
  scroll-snap-align: start;
}
.pipeline-col-head {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  display: flex; align-items: center; justify-content: space-between;
  border-top-left-radius: 12px; border-top-right-radius: 12px;
  font-size: 13px;
  font-weight: 600;
}
.pipeline-col-head h3 { margin: 0; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.pipeline-col-head.stage-discovery   { background: rgba(99, 102, 241, 0.08); color: #4338ca; }
.pipeline-col-head.stage-in_progress { background: rgba(59, 130, 246, 0.08); color: #1d4ed8; }
.pipeline-col-head.stage-in_review   { background: rgba(168, 85, 247, 0.08); color: #7e22ce; }
.pipeline-col-head.stage-demo        { background: rgba(245, 158, 11, 0.12); color: #b45309; }
.pipeline-col-head.stage-delivery    { background: rgba(20, 184, 166, 0.10); color: #0f766e; }
.pipeline-col-head.stage-done        { background: rgba(16, 185, 129, 0.10); color: #047857; }
.pipeline-col-head.stage-on_hold     { background: rgba(113, 113, 122, 0.10); color: #52525b; }
.pipeline-col-head.stage-cancelled   { background: rgba(239, 68, 68, 0.08); color: #b91c1c; }
.pipeline-col-head.stage-no_tracking { background: rgba(113, 113, 122, 0.08); color: #52525b; }

.pipeline-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 22px; padding: 0 8px;
  background: var(--surface-1, #fff);
  border-radius: 999px;
  font-size: 11px; font-weight: 700;
  color: var(--text, #18181b);
  border: 1px solid var(--border, #e5e7eb);
}
.pipeline-col-body {
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px;
  flex: 1;
}
.pipeline-empty {
  text-align: center; font-size: 11px; color: var(--text-muted, #9ca3af);
  padding: 16px 0; font-style: italic;
}
.pipeline-card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px 12px;
  background: var(--surface-1, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-left: 3px solid var(--border, #e5e7eb);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
}
.pipeline-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}
.pipeline-card.stage-discovery   { border-left-color: #6366f1; }
.pipeline-card.stage-in_progress { border-left-color: #3b82f6; }
.pipeline-card.stage-in_review   { border-left-color: #a855f7; }
.pipeline-card.stage-demo        { border-left-color: #f59e0b; }
.pipeline-card.stage-delivery    { border-left-color: #14b8a6; }
.pipeline-card.stage-done        { border-left-color: #10b981; opacity: 0.85; }
.pipeline-card.stage-on_hold     { border-left-color: #71717a; }
.pipeline-card.stage-cancelled   { border-left-color: #ef4444; opacity: 0.7; }
.pipeline-card.stage-no_tracking { border-left-color: #d4d4d8; border-style: dashed; }

.pipeline-card-title { font-size: 13px; font-weight: 600; line-height: 1.3; }
.pipeline-card-client { font-size: 11px; color: var(--text-muted, #6b7280); }
.pipeline-card-meta { font-size: 11.5px; color: var(--text, #18181b); line-height: 1.3; }

.pipeline-card-foot { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.pipeline-chip {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 7px; border-radius: 999px;
  background: var(--surface-2, #f4f4f5);
  color: var(--text-muted, #52525b);
  font-size: 10.5px; font-weight: 500;
  border: 1px solid var(--border, #e5e7eb);
}
.pipeline-chip-demo { background: rgba(245, 158, 11, 0.14); color: #b45309; border-color: rgba(245, 158, 11, 0.30); }
.pipeline-chip-warn { background: rgba(239, 68, 68, 0.12); color: #b91c1c; border-color: rgba(239, 68, 68, 0.25); }

.progress-bar-sm { height: 14px; }
.progress-bar-sm .progress-label { font-size: 9.5px; }

.kpi-warn .kpi-value { color: #b91c1c; }



/* ── Dashboard pipeline strip (cycle 19, 2026-07-15) ────────────────────── */

.warn-text { color: #b45309; font-weight: 600; }

.pipeline-mini {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.pipeline-mini-link {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 14px 10px;
  background: var(--surface-2, #fafafa);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text, #18181b);
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
}
.pipeline-mini-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
  border-color: var(--border-strong, #d4d4d8);
}
.pipeline-mini-link.kpi-warn {
  background: rgba(239, 68, 68, 0.05);
  border-color: rgba(239, 68, 68, 0.20);
}
.pipeline-mini-link.kpi-warn .pipeline-mini-val { color: #b91c1c; }
.pipeline-mini-icon { font-size: 20px; }
.pipeline-mini-val {
  font-size: 24px; font-weight: 700; line-height: 1;
  color: var(--text, #18181b);
}
.pipeline-mini-lbl {
  font-size: 11px;
  color: var(--text-muted, #6b7280);
  text-transform: uppercase; letter-spacing: 0.04em; font-weight: 500;
}

.pipeline-mini-link.stage-in_progress .pipeline-mini-val { color: #1d4ed8; }
.pipeline-mini-link.stage-in_review   .pipeline-mini-val { color: #7e22ce; }
.pipeline-mini-link.stage-demo        .pipeline-mini-val { color: #b45309; }
.pipeline-mini-link.stage-delivery    .pipeline-mini-val { color: #0f766e; }
.pipeline-mini-link.stage-done        .pipeline-mini-val { color: #047857; }



/* ── Suggestions panel (cycle 19, 2026-07-15) ──────────────────────────── */

.suggestions-panel {
  background:
    radial-gradient(700px 220px at 0% 0%, rgba(168, 85, 247, 0.10), transparent 60%),
    var(--surface-2, #fafafa);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  padding: 12px 16px 14px;
}
.suggestions-panel.suggestions-ok {
  text-align: center;
  padding: 20px;
  color: var(--text-muted, #6b7280);
}
.suggestions-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.suggestions-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.suggestions-count {
  font-size: 11px; padding: 2px 9px;
  background: rgba(168, 85, 247, 0.12); color: #7e22ce;
  border-radius: 999px; font-weight: 600;
}
.suggestions-list { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.suggestion-item {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-1, #fff);
  border-radius: 8px;
  border: 1px solid var(--border, #e5e7eb);
  border-left: 3px solid var(--border, #e5e7eb);
  align-items: start;
}
.suggestion-item.urgency-CRITICAL { border-left-color: #ef4444; }
.suggestion-item.urgency-HIGH     { border-left-color: #f59e0b; }
.suggestion-item.urgency-MEDIUM   { border-left-color: #6366f1; }
.suggestion-item.urgency-LOW      { border-left-color: #d4d4d8; }
.suggestion-urgency { display: flex; flex-direction: column; gap: 2px; font-size: 11px; }
.urgency-label { font-weight: 700; letter-spacing: 0.04em; font-size: 10px; }
.urgency-CRITICAL .urgency-label { color: #b91c1c; }
.urgency-HIGH .urgency-label     { color: #b45309; }
.urgency-MEDIUM .urgency-label   { color: #4338ca; }
.urgency-LOW .urgency-label      { color: #71717a; }
.suggestion-body { display: flex; flex-direction: column; gap: 3px; }
.suggestion-job { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; font-weight: 600; }
.suggestion-job a { color: inherit; text-decoration: none; }
.suggestion-job a:hover { text-decoration: underline; }
.suggestion-msg { font-size: 12.5px; color: var(--text, #18181b); }
.suggestion-rule { font-size: 10.5px; }
.suggestion-rule code { background: var(--surface-2, #f4f4f5); padding: 1px 5px; border-radius: 3px; font-size: 10.5px; }
.suggestions-foot { margin: 10px 0 0; font-size: 11.5px; }


/* ── CRM v2 additions (2026-07-16) ─────────────────────────────────────── */

/* 7-column kanban */
.kanban-v2 {
  grid-template-columns: repeat(7, minmax(180px, 1fr));
  gap: 10px;
}
.kanban-v2 .kanban-col {
  background: var(--surface-1, #fafafa);
  border-radius: 8px;
  padding: 8px;
}
.kanban-card.status-backlog { border-left: 4px solid #94a3b8; }
.kanban-card.status-todo { border-left: 4px solid #3b82f6; }
.kanban-card.status-doing { border-left: 4px solid #f59e0b; }
.kanban-card.status-review { border-left: 4px solid #8b5cf6; }
.kanban-card.status-blocked { border-left: 4px solid #ef4444; background: var(--surface-1); }
.kanban-card.status-done { border-left: 4px solid #22c55e; opacity: 0.78; }
.kanban-card.status-cancelled { border-left: 4px solid #64748b; opacity: 0.6; }
.kanban-card .kanban-card-actions {
  display: flex; flex-wrap: wrap; gap: 3px; padding: 4px 6px; border-top: 1px solid var(--border, #e4e4e7);
}
.kanban-card .kanban-card-actions form { margin: 0; }
.kanban-card .kanban-card-actions .btn-sm { padding: 2px 6px; font-size: 11px; min-width: 28px; }
.btn-warn { background: #ef4444; color: white; border-color: #ef4444; }
.btn-warn:hover { background: #dc2626; }

/* HTMX inline boost: when htmx swaps a form back to 303, refresh cards */
.kanban-card.htmx-swapping { opacity: 0.5; transition: opacity 200ms; }

/* Kanban distribution bar chart (CSS only) */
.kanban-dist {
  padding: 16px 20px 12px;
}
.kanban-dist-bars {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end;
  min-height: 140px; margin-bottom: 8px;
}
.kanban-dist-col {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  height: 100%;
}
.kanban-dist-bar-wrap {
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  height: 100px; width: 100%;
}
.kanban-dist-count {
  font-size: 13px; font-weight: 600; color: var(--text, #18181b); margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}
.kanban-dist-bar {
  width: 75%; border-radius: 6px 6px 0 0; min-height: 4px; transition: height 400ms ease;
  box-shadow: 0 1px 0 rgba(0,0,0,0.04);
}
.kanban-dist-label {
  font-size: 10.5px; color: var(--muted, #6b7280); text-align: center;
  letter-spacing: -0.02em; line-height: 1.2; max-width: 84px;
}
.kanban-dist-label span { display: inline-block; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; max-width: 84px; }
.kanban-dist-summary {
  text-align: center; font-size: 12px; margin-top: 6px;
}
.kanban-dist-summary strong { color: var(--text, #18181b); }

/* Team KPI cards (v2) */
.team-kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px;
  padding: 16px 20px;
}
.team-kpi-card {
  background: var(--surface-1, #fafafa); border: 1px solid var(--border, #e4e4e7);
  border-radius: 10px; padding: 12px 14px; transition: border-color 200ms;
}
.team-kpi-card.is-warning { border-color: #f59e0b; }
.team-kpi-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.team-kpi-name { font-weight: 600; font-size: 14px; }
.team-kpi-stats { display: flex; gap: 14px; }
.team-kpi-stat { display: flex; flex-direction: column; gap: 2px; align-items: center; flex: 1; }
.team-kpi-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.team-kpi-label { font-size: 10.5px; color: var(--muted, #6b7280); text-transform: lowercase; letter-spacing: 0.02em; }
.hal-chat-toggle .hal-badge {
  /* SVG inside the button — sized to fill */
  width: 32px;
  height: 32px;
  display: block;
}
/* El 🤖 emoji en el toggle debe ser siempre visible */
.hal-chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: white;
  border: 2px solid rgba(255,255,255,0.4);
  cursor: pointer;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 1.8rem !important;
  line-height: 1 !important;
  box-shadow: 0 6px 20px rgba(124,58,237,0.5);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  overflow: visible !important;
}
.hal-chat-toggle:hover { transform: scale(1.08); box-shadow: 0 8px 28px rgba(124,58,237,0.65); background: linear-gradient(135deg, #1d4ed8, #6d28d9); }
.hal-chat-toggle:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.hal-chat-toggle[aria-expanded="true"] { background: linear-gradient(135deg, #1d4ed8, #6d28d9); transform: scale(1.05); }
.hal-chat-toggle .hal-badge {
  position: absolute;
  top: -3px; right: -3px;
  background: #ef4444;
  color: white;
  font-size: 9px;
  font-family: system-ui, sans-serif;
  font-weight: 700;
  min-width: 14px;
  height: 14px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
  border: 1.5px solid #1f1235;
  z-index: 1;
}
/* El emoji 🤖 debe renderizar por encima del badge */
.hal-chat-toggle > .hal-badge:first-child,
.hal-chat-toggle > * { z-index: 0; }
.hal-chat-toggle > *:not(.hal-badge) { z-index: 2; }

/* ── Chat panel ── */
.hal-chat-panel {
  position: fixed;
  bottom: 90px;
  right: 24px;
  z-index: 199;
  width: var(--chat-width);
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: var(--bg-elevated, #fff);
  border: 1px solid var(--border, #e7e5e4);
  border-radius: var(--radius-lg, 12px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s cubic-bezier(0.34,1.56,0.64,1), opacity 0.18s ease;
}
.hal-chat-panel.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}
.hal-chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border, #e7e5e4);
  background: var(--bg-sunken, #f5f5f4);
  flex-shrink: 0;
}
.hal-chat-header-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent, #2563eb);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.hal-chat-header-info { flex: 1; min-width: 0; }
.hal-chat-header-name { font-weight: 600; font-size: 0.9rem; }
.hal-chat-header-sub { font-size: 0.75rem; color: var(--text-muted, #78716c); }
.hal-chat-header-actions { display: flex; gap: 4px; }
.hal-chat-btn-icon {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted, #78716c);
  font-size: 0.85rem;
  transition: background 0.1s;
}
.hal-chat-btn-icon:hover { background: var(--border, #e7e5e4); color: var(--text); }
.hal-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.hal-chat-messages::-webkit-scrollbar { width: 4px; }
.hal-chat-messages::-webkit-scrollbar-thumb { background: var(--border-strong, #d6d3d1); border-radius: 2px; }
.hal-chat-msg { display: flex; flex-direction: column; gap: 2px; max-width: 88%; }
.hal-chat-msg.user { align-self: flex-end; align-items: flex-end; }
.hal-chat-msg.hal { align-self: flex-start; align-items: flex-start; }
.hal-chat-msg-bubble {
  padding: 7px 11px;
  border-radius: 12px;
  font-size: 0.875rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 100%;
}
.hal-chat-msg.user .hal-chat-msg-bubble {
  background: var(--accent, #2563eb);
  color: white;
  border-bottom-right-radius: 3px;
}
.hal-chat-msg.hal .hal-chat-msg-bubble {
  background: var(--bg-sunken, #f5f5f4);
  color: var(--text, #1c1917);
  border-bottom-left-radius: 3px;
}
.hal-chat-msg-time { font-size: 0.68rem; color: var(--text-soft, #a8a29e); padding: 0 4px; }
.hal-chat-msg-status { font-size: 0.68rem; color: var(--text-soft); }
.hal-chat-msg-error .hal-chat-msg-bubble { background: var(--danger-bg, #fef2f2); border: 1px solid var(--danger-border, #fecaca); color: var(--danger, #dc2626); }
.hal-chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-muted, #78716c);
  text-align: center;
  padding: 24px;
}
.hal-chat-empty-icon { font-size: 2rem; opacity: 0.5; }
.hal-chat-empty h3 { font-size: 0.9rem; margin: 0; }
.hal-chat-empty p { font-size: 0.8rem; margin: 0; max-width: 240px; line-height: 1.4; }
.hal-chat-welcome {
  background: var(--accent-bg, #eff6ff);
  border: 1px solid var(--accent-border, #bfdbfe);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.82rem;
  color: var(--accent, #2563eb);
  line-height: 1.4;
  margin-bottom: 4px;
}
.hal-chat-input-area {
  padding: 10px 12px;
  border-top: 1px solid var(--border, #e7e5e4);
  background: var(--bg-elevated, #fff);
  flex-shrink: 0;
}
.hal-chat-input-row { display: flex; gap: 6px; align-items: flex-end; }
.hal-chat-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border, #e7e5e4);
  border-radius: 20px;
  font: inherit;
  font-size: 0.875rem;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
  background: var(--bg, #fafaf9);
  color: var(--text, #1c1917);
  transition: border-color 0.15s;
  line-height: 1.4;
}
.hal-chat-input:focus { outline: none; border-color: var(--accent, #2563eb); }
.hal-chat-input::placeholder { color: var(--text-soft, #a8a29e); }
.hal-chat-send {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--accent, #2563eb);
  color: white;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
  transition: background 0.1s, transform 0.1s;
}
.hal-chat-send:hover { background: var(--accent-hover, #1d4ed8); transform: scale(1.05); }
.hal-chat-send:disabled { background: var(--text-soft, #a8a29e); cursor: not-allowed; transform: none; }
.hal-chat-send:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hal-chat-error-bar {
  font-size: 0.75rem;
  color: var(--danger, #dc2626);
  background: var(--danger-bg, #fef2f2);
  padding: 4px 8px;
  border-radius: 4px;
  margin-top: 4px;
  display: none;
}
.hal-chat-error-bar.visible { display: block; }
.hal-chat-typing-indicator {
  display: flex; gap: 4px; align-items: center;
  padding: 6px 10px;
}
.hal-chat-typing-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-soft, #a8a29e);
  animation: hal-chat-typing 1.2s ease-in-out infinite;
}
.hal-chat-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.hal-chat-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes hal-chat-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}
/* Panel session list */
.hal-chat-sessions { padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.hal-chat-session-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.1s;
}
.hal-chat-session-item:hover { background: var(--bg-sunken, #f5f5f4); }
.hal-chat-session-item.active { background: var(--accent-bg, #eff6ff); }
.hal-chat-session-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent, #2563eb); flex-shrink: 0; }
.hal-chat-session-info { flex: 1; min-width: 0; }
.hal-chat-session-preview { font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hal-chat-session-meta { font-size: 0.7rem; color: var(--text-soft); }
.hal-chat-session-count { font-size: 0.7rem; color: var(--text-muted); background: var(--bg-sunken); padding: 1px 5px; border-radius: 9px; }

/* Responsive */
@media (max-width: 640px) {
  .hal-chat-panel { right: 8px; bottom: 80px; width: calc(100vw - 16px); height: calc(100vh - 100px); }
  .hal-chat-toggle { right: 16px; bottom: calc(6.25rem + env(safe-area-inset-bottom, 0px)); }
}

/* ── Thinking Orbs utilities (2026-07-23) ──────────────────────────── */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.hal-orb-static {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  font-size: 18px; line-height: 1;
}
.hal-orb-large {
  display: inline-flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  font-size: 32px; margin: 0 auto 8px;
  animation: hal-orb-pulse 2.2s ease-in-out infinite;
  box-shadow: 0 0 24px rgba(37, 99, 235, 0.45);
}
@keyframes hal-orb-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 24px rgba(37, 99, 235, 0.45); }
  50%      { transform: scale(1.06); box-shadow: 0 0 32px rgba(124, 58, 237, 0.6); }
}
.hal-chat-empty {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  text-align: center; padding: 24px 16px; color: var(--text-muted, #78716c);
}
.hal-chat-input-form {
  display: flex; gap: 8px; padding: 12px;
  border-top: 1px solid var(--border, #e7e5e4); background: var(--bg, #fff);
}
.hal-chat-input-form textarea {
  flex: 1; resize: none; padding: 8px 10px;
  border: 1px solid var(--border, #e7e5e4); border-radius: 8px;
  font: inherit; background: var(--bg, #fff); color: var(--text, #1c1917);
  min-height: 36px; max-height: 140px;
}
.hal-chat-input-form textarea:focus {
  outline: none; border-color: var(--accent, #2563eb);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.18);
}
.hal-chat-bubble {
  padding: 8px 12px; border-radius: 14px; line-height: 1.45;
  word-wrap: break-word; white-space: pre-wrap; font-size: 0.88rem;
}
.hal-chat-bubble.user {
  background: var(--accent, #2563eb); color: #fff;
  border-bottom-right-radius: 4px;
}
.hal-chat-bubble.hal {
  background: var(--border, #e7e5e4); color: var(--text, #1c1917);
  border-bottom-left-radius: 4px;
}
.hal-chat-status {
  font-size: 0.7rem; opacity: 0.7; padding: 2px 0;
}
.hal-status-error   { color: #b91c1c; }
.hal-status-timeout { color: #92400e; }

/* Whole board card clickable without nesting the project/client chip links. */
.kanban-card-link-stretched::after { content: ""; position: absolute; inset: 0; }
.kanban-card .kanban-card-meta a.task-chip { position: relative; z-index: 1; }
