/* Pyro K9 Ops — one stylesheet. Colours live in :root so the whole look changes in one place. */
:root {
  --ink: #1f1b18;
  --ink-2: #5c534c;
  --ink-3: #8a8079;
  --bg: #f5f2ee;
  --card: #ffffff;
  --line: #e4ddd5;
  /* Brand: gold and near-black, sampled from the Pyro K9 logo. */
  --gold: #c8902a;        /* fills (buttons, active tab) — always with dark text */
  --gold-hover: #b5801f;
  --gold-dark: #8a6214;   /* gold text and links on white (passes contrast) */
  --gold-soft: #f7eeda;
  --char: #0d1114;
  --ok: #2b7a3d;
  --ok-soft: #e6f3e8;
  --warn: #a86400;
  --warn-soft: #fdf3e0;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(31, 27, 24, .06), 0 2px 8px rgba(31, 27, 24, .04);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--gold-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; display: flex; align-items: center; gap: .5rem; }
h3 { font-size: .95rem; margin: 1rem 0 .4rem; }
code, pre { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9em; }
pre { white-space: pre-wrap; background: var(--bg); padding: .75rem; border-radius: 6px; }
.muted { color: var(--ink-3); }
.small { font-size: .85rem; }
.notes { white-space: normal; color: var(--ink-2); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1rem;
  background: var(--char); color: #fff; padding: 0 1rem; min-height: 56px;
}
.brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; color: #fff; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand em { font-style: normal; font-weight: 400; opacity: .6; }
.brand .mark {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 7px;
  background: var(--gold); color: #fff; font-size: .8rem; letter-spacing: .02em;
}
.brand.big { color: var(--ink); font-size: 1.25rem; margin-bottom: 1rem; }
.brand.big .mark { width: 38px; height: 38px; font-size: .95rem; }
.mainnav { display: flex; gap: .15rem; overflow-x: auto; scrollbar-width: none; flex: 1; }
.mainnav::-webkit-scrollbar { display: none; }
.mainnav a {
  color: #d9d2cb; padding: .5rem .7rem; border-radius: 7px; white-space: nowrap; font-size: .92rem;
}
.mainnav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.mainnav a.on { background: var(--gold); color: var(--char); font-weight: 600; }
.logout { color: #b9b0a8; font-size: .85rem; white-space: nowrap; }

/* ---------- logo ---------- */
.logo { display: block; flex-shrink: 0; }
.brand .logo { width: 36px; height: 36px; }
.login-logo { width: 150px; height: 150px; margin: 0 auto 1rem; }
.pub-head .logo { width: 44px; height: 44px; }
.pub-logo { width: 120px; height: 120px; margin: .5rem auto 1rem; }
.sheet-logo { width: 78px; height: 78px; }

/* ---------- layout ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 1.25rem 1rem 4rem; }
.titlebar { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin: .5rem 0 1.25rem; }
.titlebar .sub { margin: .3rem 0 0; color: var(--ink-2); }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.grid2 > * { margin-bottom: 0; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.1rem 1.2rem; margin-bottom: 1rem;
}
.card.flush { padding: 0; overflow: hidden; }
.card.narrow { max-width: 440px; margin: 3rem auto; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: 1rem 1.2rem .5rem; }
.card-head h2 { margin: 0; }
.empty { color: var(--ink-3); padding: 1rem 0; }
.card.flush > .empty { padding: 1.2rem; }
.count { font-size: .75rem; font-weight: 600; background: var(--bg); color: var(--ink-2); border-radius: 99px; padding: .05rem .5rem; }
.count.warn { background: var(--bad-soft); color: var(--bad); }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; }
.stat span { display: block; font-size: .8rem; color: var(--ink-3); }
.stat strong { display: block; font-size: 1.3rem; font-variant-numeric: tabular-nums; margin-top: .15rem; }
.stat em { display: block; font-style: normal; font-size: .8rem; color: var(--ink-3); }
.stat.neg strong { color: var(--bad); }
.stat.pos strong { color: var(--ok); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .3rem;
  min-height: 40px; padding: .45rem .95rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; border-color: var(--ink-3); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--char); }
.btn.primary:hover { background: var(--gold-hover); border-color: var(--gold-hover); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: #f0c4bf; background: #fff; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.small { min-height: 32px; padding: .25rem .65rem; font-size: .82rem; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
form.inline { display: inline; margin: 0; }
.inline-form { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin: .5rem 0; }
.inline-form input { width: auto; flex: 1 1 120px; }
.quick-status { display: flex; gap: .4rem; flex-wrap: wrap; margin: -.5rem 0 1rem; }
.danger-zone { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px dashed var(--line); }

/* ---------- forms ---------- */
.form label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; font-weight: 600; color: var(--ink-2); margin-bottom: .85rem; }
.form.cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 1rem; }
.form .full { grid-column: 1 / -1; }
.form h2 { margin-top: .5rem; padding-top: .75rem; border-top: 1px solid var(--line); }
.form h2:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; /* 16px stops phones zooming in */
  color: var(--ink); background: #fff; border: 1px solid #d6cdc4; border-radius: 8px;
  padding: .55rem .7rem; min-height: 42px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 0; border-color: var(--gold); }
input[type=file] { padding: .4rem; }
label.check { flex-direction: row; align-items: center; gap: .55rem; font-weight: 600; color: var(--ink); }
label.check input { width: 20px; height: 20px; min-height: 0; accent-color: var(--gold); }
.form-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .25rem; }

/* ---------- flash ---------- */
.flash { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.flash.ok { background: var(--ok-soft); border-color: #bfe0c5; color: #1d5c2c; }
.flash.err { background: var(--bad-soft); border-color: #f3c3bd; color: #8c1c13; }
.flash.warn { background: var(--warn-soft); border-color: #f1d9a6; color: #7a4a00; }
.flash ul { margin: .3rem 0 0; }

/* ---------- badges ---------- */
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: .1rem .5rem; border-radius: 99px; background: var(--bg); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.badge.pass, .badge.sold { background: var(--ok-soft); color: var(--ok); border-color: #c7e3cc; }
.badge.fail, .badge.died { background: var(--bad-soft); color: var(--bad); border-color: #f3c3bd; }
.badge.pending, .badge.reserved { background: var(--warn-soft); color: var(--warn); border-color: #f1d9a6; }
.badge.available { background: var(--gold-soft); color: var(--gold-dark); border-color: #f6c9b3; }

/* ---------- tables ---------- */
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 600; padding: .6rem .75rem; border-bottom: 1px solid var(--line); background: #faf8f5; }
.tbl td { padding: .65rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.card:not(.flush) .tbl td, .card:not(.flush) .tbl th { padding-left: 0; }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl tr.sum td { font-weight: 700; border-top: 2px solid var(--ink); }
.tbl .neg, .num.neg { color: var(--bad); }

/* ---------- lists ---------- */
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: .4rem 0; border-bottom: 1px solid var(--line); }
ul.plain li:last-child { border-bottom: 0; }
ul.tasks { list-style: none; padding: 0; margin: 0; }
ul.tasks > li { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .7rem 0 .7rem .75rem; border-bottom: 1px solid var(--line); border-left: 3px solid var(--line); }
ul.tasks > li:last-child { border-bottom: 0; }
ul.tasks > li.late { border-left-color: var(--gold); }
.row-actions { display: flex; gap: .35rem; flex-shrink: 0; }
ul.gaps { margin: .3rem 0 0; padding-left: 1.1rem; font-size: .88rem; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0; }
dl.facts dt { color: var(--ink-3); font-size: .85rem; }
dl.facts dd { margin: 0; }
dl.facts.stacked { grid-template-columns: 1fr; gap: .1rem; }
dl.facts.stacked dd { margin-bottom: .6rem; }
.filters { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters a { padding: .35rem .75rem; border-radius: 99px; border: 1px solid var(--line); background: var(--card); color: var(--ink-2); font-size: .85rem; }
.filters a.on { background: var(--char); color: #fff; border-color: var(--char); }
.filters a:hover { text-decoration: none; }
.monthnav { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }

/* ---------- small charts ---------- */
.chart { width: 100%; height: auto; max-height: 220px; }
.chart .axis { stroke: var(--line); }
.chart .line { fill: none; stroke: var(--gold); stroke-width: 2.5; }
.chart .dot { fill: var(--gold); }
.chart .lbl { font-size: 12px; fill: var(--ink-2); }
.bars { display: grid; gap: .5rem; }
.bar { display: grid; grid-template-columns: 170px 1fr 170px; align-items: center; gap: .75rem; font-size: .88rem; }
.bt { background: var(--bg); border-radius: 4px; height: 12px; overflow: hidden; }
.bt i { display: block; height: 100%; background: var(--gold); border-radius: 4px; }
.bv { text-align: right; font-variant-numeric: tabular-nums; }
.bv em { font-style: normal; color: var(--ink-3); margin-left: .3rem; }

/* ---------- login ---------- */
.login { text-align: left; }
.login-title { text-align: center; font-size: 1.3rem; margin-bottom: 1.25rem; }
.login-title em { font-style: normal; font-weight: 400; color: var(--ink-3); }

/* ---------- history sheet ---------- */
.sheet { background: #fff; max-width: 800px; margin: 0 auto; padding: 2rem 2.2rem; border: 1px solid var(--line); border-radius: var(--radius); }
.sheet h2 { font-size: .95rem; text-transform: uppercase; letter-spacing: .05em; color: var(--gold-dark); border-bottom: 2px solid var(--gold); padding-bottom: .25rem; margin-top: 1.4rem; }
.sheet h3 { margin: .2rem 0; }
.sheet-head { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--line); padding-bottom: 1rem; }
.sheet-head .brand.big { margin-bottom: .3rem; }
.sheet-head .right { text-align: right; }
.sheet table.kv, .sheet table.list { width: 100%; border-collapse: collapse; font-size: .9rem; }
.sheet table.kv th { text-align: left; color: var(--ink-3); font-weight: 600; width: 18%; padding: .3rem .4rem .3rem 0; }
.sheet table.kv td { padding: .3rem .8rem .3rem 0; }
.sheet table.list th, .sheet table.list td { text-align: left; border-bottom: 1px solid var(--line); padding: .35rem .4rem .35rem 0; }
.sheet-parents { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.sheet-parents ul { margin: .3rem 0; padding-left: 1.1rem; }
.sigs { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; margin-top: 3rem; }
.sigs div { border-top: 1px solid var(--ink); padding-top: .3rem; font-size: .85rem; color: var(--ink-2); }

/* ---------- public application form (apply.php) ---------- */
body.public { background: var(--bg); }
.pub-head { background: var(--char); padding: .6rem 1rem; display: flex; align-items: center; }
.pub-head .brand { font-size: 1.1rem; }
.pub-wrap { max-width: 640px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.pub-intro h1 { font-size: 1.6rem; margin-bottom: .5rem; }
.pub-intro p { color: var(--ink-2); margin: 0 0 1.25rem; }
.pub-form fieldset { border: 1px solid var(--line); margin: 0 0 1rem; }
.pub-form legend { font-weight: 700; font-size: 1rem; padding: 0 .4rem; margin-left: -.4rem; color: var(--gold-dark); }
.pub-form .q { margin-bottom: 1rem; }
.pub-form .q > span { display: block; font-size: .85rem; font-weight: 600; color: var(--ink-2); margin-bottom: .4rem; }
.choices { display: flex; flex-wrap: wrap; gap: .4rem; }
.choices.stack { flex-direction: column; align-items: stretch; }
.choice { display: inline-flex; margin: 0 !important; cursor: pointer; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.choice span {
  display: inline-flex; align-items: center; min-height: 42px; padding: .45rem .9rem;
  border: 1px solid #d6cdc4; border-radius: 8px; background: #fff;
  font-size: .92rem; font-weight: 500; color: var(--ink); width: 100%;
}
.choice input:checked + span { background: var(--gold-soft); border-color: var(--gold); color: var(--gold-dark); font-weight: 700; }
.choice input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 1px; }
.pub-form label.check { align-items: flex-start; font-weight: 500; line-height: 1.4; }
.pub-form label.check input { margin-top: .1rem; flex-shrink: 0; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.pub-done { padding: 1.75rem; }
.pub-done h1 { margin-bottom: .75rem; }

/* Kiswahili half of a bilingual heading: same size, lighter, so English and Kiswahili readers both scan easily. */
.sw { font-weight: 400; color: var(--ink-3); }
.paperform .sw { color: #555; }
.staff-bar { background: var(--warn-soft); border-bottom: 1px solid #f1d9a6; color: #7a4a00; padding: .6rem 1rem; font-size: .9rem; text-align: center; }

/* ---------- printable paper application (pages/printform.php) ---------- */
.paperform { background: #fff; max-width: 800px; margin: 0 auto; padding: 1.8rem 2.2rem; border: 1px solid var(--line); border-radius: var(--radius); color: #000; }
.paperform h2 { font-size: .9rem; text-transform: uppercase; letter-spacing: .05em; color: var(--gold-dark); border-bottom: 2px solid var(--gold); padding-bottom: .2rem; margin: 1.1rem 0 .6rem; }
.pf-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; border-bottom: 1px solid var(--line); padding-bottom: .8rem; }
.pf-head .brand.big { margin-bottom: .2rem; }
.pf-brand { display: flex; gap: .8rem; align-items: center; }
.pf-title { text-align: right; display: flex; flex-direction: column; gap: .2rem; }
.pf-title strong { font-size: 1.15rem; }
.pf-grid { display: grid; grid-template-columns: 1fr 1fr; column-gap: 1.5rem; }
.pf-field, .pf-q { margin-bottom: .7rem; break-inside: avoid; }
.pf-field label, .pf-q label { display: block; font-size: .82rem; font-weight: 600; color: #333; }
.pf-line { border-bottom: 1px solid #555; height: 1.7rem; }
.pf-boxes { display: flex; flex-wrap: wrap; gap: .3rem 1.1rem; margin-top: .3rem; font-size: .88rem; }
.pf-box { display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap; }
.pf-box i { display: inline-block; width: 13px; height: 13px; border: 1.5px solid #333; border-radius: 2px; flex-shrink: 0; }
.pf-agree { display: flex; gap: .6rem; align-items: flex-start; font-size: .9rem; }
.pf-agree .pf-box i { margin-top: .2rem; }
.pf-agree p { margin: 0 0 .5rem; }
.pf-sign { display: grid; grid-template-columns: 2fr 1fr; gap: 2rem; margin: 1.2rem 0 .4rem; font-size: .8rem; color: #555; }
.pf-office { display: flex; flex-wrap: wrap; gap: .5rem 1.4rem; align-items: center; border: 1px dashed #999; border-radius: 6px; padding: .6rem .8rem; font-size: .8rem; color: #444; margin-top: 1rem; }
@media (max-width: 640px) {
  .paperform { padding: 1.1rem; }
  .pf-grid { grid-template-columns: 1fr; }
}
@media print {
  @page { size: A4; margin: 10mm 12mm; }
  .paperform { border: 0; padding: 0; max-width: none; font-size: 9.5pt; zoom: .86; }
  .paperform h2 { margin: .55rem 0 .4rem; }
  .pf-head { padding-bottom: .5rem; }
  .pf-field, .pf-q { margin-bottom: .45rem; }
  .pf-boxes { margin-top: .2rem; gap: .2rem 1rem; }
  .pf-line { height: 1.3rem; }
  .pf-agree p { margin-bottom: .3rem; }
  .pf-sign { margin: .9rem 0 .3rem; }
  .pf-office { margin-top: .6rem; padding: .45rem .7rem; }
  .pf-agree, .pf-sign, .pf-office { break-inside: avoid; }
  .paperform .brand .mark { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- phone ---------- */
@media (max-width: 860px) {
  .grid2 { grid-template-columns: 1fr; }
  .form.cols { grid-template-columns: 1fr 1fr; }
  .bar { grid-template-columns: 110px 1fr; }
  .bv { grid-column: 2; text-align: left; }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .topbar { flex-wrap: wrap; padding: .5rem .75rem 0; gap: .5rem; }
  .mainnav { order: 3; flex-basis: 100%; padding-bottom: .5rem; }
  .logout { margin-left: auto; }
  .wrap { padding: 1rem .75rem 4rem; }
  h1 { font-size: 1.35rem; }
  .form.cols { grid-template-columns: 1fr; }
  .card { padding: 1rem; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat strong { font-size: 1.1rem; }
  ul.tasks > li { flex-direction: column; align-items: stretch; }
  .row-actions { justify-content: flex-start; }
  dl.facts { grid-template-columns: 1fr; gap: 0; }
  dl.facts dd { margin-bottom: .5rem; }
  /* Wide tables turn into stacked cards. Each cell shows its column name from data-l. */
  table.cards-on-phone thead { display: none; }
  table.cards-on-phone tr { display: block; padding: .6rem 1rem; border-bottom: 1px solid var(--line); }
  table.cards-on-phone td { display: flex; justify-content: space-between; gap: 1rem; padding: .2rem 0; border: 0; text-align: right; }
  table.cards-on-phone td::before { content: attr(data-l); color: var(--ink-3); font-size: .8rem; text-align: left; }
  table.cards-on-phone td:not([data-l]) { justify-content: flex-end; }
  table.cards-on-phone td:not([data-l])::before { content: none; }
  .monthnav { font-size: .85rem; }
  .sheet { padding: 1.2rem; }
  .sheet-parents { grid-template-columns: 1fr; }
}

/* ---------- print (history sheet) ---------- */
@media print {
  body { background: #fff; font-size: 11pt; }
  .topbar, .noprint, .flash { display: none !important; }
  .wrap { padding: 0; max-width: none; }
  .sheet { border: 0; padding: 0; max-width: none; }
  a { color: inherit; }
}
