/* Old-fashioned bookkeeping look: grey desktop, an off-white ledger sheet, ink-blue masthead, tab strip,
   serif headings, green-bar table rows, double-ruled totals, bevelled buttons. No rounded corners,
   no web fonts. Charts progressively enhance the bookkeeping tables. */
:root {
  --fg: #1c1b19; --muted: #5d5b55; --line: #8c8a82; --line-light: #cfccc3;
  --desk: #d5d3cb; --sheet: #fffefb; --bg-alt: #eeece5; --head: #e3e0d7; --bar: #f0f3ec;
  --ink: #22324d; --ink-light: #3b5076; --accent: #22324d;
  --error: #9b1c1c; --ok: #24602a; --warn: #7a5200;
  --serif: Georgia, "Book Antiqua", Palatino, "Times New Roman", serif;
  --sans: Verdana, Tahoma, Geneva, "DejaVu Sans", sans-serif;
  --mono: "Lucida Console", Consolas, "DejaVu Sans Mono", "Courier New", monospace;
}
.statistics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 30rem), 1fr)); column-gap: 1.5rem; }
.statistics-panel { border-top: 3px double var(--line); margin-top: 1rem; padding-top: .2rem; min-width: 0; }
.statistics-panel h2 { margin: .3rem 0 .1rem; }
.statistics-panel h2 + p { margin: 0 0 .3rem; }
.statistics-kpis { display: flex; flex-wrap: wrap; gap: .5rem; margin: .4rem 0; }
.statistics-kpis > div { background: var(--bg-alt); border: 1px solid var(--line-light); padding: .3rem .7rem; flex: 1 1 11rem; }
.statistics-kpis dt { font-weight: bold; font-size: .88rem; }
.statistics-kpis dd { margin: .1rem 0 0; font-variant-numeric: tabular-nums; }
.statistics-kpis dd:not(.small) { font-size: 1.15rem; }
.statistics-plot { width: 100%; min-width: 0; }
.statistics-panel [hidden] { display: none !important; }
.statistics-aggregates summary { cursor: pointer; margin: .2rem 0; font-size: .88rem; }
.statistics-panel .table-scroll { overflow-x: auto; max-width: 100%; }
.statistics-dialog { width: min(72rem, calc(100vw - 2rem)); max-height: 85vh; padding: 0; border: 1px solid var(--ink);
  background: var(--sheet); color: var(--fg); display: none; flex-direction: column; }
.statistics-dialog[open] { display: flex; }
.statistics-dialog::backdrop { background: rgba(28, 27, 25, .45); }
.statistics-dialog-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .4rem .4rem .4rem 1rem; background: var(--ink); color: #f1efe8; font-family: var(--serif); }
.statistics-dialog-bar form { margin: 0; }
.statistics-dialog .box { margin: .75rem 1rem 0; }
.statistics-records { overflow: auto; padding: 0 1rem 1rem; }
.statistics-records h3 { margin-top: .8rem; }
.statistics-records[aria-busy="true"] { opacity: .55; }
.statistics-records h3:focus { outline: none; }
@media (max-width: 600px) {
  .statistics-kpis { gap: .35rem; }
  .statistics-kpis > div { flex-basis: 100%; }
  .statistics-dialog { width: 100vw; max-width: 100vw; max-height: 100vh; height: 100vh; }
}
@media print {
  .statistics-panel .table-scroll { overflow: visible; }
}
* { box-sizing: border-box; border-radius: 0 !important; }
html { font-size: 13px; }
body { margin: 0; font-family: var(--sans); color: var(--fg); background: var(--desk); line-height: 1.45;
       min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--ink-light); }
a:visited { color: #4a3f6b; }
h1 { font-family: var(--serif); font-size: 1.75rem; font-weight: normal; margin: 0 0 1rem; color: var(--ink);
     border-bottom: 3px double var(--ink); padding-bottom: .25rem; }
h2 { font-family: var(--serif); font-size: 1.3rem; font-weight: normal; font-variant: small-caps; letter-spacing: .03em;
     margin: 1.8rem 0 .5rem; color: var(--ink); border-bottom: 1px solid var(--line); padding-bottom: .15rem; }
h3 { font-family: var(--serif); font-size: 1.1rem; font-weight: normal; margin: 1.2rem 0 .4rem; color: var(--ink); }

/* --- masthead and tabs ------------------------------------------------------------------------- */
header.top { background: var(--ink); color: #f1efe8; border-bottom: 1px solid #111a2b; }
header.top .masthead { display: flex; align-items: center; gap: 1rem; padding: .55rem 1rem; flex-wrap: wrap; }
header.top .brand { display: flex; align-items: center; gap: .8rem; color: inherit; text-decoration: none; }
header.top .logo { background: #fff; border: 1px solid #0d1524; padding: 3px; display: inline-flex; }
header.top .logo img { height: 46px; width: auto; max-width: 160px; display: block; object-fit: contain; }
header.top .org { display: block; font-family: var(--serif); font-size: 1.45rem; font-variant: small-caps;
                  letter-spacing: .04em; line-height: 1.15; }
header.top .subtitle { display: block; font-size: .8rem; color: #b9c2d3; letter-spacing: .08em; text-transform: uppercase; }
header.top .meta { margin-left: auto; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; font-size: .88rem; }
header.top .user { color: #d5dbe6; }
header.top form { display: inline; }
header.top button { font-size: .82rem; padding: .1rem .45rem; }
form.lang { display: inline-flex !important; }
form.lang button { margin-left: -1px; min-width: 2.4rem; }
form.lang button.current { background: var(--sheet); font-weight: bold; box-shadow: inset 1px 1px 2px rgba(0, 0, 0, .25); }
nav.tabs { background: var(--head); border-top: 1px solid #0d1524; padding: .45rem .8rem 0;
           display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--line); }
nav.tabs a { display: inline-block; padding: .3rem .75rem; text-decoration: none; color: var(--fg);
             background: linear-gradient(#f7f6f1, #dad7cd); border: 1px solid var(--line); border-bottom: none;
             margin-bottom: -1px; }
nav.tabs a:hover { background: #fbfaf6; }
nav.tabs a.active { background: var(--sheet); font-weight: bold; color: var(--ink); position: relative;
                    border-bottom: 1px solid var(--sheet); }

/* --- the sheet and the footer ------------------------------------------------------------------ */
main { background: var(--sheet); padding: 1.2rem 1.4rem 1.6rem; margin: 0 .8rem; border: 1px solid var(--line);
       border-top: none; flex: 1 0 auto; box-shadow: 2px 2px 0 rgba(0, 0, 0, .08); }
footer.bottom { display: flex; flex-wrap: wrap; gap: .6rem 3rem; padding: .7rem 1.6rem 1rem; font-size: .8rem;
                color: var(--muted); border-top: 1px solid transparent; }
footer.bottom strong { color: var(--fg); font-family: var(--serif); font-size: .95rem; font-weight: normal;
                       font-variant: small-caps; }
footer.bottom .stamp { margin-left: auto; text-align: right; font-family: var(--mono); font-size: .75rem; }

/* --- text helpers ------------------------------------------------------------------------------ */
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.num, input.num { font-family: var(--mono); font-size: .95rem; }
.neg { color: var(--error); }
.nowrap { white-space: nowrap; }
.iban { white-space: nowrap; font-family: var(--mono); font-size: .95em; }
input.iban { min-width: 20rem; letter-spacing: .03em; }

/* --- ledger tables ----------------------------------------------------------------------------- */
table { border-collapse: collapse; width: 100%; margin: .3rem 0 1.1rem; background: #fff; border: 1px solid var(--line); }
th, td { border: 1px solid var(--line-light); padding: .22rem .5rem; vertical-align: top; text-align: left; }
th { background: var(--head); font-weight: bold; border-color: var(--line); color: #2b2a26; font-size: .92rem; }
tr:first-child th { border-bottom: 2px solid var(--ink); }
tr:nth-child(even) td { background: var(--bar); }
tr:hover td { background: #f8f4e2; }
tr.total td { font-weight: bold; border-top: 1px solid var(--fg); border-bottom: 3px double var(--fg); background: #f4f2eb; }
tr.sub td { background: #efede6; font-weight: bold; }
table.kv { width: auto; min-width: 440px; }
table.kv th { width: 14rem; border-bottom: 1px solid var(--line); }
table.kv tr:first-child th { border-bottom: 1px solid var(--line); }
table.kv tr:nth-child(even) td { background: #fff; }

/* --- forms and buttons ------------------------------------------------------------------------- */
.toolbar { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; margin: .4rem 0 .9rem;
           padding: .35rem .45rem; background: var(--bg-alt); border: 1px solid var(--line-light); }
.toolbar form { display: inline; }
form.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: end; margin-bottom: .7rem;
               padding: .5rem .6rem; border: 1px solid var(--line); background: var(--bg-alt);
               box-shadow: inset 1px 1px 0 #fff; }
form.filters label { display: block; font-size: .8rem; color: var(--muted); }
input, select, textarea, button, .button { font: inherit; color: var(--fg); padding: .22rem .4rem; }
input, select, textarea { background: #fff; border: 1px solid var(--line); border-top-color: #68655d;
                          border-left-color: #68655d; box-shadow: inset 1px 1px 2px rgba(0, 0, 0, .1); }
input:focus, select:focus, textarea:focus { outline: 2px solid #b8962e; outline-offset: 0; background: #fffef5; }
button, .button { background: linear-gradient(#fdfcf9, #dddad1); border: 1px solid #6d6a62; cursor: pointer;
                  text-decoration: none; display: inline-block; box-shadow: inset 1px 1px 0 #fff;
                  color: var(--fg) !important; line-height: 1.3; }
button:hover, .button:hover { background: linear-gradient(#ffffff, #e8e6df); }
button:active, .button:active { background: #d2cfc6; box-shadow: inset 1px 1px 2px rgba(0, 0, 0, .3); }
button.primary, .button.primary { background: linear-gradient(var(--ink-light), var(--ink)); border-color: #111a2b;
                                  color: #fff !important; box-shadow: inset 1px 1px 0 rgba(255, 255, 255, .25); }
button.primary:hover, .button.primary:hover { background: linear-gradient(#4a6290, var(--ink-light)); }
button.danger { color: var(--error) !important; border-color: var(--error); }
.form div { margin-bottom: .65rem; }
.form label { display: block; font-weight: bold; margin-bottom: .15rem; font-size: .92rem; }
.form input[type=text], .form input[type=email], .form input[type=date], .form input[type=number],
.form input[type=password], .form select, .form textarea { width: 100%; max-width: 34rem; }
.form input[type=checkbox] { margin-right: .3rem; box-shadow: none; }
.form .helptext { display: block; color: var(--muted); font-size: .85rem; font-style: italic; }
.form ul.errorlist, ul.errorlist { color: var(--error); margin: .2rem 0; padding-left: 1.1rem; font-weight: bold; }
.form fieldset { border: 1px solid var(--line); margin: 0 0 1.1rem; padding: .6rem .9rem; background: #fbfaf6; }
.form legend { font-family: var(--serif); font-variant: small-caps; font-size: 1.1rem; color: var(--ink); padding: 0 .35rem; }
#id_donations div, #id_donations label { font-weight: normal; display: block; }

/* --- notices, boxes, status stamps ------------------------------------------------------------- */
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li { border: 1px solid var(--line); border-left-width: 5px; padding: .4rem .7rem; margin-bottom: .3rem; background: #f7f6f1; }
.messages li.error { border-left-color: var(--error); background: #fbeeee; }
.messages li.warning { border-left-color: var(--warn); background: #fbf4e4; }
.messages li.success { border-left-color: var(--ok); background: #edf5ee; }
.box { border: 1px solid var(--line); padding: .6rem .8rem; margin: .5rem 0 1rem; background: #f7f6f1; }
.box.warn { border-left: 5px solid var(--warn); }
.box.error { border-left: 5px solid var(--error); }
.status { font-size: .74rem; border: 1px solid var(--line); padding: 0 .35rem; white-space: nowrap; background: #fff;
          text-transform: uppercase; letter-spacing: .06em; font-weight: bold; }
.status.reconciled, .status.paid, .status.issued { border-color: var(--ok); color: var(--ok); }
.status.open, .status.draft, .status.planned, .status.accepted { border-color: var(--warn); color: var(--warn); }
.status.rejected, .status.cancelled { border-color: var(--error); color: var(--error); }
.status.submitted, .status.instructed { border-color: var(--accent); color: var(--accent); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 0 2rem; }
.pagination { margin: .5rem 0; }
pre { background: #f6f5f0; border: 1px solid var(--line-light); padding: .5rem; overflow: auto; font-size: .85rem; font-family: var(--mono); }
.qr svg { border: 1px solid var(--line); background: #fff; }
.transfer td { font-size: 1.1rem; font-family: var(--mono); }

/* --- status graph ------------------------------------------------------------------------------ */
.workflow { border: 1px solid var(--line); padding: .5rem .7rem; margin: .4rem 0 1.1rem; background: var(--bg-alt); }
.workflow ol.steps { list-style: none; display: flex; flex-wrap: wrap; gap: .3rem 0; padding: 0; margin: 0 0 .4rem; }
.workflow ol.steps li { border: 1px solid var(--line); padding: .15rem .55rem; background: #fff; }
.workflow ol.steps li + li { margin-left: 1.4rem; position: relative; }
.workflow ol.steps li + li::before { content: "→"; position: absolute; left: -1.15rem; color: var(--muted); }
.workflow ol.steps li.todo { color: var(--muted); border-style: dashed; background: transparent; }
.workflow ol.steps li.current { background: var(--ink); border-color: #111a2b; color: #fff; font-weight: bold; }
.workflow p.side { margin: .2rem 0 .4rem; }
.workflow form.transitions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin: .3rem 0; }
.workflow form.transitions input[name=note] { min-width: 18rem; flex: 1 1 18rem; max-width: 30rem; }
.workflow details { margin-top: .3rem; }

form.inline-form { display: inline; }
form.link-person { margin: .3rem 0 .1rem; }
form.link-person select { max-width: 18rem; }
body.read-only form[method=post]:not(.keep) { display: none !important; }

@media (max-width: 700px) {
  main { margin: 0; border-left: none; border-right: none; padding: 1rem; }
  header.top .meta { margin-left: 0; }
  footer.bottom .stamp { margin-left: 0; text-align: left; }
}
@media print {
  body { background: #fff; display: block; }
  header.top .meta, nav.tabs, .toolbar, form, .noprint, .messages { display: none !important; }
  header.top { background: #fff; color: #000; border-bottom: 2px solid #000; }
  header.top .subtitle { color: #444; }
  main { padding: .5rem 0; margin: 0; border: none; box-shadow: none; }
  tr:nth-child(even) td { background: #f2f2f2 !important; }
  footer.bottom { border-top: 1px solid #000; color: #000; padding: .4rem 0; }
  a { color: var(--fg); text-decoration: none; }
}
