@font-face {
  font-family: "Noto Sans Malayalam";
  src: url(/fonts/noto-sans-malayalam-malayalam-400-normal.woff2) format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Noto Sans Malayalam";
  src: url(/fonts/noto-sans-malayalam-malayalam-700-normal.woff2) format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --green: #14532d;
  --green-2: #166534;
  --green-bg: #f0fdf4;
  --red: #b91c1c;
  --red-bg: #fef2f2;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f6f7f5;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Malayalam", sans-serif;
  font-size: 17px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
}
#app { max-width: 640px; margin: 0 auto; padding-bottom: 96px; }

header.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: var(--green); color: #fff;
}
header.top h1 { flex: 1; margin: 0; font-size: 18px; font-weight: 700; }
header.top button {
  background: rgba(255,255,255,.15); color: #fff; border: 0;
  border-radius: 8px; padding: 7px 11px; font: inherit; font-size: 15px;
}

main { padding: 14px; }
h2 { font-size: 18px; margin: 22px 0 8px; }
h2:first-child { margin-top: 4px; }
.muted { color: var(--muted); font-size: 15px; }

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

/* Institution tabs */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 12px 14px 0; }
.tabs button {
  flex: 1 0 auto; border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 999px; padding: 8px 12px; font: inherit; font-size: 15px; white-space: nowrap;
}
.tabs button.on { background: var(--green-2); border-color: var(--green-2); color: #fff; font-weight: 700; }

/* Month picker */
.period { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.period .label { flex: 1; text-align: center; font-weight: 700; font-size: 18px; }
.period button.arrow { width: 44px; height: 44px; font-size: 22px; padding: 0; }
.dates { display: flex; gap: 8px; margin-bottom: 12px; }
.dates label { flex: 1; }
.link { background: none; border: 0; color: var(--green-2); font: inherit; font-size: 15px; text-decoration: underline; padding: 4px 0; }

/* Summary */
.sum-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.sum-row:last-child { border-bottom: 0; }
.sum-row b { font-variant-numeric: tabular-nums; }
.sum-row.total { font-size: 20px; font-weight: 700; padding-top: 10px; }
.in { color: var(--green-2); }
.out { color: var(--red); }
.sum-row.short { color: var(--red); }
.short-word { display: inline-block; background: var(--red-bg); color: var(--red); border-radius: 6px; padding: 0 8px; margin-left: 6px; font-size: 15px; }

.list-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row b { white-space: nowrap; font-variant-numeric: tabular-nums; }

.entry { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; font: inherit; color: inherit; text-align: left; }
.entry:last-child { border-bottom: 0; }
.entry .what { flex: 1; min-width: 0; }
.entry .what div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry .amt { font-weight: 700; white-space: nowrap; }

/* Forms */
label { display: block; margin-bottom: 14px; font-size: 15px; color: var(--muted); }
input, select, textarea {
  display: block; width: 100%; margin-top: 5px;
  font: inherit; font-size: 17px; color: var(--ink);
  padding: 11px 12px; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff;
}
input.big { font-size: 26px; font-weight: 700; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green-2); border-color: transparent; }

.btn {
  display: block; width: 100%; border: 0; border-radius: 12px;
  padding: 13px 16px; font: inherit; font-size: 17px; font-weight: 700;
  background: var(--green-2); color: #fff; text-align: center;
}
.btn.light { background: #fff; color: var(--green-2); border: 1px solid var(--green-2); }
.btn.red { background: var(--red); }
.btn.red-light { background: #fff; color: var(--red); border: 1px solid var(--red); }
.btn + .btn { margin-top: 10px; }
.btn:disabled { opacity: .6; }
button { cursor: pointer; }
.small-btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 10px; font: inherit; font-size: 14px; color: var(--ink); }

.choice { display: flex; gap: 8px; margin-top: 5px; }
.choice button {
  flex: 1; padding: 12px 6px; border-radius: 10px; border: 1px solid #cbd5e1;
  background: #fff; font: inherit; font-size: 15px; color: var(--ink);
}
.choice button.on { background: var(--green-2); color: #fff; border-color: var(--green-2); font-weight: 700; }
.choice.kind button.on.expense { background: var(--red); border-color: var(--red); }

.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; gap: 10px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: #fff; border-top: 1px solid var(--line);
  max-width: 640px; margin: 0 auto;
}
.bottom-bar .btn { margin: 0; }
.bottom-bar .btn + .btn { margin: 0; }

.note { background: #fffbeb; border: 1px solid #fde68a; border-radius: 12px; padding: 12px; margin-bottom: 14px; font-size: 15px; }
.error { color: var(--red); font-size: 15px; margin: -4px 0 12px; }

.login { max-width: 400px; margin: 0 auto; padding: 32px 18px; }
.login h1 { color: var(--green); font-size: 24px; margin: 18px 0 4px; }
.lang-switch { text-align: right; }

#toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 10;
  background: #111827; color: #fff; border-radius: 10px; padding: 10px 16px; font-size: 15px;
}
.row-actions { display: flex; gap: 6px; }
.pay-grid { display: grid; grid-template-columns: 1fr auto auto; gap: 8px 14px; align-items: baseline; }
.pay-grid b { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pay-grid .muted { text-align: right; }
.user-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.user-row:last-child { border-bottom: 0; }
.user-row .row-actions { margin-top: 8px; flex-wrap: wrap; }
.dates label { min-width: 0; }
.dates input { min-width: 0; padding-left: 8px; padding-right: 6px; }
.code { letter-spacing: 6px; font-size: 22px; }
.masjid-photo { display: block; width: 100%; height: auto; aspect-ratio: 450 / 300; object-fit: cover; object-position: center 40%; border-radius: 14px; margin-top: 12px; }
.login .lang-switch + .masjid-photo + h1 { margin-top: 14px; }
