*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f13;
  --bg2: #16161d;
  --bg3: #1e1e28;
  --border: #2a2a38;
  --accent: #6366f1;
  --accent-hover: #4f52d4;
  --text: #e2e2f0;
  --text-muted: #7b7b9a;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #22c55e;
  --radius: 10px;
  --sidebar-w: 280px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

/* ── SCREENS ─────────────────────────────── */
.screen { width: 100%; height: 100vh; }
.hidden { display: none !important; }

/* ── AUTH: split layout ──────────────────── */
#bg-canvas { display: none !important; }

#auth-screen {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ─ LEFT PANEL ─ */
.auth-left {
  flex: 0 0 50%;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px 52px;
  overflow: hidden;
  background:
    linear-gradient(155deg, rgba(4,6,18,0.86) 0%, rgba(8,14,36,0.78) 55%, rgba(4,10,22,0.90) 100%),
    url('bg-login.png') center / cover no-repeat;
}

.auth-left::after {
  content: '';
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 1px;
  background: linear-gradient(to bottom, transparent, rgba(99,102,241,0.25) 30%, rgba(99,102,241,0.25) 70%, transparent);
}

.auth-brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(99,102,241,0.10);
  border: 1px solid rgba(99,102,241,0.28);
  border-radius: 100px;
  padding: 7px 16px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #818cf8;
  text-transform: uppercase;
  width: fit-content;
}

.auth-brand-badge::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #6366f1;
  box-shadow: 0 0 6px #6366f1;
  display: block;
}

.auth-left-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px 0;
}

.auth-headline {
  font-size: clamp(2.2rem, 4vw, 3.6rem);
  font-weight: 900;
  line-height: 1.08;
  color: #fff;
  margin: 0 0 22px;
  letter-spacing: -0.03em;
}

.auth-headline-accent { color: #6366f1; }

.auth-desc {
  color: rgba(226,226,240,0.58);
  font-size: 0.95rem;
  line-height: 1.65;
  max-width: 380px;
  margin-bottom: 36px;
}

.auth-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.auth-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(255,255,255,0.055);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 100px;
  padding: 8px 16px;
  font-size: 0.81rem;
  color: rgba(226,226,240,0.75);
  backdrop-filter: blur(6px);
}

.auth-chip svg {
  width: 15px; height: 15px;
  fill: #818cf8;
  flex-shrink: 0;
}

.auth-left-footer {
  font-size: 0.76rem;
  color: rgba(226,226,240,0.30);
  letter-spacing: 0.02em;
}

/* ─ RIGHT PANEL ─ */
.auth-right {
  flex: 0 0 50%;
  background: #0b0b10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 44px;
  overflow-y: auto;
}

.auth-card {
  width: 100%;
  max-width: 420px;
}

/* Logo */
.auth-logo-wrap {
  width: 118px;
  height: 118px;
  margin: 0 auto 18px;
}

.auth-logo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.auth-brand-name {
  text-align: center;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.auth-brand-sub {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 32px;
}

/* Auth heading */
.auth-heading {
  text-align: center;
  margin-bottom: 28px;
}

.auth-heading h2 {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.auth-heading .subtitle {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

/* Auth field labels */
#auth-screen .field-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}

/* Icon-prefixed input wrapper */
.field-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.field-icon-wrap .f-ico {
  position: absolute;
  left: 13px;
  width: 17px; height: 17px;
  fill: var(--text-muted);
  pointer-events: none;
  z-index: 1;
  flex-shrink: 0;
}

.field-icon-wrap input {
  padding-left: 40px !important;
}

/* Disable entrance animations inside auth panel */
#auth-screen .field,
#auth-screen .btn-primary,
#auth-screen .btn-register {
  animation: none !important;
  opacity: 1 !important;
}

#auth-screen .field input {
  background: #13131a !important;
  border: 1px solid #2a2a3a !important;
  border-radius: 10px;
  color: var(--text) !important;
}

#auth-screen .field input:focus {
  border-color: rgba(99,102,241,0.6) !important;
  background: #1a1a24 !important;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.10);
}

/* Fix Chrome autofill light background */
#auth-screen input:-webkit-autofill,
#auth-screen input:-webkit-autofill:hover,
#auth-screen input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0px 1000px #13131a inset !important;
  -webkit-text-fill-color: #e2e2f0 !important;
  caret-color: #e2e2f0;
  border: 1px solid #2a2a3a !important;
  transition: background-color 5000s ease-in-out 0s;
}

/* Auth primary button → white */
#auth-screen .btn-primary {
  background: #ffffff;
  color: #0b0b10;
  border: none;
  border-radius: 10px;
  padding: 15px;
  font-size: 1rem;
  font-weight: 700;
  width: 100%;
  cursor: pointer;
  transition: background 0.18s, transform 0.1s;
  margin-top: 10px;
  box-shadow: none;
  animation: none;
  opacity: 1;
  letter-spacing: 0.02em;
}
#auth-screen .btn-primary::after { display: none; }
#auth-screen .btn-primary:hover { background: #eaeaf8; transform: none; box-shadow: none; }
#auth-screen .btn-primary:active { transform: scale(0.98); }

/* "Crear cuenta" secondary button */
#auth-screen .btn-register {
  display: block;
  width: 100%;
  background: transparent;
  border: 1px solid rgba(99,102,241,0.35);
  border-radius: 10px;
  padding: 13px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #818cf8;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, color 0.18s;
  margin-top: 10px;
  text-decoration: none;
  text-align: center;
  letter-spacing: 0.01em;
  animation: none !important;
  opacity: 1 !important;
}
#auth-screen .btn-register:hover {
  border-color: rgba(99,102,241,0.65);
  background: rgba(99,102,241,0.08);
  color: #a5b4fc;
}

/* "¿No tenés cuenta?" small label above register button */
.auth-link-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  margin-top: 4px;
}

.auth-link-row span {
  display: none; /* texto movido al interior del botón */
}

.auth-footer-note {
  text-align: center;
  font-size: 0.72rem;
  color: rgba(123,123,154,0.45);
  margin-top: 24px;
}

/* ── AUTH HEADING TEXT (legacy) ──────────── */
.subtitle {
  color: var(--text-muted);
  font-size: .9rem;
  margin-bottom: 24px;
}

/* ── FIELDS ──────────────────────────────── */
.field {
  position: relative;
  margin-bottom: 14px;
  animation: fieldIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
  opacity: 0;
}

@keyframes fieldIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.field label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Auth-screen inputs — duplicated rule removed, handled above */
#auth-screen .field input:focus {
  border-color: rgba(99,102,241,0.65);
  box-shadow:
    inset 0 1px 3px rgba(0,0,0,0.3),
    0 0 0 3px rgba(99,102,241,0.12),
    0 0 16px rgba(99,102,241,0.08);
}

.field input,
.field textarea,
.field select {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 40px 10px 14px;
  font-size: .95rem;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.field select {
  padding-right: 14px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%237b7b9a'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.field select option { background: var(--bg2); color: var(--text); }

.field textarea {
  padding-right: 14px;
  resize: vertical;
  font-family: inherit;
}

.field input:focus,
.field textarea:focus { border-color: var(--accent); }
.field input::placeholder,
.field textarea::placeholder { color: var(--text-muted); }

.toggle-pw {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
}

.toggle-pw svg { width: 18px; height: 18px; fill: currentColor; }
.toggle-pw:hover { color: var(--text); }

/* field with generate button */
.field-with-btn {
  display: flex;
  gap: 6px;
  position: relative;
}

.field-with-btn input {
  flex: 1;
}

.btn-generate {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 12px;
  display: flex;
  align-items: center;
  transition: all .15s;
  flex-shrink: 0;
}
.btn-generate svg { width: 18px; height: 18px; fill: currentColor; }
.btn-generate:hover { border-color: var(--accent); color: var(--accent); }

.field-with-btn .toggle-pw {
  right: 52px;
  top: 50%;
}

/* ── BUTTONS ──────────────────────────────── */
.btn-primary {
  position: relative;
  overflow: hidden;
  width: 100%;
  background: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 13px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: transform .15s, box-shadow .2s;
  margin-top: 6px;
  box-shadow: 0 4px 20px rgba(99,102,241,0.35);
  animation: fieldIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
  opacity: 0;
}

/* shimmer sweep */
.btn-primary::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.22), transparent);
  transform: skewX(-20deg);
  transition: left 0.55s ease;
}
.btn-primary:hover::after { left: 160%; }
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 28px rgba(99,102,241,0.5);
}
.btn-primary:active { transform: scale(.97) translateY(0); }

.btn-register {
  width: 100%;
  background: rgba(99,102,241,0.06);
  color: var(--text-muted);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: var(--radius);
  padding: 11px;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
  margin-top: 10px;
  animation: fieldIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
  opacity: 0;
}
.btn-register:hover {
  border-color: rgba(99,102,241,0.5);
  color: var(--text);
  background: rgba(99,102,241,0.1);
}

/* OTP step */
#otp-form {
  animation: fieldIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.otp-info {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(99,102,241,.07);
  border: 1px solid rgba(99,102,241,.22);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
}
.otp-info p { color: var(--text-muted); font-size: .875rem; margin: 0; line-height: 1.5; }
.otp-info strong { color: var(--text); }

#otp-code {
  font-family: 'SF Mono', 'Fira Code', monospace !important;
  font-size: 1.8rem !important;
  letter-spacing: 12px !important;
  text-align: center !important;
  padding: 16px 14px !important;
  background: rgba(22,22,30,0.9) !important;
  border: 1px solid rgba(60,60,80,0.8) !important;
  border-radius: 10px !important;
}

/* ── AUTH RESPONSIVE ─────────────────────── */
@media (max-width: 900px) {
  .auth-left { display: none; }
  .auth-right { width: 100%; padding: 40px 32px; }
}

@media (max-width: 480px) {
  .auth-right { padding: 32px 20px; }
  .auth-logo-wrap { width: 60px; height: 60px; }
  .auth-heading h2 { font-size: 1.25rem; }
}

.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 20px;
  font-size: .95rem;
  cursor: pointer;
  transition: border-color .15s;
}
.btn-secondary:hover { border-color: var(--accent); }

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color .15s, background .15s;
}
.btn-icon svg { width: 20px; height: 20px; fill: currentColor; }
.btn-icon:hover { background: var(--bg3); color: var(--text); }

.btn-edit:hover { color: var(--accent) !important; }
.btn-delete:hover { color: var(--danger) !important; }

.error-msg {
  color: #fc8181;
  font-size: .85rem;
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.3);
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 8px;
}

/* ── LAYOUT ──────────────────────────────── */
#app-screen {
  display: flex;
}

/* ── SIDEBAR ─────────────────────────────── */
/* ── SIDEBAR ─────────────────────────────── */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px 14px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand svg { flex-shrink: 0; }
.brand-label {
  font-size: .75rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: .12em;
  text-transform: uppercase;
  border-left: 1px solid var(--border);
  padding-left: 10px;
}

.sidebar-user {
  padding: 10px 12px 6px;
}
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: .78rem;
  color: var(--text-muted);
  font-weight: 500;
  max-width: 100%;
  overflow: hidden;
}

.role-badge {
  background: rgba(99,102,241,.2);
  color: var(--accent);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  flex-shrink: 0;
}
.role-badge.role-user {
  background: rgba(16,185,129,.15);
  color: #10b981;
}

/* ── CATEGORY TREE ───────────────────────── */
.cat-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 10px 4px 14px;
}
.cat-section-title {
  font-size: .65rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: .1em;
  opacity: .6;
}
.btn-new-cat {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px 5px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color .12s, background .12s;
}
.btn-new-cat svg { width: 14px; height: 14px; fill: currentColor; }
.btn-new-cat:hover { background: var(--bg3); color: var(--accent); }

.new-cat-form {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
}
.new-cat-form input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--accent);
  border-radius: 7px;
  color: var(--text);
  font-size: .8rem;
  outline: none;
  padding: 5px 9px;
}
.new-cat-form button {
  background: var(--accent);
  border: none;
  border-radius: 7px;
  color: #fff;
  cursor: pointer;
  padding: 5px 7px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.new-cat-form button svg { width: 14px; height: 14px; fill: currentColor; }

.cat-tree {
  flex: 1;
  overflow-y: auto;
  padding: 2px 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.cat-tree::-webkit-scrollbar { width: 3px; }
.cat-tree::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.cat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .85rem;
  font-weight: 500;
  padding: 7px 8px;
  text-align: left;
  transition: background .12s, color .12s;
  white-space: nowrap;
  overflow: hidden;
}
.cat-item svg {
  width: 15px; height: 15px;
  fill: currentColor;
  flex-shrink: 0;
  opacity: .7;
}
.cat-item span:not(.cat-count) { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.cat-count {
  font-size: .7rem;
  background: var(--bg3);
  border-radius: 10px;
  padding: 1px 7px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.cat-item:hover { background: var(--bg3); color: var(--text); }
.cat-item.active {
  background: rgba(99,102,241,.14);
  color: #a5b4fc;
  font-weight: 600;
}
.cat-item.active svg { opacity: 1; }
.cat-item.active .cat-count { background: rgba(99,102,241,.2); color: #a5b4fc; }

.cat-del,
.cat-share {
  display: flex;
  align-items: center;
  padding: 1px 3px;
  border-radius: 4px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.cat-del svg,
.cat-share svg { width: 12px; height: 12px; fill: currentColor; }
/* Eliminar: oculto hasta hover */
.cat-del { display: none; }
.cat-item:hover .cat-del { display: flex; }
/* Compartir: siempre visible pero opaco, acento en hover */
.cat-share { opacity: 0.35; }
.cat-item:hover .cat-share { opacity: 1; }
.cat-del:hover { color: var(--danger) !important; }
.cat-share:hover { color: var(--accent) !important; }
/* Categoría compartida → color acento permanente */
.cat-share.shared {
  opacity: 1;
  color: var(--accent);
}

/* ── CATEGORY BADGE (detail/table) ──────── */
.category-badge {
  display: inline-block;
  background: rgba(99,102,241,.15);
  color: var(--accent);
  border: 1px solid rgba(99,102,241,.3);
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 700;
  padding: 2px 9px;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}

/* ── SIDEBAR FOOTER ─────────────────────── */
.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.footer-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .82rem;
  padding: 7px 9px;
  text-align: left;
  transition: background .12s, color .12s;
}
.footer-btn svg { width: 15px; height: 15px; fill: currentColor; flex-shrink: 0; }
.footer-btn:hover { background: var(--bg3); color: var(--text); }
.footer-btn-danger:hover { color: var(--danger); }

/* ── MAIN AREA ───────────────────────────── */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
  overflow: hidden;
}

.main-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  gap: 12px;
  flex-shrink: 0;
}
.toolbar-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.toolbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
  transition: border-color .15s;
}
.toolbar-search:focus-within { border-color: var(--accent); }
.toolbar-search svg { width: 15px; height: 15px; fill: var(--text-muted); flex-shrink: 0; }
.toolbar-search input {
  background: none;
  border: none;
  color: var(--text);
  font-size: .875rem;
  outline: none;
  width: 180px;
}
.toolbar-search input::placeholder { color: var(--text-muted); }
.btn-new-cred {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 8px 16px;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}
.btn-new-cred svg { width: 18px; height: 18px; fill: currentColor; }
.btn-new-cred:hover { background: var(--accent-hover); }

/* ── CREDENTIALS TABLE ───────────────────── */
.table-wrap {
  flex: 1;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.table-wrap::-webkit-scrollbar { width: 5px; height: 5px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.cred-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.cred-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}
.cred-table th {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  padding: 9px 14px;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
.th-notes { min-width: 120px; }
.th-actions { width: 80px; }

.cred-row {
  border-bottom: 1px solid rgba(42,42,56,.5);
  cursor: pointer;
  transition: background .1s;
}
.cred-row:hover { background: rgba(30,30,40,.7); }
.cred-row:hover .row-actions { opacity: 1; }
.cred-row.active { background: rgba(99,102,241,.07); }

.cred-row td {
  padding: 9px 14px;
  vertical-align: middle;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.td-name { display: flex; align-items: center; gap: 9px; min-width: 0; }
.td-name-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cred-avatar-sm {
  width: 28px; height: 28px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .78rem; color: #fff;
  flex-shrink: 0; text-transform: uppercase;
}
.cred-name-text { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.td-copyable {
  display: flex;
  align-items: center;
  gap: 4px;
}
.td-copyable span { overflow: hidden; text-overflow: ellipsis; }

.btn-inline-copy {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  opacity: 0;
  transition: opacity .12s, color .12s;
  flex-shrink: 0;
}
.btn-inline-copy svg { width: 13px; height: 13px; fill: currentColor; }
.cred-row:hover .btn-inline-copy { opacity: 1; }
.btn-inline-copy:hover { color: var(--accent); }

.pw-dots { color: var(--text-muted); letter-spacing: 2px; }

.td-url-link {
  color: var(--accent);
  text-decoration: none;
  font-size: .82rem;
}
.td-url-link:hover { text-decoration: underline; }

.td-muted { color: var(--text-muted); font-size: .82rem; }

.row-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity .12s;
}
.btn-row-action {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 5px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color .12s, background .12s;
}
.btn-row-action svg { width: 15px; height: 15px; fill: currentColor; }
.btn-row-action:hover { background: var(--bg3); color: var(--text); }
.btn-row-action.btn-del:hover { color: var(--danger); }

.empty-table-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 80px 40px;
  color: var(--text-muted);
  font-size: .9rem;
}

/* ── DETAIL PANEL (modal) ────────────────── */
.detail {
  padding: 28px 32px;
  max-width: 560px;
  width: 100%;
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
}

.detail-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.3rem;
  color: #fff;
  text-transform: uppercase;
  flex-shrink: 0;
}

.detail-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
}

.detail-url { font-size: .85rem; color: var(--text-muted); }

.detail-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.detail-body { display: flex; flex-direction: column; gap: 20px; }

.field-group label {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 6px;
}

.copy-field {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.copy-field span, .copy-field a {
  flex: 1;
  font-size: .95rem;
  word-break: break-all;
}

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

.password-dots {
  font-size: 1.2rem;
  letter-spacing: 2px;
  color: var(--text-muted);
}

.btn-copy {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: color .12s, background .12s;
}
.btn-copy svg { width: 17px; height: 17px; fill: currentColor; }
.btn-copy:hover { color: var(--text); background: var(--bg3); }

.notes-text {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: .9rem;
  line-height: 1.6;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
}

.meta {
  display: flex;
  gap: 24px;
  font-size: .78rem;
  color: var(--text-muted);
  padding-top: 4px;
}

/* ── MODAL ───────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 32px 80px rgba(0,0,0,.6);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }

#credential-form { padding: 20px 24px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 8px;
}

.modal-footer .btn-primary {
  width: auto;
  padding: 10px 24px;
  margin-top: 0;
}

.modal-wide { max-width: 560px; }

/* ── USER MANAGEMENT ─────────────────────── */
.users-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
  color: #fff;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.user-name {
  font-weight: 600;
  font-size: .9rem;
}

.user-creds {
  font-size: .78rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.user-date {
  font-size: .75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.add-user-section {
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.add-user-section h4 {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 14px;
}

.add-user-fields {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.add-user-fields .field { margin-bottom: 0; }

.add-user-fields select {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 14px;
  font-size: .95rem;
  outline: none;
  cursor: pointer;
  height: 100%;
}

/* ── SHARE TOGGLE ────────────────────────── */
.share-toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(99,102,241,.06);
  border: 1px solid rgba(99,102,241,.18);
  border-radius: var(--radius);
  margin-bottom: 14px;
  cursor: pointer;
  user-select: none;
}
.share-toggle-row input[type="checkbox"] { display: none; }
.share-toggle-track {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  position: relative;
  flex-shrink: 0;
  transition: background .2s, border-color .2s;
}
.share-toggle-track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform .2s, background .2s;
}
.share-toggle-row input:checked + .share-toggle-track {
  background: rgba(99,102,241,.35);
  border-color: var(--accent);
}
.share-toggle-row input:checked + .share-toggle-track::after {
  transform: translateX(16px);
  background: var(--accent);
}
.share-toggle-text { font-size: .88rem; color: var(--text); line-height: 1.35; }
.share-toggle-text small { display: block; color: var(--text-muted); font-size: .75rem; margin-top: 1px; }

/* Shared badge on credentials */
.shared-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(99,102,241,.12);
  color: #a5b4fc;
  border: 1px solid rgba(99,102,241,.25);
  border-radius: 8px;
  font-size: .65rem;
  font-weight: 700;
  padding: 1px 6px;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
.shared-badge svg { width: 9px; height: 9px; fill: currentColor; }

/* Readonly row (shared from admin, visible to users) */
.cred-row.shared-row { opacity: .9; }
.cred-row.shared-row:hover { background: rgba(99,102,241,.04); }

/* ── PERMISSION BADGES ───────────────────── */
.perm-badge {
  display: inline-block;
  border-radius: 10px;
  padding: 1px 8px;
  font-size: .67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
  flex-shrink: 0;
}
.perm-badge.perm-read {
  background: rgba(59,130,246,.15);
  color: #60a5fa;
}
.perm-badge.perm-write {
  background: rgba(245,158,11,.15);
  color: #fbbf24;
}
.perm-badge.perm-read_write {
  background: rgba(16,185,129,.15);
  color: #34d399;
}

/* Permission badge inside user chip (sidebar) */
.user-chip .perm-badge {
  font-size: .62rem;
  padding: 1px 6px;
}

/* ── PERMISSION SECTION (add user form) ───── */
.perm-section {
  margin-top: 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.perm-section-label {
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 10px;
}
.perm-checks {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.perm-check {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-size: .875rem;
  color: var(--text);
}
.perm-check input[type="checkbox"] { display: none; }
.perm-check-box {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 2px solid var(--border);
  background: var(--bg2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color .15s, background .15s;
}
.perm-check input:checked + .perm-check-box {
  background: var(--accent);
  border-color: var(--accent);
}
.perm-check input:checked + .perm-check-box::after {
  content: '';
  display: block;
  width: 10px;
  height: 6px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: translateY(-1px) rotate(-45deg);
}
.perm-check small { color: var(--text-muted); font-size: .75rem; }
.perm-check:hover .perm-check-box { border-color: var(--accent); }

/* ── TOAST ───────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: .9rem;
  font-weight: 500;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  animation: slideIn .2s ease;
}

.toast.success { border-color: var(--success); color: var(--success); }
.toast.error { border-color: var(--danger); color: #fc8181; }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── SESSION WARNING ─────────────────────── */
.session-warn {
  position: fixed;
  bottom: 24px;
  left: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #1c1208;
  border: 1px solid #f59e0b;
  color: #fbbf24;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: .875rem;
  font-weight: 500;
  z-index: 300;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  animation: slideIn .25s ease;
  max-width: 360px;
}
.session-warn svg { flex-shrink: 0; }
.session-warn-btn {
  background: #f59e0b;
  color: #000;
  border: none;
  border-radius: 6px;
  padding: 4px 12px;
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background .15s;
}
.session-warn-btn:hover { background: #fbbf24; }

/* ── HAMBURGER ───────────────────────────── */
.btn-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  flex-shrink: 0;
  transition: color .15s, background .15s;
}
.btn-hamburger svg { width: 22px; height: 22px; fill: currentColor; }
.btn-hamburger:hover { background: var(--bg3); color: var(--text); }

/* ── SIDEBAR OVERLAY (mobile) ────────────── */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 59;
  backdrop-filter: blur(3px);
}

/* ── RESPONSIVE ──────────────────────────── */

/* Tablet ≤ 920px: ocultar notas */
@media (max-width: 920px) {
  .cred-table .th-notes,
  .cred-table tbody td:nth-child(6) { display: none; }
}

/* Tablet/laptop chico ≤ 768px: sidebar colapsable */
@media (max-width: 768px) {
  .btn-hamburger { display: flex; }

  .sidebar {
    position: fixed;
    left: -270px;
    top: 0; bottom: 0;
    z-index: 60;
    width: 260px;
    transition: left .25s cubic-bezier(.4,0,.2,1);
    box-shadow: 4px 0 28px rgba(0,0,0,.55);
  }
  .sidebar.open { left: 0; }

  /* Ocultar URL y categoría en tabla */
  .cred-table th:nth-child(4),
  .cred-table tbody td:nth-child(4),
  .cred-table th:nth-child(5),
  .cred-table tbody td:nth-child(5) { display: none; }

  .main-toolbar { padding: 10px 14px; }
  .toolbar-search input { width: 130px; }
}

/* ── EMAIL SELECT STEP (login multi-email) ── */
.email-options-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.email-option-btn {
  width: 100%;
  background: #13131a;
  border: 1.5px solid #2a2a3a;
  border-radius: 10px;
  padding: 14px 16px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}

.email-option-btn:hover {
  border-color: rgba(99,102,241,0.5);
  background: #1a1a24;
}

.email-option-btn.selected {
  border-color: #6366f1;
  background: rgba(99,102,241,0.08);
}

.email-option-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.email-option-radio {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #3a3a50;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s;
}

.email-option-radio.checked {
  border-color: #6366f1;
  background: radial-gradient(circle, #6366f1 40%, transparent 50%);
}

.email-option-masked {
  font-size: 0.92rem;
  color: var(--text);
  font-weight: 500;
}

.email-option-label {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── PROFILE MODAL ───────────────────────── */
.profile-hint {
  font-size: 0.83rem;
  color: var(--text-muted);
  margin: 0 0 16px;
  line-height: 1.55;
}

.profile-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  margin-bottom: 8px;
  opacity: 0.7;
}

.profile-email-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 7px;
}

.profile-email-address {
  flex: 1;
  font-size: 0.88rem;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-primary-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(99,102,241,0.15);
  color: #818cf8;
  border: 1px solid rgba(99,102,241,0.28);
  border-radius: 6px;
  padding: 2px 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

.profile-email-label-tag {
  font-size: 0.74rem;
  color: var(--text-muted);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 7px;
  white-space: nowrap;
  flex-shrink: 0;
}

.profile-no-extras {
  font-size: 0.83rem;
  color: var(--text-muted);
  margin: 0 0 10px;
  font-style: italic;
}

.profile-del-btn {
  flex-shrink: 0;
  padding: 4px !important;
}

/* ── PROFILE: USER SECTION ───────────────── */
.profile-user-section {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 18px;
}
.profile-user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  flex-shrink: 0;
}
.profile-user-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}
.profile-user-role {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── SHARE CATEGORY MODAL ────────────────── */
.share-divider {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  margin: 14px 0 8px;
  letter-spacing: 0.04em;
}
.share-users-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 220px;
  overflow-y: auto;
}
.share-user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s;
  user-select: none;
}
.share-user-row:hover { background: var(--bg3); }
.share-user-row input[type="checkbox"] { display: none; }
.share-user-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}
.share-user-name {
  font-size: 0.88rem;
  color: var(--text);
  font-weight: 500;
}
.share-user-role-badge {
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: 99px;
  background: rgba(99,102,241,.18);
  color: #818cf8;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.share-user-role-badge.role-user {
  background: rgba(123,123,154,.15);
  color: var(--text-muted);
}

/* Mobile ≤ 540px */
@media (max-width: 540px) {
  /* Auth card mobile */
  .auth-right { padding: 24px 16px; }
  .auth-logo-wrap { width: 56px; height: 56px; }
  .auth-heading h2 { font-size: 1.25rem; }

  /* Toolbar */
  .toolbar-title { font-size: .9rem; }
  .toolbar-search input { width: 90px; }
  .btn-new-cred-text { display: none; }
  .btn-new-cred { padding: 8px 10px; }

  /* Table cells */
  .cred-row td  { padding: 8px 10px; }
  .cred-table th { padding: 7px 10px; }

  /* Modales: bottom sheet */
  .modal-overlay { align-items: flex-end; padding-bottom: 0; }
  .modal {
    max-width: 100%;
    width: 100%;
    border-radius: 18px 18px 0 0;
    max-height: 92vh;
  }
  .detail {
    max-width: 100%;
    padding: 20px 18px 28px;
    border-radius: 18px 18px 0 0;
  }
  .detail-header { gap: 12px; margin-bottom: 20px; }
  .detail-icon { width: 42px; height: 42px; font-size: 1.1rem; }
  .detail-header h2 { font-size: 1.15rem; }

  /* Session warn */
  .session-warn {
    left: 12px; right: 12px; bottom: 12px;
    max-width: none;
  }
}
