@font-face { font-family: "Inter Variable"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("/fonts/inter-latin-wght-normal.woff2") format("woff2"); }
/* Backhouse UI: warm off-white page, one big white panel, hairline borders, soft shadows, a single green accent.
   Mobile first. From 1100px the sidebar and the page panel sit side by side. */
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --line: #e8e9ee;
  --line-strong: #dcdee4;
  --ink: #151515;
  --ink-2: #3b3b37;
  --muted: #6c6c66;
  --faint: #9b9b94;
  --hover: rgba(21, 21, 21, 0.045);
  --accent: #0a8021;
  --accent-ink: #07591a;
  --accent-soft: #e8f5ea;
  --accent-line: #bfe1c5;
  --bad: #b3261e;
  --bad-soft: #fdeceb;
  --bad-line: #f3c4c0;
  --warn-ink: #80520a;
  --warn-soft: #fff4dd;
  --warn-line: #f0d9a3;
  --r-panel: 24px;
  --r-card: 18px;
  --r-ctl: 10px;
  --tap: 46px;
  --font: "Inter Variable", Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --off-bg: #fdf0a8;
  --off-ink: #5a4a00;
  --shadow: 0 1px 2px rgba(20, 20, 15, 0.04), 0 8px 24px -10px rgba(20, 20, 15, 0.1);
  --shadow-sm: 0 1px 2px rgba(20, 20, 15, 0.06);
  /* theme cursors: a dark arrow, and the same arrow in the accent green over anything you can click */
  --cur-default: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M5 3.2v15.6l4.2-3.9 2.9 6.3 2.6-1.2-2.9-6.2h5.7z' fill='%23151515' stroke='%23ffffff' stroke-width='1.5' stroke-linejoin='round'/%3E%3C/svg%3E") 5 3, auto;
  --cur-pointer: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M5 3.2v15.6l4.2-3.9 2.9 6.3 2.6-1.2-2.9-6.2h5.7z' fill='%230a8021' stroke='%23ffffff' stroke-width='1.5' stroke-linejoin='round'/%3E%3C/svg%3E") 5 3, pointer;
  accent-color: #0a8021;
  /* chart categories, fixed order (validated palette) */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; cursor: var(--cur-default); }
a[href], summary, label[for], [role=button], [role=tab], [role=option], [role=radio] { cursor: var(--cur-pointer); }
button:disabled { cursor: var(--cur-default); }
input, textarea { caret-color: var(--accent); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14.5px/1.45 var(--font); font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { line-height: 1.2; margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.45rem; letter-spacing: -0.02em; }
h2 { font-size: 1rem; }
h3 { font-size: 0.95rem; }
p { margin: 0; }
a { color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
.icon { flex: none; display: block; }
.pad { padding: 12px; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.right { text-align: right; }
.num { font-variant-numeric: tabular-nums; }
.grow { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 8px; }
.partner-edit, .partner-add { gap: 10px; flex-wrap: nowrap; }
.partner-edit input, .partner-add input { flex: 1; min-width: 0; }
[hidden] { display: none !important; }

/* ================= Shell: phone first ================= */
#sidebar { display: contents; }
#sidebar .ws, #favs, #nav-foot, #sidebar .usercard, #sidebar .logout { display: none; }
#topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 8px; padding: 7px 14px; padding-top: calc(7px + env(safe-area-inset-top));
  background: rgba(244, 245, 247, 0.92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 650; font-size: 1rem; color: var(--ink); text-decoration: none; }
.brand-mark, .ws-logo {
  display: grid; place-items: center; flex: none; color: #f5f6f8; background: #111;
  width: 26px; height: 26px; border-radius: 8px;
}
.logo-mark { display: block; }
#who { margin-left: auto; text-decoration: none; }
#logout-top { color: var(--ink-2); }
.avatar {
  display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 50%; font-size: 0.75rem; font-weight: 650;
  color: var(--c-ink, var(--accent-ink)); background: var(--c-soft, var(--accent-soft)); border: 1px solid var(--c-line, var(--accent-line));
}
.avatar.lg { width: 44px; height: 44px; font-size: 1rem; }
.avatar.xs { width: 24px; height: 24px; font-size: 0.62rem; }
#nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex; background: rgba(255, 255, 255, 0.96); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
#nav a {
  flex: 1; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 0.68rem; font-weight: 500;
}
#nav a.active { color: var(--accent); }
#nav .desk-only { display: none; }
.nav-pill { display: none; }
@media (min-width: 1100px) { .nav-pill { display: block; } }
@media (max-width: 1099px) { .single-nav #nav { display: none; } .single-nav #stage { padding-bottom: 20px; } }
#stage { padding: 12px 12px calc(80px + env(safe-area-inset-bottom)); }
main#view { max-width: 980px; margin: 0 auto; outline: none; }
.booting main#view::before { content: "Loading…"; color: var(--muted); }
body.logged-out #nav, body.logged-out #topbar .avatar, body.logged-out #logout-top { display: none !important; }
body.logged-out #stage { padding-bottom: 24px; }

/* ================= Shell: desktop ================= */
@media (min-width: 1100px) {
  #app { display: grid; grid-template-columns: 218px minmax(0, 1fr); column-gap: 8px; align-items: start; min-height: 100vh; padding: 8px; }
  #topbar { display: none; }
  #sidebar {
    display: flex; flex-direction: column; position: sticky; top: 8px; height: calc(100vh - 16px); padding: 0 2px; overflow-y: auto;
  }
  #sidebar .ws {
    display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel);
    box-shadow: var(--shadow-sm); text-decoration: none; color: var(--ink);
  }
  .ws-logo { width: 34px; height: 34px; border-radius: 10px; }
  .ws-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
  .ws-text b { font-weight: 600; }
  .ws-text span { color: var(--muted); font-size: 0.8rem; }
  #nav {
    position: relative; display: flex; flex-direction: column; gap: 2px; margin-top: 28px; padding: 0; background: none; border: 0;
    backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  #nav a {
    flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: 10px; min-height: 36px; padding: 0 12px; border-radius: 10px;
    font-size: 0.95rem; font-weight: 450; color: var(--ink-2); border: 1px solid transparent;
  }
  #nav a:hover { background: var(--hover); }
  #nav a.active { color: var(--ink); font-weight: 500; }
  #nav a { position: relative; z-index: 1; }
  .nav-pill {
    position: absolute; left: 0; right: 0; top: 0; height: var(--h, 35px); transform: translateY(var(--y, 0px)); border-radius: 10px;
    background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-sm); opacity: 0; pointer-events: none;
  }
  .nav-pill.on { opacity: 1; }
  .nav-pill.placed { transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1), height 0.35s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease; }
  #nav .mobile-only { display: none; }
  #nav .desk-only { display: flex; }
  #favs { display: block; margin-top: 16px; padding: 0 4px; }
  .fav-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 8px; margin-bottom: 4px; }
  .fav-title { color: var(--muted); font-size: 0.82rem; }
  .fav-all { color: var(--muted); font-size: 0.78rem; text-decoration: none; }
  .fav-all:hover { color: var(--accent); }
  .fav {
    display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 8px; border-radius: 10px; color: var(--ink-2); text-decoration: none;
    font-size: 0.92rem; border: 1px solid transparent;
  }
  .fav + .fav { margin-top: 2px; }
  .fav:hover { background: var(--hover); }
  .fav.active { color: var(--ink); font-weight: 600; background: var(--panel); border-color: var(--line); box-shadow: var(--shadow-sm); }
  .fav-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* History and Settings sit together at the bottom, just above Log out */
  #nav-foot { display: flex; flex-direction: column; gap: 2px; margin-top: auto; padding-top: 14px; }
  #nav-foot a {
    display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid transparent;
    font-size: 0.95rem; font-weight: 450; color: var(--ink-2); text-decoration: none;
  }
  #nav-foot a:hover { background: var(--hover); }
  #nav-foot a.active { color: var(--ink); font-weight: 500; background: var(--panel); border-color: var(--line); box-shadow: var(--shadow-sm); }
  #sidebar .logout {
    display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 10px; min-height: 38px; padding: 0 12px; border-radius: 10px;
    border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow-sm); color: var(--ink-2); font: inherit; font-size: 0.92rem; font-weight: 500;
    cursor: var(--cur-pointer);
  }
  #sidebar .logout:hover { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); }
  #sidebar .usercard {
    display: flex; align-items: center; gap: 10px; margin-top: 2px; padding: 7px 10px; border-radius: 12px; color: var(--ink); text-decoration: none;
  }
  .usercard:hover { background: var(--hover); }
  .usercard .avatar { width: 32px; height: 32px; font-size: 0.8rem; }
  .usercard .who { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.25; }
  .usercard .who b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .usercard .who span { color: var(--muted); font-size: 0.78rem; }

  #stage {
    position: relative; min-width: 0; min-height: calc(100vh - 16px); padding: 22px 26px 30px; background: var(--panel); border: 1px solid var(--line);
    border-radius: var(--r-panel); box-shadow: var(--shadow);
  }
  main#view { max-width: none; margin: 0; }
  body.logged-out #app { display: block; padding: 0; }
  body.logged-out #sidebar { display: none; }
  body.logged-out #stage { min-height: 0; padding: 0 12px 24px; background: none; border: 0; box-shadow: none; }
}

/* ================= Page structure ================= */
main#view > * + * { margin-top: 12px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 2px; }
.page-title h1 { margin-top: 0; }
.page-sub { color: var(--muted); margin-top: 1px; font-size: 0.9rem; }
.page-head .row { flex-wrap: nowrap; gap: 6px; align-self: center; }
.page-head .row .dd { width: auto; min-width: 130px; }
.page-head .row .btn { padding: 0 11px; }
.note { color: var(--muted); font-size: 0.82rem; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 14px; }
.card h2 { margin-bottom: 8px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 9px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.card-head h2 { margin: 0; font-weight: 550; font-size: 0.95rem; }
.card-head .icon { color: var(--ink); }
.card-head .end { margin-left: auto; color: var(--muted); font-size: 0.8rem; }
.card-body { padding: 12px 14px 14px; }
.card.flush .table-wrap { margin: 0; padding: 0; }
.cards-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 12px; }
.cards-2 > * { margin-top: 0 !important; min-width: 0; }
.cards-2 > .card.flush { display: flex; flex-direction: column; }
.cards-2 > .card.flush > .card-body, .cards-2 > .card.flush > .recent { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.cards-2 > .card.flush > .card-body > *, .cards-2 > .card.flush > .recent > * { width: 100%; }
.recent { justify-content: space-around; }
.empty { text-align: center; color: var(--muted); padding: 18px 10px; }
.banner { border-radius: 10px; padding: 8px 12px; background: var(--warn-soft); border: 1px solid var(--warn-line); color: var(--warn-ink); font-size: 0.86rem; }
.banner.bad { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); }
.banner.off { background: var(--off-bg); border-color: #e6d27a; color: var(--off-ink); font-weight: 550; }
.banner.ok { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-ink); }

/* Status chips */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 7px; border-radius: 7px; font-size: 0.74rem; font-weight: 500; white-space: nowrap;
  color: var(--ink-2); background: #f5f6f8; border: 1px solid var(--line);
}
.chip.ok, .chip.bad, .chip.grey, .chip.amber { padding-left: 6px; }
.chip.ok::before, .chip.bad::before, .chip.grey::before, .chip.amber::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.chip.ok { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-ink); }
.chip.bad { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); }
.chip.amber { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn-ink); }
.chip.grey { background: #f3f4f7; border-color: var(--line); color: var(--muted); }

/* ================= Buttons ================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: var(--r-ctl);
  border: 1px solid var(--ink); background: var(--ink); color: #fff; font-weight: 550; cursor: var(--cur-pointer); text-decoration: none;
}
.btn:hover { background: #2b2b28; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #086d1c; border-color: #086d1c; }
.btn.ghost { background: var(--panel); color: var(--ink); border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.btn.ghost:hover { background: #f6f7f9; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.big { min-height: var(--tap); font-size: 1rem; width: 100%; border-radius: 12px; }
.btn.sm { min-height: 28px; padding: 0 10px; font-size: 0.82rem; border-radius: 8px; }
.btn:disabled { opacity: 0.5; cursor: var(--cur-default); }
.icon-btn { border: 0; background: none; font-size: 1rem; min-width: 36px; min-height: 36px; cursor: var(--cur-pointer); border-radius: 8px; color: var(--muted); }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.link { background: none; border: 0; padding: 4px 0; color: var(--muted); text-decoration: underline; cursor: var(--cur-pointer); font-size: 0.85rem; }
.link:disabled { color: var(--faint); text-decoration: none; cursor: var(--cur-default); }

/* ================= Forms ================= */
.field { display: block; }
.field > .label { display: block; font-weight: 550; margin-bottom: 4px; font-size: 0.85rem; }
.field .hint { color: var(--muted); font-size: 0.78rem; margin-top: 3px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input[type=month], input[type=search], input[type=tel], textarea {
  width: 100%; min-height: 38px; padding: 6px 11px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); background: var(--panel);
  appearance: none; -webkit-appearance: none; box-shadow: var(--shadow-sm);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, textarea:focus { outline: none; border-color: var(--ink); }
.btn:focus-visible, .pill:focus-visible, .cell:focus-visible, a:focus-visible, button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
/* In-app dropdown (see selectInput in ui.js) */
.dd {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 38px; padding: 6px 11px; text-align: left; cursor: var(--cur-pointer);
  border: 1px solid var(--line-strong); border-radius: var(--r-ctl); background: var(--panel); box-shadow: var(--shadow-sm); color: var(--ink);
}
.dd:hover { border-color: #b8bcc6; }
.dd-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd .icon { color: var(--muted); transition: transform 0.15s ease; }
.dd[aria-expanded="true"] { border-color: var(--ink); }
.dd[aria-expanded="true"] .icon { transform: rotate(180deg); }
.dd:disabled { opacity: 0.55; cursor: var(--cur-default); }
.dd-menu {
  position: fixed; z-index: 300; width: max-content; max-width: calc(100vw - 16px); overflow-y: auto; padding: 4px; outline: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 18px 44px rgba(20, 20, 15, 0.18), 0 2px 6px rgba(20, 20, 15, 0.06);
}
.dd-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 32px; padding: 0 10px; border-radius: 8px; cursor: var(--cur-pointer); }
.dd-item.active { background: var(--hover); }
.dd-item[aria-selected="true"] { font-weight: 600; }
.dd-item .icon { color: var(--accent); }
.money { position: relative; }
.money::before { content: "£"; position: absolute; left: 11px; top: 50%; transform: translateY(-50%); font-weight: 600; color: var(--muted); pointer-events: none; }
.money input[type=text], .money input[type=number] { padding-left: 26px; font-variant-numeric: tabular-nums; }
.money.big input[type=text] { font-size: 1.6rem; font-weight: 600; letter-spacing: -0.02em; min-height: 52px; padding-left: 34px; }
.money.big::before { font-size: 1.3rem; left: 13px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.form > * + * { margin-top: 11px; }
.msg { border-radius: 10px; padding: 8px 12px; font-weight: 550; font-size: 0.9rem; }
.msg.ok { background: var(--accent-soft); color: var(--accent-ink); border: 1px solid var(--accent-line); }
.msg.err { background: var(--bad-soft); color: var(--bad); border: 1px solid var(--bad-line); }
details.more > summary { cursor: var(--cur-pointer); color: var(--muted); font-weight: 500; padding: 3px 0; font-size: 0.88rem; }
details.more[open] > summary { margin-bottom: 6px; }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  min-height: 34px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--panel); color: var(--ink);
  font-weight: 500; cursor: var(--cur-pointer); box-shadow: var(--shadow-sm);
}
.pill:hover { border-color: #b8bcc6; }
.pill[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill.cashflow[aria-checked="true"] { background: var(--ink); border-color: var(--ink); }
.pill.off[aria-checked="true"] { background: var(--off-bg); border-color: #e6d27a; color: var(--off-ink); font-weight: 650; }

.tabs { display: flex; gap: 3px; background: #eceef2; padding: 3px; border-radius: 11px; }
.tab {
  flex: 1; min-height: 32px; border: 1px solid transparent; border-radius: 8px; background: transparent; font-weight: 550; color: var(--muted); cursor: var(--cur-pointer);
  display: flex; align-items: center; justify-content: center; text-decoration: none; padding: 0 10px; text-align: center; font-size: 0.9rem;
}
.tab[aria-selected="true"] { background: var(--panel); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow-sm); }
.period-tabs { max-width: 400px; }
.period-tabs .tab { font-size: 0.88rem; }
.big-tabs .tab { min-height: 54px; flex-direction: column; gap: 3px; font-size: 0.82rem; }

/* ================= Add entry panel ================= */
.entry-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 14px; }
.entry-card > * + * { margin-top: 11px; }
.undo-row { text-align: center; }
.undo-row .small { display: block; color: var(--muted); }

/* ================= Lists and tables ================= */
.list > .item { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.list > .item:first-child { border-top: 0; }
.item .main { flex: 1; min-width: 0; }
.item .title { font-weight: 550; overflow-wrap: anywhere; }
.item.off .title { color: var(--faint); }
.item .sub { color: var(--muted); font-size: 0.8rem; display: flex; gap: 5px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.item .amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.t { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.t th, table.t td { padding: 7px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td.wrap { white-space: normal; min-width: 200px; }
table.t th { font-size: 0.78rem; font-weight: 500; color: var(--muted); background: #fafbfc; }
table.t tbody tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover td { background: #fafbfc; }
table.t td.r, table.t th.r { text-align: right; font-variant-numeric: tabular-nums; }
table.t tfoot td { font-weight: 600; border-top: 1px solid var(--line-strong); border-bottom: 0; background: #fafbfc; }
table.t tr.hl td { background: var(--accent-soft); }
.person { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; text-decoration: none; }
.person:hover span:last-child { text-decoration: underline; }
.person .avatar { width: 28px; height: 28px; font-size: 0.7rem; }
.back { display: inline-flex; align-items: center; gap: 2px; text-decoration: none; }
.person-head { display: flex; align-items: center; gap: 12px; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin-bottom: 10px; }

/* ================= Stat cards (dashboard) ================= */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.stat { display: flex; flex-direction: column; min-width: 0; padding: 11px 13px 9px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.stat-top { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 0.9rem; }
.stat-go {
  margin-left: auto; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel);
  color: var(--ink-2); box-shadow: var(--shadow-sm);
}
.stat-go:hover { background: var(--hover); }
.stat-row { display: flex; align-items: baseline; justify-content: space-between; gap: 2px 8px; margin-top: 8px; padding-left: 26px; flex-wrap: wrap; }
.stat-val { font-size: 1.3rem; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-val.over { color: var(--bad); }
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.delta.good { color: var(--accent); }
.delta.bad { color: var(--bad); }
.delta.flat { color: var(--muted); }
.spark { display: block; width: 100%; height: 44px; margin-top: auto; padding-top: 4px; box-sizing: content-box; }
.stat-sub { color: var(--muted); font-size: 0.76rem; margin-top: 4px; padding-left: 26px; }
.stat-top .icon, .card-head .icon { stroke-width: 2; }
.meter { position: relative; height: 7px; margin: 14px 0 4px; border-radius: 999px; background: #eceef2; }
.meter-fill { position: absolute; left: 0; top: 0; bottom: 0; width: var(--w, 0%); border-radius: 999px; background: var(--c, var(--accent)); }
.meter-target { position: absolute; top: -4px; bottom: -4px; left: var(--t, 0%); width: 2px; border-radius: 2px; background: var(--ink); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); padding: 9px 12px; }
.tile .k { color: var(--muted); font-size: 0.78rem; }
.tile .v { font-size: 1.2rem; font-weight: 600; letter-spacing: -0.02em; margin-top: 2px; overflow-wrap: anywhere; }
.tile .s { color: var(--muted); font-size: 0.76rem; margin-top: 1px; }
.tile.good .v { color: var(--accent); }
.tile.bad .v { color: var(--bad); }
.tile.hero { background: var(--accent-soft); border-color: var(--accent-line); }
.tile.hero.bad { background: var(--bad-soft); border-color: var(--bad-line); }
.tile.hero.bad .v { color: var(--bad); }
.tile.hero .k { color: var(--ink-2); }

.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 4px; background: var(--c, var(--s1)); flex: none; }

/* ================= Chart ================= */
.chart-wrap { position: relative; }
.chart { width: 100%; height: auto; display: block; }
.chart text { font: 11px var(--font); fill: #6c6c66; }
.chart .grid { stroke: #eceef2; stroke-width: 1; }
.chart .axis { stroke: #dcdee4; stroke-width: 1; }
.chart .focus { fill: #f5f5f2; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hit:hover, .chart .hit:focus { fill: rgba(21, 21, 21, 0.04); outline: none; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; font-size: 0.78rem; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .line-key { width: 18px; height: 3px; border-radius: 2px; background: var(--ink); }
.tip {
  position: absolute; z-index: 5; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px;
  box-shadow: 0 10px 30px rgba(20, 20, 15, 0.16); font-size: 0.78rem; min-width: 200px; transform: translate(-50%, 0);
}
.tip b { display: block; margin-bottom: 4px; }
.tip div { display: flex; justify-content: space-between; gap: 14px; }
.tip div b { display: inline; margin: 0; }

/* Partner charts */
.donut-wrap { display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
.donut { width: 168px; height: 168px; flex: none; align-self: center; }
.donut .seg { cursor: var(--cur-pointer); outline: none; transition: opacity 0.12s ease; }
.donut.dim .seg:not(.on) { opacity: 0.35; }
.donut .seg.on, .donut .seg:focus-visible { stroke-width: 19; }
.donut-value { font: 600 24px var(--font); fill: var(--ink); letter-spacing: -0.02em; }
.donut-label { font: 13px var(--font); fill: var(--muted); }
.legend-list { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.legend-row { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto 52px; gap: 8px; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 0.86rem; }
.legend-row:last-child { border-bottom: 0; }
.legend-row .num:last-child { text-align: right; font-weight: 600; color: var(--ink); }
.legend-row .legend-name { color: var(--ink-2); }
.chart .name { font: 500 13px var(--font); fill: var(--ink); }
.chart .bar-value { font: 600 13px var(--font); fill: var(--ink); paint-order: stroke; stroke: #fff; stroke-width: 3px; stroke-linejoin: round; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin-top: 10px; }
.kpi .k { color: var(--muted); font-size: 0.78rem; }
.kpi .v { font-size: 1.02rem; font-weight: 600; letter-spacing: -0.01em; }
.kpi.good .v { color: var(--accent); }
.kpi.bad .v { color: var(--bad); }
details.more .table-wrap { margin-top: 6px; border: 1px solid var(--line); border-radius: 10px; }

/* Costs page: list on the left, Add entry docked on the right (desktop only) */
.split-main { min-width: 0; }
.split-main > * + * { margin-top: 12px; }
.cost-charts { display: flex; flex-direction: column; gap: 12px; }
.cost-charts .cards-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.entry-card > h2 { font-size: 1.02rem; }
/* Phones: the Add entry panel sits above the list */
.split.has-side { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.split.has-side .split-side { order: -1; }
@media (min-width: 1100px) {
  .split.has-side { grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: start; }
  .split.has-side .split-side { order: 0; }
  .split-side { position: sticky; top: 14px; max-height: calc(100vh - 36px); overflow-y: auto; border-radius: var(--r-card); }
}

/* ================= Rota: a plain grid like the spreadsheet it replaces ================= */
.rota-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rota-bar .dd { flex: 1; min-width: 180px; width: auto; }
.rota-bar .dd.staff-filter { flex: 0 0 180px; }
.rota-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--panel); }
.rota { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 0.86rem; }
.rota th, .rota td { padding: 0; text-align: center; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.rota th:last-child, .rota td:last-child { border-right: 0; }
.rota tbody tr:last-child td { border-bottom: 0; }
.rota thead th { background: #edf0f4; padding: 8px 6px; font-weight: 600; font-size: 0.82rem; line-height: 1.3; border-bottom: 2px solid var(--line-strong); }
.rota thead th .d { display: block; white-space: nowrap; }
.rota thead th .w { display: block; margin-top: 2px; font-size: 0.74rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-2); }
.rota thead th.locked-h { color: #a8aeb9; }
.rota th.who, .rota td.who { position: sticky; left: 0; z-index: 2; background: var(--panel); text-align: left; padding: 0 12px; min-width: 124px; max-width: 160px; border-right: 2px solid var(--line-strong); }
.rota thead th.who { background: #edf0f4; }
.rota td.who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; font-size: 0.8rem; letter-spacing: 0.03em; text-transform: uppercase; }
.rota th.tot, .rota td.tot { min-width: 100px; text-align: right; padding: 0 14px; white-space: nowrap; }
.rota td.tot b { display: block; font-weight: 700; font-variant-numeric: tabular-nums; }
.rota td.tot small { display: block; color: var(--muted); font-size: 0.74rem; font-variant-numeric: tabular-nums; }
.rota tfoot td { background: #f6f7f9; font-weight: 700; padding: 9px 6px; font-variant-numeric: tabular-nums; border-bottom: 0; border-top: 2px solid var(--line-strong); }
.rota tfoot td.who { background: #f6f7f9; text-transform: none; }
.rota tfoot td.tot { padding: 6px 14px; }
.rota td { height: 46px; }
.cell { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; min-width: 96px; min-height: 46px; padding: 4px 6px; border: 0; background: transparent; cursor: var(--cur-pointer); font-size: 0.85rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rota td:hover > .cell:not(.locked) { background: #f2f4f7; }
.cell.empty-cell { color: #c3c8d1; font-size: 1.05rem; }
.rota td.off { background: var(--off-bg); }
.cell.off { color: var(--off-ink); font-weight: 650; letter-spacing: 0.04em; }
.rota td.off:hover > .cell { background: #fbe888 !important; }
.rota td.locked { background: repeating-linear-gradient(135deg, #f6f7f9, #f6f7f9 6px, #eceef2 6px, #eceef2 12px); }
.cell.locked { cursor: not-allowed; }
.tabs.mini { display: inline-flex; flex: none; padding: 3px; border-radius: 10px; }
.tabs.mini .tab { flex: 0 0 auto; min-height: 28px; padding: 0 12px; border-radius: 8px; font-size: 0.82rem; white-space: nowrap; }
.rota tr.grp td { height: 34px; background: #f3f5f8; border-bottom: 1px solid var(--line); }
.rota tr.grp td.who { font-weight: 650; font-size: 0.74rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); }
.rota tr.grp td.tot b { font-weight: 600; font-size: 0.82rem; }
.rota-month th { min-width: 98px; }
.rota-month td.wk { padding: 4px 8px; text-align: center; font-variant-numeric: tabular-nums; }
.rota-month td.wk b { display: block; font-weight: 600; }
.rota-month td.wk small { display: block; color: var(--muted); font-size: 0.74rem; }
.rota-month th.st, .rota-month td.st { min-width: 96px; padding: 0 10px; text-align: center; white-space: nowrap; }
.rota-month .none { color: #c3c8d1; }
.wk-link { display: block; color: inherit; text-decoration: none; }
.wk-link:hover .d { text-decoration: underline; }
.rota-actions { display: flex; flex-direction: column; gap: 6px; }

/* Staff phone view */
.day { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-top: 1px solid var(--line); }
.day:first-of-type { border-top: 0; }
.day .d { width: 56px; flex: none; }
.day .d b { display: block; }
.day .d span { color: var(--muted); font-size: 0.82rem; }
.day .what { flex: 1; font-size: 0.98rem; font-weight: 600; }
.day .what small { display: block; color: var(--muted); font-weight: 400; font-size: 0.82rem; }
.day.today { background: var(--accent-soft); border-radius: 10px; margin: 0 -6px; padding-left: 10px; padding-right: 10px; border-top-color: transparent; } /* the tint reaches out so the text lines up with the other days */
.day.none .what, .day.locked .what { color: var(--faint); font-weight: 500; }
.off-pill { display: inline-block; padding: 3px 14px; border-radius: 8px; background: var(--off-bg); color: var(--off-ink); font-weight: 650; letter-spacing: 0.04em; }

/* ================= Modal, toast ================= */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(20, 20, 15, 0.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--panel); width: 100%; max-width: 520px; max-height: 92vh; display: flex; flex-direction: column; border-radius: 18px 18px 0 0; box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.2); }
.sheet.wide { max-width: 760px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 6px 2px 16px; }
.sheet-body { padding: 6px 16px 12px; overflow-y: auto; }
.sheet-actions { display: flex; gap: 8px; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); flex-wrap: wrap; }
.sheet-actions .btn { flex: 1; }
@media (min-width: 700px) { .overlay { align-items: center; } .sheet { border-radius: 18px; } }
#toasts { position: fixed; left: 0; right: 0; bottom: calc(70px + env(safe-area-inset-bottom)); z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
@media (min-width: 1100px) { #toasts { bottom: 24px; } }
.toast { background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 10px; font-size: 0.9rem; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); font-weight: 500; max-width: 520px; }
.toast.err { background: var(--bad); }

/* ================= Login, More ================= */
.login { max-width: 360px; margin: 6vh auto 0; padding: 20px 18px; overflow: hidden; }
.login-hero { display: grid; place-items: center; margin: -20px -18px 2px; padding: 26px 18px 22px; background: #0b0b0b; }
.login-hero img { display: block; width: min(250px, 80%); height: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.menu a { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-top: 1px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 500; min-height: 46px; }
.menu a:first-child { border-top: 0; }
.menu .icon { color: var(--ink-2); }

/* Dashboard pieces from the reference: date box list, share meters, icon headers, icon buttons */
.datebox { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 38px; height: 38px; flex: none; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); box-shadow: var(--shadow-sm); line-height: 1.1; }
.datebox small { font-size: 0.58rem; font-weight: 650; letter-spacing: 0.05em; color: #c2413b; }
.datebox b { font-size: 0.95rem; font-weight: 600; }
.recent { padding: 4px 8px 8px; }
.recent-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; text-decoration: none; color: inherit; }
.recent-item:hover { background: var(--hover); }
.recent-bar { align-self: stretch; width: 5px; min-height: 28px; flex: none; border-radius: 3px; background: var(--c, var(--s1)); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.14); }
.recent-main { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.recent-main b { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-main small { color: var(--muted); font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-amt { font-weight: 600; }
.recent-item > .icon { color: var(--muted); }
.share-head { display: flex; align-items: baseline; justify-content: space-between; margin-top: 8px; font-size: 0.9rem; }
.share-head span { color: var(--muted); }
.share-head b { font-size: 1.15rem; font-weight: 600; letter-spacing: -0.02em; }
.share-head b.over { color: var(--bad); }
.share-row .meter { margin: 8px 0 3px; }
.stat > .share-row { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.th-in { display: inline-flex; align-items: center; gap: 5px; }
th.r .th-in { justify-content: flex-end; }
.icon-link { display: inline-grid; place-items: center; width: 28px; height: 28px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--panel); box-shadow: var(--shadow-sm); color: var(--ink-2); }
.icon-link:hover { background: var(--hover); }
.person-text { display: flex; flex-direction: column; line-height: 1.25; }
.person-text b { font-weight: 550; }
.person-text small { color: var(--muted); font-size: 0.76rem; font-weight: 400; }
.chart .pill-box { fill: #fff; stroke: var(--line-strong); stroke-width: 1; }
.chart .pill-text { font: 600 12px var(--font); fill: var(--ink); }
.chart .day-on { fill: var(--ink); font-weight: 600; }

/* Desktop type scale, matched to the reference: small, quiet type with the same proportions */
@media (min-width: 1100px) {
  html { font-size: 13px; }
  body { font-size: 1rem; }
  h1 { font-size: 1.55rem; }
  #nav a { min-height: 35px; font-size: 0.96rem; gap: 9px; }
  .fav { min-height: 32px; }
  .chip { font-size: 0.8rem; }
  .delta { font-size: 0.82rem; }
  .note { font-size: 0.88rem; }
  .btn { min-height: 32px; }
  .btn.sm { min-height: 26px; }
  .btn.big { min-height: 42px; }
  input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input[type=month], input[type=search], input[type=tel], textarea, .dd { min-height: 34px; padding: 5px 10px; }
  .pill { min-height: 30px; padding: 0 11px; }
  .tab { min-height: 28px; }
  .big-tabs .tab { min-height: 48px; }
  .money.big input[type=text] { min-height: 46px; font-size: 1.5rem; }
  .card-head { padding: 9px 14px; }
  table.t th, table.t td { padding: 9px 14px; }
  .stat-val { font-size: 1.4rem; }
  .stat-top { font-size: 0.95rem; }
}


/* Toggle switch */
.switch { position: relative; flex: none; width: 36px; height: 20px; border: 0; border-radius: 999px; background: #d4d8df; cursor: var(--cur-pointer); transition: background 0.15s ease; padding: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.15s ease; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(16px); }
.switch:disabled { opacity: 0.5; cursor: var(--cur-default); }
.switch-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: var(--shadow-sm); }
.switch-row > div { flex: 1; min-width: 0; line-height: 1.3; }
.switch-row small { display: block; color: var(--muted); font-size: 0.8rem; }

/* Member rows (Users): avatar with a status dot, role dropdown, status chip */
.members { display: flex; flex-direction: column; gap: 8px; }
.member { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); box-shadow: var(--shadow-sm); flex-wrap: wrap; }
.member-main { flex: 1; min-width: 160px; display: flex; flex-direction: column; line-height: 1.3; }
.member.inactive .member-main b { color: var(--faint); }
.staff-group { display: flex; flex-direction: column; gap: 8px; }
.group-title { font-size: 0.8rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }
.group-title .muted { font-weight: 500; }
.member-main small { color: var(--muted); font-size: 0.82rem; overflow-wrap: anywhere; }
.member-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.avatar-wrap { position: relative; flex: none; display: inline-flex; }
.status-dot { position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; background: #2fa04a; border: 2px solid #fff; }
.status-dot.off { background: #b8bcc6; }
.dd.compact { width: auto; min-height: 28px; padding: 2px 8px 2px 10px; border-radius: 8px; background: #f6f7f9; font-weight: 600; font-size: 0.88rem; color: var(--ink-2); box-shadow: none; }
.dd.compact:disabled { opacity: 1; }
.chip.plain-role { background: #f6f7f9; font-weight: 600; font-size: 0.88rem; padding: 3px 10px; }

/* Phones and tablets: the stat cards sit two by two, like the reference */
@media (max-width: 1099px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 699px) {
  .hide-sm { display: none; }

  /* Dashboard on a phone, laid out like the reference: title and period picker share a row, the comparison sits in a banner, cards two by two */
  .dash-head { flex-wrap: nowrap; align-items: flex-start; }
  .dash-head .page-title { flex: 1; min-width: 0; }
  .dash-head > .row { flex: none; align-self: flex-start; }
  .dash-head > .row > .btn { display: none; }
  .dash-head > .row .dd { min-width: 0; }
  .compare { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
  .compare-ico { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 10px; background: var(--accent-soft, #e8f4ea); color: var(--accent); }
  .compare .note { margin: 0; line-height: 1.35; }
  .stat-row, .stat-sub { padding-left: 0; }
  .stat { padding: 11px 12px 10px; }
  .stat-val { font-size: 1.2rem; }
  .stat.compact .spark { display: none; }
  .stat.compact .stat-sub { margin-top: 6px; }
}
.compare-ico { display: none; }
@media (max-width: 699px) { .compare-ico { display: inline-flex; } }

/* Rota toolbar on a phone: the wages switch across the top, then previous / week / next, then the staff filter, each on its own tidy row */
@media (max-width: 699px) {
  .rota-bar { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; gap: 8px; align-items: stretch; }
  .rota-bar > .tabs.mini { grid-column: 1 / -1; display: flex; }
  .rota-bar > .tabs.mini .tab { flex: 1 1 0; display: flex; align-items: center; justify-content: center; min-height: 32px; font-size: 0.88rem; }
  .rota-bar > .btn { width: 44px; padding: 0; }
  .rota-bar > .chip { display: none; } /* the week picker already says this week, past or planned */
  .rota-bar .dd { width: 100%; min-width: 0; flex: none; }
  .rota-bar .dd.staff-filter { grid-column: 1 / -1; }
  .rota tr.grp td.who { white-space: nowrap; text-transform: none; letter-spacing: 0; font-size: 0.8rem; }
}
.compare .note { margin: 0; }
.card-head .end .view-all { display: inline-flex; align-items: center; gap: 2px; color: var(--accent); font-weight: 500; text-decoration: none; }

/* Motion: everything eases the same way (a soft spring), and nothing moves for people who ask for less motion */
.btn, .pill, .tab, .dd, input, textarea, .icon-btn, .chip, .stat-go, .icon-link, .fav, #nav a, .recent-item, .member, table.t tbody tr td { transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease; }
.btn:active, .pill:active { transform: scale(0.98); }
#view.leaving { opacity: 0; transform: translateY(-6px); transition: opacity 0.14s ease, transform 0.14s ease; }
#view.enter > * { animation: rise 0.6s cubic-bezier(0.22, 1, 0.36, 1) both; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(0.992); filter: blur(3px); } to { opacity: 1; transform: none; filter: blur(0); } }
.dd-menu { animation: pop 0.18s cubic-bezier(0.22, 1, 0.36, 1) both; transform-origin: top left; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }
.overlay { animation: fade 0.2s ease both; }
.sheet { animation: sheet 0.4s cubic-bezier(0.22, 1, 0.36, 1) both; }
@keyframes fade { from { opacity: 0; } }
@keyframes sheet { from { opacity: 0; transform: translateY(18px) scale(0.985); } }
.toast { animation: toast 0.4s cubic-bezier(0.22, 1, 0.36, 1) both; }
@keyframes toast { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
.tip { animation: fade 0.12s ease both; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.001ms !important; animation-delay: 0ms !important; transition-duration: 0.001ms !important; } }

/* Touch screens keep generous tap targets; mouse screens get the dense layout. Inputs stay 16px so iOS doesn't zoom. */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn.sm { min-height: 36px; }
  .pill { min-height: 42px; }
  input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input[type=month], input[type=search], input[type=tel], textarea, .dd { min-height: 44px; font-size: 16px; }
  .dd-item { min-height: 40px; }
  .big-tabs .tab { min-height: 60px; }
  .cell { min-height: 58px; }
}

@media print { #nav, #topbar, #sidebar, .btn, .rota-bar { display: none !important; } #stage { border: 0; box-shadow: none; } }

/* ================= Phones and touch screens: roomy tap targets, and History as a list ================= */
@media (max-width: 699px), (pointer: coarse) {
  .tabs .tab { min-height: 40px; }
  .rota-bar > .tabs.mini .tab { min-height: 36px; }
  #who { display: inline-grid; place-items: center; width: 40px; height: 40px; margin-top: -5px; margin-bottom: -5px; margin-right: -5px; }
  .switch::before { content: ""; position: absolute; inset: -12px -8px; } /* the toggle looks the same, the tap area is bigger */
  .stat-go { position: relative; }
  .stat-go::before { content: ""; position: absolute; inset: -12px; }
  .card-head .end .view-all { min-height: 40px; }
  button.link { min-height: 40px; }
  .back { display: inline-flex; align-items: center; min-height: 36px; }
  details.more summary { display: flex; align-items: center; min-height: 40px; }
  .dd.compact { min-height: 36px; }
  input[type=file] { min-height: 40px; }
  a.person { min-height: 36px; }
  .icon-link { min-width: 36px; min-height: 36px; }
}
@media (max-width: 699px) {
  /* History filters: selects in pairs, then the dates side by side */
  .hist-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hist-filters > input[type=search] { order: 3; }
  .hist-filters > .field { order: 4; }
  .tiles .tile.hero { grid-column: 1 / -1; } /* an odd tile fills the last row instead of leaving a gap */

  /* History: each entry is a small card (who and when, what and amount, then the details) instead of a table that needs sideways scrolling */
  .hist thead { display: none; }
  .hist, .hist tbody { display: block; }
  table.t.hist tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "who when" "what amount" "details details";
    gap: 4px 10px; padding: 11px 14px; border-bottom: 1px solid var(--line);
  }
  table.t.hist tr:last-child { border-bottom: 0; }
  table.t.hist td { display: block; padding: 0; border: 0; white-space: normal; min-width: 0; }
  table.t.hist td:nth-child(1) { grid-area: when; text-align: right; color: var(--muted); font-size: 0.78rem; align-self: center; }
  table.t.hist td:nth-child(2) { grid-area: who; }
  table.t.hist td:nth-child(3) { grid-area: what; font-size: 0.82rem; color: var(--muted); align-self: center; }
  table.t.hist td:nth-child(4) { grid-area: details; font-size: 0.9rem; line-height: 1.35; overflow-wrap: anywhere; }
  table.t.hist td:nth-child(5) { grid-area: amount; font-weight: 600; align-self: center; }
}
