/* Friends Savings Manager — mobile-first Bengali UI.
   No external fonts or CDNs: everything must work offline on a cheap Android phone. */

:root {
  --brand: #0f766e;
  --brand-dark: #115e59;
  --brand-soft: #ccfbf1;
  --ink: #14213d;
  --ink-soft: #5b6478;
  --line: #e3e7ee;
  --bg: #f5f7fa;
  --card: #ffffff;
  --good: #15803d;
  --good-soft: #dcfce7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 33, 61, .06), 0 4px 16px rgba(20, 33, 61, .06);
  --tabbar-height: 62px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Noto Sans Bengali', 'Hind Siliguri', 'Kalpurush', 'SolaimanLipi',
               system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  padding-bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
}

.body--centered { display: grid; place-items: center; min-height: 100dvh; padding: 20px 16px; }

a { color: var(--brand-dark); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px calc(10px + env(safe-area-inset-top));
  background: var(--brand); color: #fff;
}
.topbar__brand { display: flex; flex-direction: column; color: #fff; text-decoration: none; min-width: 0; }
.topbar__name { font-size: 1.05rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__tagline { font-size: .78rem; opacity: .85; }
.topbar__me { display: flex; }

/* ---------- layout ---------- */
.page { max-width: 720px; margin: 0 auto; padding: 16px 14px 24px; display: grid; gap: 14px; }
.guest { width: 100%; max-width: 420px; display: grid; gap: 16px; }
.guest__brand { text-align: center; }
.guest__logo {
  width: 62px; height: 62px; margin: 0 auto 10px; border-radius: 20px;
  display: grid; place-items: center; background: var(--brand); color: #fff; font-size: 2rem;
}
.guest__name { margin: 0; font-size: 1.35rem; }
.guest__tagline { margin: 4px 0 0; color: var(--ink-soft); font-size: .9rem; }

/* ---------- cards ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card--center { text-align: center; display: grid; gap: 12px; justify-items: center; }
.card__title { margin: 0 0 10px; font-size: 1rem; font-weight: 700; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card__link { font-size: .85rem; text-decoration: none; }

/* ---------- numbers ---------- */
.stat { display: grid; gap: 2px; }
.stat__label { font-size: .82rem; color: var(--ink-soft); }
.stat__value { font-size: 1.5rem; font-weight: 700; line-height: 1.3; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat-grid--3 { grid-template-columns: repeat(3, 1fr); }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.pill--good { background: var(--good-soft); color: var(--good); }
.pill--bad { background: var(--bad-soft); color: var(--bad); }
.pill--warn { background: var(--warn-soft); color: var(--warn); }
.pill--muted { background: var(--line); color: var(--ink-soft); }

.amount--good { color: var(--good); }
.amount--bad { color: var(--bad); }

.progress { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress__bar { height: 100%; background: var(--brand); border-radius: 999px; }

/* ---------- lists ---------- */
.list { display: grid; gap: 10px; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--line); text-decoration: none; color: inherit;
}
.row:last-child { border-bottom: 0; }
.row__body { flex: 1; min-width: 0; }
.row__title { font-weight: 600; }
.row__meta { font-size: .82rem; color: var(--ink-soft); }
.row__value { text-align: left; font-weight: 700; white-space: nowrap; }

/* ---------- avatar (SPEC §3.7) ---------- */
.avatar { display: inline-grid; place-items: center; border-radius: 50%; object-fit: cover; background: var(--line); flex: none; }
.avatar--sm { width: 34px; height: 34px; font-size: .95rem; }
.avatar--md { width: 46px; height: 46px; font-size: 1.15rem; }
.avatar--lg { width: 92px; height: 92px; font-size: 2.2rem; }
.avatar--letter {
  font-weight: 700; color: hsl(var(--avatar-hue, 170) 45% 28%);
  background: hsl(var(--avatar-hue, 170) 70% 90%);
}

/* ---------- forms ---------- */
.form { display: grid; gap: 14px; }
.form__title { margin: 0; font-size: 1.1rem; }
.form__note, .form__help { margin: 0; font-size: .85rem; color: var(--ink-soft); }
.field { display: grid; gap: 6px; }
.field__label { font-size: .88rem; font-weight: 600; }
.field__hint { font-size: .78rem; color: var(--ink-soft); }
.field__input, .field__select, .field__textarea {
  width: 100%; padding: 12px 14px; font: inherit; color: inherit;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
}
.field__input:focus, .field__select:focus, .field__textarea:focus {
  outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 10px 18px; border: 0; border-radius: 10px;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:active { background: var(--brand-dark); }
.btn--ghost { background: var(--line); color: var(--ink); }
.btn--danger { background: var(--bad-soft); color: var(--bad); }
.btn--block { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- flash ---------- */
.flash-stack { display: grid; gap: 8px; }
.flash { padding: 11px 14px; border-radius: 10px; font-size: .92rem; }
.flash--success { background: var(--good-soft); color: var(--good); }
.flash--error { background: var(--bad-soft); color: var(--bad); }
.flash--info { background: var(--brand-soft); color: var(--brand-dark); }

/* ---------- bottom tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around;
  padding-bottom: env(safe-area-inset-bottom);
  background: #fff; border-top: 1px solid var(--line);
}
.tabbar__item {
  flex: 1; display: grid; place-items: center; gap: 2px; padding: 8px 2px;
  color: var(--ink-soft); text-decoration: none; font-size: .72rem; min-height: var(--tabbar-height);
}
.tabbar__item.is-active { color: var(--brand); font-weight: 700; }
.tabbar__icon { font-size: 1.15rem; line-height: 1; }
.badge {
  min-width: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--bad); color: #fff; font-size: .72rem; font-weight: 700; text-align: center;
}

/* ---------- misc ---------- */
.error__code { font-size: 2.2rem; font-weight: 700; margin: 0; }
.error__message { margin: 0; color: var(--ink-soft); }
.muted { color: var(--ink-soft); }
.empty { text-align: center; color: var(--ink-soft); padding: 18px 0; }
.table-scroll { overflow-x: auto; }

/* ---------- report tables ---------- */
.report-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.report-table th, .report-table td { padding: 8px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
.report-table th:first-child, .report-table td:first-child { text-align: left; }
.report-table thead th { background: var(--bg); font-size: .8rem; color: var(--ink-soft); position: sticky; top: 0; }
.report-table tfoot td { font-weight: 700; border-top: 2px solid var(--line); border-bottom: 0; }
.report-table tbody tr:last-child td { border-bottom: 0; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.toolbar .field { flex: 1 1 140px; }

/* ---------- print ---------- */
.body--print { background: #fff; padding-bottom: 90px; }
.print-sheet { max-width: 900px; margin: 0 auto; padding: 24px 18px; }
.print-head { border-bottom: 2px solid var(--brand); padding-bottom: 10px; margin-bottom: 16px; }
.print-title { margin: 0; font-size: 1.3rem; color: var(--brand); }
.print-sub { margin: 2px 0 0; font-weight: 600; }
.print-meta { margin: 2px 0 0; font-size: .8rem; color: var(--ink-soft); }
.print-foot { margin-top: 22px; padding-top: 10px; border-top: 1px solid var(--line); font-size: .78rem; color: var(--ink-soft); }
.print-actions {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 10px; justify-content: center;
  padding: 12px calc(12px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line);
}
.print-sheet .card { box-shadow: none; padding: 0; margin-bottom: 18px; }

@media print {
  .no-print, .tabbar, .topbar { display: none !important; }
  body { background: #fff; padding: 0; }
  .print-sheet { max-width: none; padding: 0; }
  .report-table { font-size: 10pt; width: 100%; }
  .table-scroll { overflow: visible; }   /* let wide tables print in full */
  .report-table thead th { position: static; background: #eee; }
  .card { break-inside: avoid; }
}
