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

:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --surface2:  #222536;
  --border:    #2e3150;
  --accent:    #0096c7;
  --accent-h:  #0077a3;
  --accent-d:  rgba(0,150,199,.14);
  --text:      #e2e4f0;
  --text-muted:#8b8fa8;
  --danger:    #e05c6b;
  --success:   #3ecf8e;
  --warn:      #f5a623;
  --radius:    10px;
  --shadow:    0 4px 24px rgba(0,0,0,.4);
}

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

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

/* ── AUTH ───────────────────────────────────── */
#auth-screen {
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, rgba(0,150,199,.18) 0%, transparent 65%), var(--bg);
}
.auth-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 36px; width: 380px; box-shadow: var(--shadow);
}
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; color: var(--accent); }
.auth-logo h1 { font-size: 22px; font-weight: 700; color: var(--text); }
.auth-tabs { display: flex; gap: 4px; background: var(--bg); border-radius: var(--radius); padding: 4px; margin-bottom: 24px; }
.tab-btn { flex: 1; padding: 8px; border: none; border-radius: 7px; cursor: pointer; font-size: 13px; font-weight: 500; background: transparent; color: var(--text-muted); transition: all .15s; }
.tab-btn.active { background: var(--surface2); color: var(--text); }

/* ── FORM FIELDS ───────────────────────────── */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; letter-spacing: .04em; text-transform: uppercase; }
.hint { font-weight: 400; text-transform: none; letter-spacing: 0; }
.required { color: var(--accent); }
input[type=text], input[type=email], input[type=password], input[type=url], textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 12px; color: var(--text); font-size: 14px; outline: none; transition: border-color .15s;
  font-family: inherit;
}
input:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }
.input-row { display: flex; gap: 6px; align-items: center; }
.input-row input { flex: 1; }

/* ── BUTTONS ───────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 9px 18px; font-size: 14px; font-weight: 600; cursor: pointer; transition: background .15s;
}
.btn-primary:hover { background: var(--accent-h); }
.btn-primary:disabled { opacity: .5; cursor: default; }
#login-form .btn-primary, #register-form .btn-primary { width: 100%; justify-content: center; margin-top: 6px; }
.btn-secondary {
  background: var(--surface2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 18px; font-size: 14px; font-weight: 500; cursor: pointer; transition: background .15s;
}
.btn-secondary:hover { background: var(--border); }
.icon-btn { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 4px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; transition: color .15s, background .15s; }
.icon-btn:hover { color: var(--text); background: var(--surface2); }
.text-btn { font-size: 12px; font-weight: 500; padding: 4px 10px; }
.text-btn.danger { color: var(--danger); }
.text-btn.danger:hover { background: rgba(224,92,107,.12); }

/* ── ERRORS / TOAST ────────────────────────── */
.error-msg { font-size: 13px; color: var(--danger); margin-top: 8px; padding: 8px 12px; background: rgba(224,92,107,.1); border-radius: 7px; }
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 999;
  background: var(--surface2); color: var(--text); border: 1px solid var(--border);
  padding: 12px 18px; border-radius: 10px; box-shadow: var(--shadow);
  font-size: 13px; font-weight: 500; animation: slide-up .2s ease;
}
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error   { border-color: var(--danger);  color: var(--danger); }
@keyframes slide-up { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── APP LAYOUT ─────────────────────────────── */
#app-screen { display: flex; height: 100vh; overflow: hidden; }

/* sidebar */
.sidebar {
  width: 220px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}
.sidebar-header { display: flex; align-items: center; gap: 10px; padding: 20px 16px 16px; color: var(--accent); font-weight: 700; font-size: 15px; border-bottom: 1px solid var(--border); }
.sidebar-header span { color: var(--text); }
.sidebar-body    { flex: 1; overflow-y: auto; }
.sidebar-section { padding: 12px 8px; }
.section-label { display: flex; justify-content: space-between; align-items: center; padding: 4px 8px 8px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
#vault-list { list-style: none; }
#vault-list li {
  padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: 13px; font-weight: 500;
  color: var(--text-muted); display: flex; align-items: center; gap: 8px; transition: background .12s, color .12s;
}
#vault-list li:hover { background: var(--surface2); color: var(--text); }
#vault-list li.active { background: var(--accent-d); color: var(--accent); }
#vault-list li .vault-count { margin-left: auto; font-size: 11px; background: var(--surface2); padding: 1px 6px; border-radius: 20px; }
li.active .vault-count { background: var(--accent-d); }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 4px; }
.profile-btn { flex: 1; justify-content: flex-start; gap: 8px; font-size: 12px; padding: 8px; overflow: hidden; }
.logout-icon-btn { flex-shrink: 0; padding: 8px; }
#user-email-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* avatar */
.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
}
.avatar-lg { width: 48px; height: 48px; font-size: 18px; }

/* profile modal */
.profile-avatar-row { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.profile-email  { font-weight: 600; font-size: 15px; }
.profile-joined { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.profile-section { margin-bottom: 4px; }
.profile-section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-bottom: 14px; }
.profile-divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* main content */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.main-header {
  display: flex; align-items: center; gap: 12px; padding: 16px 24px;
  border-bottom: 1px solid var(--border); background: var(--surface);
}
.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* dropdown */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 9px;
  padding: 4px; min-width: 160px; box-shadow: var(--shadow);
}
.dropdown-item {
  display: block; width: 100%; padding: 8px 12px; text-align: left;
  background: none; border: none; color: var(--text); font-size: 13px;
  border-radius: 6px; cursor: pointer;
}
.dropdown-item:hover { background: var(--border); }

/* import modal extras */
.import-info { font-size: 13px; color: var(--text-muted); margin-bottom: 18px; line-height: 1.7; }
.import-info strong { color: var(--text); }
.import-format-list { list-style: none; margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.import-format-list li { display: flex; align-items: baseline; gap: 6px; padding-left: 4px; }
.import-format-list li::before { content: '·'; color: var(--accent); font-size: 16px; line-height: 1; flex-shrink: 0; }
.import-info code { font-size: 12px; background: var(--bg); padding: 2px 6px; border-radius: 4px; }
.text-muted { color: var(--text-muted); }
.file-drop-zone {
  border: 2px dashed var(--border); border-radius: 9px; padding: 28px;
  text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
  position: relative; color: var(--text-muted); font-size: 13px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.file-drop-zone:hover, .file-drop-zone.dragover { border-color: var(--accent); background: var(--accent-d); color: var(--text); }
.file-drop-zone u { color: var(--accent); cursor: pointer; }
.file-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.file-name { font-size: 12px; color: var(--success); margin-top: 6px; }
select {
  width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 12px; color: var(--text); font-size: 14px; outline: none; cursor: pointer;
}
.search-wrap { flex: 1; display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 7px 12px; color: var(--text-muted); }
.search-wrap input { border: none; background: none; outline: none; color: var(--text); font-size: 14px; flex: 1; }
.vault-title-row { display: flex; align-items: center; gap: 8px; padding: 16px 24px 10px; }
.vault-title-row h2 { font-size: 16px; font-weight: 700; }

/* admin sidebar */
.admin-nav-list { list-style: none; }
.admin-nav-item {
  padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: 13px; font-weight: 500;
  color: var(--text-muted); display: flex; align-items: center; gap: 8px; transition: background .12s, color .12s;
}
.admin-nav-item:hover { background: var(--surface2); color: var(--text); }
.admin-nav-item.active { background: var(--accent-d); color: var(--accent); }

/* admin main view */
#admin-view { flex: 1; overflow-y: auto; padding: 0 24px 24px; display: flex; flex-direction: column; }
.admin-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 0 16px; }
.admin-header h2 { font-size: 16px; font-weight: 700; }
.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th {
  text-align: left; padding: 10px 12px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.admin-table td { padding: 12px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--surface2); }
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell .avatar { flex-shrink: 0; }
.user-email { font-weight: 500; }
.user-id { font-size: 11px; color: var(--text-muted); margin-top: 1px; font-family: monospace; }
.role-badge {
  display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
}
.role-badge.admin { background: rgba(108,99,255,.18); color: var(--accent); }
.role-badge.user  { background: var(--surface2); color: var(--text-muted); }
.you-badge { font-size: 10px; color: var(--text-muted); margin-left: 4px; }
.admin-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* reset pw modal label */
.reset-pw-label { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }
.reset-pw-label strong { color: var(--text); }

/* entries */
.entries-list { flex: 1; overflow-y: auto; padding: 0 24px 24px; }
.empty-state { text-align: center; color: var(--text-muted); padding: 60px 0; font-size: 14px; }

.entry-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 8px; cursor: pointer;
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  transition: border-color .15s, background .15s;
}
.entry-card:hover { border-color: var(--accent); background: var(--surface2); }
.entry-icon {
  width: 38px; height: 38px; border-radius: 9px; background: var(--accent-d);
  display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700; color: var(--accent);
  flex-shrink: 0;
}
.entry-info { overflow: hidden; }
.entry-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-sub   { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-actions { display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.entry-card:hover .entry-actions { opacity: 1; }

/* ── MODAL ──────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  width: 480px; max-width: 95vw; max-height: 90vh; overflow-y: auto;
  padding: 24px; box-shadow: var(--shadow);
}
.modal-sm { width: 340px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* password strength */
.strength-bar { height: 4px; background: var(--border); border-radius: 4px; margin-top: 8px; overflow: hidden; }
.strength-fill { height: 100%; width: 0; border-radius: 4px; transition: width .3s, background .3s; }
.strength-label { font-size: 11px; margin-top: 4px; display: block; color: var(--text-muted); }

/* scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
