/* Large, high-contrast styles so the app is easy to read and tap for older users. */
:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1a1f24;
  --muted: #4f5b66;
  --line: #d3dae0;
  --primary: #1f5f8b;
  --primary-dark: #164866;
  --ok: #1e7b3c;
  --ok-bg: #e3f4e8;
  --warn: #a4400a;
  --warn-bg: #fdecdf;
  --error: #b3261e;
  --radius: 14px;
}

* { box-sizing: border-box; }
html { font-size: 20px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.5;
}
h1 { font-size: 1.6rem; margin: 0 0 .5rem; line-height: 1.25; }
h2 { font-size: 1.25rem; margin: 1.5rem 0 .75rem; }
.card > h2:first-child { margin-top: 0; }
a { color: var(--primary); }
[hidden] { display: none !important; }

.loading { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.wrap { max-width: 640px; margin: 0 auto; padding: 1rem; }
.wrap.wide { max-width: 1200px; }
.center { text-align: center; }
.lead { font-size: 1.05rem; color: var(--muted); margin-top: 0; }
.hint { color: var(--muted); font-size: .85rem; margin: .5rem 0; }
.empty { color: var(--muted); background: var(--card); border: 2px dashed var(--line); border-radius: var(--radius); padding: 1.25rem; text-align: center; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
  background: var(--primary); color: #fff; padding: .75rem 1rem;
}
.brand { font-weight: 700; font-size: 1.05rem; }
.who { display: flex; align-items: center; gap: .75rem; }
.who-name { font-weight: 600; }
.topbar .btn { background: #fff; color: var(--primary); border-color: #fff; }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem; margin: 0 0 1rem; box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.card.narrow { max-width: 480px; margin: 2rem auto; }
.total-card { text-align: center; }
.total-card .label { margin: 0; color: var(--muted); font-weight: 600; }
.big-number { font-size: 2.6rem; font-weight: 800; margin: .25rem 0; color: var(--primary-dark); line-height: 1.1; overflow-wrap: anywhere; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 48px; padding: .6rem 1.1rem; font: inherit; font-weight: 600; font-size: .95rem;
  border: 2px solid var(--primary); background: #fff; color: var(--primary);
  border-radius: 12px; cursor: pointer; text-decoration: none; text-align: center;
}
.btn:hover { background: #eef4f8; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .choice input:focus-visible + span {
  outline: 4px solid #f2b705; outline-offset: 2px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { border-color: var(--error); color: var(--error); }
.btn-danger.btn-primary { background: var(--error); color: #fff; }
.btn-big { width: 100%; min-height: 64px; font-size: 1.15rem; margin: .5rem 0; }
.btn-small { min-height: 40px; padding: .3rem .8rem; font-size: .85rem; }
.row-btns { display: flex; gap: .75rem; justify-content: flex-end; flex-wrap: wrap; margin-top: 1rem; }

/* Forms */
.field { display: block; margin: 0 0 1.1rem; }
.field .label { display: block; font-weight: 700; margin-bottom: .35rem; }
.field .hint { display: block; margin-top: .3rem; }
.optional { font-weight: 400; color: var(--muted); }
input[type=text], input[type=tel], input[type=password], input[type=date], input[type=month], input[type=number], select, textarea {
  width: 100%; font: inherit; font-size: 1.1rem; padding: .7rem .8rem; min-height: 56px;
  border: 2px solid #8a98a5; border-radius: 10px; background: #fff; color: var(--text);
}
textarea { min-height: 90px; resize: vertical; }
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .6rem; }
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span {
  display: flex; align-items: center; justify-content: center; min-height: 56px; padding: .4rem;
  border: 2px solid #8a98a5; border-radius: 10px; font-weight: 600; text-align: center;
}
.choice input:checked + span { border-color: var(--primary); background: var(--primary); color: #fff; }
.file-btn { position: relative; }
.file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.preview { margin-top: .6rem; }
.preview img { max-width: 100%; max-height: 260px; border-radius: 10px; border: 1px solid var(--line); display: block; margin-bottom: .5rem; }
.check-row { display: flex; gap: .75rem; align-items: flex-start; font-weight: 600; cursor: pointer; }
.check-row input { width: 28px; height: 28px; flex: none; margin-top: .1rem; }

.error {
  color: var(--error); background: #fdeceb; border: 2px solid var(--error); border-radius: 10px;
  padding: .7rem .9rem; font-weight: 600; margin: .75rem 0;
}
.notice { border-radius: 10px; padding: .8rem 1rem; margin: 0 0 1rem; font-weight: 600; }
.notice.ok { background: var(--ok-bg); color: var(--ok); border: 2px solid var(--ok); }
.notice.warn { background: var(--warn-bg); color: var(--warn); border: 2px solid var(--warn); }

/* Confirmation summary */
.summary { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0 0 1rem; font-size: 1.05rem; }
.summary dt { font-weight: 700; color: var(--muted); }
.summary dd { margin: 0; overflow-wrap: anywhere; }
.success-mark {
  width: 88px; height: 88px; margin: .5rem auto 1rem; border-radius: 50%;
  background: var(--ok); color: #fff; font-size: 3rem; display: flex; align-items: center; justify-content: center;
}

/* Donation lists (donor and student) */
.list { list-style: none; padding: 0; margin: 0; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: .75rem; }
.item-main { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; flex-wrap: wrap; }
.item-amount { font-size: 1.35rem; font-weight: 800; }
.item-date { color: var(--muted); font-weight: 600; }
.item-meta, .item-note { color: var(--muted); font-size: .95rem; overflow-wrap: anywhere; }
.item-foot { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-top: .35rem; }
.badge { display: inline-block; padding: .1rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 700; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.plain { background: #e9edf0; color: var(--muted); }

/* Admin */
.tabs { display: flex; gap: .25rem; overflow-x: auto; background: #fff; border-bottom: 1px solid var(--line); padding: 0 .5rem; }
.tab {
  padding: .8rem 1rem; text-decoration: none; color: var(--muted); font-weight: 600; white-space: nowrap;
  border-bottom: 4px solid transparent;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; }
.stat .label { color: var(--muted); font-weight: 600; font-size: .9rem; }
.stat .value { font-size: 1.8rem; font-weight: 800; line-height: 1.2; margin: .2rem 0; overflow-wrap: anywhere; }
.stat .sub { font-size: .85rem; color: var(--muted); }
.stat.warn { border: 2px solid var(--warn); background: var(--warn-bg); }
.stat.warn .value, .stat.warn .sub { color: var(--warn); }
.stat.ok { border: 2px solid var(--ok); background: var(--ok-bg); }
.stat.ok .value, .stat.ok .sub { color: var(--ok); }
.ok-text { color: var(--ok); font-weight: 700; }
.warn-text { color: var(--warn); font-weight: 700; }

.toolbar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin-bottom: 1rem; }
.toolbar .field { margin: 0; flex: 1 1 180px; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1rem; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: .6rem .75rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #eef2f5; font-weight: 700; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
td select { min-height: 40px; font-size: .9rem; padding: .3rem; width: auto; }
td .btn { margin: 0 .25rem .25rem 0; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--primary); text-decoration: underline; cursor: pointer; text-align: left; }
.addform { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 1rem; align-items: end; }

dialog.dlg {
  border: 0; border-radius: var(--radius); padding: 1.25rem; width: min(560px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem); box-shadow: 0 10px 40px rgba(0,0,0,.3);
}
dialog.dlg::backdrop { background: rgba(10, 20, 30, .5); }
dialog.dlg h2 { margin-top: 0; }

@media (max-width: 560px) {
  html { font-size: 18px; }
  .wrap { padding: .75rem; }
  .summary { grid-template-columns: 1fr; gap: 0; }
  .summary dd { margin-bottom: .5rem; }
}

/* ---------------------------------------------------------------- confirmations by the student */
.confirm { margin-top: .5rem; font-weight: 700; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.confirm-confirmed { color: var(--ok); }
.confirm-waiting { color: var(--muted); }
.confirm-overdue { color: var(--warn); }
.badge.new { background: #f2b705; color: #1a1f24; }

/* Donor metrics */
.metrics { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6rem; }
.metrics .stat { padding: .75rem .9rem; }
.metrics .stat .value { font-size: 1.45rem; }
.metrics .stat:first-child { grid-column: 1 / -1; text-align: center; }
.metrics .stat:first-child .value { font-size: 2.4rem; color: var(--primary-dark); }

/* List / Calendar / By month switch */
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: .25rem; background: #e3e8ec; padding: .25rem; border-radius: 12px; margin-bottom: 1rem; }
.seg { min-height: 48px; border: 0; border-radius: 9px; background: transparent; font: inherit; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg.active { background: #fff; color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,.15); }

/* Calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; font-size: 1.15rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-wd { text-align: center; font-size: .75rem; font-weight: 700; color: var(--muted); padding: .2rem 0; }
.cal-cell {
  min-height: 58px; border-radius: 8px; background: #f4f6f8; border: 2px solid transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: .25rem .1rem;
  font: inherit; color: var(--text);
}
.cal-cell.empty { background: transparent; }
.cal-cell.today { border-color: var(--primary); }
.cal-cell.has { cursor: pointer; }
.cal-cell.has.ok { background: var(--ok-bg); }
.cal-cell.has.wait { background: #e9edf0; }
.cal-cell.has.warn { background: var(--warn-bg); }
.cal-cell.picked { border-color: #f2b705; }
.cal-num { font-weight: 700; font-size: .9rem; }
.cal-amt { font-size: .62rem; font-weight: 700; line-height: 1.1; overflow-wrap: anywhere; text-align: center; }
.cal-legend { text-align: center; }
.dot { display: inline-block; width: .8em; height: .8em; border-radius: 50%; vertical-align: middle; }
.dot.ok { background: var(--ok); }
.dot.wait { background: #9aa7b2; }
.dot.warn { background: var(--warn); }

/* Monthly bars */
.bars { display: grid; gap: .45rem; }
.bar-row { display: grid; grid-template-columns: 4.2em 1fr auto; gap: .6rem; align-items: center; font-size: .9rem; }
.bar-label { color: var(--muted); font-weight: 600; }
.bar-track { display: flex; height: 22px; background: #eef2f5; border-radius: 6px; overflow: hidden; }
.bar-fill { display: block; height: 100%; width: 0; }
.bar-fill.ok { background: var(--ok); }
.bar-fill.wait { background: #9aa7b2; }
.bar-value { font-weight: 700; min-width: 4.5em; text-align: right; }

/* ---------------------------------------------------------------- the student's money in / out */
.item-amount.in { color: var(--ok); }
.item-amount.out { color: var(--warn); }
.two-btns { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.two-btns .btn-big { margin: .25rem 0; font-size: 1.05rem; }
.btn-out { background: var(--warn); border-color: var(--warn); }
.btn-out:hover { background: #7f3108; }
.bars.cats .bar-row { grid-template-columns: minmax(6.5em, 9em) 1fr auto; }
.bar-fill.spend { background: var(--primary); }
@media (max-width: 400px) {
  .two-btns { grid-template-columns: 1fr; }
  .bars.cats .bar-row { grid-template-columns: 1fr auto; }
  .bars.cats .bar-track { grid-column: 1 / -1; grid-row: 2; }
}

/* ---------------------------------------------------------------- two-step login */
.steps { padding-left: 1.3rem; }
.steps li { margin-bottom: .4rem; }
.qr { display: block; width: 220px; height: 220px; margin: .5rem auto; background: #fff; padding: 8px; border: 1px solid var(--line); border-radius: 12px; }
.secret { font-size: .85rem; word-break: break-all; background: #eef2f5; padding: .1rem .3rem; border-radius: 4px; }
.captcha { margin: .25rem 0 .75rem; min-height: 65px; }
.who { flex-wrap: wrap; justify-content: flex-end; }

/* ---------------------------------------------------------------- demo build only */
.demo-banner {
  background: #fff4cc; color: #5c4600; border-bottom: 2px solid #f2b705;
  padding: .45rem 1rem; font-size: .85rem; text-align: center;
}
.demo-accounts {
  background: #eef4f8; border: 2px dashed var(--primary); border-radius: 12px;
  padding: .8rem; margin: 0 0 1rem; display: grid; gap: .5rem;
}
.demo-accounts .btn { width: 100%; justify-content: flex-start; }
.demo-accounts .hint { margin: 0; }
