/* Expense Tracker — modernized AndroMoney look.
   Dark header, teal accent, red expense amounts, olive account names.
   Mobile first; on desktop the app stays a centered phone-width column. */
* { box-sizing: border-box; }
:root {
  --header: #23272b;
  --header-soft: #2e3438;
  --teal: #00897b;
  --teal-dark: #00695c;
  --red: #e53935;
  --blue: #1e88e5;
  --green: #43a047;
  --olive: #7a8c1f;
  --bg: #f4f4f4;
  --card: #ffffff;
  --line: #e3e3e3;
  --text: #222222;
  --muted: #777777;
}
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #e9e9e9;
  color: var(--text);
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app { max-width: 560px; margin: 0 auto; background: var(--bg); min-height: 100vh; position: relative; padding-bottom: 110px; }

/* ---------- Header ---------- */
.app-header {
  background: var(--header); color: #fff;
  display: flex; align-items: center; gap: 4px;
  padding: 10px 8px;
  position: sticky; top: 0; z-index: 40;
}
.icon-btn { background: none; border: 0; color: #fff; font-size: 24px; line-height: 1; padding: 8px 10px; cursor: pointer; border-radius: 8px; }
.icon-btn.dark { color: #fff; }
.icon-btn:active { background: rgba(255,255,255,.12); }
.header-spacer { flex: 1; }
.period-btn { background: none; border: 0; color: #fff; font-size: 19px; padding: 8px 6px; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.period-btn .caret { font-size: 12px; opacity: .8; }

/* ---------- Period navigator ---------- */
.period-nav { background: #ececec; display: flex; align-items: center; padding: 10px 4px; }
.nav-arrow { background: none; border: 0; color: #42a5f5; font-size: 44px; line-height: 1; padding: 0 14px; cursor: pointer; }
.nav-arrow.small { font-size: 34px; padding: 0 10px; }
.period-title { flex: 1; text-align: center; }
.period-title-line { font-size: 19px; }
.period-total-line { font-size: 19px; margin-top: 2px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 56px; z-index: 30; }
.tab { flex: 1; background: none; border: 0; border-bottom: 3px solid transparent; padding: 13px 4px 11px; font-size: 16px; color: #888; cursor: pointer; }
.tab.active { color: var(--text); border-bottom-color: var(--teal); font-weight: 600; }

/* ---------- Summary ---------- */
.summary { background: #fff; padding: 10px 16px 12px; border-bottom: 1px solid var(--line); }
.summary-row { display: flex; justify-content: space-between; align-items: baseline; padding: 3px 0; gap: 12px; }
.summary-row span:first-child { color: var(--text); }
.summary-row.total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; font-weight: 700; }
.amt-red { color: var(--red); font-weight: 600; }
.amt-blue { color: var(--blue); font-weight: 600; }
.amt-green { color: var(--green); font-weight: 600; }
#sumTop { text-align: right; }

/* ---------- Views / cards ---------- */
.view { display: none; }
.view.active { display: block; }
.card { background: var(--card); margin: 12px; padding: 14px 16px; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.card h3 { margin: 0 0 10px; font-size: 16px; }
.hint { color: var(--muted); font-size: 14px; margin: 12px 16px; }
.empty { text-align: center; color: var(--muted); padding: 48px 24px; font-size: 15px; }
.list-more { text-align: center; padding: 12px; }

/* ---------- Transaction rows ---------- */
.tx-list { background: #fff; }
.tx-row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-bottom: 1px solid #f0f0f0; cursor: pointer; background: #fff; width: 100%; border-left: 0; border-right: 0; border-top: 0; text-align: left; font: inherit; }
.tx-row:active { background: #f2f8f7; }
.tx-icon { width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 26px; flex: none; }
.tx-main { flex: 1; min-width: 0; }
.tx-title { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-sub { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.tx-amt { text-align: right; flex: none; }
.tx-amt .amt { color: var(--red); font-size: 17px; font-weight: 600; }
.tx-amt .amt.income { color: var(--green); }
.tx-amt .acct { color: var(--olive); font-size: 14px; margin-top: 2px; }
.tx-row.future { opacity: .55; }

/* ---------- Bars (report / budget) ---------- */
.bar-row { margin: 10px 0; }
.bar-label { display: flex; justify-content: space-between; font-size: 15px; margin-bottom: 4px; }
.bar-track { background: #eeeeee; border-radius: 6px; height: 10px; overflow: hidden; }
.bar-fill { background: var(--teal); height: 100%; border-radius: 6px; }
.bar-fill.over { background: var(--red); }

/* ---------- Buttons ---------- */
.btn { border: 0; border-radius: 8px; padding: 12px 18px; font-size: 16px; cursor: pointer; background: #eeeeee; color: var(--text); }
.btn.primary { background: var(--teal); color: #fff; }
.btn.danger { background: var(--red); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid #cccccc; }
.btn.block { display: block; width: 100%; margin: 8px 0; }
.btn:active { opacity: .85; }
label.btn { text-align: center; }

/* ---------- FAB ---------- */
.fab {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  width: 68px; height: 68px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--teal); color: #fff; font-size: 30px;
  box-shadow: 0 4px 14px rgba(0,0,0,.35); z-index: 50;
}
.fab:active { background: var(--teal-dark); }

/* ---------- Drawer ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 60; }
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: 300px; max-width: 82vw;
  background: var(--header); color: #fff; z-index: 61;
  transform: translateX(-105%); transition: transform .22s ease; display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head { padding: 20px 16px; border-bottom: 1px solid #3a4045; display: flex; align-items: center; gap: 12px; }
.drawer-avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--teal); display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; }
.drawer-email { font-size: 15px; word-break: break-all; }
.drawer-menu { padding: 8px 0; flex: 1; overflow-y: auto; }
.drawer-menu button { display: flex; align-items: center; gap: 16px; width: 100%; background: none; border: 0; color: #fff; font-size: 17px; padding: 14px 20px; cursor: pointer; text-align: left; }
.drawer-menu button:active { background: #3a4045; }
.drawer-menu .mi { font-size: 20px; width: 26px; text-align: center; }
.drawer-foot { padding: 14px 20px; color: #999; font-size: 13px; border-top: 1px solid #3a4045; }

/* ---------- Popup menus ---------- */
.popup-menu { position: fixed; z-index: 70; background: #fff; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.3); min-width: 170px; overflow: hidden; }
.popup-menu button { display: block; width: 100%; background: none; border: 0; text-align: left; padding: 13px 18px; font-size: 16px; cursor: pointer; }
.popup-menu button:active { background: #f0f0f0; }

/* ---------- Login ---------- */
.login-screen { position: fixed; inset: 0; background: var(--bg); z-index: 80; display: flex; align-items: flex-start; justify-content: center; padding: 72px 20px 20px; }
.login-card { background: #fff; border-radius: 16px; padding: 28px 22px; width: 100%; max-width: 380px; box-shadow: 0 4px 20px rgba(0,0,0,.12); text-align: center; }
.login-icon { width: 72px; height: 72px; border-radius: 22px; background: var(--teal); color: #fff; font-size: 40px; font-weight: 700; display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }
.login-card h1 { margin: 0 0 6px; font-size: 22px; }
.login-card label { display: block; text-align: left; font-size: 14px; color: var(--muted); margin: 14px 0 6px; }
.login-card input { width: 100%; font-size: 17px; padding: 12px; border: 1px solid #ccc; border-radius: 8px; }
.error { color: var(--red); font-size: 14px; margin-top: 8px; text-align: left; }

/* ---------- Entry sheet ---------- */
.sheet { position: fixed; inset: 0; background: #fff; z-index: 55; overflow-y: auto; max-width: 560px; margin: 0 auto; }
.sheet.small { max-width: 560px; }
.sheet-head { background: var(--header); color: #fff; display: flex; align-items: center; padding: 8px; position: sticky; top: 0; z-index: 5; }
.entry-tabs { display: flex; flex: 1; justify-content: center; gap: 4px; }
.entry-tab { background: none; border: 0; color: #bbb; font-size: 15px; font-weight: 700; padding: 10px 12px; cursor: pointer; border-bottom: 3px solid transparent; }
.entry-tab.active { color: #fff; border-bottom-color: #80cbc4; }
.amount-row { display: flex; align-items: center; gap: 8px; padding: 18px 20px 0; }
.amount-currency { color: #c9a227; font-size: 20px; }
#amountInput { flex: 1; border: 0; outline: 0; font-size: 40px; text-align: right; color: var(--red); background: none; min-width: 0; }
.amount-underline { height: 6px; background: #ffeb3b; margin: 4px 20px 0; border-radius: 3px; }
.date-row { display: flex; align-items: center; background: #f0f0f0; margin-top: 14px; padding: 6px 0; }
.date-field { flex: 1; background: none; border: 0; font-size: 17px; cursor: pointer; text-align: center; padding: 6px; }
.date-field span { display: block; }
.date-field #timeLabel { font-size: 15px; color: var(--muted); }
.form-rows { padding: 4px 0; }
.form-row { display: flex; align-items: center; gap: 10px; width: 100%; background: #fff; border: 0; border-bottom: 1px solid var(--line); padding: 15px 16px; font-size: 16px; cursor: pointer; text-align: left; }
.form-row.static { cursor: default; }
.row-label { color: var(--muted); flex: none; min-width: 86px; }
.row-value { flex: 1; color: var(--text); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-value.green { color: var(--green); }
.row-icon { font-size: 24px; flex: none; }
#noteInput, #projectInput { flex: 1; border: 0; outline: 0; font-size: 16px; text-align: right; min-width: 0; }
.check-row { justify-content: flex-start; }
.check-wrap { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.check-wrap input { width: 20px; height: 20px; accent-color: var(--teal); }
.sheet-actions { padding: 16px; }

/* ---------- Keypad ---------- */
.keypad { display: grid; grid-template-columns: 1fr 1fr 2fr; gap: 0; padding: 12px 16px 4px; max-width: 480px; margin: 0 auto; }
.key { border: 2px solid #fff; font-size: 26px; padding: 13px 0; cursor: pointer; color: #fff; border-radius: 4px; }
.key:active { opacity: .8; }
.key-num { background: #42a5f5; }
.key-op { background: #ffa726; }
.key-ac { background: #ef5350; }
.key-del { background: #616161; }
.key-ok { background: #66bb6a; }
.key-zero { grid-column: span 1; }

/* ---------- Modals ---------- */
.modal { position: fixed; inset: 0; background: #fff; z-index: 65; overflow-y: auto; max-width: 560px; margin: 0 auto; }
.modal-head { background: var(--header); color: #fff; display: flex; align-items: center; padding: 8px; position: sticky; top: 0; z-index: 5; }
.modal-title { font-size: 19px; flex: 1; padding-left: 6px; }
.modal-title small { display: block; font-size: 13px; color: #bbb; font-weight: 400; }
.modal-body { padding: 16px; }
.modal-body input[type="text"] { width: 100%; font-size: 17px; padding: 12px; border: 1px solid #ccc; border-radius: 8px; margin-bottom: 12px; }
.modal-body hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.picker-two { display: flex; min-height: calc(100vh - 60px); }
.picker-left { width: 46%; border-right: 1px solid var(--line); overflow-y: auto; }
.picker-right { flex: 1; background: #f7f7f7; overflow-y: auto; }
.picker-item { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 0; border-bottom: 1px solid #f0f0f0; padding: 14px 12px; font-size: 16px; cursor: pointer; text-align: left; }
.picker-item .pi-icon { font-size: 22px; flex: none; }
.picker-item.selected { color: var(--green); font-weight: 600; background: #eef7ee; }
.picker-item.starred { color: var(--green); }
.picker-list { padding: 4px 0; }
.picker-list.two-col { display: grid; grid-template-columns: 1fr 1fr; }
.picker-list.two-col .picker-item { border-bottom: 1px solid #f0f0f0; }
.search-bar { padding: 10px 12px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.search-bar input { width: 100%; font-size: 16px; padding: 11px 12px; border: 1px solid #ccc; border-radius: 8px; }
.add-payee { display: flex; gap: 8px; padding: 12px; position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--line); }
.add-payee input { flex: 1; font-size: 16px; padding: 11px 12px; border: 1px solid #ccc; border-radius: 8px; min-width: 0; }

/* ---------- Confirm / toast ---------- */
.confirm { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 90; display: flex; align-items: center; justify-content: center; padding: 20px; }
.confirm-card { background: #fff; border-radius: 14px; padding: 22px; width: 100%; max-width: 340px; }
.confirm-card p { margin: 0 0 18px; font-size: 17px; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; }
.toast { position: fixed; bottom: 110px; left: 50%; transform: translateX(-50%); background: #323232; color: #fff; padding: 12px 20px; border-radius: 24px; font-size: 15px; z-index: 95; max-width: 90vw; text-align: center; }

@media (min-width: 561px) {
  body { background: #dcdcdc; }
  .sheet, .modal { box-shadow: 0 0 30px rgba(0,0,0,.25); }
}
