@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=DM+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-base: #0a0e1a;
  --bg-surface: #111827;
  --bg-elevated: #1e293b;
  --bg-input: #0f172a;
  --bg-hover: rgba(255,255,255,0.04);

  --border: #1e293b;
  --border-light: #334155;
  --border-focus: #29A7DE;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #475569;

  --accent: #29A7DE;
  --accent-hover: #1E8FC2;
  --accent-soft: rgba(41,167,222,0.10);
  --accent-border: rgba(41,167,222,0.25);

  /* Color de "otro miembro" en un proyecto grupal -- distinto del azul (yo) y del
     gris (la IA), para que un vistazo alcance para saber quien escribio que. */
  --accent2: #8b5cf6;
  --accent2-soft: rgba(139,92,246,0.10);
  --accent2-border: rgba(139,92,246,0.25);

  --danger: #ef4444;
  --danger-soft: rgba(239,68,68,0.12);
  --success: #22c55e;
  --warning: #f59e0b;

  --font-display: 'Bebas Neue', 'Segoe UI', sans-serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.35);
  --shadow-glow: 0 4px 20px rgba(41,167,222,0.25);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font-family: inherit; }
::selection { background: var(--accent-soft); color: var(--text-primary); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: var(--radius-full); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Login ---------- */
.login-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(41,167,222,0.08), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(41,167,222,0.06), transparent 40%),
    var(--bg-base);
}
.login-card {
  width: 360px;
  max-width: 90vw;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 32px 32px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.login-brand {
  font-family: var(--font-display);
  font-size: 48px;
  letter-spacing: 2px;
  color: var(--accent);
  text-shadow: var(--shadow-glow);
  margin: 0 0 4px;
}
.login-sub {
  color: var(--text-secondary);
  font-size: 12px;
  margin: 0 0 28px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.field { text-align: left; margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.field input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color 150ms var(--ease-out), box-shadow 150ms var(--ease-out);
}
.field input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field textarea {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); padding: 10px 12px; color: var(--text-primary); font-size: 13px;
  outline: none; resize: vertical; font-family: var(--font-body); line-height: 1.5;
  transition: border-color 150ms var(--ease-out), box-shadow 150ms var(--ease-out);
}
.field textarea:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--accent-soft); }
.field select {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); padding: 9px 10px; color: var(--text-primary); font-size: 13px;
}
.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #051018;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: transform 120ms var(--ease-out), box-shadow 120ms var(--ease-out);
  box-shadow: 0 2px 16px rgba(41,167,222,0.3);
}
.btn-primary:hover { box-shadow: 0 4px 24px rgba(41,167,222,0.45); }
.btn-primary:active { transform: scale(0.98); }
.login-error {
  color: var(--danger);
  font-size: 12px;
  margin-top: 12px;
  min-height: 16px;
}
.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.input-eye { position: relative; }
.input-eye input { padding-right: 38px; }
.eye-btn {
  position: absolute; top: 50%; right: 4px; transform: translateY(-50%);
  width: 26px; height: 26px; border-radius: var(--radius-sm);
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color 120ms var(--ease-out);
}
.eye-btn:hover { color: var(--text-primary); }

/* ---------- App shell ---------- */
.app {
  display: none;
  height: 100vh;
  grid-template-columns: 280px 1fr;
}
.app.active { display: grid; }

.sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
}
.sidebar-brand {
  font-family: var(--font-display);
  font-size: 30px;
  letter-spacing: 1.5px;
  color: var(--accent);
  margin: 4px 4px 24px;
}
.sidebar-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin: 4px 8px 8px;
}
.proyecto-list { list-style: none; margin: 0 0 20px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.proyecto-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  transition: background 120ms var(--ease-out), color 120ms var(--ease-out);
  border: 1px solid transparent;
}
.proyecto-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.proyecto-item.active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--text-primary);
}
.proyecto-nombre { flex: 1; font-weight: 500; text-transform: capitalize; }
.proyecto-item.proyecto-grupo { border-left: 3px solid var(--accent2); padding-left: 9px; }
.proyecto-item.proyecto-grupo .proyecto-nombre { font-weight: 700; }
.proyecto-arrows { display: flex; flex-direction: column; gap: 1px; flex-shrink: 0; }
.proyecto-arrow {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 8px; line-height: 1; padding: 1px 3px; border-radius: 3px;
  transition: color 120ms var(--ease-out), background 120ms var(--ease-out);
}
.proyecto-arrow:hover:not(:disabled) { color: var(--text-primary); background: var(--bg-elevated); }
.proyecto-arrow:disabled { opacity: 0.25; cursor: default; }
.nivel-badge {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  white-space: nowrap;
}
.nivel-badge[data-nivel="1"] { background: rgba(148,163,184,0.15); color: #94a3b8; }
.nivel-badge[data-nivel="2"] { background: var(--warning); color: #1a1200; opacity: 0.85; }
.nivel-badge[data-nivel="3"] { background: var(--danger); color: #1a0505; opacity: 0.85; }
.nivel-badge[data-nivel="0"] {
  background: repeating-linear-gradient(45deg, var(--danger), var(--danger) 4px, #7f1d1d 4px, #7f1d1d 8px);
  color: #fff; font-weight: 700;
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.user-chip { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); font-size: 13px; overflow: hidden; }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.icon-btn {
  background: transparent; border: 1px solid var(--border-light);
  color: var(--text-secondary); border-radius: var(--radius-sm);
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: background 120ms var(--ease-out), color 120ms var(--ease-out);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ---------- Chat ---------- */
.chat {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-width: 0;
}
.chat-header {
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
}
.chat-header h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 22px;
  letter-spacing: 0.5px;
  margin: 0;
  text-transform: capitalize;
}
.chat-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-muted); gap: 8px; text-align: center; padding: 24px;
}
.chat-empty .big { font-family: var(--font-display); font-size: 26px; color: var(--text-secondary); letter-spacing: 1px; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.msg { display: flex; gap: 12px; max-width: 780px; }
.msg-user { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
}
.msg-user .msg-avatar { background: var(--accent-soft); color: var(--accent); }
.msg-ai .msg-avatar { background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border-light); }
/* Color por persona en .msg-otro: --user-color/--user-color-soft/--user-color-border
   se calculan en JS (hash determinista del nombre, ver colorParaRemitente en app.js) y
   se setean inline por mensaje -- asi cada miembro del grupo tiene SIEMPRE el mismo
   color propio, distinguible del resto, sin depender de una lista fija de usuarios.
   El fallback (--accent2) cubre el caso sin JS o sin remitente. */
.msg-otro .msg-avatar { background: var(--user-color-soft, var(--accent2-soft)); color: var(--user-color, var(--accent2)); }
.msg-body {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-user .msg-body { background: var(--accent-soft); border-color: var(--accent-border); }
.msg-ai .msg-body { background: var(--bg-surface); }
.msg-otro .msg-body { background: var(--user-color-soft, var(--accent2-soft)); border-color: var(--user-color-border, var(--accent2-border)); }
.msg-remitente {
  font-size: 11px; font-weight: 700; color: var(--user-color, var(--accent2));
  margin-bottom: 4px; padding-left: 2px;
}
.msg-remitente-propio { color: var(--accent); text-align: right; padding-left: 0; padding-right: 2px; }
.msg-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.msg-time { font-size: 10px; color: var(--text-muted); }
.speak-btn {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  padding: 2px; display: flex; align-items: center; transition: color 120ms var(--ease-out);
}
.speak-btn:hover { color: var(--accent); }
.speak-btn.speaking { color: var(--accent); animation: pulse 1.1s infinite ease-in-out; }
.copy-btn {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  padding: 2px; display: flex; align-items: center; transition: color 120ms var(--ease-out);
}
.copy-btn:hover { color: var(--accent); }
.copy-btn.copied { color: var(--accent); }
.delete-btn {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  padding: 2px; display: flex; align-items: center; transition: color 120ms var(--ease-out);
}
.delete-btn:hover { color: var(--danger); }
.reply-btn {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  padding: 2px; display: flex; align-items: center; transition: color 120ms var(--ease-out);
}
.reply-btn:hover { color: var(--accent); }

.msg-quote {
  display: block; border-left: 3px solid var(--accent-border); background: rgba(255,255,255,0.04);
  border-radius: 4px; padding: 6px 10px; margin-bottom: 8px; font-size: 12px;
  color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
}

.reply-preview-bar {
  display: flex; align-items: center; gap: 8px; background: var(--bg-input);
  border: 1px solid var(--border-light); border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: 6px 10px; margin-bottom: 10px;
}
.reply-preview-bar:empty { display: none; margin: 0; }
.reply-preview-text {
  flex: 1; font-size: 12px; color: var(--text-secondary); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.reply-preview-text b { color: var(--text-primary); }
.reply-preview-close {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  padding: 4px; display: flex; align-items: center; transition: color 120ms var(--ease-out); flex: none;
}
.reply-preview-close:hover { color: var(--danger); }

.thinking { display: flex; gap: 4px; padding: 6px 2px; }
.thinking span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
  animation: pulse 1.1s infinite ease-in-out;
}
.thinking span:nth-child(2) { animation-delay: 0.15s; }
.thinking span:nth-child(3) { animation-delay: 0.3s; }
@keyframes pulse { 0%, 80%, 100% { opacity: 0.25; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }

.thinking-status { font-size: 11px; margin-top: 4px; font-family: var(--font-mono); }
.thinking-timer { opacity: 0.65; color: var(--text-secondary); }
.thinking-steps {
  list-style: none; margin: 4px 0 0; padding: 6px 0 0 10px; border-left: 2px solid var(--border-light);
  display: flex; flex-direction: column; gap: 3px; max-height: 110px; overflow-y: auto;
}
.thinking-steps li { opacity: 0.45; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thinking-steps li:last-child { opacity: 0.75; }

.chat-inputbar {
  border-top: 1px solid var(--border);
  padding: 16px 28px 20px;
  background: var(--bg-surface);
}
.inputbar-inner {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 8px 8px 8px 16px;
  transition: border-color 150ms var(--ease-out), box-shadow 150ms var(--ease-out);
}
.inputbar-inner:focus-within { border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--accent-soft); }
.inputbar-inner textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 14px;
  resize: none;
  max-height: 160px;
  padding: 8px 0;
  font-family: inherit;
}
.inputbar-inner textarea::placeholder { color: var(--text-muted); }
.round-btn {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  border: 1px solid var(--border-light); background: var(--bg-elevated);
  color: var(--text-secondary); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 150ms var(--ease-out);
}
.round-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.round-btn.mic-active { background: var(--danger-soft); border-color: rgba(239,68,68,0.4); color: var(--danger); animation: mic-pulse 1.4s infinite; }
@keyframes mic-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.35);} 50% { box-shadow: 0 0 0 6px rgba(239,68,68,0);} }
.round-btn.send { background: linear-gradient(135deg, var(--accent), var(--accent-hover)); color: #051018; border: none; }
.round-btn.send:disabled { opacity: 0.4; cursor: not-allowed; }
.inputbar-hint { font-size: 10px; color: var(--text-muted); margin-top: 8px; text-align: center; }

.attach-preview-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.attach-preview-list:empty { display: none; margin: 0; }
.attach-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-input); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); padding: 5px 8px; max-width: 220px;
}
.attach-chip-icon { flex: none; display: flex; align-items: center; justify-content: center; color: var(--accent); }
.attach-chip-icon img { height: 36px; width: 36px; object-fit: cover; border-radius: 6px; display: block; }
.attach-chip-name {
  font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; max-width: 130px;
}
.img-preview-remove {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  padding: 4px; display: flex; align-items: center; transition: color 120ms var(--ease-out); flex: none;
}
.img-preview-remove:hover { color: var(--danger); }
.attach-thumb { position: relative; display: block; width: 56px; height: 56px; flex: none; }
.attach-thumb img {
  width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius-sm);
  cursor: zoom-in; display: block; transition: opacity 120ms var(--ease-out);
}
.attach-thumb img:hover { opacity: 0.85; }
.attach-thumb .img-preview-remove {
  position: absolute; top: -6px; right: -6px; background: var(--bg-elevated);
  border: 1px solid var(--border-light); border-radius: 50%; width: 20px; height: 20px;
  justify-content: center; padding: 0; box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,.3));
}
.msg-adjuntos { display: flex; flex-wrap: wrap; gap: 8px; }
.msg-adjuntos + .msg-text { margin-top: 8px; }
.msg-img { max-width: 220px; max-height: 220px; border-radius: var(--radius-sm); display: block; cursor: zoom-in; transition: opacity 120ms var(--ease-out); }
.msg-img:hover { opacity: 0.88; }
.msg-file-chip {
  display: inline-flex; align-items: center; gap: 8px; background: var(--bg-input);
  border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 8px 12px;
  color: var(--text-secondary); font-size: 12.5px; text-decoration: none;
}
.msg-file-chip:hover { border-color: var(--border-focus); color: var(--text-primary); }

/* --- Boton + y menu de adjuntar --- */
.attach-wrap { position: relative; }
.attach-menu {
  display: none; position: absolute; bottom: calc(100% + 8px); left: 0; z-index: 20;
  background: var(--bg-elevated); border: 1px solid var(--border-light); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); padding: 6px; min-width: 170px; flex-direction: column; gap: 2px;
}
.attach-menu.active { display: flex; }
.attach-menu button {
  display: flex; align-items: center; gap: 10px; background: none; border: none; text-align: left;
  color: var(--text-secondary); font-size: 13px; padding: 8px 10px; border-radius: var(--radius-sm);
  cursor: pointer; font-family: var(--font-body);
}
.attach-menu button:hover { background: var(--bg-hover); color: var(--text-primary); }

.lightbox-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(5,8,16,0.92);
  align-items: center; justify-content: center;
  z-index: 600;
  padding: 32px;
}
.lightbox-overlay.active { display: flex; }
.lightbox-img { max-width: 100%; max-height: 100%; border-radius: var(--radius-md); box-shadow: var(--shadow-lg); }
.lightbox-close {
  position: absolute; top: 20px; right: 20px;
  background: var(--bg-surface);
}

/* ---------- Modal de ajustes ---------- */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(5,8,16,0.7);
  align-items: center; justify-content: center;
  z-index: 500;
}
.modal-overlay.active { display: flex; }
.modal-card {
  width: 380px; max-width: 90vw;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-lg);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-head h2 { font-family: var(--font-display); font-weight: 400; font-size: 20px; letter-spacing: 0.5px; margin: 0; color: var(--text-primary); }
.field-hint { font-size: 11px; color: var(--text-muted); margin: 6px 2px 0; }
#voice-select {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); padding: 9px 10px; color: var(--text-primary); font-size: 13px;
}
#voice-rate { width: 100%; accent-color: var(--accent); }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.btn-secondary {
  flex: 1; background: var(--bg-elevated); border: 1px solid var(--border-light);
  color: var(--text-secondary); border-radius: var(--radius-sm); padding: 10px; cursor: pointer;
  font-weight: 500; font-size: 13px; transition: color 120ms var(--ease-out), background 120ms var(--ease-out);
}
.btn-secondary:hover { color: var(--text-primary); background: var(--bg-hover); }
.modal-actions .btn-primary { flex: 1; width: auto; }
.btn-danger {
  flex: 1; background: linear-gradient(135deg, var(--danger), #b91c1c); border: none;
  color: #fff; border-radius: var(--radius-sm); padding: 10px; cursor: pointer;
  font-weight: 600; font-size: 13px; transition: box-shadow 120ms var(--ease-out), transform 120ms var(--ease-out);
}
.btn-danger:hover { box-shadow: 0 4px 20px rgba(239,68,68,0.35); }
.btn-danger:active { transform: scale(0.98); }
.modal-sep { border: none; border-top: 1px solid var(--border-light); margin: 22px 0 16px; }
#token-claude-input {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); padding: 9px 10px; color: var(--text-primary); font-size: 13px;
}

.modal-card.wide { width: 620px; max-width: 94vw; max-height: 86vh; overflow-y: auto; }

/* --- Toolbar / busqueda --- */
.admin-toolbar { display: flex; gap: 10px; margin-bottom: 16px; }
.admin-search {
  flex: 1; display: flex; align-items: center; gap: 8px; background: var(--bg-input);
  border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 0 10px; color: var(--text-muted);
}
.admin-search input {
  flex: 1; background: none; border: none; outline: none; color: var(--text-primary);
  font-size: 13px; padding: 9px 0; font-family: var(--font-body);
}

/* --- Lista de usuarios (cards) --- */
.admin-user-list { display: flex; flex-direction: column; gap: 8px; }
.admin-empty-hint { color: var(--text-muted); font-size: 13px; text-align: center; padding: 24px 0; }
.admin-family-children {
  display: flex; flex-direction: column; gap: 8px; margin: 8px 0 4px 22px;
  padding-left: 14px; border-left: 2px solid var(--border-light);
}
.admin-user-card {
  display: flex; align-items: center; gap: 12px; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: var(--radius-md); padding: 10px 12px;
  transition: border-color 120ms var(--ease-out), background 120ms var(--ease-out);
}
.admin-user-card:hover { border-color: var(--border-light); background: var(--bg-hover); }
.admin-user-card.inactive { opacity: 0.55; }
.admin-user-avatar {
  flex: none; width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-family: var(--font-display); font-size: 16px; letter-spacing: 0.5px;
  background: var(--accent-soft); color: var(--accent);
}
.admin-user-avatar.rol-1 { background: var(--accent-soft); color: var(--accent); }
.admin-user-avatar.rol-2 { background: rgba(34,197,94,0.12); color: var(--success); }
.admin-user-avatar.rol-3 { background: rgba(148,163,184,0.14); color: var(--text-secondary); }
.admin-user-info { flex: 1; min-width: 0; }
.admin-user-name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13.5px; color: var(--text-primary); }
.admin-user-meta {
  font-size: 12px; color: var(--text-muted); margin-top: 2px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.admin-user-meta .dot { margin: 0 5px; opacity: 0.5; }
.admin-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 600; }
.admin-badge.rol-1 { background: var(--accent-soft); color: var(--accent); }
.admin-badge.rol-2 { background: rgba(34,197,94,0.12); color: var(--success); }
.admin-badge.rol-3 { background: rgba(148,163,184,0.14); color: var(--text-secondary); }
.admin-user-actions { flex: none; display: flex; gap: 4px; }
.admin-icon-btn {
  background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 6px;
  border-radius: var(--radius-sm); display: flex; transition: color 120ms var(--ease-out), background 120ms var(--ease-out);
}
.admin-icon-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.admin-icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }
.admin-icon-btn.on { color: var(--success); }

/* --- Boton volver --- */
.admin-row-btn {
  background: none; border: none; color: var(--accent); cursor: pointer; font-size: 12px;
  font-weight: 600; padding: 2px 4px; margin-bottom: 16px; display: inline-block;
}

/* --- Preview chip --- */
.admin-preview-chip {
  display: flex; align-items: center; gap: 10px; background: var(--accent-soft);
  border: 1px solid var(--accent-border); border-radius: var(--radius-md); padding: 10px 14px; margin-bottom: 20px;
}
.admin-preview-avatar {
  flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--bg-surface);
  color: var(--accent); display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 14px;
}
.admin-preview-text { font-size: 12.5px; color: var(--text-secondary); }
.admin-preview-text strong { color: var(--accent); font-weight: 700; }

/* --- Secciones del formulario --- */
.admin-section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-muted); margin: 22px 0 10px;
}
.admin-section-title:first-of-type { margin-top: 0; }
.admin-field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

/* --- Role pills --- */
.role-pills { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.role-pill {
  text-align: left; background: var(--bg-input); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); padding: 10px 12px; cursor: pointer;
  transition: border-color 120ms var(--ease-out), background 120ms var(--ease-out);
}
.role-pill:hover { border-color: var(--border-light); background: var(--bg-hover); }
.role-pill.active { border-color: var(--accent); background: var(--accent-soft); }
.role-pill-title { display: block; font-size: 12.5px; font-weight: 700; color: var(--text-primary); }
.role-pill.active .role-pill-title { color: var(--accent); }
.role-pill-desc { display: block; font-size: 10.5px; color: var(--text-muted); margin-top: 2px; line-height: 1.3; }

#admin-clonar-select {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); padding: 9px 10px; color: var(--text-primary); font-size: 13px;
}

/* --- Chips de proyectos --- */
.admin-chip-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.admin-chip {
  display: flex; align-items: center; gap: 8px; background: var(--bg-input); border: 1px solid var(--border-light);
  border-radius: 999px; padding: 5px 6px 5px 12px; font-size: 12px; color: var(--text-secondary);
}
.admin-chip .admin-chip-quitar {
  background: var(--bg-elevated); border: none; color: var(--text-muted); cursor: pointer;
  width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 13px; line-height: 1;
}
.admin-chip .admin-chip-quitar:hover { color: var(--danger); background: var(--danger-soft); }
.admin-add-proyecto { display: flex; gap: 8px; }
.admin-add-proyecto select { flex: 1; }
.admin-proyecto-actions { margin-top: 4px; }
.admin-chip { cursor: pointer; }

.menu-btn { display: none; margin-right: 8px; }
.sidebar-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45);
  z-index: 40; opacity: 0; transition: opacity 200ms var(--ease-out);
}

@media (max-width: 760px) {
  .app.active { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 30% 0 0; z-index: 50; transform: translateX(-100%); transition: transform 200ms var(--ease-out); }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: flex; }
  .sidebar-backdrop.open { display: block; opacity: 1; }
}
