:root {
  --navy: #0F161D;
  --navy-2: #16202b;
  --navy-3: #1e2b38;
  --brass: #B08D57;
  --brass-2: #c9a877;
  --cream: #ece3d2;
  --muted: #8a97a5;
  --green: #6fae7d;
  --red: #cf7a6a;
  --line: #2a3947;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  background: var(--navy);
  color: var(--cream);
  padding-bottom: calc(66px + var(--safe-bottom));
}

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: linear-gradient(180deg, var(--navy-2), var(--navy));
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.seal { width: 38px; height: 38px; object-fit: contain; }
.brand { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.brand-name { font-size: 18px; letter-spacing: .5px; color: var(--brass-2); }
.entity-filter {
  background: var(--navy-3); color: var(--cream); border: 1px solid var(--line);
  border-radius: 8px; padding: 4px 8px; font-family: inherit; font-size: 13px; max-width: 220px;
}

.view { padding: 16px; max-width: 640px; margin: 0 auto; }

/* Cards / stat tiles */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  background: var(--navy-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
}
.tile .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .8px; }
.tile .value { font-size: 22px; margin-top: 6px; color: var(--cream); }
.tile.wide { grid-column: 1 / -1; }
.value.pos { color: var(--green); }
.value.neg { color: var(--red); }

.section-title {
  font-size: 15px; color: var(--brass-2); margin: 22px 0 10px;
  border-bottom: 1px solid var(--line); padding-bottom: 6px;
}

/* Lists */
.row {
  background: var(--navy-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 8px; display: flex; justify-content: space-between; gap: 10px;
}
.row .main { flex: 1; min-width: 0; }
.row .title { font-size: 15px; }
.row .sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.row .amt { font-size: 16px; white-space: nowrap; }
.amt.income { color: var(--green); }
.amt.expense { color: var(--red); }
.pill {
  display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); margin-left: 6px;
}

/* Forms */
form { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
input, select, textarea, button {
  font-family: inherit; font-size: 16px; /* 16px avoids iOS zoom */
}
input, select, textarea {
  background: var(--navy-2); color: var(--cream); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 12px; width: 100%;
}
textarea { min-height: 64px; resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { flex-direction: row; align-items: center; gap: 8px; color: var(--cream); }
.check input { width: auto; }

.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button {
  flex: 1; background: var(--navy-2); color: var(--muted); border: 0; padding: 11px; font-size: 15px;
}
.seg button.on { background: var(--brass); color: var(--navy); }

.btn {
  background: var(--brass); color: var(--navy); border: 0; border-radius: 10px;
  padding: 13px; font-size: 16px; font-weight: bold; letter-spacing: .3px;
}
.btn.ghost { background: transparent; color: var(--brass-2); border: 1px solid var(--brass); }
.btn:active { opacity: .85; }

.hint { color: var(--muted); font-size: 12px; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(80px + var(--safe-bottom)); background: var(--navy-3);
  border: 1px solid var(--brass); color: var(--cream); padding: 10px 16px;
  border-radius: 999px; font-size: 14px; opacity: 0; transition: opacity .2s; z-index: 30;
}
.toast.show { opacity: 1; }

/* Bottom tab bar */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; background: var(--navy-2); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom); z-index: 20;
}
.tab {
  flex: 1; background: transparent; border: 0; color: var(--muted);
  padding: 12px 4px; font-size: 12px; letter-spacing: .3px;
}
.tab.active { color: var(--brass-2); }

.empty { color: var(--muted); text-align: center; padding: 30px 10px; }
img.receipt-preview { max-width: 100%; border-radius: 10px; border: 1px solid var(--line); margin-top: 6px; }
