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

:root {
  --bg:        #0f0f10;
  --surface:   #18181a;
  --surface2:  #222226;
  --border:    #2e2e34;
  --accent:    #f5c518;
  --accent-fg: #111111;
  --accent2:   #e94560;
  --text:      #eaeae0;
  --muted:     #72728a;
  --green:     #4ade80;
  --cyan:      #22d3ee;
  --orange:    #fb923c;
  --yellow:    #f5c518;
  --red:       #f87171;
  --radius:    12px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
}

/* ── HEADER ── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo { display: flex; align-items: center; gap: 12px; }

.logo-icon {
  width: 38px; height: 38px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--accent-fg);
}
.logo-icon svg { width: 18px; height: 18px; }

.logo-text { display: flex; flex-direction: column; gap: 1px; }
.logo-text h1 {
  font-size: 1.3rem; font-weight: 800;
  color: var(--text); letter-spacing: -0.03em; line-height: 1;
}
.logo-text span {
  font-size: 0.65rem; color: var(--muted);
  letter-spacing: 0.06em; text-transform: uppercase;
}

.count-badge {
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 0.72rem; font-weight: 700;
  padding: 2px 8px; border-radius: 20px;
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: opacity 0.15s, transform 0.1s;
}
.btn:hover { opacity: 0.85; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: var(--accent-fg); font-weight: 700; }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--border); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; }

.btn-icon {
  background: transparent;
  color: var(--muted);
  padding: 6px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  transition: background 0.15s, color 0.15s;
}
.btn-icon:hover          { background: var(--border);  color: var(--text); }
.btn-icon.danger:hover   { background: #3a1a1a;        color: var(--red); }
.btn-icon.copy:hover     { background: #1a2a1a;        color: var(--green); }
.btn-icon.edit:hover     { background: #1a1a3a;        color: var(--accent); }

/* ── MAIN / LAYOUT ── */
main { max-width: 1100px; margin: 0 auto; padding: 24px 20px; }

.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  align-items: center;
}
.search-wrap { flex: 1; position: relative; }
.search-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  width: 18px; height: 18px;
  pointer-events: none;
}
.search-wrap input {
  width: 100%;
  padding: 10px 12px 10px 38px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}
.search-wrap input:focus { border-color: var(--accent); }
.search-wrap input::placeholder { color: var(--muted); }

/* ── GRID ── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

/* ── CARD ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: border-color 0.2s, transform 0.15s;
  animation: fadeIn 0.25s ease;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.icon-wrap {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.icon-wrap img { width: 26px; height: 26px; object-fit: contain; }
.icon-letter {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 1rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.card-title { font-size: 1rem; font-weight: 700; color: var(--text); }
.card-url {
  font-size: 0.75rem; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px;
}
.card-actions { margin-left: auto; display: flex; gap: 4px; }

.field { margin-bottom: 10px; }
.field-label {
  font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted); margin-bottom: 4px;
}
.field-value {
  font-size: 0.9rem; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.field-value span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pwd-dots { letter-spacing: 0.15em; font-size: 1rem; color: var(--muted); }
.notes { font-size: 0.82rem; color: var(--muted); margin-top: 8px; font-style: italic; }

/* ── EMPTY STATE ── */
.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 24px;
  color: var(--muted);
}
.empty svg { width: 60px; height: 60px; margin-bottom: 16px; opacity: 0.3; }
.empty p { font-size: 1rem; }

/* ── MODAL ── */
.overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center; justify-content: center;
  padding: 16px;
}
.overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%; max-width: 480px;
  padding: 28px;
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 24px;
}
.modal-icon-preview {
  width: 48px; height: 48px;
  border-radius: 12px;
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.modal-icon-preview img { width: 28px; height: 28px; object-fit: contain; }
.modal-title { font-size: 1.15rem; font-weight: 700; }
.modal-subtitle { font-size: 0.78rem; color: var(--muted); }
.modal-close { margin-left: auto; }

.form-group { margin-bottom: 16px; }
label {
  display: block;
  font-size: 0.8rem; font-weight: 600;
  color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em;
  margin-bottom: 6px;
}
input[type="text"],
input[type="password"],
input[type="url"],
textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  outline: none; font-family: inherit;
  transition: border-color 0.15s;
}
input:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; }

.input-with-btn { position: relative; }
.input-with-btn input { padding-right: 76px; }
.input-btn-group {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  display: flex; gap: 2px;
}

.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px;
}

/* ── 2FA ── */
.twofa-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.twofa-row-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.9rem; color: var(--text);
}
.twofa-row-label svg { color: var(--accent); flex-shrink: 0; }

.toggle-switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--border);
  border-radius: 12px; cursor: pointer;
  transition: background 0.2s;
}
.toggle-track::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%;
  transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-track { background: var(--accent); }
.toggle-switch input:checked + .toggle-track::before { transform: translateX(18px); }

.twofa-method-wrap { margin-top: 10px; }
select {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem; outline: none; font-family: inherit; cursor: pointer;
  transition: border-color 0.15s;
  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='none' stroke='%237070a0' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
select:focus { border-color: var(--accent); }
select option { background: #1e1e35; }

.twofa-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.72rem; font-weight: 600;
  padding: 3px 8px; border-radius: 20px;
  background: rgba(245,197,24,0.12);
  color: var(--accent);
  border: 1px solid rgba(245,197,24,0.3);
  margin-top: 8px;
}
.twofa-badge svg { width: 11px; height: 11px; }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 10px 22px;
  color: var(--text); font-size: 0.9rem;
  display: flex; align-items: center; gap: 8px;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 999; white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }

/* ── CONFIRM ── */
.confirm-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 300;
  align-items: center; justify-content: center;
  padding: 16px;
}
.confirm-overlay.open { display: flex; }
.confirm-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px; max-width: 360px; width: 100%;
  text-align: center;
  animation: slideUp 0.2s ease;
}
.confirm-box .icon { font-size: 2.5rem; margin-bottom: 12px; }
.confirm-box h3 { font-size: 1.1rem; margin-bottom: 8px; }
.confirm-box p { color: var(--muted); font-size: 0.9rem; margin-bottom: 20px; }
.confirm-footer { display: flex; gap: 10px; justify-content: center; }

/* ── GENERATOR PANEL ── */
.gen-panel {
  display: none;
  margin-top: 8px;
  padding: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  animation: fadeIn 0.15s ease;
}
.gen-panel.open { display: block; }

.gen-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.gen-header-label { font-size: 0.8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }

.gen-strength {
  font-size: 0.72rem; font-weight: 700;
  padding: 2px 8px; border-radius: 20px;
}
.gen-strength.weak      { background: rgba(248,113,113,0.15); color: var(--red); }
.gen-strength.good      { background: rgba(251,146,60,0.15);  color: var(--orange); }
.gen-strength.strong    { background: rgba(74,222,128,0.15);  color: var(--green); }
.gen-strength.very-strong { background: rgba(34,211,238,0.15); color: var(--cyan); }

.gen-preview-row {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px;
  margin-bottom: 12px;
}
.gen-preview {
  flex: 1; font-family: 'Courier New', monospace;
  font-size: 0.88rem; color: var(--text);
  word-break: break-all; line-height: 1.4;
}

.gen-length-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px; font-size: 0.85rem; color: var(--muted);
}
.gen-length-row strong { min-width: 24px; text-align: right; color: var(--text); }

.gen-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.gen-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  transition: transform 0.1s;
}
.gen-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }
.gen-slider::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%; border: none;
  background: var(--accent); cursor: pointer;
}

.gen-opts {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.gen-opt {
  display: flex; align-items: center; gap: 5px;
  font-size: 0.82rem; color: var(--text);
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 10px;
  transition: border-color 0.15s;
  text-transform: none; letter-spacing: 0; font-weight: 400; margin-bottom: 0;
}
.gen-opt:has(input:checked) { border-color: var(--accent); }
.gen-opt input { accent-color: var(--accent); cursor: pointer; }

.btn-full { width: 100%; justify-content: center; }

/* ── RESPONSIVE ── */
@media (max-width: 600px) {
  header { padding: 12px 16px; }
  .logo h1 { font-size: 1rem; }
  main { padding: 16px 12px; }
  .grid { grid-template-columns: 1fr; }
}
