:root {
  --board:   #1f3a33;   /* chalkboard green */
  --ink:     #1b2a26;
  --paper:   #f3f5f4;
  --surface: #ffffff;
  --pencil:  #e9b824;   /* pencil yellow, used for the main action */
  --line:    #d3dbd8;
  --owing:   #a63d2a;
  --cleared: #2e7350;
  --serif:   Charter, "Bitstream Charter", "Iowan Old Style", Georgia, serif;
  --sans:    system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
}

h1, h2, h3, .brand, .receipt { font-family: var(--serif); }
h1 { font-size: 1.9rem; margin: 0 0 .75rem; }
h2 { font-size: 1.3rem; margin: 2rem 0 .5rem; }
h3 { font-size: 1.05rem; margin: 1.25rem 0 .25rem; }
small { color: #55655f; font-weight: 400; font-size: .85em; }
a { color: #1c5c47; }
code { background: #e4eae7; padding: 0 .3em; border-radius: 3px; }

/* ---- Top bar ---- */
.topbar {
  background: var(--board);
  color: #f3f5f4;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .5rem 2rem;
  padding: .75rem 1.25rem;
  border-bottom: 4px solid var(--pencil);
}
.topbar a { color: inherit; text-decoration: none; }
.topbar nav { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; margin-left: auto; }
.topbar nav a { padding: .25rem 0; border-bottom: 2px solid transparent; }
.topbar nav a:hover, .topbar nav a:focus-visible { border-bottom-color: var(--pencil); }
.brand { font-size: 1.25rem; font-weight: 700; display: inline-flex; align-items: center; gap: .5rem; }
.brand span { font-weight: 400; opacity: .75; }
.brand-logo { height: 1.8rem; width: auto; border-radius: 3px; }
.settings-preview { display: block; max-height: 4rem; margin: .4rem 0; border: 1px solid var(--line); background: #fff; padding: .25rem; }

main { max-width: 60rem; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

/* ---- Messages ---- */
.flash { padding: .65rem .9rem; border-left: 4px solid; background: var(--surface); margin: 0 0 1.25rem; }
.flash-ok    { border-color: var(--cleared); }
.flash-error { border-color: var(--owing); }
.empty { padding: .9rem 1rem; background: var(--surface); border: 1px dashed var(--line); }

/* ---- Tables ---- */
table { width: 100%; border-collapse: collapse; background: var(--surface); margin: .5rem 0 1rem; }
th, td { padding: .55rem .75rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: baseline; }
th { font-weight: 600; background: #e8eeeb; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.owing { color: var(--owing); font-weight: 600; }
.cleared { color: var(--cleared); }
tr.void td { color: #7b8a84; text-decoration: line-through; }
@media (max-width: 40rem) { table { display: block; overflow-x: auto; } }

/* ---- Totals ---- */
.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 1rem; margin: 1rem 0; }
.totals div { background: var(--surface); padding: .9rem 1rem; border-top: 3px solid var(--line); }
.totals .owing { border-top-color: var(--owing); }
.totals dt { font-size: .85rem; color: #55655f; }
.totals dd { margin: .15rem 0 0; font: 700 1.5rem var(--serif); font-variant-numeric: tabular-nums; }

/* ---- Forms ---- */
label { display: block; font-weight: 600; margin-bottom: 1rem; }
label small { font-weight: 400; }
input, select, button { font: inherit; }
input, select {
  display: block; width: 100%; max-width: 26rem; margin-top: .25rem;
  padding: .5rem .6rem; border: 1px solid #9fb0a9; border-radius: 4px; background: #fff; color: var(--ink);
}
button {
  background: var(--pencil); color: #2a2200; font-weight: 700;
  border: 0; border-radius: 4px; padding: .6rem 1.1rem; cursor: pointer;
}
button:hover { filter: brightness(.95); }
:focus-visible { outline: 3px solid #2b7bd6; outline-offset: 2px; }
form.inline { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0 .75rem; }
form.inline label { margin-bottom: 1rem; }
form.inline button { margin-bottom: 1rem; }
.stack { margin: 1.25rem 0; }
details.stack summary { cursor: pointer; font-weight: 600; margin-bottom: .75rem; }
.discount-row { border-bottom: 1px solid var(--line); padding-bottom: .75rem; margin-bottom: .75rem; }
.discount-row label { min-width: 14rem; }
.charge-block { border-bottom: 1px solid var(--line); padding-bottom: 1rem; margin-bottom: 1rem; }
.charge-block table { margin: .5rem 0; }
.charge-block form.inline label { min-width: 10rem; }
.bill-block { margin: 1.5rem 0 2rem; }
.bill-block h3 { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.bill-block h4 { margin: 1rem 0 .3rem; font-size: .9rem; }
tfoot th { text-align: left; border-top: 2px solid var(--ink); }
.empty-cell { color: #9aa8a2; }
input.cell { max-width: 7rem; padding: .35rem .4rem; }

.btn-link {
  display: inline-block; background: var(--pencil); color: #2a2200; font-weight: 700;
  border-radius: 4px; padding: .6rem 1.1rem; text-decoration: none;
}
label.checkbox { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
label.checkbox input { width: auto; margin: 0; }
.row-actions { display: flex; gap: .75rem; align-items: baseline; white-space: nowrap; }
.row-actions form { margin: 0; display: inline; }
.link-btn {
  background: none; border: 0; padding: 0; color: var(--owing); font-weight: 600;
  cursor: pointer; text-decoration: underline;
}

/* ---- Dashboard ---- */
.term-badge {
  display: inline-block; background: var(--board); color: #fff; font-weight: 600;
  padding: .3rem .8rem; border-radius: 4px; margin: -.5rem 0 1.25rem; font-size: .9rem;
}
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 1rem; margin: 1rem 0 1.5rem; }
.kpi-card { color: #fff; border-radius: 6px; padding: 1rem 1.1rem; }
.kpi-num { font: 700 1.7rem var(--serif); font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi-label { font-size: .85rem; opacity: .9; margin-top: .3rem; }
.kpi-cyan   { background: #2596be; }
.kpi-green  { background: #2e9e5b; }
.kpi-blue   { background: #1f5fa8; }
.kpi-amber  { background: #c98a1c; }
.kpi-red    { background: #b33f3f; }
.kpi-dark   { background: #1b2a26; }
.kpi-orange { background: #c9702f; }
.kpi-purple { background: #6a4c93; }

.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 1.25rem; margin: 1.5rem 0; }
.chart-card { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 1rem 1.1rem 1.25rem; }
.chart-card h2 { margin: 0 0 .75rem; font-size: 1rem; }
.chart-card canvas { max-height: 18rem; }

.login { max-width: 22rem; margin: 3rem auto; }
.results { list-style: none; padding: 0; background: var(--surface); }
.results li { padding: .55rem .75rem; border-bottom: 1px solid var(--line); }
.child { margin-bottom: 2.5rem; }

/* ---- Receipt: a slip with a tear-off edge ---- */
.toolbar { display: flex; gap: 1.25rem; align-items: center; margin-bottom: 1rem; }
.receipt {
  max-width: 26rem; margin: 0 auto; background: var(--surface);
  padding: 1.5rem 1.5rem 1.25rem; border: 1px solid var(--line);
  border-bottom: 2px dashed #8ea19a;
}
.receipt header { text-align: center; border-bottom: 1px solid var(--line); padding-bottom: .75rem; margin-bottom: 1rem; }
.receipt .school { margin: 0; font-size: 1.05rem; font-weight: 700; }
.receipt h1 { font-size: 1.1rem; font-weight: 400; margin: .1rem 0; }
.receipt .no { margin: 0; font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.receipt dl { margin: 0 0 1rem; }
.receipt dl div { display: flex; justify-content: space-between; gap: 1rem; padding: .2rem 0; }
.receipt dt { color: #55655f; }
.receipt dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.receipt .amount { display: flex; justify-content: space-between; align-items: baseline; margin: 1rem 0; padding: .6rem 0; border-block: 2px solid var(--ink); }
.receipt .amount strong { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.receipt .bal dt, .receipt .bal dd { font-weight: 700; color: var(--ink); }
.receipt footer { margin-top: 1rem; font-size: .85rem; color: #55655f; text-align: center; }
.void-banner { text-align: center; font-weight: 700; color: var(--owing); border: 2px solid var(--owing); padding: .4rem; }

@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  main { padding: 0; }
  .receipt { border: 0; border-bottom: 2px dashed #000; max-width: none; }
}

/* ---- Console shell (sidebar layout for staff) ---- */
:root {
  --sidebar-bg: #16232a;
  --sidebar-bg-active: #22333d;
  --sidebar-text: #c7d3d0;
  --console-topbar: #2f80b5;
}

.app-shell { display: flex; min-height: 100vh; align-items: stretch; }
.sidebar-toggle-input { display: none; }

.sidebar {
  width: 15.5rem; flex-shrink: 0; background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  transition: margin-left .2s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.25rem; font: 700 1.1rem var(--serif);
  color: #fff; border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .brand-logo { height: 1.6rem; width: auto; border-radius: 3px; }
.sidebar-nav { padding: .75rem 0 1.5rem; }
.sidebar-heading {
  font-size: .72rem; letter-spacing: .06em; color: #7f8f8c; padding: 1rem 1.25rem .35rem;
}
.sidebar-link {
  display: flex; align-items: center; gap: .6rem; padding: .6rem 1.25rem; color: var(--sidebar-text);
  text-decoration: none; border-left: 3px solid transparent; font-size: .95rem;
}
.sidebar-link:hover { background: var(--sidebar-bg-active); color: #fff; }
.sidebar-link.active { background: var(--sidebar-bg-active); color: #fff; border-left-color: var(--pencil); font-weight: 600; }
.sidebar-icon { font-size: 1.05rem; width: 1.3rem; text-align: center; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--paper); }
.console-topbar {
  background: var(--console-topbar); color: #fff; display: flex; align-items: center;
  padding: .6rem 1.25rem; gap: 1rem;
}
.console-topbar-spacer { flex: 1; }
.sidebar-burger {
  display: none; font-size: 1.3rem; cursor: pointer; background: none; border: 0; color: #fff;
}
.console-user { display: flex; align-items: center; gap: .6rem; }
.avatar-circle {
  width: 2rem; height: 2rem; border-radius: 50%; background: rgba(255,255,255,.25);
  display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0;
}
.console-user-text { display: flex; flex-direction: column; font-size: .8rem; line-height: 1.3; }
.status-dot { display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; background: #4caf6a; margin-right: .25rem; }
.sign-out-link { padding: .3rem .7rem; border: 1px solid rgba(255,255,255,.5); border-radius: 4px; color: #fff !important; }
.sign-out-link:hover { background: rgba(255,255,255,.15); }

.breadcrumb { padding: .75rem 1.5rem 0; font-size: .85rem; color: #55655f; }
.breadcrumb a { color: inherit; }
.main-col main { padding: .75rem 1.5rem 3rem; max-width: none; margin: 0; }

@media (max-width: 55rem) {
  .sidebar { position: fixed; z-index: 20; margin-left: -15.5rem; }
  .sidebar-toggle-input:checked ~ .sidebar { margin-left: 0; box-shadow: 4px 0 12px rgba(0,0,0,.3); }
  .sidebar-burger { display: inline-block; }
}
