/* ── Reset & Base ─────────────────────────────────────────────────────────── */
:root {
  --bg:        #0f0f1a;
  --bg2:       #1a1a2e;
  --bg3:       #252540;
  --border:    #2e2e4a;
  --accent:    #6c63ff;
  --accent2:   #4CAF50;
  --danger:    #e53935;
  --text:      #e8e8f0;
  --text2:     #9090b0;
  --radius:    14px;
  --nav-h:     64px;
  --top-h:     52px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

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

/* ── Top bar ──────────────────────────────────────────────────────────────── */
.top-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--top-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
}
.top-bar-title { font-weight: 600; font-size: 16px; }
.top-bar-logout { color: var(--text2); font-size: 20px; text-decoration: none; padding: 8px; }
.top-bar-logout:hover { color: var(--danger); }

/* ── Main content ────────────────────────────────────────────────────────── */
.main-content {
  padding: 12px 12px 24px;
}
.main-content.with-nav {
  padding-top: calc(var(--top-h) + 12px);
  padding-bottom: calc(var(--nav-h) + 16px);
}

/* ── Bottom nav ──────────────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--bg2);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text2);
  text-decoration: none;
  font-size: 11px;
  gap: 3px;
  transition: color .15s;
}
.nav-item i { font-size: 22px; }
.nav-item.active { color: var(--accent); }
.nav-item:hover  { color: var(--text); }

/* ── Flash messages ──────────────────────────────────────────────────────── */
.flash-container {
  position: fixed;
  top: calc(var(--top-h) + 8px);
  left: 12px; right: 12px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  animation: slideDown .2s ease;
}
.flash-success { background: #1b3a1b; color: #81c784; border: 1px solid #2e7d32; }
.flash-info    { background: #1a2a3a; color: #64b5f6; border: 1px solid #1565c0; }
.flash-error   { background: #3a1a1a; color: #e57373; border: 1px solid #c62828; }
@keyframes slideDown { from { transform: translateY(-10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── Login ───────────────────────────────────────────────────────────────── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-wrapper { width: 100%; max-width: 380px; padding: 20px; }
.login-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 28px;
  text-align: center;
}
.login-icon { font-size: 52px; color: var(--accent); margin-bottom: 12px; }
.login-title { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.login-subtitle { color: var(--text2); font-size: 14px; margin-bottom: 24px; }
.alert-error {
  background: #3a1a1a;
  color: #e57373;
  border: 1px solid #c62828;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 16px;
  text-align: left;
}
.btn-login {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 16px;
  transition: opacity .15s;
}
.btn-login:hover { opacity: .9; }

/* ── Input ───────────────────────────────────────────────────────────────── */
.input-group-custom {
  display: flex;
  align-items: center;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color .15s;
}
.input-group-custom:focus-within { border-color: var(--accent); }
.input-icon { padding: 0 10px 0 14px; color: var(--text2); font-size: 17px; flex-shrink: 0; }
.input-field {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 15px;
  padding: 13px 4px;
  outline: none;
}
.input-field::placeholder { color: var(--text2); }
.toggle-pwd {
  background: none;
  border: none;
  color: var(--text2);
  padding: 0 14px;
  cursor: pointer;
  font-size: 17px;
}
.toggle-pwd:hover { color: var(--text); }

/* ── Search ──────────────────────────────────────────────────────────────── */
.search-bar { padding: 0 0 10px; position: sticky; top: var(--top-h); background: var(--bg); z-index: 50; padding-top: 8px; }
.search-input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 12px;
}
.search-icon { color: var(--text2); font-size: 16px; margin-right: 8px; }
.search-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 15px;
  padding: 12px 0;
  outline: none;
}
.search-clear { color: var(--text2); font-size: 17px; padding: 4px; text-decoration: none; }

/* ── Password cards ──────────────────────────────────────────────────────── */
.list-container { display: flex; flex-direction: column; gap: 8px; }
.pwd-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.pwd-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
}
.pwd-card-header:hover { background: var(--bg3); }
.pwd-site { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.site-avatar {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--accent), #9c27b0);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; flex-shrink: 0;
}
.addr-avatar { background: linear-gradient(135deg, #4CAF50, #00796b); }
.card-avatar { background: linear-gradient(135deg, #FF9800, #e65100); }
.site-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.site-user { color: var(--text2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chevron-icon { color: var(--text2); font-size: 16px; transition: transform .2s; flex-shrink: 0; }
.pwd-card.open .chevron-icon { transform: rotate(180deg); }

.pwd-card-body {
  display: none;
  padding: 0 16px 14px;
  border-top: 1px solid var(--border);
}
.pwd-card.open .pwd-card-body { display: block; }

.pwd-field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.pwd-field-row:last-of-type { border-bottom: none; }
.pwd-label { color: var(--text2); font-size: 12px; white-space: nowrap; min-width: 70px; }
.pwd-value-wrap { display: flex; align-items: center; gap: 6px; flex: 1; justify-content: flex-end; min-width: 0; }
.pwd-value { font-size: 14px; word-break: break-all; text-align: right; }
.pwd-value.masked { letter-spacing: 3px; color: var(--text2); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-icon {
  background: none; border: none; color: var(--text2);
  font-size: 18px; cursor: pointer; padding: 4px; flex-shrink: 0;
}
.btn-icon:hover { color: var(--text); }
.btn-icon-sm {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text2); border-radius: 8px;
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; cursor: pointer; flex-shrink: 0;
  transition: all .15s;
}
.btn-icon-sm:hover { color: var(--accent); border-color: var(--accent); }
.btn-icon-sm.copied { color: var(--accent2) !important; border-color: var(--accent2) !important; }

.pwd-actions { display: flex; gap: 8px; padding-top: 12px; }
.btn-action {
  flex: 1; padding: 9px; border-radius: 10px;
  font-size: 13px; font-weight: 600;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  text-decoration: none; transition: opacity .15s;
}
.btn-action:hover { opacity: .85; }
.btn-edit   { background: rgba(108,99,255,.15); color: var(--accent); border: 1px solid rgba(108,99,255,.3); }
.btn-delete { background: rgba(229,57,53,.12);  color: var(--danger);  border: 1px solid rgba(229,57,53,.3); }

/* ── FAB ─────────────────────────────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  right: 18px;
  width: 52px; height: 52px;
  background: var(--accent);
  border: none; border-radius: 16px;
  color: #fff; font-size: 24px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; text-decoration: none;
  box-shadow: 0 4px 16px rgba(108,99,255,.5);
  transition: transform .15s;
  z-index: 90;
}
.fab:hover { transform: scale(1.05); color: #fff; }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 60px 20px; text-align: center; color: var(--text2);
}
.empty-icon { font-size: 52px; margin-bottom: 16px; opacity: .4; }
.btn-primary-outline {
  margin-top: 16px; padding: 10px 24px;
  border: 1px solid var(--accent); color: var(--accent);
  border-radius: 12px; text-decoration: none; font-weight: 600;
  transition: all .15s;
}
.btn-primary-outline:hover { background: rgba(108,99,255,.1); color: var(--accent); }

/* ── Form page ───────────────────────────────────────────────────────────── */
.form-page { max-width: 520px; margin: 0 auto; padding: 8px 0; }
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 7px; font-weight: 500; }
.input-field-plain {
  width: 100%; background: var(--bg3);
  border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); font-size: 15px;
  padding: 13px 14px; outline: none;
  transition: border-color .15s;
}
.input-field-plain:focus { border-color: var(--accent); }
.input-field-plain::placeholder { color: var(--text2); }

.input-row { display: flex; gap: 8px; margin-bottom: 10px; }
.input-row .input-field-plain { flex: 1; }
.w-sm { flex: 0 0 auto; width: 64px; }

.btn-submit {
  width: 100%; background: var(--accent); color: #fff;
  border: none; border-radius: 12px;
  padding: 14px; font-size: 16px; font-weight: 600;
  cursor: pointer; transition: opacity .15s;
  display: flex; align-items: center; justify-content: center;
}
.btn-submit:hover { opacity: .9; }
.btn-submit-secondary {
  width: 100%; background: transparent;
  color: var(--accent2); border: 1px solid var(--accent2);
  border-radius: 12px; padding: 12px;
  font-size: 15px; font-weight: 600;
  cursor: pointer; transition: all .15s;
  display: flex; align-items: center; justify-content: center;
}
.btn-submit-secondary:hover { background: rgba(76,175,80,.1); }
.btn-cancel {
  display: block; text-align: center;
  color: var(--text2); text-decoration: none;
  padding: 12px; font-size: 15px;
}
.form-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }

/* ── Quick gen ───────────────────────────────────────────────────────────── */
.quick-gen { display: flex; gap: 8px; margin-top: 10px; }
.btn-gen {
  flex: 1; background: rgba(108,99,255,.15);
  color: var(--accent); border: 1px solid rgba(108,99,255,.3);
  border-radius: 10px; padding: 10px; font-size: 14px;
  font-weight: 600; cursor: pointer; transition: all .15s;
  display: flex; align-items: center; justify-content: center;
}
.btn-gen:hover { background: rgba(108,99,255,.25); }
.gen-length-select {
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 10px; font-size: 14px; cursor: pointer;
}

/* ── Generator page ──────────────────────────────────────────────────────── */
.gen-output-card {
  background: var(--bg2); border: 1px solid var(--accent);
  border-radius: var(--radius); padding: 20px 16px;
  margin-bottom: 20px; min-height: 80px;
  display: flex; align-items: center; justify-content: center;
}
.gen-output-wrap { display: flex; align-items: center; gap: 12px; width: 100%; }
.gen-output {
  flex: 1; font-family: "Courier New", monospace;
  font-size: 18px; word-break: break-all;
  color: var(--accent); text-align: center;
}
.range-slider {
  width: 100%; accent-color: var(--accent);
  height: 6px; border-radius: 3px;
}
.char-options { display: flex; gap: 10px; flex-wrap: wrap; }
.char-option { display: flex; align-items: center; gap: 0; cursor: pointer; }
.char-option input { position: absolute; opacity: 0; width: 0; height: 0; }
.char-badge {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 16px;
  font-family: monospace; font-size: 15px; font-weight: 600;
  transition: all .15s; cursor: pointer;
}
.char-option input:checked + .char-badge {
  background: rgba(108,99,255,.2);
  border-color: var(--accent); color: var(--accent);
}
.save-section { margin-top: 20px; }
.save-divider {
  text-align: center; color: var(--text2);
  font-size: 13px; margin-bottom: 12px;
  border-top: 1px solid var(--border); padding-top: 16px;
}

/* ── Modal (bottom sheet) ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  display: flex; align-items: flex-end;
  z-index: 300;
}
.modal-sheet {
  background: var(--bg2);
  border-radius: 20px 20px 0 0;
  padding: 12px 16px 32px;
  width: 100%; max-height: 85vh;
  overflow-y: auto;
  animation: slideUp .25s ease;
}
.modal-handle {
  width: 36px; height: 4px;
  background: var(--border); border-radius: 2px;
  margin: 0 auto 16px;
}
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; }
.modal-form { display: flex; flex-direction: column; gap: 10px; }
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── Utilities ───────────────────────────────────────────────────────────── */
.mt-3 { margin-top: 12px !important; }
.text-muted { color: var(--text2) !important; }
.small { font-size: 12px !important; }
