:root {
  --bg: #0a0f1a;
  --surface: #1e293b;
  --surface-hover: #243152;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --border: #334155;
  --border-light: #2a3a4e;
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #22c55e;
  --warning: #f59e0b;
  --shadow: 0 4px 24px rgba(0,0,0,0.5);
  --radius: 14px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --max-width: 640px;
  --transition: 0.2s ease;
  --card-gradient: linear-gradient(135deg, #1e293b, #0f172a);
  --card-border: 1px solid #334155;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
}

.hidden {
  display: none !important;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px;
}

header {
  background: linear-gradient(135deg, #1a2537, #0f172a);
  border-bottom: 1px solid #334155;
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  font-family: var(--font);
  line-height: 1.2;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  box-shadow: 0 2px 12px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #60a5fa, #3b82f6);
}

.btn-secondary {
  background: var(--card-gradient);
  color: var(--text);
  border: var(--card-border);
}

.btn-secondary:hover {
  background: linear-gradient(135deg, #243152, #1a2537);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  box-shadow: 0 2px 12px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: linear-gradient(135deg, #f87171, #ef4444);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-outline:hover {
  background: var(--primary);
  color: #fff;
}

.btn-outline-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.btn-outline-danger:hover {
  background: var(--danger);
  color: #fff;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  font-size: 1.3rem;
  padding: 6px;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.icon-btn:hover {
  background: rgba(255,255,255,0.08);
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="url"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: var(--font);
  background: #0f172a;
  color: var(--text);
  transition: border-color var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

select {
  background: #0f172a;
  cursor: pointer;
}

.input-with-btn {
  display: flex;
  gap: 8px;
}

.input-with-btn input {
  flex: 1;
}

.card {
  background: var(--card-gradient);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  border: var(--card-border);
}

.card-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text);
}

.text-center {
  text-align: center;
}

.text-secondary {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.mb-4 {
  margin-bottom: 16px;
}

.mt-4 {
  margin-top: 16px;
}

.gap-2 {
  gap: 8px;
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

/* Entry List */
.entry-item {
  display: flex;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid rgba(51, 65, 85, 0.6);
  cursor: pointer;
  transition: background var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.entry-item:hover {
  background: rgba(255,255,255,0.03);
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
  border-radius: var(--radius-sm);
}

.entry-item:last-child {
  border-bottom: none;
}

.entry-number {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 32px;
  text-align: center;
  flex-shrink: 0;
}

.entry-name {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text);
  flex: 1;
}

.entry-chevron {
  color: var(--text-secondary);
  font-size: 1.2rem;
  flex-shrink: 0;
  padding: 4px;
}

.entry-date {
  font-size: 0.75rem;
  color: var(--text-secondary);
  flex-shrink: 0;
  margin-right: 8px;
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.4;
}

/* Vault Search */
.vault-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #0f172a;
  border-radius: var(--radius);
  padding: 0 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

.vault-search-icon {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.vault-search input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 0;
  font-size: 0.9rem;
  font-family: var(--font);
  color: var(--text);
  outline: none;
}

.vault-controls {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.vault-controls select {
  width: auto;
  min-width: 130px;
  padding: 6px 10px;
  font-size: 0.8rem;
}

/* Unlock Screen */
.auth-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
  text-align: center;
  color: var(--text);
}

.auth-subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 24px;
  font-size: 0.95rem;
}

/* View Detail */
.detail-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(51, 65, 85, 0.6);
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  min-width: 80px;
  flex-shrink: 0;
}

.detail-value {
  font-size: 1rem;
  color: var(--text);
  word-break: break-all;
  flex: 1;
}

.btn-sm-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 6px;
  border-radius: 6px;
  color: var(--text-secondary);
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
}

.btn-sm-icon:hover {
  background: rgba(255,255,255,0.08);
  color: var(--primary);
}

.view-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* Password Generator Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--card-gradient);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 400px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  border: var(--card-border);
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

.gen-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}

.gen-options label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text);
}

.gen-options input[type="checkbox"] {
  accent-color: var(--primary);
}

.strength-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: capitalize;
}

.strength-weak { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.strength-fair { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.strength-strong { background: rgba(34, 197, 94, 0.2); color: #86efac; }
.strength-very-strong { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }

/* Custom Fields */
.custom-field-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}

.custom-field-row input {
  flex: 1;
}

.custom-field-row .btn {
  flex-shrink: 0;
}

/* Notification */
.notification {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 2000;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  max-width: 90%;
  text-align: center;
  animation: slideUp 0.3s ease;
}

.notification.info { background: var(--card-gradient); color: var(--text); border: 1px solid var(--border); }
.notification.success { background: linear-gradient(135deg, #166534, #14532d); color: #bbf7d0; border: 1px solid #22c55e; }
.notification.error { background: linear-gradient(135deg, #991b1b, #7f1d1d); color: #fecaca; border: 1px solid #ef4444; }

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

/* Warning box */
.warning-box {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin: 16px 0;
  font-size: 0.85rem;
  color: #fbbf24;
}

/* Settings */
.settings-section {
  margin-bottom: 24px;
}

.settings-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid rgba(51, 65, 85, 0.6);
  gap: 12px;
}

.setting-row:last-child {
  border-bottom: none;
}

.setting-label {
  font-size: 0.95rem;
  color: var(--text);
}

.setting-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Home Screen */
.home-header {
  text-align: center;
  padding: 40px 0 32px;
}

.home-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.home-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.home-cards {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0 4px;
}

.home-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 24px;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  font-family: var(--font);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  text-align: center;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: #f1f5f9;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.home-card:hover {
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
  transform: translateY(-2px);
}

.home-card:active {
  transform: scale(0.97);
}

.home-card:first-child {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid #334155;
}

.home-card:last-child {
  background: linear-gradient(135deg, #0f172a, #1a1a2e);
  border: 1px solid #1e293b;
}

.home-card-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
}

.home-card-icon-view {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  font-size: 1.5rem;
}

.home-card-icon-add {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
  font-size: 2rem;
  font-weight: 300;
}

.home-card-label {
  font-size: 1.15rem;
  font-weight: 600;
}

.home-card-desc {
  font-size: 0.85rem;
  opacity: 0.7;
}

@media (max-width: 480px) {
  .container {
    padding: 12px;
  }
  header {
    padding: 10px 12px;
  }
  header h1 {
    font-size: 1rem;
  }
  .card {
    padding: 16px;
  }
  .auth-card {
    padding: 0;
  }
  .modal-content {
    padding: 16px;
  }

  .home-header {
    padding: 24px 0 20px;
  }
  .home-title {
    font-size: 1.3rem;
  }
  .home-card {
    padding: 28px 16px;
  }
  .home-card-icon {
    width: 48px;
    height: 48px;
    font-size: 1.3rem;
  }
}

@media (min-width: 768px) {
  .container {
    padding: 24px;
  }
  .home-cards {
    flex-direction: row;
    gap: 20px;
    max-width: 600px;
    margin: 0 auto;
  }
  .home-card {
    flex: 1;
    padding: 48px 24px;
  }
}
