:root {
  --sidebar-w: 220px;
  --sidebar-bg: #1f2937;
  --sidebar-text: #d1d5db;
  --accent: #2563eb;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --hover-bg: #f3f4f6;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f9fafb;
  color: var(--text);
}

/* ── Auth pages ─────────────────────────────────────────────────────────────── */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1f2937 0%, #1d4ed8 100%);
  padding: 1rem;
}

.auth-card {
  background: white;
  border-radius: 14px;
  padding: 2rem 2.25rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}

.auth-logo {
  text-align: center;
  font-size: 2.5rem;
  margin-bottom: 0.25rem;
}

.auth-card h2 {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1.5rem;
}

/* ── Vault layout ───────────────────────────────────────────────────────────── */

.vault-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.vault-sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  user-select: none;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1.1rem 1rem;
  color: white;
  font-weight: 700;
  font-size: 1.05rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-nav {
  flex: 1;
  padding: 0.5rem 0;
  overflow-y: auto;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.6rem 1rem;
  background: transparent;
  border: none;
  border-left: 3px solid transparent;
  color: var(--sidebar-text);
  cursor: pointer;
  text-align: left;
  font-size: 0.875rem;
  transition: background 0.12s, color 0.12s;
}

.sidebar-item:hover { background: rgba(255,255,255,0.07); color: white; }
.sidebar-item.active { background: rgba(37,99,235,0.3); color: white; border-left-color: var(--accent); }
.sidebar-item i { font-size: 1rem; width: 1.1rem; text-align: center; }

.sidebar-divider { height: 1px; background: rgba(255,255,255,0.08); margin: 0.4rem 0.75rem; }

.sidebar-section { padding: 0.15rem 0; }

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0 1rem 0.35rem;
}

.sidebar-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: rgba(209, 213, 219, 0.72);
}

.sidebar-section-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: rgba(209, 213, 219, 0.82);
}

.sidebar-section-btn:hover {
  background: rgba(255,255,255,0.08);
  color: white;
}

.folder-nav {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.sidebar-folder-item {
  padding-left: 1.35rem;
  font-size: 0.82rem;
}

.sidebar-folder-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-folder-empty {
  padding: 0.2rem 1rem 0.45rem 1.35rem;
  font-size: 0.8rem;
  color: rgba(209, 213, 219, 0.66);
}

.sidebar-footer { padding: 0.75rem 1rem; border-top: 1px solid rgba(255,255,255,0.08); }

/* Main content */
.vault-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.vault-topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  background: white;
  border-bottom: 1px solid var(--border);
}

.search-input { flex: 1; border-radius: 8px; }

/* Cipher list */
.cipher-list { flex: 1; overflow-y: auto; padding: 0.75rem; }

.cipher-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  background: white;
  border-radius: 10px;
  margin-bottom: 0.4rem;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: box-shadow 0.15s, border-color 0.15s;
}

.cipher-item:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.07); border-color: #d1d5db; }

.cipher-icon-wrap {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: #eff6ff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
  color: var(--accent);
}

.cipher-icon-wrap.green  { background: #f0fdf4; color: #16a34a; }
.cipher-icon-wrap.amber  { background: #fffbeb; color: #d97706; }
.cipher-icon-wrap.purple { background: #faf5ff; color: #7c3aed; }

.cipher-info { flex: 1; min-width: 0; }
.cipher-name { font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cipher-subtitle { font-size: 0.8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cipher-actions { display: flex; gap: 0.3rem; flex-shrink: 0; }
.cipher-actions .btn { opacity: 0.5; transition: opacity 0.12s; }
.cipher-item:hover .cipher-actions .btn { opacity: 1; }

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5rem 2rem;
  text-align: center;
  color: var(--muted);
}
.empty-state i { font-size: 3rem; margin-bottom: 1rem; opacity: 0.35; }

/* Detail modal */
.detail-field { margin-bottom: 1rem; }
.detail-field .label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.detail-value-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--hover-bg);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
}

.detail-value {
  flex: 1;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-size: 0.88rem;
  word-break: break-all;
  color: var(--text);
  min-width: 0;
}

/* TOTP */
.totp-row { gap: 0.75rem; flex-wrap: nowrap; }
.totp-display { display: flex; align-items: baseline; gap: 0.35rem; flex-shrink: 0; }
.totp-code { font-size: 1.75rem; font-weight: 700; letter-spacing: 0.12em; font-family: 'SFMono-Regular', Consolas, monospace; color: var(--accent); }
.totp-remaining { font-size: 0.75rem; color: var(--muted); }
.totp-progress-wrap { flex: 1; height: 4px; background: #e5e7eb; border-radius: 2px; overflow: hidden; }
.totp-bar { height: 100%; background: var(--accent); transition: width 1s linear, background 0.3s; }

/* Custom field rows in edit modal */
.field-row .field-type { width: 72px; flex-shrink: 0; }
.field-row .field-name { flex: 0 0 140px; }
.field-row .field-value { flex: 1; }

/* Badge in cipher list for TOTP indicator */
.totp-badge { font-size: 0.7rem; cursor: default; align-self: center; }

.folder-manager-empty {
  padding: 1rem;
  text-align: center;
  color: var(--muted);
}

/* Sync button spin animation */
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.spin-anim { animation: spin 0.8s linear infinite; }
