:root {
  --bg: #0b0f1a;
  --panel: #141a2b;
  --panel-2: #1b2235;
  --line: #262e44;
  --text: #e8ecf6;
  --muted: #8b93a8;
  --brand: #5b8cff;
  --brand-2: #7c5cff;
  --green: #2ecc8f;
  --red: #ff5d6c;
  --radius: 16px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Inter", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 14px; }
.link { background: none; border: none; color: var(--brand); cursor: pointer; font-size: 13px; padding: 0; }
.error { color: var(--red); font-size: 14px; margin-top: 12px; text-align: center; }
.hint { color: var(--muted); font-size: 13px; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { font-size: 28px; }
.brand-name { font-size: 22px; font-weight: 700; letter-spacing: -.5px; }
.brand-name b { background: linear-gradient(90deg, var(--brand), var(--brand-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand.small .logo { font-size: 22px; }
.brand.small .brand-name { font-size: 18px; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  padding: 11px 18px; border-radius: 12px; font-weight: 600; font-size: 14px;
  cursor: pointer; transition: transform .08s, filter .15s; font-family: inherit;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: scale(.98); }
.btn.primary { background: linear-gradient(90deg, var(--brand), var(--brand-2)); border: none; color: #fff; }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-card {
  display: flex; flex-direction: column; justify-content: center;
  padding: 6vh 8%; max-width: 560px; margin: 0 auto; width: 100%;
}
.tagline { color: var(--muted); margin: 14px 0 28px; }
.tabs { display: flex; gap: 8px; background: var(--panel); padding: 6px; border-radius: 12px; margin-bottom: 22px; }
.tab { flex: 1; padding: 10px; border: none; border-radius: 8px; background: transparent; color: var(--muted); font-weight: 600; cursor: pointer; font-family: inherit; }
.tab.active { background: var(--panel-2); color: var(--text); }
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
.form input, .form select {
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  padding: 12px 14px; border-radius: 10px; font-size: 15px; font-family: inherit; outline: none;
}
.form input:focus, .form select:focus { border-color: var(--brand); }
.auth-side {
  background: linear-gradient(160deg, #16203f, #1a1430);
  display: flex; flex-direction: column; justify-content: center; padding: 0 9%; gap: 24px;
}
.auth-side h1 { font-size: 44px; line-height: 1.1; font-weight: 800; letter-spacing: -1px; }
.auth-side ul { list-style: none; display: flex; flex-direction: column; gap: 14px; }
.auth-side li { font-size: 17px; color: #cfd6ea; }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--panel); border-right: 1px solid var(--line);
  padding: 24px 16px; display: flex; flex-direction: column; gap: 28px;
}
.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  text-align: left; background: none; border: none; color: var(--muted);
  padding: 12px 14px; border-radius: 10px; font-size: 15px; font-weight: 500;
  cursor: pointer; font-family: inherit; transition: .12s;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active { background: var(--panel-2); color: var(--text); }
.user-box { display: flex; align-items: center; gap: 12px; padding-top: 16px; border-top: 1px solid var(--line); }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg, var(--brand), var(--brand-2)); display: flex; align-items: center; justify-content: center; font-weight: 700; }
.uname { font-weight: 600; font-size: 14px; }

.content { padding: 36px 44px; overflow-y: auto; max-height: 100vh; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }
.view h2 { font-size: 26px; font-weight: 700; letter-spacing: -.5px; }
.view h3 { font-size: 16px; margin: 26px 0 14px; color: var(--text); }
.big-number { font-size: 40px; font-weight: 800; letter-spacing: -1px; }

/* ---------- cards / accounts ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.account-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.acc {
  background: linear-gradient(150deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; cursor: pointer; transition: .12s;
}
.acc:hover { border-color: var(--brand); transform: translateY(-2px); }
.acc .type { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.acc .bal { font-size: 28px; font-weight: 700; margin: 8px 0; }
.acc .iban { font-size: 12px; color: var(--muted); font-family: ui-monospace, monospace; }
.iban { font-family: ui-monospace, monospace; color: var(--muted); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }

/* ---------- transactions ---------- */
.tx-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.tx { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 12px; transition: .1s; }
.tx:hover { background: var(--panel); }
.tx-ic { width: 38px; height: 38px; border-radius: 50%; background: var(--panel-2); display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.tx-main { flex: 1; min-width: 0; }
.tx-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-sub { font-size: 12px; color: var(--muted); }
.tx-amt { font-weight: 700; font-size: 15px; white-space: nowrap; }
.tx-amt.in { color: var(--green); }
.tx-amt.out { color: var(--red); }

/* ---------- bank cards ---------- */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 20px; }
.bankcard {
  aspect-ratio: 1.6 / 1; border-radius: 18px; padding: 24px; color: #fff;
  background: linear-gradient(135deg, #2a3a7a, #5b3a9e); position: relative;
  display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: 0 12px 30px rgba(0,0,0,.35);
}
.bankcard.frozen { filter: grayscale(.7) brightness(.7); }
.bankcard.bc-spent { filter: grayscale(.9) brightness(.55); }
.bankcard.bc-disposable { background: linear-gradient(135deg, #1a4a3a, #2a6b50); }
.bc-badge {
  display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .5px;
  text-transform: uppercase; padding: 3px 7px; border-radius: 6px; margin-bottom: 4px;
}
.bc-badge-disposable { background: rgba(91,140,255,.25); color: #a0c4ff; }
.bc-badge-used { background: rgba(255,255,255,.15); color: rgba(255,255,255,.7); }
.bankcard .bc-top { display: flex; justify-content: space-between; align-items: center; }
.bankcard .bc-num { font-size: 21px; letter-spacing: 2px; font-family: ui-monospace, monospace; }
.bankcard .bc-bottom { display: flex; justify-content: space-between; font-size: 13px; }
.bankcard .bc-label { font-size: 9px; opacity: .7; text-transform: uppercase; letter-spacing: 1px; }
.bc-actions { display: flex; gap: 8px; margin-top: 12px; }
.bc-actions .btn { padding: 8px 14px; font-size: 13px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 14px 22px; border-radius: 12px; font-weight: 600; font-size: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4); z-index: 50; animation: pop .25s ease;
}
.toast.ok { border-color: var(--green); }
.toast.err { border-color: var(--red); }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ---------- analytics ---------- */
.ana-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.summary-card { text-align: center; padding: 20px 16px; }
.sc-label { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.sc-value { font-size: 24px; font-weight: 800; letter-spacing: -.5px; }
.sc-value.green { color: var(--green); }
.sc-value.red { color: var(--red); }
.ana-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.period-tabs { display: flex; gap: 4px; background: var(--panel); padding: 4px; border-radius: 10px; }
.period-tabs .tab { flex: unset; padding: 8px 16px; font-size: 13px; }

/* ---------- request tabs (reuse period-tabs pattern) ---------- */
.req-tabs { display: flex; gap: 4px; background: var(--panel); padding: 4px; border-radius: 10px; max-width: 280px; }
.req-tabs .tab { flex: 1; padding: 8px 14px; font-size: 13px; }

/* ---------- vault cards ---------- */
.vaults-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.vault-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; display: flex; flex-direction: column;
}
.vault-emoji { font-size: 36px; margin-bottom: 8px; }
.vault-name { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.vault-balance { font-size: 26px; font-weight: 800; letter-spacing: -.5px; color: var(--brand); margin: 8px 0; }
@media (max-width: 860px) { .vaults-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .vaults-grid { grid-template-columns: 1fr; } }

/* ---------- card feature toggles ---------- */
.card-toggles {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 0 14px; margin-top: 8px;
}
.toggle-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 0; cursor: pointer; font-size: 14px; user-select: none;
}
.toggle-row:not(:last-child) { border-bottom: 1px solid var(--line); }
.toggle-cb {
  appearance: none; -webkit-appearance: none;
  width: 44px; height: 24px; border-radius: 12px;
  background: var(--line); cursor: pointer; position: relative;
  transition: background .2s; flex-shrink: 0;
}
.toggle-cb::after {
  content: ""; position: absolute;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px;
  transition: left .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.toggle-cb:checked { background: var(--brand); }
.toggle-cb:checked::after { left: 23px; }

/* ---------- budget progress bars ---------- */
.budget-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.budget-item:last-child { border-bottom: none; padding-bottom: 0; }
.budget-item:first-child { padding-top: 0; }
.budget-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.budget-bar { height: 6px; background: var(--line); border-radius: 3px; margin-bottom: 4px; }
.budget-bar-fill { height: 100%; border-radius: 3px; background: var(--brand); transition: width .4s; }
.budget-bar-fill.warn { background: #f5b942; }
.budget-bar-fill.over { background: var(--red); }
.budget-pct { font-size: 12px; color: var(--muted); }

/* ---------- profile grid ---------- */
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; max-width: 900px; }
@media (max-width: 860px) { .profile-grid { grid-template-columns: 1fr; } }

/* ---------- activity filter ---------- */
.filter-select {
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  padding: 10px 14px; border-radius: 10px; font-size: 14px; font-family: inherit; outline: none;
}
.filter-select:focus { border-color: var(--brand); }

/* ---------- input + inline button (e.g. IBAN + Scan QR) ---------- */
.input-with-btn { display: flex; gap: 8px; }
.input-with-btn input { flex: 1; }
.input-with-btn .btn { flex-shrink: 0; font-size: 13px; padding: 11px 14px; }

/* ---------- QR scanner modal ---------- */
.qr-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.82);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; backdrop-filter: blur(6px);
}
.qr-modal-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; width: 100%; max-width: 460px; margin: 16px;
}
.qr-modal-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; font-weight: 700; font-size: 16px;
}
.qr-video-wrap {
  position: relative; border-radius: 12px; overflow: hidden; background: #000; aspect-ratio: 4/3;
}
.qr-video-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.qr-aim {
  position: absolute; inset: 20%;
  border: 2px solid var(--brand); border-radius: 8px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.4);
}

@media (max-width: 860px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .app { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; align-items: center; overflow-x: auto; }
  .sidebar nav { flex-direction: row; }
  .two-col { grid-template-columns: 1fr; }
  .content { padding: 24px 18px; }
  .ana-summary { grid-template-columns: 1fr; }
  .ana-charts { grid-template-columns: 1fr; }
  .profile-grid { grid-template-columns: 1fr; }
}


/* ---- PWA install banner ---- */
.install-banner {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: center;
  background: var(--card); border: 1px solid var(--brand);
  border-radius: 14px; padding: 14px 20px;
  box-shadow: 0 4px 24px rgba(91,140,255,.25);
  z-index: 9999;
  animation: bannerIn .35s cubic-bezier(.22,1,.36,1);
}
.install-banner-btns { display: flex; gap: 8px; }
.btn-sm { padding: 6px 14px; font-size: .82rem; }
@keyframes bannerIn {
  from { opacity: 0; transform: translateX(-50%) translateY(24px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---- Split bill ---- */
.split-participant-row {
  display: flex; gap: 8px; margin-bottom: 8px; align-items: center;
}
.split-participant-row .sp-email { flex: 2; }
.split-participant-row .sp-amount { flex: 1; min-width: 80px; }
.split-progress-bar {
  height: 6px; background: var(--border); border-radius: 4px; overflow: hidden;
}
.split-progress-fill {
  height: 100%; border-radius: 4px; transition: width .4s;
}
.split-participants { display: flex; flex-direction: column; gap: 6px; }
.split-participant {
  display: flex; justify-content: space-between;
  font-size: .85rem; color: var(--text-sub, var(--muted));
}
.split-card { border: 1px solid var(--border); }

/* ---- Activity search + filters ---- */
.activity-search-bar {
  display: flex; gap: 8px; align-items: center; margin-bottom: 10px;
}
.activity-search-bar input[type="search"] {
  flex: 1; padding: 9px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--card);
  color: var(--text); font-size: .9rem;
}
.activity-search-bar input[type="search"]:focus { outline: none; border-color: var(--brand); }
.activity-filters {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px; margin-bottom: 12px;
}
.filters-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px;
}
.filters-grid label { font-size: .82rem; }
.filters-grid select,
.filters-grid input { padding: 7px 10px; font-size: .85rem; }

/* ---- WebAuthn credential rows ---- */
.wa-cred-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.wa-cred-row:last-child { border-bottom: none; }
