:root {
  --bg: #0b0d12;
  --surface: #161922;
  --surface-2: #1f2330;
  --surface-3: #2a2f3e;
  --text: #f5f6fa;
  --muted: #8b90a0;
  --accent: #8b5cf6;       /* revolut-ish violet */
  --accent-2: #6d4aff;
  --good: #2dd4a7;
  --bad: #ff5c7c;
  --warn: #ffb340;
  --radius: 22px;
  --radius-sm: 14px;
}

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

/* the hidden attribute must beat our display:flex rules */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  background: #05060a;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* phone shell */
.phone {
  position: relative;
  width: 100%;
  max-width: 430px;
  height: 100dvh;
  max-height: 932px;
  background: radial-gradient(140% 60% at 50% -10%, #251b46 0%, var(--bg) 45%);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
@media (min-width: 480px) {
  .phone { border-radius: 38px; box-shadow: 0 30px 80px rgba(0,0,0,.6); height: 92dvh; }
}

.screen {
  flex: 1;
  overflow-y: auto;
  padding: 0 18px 120px;
  scrollbar-width: none;
}
.screen::-webkit-scrollbar { display: none; }

/* top bar */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 2px 14px;
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
  z-index: 5;
}
.avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--surface-2);
  color: var(--text);
  font-size: 18px; font-weight: 600;
  display: grid; place-items: center;
  cursor: pointer;
}
.avatar.ghost { background: var(--surface); border: 1px solid var(--surface-3); }
.month-switch {
  display: flex; align-items: center; gap: 6px;
  font-weight: 600; font-size: 16px;
}
.month-nav {
  background: none; border: none; color: var(--muted);
  font-size: 20px; cursor: pointer; display: grid; place-items: center;
  width: 30px; height: 30px;
}

/* balance card */
.balance-card {
  background: linear-gradient(160deg, #2a2150, var(--surface) 70%);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius);
  padding: 22px 20px;
  margin-bottom: 18px;
}
.balance-label { color: var(--muted); font-size: 13px; }
.balance-amount { font-size: 44px; font-weight: 700; letter-spacing: -1px; margin: 4px 0 10px; }
.balance-amount.over { color: var(--bad); }
.balance-sub {
  display: flex; align-items: center; gap: 10px;
  color: var(--muted); font-size: 13px; margin-bottom: 14px;
}
.link-btn {
  background: none; border: none; color: var(--accent);
  font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 3px;
  margin-left: auto;
}
.progress {
  height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 99px; transition: width .35s ease;
}
.progress-fill.over { background: linear-gradient(90deg, var(--bad), #ff8aa0); }
.balance-stats {
  display: flex; justify-content: space-between; margin-top: 14px;
}
.balance-stats > div { display: flex; flex-direction: column; gap: 2px; }
.stat-label { color: var(--muted); font-size: 12px; }
.stat-val { font-size: 16px; font-weight: 600; }

/* filters */
.filters { display: flex; gap: 8px; margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  background: var(--surface);
  border: 1px solid var(--surface-3);
  color: var(--muted);
  padding: 8px 14px; border-radius: 99px;
  font-size: 13px; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 4px;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.list-header {
  display: flex; justify-content: space-between; align-items: baseline;
  color: var(--muted); font-size: 13px; margin: 4px 4px 10px;
}
.rate-note { font-size: 11px; }

/* transaction list */
.tx-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.tx {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 13px 14px; cursor: pointer;
}
.tx.important { border-color: rgba(255,179,64,.4); }
.tx-icon {
  width: 44px; height: 44px; border-radius: 13px;
  background: var(--surface-2); color: var(--accent);
  display: grid; place-items: center; font-size: 22px; flex: 0 0 auto;
}
.tx.paid .tx-icon { background: rgba(45,212,167,.15); color: var(--good); }
.tx-main { flex: 1; min-width: 0; }
.tx-name { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.tx-name .star { color: var(--warn); font-size: 14px; }
.tx-meta { color: var(--muted); font-size: 12px; margin-top: 2px; display: flex; gap: 6px; flex-wrap: wrap; }
.tag { background: var(--surface-3); padding: 1px 8px; border-radius: 99px; font-size: 11px; }
.tx-right { display: flex; flex-direction: column; align-items: flex-end; gap: 7px; flex: 0 0 auto; }
.tx-amount { font-weight: 600; font-size: 15px; }
.tx.paid .tx-amount { color: var(--muted); }
.tx-status {
  font-size: 11px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 99px; cursor: pointer;
  border: 1px solid transparent; line-height: 1;
  transition: background .15s, color .15s, border-color .15s;
}
.tx-status i { font-size: 13px; }
.tx-status.unpaid {
  background: var(--surface-2); color: var(--muted); border-color: var(--surface-3);
}
.tx-status.unpaid:hover { color: var(--text); border-color: var(--muted); }
.tx-status.paid {
  background: rgba(45,212,167,.14); color: var(--good); border-color: transparent;
}

.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.empty i { font-size: 46px; opacity: .5; }
.empty p { margin-top: 10px; font-size: 14px; }

/* bottom nav */
.bottom-nav {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 84px;
  background: rgba(11,13,18,.85);
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--surface-3);
  display: flex; align-items: center; justify-content: space-around;
  padding: 14px 0 calc(14px + env(safe-area-inset-bottom));
}
.nav-btn {
  background: none; border: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 4px;
  font-size: 11px; cursor: pointer; flex: 1;
  align-self: flex-start;
}
.nav-btn i { font-size: 23px; }
.nav-btn.active { color: var(--text); }
.nav-btn.fab {
  flex: 1;
  align-self: stretch;
  align-items: center;
  justify-content: flex-start;
  padding: 0;
  background: none;
}
.fab-circle {
  width: 58px; height: 58px; border-radius: 50%;
  background: linear-gradient(160deg, var(--accent), var(--accent-2));
  color: #fff;
  display: grid; place-items: center;
  transform: translateY(-22px);
  box-shadow: 0 8px 22px rgba(109,74,255,.5);
}
.nav-btn.fab i { font-size: 28px; line-height: 1; }

/* sheets */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 50;
}
.sheet {
  width: 100%; max-width: 430px;
  background: var(--surface);
  border-radius: 26px 26px 0 0;
  padding: 10px 20px calc(26px + env(safe-area-inset-bottom));
  max-height: 92dvh; overflow-y: auto;
  animation: slideUp .25s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-handle { width: 40px; height: 4px; border-radius: 99px; background: var(--surface-3); margin: 6px auto 14px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.sheet-head h2 { font-size: 19px; font-weight: 700; }
.icon-btn { background: var(--surface-2); border: none; color: var(--text); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 17px; }

/* forms */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; color: var(--muted); }
.field small { color: var(--surface-3); }
.field input, .field select {
  background: var(--surface-2); border: 1px solid var(--surface-3);
  border-radius: 12px; padding: 13px 14px; color: var(--text); font-size: 16px;
  outline: none;
}
.field input:focus, .field select:focus { border-color: var(--accent); }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.amount-input { display: flex; align-items: center; background: var(--surface-2); border: 1px solid var(--surface-3); border-radius: 12px; padding: 0 14px; }
.amount-input .cur { color: var(--muted); font-size: 18px; }
.amount-input input { background: none; border: none; flex: 1; }

.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg.small { padding: 3px; }
.seg-btn {
  flex: 1; background: none; border: none; color: var(--muted);
  padding: 10px; border-radius: 9px; cursor: pointer; font-size: 14px; font-weight: 500;
}
.seg-btn.active { background: var(--accent); color: #fff; }

.toggles { display: flex; gap: 10px; }
.toggle input { display: none; }
.toggle-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-2); border: 1px solid var(--surface-3);
  padding: 10px 16px; border-radius: 99px; cursor: pointer; font-size: 14px; color: var(--muted);
}
.toggle input:checked + .toggle-pill { background: rgba(255,179,64,.15); border-color: var(--warn); color: var(--warn); }

.sheet-actions { display: flex; gap: 12px; align-items: center; margin-top: 8px; }
.btn-primary {
  flex: 1; background: linear-gradient(160deg, var(--accent), var(--accent-2));
  border: none; color: #fff; padding: 15px; border-radius: 14px;
  font-size: 16px; font-weight: 600; cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(139,92,246,.4);
}
.btn-primary:active {
  transform: translateY(0);
}
.auth-form .btn-primary {
  width: 100%;
  padding: 16px;
  font-size: 16px;
}
.btn-secondary {
  background: var(--surface-2); border: 1px solid var(--surface-3); color: var(--text);
  padding: 14px; border-radius: 12px; font-size: 15px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-text { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 14px; }
.btn-text.danger { color: var(--bad); }
.danger-ghost {
  width: 100%; background: rgba(255,92,124,.1); border: 1px solid rgba(255,92,124,.3);
  color: var(--bad); padding: 13px; border-radius: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 14px;
}
.cancel-block { display: flex; flex-direction: column; gap: 12px; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.5; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.setting-row.stacked { flex-direction: column; align-items: flex-start; gap: 6px; }
.muted { color: var(--muted); font-size: 13px; }
hr { border: none; border-top: 1px solid var(--surface-3); margin: 6px 0; }

.toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: var(--surface-3); color: var(--text);
  padding: 12px 18px; border-radius: 12px; font-size: 14px; z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); max-width: 90%; text-align: center;
}

/* auth screen */
.auth-screen {
  position: fixed; inset: 0; z-index: 1000;
  background: radial-gradient(140% 60% at 50% -10%, #251b46 0%, var(--bg) 45%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  overflow-y: auto;
}
.auth-screen.hidden { display: none !important; }

.auth-container {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius);
  padding: 50px 35px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.auth-logo {
  text-align: center; margin-bottom: 40px;
}
.auth-logo i {
  font-size: 72px; 
  color: var(--accent);
  display: block; 
  margin-bottom: 16px;
  line-height: 1;
}
.auth-logo h1 {
  font-size: 32px; font-weight: 700; margin-bottom: 6px;
  letter-spacing: -0.5px;
}
.auth-logo p {
  color: var(--muted); font-size: 15px;
}

.auth-form {
  display: flex; flex-direction: column; gap: 18px;
}
.auth-form h2 {
  font-size: 24px; font-weight: 600; margin-bottom: 8px;
}
.auth-form .field {
  margin: 0;
}
.auth-form .field input {
  width: 100%;
  padding: 15px 16px;
  font-size: 16px;
}

.auth-switch {
  text-align: center; color: var(--muted); font-size: 14px; margin-top: 4px;
}
.auth-switch .link {
  background: none; border: none; color: var(--accent);
  cursor: pointer; font-size: 14px; font-weight: 500;
  text-decoration: none;
  transition: color .15s;
}
.auth-switch .link:hover {
  color: var(--accent-2);
  text-decoration: underline;
}

.auth-error {
  background: rgba(255,92,124,.15);
  border: 1px solid rgba(255,92,124,.3);
  color: var(--bad);
  padding: 14px; border-radius: 12px;
  font-size: 14px; text-align: center;
  margin-top: 16px;
  animation: shake .3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.btn-secondary.danger {
  color: var(--bad); border-color: rgba(255,92,124,.3);
}
.btn-secondary.danger:hover {
  background: rgba(255,92,124,.1);
}
