/* Leicester PKA members — mobile first. Base styles are for phones; wider screens get a sidebar. */

/* Brand colours from the Leicester PKA logo pack: blue #0475BB, red #ED2024, black #040707 */
:root {
  --brand-blue: #0475BB;
  --brand-red: #ED2024;
  --brand-black: #040707;
  --bg: #f5f7f9;
  --surface: #ffffff;
  --surface-2: #f1f4f7;
  --text: #040707;
  --muted: #5b6570;
  --line: #dde3e9;
  --accent: #0475BB;
  --accent-press: #035d95;
  --accent-ink: #ffffff;
  --accent-soft: #e3eff9;
  --ok: #1d6b38;   --ok-bg: #e2f2e7;
  --warn: #7f5200; --warn-bg: #fcefd2;
  --bad: #b3171b;  --bad-bg: #fde4e4;
  --info: #0467a5; --info-bg: #e3eff9;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(4,7,7,.05), 0 2px 8px rgba(4,7,7,.04);
  --tabbar-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0e12; --surface: #131a20; --surface-2: #1a222a; --text: #eef2f5; --muted: #9ba7b3;
    --line: #29323c; --accent: #4fa6de; --accent-press: #74baea; --accent-ink: #03121d; --accent-soft: #0f2a3d;
    --brand-red: #ff4b4e;
    --ok: #79d49a; --ok-bg: #16301f; --warn: #f2c165; --warn-bg: #3a2c0f; --bad: #ff8a85; --bad-bg: #3d1517;
    --info: #8cc4ec; --info-bg: #0f2a3d; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0e12; --surface: #131a20; --surface-2: #1a222a; --text: #eef2f5; --muted: #9ba7b3;
  --line: #29323c; --accent: #4fa6de; --accent-press: #74baea; --accent-ink: #03121d; --accent-soft: #0f2a3d;
  --brand-red: #ff4b4e;
  --ok: #79d49a; --ok-bg: #16301f; --warn: #f2c165; --warn-bg: #3a2c0f; --bad: #ff8a85; --bad-bg: #3d1517;
  --info: #8cc4ec; --info-bg: #0f2a3d; --shadow: none; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h2 { font-size: 1.05rem; font-weight: 650; margin: 28px 0 10px; }
h2:first-child { margin-top: 4px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.icon { width: 22px; height: 22px; flex: none; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Shell ---------- */
.shell { min-height: 100vh; min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
  min-height: 56px;
}
.topbar { box-shadow: inset 0 3px 0 var(--brand-red); }
.topbar-logo { display: block; flex: none; margin-right: 2px; }
.topbar-logo .logo { width: 34px; }
@media (min-width: 900px) { .topbar-logo { display: none; } .topbar { box-shadow: none; } }
.topbar h1 { font-size: 1.2rem; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main {
  padding: 16px 16px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom));
  max-width: 760px; margin: 0 auto;
}

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: .72rem; font-weight: 550;
}
.tabbar a { position: relative; }
.tabbar a.on { color: var(--accent); }
.tabbar a.on::before {
  content: ""; position: absolute; top: 0; left: 50%; width: 28px; height: 3px; margin-left: -14px;
  border-radius: 0 0 3px 3px; background: var(--brand-red);
}
.sidenav { display: none; }

@media (min-width: 900px) {
  .tabbar { display: none; }
  .sidenav {
    display: flex; flex-direction: column; gap: 2px;
    position: fixed; top: 0; bottom: 0; left: 0; width: 232px;
    padding: 18px 12px; background: var(--surface); border-right: 1px solid var(--line);
  }
  .sidenav { border-top: 4px solid var(--brand-red); }
  .sidenav .brand { display: flex; align-items: center; gap: 10px; font-weight: 750; padding: 4px 10px 18px; color: var(--text); }
  .sidenav .brand:hover { background: none; }
  .sidenav a.on { box-shadow: inset 3px 0 0 var(--brand-red); }
  .sidenav a {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
    color: var(--text); text-decoration: none; font-weight: 550;
  }
  .sidenav a:hover { background: var(--surface-2); }
  .sidenav a.on { background: var(--accent-soft); color: var(--accent); }
  .shell { margin-left: 232px; }
  .topbar { padding-left: 32px; padding-right: 32px; }
  .main { padding: 24px 32px 48px; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent;
  background: var(--accent); color: var(--accent-ink);
  font: inherit; font-weight: 650; text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.btn:active { background: var(--accent-press); }
.btn:focus-visible, .iconbtn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px;
}
.btn-sm { min-height: 40px; padding: 0 12px; font-size: .92rem; border-radius: 10px; }
.btn-sm .icon { width: 18px; height: 18px; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn-ghost:active { background: var(--surface-2); }
.btn-danger { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.iconbtn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; margin-left: -8px;
  border-radius: 10px; color: var(--text);
}
.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin: 14px 0; }
.actions .btn { padding: 0 10px; font-size: .95rem; white-space: nowrap; }
.actions .btn .icon { width: 20px; height: 20px; }
.stack { display: grid; gap: 10px; }
.form-actions {
  position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  margin: 20px -16px 0; padding: 12px 16px; background: var(--bg); border-top: 1px solid var(--line);
  display: flex; gap: 8px;
}
.form-actions .btn { flex: 1; }
@media (min-width: 900px) { .form-actions { position: static; margin: 24px 0 0; padding: 0; border: 0; background: none; } .form-actions .btn { flex: 0 0 auto; min-width: 160px; } }

/* ---------- Cards & rows ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}
.card + .card { margin-top: 12px; }
.list {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 64px;
  color: var(--text); text-decoration: none; border-top: 1px solid var(--line);
}
.row:first-child { border-top: 0; }
a.row:active { background: var(--surface-2); }
a.row > .icon { color: var(--muted); width: 18px; height: 18px; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { color: var(--muted); font-size: .875rem; }
.row-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.row-end { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.avatar {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .85rem;
}
.avatar-lg { width: 64px; height: 64px; font-size: 1.2rem; }

.chip {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px;
  font-size: .75rem; font-weight: 650; white-space: nowrap;
}
.chip-ok { background: var(--ok-bg); color: var(--ok); }
.chip-warn { background: var(--warn-bg); color: var(--warn); }
.chip-bad { background: var(--bad-bg); color: var(--bad); }
.chip-info { background: var(--info-bg); color: var(--info); }
.chip-muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat {
  display: block; padding: 14px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--text); text-decoration: none;
}
.stat-value { display: block; font-size: 1.6rem; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat-label { display: block; color: var(--muted); font-size: .82rem; font-weight: 550; margin-top: 2px; }
.stat-bad .stat-value { color: var(--bad); }
.stat-warn .stat-value { color: var(--warn); }

/* ---------- Detail list ---------- */
.dl { display: grid; gap: 0; margin: 0; }
.dl > div { display: grid; grid-template-columns: 8.5em 1fr; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.dl > div:first-child { border-top: 0; padding-top: 0; }
.dl dt { color: var(--muted); font-size: .9rem; }
.dl dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 340px) { .dl > div { grid-template-columns: 1fr; gap: 2px; } }

.profile { display: flex; gap: 14px; align-items: center; }
.profile h2 { margin: 0 0 6px; font-size: 1.35rem; }

/* ---------- Forms ---------- */
label, .label { display: block; font-weight: 600; font-size: .92rem; margin: 16px 0 6px; }
.card > .grid-2:first-child label { margin-top: 0; }
@media (max-width: 559px) { .card > .grid-2:first-child .field + .field label { margin-top: 16px; } }
.hint { color: var(--muted); font-size: .84rem; margin-top: 5px; }
input:not([type]), input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number], input[type=date], input[type=search], input[type=month], input[type=url], select, textarea {
  display: block; width: 100%; min-height: 48px; padding: 11px 13px;
  border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--text);
  font: inherit; font-size: 16px; /* 16px stops iOS zooming in on focus */
  appearance: none; -webkit-appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px; padding-right: 40px;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.grid-2 { display: grid; gap: 0 12px; }
@media (min-width: 560px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.check { display: flex; gap: 12px; align-items: flex-start; font-weight: 500; margin: 16px 0 0; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.prefix { position: relative; }
.prefix span { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; }
.prefix input { padding-left: 30px; }
.big-amount input { font-size: 1.6rem; font-weight: 700; min-height: 60px; }
.big-amount span { font-size: 1.3rem; }

/* Segmented choice buttons (radio inputs) */
.seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.seg-4 { grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seg-5 { grid-template-columns: repeat(5, 1fr); gap: 6px; }
.seg-4 span, .seg-5 span { padding: 6px 4px; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: flex; align-items: center; justify-content: center; text-align: center; min-height: 48px; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 11px; background: var(--surface); font-weight: 600; font-size: .92rem; cursor: pointer;
}
.seg input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.seg input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }

.search { position: relative; margin-bottom: 12px; }
.search .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 20px; height: 20px; }
.search input { padding-left: 42px; }
.filters { display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px 14px; padding: 0 16px 2px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters a {
  flex: none; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); text-decoration: none; font-weight: 600; font-size: .88rem; white-space: nowrap;
}
.filters a.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.filters a .count { color: inherit; opacity: .65; margin-left: 4px; }

.flash { padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; font-weight: 550; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-bad { background: var(--bad-bg); color: var(--bad); }
.flash-warn { background: var(--warn-bg); color: var(--warn); }
.flash-info { background: var(--info-bg); color: var(--info); }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty .btn { margin-top: 6px; }

.summary { display: grid; gap: 0; }
.summary > div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.summary > div:first-child { border-top: 0; padding-top: 0; }
.summary .total { font-weight: 750; font-size: 1.1rem; }
.callout { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-top: 12px; font-size: .94rem; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tags button { font: inherit; font-size: .8rem; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); cursor: pointer; }
pre.code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow-x: auto; font-size: .82rem; white-space: pre-wrap; word-break: break-all; }
.table-wrap { overflow-x: auto; }
table.mapping { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.mapping td, table.mapping th { padding: 8px 6px; border-top: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.mapping select { min-height: 40px; padding: 6px 34px 6px 10px; font-size: 15px; }

/* Login */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth .card { width: 100%; max-width: 400px; padding: 24px; }
.auth .auth h1 { font-size: 1.4rem; margin-bottom: 4px; }

/* Logo */
.logo { display: block; height: auto; }
.logo-nav { width: 34px; flex: none; }
.auth .logo-auth { width: 92px; margin-bottom: 16px; }
.auth .card { border-top: 4px solid var(--brand-red); }
