/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0d0d17;
  --surface:     #16162a;
  --surface2:    #1e1e38;
  --border:      #2a2a4a;
  --accent:      #6d6afe;
  --accent-dim:  #4a4bc8;
  --danger:      #ef4444;
  --success:     #22c55e;
  --warn:        #f59e0b;
  --text:        #e2e4f0;
  --text-muted:  #7878a8;
  --radius:      10px;
  --radius-lg:   16px;
  --shadow:      0 4px 24px rgba(0,0,0,.5);
}

html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

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

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
  transition: opacity .15s, background .15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dim); text-decoration: none; color: #fff; }

.btn-ghost    { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--border); text-decoration: none; }

.btn-danger   { color: var(--danger) !important; }
.btn-danger:hover { background: rgba(239,68,68,.15) !important; }

.btn-full  { width: 100%; justify-content: center; padding: 11px 16px; }
.btn-sm    { padding: 5px 11px; font-size: .8125rem; }
.btn-xs    { padding: 4px 9px; font-size: .75rem; }
.btn-icon  { padding: 7px; background: transparent; border: none; color: var(--text-muted); }
.btn-icon:hover { color: var(--text); background: var(--surface2); }
.btn svg   { width: 16px; height: 16px; flex-shrink: 0; }

.inline-form { display: inline; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.form-group label { font-size: .8125rem; font-weight: 500; color: var(--text-muted); letter-spacing: .02em; }
.form-group .required { color: var(--danger); }

input[type="text"],
input[type="password"],
input[type="url"],
input[type="search"],
input[type="number"],
textarea,
select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 13px;
  font-size: .9375rem;
  width: 100%;
  transition: border-color .15s;
  outline: none;
  font-family: inherit;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(109,106,254,.2);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
textarea { resize: vertical; min-height: 100px; }

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}

/* ── Auth pages (setup / unlock) ─────────────────────────────────────────── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
  text-align: center;
}

.auth-icon {
  width: 56px;
  height: 56px;
  background: rgba(109,106,254,.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  color: var(--accent);
}
.auth-icon svg { width: 28px; height: 28px; }

.auth-card h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 8px; }
.auth-subtitle { color: var(--text-muted); font-size: .875rem; margin-bottom: 28px; }

.pin-input-wrap input {
  font-size: 1.5rem;
  letter-spacing: .5em;
  text-align: center;
}

.auth-security-note {
  margin-top: 24px;
  font-size: .75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.auth-security-note svg { width: 13px; height: 13px; flex-shrink: 0; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
  border-radius: var(--radius);
  padding: 11px 14px;
  font-size: .875rem;
  margin-bottom: 18px;
  text-align: left;
}
.alert-error   { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.35); color: #fca5a5; }
.alert-success { background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.35); color: #86efac; }

/* ── Header ──────────────────────────────────────────────────────────────── */
.vault-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(13,13,23,.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.vault-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.vault-logo {
  font-weight: 700;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
}
.vault-logo svg { width: 22px; height: 22px; color: var(--accent); }
.vault-logo:hover { text-decoration: none; }

.vault-header-actions { display: flex; align-items: center; gap: 8px; }

.lock-timer {
  font-size: .75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.lock-timer.warn { color: var(--warn); font-weight: 600; }

/* ── Vault main ──────────────────────────────────────────────────────────── */
.vault-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

/* ── Search ──────────────────────────────────────────────────────────────── */
.search-bar-wrap { margin-bottom: 20px; }
.search-bar {
  position: relative;
  max-width: 480px;
}
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}
.search-bar input {
  padding-left: 38px;
}

.entry-count {
  font-size: .8125rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ── Entries grid ────────────────────────────────────────────────────────── */
.entries-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.entry-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color .15s;
}
.entry-card:hover { border-color: rgba(109,106,254,.4); }

.entry-card-header { display: flex; align-items: center; gap: 12px; }

.entry-favicon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: var(--surface2);
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.entry-favicon img { width: 24px; height: 24px; object-fit: contain; }
.entry-favicon-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent);
  background: rgba(109,106,254,.15);
}

.entry-card-title-wrap { min-width: 0; }
.entry-title {
  font-size: .9375rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.entry-username {
  font-size: .8rem;
  color: var(--text-muted);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-url {
  font-size: .8rem;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 4px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.entry-url svg { width: 12px; height: 12px; flex-shrink: 0; }

.entry-card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* ── Empty / no-results ──────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.empty-state svg { width: 52px; height: 52px; opacity: .25; }

.no-results {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: .9rem;
}

/* ── Form page ───────────────────────────────────────────────────────────── */
.form-page {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
}
.form-title { font-size: 1.35rem; font-weight: 700; margin-bottom: 24px; }

/* ── Password field ──────────────────────────────────────────────────────── */
.password-field {
  display: flex;
  align-items: center;
  gap: 4px;
}
.password-field input { flex: 1; }

/* ── Password generator ──────────────────────────────────────────────────── */
.generator-bar { margin-top: 6px; }
.generator-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  padding: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.generator-options label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .8125rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.generator-options input[type="range"] {
  width: 80px;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}
.checkbox-label input[type="checkbox"] {
  width: auto;
  margin: 0;
}

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: .875rem;
  box-shadow: var(--shadow);
  z-index: 100;
  white-space: nowrap;
}
.toast.success { border-color: var(--success); color: #86efac; }
.toast.error   { border-color: var(--danger);  color: #fca5a5; }

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utilities ───────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .auth-card { padding: 28px 20px; }
  .form-card  { padding: 22px 16px; }
  .entries-grid { grid-template-columns: 1fr; }
  .vault-header-inner { padding: 0 14px; }
  .entry-card-actions { flex-direction: row; }
}
