:root {
  --bg: #0f172a;
  --surface: #111827;
  --surface-2: #1e293b;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --brand: #22c55e;
  --brand-dark: #16803c;
  --danger: #f87171;
  --warn: #fbbf24;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  min-height: 100vh;
  padding-bottom: calc(72px + var(--safe-bottom));
}

a { color: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: calc(14px + var(--safe-top)) 16px 14px;
  background: linear-gradient(180deg, #0f172a 80%, transparent);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar h1 { font-size: 17px; margin: 0; font-weight: 700; }
.topbar .role-badge {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}

main.screen { padding: 4px 16px 24px; max-width: 640px; margin: 0 auto; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.card h2 { margin: 0 0 12px; font-size: 15px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

.balance-hero {
  text-align: center;
  padding: 22px 16px;
}
.balance-hero .amount { font-size: 34px; font-weight: 800; color: var(--brand); }
.balance-hero .label { color: var(--muted); font-size: 13px; margin-top: 2px; }
.balance-row { display: flex; gap: 10px; margin-top: 14px; }
.balance-chip { flex: 1; background: var(--surface-2); border-radius: 10px; padding: 10px; text-align: center; }
.balance-chip .v { font-weight: 700; font-size: 16px; }
.balance-chip.in .v { color: var(--brand); }
.balance-chip.out .v { color: var(--danger); }
.balance-chip .l { font-size: 11px; color: var(--muted); }

.grid-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.action-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 16px 10px; border-radius: 12px; background: var(--surface-2);
  border: 1px solid var(--border); text-decoration: none; color: var(--text);
  font-size: 13px; font-weight: 600; min-height: 44px;
}
.action-btn .emoji { font-size: 22px; }

form { display: flex; flex-direction: column; gap: 12px; }
label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 5px; font-weight: 500; }

input, select, textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px;
  border-radius: 10px;
  font-size: 15px;
  min-height: 44px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); border-color: var(--brand); }

.btn {
  min-height: 44px;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  padding: 0 16px;
}
.btn-primary { background: var(--brand); color: #052e13; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #3b0a0a; }
.btn-ghost { background: transparent; color: var(--brand); }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 6px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; }
tfoot td { font-weight: 700; border-top: 2px solid var(--border); border-bottom: none; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.badge { font-size: 11px; padding: 3px 9px; border-radius: 999px; font-weight: 700; display: inline-block; }
.badge.pending { background: rgba(251,191,36,.15); color: var(--warn); }
.badge.approved { background: rgba(34,197,94,.15); color: var(--brand); }
.badge.rejected { background: rgba(248,113,113,.15); color: var(--danger); }

.list-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); gap: 10px; }
.list-item:last-child { border-bottom: none; }
.list-item .meta { font-size: 12px; color: var(--muted); }
.list-item .amt { font-weight: 700; }

.empty-state { text-align: center; padding: 30px 10px; color: var(--muted); }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  background: var(--surface); border-top: 1px solid var(--border);
  display: flex; padding-bottom: var(--safe-bottom);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 8px 4px; text-decoration: none; color: var(--muted); font-size: 10px; min-height: 44px;
}
.tabbar a.active { color: var(--brand); }
.tabbar .icon { font-size: 19px; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(84px + var(--safe-bottom));
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; font-size: 14px; z-index: 50; box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.success { border-color: var(--brand); color: var(--brand); }

.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-box { width: 100%; max-width: 380px; }
.auth-box h1 { text-align: center; font-size: 20px; }
.auth-box p.sub { text-align: center; color: var(--muted); font-size: 13px; margin-top: -6px; }
.auth-links { text-align: center; font-size: 13px; margin-top: 4px; }
.auth-links a { color: var(--brand); font-weight: 600; text-decoration: none; }

.helper { font-size: 12px; color: var(--muted); }
.section-title { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 18px 0 8px; font-weight: 700; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 8px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; cursor: pointer; }
.chip.active { background: var(--brand); color: #052e13; border-color: var(--brand); font-weight: 700; }

.spinner { width: 20px; height: 20px; border: 3px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; margin: 20px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.csv-preview { font-size: 12px; }
.csv-row-error { background: rgba(248,113,113,.08); }

.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); }
.checkbox-row input { min-height: auto; width: 18px; height: 18px; }

@media print {
  .tabbar, .topbar, .no-print { display: none !important; }
  body { background: white; color: black; }
  .card { border: 1px solid #ccc; }
}
