/* Arshara Finance Web — dark theme matching the Android app */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --primary: #4E9AF1; --primary-dim: #1A3A5C;
  --secondary: #2ECC71; --error: #E74C3C;
  --bg: #0F1117; --surface: #1A1D27; --surface2: #252836;
  --text: #E1E1E1; --text-dim: #8892A4; --outline: #2E3347;
  --radius: 12px;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45;
}
.hidden { display: none !important; }
#app { max-width: 560px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; position: relative; }

/* ── Auth ─────────────────────────────── */
.auth-view { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; min-height: 100vh; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 20px; padding: 32px 24px; text-align: center; }
.auth-logo { font-size: 52px; margin-bottom: 8px; }
.auth-card h1 { font-size: 24px; margin-bottom: 4px; }
.auth-tagline { color: var(--text-dim); margin-bottom: 24px; font-size: 14px; }
.auth-card input {
  width: 100%; padding: 14px 14px; margin-bottom: 12px; border-radius: 10px;
  border: 1px solid var(--outline); background: var(--bg); color: var(--text); font-size: 15px; outline: none;
}
.auth-card input:focus { border-color: var(--primary); }
.auth-switch { margin-top: 16px; font-size: 13px; color: var(--text-dim); }
.auth-switch a { color: var(--primary); text-decoration: none; }

/* ── Buttons ──────────────────────────── */
.btn { border: none; border-radius: 10px; padding: 13px 18px; font-size: 15px; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.secondary { background: var(--surface2); color: var(--text); }
.btn.danger { background: var(--error); color: #fff; }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.6; }

/* ── Alerts ───────────────────────────── */
.alert { padding: 11px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 12px; }
.alert.error { background: rgba(231,76,60,.12); color: #ff9c8f; border: 1px solid rgba(231,76,60,.3); }
.alert.success { background: rgba(46,204,113,.12); color: #7ce8a8; border: 1px solid rgba(46,204,113,.3); }

/* ── Top bar ──────────────────────────── */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--surface); border-bottom: 1px solid var(--outline);
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-size: 18px; font-weight: 700; }
.topbar-actions { display: flex; gap: 8px; }
.icon-btn {
  background: var(--surface2); border: none; color: var(--text); font-size: 19px;
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
}

/* ── Pages ────────────────────────────── */
.page { flex: 1; padding: 16px; padding-bottom: 90px; overflow-y: auto; }
.page-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.page-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 16px; }

/* Cards */
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card-row { display: flex; justify-content: space-between; align-items: center; }
.card-row .label { color: var(--text-dim); font-size: 13px; }
.card-row .value { font-weight: 700; font-size: 16px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.stat { background: var(--surface); border-radius: var(--radius); padding: 14px; text-align: center; }
.stat .num { font-size: 18px; font-weight: 800; }
.stat .lbl { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.stat.income .num { color: var(--secondary); }
.stat.expense .num { color: var(--error); }

/* Net worth hero */
.hero { background: linear-gradient(135deg, var(--primary-dim), #12233a); border-radius: 16px; padding: 22px; text-align: center; margin-bottom: 16px; }
.hero .lbl { color: #b8d9f5; font-size: 13px; }
.hero .amount { font-size: 32px; font-weight: 800; color: #fff; margin: 4px 0; }
.hero .sub { color: #8fb6dd; font-size: 12px; }

/* Transactions */
.txn-item { display: flex; align-items: center; padding: 12px 0; border-bottom: 1px solid rgba(46,51,71,.5); }
.txn-item:last-child { border-bottom: none; }
.txn-ic { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; margin-right: 12px; flex-shrink: 0; }
.txn-ic.income { background: rgba(46,204,113,.15); }
.txn-ic.expense { background: rgba(231,76,60,.15); }
.txn-ic.transfer { background: rgba(78,154,241,.15); }
.txn-main { flex: 1; min-width: 0; }
.txn-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.txn-sub { color: var(--text-dim); font-size: 12px; }
.txn-amt { font-weight: 700; font-size: 14px; }
.txn-amt.income { color: var(--secondary); }
.txn-amt.expense { color: var(--error); }
.txn-amt.transfer { color: var(--primary); }

/* List header */
.list-header { display: flex; justify-content: space-between; align-items: center; margin: 18px 0 10px; }
.list-header h3 { font-size: 15px; }
.list-header .link { color: var(--primary); font-size: 13px; cursor: pointer; }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 12px 13px; border-radius: 10px; border: 1px solid var(--outline);
  background: var(--bg); color: var(--text); font-size: 15px; outline: none; font-family: inherit;
}
.form-group input:focus, .form-group select:focus { border-color: var(--primary); }
.form-row { display: flex; gap: 10px; }
.form-row > * { flex: 1; }
.seg { display: flex; background: var(--surface2); border-radius: 10px; padding: 4px; margin-bottom: 14px; }
.seg button { flex: 1; border: none; background: transparent; color: var(--text-dim); padding: 10px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.seg button.active { background: var(--primary); color: #fff; }

/* Accounts */
.acc-group-title { font-size: 13px; color: var(--text-dim); font-weight: 700; margin: 16px 0 8px; text-transform: uppercase; letter-spacing: .5px; }
.acc-item { display: flex; align-items: center; padding: 13px 0; border-bottom: 1px solid rgba(46,51,71,.5); cursor: pointer; }
.acc-item:last-child { border-bottom: none; }
.acc-ic { width: 38px; height: 38px; border-radius: 10px; background: var(--surface2); display: flex; align-items: center; justify-content: center; font-size: 17px; margin-right: 12px; }
.acc-name { font-weight: 600; font-size: 14px; }
.acc-sub { color: var(--text-dim); font-size: 12px; }
.acc-bal { font-weight: 700; text-align: right; }
.acc-bal.liability { color: var(--error); }

/* Charts */
.chart-bar-row { display: flex; align-items: center; margin-bottom: 8px; }
.chart-bar-row .lbl { width: 44px; font-size: 11px; color: var(--text-dim); }
.chart-bar-wrap { flex: 1; background: var(--surface2); border-radius: 4px; height: 14px; overflow: hidden; }
.chart-bar { height: 100%; border-radius: 4px; }
.chart-bar.income { background: var(--secondary); }
.chart-bar.expense { background: var(--error); }
.legend { display: flex; gap: 16px; margin-bottom: 10px; font-size: 12px; color: var(--text-dim); }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; }

/* Pie */
.pie-wrap { display: flex; align-items: center; gap: 16px; }
.pie-legend { flex: 1; }
.pie-row { display: flex; align-items: center; font-size: 13px; margin-bottom: 6px; }
.pie-row .sw { width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; flex-shrink: 0; }
.pie-row .nm { flex: 1; }
.pie-row .vl { color: var(--text-dim); font-size: 12px; }

/* Bottom nav */
#bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 560px;
  display: flex; background: var(--surface); border-top: 1px solid var(--outline);
  z-index: 30; padding-bottom: env(safe-area-inset-bottom);
}
.nav-item { flex: 1; background: none; border: none; color: var(--text-dim); padding: 9px 0 8px; cursor: pointer; font-size: 10px; }
.nav-item .nav-ic { display: block; font-size: 19px; margin-bottom: 2px; }
.nav-item.active { color: var(--primary); }

/* Modal */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal {
  background: var(--surface); width: 100%; max-width: 560px; border-radius: 20px 20px 0 0;
  padding: 20px 20px 30px; max-height: 88vh; overflow-y: auto;
}
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 16px; }
.modal-close { float: right; background: none; border: none; color: var(--text-dim); font-size: 20px; cursor: pointer; }

/* Drawer */
.drawer-mask { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 45; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 280px; max-width: 85vw; background: var(--surface); z-index: 46; padding: 24px 16px; overflow-y: auto; }
.drawer h3 { font-size: 14px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; margin: 18px 0 6px; }
.drawer .user-name { font-size: 17px; font-weight: 700; }
.drawer .user-mail { color: var(--text-dim); font-size: 12px; margin-bottom: 8px; }
.drawer-item { display: flex; align-items: center; width: 100%; background: none; border: none; color: var(--text); padding: 12px 8px; font-size: 15px; cursor: pointer; border-radius: 10px; text-align: left; }
.drawer-item:hover { background: var(--surface2); }
.drawer-item .di-ic { margin-right: 12px; font-size: 18px; }

/* Notifications */
.bell-dot { position: absolute; top: 6px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: #f87171; box-shadow: 0 0 6px rgba(248,113,113,.8); }
.ntf-card { display: flex; gap: 12px; padding: 12px 8px; border-bottom: 1px solid var(--surface2); align-items: flex-start; }
.ntf-ic { font-size: 20px; line-height: 1.3; }
.ntf-title { font-size: 14px; font-weight: 700; }
.ntf-msg { font-size: 13px; color: var(--text-dim); margin-top: 2px; line-height: 1.5; }
.ntf-date { font-size: 11px; color: var(--text-dim); margin-top: 4px; opacity: .7; }

/* Toast */
#toast-root { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 100; }
.toast { background: var(--surface2); color: var(--text); padding: 12px 20px; border-radius: 10px; font-size: 14px; margin-bottom: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.toast.success { border-left: 3px solid var(--secondary); }
.toast.error { border-left: 3px solid var(--error); }

/* Misc */
.empty { text-align: center; color: var(--text-dim); padding: 40px 20px; font-size: 14px; }
.loading { text-align: center; padding: 40px; color: var(--text-dim); }
.spinner { display: inline-block; width: 26px; height: 26px; border: 3px solid var(--surface2); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.chip { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; margin: 2px; }
.chip.blue { background: rgba(78,154,241,.15); color: #8ec5ff; }
.chip.green { background: rgba(46,204,113,.15); color: #7ce8a8; }
.chip.red { background: rgba(231,76,60,.15); color: #ff9c8f; }
.chip.gray { background: var(--surface2); color: var(--text-dim); }
.section-title { font-size: 16px; font-weight: 700; margin: 20px 0 10px; }
.flat-btn { width: 100%; margin-top: 8px; }

/* Auth divider + Google button */
.auth-divider { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--text-dim); font-size: 12px; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
#google-btn-login, #google-btn-register { display: flex; justify-content: center; margin-bottom: 4px; }
#google-btn-login iframe, #google-btn-register iframe { margin: 0 auto; }

/* Custom Google button (works on iOS Safari — no iframe) */
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; max-width: 280px; margin: 0 auto;
  padding: 11px 16px; border: 1px solid var(--border); border-radius: 10px;
  background: #fff; color: #1F1F1F; font-size: 15px; font-weight: 500;
  cursor: pointer; transition: background .15s;
}
.google-btn:hover { background: #F1F3F4; }
.google-btn svg { flex-shrink: 0; }
