/* ==========================================================================
   SPHSMS — Fees, Payroll & Accounting
   Brand palette: maroon, cream, navy, gold.
   ========================================================================== */

:root {
  --maroon:        #7b1e28;
  --maroon-dark:   #5a141c;
  --maroon-tint:   #f5e6e7;
  --navy:          #14213d;
  --navy-soft:     #e8ebf2;
  --cream:         #fbf6ec;
  --cream-deep:    #f4ecdd;
  --surface:       #ffffff;
  --gold:          #c8a227;
  --gold-tint:     #fbf1d4;

  --ink:           #1b1b1f;
  --ink-soft:      #4a4a55;
  --muted:         #71717f;
  --line:          #e3ddd1;
  --line-strong:   #cfc7b6;

  /* Ink: used as text on the tinted pill backgrounds below. */
  --unpaid:        #a52218;
  --unpaid-bg:     #fdeceb;
  --partial:       #8f5a00;
  --partial-bg:    #fdf2df;
  --paid:          #14653c;
  --paid-bg:       #e7f4ec;

  /* Fill: used for chart marks on white. This trio is validated for colour-vision
     separation (worst adjacent pair ΔE 16.8 CVD / 22.7 normal). The amber is
     lighter than the ink above, which fails as text but is what makes it
     distinguishable from the red as a filled shape. */
  --unpaid-fill:   #a52218;
  --partial-fill:  #c08500;
  --paid-fill:     #14653c;

  --radius:        14px;
  --radius-sm:     9px;
  --shadow:        0 1px 2px rgba(20, 33, 61, .06), 0 8px 24px rgba(20, 33, 61, .06);
  --shadow-lift:   0 2px 6px rgba(20, 33, 61, .08), 0 16px 40px rgba(20, 33, 61, .10);

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; color: var(--navy); margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p  { margin: 0 0 12px; }
a  { color: var(--maroon); }

/* ---------- App frame ---------------------------------------------------- */

.app { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--navy);
  color: #dfe3ec;
  padding: 22px 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 0 6px; }
.brand__mark {
  width: 40px; height: 40px; flex: none;
  border-radius: 11px;
  background: linear-gradient(150deg, var(--maroon) 0%, var(--maroon-dark) 100%);
  border: 1px solid rgba(200, 162, 39, .55);
  display: grid; place-items: center;
  font-family: var(--serif); font-size: 16px; font-weight: 600; color: var(--gold);
}
.brand__name { font-family: var(--serif); font-size: 17px; color: #fff; line-height: 1.15; }
.brand__sub  { font-size: 11.5px; color: #9aa4bb; letter-spacing: .04em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav__group { margin-top: 14px; }
.nav__label {
  font-size: 10.5px; letter-spacing: .11em; text-transform: uppercase;
  color: #7f8aa5; padding: 0 10px 7px;
}
.nav__link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: #cdd4e2; text-decoration: none;
  font-size: 14.5px;
  transition: background .15s ease, color .15s ease;
}
.nav__link:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav__link.is-active { background: var(--maroon); color: #fff; box-shadow: inset 0 0 0 1px rgba(200,162,39,.4); }
.nav__icon { width: 18px; text-align: center; opacity: .9; font-size: 15px; }

.sidebar__footer { margin-top: auto; border-top: 1px solid rgba(255,255,255,.1); padding-top: 14px; }
.who { padding: 0 8px 10px; }
.who__name { color: #fff; font-size: 14px; }
.who__role { font-size: 12px; color: #97a1b8; }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: rgba(251, 246, 236, .88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 14px 32px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 20;
}
.topbar__title { flex: 1; min-width: 200px; }
.topbar__subtitle { font-size: 13.5px; color: var(--muted); margin-top: 2px; }

.content { padding: 26px 32px 60px; max-width: 1120px; width: 100%; }

/* ---------- Cards -------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card__head {
  padding: 18px 22px 0;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.card__body { padding: 20px 22px 22px; }
.card__hint { font-size: 13px; color: var(--muted); margin-top: 4px; }

.stack { display: flex; flex-direction: column; gap: 18px; }
.grid  { display: grid; gap: 18px; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(196px, 1fr)); }

/* ---------- Forms -------------------------------------------------------- */

.form { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 13.5px; font-weight: 600; color: var(--navy); }
.field__hint  { font-size: 12.5px; color: var(--muted); }
.field--inline { flex-direction: row; align-items: center; gap: 10px; }

.row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

input[type=text], input[type=search], input[type=number], input[type=date],
input[type=month], input[type=password], input[type=tel], select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--maroon);
  box-shadow: 0 0 0 3px rgba(123, 30, 40, .13);
}
input::placeholder, textarea::placeholder { color: #a6a6b2; }
input:disabled, select:disabled { background: var(--cream-deep); color: var(--muted); }

input.input--money { font-size: 22px; font-weight: 600; padding: 14px 14px 14px 62px; font-variant-numeric: tabular-nums; }
.money-wrap { position: relative; }
.money-wrap__symbol {
  position: absolute; left: 15px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 15px; font-weight: 600; pointer-events: none;
}

.quick-amounts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* ---------- Buttons ------------------------------------------------------ */

.btn {
  font: inherit; font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 11px 18px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--primary { background: var(--maroon); color: #fff; box-shadow: 0 1px 2px rgba(90,20,28,.3); }
.btn--primary:hover:not(:disabled) { background: var(--maroon-dark); }
.btn--ghost { background: var(--surface); color: var(--navy); border-color: var(--line-strong); }
.btn--ghost:hover:not(:disabled) { background: var(--cream-deep); }
.btn--quiet { background: transparent; color: var(--maroon); padding: 6px 8px; }
.btn--quiet:hover { text-decoration: underline; }
.btn--danger { background: var(--surface); color: var(--unpaid); border-color: #eccbc8; }
.btn--danger:hover:not(:disabled) { background: var(--unpaid-bg); }
.btn--lg { padding: 14px 26px; font-size: 16px; }
.btn--block { width: 100%; }
.btn--chip { padding: 7px 13px; font-size: 13.5px; border-radius: 999px; background: var(--cream-deep); color: var(--navy); border-color: var(--line); }
.btn--chip:hover { background: var(--gold-tint); border-color: var(--gold); }

.actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* ---------- Advanced disclosure ------------------------------------------ */

.advanced { border-top: 1px dashed var(--line-strong); padding-top: 16px; }
.advanced__toggle {
  background: none; border: none; padding: 0; font: inherit; font-weight: 600;
  color: var(--maroon); cursor: pointer; display: inline-flex; align-items: center; gap: 7px;
}
.advanced__toggle::before { content: "＋"; font-size: 14px; line-height: 1; }
.advanced[open] .advanced__toggle::before { content: "－"; }
.advanced__panel { margin-top: 16px; display: flex; flex-direction: column; gap: 16px; }
.advanced__panel[hidden] { display: none; }

/* ---------- Status ------------------------------------------------------- */

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill--unpaid  { background: var(--unpaid-bg);  color: var(--unpaid); }
.pill--partial { background: var(--partial-bg); color: var(--partial); }
.pill--paid    { background: var(--paid-bg);    color: var(--paid); }
.pill--neutral { background: var(--navy-soft);  color: var(--navy); }
.pill--gold    { background: var(--gold-tint);  color: #7a5f00; }

/* ---------- Numbers ------------------------------------------------------ */

.stat { padding: 20px 22px; }
.stat__label { font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: .01em; }
.stat__value {
  font-family: var(--sans); font-size: 31px; font-weight: 650; color: var(--navy);
  margin-top: 6px; line-height: 1.15; letter-spacing: -0.02em;
}
.stat__note { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Tables ------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.data th {
  text-align: left; font-size: 12px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); font-weight: 700; padding: 0 14px 10px; white-space: nowrap;
}
table.data td { padding: 12px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:hover { background: var(--cream); }
table.data .right, table.data th.right { text-align: right; }
.row-link { cursor: pointer; }

/* ---------- Search picker ------------------------------------------------ */

.picker { position: relative; }
.picker__results {
  position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lift);
  max-height: 320px; overflow-y: auto; padding: 6px;
}
.picker__item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border-radius: 8px; cursor: pointer; border: none; background: none;
  width: 100%; text-align: left; font: inherit;
}
.picker__item:hover, .picker__item.is-active { background: var(--cream-deep); }
.picker__name { font-weight: 600; color: var(--navy); }
.picker__meta { font-size: 12.5px; color: var(--muted); }
.picker__empty { padding: 14px; color: var(--muted); font-size: 14px; }

.chosen {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--cream); border: 1px solid var(--line-strong);
}
.chosen__name { font-family: var(--serif); font-size: 18px; color: var(--navy); }
.chosen__meta { font-size: 13px; color: var(--muted); }

/* ---------- Feedback ----------------------------------------------------- */

.notice {
  padding: 13px 16px; border-radius: var(--radius-sm);
  font-size: 14px; border: 1px solid;
}
.notice--error   { background: var(--unpaid-bg); border-color: #f0cdc9; color: #7d1a13; }
.notice--success { background: var(--paid-bg);   border-color: #c4e3d1; color: #0f4c2d; }
.notice--info    { background: var(--gold-tint); border-color: #ecdaa4; color: #6a5210; }

.toasts { position: fixed; right: 22px; bottom: 22px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--navy); color: #fff;
  padding: 14px 18px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lift); max-width: 380px;
  animation: rise .22s ease;
}
.toast--success { background: #14653c; }
.toast--error   { background: #8a1f16; }
.toast__title { font-weight: 700; margin-bottom: 2px; }
.toast__body  { font-size: 13.5px; opacity: .92; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty__title { font-family: var(--serif); font-size: 19px; color: var(--navy); margin-bottom: 6px; }

.skeleton { background: linear-gradient(90deg, var(--cream-deep) 25%, #efe8db 37%, var(--cream-deep) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: 8px; height: 16px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ---------- Sign-in ------------------------------------------------------ */

.signin {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(123,30,40,.12), transparent 60%),
    radial-gradient(700px 420px at 110% 110%, rgba(20,33,61,.14), transparent 60%),
    var(--cream);
}
.signin__card { width: 100%; max-width: 420px; padding: 34px 32px; }
.signin__brand { text-align: center; margin-bottom: 24px; }
.signin__mark {
  width: 58px; height: 58px; margin: 0 auto 14px; border-radius: 16px;
  background: linear-gradient(150deg, var(--maroon), var(--maroon-dark));
  display: grid; place-items: center; color: var(--gold);
  font-family: var(--serif); font-size: 22px; border: 1px solid rgba(200,162,39,.5);
}

/* ---------- Misc --------------------------------------------------------- */

.muted { color: var(--muted); }
.small { font-size: 13px; }
.divider { height: 1px; background: var(--line); margin: 4px 0; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.tag-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); }
.timeline li:first-child { border-top: none; }
.timeline__date { width: 108px; flex: none; font-size: 13px; color: var(--muted); }
.timeline__amount { font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }

.progress { height: 8px; border-radius: 999px; background: var(--cream-deep); overflow: hidden; margin-top: 10px; }
.progress__fill { height: 100%; background: var(--paid); border-radius: 999px; transition: width .4s ease; }

/* ---------- Responsive --------------------------------------------------- */

@media (max-width: 900px) {
  /* The menu becomes one scrolling strip at the top. It must not cost a whole
     screenful before the first number — the office often works from a phone. */
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto;
    padding: 12px 14px; gap: 12px;
    flex-direction: row; align-items: center; flex-wrap: wrap;
  }
  .brand { flex: none; }
  .brand__mark { width: 34px; height: 34px; border-radius: 9px; font-size: 14px; }
  .brand__sub { display: none; }

  .nav {
    order: 3; width: 100%;
    flex-direction: row; flex-wrap: nowrap;
    overflow-x: auto; gap: 6px;
    padding-bottom: 4px; scrollbar-width: thin;
  }
  .nav__group { margin-top: 0; display: flex; gap: 6px; }
  .nav__group + .nav__group { border-left: 1px solid rgba(255,255,255,.14); padding-left: 6px; }
  .nav__label { display: none; }
  .nav__link { padding: 8px 12px; font-size: 14px; white-space: nowrap; }
  .nav__icon { display: none; }

  .sidebar__footer {
    margin-top: 0; margin-left: auto; border-top: none; padding-top: 0;
    display: flex; align-items: center; gap: 10px;
  }
  .who { padding: 0; text-align: right; }
  .who__role { display: none; }
  .btn--block { width: auto; padding: 8px 14px; }

  .topbar { padding: 12px 18px; }
  .content { padding: 18px 18px 48px; }
  .toasts { left: 16px; right: 16px; }
  .toast { max-width: none; }
}

@media print {
  .sidebar, .topbar, .actions, .toasts { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #ccc; }
}

/* ---------- Charts -------------------------------------------------------- */

.chart { position: relative; width: 100%; }
.chart__svg { width: 100%; height: auto; display: block; overflow: visible; }

/* Recessive chrome: solid hairlines one shade off the surface, never dashed. */
.chart__grid { stroke: var(--line); stroke-width: 1; }
.chart__tick { fill: var(--muted); font-size: 11px; font-family: var(--sans); font-variant-numeric: tabular-nums; }

.chart__line { fill: none; stroke: var(--maroon); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart__area { fill: var(--maroon); opacity: .07; }
.chart__dot-end { fill: var(--maroon); stroke: var(--surface); stroke-width: 2; }
.chart__dot-hover { fill: var(--maroon); stroke: var(--surface); stroke-width: 2; }
.chart__crosshair { stroke: var(--line-strong); stroke-width: 1; }

.chart__tooltip {
  position: absolute; top: 0; transform: translateX(-50%);
  background: var(--navy); color: #fff;
  padding: 7px 11px; border-radius: 8px;
  pointer-events: none; white-space: nowrap;
  box-shadow: var(--shadow-lift); z-index: 5;
}
.chart__tooltip-title { font-size: 11.5px; opacity: .8; }
.chart__tooltip-value { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Part-to-whole bar. The 2px gaps are the surface showing through — no borders. */
.segbar { display: flex; gap: 2px; height: 14px; margin-bottom: 16px; }
.segbar__part { border-radius: 3px; min-width: 4px; }
.segbar__part--unpaid  { background: var(--unpaid-fill); }
.segbar__part--partial { background: var(--partial-fill); }
.segbar__part--paid    { background: var(--paid-fill); }
.segbar__part--neutral { background: var(--line-strong); }

.legend { display: flex; flex-wrap: wrap; gap: 18px 26px; }
.legend__item { display: flex; align-items: flex-start; gap: 8px; }
.legend__swatch { width: 11px; height: 11px; border-radius: 3px; margin-top: 4px; flex: none; }
.legend__swatch--unpaid  { background: var(--unpaid-fill); }
.legend__swatch--partial { background: var(--partial-fill); }
.legend__swatch--paid    { background: var(--paid-fill); }
.legend__swatch--neutral { background: var(--line-strong); }
.legend__label { display: block; font-size: 13px; color: var(--ink-soft); }
.legend__value { display: block; font-weight: 700; color: var(--navy); font-size: 15px; }

/* Headline card — the one number the Proprietress looks for first. */
.headline { padding: 26px 24px; }
.headline__label { font-size: 13.5px; color: var(--muted); font-weight: 600; }
.headline__value {
  font-family: var(--sans); font-size: 46px; font-weight: 650;
  letter-spacing: -0.025em; line-height: 1.05; margin-top: 8px; color: var(--navy);
}
.headline__value--good { color: var(--paid); }
.headline__value--bad  { color: var(--unpaid); }
.headline__note { font-size: 13.5px; color: var(--ink-soft); margin-top: 10px; }

.delta { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; font-size: 13px; }
.delta--up   { color: var(--paid); }
.delta--down { color: var(--unpaid); }
.delta--flat { color: var(--muted); }

@media (max-width: 700px) {
  .headline__value { font-size: 38px; }
  .stat__value { font-size: 27px; }
}

/* ---------- School crest -------------------------------------------------- */
/* The crest is maroon on white, so it needs a light chip to read against the
   navy sidebar. Same 40px box as before — the header height does not change. */
.brand__mark--logo { background: #fff; padding: 2px; border-color: rgba(200, 162, 39, .75); }
.brand__mark--logo img { width: 100%; height: 100%; object-fit: contain; display: block; border-radius: 8px; }

/* ---------- Bar charts ---------------------------------------------------- */

.chart__bar { fill: var(--maroon); transition: fill .12s ease; }
.chart__bar.is-hot { fill: var(--maroon-dark); }

.hbars { display: flex; flex-direction: column; gap: 12px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 148px) 1fr auto; gap: 14px; align-items: center; }
.hbar__label { font-size: 13.5px; color: var(--ink-soft); }
.hbar__track { background: var(--cream-deep); border-radius: 4px; height: 16px; overflow: hidden; }
.hbar__fill { height: 100%; background: var(--maroon); border-radius: 4px; transition: width .35s ease; }
.hbar__value { font-size: 13.5px; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; white-space: nowrap; }

@media (max-width: 620px) {
  .hbar { grid-template-columns: 1fr auto; }
  .hbar__track { grid-column: 1 / -1; order: 3; }
}
.chart__bar--negative { fill: var(--unpaid-fill); }
.chart__bar--negative.is-hot { fill: #8a1c13; }
.chart__zero { stroke: var(--line-strong); stroke-width: 1.5; }
.signin__mark--logo { background: #fff; padding: 3px; border: 1px solid rgba(200, 162, 39, .6); }
.signin__mark--logo img { width: 100%; height: 100%; object-fit: contain; display: block; border-radius: 12px; }
