/* Fonts are hosted with the site (no third-party requests). Both are SIL Open Font License. */
@font-face { font-family: "Instrument Sans"; src: url("../fonts/instrument-sans.woff2") format("woff2");
  font-weight: 400 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Young Serif"; src: url("../fonts/young-serif.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap; }

/* WinKredo — banknote-inspired identity.
   One memorable thing: money figures set large in an engraved-looking serif,
   framed by a fine guilloche line pattern. Everything else stays quiet. */

:root {
  --ink: #17231d;          /* text */
  --treasury: #1e5a44;     /* primary: banknote green */
  --treasury-deep: #143f30;
  --paper: #f2f5f1;        /* cool note-paper background */
  --sheet: #ffffff;
  --line: #d5ddd6;
  --gold: #b8901f;         /* "Win" accent, used sparingly */
  --debit: #a3332f;        /* violations and errors */
  --muted: #5b6b62;
  --focus: #2d7fd3;
  --radius-s: 6px;
  --radius-l: 14px;
  --serif: "Young Serif", "Georgia", serif;
  --sans: "Instrument Sans", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  font-variant-numeric: tabular-nums;
}
a { color: var(--treasury); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

h1, h2, h3 { font-weight: 600; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; max-width: 68ch; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: inherit; }
.brand-mark { width: 38px; height: 38px; flex: none; }
.auth-logo { height: 52px; width: auto; }
.brand-name { font-family: var(--serif); font-size: 1.3rem; letter-spacing: .01em; }
.brand-name b { color: var(--gold); font-weight: inherit; }
.brand-by { display: block; font-size: .75rem; color: var(--muted); font-family: var(--sans); }

/* ---------- Money: the signature element ---------- */
.note {
  position: relative;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 1.1rem 1.25rem;
  overflow: hidden;
}
.note::before {             /* fine guilloche-like engraving along the top edge */
  content: ""; position: absolute; inset: 0 0 auto 0; height: 7px;
  background:
    repeating-radial-gradient(circle at 0 100%, transparent 0 3px, var(--treasury) 3px 3.6px, transparent 3.6px 6px);
  background-size: 12px 7px;
  opacity: .55;
}
.note-label { color: var(--muted); font-size: .9rem; margin: .2rem 0 .1rem; }
.money { font-family: var(--serif); font-size: 2.1rem; line-height: 1.1; color: var(--treasury-deep); }
.money.sm { font-size: 1.35rem; }
.money.neg { color: var(--debit); }
.notes { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 1.5rem; }

/* ---------- Sign-in pages ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth-card { width: 100%; max-width: 400px; background: var(--sheet); border: 1px solid var(--line);
  border-radius: var(--radius-l); padding: 2rem 1.75rem; }
.auth-card .brand { margin-bottom: 1.5rem; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--treasury-deep); color: #e8efe9; padding: 1.25rem 1rem; display: flex; flex-direction: column; gap: 1.25rem; }
.side .brand-name, .side .brand-by { color: #fff; }
.side .brand-by { color: #a9c1b4; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button {
  all: unset; cursor: pointer; padding: .55rem .75rem; border-radius: var(--radius-s);
  color: #d6e3da; font-size: .95rem;
}
.nav button:hover { background: rgba(255,255,255,.07); }
.nav button[aria-current="page"] { background: rgba(255,255,255,.12); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.nav button:focus-visible { outline: 3px solid var(--focus); }
.nav-group { font-size: .78rem; color: #8fab9c; padding: .75rem .75rem .25rem; }
.side-foot { margin-top: auto; font-size: .85rem; color: #a9c1b4; }
.side-foot button { all: unset; cursor: pointer; color: #fff; text-decoration: underline; }
.main { padding: 2rem clamp(1rem, 3vw, 2.5rem); max-width: 1100px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head p { margin: 0; }

/* ---------- Panels, tables, forms ---------- */
.panel { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 1.25rem; margin-bottom: 1.25rem; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: .85rem; border-bottom: 1px solid var(--line); padding: .5rem .6rem; }
td { border-bottom: 1px solid #edf1ee; padding: .55rem .6rem; vertical-align: middle; }
td.num, th.num { text-align: right; }
tr:last-child td { border-bottom: 0; }

label { display: block; font-size: .9rem; font-weight: 600; margin-bottom: .3rem; }
.field { margin-bottom: .9rem; }
.field .hint { font-weight: 400; color: var(--muted); font-size: .82rem; }
input, select, textarea {
  font: inherit; width: 100%; padding: .55rem .7rem; border: 1px solid #b9c6bd;
  border-radius: var(--radius-s); background: #fff; color: var(--ink);
}
textarea { min-height: 120px; }
.row { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.btn {
  font: inherit; font-weight: 600; cursor: pointer; border: 1px solid transparent;
  border-radius: var(--radius-s); padding: .55rem 1rem; background: var(--treasury); color: #fff;
}
.btn:hover { background: var(--treasury-deep); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--treasury); border-color: #b9c6bd; }
.btn.secondary:hover { background: #eef3ef; }
.btn.danger { background: var(--debit); }
.btn.sm { padding: .3rem .65rem; font-size: .85rem; }
.btn.block { width: 100%; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.tag { display: inline-block; font-size: .78rem; padding: .1rem .5rem; border-radius: 999px; background: #e7eee9; color: var(--treasury-deep); }
.tag.planned { background: #eef0f6; color: #3d4a6b; }
.tag.closed { background: #eceeed; color: var(--muted); }
.tag.violation { background: #f7e8e7; color: var(--debit); }

.msg { padding: .65rem .85rem; border-radius: var(--radius-s); margin-bottom: 1rem; font-size: .92rem; }
.msg.error { background: #f9e9e8; color: #7a201d; }
.msg.ok { background: #e6f2ea; color: #1b4d37; }
.empty { color: var(--muted); padding: 1rem 0; }

/* ---------- Give & take ---------- */
.student-results { display: grid; gap: .4rem; margin-top: .6rem; }
.student-btn {
  all: unset; cursor: pointer; display: flex; justify-content: space-between; gap: 1rem;
  padding: .6rem .8rem; border: 1px solid var(--line); border-radius: var(--radius-s); background: #fff;
}
.student-btn:hover { border-color: var(--treasury); }
.student-btn:focus-visible { outline: 3px solid var(--focus); }
.choice-grid { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.choice {
  all: unset; cursor: pointer; padding: .75rem .9rem; border-radius: var(--radius-s);
  border: 1px solid var(--line); background: #fff; display: flex; justify-content: space-between; gap: .75rem;
}
.choice:hover { border-color: var(--treasury); }
.choice:focus-visible { outline: 3px solid var(--focus); }
.choice:disabled { opacity: .45; cursor: not-allowed; }
.choice .amt { font-family: var(--serif); color: var(--treasury-deep); white-space: nowrap; }
.choice.violation .amt { color: var(--debit); }

/* ---------- Confirm dialog ---------- */
dialog { border: 0; border-radius: var(--radius-l); padding: 0; width: min(420px, 92vw); }
dialog::backdrop { background: rgba(15, 30, 22, .45); }
.dialog-body { padding: 1.5rem; }
.confirm-amount { font-family: var(--serif); font-size: 2.4rem; color: var(--treasury-deep); margin: .25rem 0 .75rem; }
.confirm-amount.violation { color: var(--debit); }

.toast { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: .7rem 1.1rem; border-radius: var(--radius-s);
  font-size: .95rem; max-width: 90vw; z-index: 50; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; align-items: center; padding: .75rem 1rem; gap: .75rem; }
  .nav { flex-direction: row; flex-wrap: wrap; width: 100%; }
  .nav-group { display: none; }
  .side-foot { margin-top: 0; margin-left: auto; }
  .main { padding: 1.25rem 1rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Store ---------- */
.thumb { width: 56px; height: 56px; border-radius: var(--radius-s); object-fit: cover; display: block; background: var(--paper); }
.no-photo { display: grid; place-items: center; background: var(--paper); border: 1px dashed var(--line); }
.no-photo img { width: 40%; opacity: .35; }
.item-grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.item-card {
  all: unset; cursor: pointer; display: flex; flex-direction: column; background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius-l); overflow: hidden;
}
.item-card:hover { border-color: var(--treasury); }
.item-card:focus-visible { outline: 3px solid var(--focus); }
.item-card:disabled { opacity: .45; cursor: not-allowed; }
.item-photo { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.item-body { padding: .6rem .75rem .75rem; display: flex; flex-direction: column; gap: .25rem; }
.item-name { font-weight: 600; }
.item-meta { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.item-meta .amt { font-family: var(--serif); font-size: 1.15rem; color: var(--treasury-deep); }
label.btn { display: inline-block; }
.item-photo.no-photo, .thumb.no-photo { display: grid; place-items: center; }
.item-photo.no-photo img { width: 28%; }
.main:focus { outline: none; }

/* ---------- Footer ---------- */
.site-foot { padding: 2rem 1rem 2.5rem; text-align: center; color: var(--muted); }
.foot-links { display: flex; gap: 1.5rem; justify-content: center; flex-wrap: wrap; }
.foot-links a { color: var(--muted); text-decoration: none; }
.foot-links a:hover { color: var(--treasury); text-decoration: underline; }
.foot-by { margin: .6rem auto 0; font-size: .95rem; max-width: none; }
.foot-by a { color: var(--ink); font-weight: 600; text-decoration: none; }
.foot-cards { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  max-width: 1100px; margin: 1.5rem auto 0; text-align: left; }
.foot-card { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius-l);
  padding: 1.25rem; display: flex; flex-direction: column; }
.foot-card h3 { color: var(--treasury); font-size: 1.15rem; margin-bottom: .4rem; }
.foot-card p { font-size: .95rem; flex: 1; }
.foot-card strong { color: var(--ink); }
.foot-cta { align-self: flex-start; background: var(--treasury); color: #fff; font-weight: 600; text-decoration: none;
  padding: .55rem 1rem; border-radius: var(--radius-s); }
.foot-cta.dark { background: var(--ink); }
.foot-cta:hover { filter: brightness(1.15); }
.auth-wrap { min-height: auto; padding-top: 3rem; }
.app-foot { padding: 2rem 0 0; }

/* ---------- Policy pages ---------- */
.legal { max-width: 760px; margin: 0 auto; padding: 2rem 1.25rem 0; }
.legal header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.legal header img { height: 44px; }
.legal h1 { font-family: var(--serif); font-weight: 400; font-size: 2rem; margin-bottom: .25rem; }
.legal h2 { margin-top: 2rem; font-size: 1.15rem; }
.legal h3 { margin-top: 1.25rem; font-size: 1rem; }
.legal p, .legal li { max-width: 70ch; }
.legal ul { padding-left: 1.25rem; }
.legal li { margin-bottom: .4rem; }
.legal .caps { text-transform: none; font-size: .95rem; }
.legal .agent { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 1rem 1.25rem; }

/* ---------- Starter list ---------- */
.starter-cols { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
label.check { display: flex; gap: .6rem; align-items: center; font-weight: 400; margin: 0 0 .35rem; cursor: pointer; }
label.check input { width: auto; }
label.check .amt { margin-left: auto; font-family: var(--serif); color: var(--treasury-deep); white-space: nowrap; }
label.check .amt.violation { color: var(--debit); }

/* ---------- Student view ---------- */
.stu-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .9rem clamp(1rem, 3vw, 2rem); background: var(--treasury-deep); color: #fff; }
.stu-head .brand-name { color: #fff; }
.stu-head .brand-by, .stu-head .muted { color: #a9c1b4; }
.stu-tabs { display: flex; gap: .25rem; flex-wrap: wrap; padding: .5rem clamp(1rem, 3vw, 2rem); background: var(--sheet); border-bottom: 1px solid var(--line); }
.stu-tabs button { all: unset; cursor: pointer; padding: .5rem .85rem; border-radius: var(--radius-s); color: var(--muted); font-weight: 600; }
.stu-tabs button[aria-current="page"] { background: var(--paper); color: var(--treasury-deep); box-shadow: inset 0 -3px 0 var(--gold); }
.stu-tabs button:focus-visible { outline: 3px solid var(--focus); }
.stu-main { max-width: 1000px; margin: 0 auto; padding: 1.5rem clamp(1rem, 3vw, 2rem); }
.stu-main:focus { outline: none; }
.item-card.dim { opacity: .5; }
.item-card.auction { cursor: default; }
.bid-form { margin-top: .4rem; }
.bid-form label { margin-bottom: .2rem; }
td.num { white-space: nowrap; }

.qr-small { width: 110px; height: 110px; flex: none; }
.qr-small svg { width: 100%; height: 100%; display: block; }

/* ---------- Attendance in the teacher view ---------- */
.att-box { background: #fbf4f3; border: 1px solid #efd9d7; border-radius: var(--radius-s); padding: .75rem .9rem; margin-bottom: 1rem; }
.att-row { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .35rem 0; border-bottom: 1px solid #f1e3e1; font-size: .92rem; }
.att-row:last-of-type { border-bottom: 0; }

/* ---------- Plans ---------- */
.nav-prem { font-size: .66rem; background: rgba(184,144,31,.25); color: #f1d98c; border-radius: 999px; padding: .05rem .4rem; margin-left: .25rem; vertical-align: middle; }
.plan-banner { background: #e7eee9; border: 1px solid #c9d8cf; color: var(--treasury-deep); border-radius: var(--radius-s); padding: .6rem .9rem; margin-bottom: 1rem; font-size: .92rem; }
.plan-banner.warn { background: #fdf3e2; border-color: #efd7a6; color: #6b4d07; }
.plan-banner a { font-weight: 600; }
.upgrade ul { padding-left: 1.2rem; }

/* ---------- Impact report ---------- */
.impact-head { display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem; }
.impact-head img { height: 44px; }
.bar-row { display: grid; grid-template-columns: 90px 1fr 190px; gap: .75rem; align-items: center; margin-bottom: .4rem; }
.bar { display: flex; height: 14px; background: #eef2ef; border-radius: 7px; overflow: hidden; }
.bar-t { background: var(--gold); }
.bar-a { background: var(--debit); }
.bar-label { font-size: .85rem; color: var(--muted); }
@media print {
  .side, .no-print, .plan-banner, .site-foot { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  .note, .panel { break-inside: avoid; }
}
