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

:root {
  --bg: #0d0f14;
  --bg-1: #13161d;
  --bg-2: #1a1d27;
  --bg-3: #22263a;
  --border: rgba(255,255,255,0.07);
  --border-strong: rgba(255,255,255,0.12);
  --text: #e8eaf0;
  --text-2: #9499b0;
  --text-3: #5a5f78;
  --primary: #6366f1;
  --primary-h: #818cf8;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --card-ratio: 1.586;
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 4px 12px rgba(0,0,0,0.2);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
}

body.light {
  --bg: #f0f2f7;
  --bg-1: #ffffff;
  --bg-2: #f8f9fc;
  --bg-3: #eef0f6;
  --border: rgba(0,0,0,0.07);
  --border-strong: rgba(0,0,0,0.12);
  --text: #111827;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
}

.hidden { display: none !important; }

/* ── Typography ─────────────────────────────────────────── */
h1 { font-size: 1.625rem; font-weight: 700; letter-spacing: -0.025em; }
h2 { font-size: 1.125rem; font-weight: 600; letter-spacing: -0.01em; }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border: none; border-radius: var(--radius-sm);
  font-size: 0.875rem; font-weight: 500; cursor: pointer;
  transition: all 0.15s; font-family: inherit; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--text-2); border: 1px solid var(--border-strong); }
.btn-ghost:hover { color: var(--text); background: var(--bg-3); }
.btn-sm { padding: 6px 14px; font-size: 0.8125rem; }
.btn-full { width: 100%; justify-content: center; }

/* ── Forms ──────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 0.75rem; font-weight: 500; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.04em; }
.form-row { display: flex; gap: 12px; }
.flex-1 { flex: 1; min-width: 0; }

input, select, textarea {
  padding: 9px 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--bg-2);
  color: var(--text); font-size: 0.9375rem; font-family: inherit;
  outline: none; transition: border-color 0.15s; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); background: var(--bg-1); }
textarea { resize: vertical; }
select { cursor: pointer; }

.form-section-title {
  font-size: 0.6875rem; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.08em;
  padding-bottom: 4px; border-bottom: 1px solid var(--border);
}

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

/* ── Auth ───────────────────────────────────────────────── */
.auth-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.auth-card {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: 16px; padding: 40px; width: 100%; max-width: 400px;
  text-align: center; box-shadow: var(--shadow-lg);
}
.auth-card h1 { margin: 12px 0 6px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 24px; text-align: left; }
.auth-icon { color: var(--primary); display: flex; justify-content: center; }
.auth-sub { color: var(--text-2); font-size: 0.875rem; line-height: 1.6; }

/* ── Navbar ─────────────────────────────────────────────── */
.navbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 52px; background: var(--bg-1);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50;
}
.navbar-brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 1rem; color: var(--primary);
  letter-spacing: -0.01em;
}
.navbar-title { font-size: 0.9375rem; font-weight: 600; }
.navbar-right { display: flex; gap: 2px; }

.nav-btn {
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: var(--radius-sm); background: transparent;
  color: var(--text-2); cursor: pointer; transition: all 0.15s;
}
.nav-btn:hover { color: var(--text); background: var(--bg-3); }
.nav-btn-text {
  display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px;
  border: none; border-radius: var(--radius-sm); background: transparent;
  color: var(--text-2); font-size: 0.875rem; font-weight: 500; cursor: pointer;
  transition: all 0.15s; font-family: inherit;
}
.nav-btn-text:hover { color: var(--text); background: var(--bg-3); }

/* ── Dashboard ──────────────────────────────────────────── */
.dashboard-body { max-width: 1100px; margin: 0 auto; padding: 20px 24px 40px; }

.search-wrap {
  position: relative; display: flex; align-items: center;
  margin-bottom: 16px;
}
.search-icon { position: absolute; left: 12px; color: var(--text-3); pointer-events: none; flex-shrink: 0; }
.search-wrap input {
  padding-left: 38px; padding-right: 36px;
  background: var(--bg-1); font-size: 0.9375rem;
  border-radius: var(--radius);
}
.search-clear {
  position: absolute; right: 10px; width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 50%; background: var(--bg-3); color: var(--text-2); cursor: pointer;
}
.search-clear:hover { color: var(--text); }

/* ── Tabs ───────────────────────────────────────────────── */
.tab-bar {
  display: flex; gap: 2px; margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 16px 11px; border: none; background: transparent;
  color: var(--text-2); font-size: 0.875rem; font-weight: 500;
  cursor: pointer; transition: all 0.15s; font-family: inherit;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-count {
  font-size: 0.6875rem; font-weight: 600;
  background: var(--bg-3); color: var(--text-2);
  padding: 1px 6px; border-radius: 20px; min-width: 18px; text-align: center;
}
.tab.active .tab-count { background: rgba(99,102,241,0.15); color: var(--primary); }

/* ── Filter Bar ─────────────────────────────────────────── */
.panel-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.filter-bar { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }

.filter-group { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.filter-group-label { font-size: 0.6875rem; color: var(--text-3); font-weight: 500; white-space: nowrap; }
.filter-chip {
  padding: 4px 10px; border: 1px solid var(--border-strong);
  border-radius: 20px; background: transparent; color: var(--text-2);
  font-size: 0.75rem; font-weight: 500; cursor: pointer; transition: all 0.15s;
  font-family: inherit; white-space: nowrap;
}
.filter-chip:hover { color: var(--text); border-color: var(--text-3); }
.filter-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── Empty State ────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 56px 24px; color: var(--text-3); font-size: 0.9375rem;
}
.empty-state svg { margin-bottom: 12px; opacity: 0.3; }

/* ── Bank Account Tiles ─────────────────────────────────── */
.entries-list { display: flex; flex-direction: column; gap: 10px; }

.bank-tile {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  border-left: 3px solid var(--bank-color, var(--primary));
  transition: box-shadow 0.15s;
}
.bank-tile:hover { box-shadow: var(--shadow); }

.bank-tile-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px 12px; border-bottom: 1px solid var(--border);
}
.bank-initial {
  width: 36px; height: 36px; border-radius: 8px; flex-shrink: 0;
  background: var(--bank-color, var(--primary));
  display: flex; align-items: center; justify-content: center;
  font-size: 0.875rem; font-weight: 700; color: #fff; letter-spacing: 0;
}
.bank-head-info { flex: 1; min-width: 0; }
.bank-head-name {
  font-size: 0.9375rem; font-weight: 600; display: flex; align-items: center; gap: 8px;
}
.bank-head-meta { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.bank-owner { font-size: 0.75rem; color: var(--text-2); }
.acct-type-badge {
  font-size: 0.625rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 2px 7px; border-radius: 4px; background: var(--bg-3); color: var(--text-2);
}
.bank-tile-actions { display: flex; gap: 4px; }
.tile-btn {
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 6px; background: transparent; color: var(--text-3);
  cursor: pointer; transition: all 0.15s;
}
.tile-btn:hover { color: var(--text); background: var(--bg-3); }
.tile-btn-danger:hover { color: var(--danger); }

.bank-tile-body { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }

.field-row { display: flex; align-items: center; gap: 8px; min-height: 26px; }
.field-lbl { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); min-width: 88px; flex-shrink: 0; font-weight: 500; }
.field-val { font-size: 0.875rem; color: var(--text); font-family: 'SF Mono', 'Fira Code', monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.field-secret { cursor: pointer; user-select: none; }
.field-link { color: var(--primary); text-decoration: none; font-size: 0.8125rem; font-family: inherit; }
.field-link:hover { text-decoration: underline; }
.field-notes { font-size: 0.8125rem; color: var(--text-2); font-family: inherit; white-space: pre-wrap; }
.field-actions { display: flex; gap: 2px; flex-shrink: 0; }
.field-btn {
  width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 5px; background: transparent; color: var(--text-3);
  cursor: pointer; transition: all 0.15s;
}
.field-btn:hover { color: var(--text); background: var(--bg-3); }

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

/* ── Card Visual ────────────────────────────────────────── */
.card-wrap { display: flex; flex-direction: column; }

.card-visual {
  position: relative; width: 100%; aspect-ratio: var(--card-ratio);
  border-radius: 16px; color: #fff; font-family: 'SF Mono', 'Fira Code', monospace;
  box-shadow: var(--shadow-lg); perspective: 1000px;
}

.card-front, .card-back {
  position: absolute; inset: 0; padding: 20px 22px;
  display: flex; flex-direction: column; border-radius: 16px;
  backface-visibility: hidden; transition: transform 0.6s cubic-bezier(0.4,0,0.2,1);
  background: inherit;
}
.card-back { transform: rotateY(180deg); justify-content: center; }
.card-visual.flipped .card-front { transform: rotateY(180deg); }
.card-visual.flipped .card-back { transform: rotateY(0); }

.card-top-row { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; }
.card-top-left { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.card-top-right { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }

.card-bank-name-text {
  font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.05em;
  font-family: var(--font); text-transform: uppercase; opacity: 0.95;
}
.card-owner-text { font-size: 0.6875rem; color: rgba(255,255,255,0.6); font-family: var(--font); }

.card-brand-logo { height: 32px; max-width: 52px; object-fit: contain; }
.card-brand-text { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; opacity: 0.85; }
.card-type-badge {
  font-size: 0.5625rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  background: rgba(255,255,255,0.18); backdrop-filter: blur(4px);
  padding: 3px 8px; border-radius: 4px; font-family: var(--font); white-space: nowrap;
}

.card-chip { margin-bottom: 14px; }
.card-number {
  font-size: 1.25rem; letter-spacing: 0.14em; margin-bottom: auto;
  cursor: pointer; user-select: none;
}
.card-number:hover { opacity: 0.8; }
.card-bottom-row { display: flex; justify-content: space-between; align-items: flex-end; }
.card-label { display: block; font-size: 0.5rem; text-transform: uppercase; letter-spacing: 0.1em; opacity: 0.6; font-family: var(--font); margin-bottom: 2px; }
.card-holder-name { font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.07em; font-family: var(--font); }
.card-expiry-value { font-size: 0.875rem; letter-spacing: 0.06em; }

/* Card action row */
.card-action-row { display: flex; gap: 6px; padding: 8px 2px 0; }
.card-row-btn {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--bg-1); color: var(--text-2); font-size: 0.75rem; font-weight: 500;
  cursor: pointer; font-family: inherit; transition: all 0.15s;
}
.card-row-btn:hover { background: var(--bg-3); color: var(--text); }
.card-row-btn-danger:hover { color: var(--danger); border-color: rgba(239,68,68,0.4); background: rgba(239,68,68,0.06); }

/* Card Back */
.card-magstripe { height: 42px; background: rgba(0,0,0,0.5); margin: -20px -22px 18px; width: calc(100% + 44px); flex-shrink: 0; }
.card-secrets { display: flex; gap: 10px; }
.card-cvv-area, .card-pin-area {
  flex: 1; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.18);
  padding: 10px 14px; border-radius: 8px; cursor: pointer; transition: background 0.15s;
}
.card-cvv-area:hover, .card-pin-area:hover { background: rgba(255,255,255,0.18); }
.card-secret-value { display: block; font-size: 1.125rem; letter-spacing: 0.2em; margin-top: 3px; user-select: none; }
.card-back-hint { font-size: 0.5625rem; text-align: center; opacity: 0.45; font-family: var(--font); letter-spacing: 0.08em; text-transform: uppercase; margin-top: 12px; }

/* Card gradient map */
.card-visa { background: linear-gradient(135deg, #1a1f71, #2557d6 60%, #1a1f71); }
.card-mastercard { background: linear-gradient(135deg, #1a1a2e, #16213e 50%, #0f3460); }
.card-amex { background: linear-gradient(135deg, #2e7d32, #388e3c 50%, #1b5e20); }
.card-rupay { background: linear-gradient(135deg, #1a237e, #283593 50%, #1a237e); }
.card-discover { background: linear-gradient(135deg, #b54400, #e65100 50%, #b54400); }
.card-jcb { background: linear-gradient(135deg, #004d40, #00695c 50%, #004d40); }
.card-diners, .card-diners-club { background: linear-gradient(135deg, #1565c0, #1976d2 50%, #1565c0); }
.card-unionpay { background: linear-gradient(135deg, #c62828, #d32f2f 50%, #b71c1c); }
.card-default { background: linear-gradient(135deg, #1e2235, #2a3050 50%, #1e2235); }

/* ── Card Preview (form) ─────────────────────────────────── */
.card-preview {
  width: 100%; max-width: 380px; aspect-ratio: var(--card-ratio);
  border-radius: 14px; padding: 18px 20px; color: #fff;
  margin: 0 auto 20px; display: flex; flex-direction: column;
  font-family: 'SF Mono','Fira Code',monospace; box-shadow: var(--shadow-lg);
  transition: background 0.3s; background: linear-gradient(135deg, #1e2235, #2a3050);
}
.card-preview-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; }
.cp-bank { display: block; font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; font-family: var(--font); }
.cp-owner { display: block; font-size: 0.6875rem; color: rgba(255,255,255,0.6); font-family: var(--font); margin-top: 2px; }
.cp-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.cp-brand { font-size: 0.8125rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.85; }
.cp-chip { margin-bottom: 12px; }
.cp-number { font-size: 1.25rem; letter-spacing: 0.14em; margin-bottom: auto; }
.cp-bottom { display: flex; justify-content: space-between; align-items: flex-end; }
.cp-holder, .cp-exp { display: block; font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.06em; font-family: var(--font); }

/* ── Form page ──────────────────────────────────────────── */
.form-page { max-width: 520px; margin: 0 auto; padding: 20px 24px 40px; }
.entry-form { display: flex; flex-direction: column; gap: 14px; }

/* ── BIN detection ──────────────────────────────────────── */
.card-number-wrap { position: relative; display: flex; align-items: center; }
.card-number-wrap input { flex: 1; }
.bin-spinner {
  position: absolute; right: 12px; width: 16px; height: 16px;
  border: 2px solid var(--border-strong); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.card-detected-panel {
  background: var(--bg-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 10px 14px;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

.detected-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.detected-bank { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.detected-bank-name { font-size: 0.9375rem; font-weight: 600; }
.detected-unknown { color: var(--text-2); font-weight: 400; }
.detected-badges { display: flex; gap: 5px; flex-wrap: wrap; }
.detected-badge {
  font-size: 0.625rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em;
  padding: 2px 8px; border-radius: 4px;
}
.detected-network { background: rgba(99,102,241,0.15); color: var(--primary); }
.detected-type { background: rgba(34,197,94,0.12); color: #22c55e; }
.detected-tier { background: rgba(245,158,11,0.15); color: #d97706; }
.btn-override {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px;
  border: 1px solid var(--border-strong); border-radius: 6px; background: transparent;
  color: var(--text-3); font-size: 0.6875rem; font-weight: 500; cursor: pointer;
  white-space: nowrap; font-family: inherit; flex-shrink: 0;
}
.btn-override:hover { color: var(--text); background: var(--bg-3); }

/* ── Autocomplete ───────────────────────────────────────── */
.autocomplete-wrap { position: relative; }
.autocomplete-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--bg-1); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); max-height: 220px; overflow-y: auto;
  z-index: 100; box-shadow: var(--shadow-lg); display: none;
}
.autocomplete-dropdown.open { display: block; }
.autocomplete-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; cursor: pointer; font-size: 0.875rem; transition: background 0.1s;
}
.autocomplete-item:hover { background: var(--bg-3); }
.ac-initial {
  width: 26px; height: 26px; border-radius: 5px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.6875rem; font-weight: 700; color: #fff;
}

/* ── Toast ──────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  padding: 9px 18px; border-radius: var(--radius-sm); font-size: 0.875rem; font-weight: 500;
  z-index: 1000; transition: transform 0.25s cubic-bezier(0.4,0,0.2,1); pointer-events: none;
  background: var(--bg-1); border: 1px solid var(--border-strong); color: var(--text);
  box-shadow: var(--shadow-lg); white-space: nowrap;
}
.toast-show { transform: translateX(-50%) translateY(0); }
.toast-error { background: #2d1515; border-color: rgba(239,68,68,0.4); color: #fca5a5; }
.toast-success { background: #0f2d1a; border-color: rgba(34,197,94,0.4); color: #86efac; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 640px) {
  .dashboard-body { padding: 16px; }
  .cards-grid { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; }
  .form-page { padding: 16px 16px 32px; }
  .panel-header { flex-direction: column; align-items: stretch; }
  .card-number { font-size: 1.0625rem; }
  .cp-number { font-size: 1.0625rem; }
  .navbar { padding: 0 16px; }
}
