*, *::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 ────────────────────────────────── */
#bg-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.35;
  mix-blend-mode: screen;
}

#auth-screen {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(135deg, rgba(6,6,18,0.72) 0%, rgba(10,8,28,0.65) 100%),
    url('bg-login.png') center center / cover no-repeat;
}

.auth-card {
  --gx: 50%;
  --gy: 50%;
  position: relative;
  background: rgba(10, 10, 18, 0.72);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid rgba(99, 102, 241, 0.22);
  border-radius: 24px;
  padding: 48px 40px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow:
    0 0 0 1px rgba(99,102,241,0.08),
    0 8px 24px rgba(0,0,0,0.5),
    0 40px 80px rgba(0,0,0,0.45),
    inset 0 1px 0 rgba(255,255,255,0.06);
  animation: cardEntrance 0.9s cubic-bezier(0.16, 1, 0.3, 1) both;
  will-change: transform;
  transition: box-shadow 0.3s ease;
}

/* moving radial highlight following mouse */
.auth-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 24px;
  background: radial-gradient(
    280px circle at var(--gx) var(--gy),
    rgba(99,102,241,0.10) 0%,
    transparent 70%
  );
  pointer-events: none;
  transition: background 0.05s;
}

/* top glint */
.auth-card::after {
  content: '';
  position: absolute;
  top: 0; left: 10%; right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(99,102,241,0.55), transparent);
  border-radius: 50%;
}

@keyframes cardEntrance {
  from {
    opacity: 0;
    transform: perspective(1100px) translateY(56px) rotateX(14deg) scale(0.97);
  }
  to {
    opacity: 1;
    transform: perspective(1100px) translateY(0) rotateX(0deg) scale(1);
  }
}

/* ── AUTH LOGO ───────────────────────────── */
.logo-wrapper {
  position: relative;
  width: 144px;
  height: 52px;
  margin: 0 auto 32px;
}

.logo-icon {
  position: relative;
  z-index: 2;
  width: 144px;
  height: 52px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 60%, #a855f7 100%);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 0 0 1px rgba(99,102,241,0.4),
    0 8px 32px rgba(99,102,241,0.4),
    0 0 60px rgba(99,102,241,0.15);
  animation: iconFloat 4s ease-in-out infinite;
}

.logo-icon svg { filter: drop-shadow(0 2px 8px rgba(0,0,0,0.5)); }

@keyframes iconFloat {
  0%,100% { transform: translateY(0) rotate(0deg); }
  33%      { transform: translateY(-5px) rotate(1deg); }
  66%      { transform: translateY(-3px) rotate(-1deg); }
}

.pulse-ring {
  position: absolute;
  inset: -8px;
  border-radius: 22px;
  border: 1.5px solid rgba(99, 102, 241, 0.55);
  animation: pulseRing 2.4s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
.pulse-ring:nth-child(2) {
  inset: -18px;
  border-radius: 30px;
  border-color: rgba(139, 92, 246, 0.35);
  animation-delay: 0.6s;
}
.pulse-ring:nth-child(3) {
  inset: -30px;
  border-radius: 40px;
  border-color: rgba(168, 85, 247, 0.18);
  animation-delay: 1.2s;
}

@keyframes pulseRing {
  0%   { opacity: 1; transform: scale(0.92); }
  100% { opacity: 0; transform: scale(1.35); }
}

/* ── AUTH HEADER TEXT ────────────────────── */
.auth-heading {
  text-align: center;
  margin-bottom: 32px;
}

.auth-heading h2 {
  font-size: 1.6rem;
  font-weight: 800;
  background: linear-gradient(135deg, #e2e2f0 30%, #a5b4fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.auth-heading .subtitle {
  color: var(--text-muted);
  font-size: .875rem;
  margin-bottom: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 28px;
}
.logo.small { font-size: .95rem; }
.logo svg { flex-shrink: 0; }

.auth-card h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.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 get extra glow treatment */
#auth-screen .field input {
  background: rgba(30, 30, 42, 0.8);
  border: 1px solid rgba(99,102,241,0.18);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
}

#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.1rem !important;
  letter-spacing: 6px !important;
  text-align: center !important;
  padding: 14px !important;
  background: rgba(30,30,42,0.8) !important;
  border: 1px solid rgba(99,102,241,0.25) !important;
}

.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 {
  display: none;
  align-items: center;
  padding: 1px 3px;
  border-radius: 4px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.cat-del svg { width: 12px; height: 12px; fill: currentColor; }
.cat-item:hover .cat-del { display: flex; }
.cat-del:hover { color: var(--danger) !important; }

/* ── 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; max-width: 180px; }
.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; }

.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; }
}

/* Mobile ≤ 540px */
@media (max-width: 540px) {
  /* Auth card */
  #auth-screen { padding: 16px; align-items: flex-start; padding-top: 10vh; }
  .auth-card {
    padding: 32px 20px 28px;
    border-radius: 18px;
  }
  .logo-wrapper { width: 120px; height: 44px; margin-bottom: 20px; }
  .logo-icon    { width: 120px; height: 44px; border-radius: 11px; }
  .pulse-ring:nth-child(1) { inset: -6px;  border-radius: 18px; }
  .pulse-ring:nth-child(2) { inset: -14px; border-radius: 24px; }
  .pulse-ring:nth-child(3) { inset: -24px; border-radius: 32px; }
  .auth-heading h2 { font-size: 1.35rem; }

  /* 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;
  }
}
