/* FTAQUIO Taxpayer Portal — self-contained, mobile-first. No external assets. */
:root {
  --navy: #1877f2; --navy-deep: #0d5dc9; --navy-soft: #4293f5;
  --gold: #4293f5; --gold-light: #b3d4ff;
  --cream: #f0f2f5; --cream-2: #e4e6eb;
  --text: #1c1e21; --text-soft: #65676b; --muted: #8a8d91;
  --line: #dadde1; --bg: #ffffff;
  --danger: #d92d20; --success: #15803d; --warning: #b45309;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px; line-height: 1.5; color: var(--text); background: var(--cream);
  -webkit-text-size-adjust: 100%;
}
a { color: var(--navy); }
h1 { font-size: 1.35rem; margin: 0 0 0.25rem; }
h2 { font-size: 1.02rem; color: var(--navy); margin: 0 0 0.6rem; }
.muted { color: var(--text-soft); }
.small { font-size: 0.82rem; }
.mono { font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.hidden { display: none !important; }

/* ---------- app shell ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center;
  justify-content: space-between; gap: 0.75rem;
  background: var(--bg); border-bottom: 1px solid var(--line);
  padding: 0.7rem 1rem; padding-top: calc(0.7rem + env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 0.55rem; text-decoration: none; color: inherit; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; background: var(--navy); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.05rem;
}
.brand-name { font-weight: 800; letter-spacing: 0.02em; line-height: 1; }
.brand-tag { font-size: 0.62rem; color: var(--muted); letter-spacing: 0.16em; }
.hdr-user { text-align: right; font-size: 0.78rem; color: var(--text-soft); max-width: 45vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-main { max-width: 820px; margin: 0 auto; padding: 1rem 1rem 6rem; }

/* bottom tab bar */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: var(--bg); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; text-decoration: none; color: var(--text-soft);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 0.5rem 0.25rem; font-size: 0.68rem; font-weight: 600;
}
.tabbar a .ic { font-size: 1.15rem; line-height: 1; }
.tabbar a.active { color: var(--navy); }
.tabbar .badge-dot {
  position: absolute; transform: translate(0.7rem, -0.35rem);
  background: var(--danger); color: #fff; border-radius: 999px;
  font-size: 0.6rem; min-width: 1.05rem; height: 1.05rem; padding: 0 3px;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ---------- cards / tiles ---------- */
.card {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem; margin-bottom: 1rem;
}
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.tile-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.7rem; margin-bottom: 1rem; }
.tile {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.85rem 0.95rem;
}
.tile .label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.tile .value { font-size: 1.28rem; font-weight: 800; margin-top: 0.15rem; font-variant-numeric: tabular-nums; }
.tile .sub { font-size: 0.72rem; color: var(--text-soft); margin-top: 0.1rem; }
.tile.accent { background: linear-gradient(135deg, var(--navy), var(--navy-deep)); border-color: transparent; color: #fff; }
.tile.accent .label, .tile.accent .sub { color: rgba(255,255,255,0.82); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  font: inherit; font-weight: 700; font-size: 0.9rem; cursor: pointer;
  border: 1px solid var(--line); background: var(--cream-2); color: var(--text);
  border-radius: 9px; padding: 0.6rem 1rem; text-decoration: none; line-height: 1;
}
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.small { padding: 0.4rem 0.65rem; font-size: 0.8rem; border-radius: 7px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: default; }
.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.8rem; }
.field label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-soft); font-weight: 700; }
.field input, .field select, .field textarea {
  font: inherit; padding: 0.6rem 0.7rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(24,119,242,.12);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.7rem; }
.form-grid .row { grid-column: 1 / -1; }
.hint { font-size: 0.72rem; color: var(--muted); }

/* ---------- badges / lists ---------- */
.badge { display: inline-block; padding: 0.12rem 0.5rem; border-radius: 999px; font-size: 0.7rem; font-weight: 700; background: var(--cream-2); color: var(--text-soft); }
.badge.draft { background: #eef0f2; color: #4b4f56; }
.badge.submitted { background: #fef3c7; color: #6b5400; }
.badge.approved { background: #dcfce7; color: #14532d; }
.badge.rejected { background: #fee2e2; color: #7f1d1d; }
.sub-item { display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem 0; border-bottom: 1px solid var(--line); }
.sub-item:last-child { border-bottom: none; }
.sub-item .grow { flex: 1; min-width: 0; }
.sub-item .t { font-weight: 700; }
.sub-item .m { font-size: 0.78rem; color: var(--text-soft); }
.sub-amt { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }

/* ---------- charts (mirrors admin SVG chart classes) ---------- */
.charts-row { display: flex; flex-direction: column; gap: 1rem; margin: 0.25rem 0 1rem; }
.chart-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.85rem 1rem; background: var(--bg); }
.chart-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.5rem; }
.chart-title { font-weight: 700; color: var(--navy); font-size: 0.88rem; }
.chart { width: 100%; height: auto; display: block; }
.chart .c-bar { transition: opacity 0.12s; }
.c-axis { fill: var(--text-soft); font-size: 11px; font-family: inherit; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; }
.chart-legend.col { flex-direction: column; gap: 0.3rem; }
.lg-item { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.78rem; color: var(--text); }
.lg-dot { width: 0.7rem; height: 0.7rem; border-radius: 3px; display: inline-block; flex: none; }
.lg-name { white-space: nowrap; }
.lg-val { margin-left: auto; }
.donut-wrap { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.donut { flex: none; }
.donut-total { fill: var(--navy); font-size: 20px; font-weight: 700; font-family: inherit; }
.donut-wrap .chart-legend.col { flex: 1; min-width: 160px; }

/* ---------- toast + modal ---------- */
.toast {
  position: fixed; left: 50%; top: 1rem; transform: translateX(-50%); z-index: 60;
  background: var(--text); color: #fff; padding: 0.6rem 1rem; border-radius: 8px; font-size: 0.85rem;
  max-width: 92vw; box-shadow: 0 6px 22px rgba(0,0,0,0.25);
}
.toast.success { background: var(--success); }
.toast.danger { background: var(--danger); }
.modal-bg { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,0.5); display: flex; align-items: flex-end; justify-content: center; }
.modal {
  background: var(--bg); width: 100%; max-width: 560px; border-radius: 16px 16px 0 0;
  max-height: 92vh; overflow-y: auto; padding: 1.1rem 1.1rem calc(1.1rem + env(safe-area-inset-bottom));
  position: relative;
}
.modal-close { position: absolute; top: 0.5rem; right: 0.6rem; background: none; border: none; font-size: 1.6rem; line-height: 1; color: var(--muted); cursor: pointer; }
@media (min-width: 640px) {
  .modal-bg { align-items: center; }
  .modal { border-radius: 16px; }
  .tile-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- receipt capture (document scanner) ---------- */
.receipts { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0; }
.receipt-thumb { position: relative; width: 76px; height: 76px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: var(--cream-2); }
.receipt-thumb img { width: 100%; height: 100%; object-fit: cover; }
.receipt-thumb .x { position: absolute; top: 1px; right: 1px; background: rgba(0,0,0,0.6); color: #fff; border: none; border-radius: 6px; width: 20px; height: 20px; font-size: 0.9rem; line-height: 1; cursor: pointer; }
.cap {
  position: fixed; inset: 0; z-index: 70; background: #000; display: flex; flex-direction: column;
}
.cap video, .cap canvas, .cap img.preview { width: 100%; flex: 1; object-fit: contain; background: #000; min-height: 0; }
.cap-frame { position: absolute; inset: 0; pointer-events: none; }
.cap-frame .edge { position: absolute; width: 26px; height: 26px; border: 3px solid rgba(255,255,255,0.9); }
.cap-frame .tl { top: 12%; left: 8%; border-right: none; border-bottom: none; border-radius: 6px 0 0 0; }
.cap-frame .tr { top: 12%; right: 8%; border-left: none; border-bottom: none; border-radius: 0 6px 0 0; }
.cap-frame .bl { bottom: 16%; left: 8%; border-right: none; border-top: none; border-radius: 0 0 0 6px; }
.cap-frame .br { bottom: 16%; right: 8%; border-left: none; border-top: none; border-radius: 0 0 6px 0; }
.cap-hint { position: absolute; top: calc(12% - 2rem); left: 0; right: 0; text-align: center; color: #fff; font-size: 0.82rem; text-shadow: 0 1px 3px rgba(0,0,0,0.6); }
.cap-bar {
  display: flex; align-items: center; justify-content: space-around; gap: 1rem;
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom)); background: #000;
}
.cap-bar button { background: none; border: none; color: #fff; font-weight: 700; font-size: 0.95rem; cursor: pointer; padding: 0.5rem; }
.shutter { width: 66px; height: 66px; border-radius: 50%; background: #fff; border: 4px solid rgba(255,255,255,0.4); cursor: pointer; }
.cap-err { color: #fff; text-align: center; padding: 2rem 1.5rem; }

/* generic table for the transaction encode confirm */
table.data { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
table.data th, table.data td { text-align: left; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--line); }
table.data td.amount { text-align: right; font-variant-numeric: tabular-nums; }
.spinner { text-align: center; color: var(--muted); padding: 2rem; }
