/* Trent District CFR Volunteer Portal: design system. Mobile first. */
@font-face { font-family: Inter; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/Inter-Regular.woff2") format("woff2"); }
@font-face { font-family: Inter; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/Inter-SemiBold.woff2") format("woff2"); }
@font-face { font-family: Inter; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/Inter-Bold.woff2") format("woff2"); }
@font-face { font-family: Inter; font-weight: 800; font-style: normal; font-display: swap; src: url("../fonts/Inter-ExtraBold.woff2") format("woff2"); }

:root {
  --ems-green: #00693e;
  --ems-green-dark: #00432a;
  --ems-green-tint: #e6f2ec;

  --nhs-blue: #005eb8;
  /* Shift categories: shared car = green, personal callsign = blue, EMAS scheme car = purple */
  --cat-shared: #00693e;
  --cat-shared-tint: #e6f2ec;
  --cat-personal: #005eb8;
  --cat-personal-tint: #e3eefa;
  --cat-scheme: #7a2a8c;
  --cat-scheme-tint: #f3e6f7;
  --cat-other: #425563;
  --cat-other-tint: #e9edf0;
  --cat-training: #8a4b00;
  --cat-training-tint: #fbf0dc;
  --nhs-dark-blue: #002d6b;

  --accent-yellow: #ffb81c;

  --donate: #d5281b;
  --donate-dark: #a81d13;

  --white: #ffffff;

  --grey-50: #f5f7f7;
  --grey-100: #eceff0;
  --grey-300: #d8dde0;

  --ink: #1b2226;
  --ink-soft: #45525a;

  --r-sm: 6px;
  --r-card: 12px;
  --r-panel: 20px;
  --r-pill: 999px;
  --shadow-sm: 0 1px 3px rgba(15,30,25,.08);
  --shadow-md: 0 8px 24px rgba(15,30,25,.10);
  --shadow-lg: 0 20px 48px rgba(15,30,25,.16);

  --font: Inter, "Segoe UI", "Helvetica Neue", Arial, system-ui, sans-serif;
  --header-h: 56px;
  --nav-h: 64px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --border-strong: #6b777e; /* 4.5:1 on white for form controls */
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--grey-50); color: var(--ink); font: 400 16px/1.5 var(--font);
  min-height: 100vh; min-height: 100dvh; overflow-x: hidden;
}
h1, h2, h3, h4 { font-weight: 800; color: var(--ems-green-dark); line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.125rem); }
h2 { font-size: clamp(1.25rem, 1.05rem + .9vw, 1.625rem); }
h3 { font-size: 1.25rem; }
h4 { font-size: 1rem; }
p { margin: 0 0 1em; }
a { color: var(--nhs-blue); }
img { max-width: 100%; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-soft); }
a.tap { display: inline-flex; align-items: center; min-height: 44px; }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 1000; background: var(--white); color: var(--ems-green-dark); padding: 10px 16px; border-radius: var(--r-pill); font-weight: 700; }
.skip-link:focus { top: calc(8px + var(--sat)); }

:focus-visible { outline: 3px solid var(--accent-yellow); outline-offset: 2px; box-shadow: 0 0 0 2px var(--ink); border-radius: var(--r-sm); }

.boot { min-height: 100dvh; display: grid; place-content: center; text-align: center; gap: 8px; color: var(--ems-green-dark); }
.boot img { border-radius: 50%; margin: 0 auto; }
.noscript { padding: 24px; text-align: center; }

/* ---------- Header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 50; background: var(--ems-green); color: var(--white);
  padding: var(--sat) max(12px, var(--sar)) 0 max(12px, var(--sal)); box-shadow: var(--shadow-sm);
}
.app-header-inner { height: var(--header-h); display: flex; align-items: center; gap: 8px; max-width: 1400px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--white); text-decoration: none; min-width: 0; flex: 1; min-height: 44px; }
.brand img { width: 36px; height: 36px; border-radius: 50%; flex: none; }
.brand-name { font-weight: 800; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-name .long { display: none; }
.icon-btn {
  display: inline-grid; place-items: center; min-width: 44px; min-height: 44px; padding: 0; border: 0; background: transparent;
  color: inherit; border-radius: var(--r-pill); font-size: 1.35rem; cursor: pointer; text-decoration: none; position: relative;
}
.icon-btn:hover { background: rgba(255,255,255,.14); }
.app-header .icon-btn { color: var(--white); }
.header-user { display: none; font-weight: 600; font-size: .9rem; }

/* ---------- Impersonation banner ---------- */
.imp-banner {
  position: sticky; top: calc(var(--header-h) + var(--sat)); z-index: 49; background: var(--accent-yellow); color: var(--ink);
  padding: 8px max(12px, var(--sar)) 8px max(12px, var(--sal)); display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between;
  border-bottom: 3px solid var(--ink); font-weight: 600;
}
.imp-banner .btn { background: var(--ink); color: var(--white); border-color: var(--ink); min-height: 44px; }

/* ---------- Layout ---------- */
.app-body { display: block; }
.sidebar { display: none; }
.content { padding: 16px max(16px, var(--sar)) calc(var(--nav-h) + var(--sab) + 28px) max(16px, var(--sal)); max-width: 1180px; margin: 0 auto; }
/* main is focused programmatically on route change; never draw a ring around the whole page */
.content:focus, .content:focus-visible { outline: none !important; box-shadow: none !important; border-radius: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.stack > * + * { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: 1fr; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

.card {
  background: var(--white); border: 1px solid var(--grey-300); border-radius: var(--r-card); box-shadow: var(--shadow-sm);
  padding: 16px; min-width: 0;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-tint { background: var(--ems-green-tint); border-color: #bcd9cb; }
.card-link { display: block; color: inherit; text-decoration: none; }
.card-link:hover { box-shadow: var(--shadow-md); }
.panel { border-radius: var(--r-panel); }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 24px 0 8px; gap: 8px; }
.section-title h2 { margin: 0; font-size: 1.15rem; }
.section-title a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; }

/* ---------- Bottom navigation ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; background: var(--white); border-top: 1px solid var(--grey-300);
  padding: 0 var(--sar) var(--sab) var(--sal); display: grid; grid-template-columns: repeat(5, 1fr); box-shadow: 0 -2px 10px rgba(15,30,25,.06);
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: var(--nav-h); padding: 6px 2px;
  color: var(--ink-soft); text-decoration: none; font-size: .8rem; font-weight: 600; min-width: 44px; position: relative;
}
.bottom-nav a i { font-size: 1.35rem; line-height: 1; padding: 2px 16px; border-radius: var(--r-pill); }
.bottom-nav a[aria-current="page"] { color: var(--ems-green-dark); }
.bottom-nav a[aria-current="page"] i { background: var(--ems-green-tint); }
.bottom-nav a.nav-book i { background: var(--ems-green); color: var(--white); }

/* ---------- Drawer ---------- */
dialog.drawer { margin: 0 auto 0 0; height: 100dvh; max-height: 100dvh; width: min(320px, 88vw); border: 0; padding: 0; background: var(--white); border-radius: 0 var(--r-panel) var(--r-panel) 0; box-shadow: var(--shadow-lg); }
dialog.drawer::backdrop, dialog.sheet::backdrop { background: rgba(10, 25, 20, .5); }
.drawer-inner { display: flex; flex-direction: column; height: 100%; padding: var(--sat) 0 var(--sab); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--grey-300); }
.drawer nav { overflow-y: auto; flex: 1; padding: 8px; }
.nav-group { margin: 12px 8px 4px; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.nav-link {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 12px; border-radius: var(--r-sm); color: var(--ink);
  text-decoration: none; font-weight: 600; background: none; border: 0; width: 100%; font: inherit; font-weight: 600; cursor: pointer; text-align: left;
}
.nav-link:hover { background: var(--grey-100); }
.nav-link[aria-current="page"] { background: var(--ems-green-tint); color: var(--ems-green-dark); }
.nav-link i { font-size: 1.15rem; width: 1.5rem; text-align: center; }
.drawer-foot { padding: 12px 16px; border-top: 1px solid var(--grey-300); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 14px; border-radius: var(--r-card); box-shadow: var(--shadow-sm);
  border: 1px solid var(--ems-green); background: var(--ems-green); color: var(--white); font: 800 1rem/1.2 var(--font); text-decoration: none; cursor: pointer;
  text-align: center; transition: background-color .15s, box-shadow .15s; max-width: 100%;
}
.btn:hover { background: var(--ems-green-dark); border-color: var(--ems-green-dark); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-outline, .btn-neutral { background: var(--white); border-color: var(--grey-300); color: var(--ems-green-dark); }
.btn-outline:hover, .btn-neutral:hover { background: var(--ems-green-tint); border-color: var(--grey-300); color: var(--ems-green-dark); }
.btn-danger { background: var(--white); border-color: var(--donate-dark); color: var(--donate-dark); }
.btn-danger:hover { background: #fdecea; border-color: var(--donate-dark); }
.btn-danger.solid { background: var(--donate-dark); color: var(--white); }
.btn-sm { min-height: 44px; padding: 8px 12px; font-size: .9rem; }
.btn-block { width: 100%; }
.btn .spinner { width: 1em; height: 1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field > label, .field > .label, legend { display: block; font-weight: 600; margin-bottom: 4px; padding: 0; }
.hint { font-size: .875rem; color: var(--ink-soft); margin-top: 2px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date], input[type=time], input[type=number], input[type=search], input[type=datetime-local], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--white);
  font: 400 1rem/1.4 var(--font); color: var(--ink); appearance: none; -webkit-appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%), linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%); background-position: calc(100% - 20px) 55%, calc(100% - 15px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
textarea { min-height: 96px; resize: vertical; }
input:disabled, select:disabled, textarea:disabled { background: var(--grey-100); color: var(--ink-soft); }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--donate-dark); border-width: 2px; }
.field-error { color: var(--donate-dark); font-size: .875rem; font-weight: 600; margin-top: 4px; display: flex; gap: 6px; align-items: flex-start; }
fieldset { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
.checkbox, .radio { display: flex; align-items: flex-start; gap: 12px; min-height: 44px; padding: 8px 0; cursor: pointer; }
.checkbox input, .radio input { width: 24px; height: 24px; margin: 0; flex: none; accent-color: var(--ems-green); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg { display: inline-flex; border: 1px solid var(--ems-green); border-radius: var(--r-pill); overflow: hidden; max-width: 100%; flex-wrap: wrap; background: var(--white); }
.seg a { min-height: 44px; padding: 0 16px; display: inline-flex; align-items: center; text-decoration: none; background: var(--white); color: var(--ems-green-dark); font: 600 .95rem var(--font); }
.seg button, .seg label {
  min-height: 44px; padding: 0 16px; border: 0; background: var(--white); color: var(--ems-green-dark); font: 600 .95rem var(--font);
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.seg [aria-pressed="true"], .seg [aria-checked="true"], .seg .on, .seg a[aria-current="page"] { background: var(--ems-green); color: var(--white); }
.seg > * + * { border-left: 1px solid var(--ems-green); }
.seg-nav { display: flex; flex-wrap: nowrap; }
.seg-nav a { flex: 1 1 auto; justify-content: center; text-align: center; white-space: nowrap; }
@media (max-width: 420px) { .seg-nav a { padding: 0 8px; font-size: .85rem; } }
.seg-fit { display: flex; flex-wrap: nowrap; }
.seg-fit button { flex: 1 1 auto; justify-content: center; text-align: center; white-space: nowrap; }
@media (max-width: 420px) { .seg-fit button { padding: 0 8px; font-size: .85rem; } }
.chips-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-btn { min-height: 44px; padding: 0 14px; border-radius: var(--r-pill); border: 1px solid var(--border-strong); background: var(--white); font: 600 .9rem var(--font); cursor: pointer; color: var(--ink); }
.chip-btn:hover { background: var(--grey-100); }
.callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--r-sm); border: 1px solid var(--grey-300); background: var(--white); align-items: flex-start; }
.callout i { font-size: 1.2rem; margin-top: 1px; }
.callout.info { background: #e8f1fa; border-color: #b6d1ea; }
.callout.info i { color: var(--nhs-blue); }
.callout.warn { background: #fff6e0; border-color: #ecc66a; }
.callout.error { background: #fdecea; border-color: #e5a29c; color: #6d150d; }
.callout.error i { color: var(--donate-dark); }
.callout.ok { background: var(--ems-green-tint); border-color: #9fc9b3; }
.callout.ok i { color: var(--ems-green); }

/* ---------- Lists, badges, tables ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: var(--r-pill); font-size: .8rem; font-weight: 700; background: var(--grey-100); color: var(--ink); border: 1px solid var(--grey-300); white-space: nowrap; }
.badge.green { background: var(--ems-green-tint); color: var(--ems-green-dark); border-color: #9fc9b3; }
.badge.blue { background: #e8f1fa; color: var(--nhs-dark-blue); border-color: #b6d1ea; }
.badge.yellow { background: #fff2cc; color: #5d4300; border-color: #ecc66a; }
.badge.red { background: #fdecea; color: var(--donate-dark); border-color: #e5a29c; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.list-item { display: flex; gap: 12px; align-items: center; background: var(--white); border: 1px solid var(--grey-300); border-radius: var(--r-card); padding: 12px 14px; min-height: 56px; min-width: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 700; overflow-wrap: anywhere; }
.list-item .muted { min-width: 0; overflow-wrap: anywhere; }
.list-item .badge { flex: none; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--grey-300); border-radius: var(--r-card); background: var(--white); }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--grey-100); vertical-align: top; }
th { background: var(--grey-50); font-weight: 700; color: var(--ems-green-dark); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-top: 12px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { font-weight: 600; color: var(--ink-soft); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.empty { text-align: center; padding: 32px 16px; color: var(--ink-soft); }
.empty > i { font-size: 2.2rem; color: var(--ems-green); display: block; margin-bottom: 8px; }
.empty p { margin-bottom: 12px; }
.empty .btn i { font-size: 1em; color: inherit; display: inline-block; margin: 0; }

/* ---------- Shift cards ---------- */
.shift {
  display: block; width: 100%; text-align: left; font: inherit; color: inherit; background: var(--white); border: 1px solid var(--grey-300);
  border-left-width: 6px; border-radius: var(--r-card); padding: 12px 14px; cursor: pointer; min-height: 56px;
}
.shift:hover { box-shadow: var(--shadow-md); }
.shift.cat-shared { border-left-color: var(--cat-shared); border-left-style: solid; background: var(--cat-shared-tint); }
.shift.cat-personal { border-left-color: var(--cat-personal); border-left-style: dashed; background: var(--cat-personal-tint); }
.shift.cat-scheme { border-left-color: var(--cat-scheme); border-left-style: double; border-left-width: 8px; background: var(--cat-scheme-tint); }
.shift.cat-shared .cs { color: var(--cat-shared); }
.shift.cat-personal .cs { color: var(--cat-personal); }
.shift.cat-scheme .cs { color: var(--cat-scheme); }
.shift.cat-other { border-left-color: var(--cat-other); border-left-style: dotted; border-left-width: 6px; background: var(--cat-other-tint); }
.shift.cat-other .cs { color: var(--cat-other); }
.shift.training { border-left-color: var(--cat-training); border-left-style: groove; border-left-width: 8px; background: var(--cat-training-tint); text-decoration: none; }
.shift.training .cs { color: var(--cat-training); }
.shift.training.done { opacity: .75; }
.shift.cancelled { opacity: .75; }
.shift.cancelled .when, .shift.cancelled .cs { text-decoration: line-through; }
.shift.mine { box-shadow: inset 0 0 0 2px var(--ink); }
.shift .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.shift .cs { font-weight: 800; font-size: 1.05rem; color: var(--ems-green-dark); display: inline-flex; align-items: center; gap: 6px; }
.shift .when { font-weight: 600; }
.shift .who { color: var(--ink-soft); font-size: .92rem; margin-top: 2px; }
.shift .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.shift-list { display: grid; gap: 8px; }
.day-head { font-weight: 800; color: var(--ems-green-dark); margin: 16px 0 6px; display: flex; gap: 8px; align-items: baseline; }
.day-head .today { font-size: .8rem; background: var(--ems-green); color: #fff; padding: 1px 8px; border-radius: var(--r-pill); }

/* ---------- Calendar ---------- */
/* Compact, sticky calendar controls: one row of title + actions, one row of views. */
.cal-bar { position: sticky; top: calc(var(--header-h) + var(--sat)); z-index: 40; background: var(--grey-50); margin: 0 -16px 12px; padding: 8px 16px 8px; border-bottom: 1px solid var(--grey-300); display: grid; gap: 8px; }
.cal-bar:has(.chips-row:not([hidden])) { padding-bottom: 4px; }
.cal-toolbar { display: flex; gap: 6px; align-items: center; }
.cal-title { position: relative; flex: 1; min-width: 0; min-height: 44px; display: flex; align-items: center; gap: 4px; font-weight: 800; color: var(--ems-green-dark); font-size: 1.2rem; line-height: 1.1; cursor: pointer; }
.cal-title > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-title > i { font-size: .8rem; flex: none; opacity: .7; }
.cal-title.static { cursor: default; }
.cal-title.static > i { display: none; }
.cal-title .cal-date { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; padding: 0; border: 0; }
.cal-title .cal-date::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.cal-toolbar .btn { padding: 0 14px; }
.cal-step { min-width: 44px; padding: 0 !important; }
.cal-filter { position: relative; min-width: 44px; padding: 0 !important; font-size: 1.05rem; }
.cal-filter-n { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; border-radius: 10px; background: var(--ems-green); color: #fff; font: 800 .75rem/20px var(--font); text-align: center; border: 2px solid var(--grey-50); box-sizing: content-box; }
.cal-views .seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; flex-wrap: nowrap; }
.cal-views .seg button { padding: 0 6px; white-space: nowrap; justify-content: center; }
@media (min-width: 600px) { .cal-views .seg { width: 100%; max-width: 420px; } }
.cal-bar .chips-row { gap: 6px; align-items: center; }
.cal-bar .chip-btn { min-height: 36px; }
.month .day .dot { display: inline-block; width: 14px; height: 10px; padding: 0; }
.today-pill { font-size: .72rem; font-weight: 700; background: var(--ems-green); color: #fff; padding: 2px 8px; border-radius: var(--r-pill); margin-left: 8px; vertical-align: middle; }
.cal-surface { touch-action: pan-y; min-height: 240px; }
.cal-surface + .legend { margin-top: 16px; }
@media (max-width: 959px) { .cal-head { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); margin: 0; } }
@media (min-width: 960px) { .cal-bar { margin-inline: 0; padding-inline: 0; } }
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0; background: var(--white); border-top: 1px solid var(--grey-300); border-left: 1px solid var(--grey-300); border-radius: var(--r-card); overflow: hidden; }
.month .dow { background: var(--grey-50); border-right: 1px solid var(--grey-300); border-bottom: 1px solid var(--grey-300); text-align: center; font-size: .8rem; font-weight: 700; padding: 6px 0; color: var(--ink-soft); }
.month .day { background: var(--white); border-right: 1px solid var(--grey-300) !important; border-bottom: 1px solid var(--grey-300) !important; min-height: 56px; padding: 4px; text-align: left; border: 0; font: inherit; color: inherit; cursor: pointer; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.month .day.out { background: var(--grey-50); color: var(--ink-soft); }
.month .day .num { font-weight: 700; font-size: .85rem; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; }
.month .day.today .num { background: var(--ems-green); color: #fff; }
.month .day.sel { outline: 3px solid var(--ems-green); outline-offset: -3px; background: var(--ems-green-tint); }
.month .day .dots { display: flex; flex-wrap: wrap; gap: 3px; }
.month .day .dot { font-size: .75rem; font-weight: 800; padding: 0 4px; border-radius: 4px; border: 1px solid currentColor; color: var(--cat-shared); background: var(--cat-shared-tint); line-height: 1.5; }
.month .day .dot.personal { color: var(--cat-personal); background: var(--cat-personal-tint); border-style: dashed; }
.month .day .dot.other { color: var(--cat-other); background: var(--cat-other-tint); border-style: dotted; }
.month .day .dot.scheme { color: var(--cat-scheme); background: var(--cat-scheme-tint); border-style: double; border-width: 3px; }
.month .day .dot.training { color: var(--cat-training); background: var(--cat-training-tint); border-style: groove; border-width: 3px; }
.month .day .chips { display: none; }
.week { display: grid; gap: 4px; }
.week-day { background: var(--white); border: 1px solid var(--grey-300); border-radius: var(--r-card); padding: 4px 8px 8px; min-width: 0; scroll-margin-top: calc(var(--header-h) + var(--sat) + 112px); }
.week-day.today { border-color: var(--ems-green); box-shadow: inset 0 0 0 1px var(--ems-green); }
.week-day.empty { padding-bottom: 4px; background: transparent; border-style: dashed; }
.week-day h3 { font-size: .95rem; margin: 0; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0 8px; min-height: 44px; min-width: 0; }
.week-day h3 { flex-direction: column; align-items: flex-start; justify-content: center; padding-bottom: 4px; }
.week-day h3 > .badge, .week-day h3 > .muted { flex: 0 0 auto; white-space: nowrap; margin-left: 0; }
.week-day .week-date { flex-wrap: wrap; gap: 2px 8px; padding-top: 4px; padding-bottom: 4px; }
.week-day .week-date .today-pill { margin-left: 0; }
.week-day.empty h3 { color: var(--ink-soft); }
.week-date { min-height: 44px; margin-left: -8px; padding: 0 8px; border: 0; background: none; font: 800 1rem var(--font); color: var(--ems-green-dark); display: inline-flex; align-items: center; cursor: pointer; border-radius: var(--r-sm); }
.week-day.empty .week-date { font-weight: 600; color: var(--ink-soft); }
.week-day .shift { padding: 8px 10px; margin-top: 6px; min-height: 44px; }
.week-day .shift .tags .badge { max-width: 100%; white-space: normal; }
.week-day .shift .top { flex-wrap: wrap; column-gap: 8px; row-gap: 0; }
.week-day .shift .cs { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.week-day .shift .who { overflow-wrap: anywhere; }
.week-day .shift .when { font-size: .92rem; white-space: nowrap; }
.shift .tags:empty { display: none; }
.timeline { background: var(--white); border: 1px solid var(--grey-300); border-radius: var(--r-card); padding: 10px 12px; }
.timeline h3 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 0 0 6px; font-size: 1rem; }
.timeline h3 .muted { font-weight: 600; }
.tl-bar { position: relative; height: 46px; background: var(--ems-green-tint); border-radius: 6px; overflow: hidden; border: 1px solid #bcd9cb; }
.tl-seg { position: absolute; top: 0; bottom: 0; background: var(--cat-shared); color: #fff; font-size: .8rem; font-weight: 700; padding: 0 4px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; display: flex; align-items: center; border: 0; cursor: pointer; border-left: 1px solid #fff; border-right: 1px solid #fff; background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.18) 0 4px, transparent 4px 8px); font-family: var(--font); }
.tl-seg.cat-personal { background-color: var(--cat-personal); }
.tl-seg.cat-scheme { background-color: var(--cat-scheme); }
.tl-seg.cat-other { background-color: var(--cat-other); }
.tl-seg.mine { box-shadow: inset 0 0 0 3px #fff; }
.tl-axis { display: flex; justify-content: space-between; font-size: .8rem; color: var(--ink-soft); margin-top: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: .82rem; color: var(--ink-soft); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 22px; height: 14px; border-left-width: 6px; border-left-style: solid; background: var(--white); border: 1px solid var(--grey-300); }
.legend i.cat-shared { border-left: 6px solid var(--cat-shared); background: var(--cat-shared-tint); }
.legend i.cat-personal { border-left: 6px dashed var(--cat-personal); background: var(--cat-personal-tint); }
.legend i.cat-other { border-left: 6px dotted var(--cat-other); background: var(--cat-other-tint); }
.legend i.cat-scheme { border-left: 8px double var(--cat-scheme); background: var(--cat-scheme-tint); }
.legend i.cat-training { border-left: 8px groove var(--cat-training); background: var(--cat-training-tint); }
.cal-date { min-height: 44px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); font: 600 .9rem var(--font); color: var(--ink); background: var(--white); }

/* ---------- Dialogs / bottom sheets ---------- */
dialog.sheet {
  /* Centred (not bottom-anchored) so mobile browser toolbars, e.g. Safari's floating bar, never cover content. */
  margin: auto; width: calc(100% - 24px); max-width: 640px; max-height: calc(100dvh - 140px); border: 0; padding: 0; background: var(--white); color: var(--ink);
  border-radius: var(--r-panel); box-shadow: var(--shadow-lg); overflow: hidden;
}
dialog.sheet[open] { display: flex; flex-direction: column; animation: sheet-up .22s ease-out; }
dialog.sheet.full { height: 100dvh; max-height: 100dvh; width: 100%; border-radius: 0; max-width: none; }
@keyframes sheet-up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 12px 8px 8px 16px; border-bottom: 1px solid var(--grey-100); flex: none; }
.sheet-head h2 { flex: 1; margin: 0; font-size: 1.15rem; }
.sheet-grab { width: 40px; height: 4px; border-radius: 4px; background: var(--grey-300); margin: 8px auto 0; flex: none; }
.sheet-body { overflow-y: auto; padding: 16px; flex: 1 1 auto; min-height: 0; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sheet-foot { padding: 12px 16px calc(12px + var(--sab)); border-top: 1px solid var(--grey-100); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; flex: none; background: var(--white); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 2000; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--sab) + 12px); display: grid; gap: 8px; padding: 0 12px; pointer-events: none; justify-items: center; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; background: var(--ink); color: var(--white); border-radius: var(--r-card); padding: 12px 14px; box-shadow: var(--shadow-lg); max-width: 520px; width: 100%; animation: sheet-up .2s ease-out; }
.toast.error { background: var(--donate-dark); }
.toast.success { background: var(--ems-green-dark); }
.toast .msg { flex: 1; }
.toast button { background: none; border: 0; color: inherit; min-width: 44px; min-height: 44px; margin: -10px -10px -10px 0; font-size: 1.1rem; cursor: pointer; border-radius: var(--r-pill); }
.toast button.txt { font: 700 .9rem var(--font); text-decoration: underline; min-width: 0; padding: 0 8px; }
.offline-bar { background: var(--ink); color: var(--white); text-align: center; padding: 8px 12px; font-weight: 600; font-size: .9rem; }

/* ---------- Skeletons ---------- */
.skel { background: linear-gradient(90deg, var(--grey-100) 25%, #f7f9f9 37%, var(--grey-100) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--r-sm); }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.skel-card { height: 76px; border-radius: var(--r-card); }
.skel-line { height: 14px; margin: 8px 0; }

/* ---------- Auth screens ---------- */
.auth-wrap { min-height: 100dvh; display: grid; place-items: center; padding: max(16px, var(--sat)) 16px max(16px, var(--sab)); background: var(--ems-green-dark); }
.auth-card { width: 100%; max-width: 440px; background: var(--white); border: 1px solid var(--grey-300); border-radius: var(--r-panel); box-shadow: var(--shadow-md); padding: 24px 20px; }
.auth-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.auth-logo img { width: 56px; height: 56px; border-radius: 50%; }
.auth-logo strong { color: var(--ems-green-dark); font-weight: 800; line-height: 1.2; }
.app-version { text-align: center; margin: 12px 0 0; color: var(--ink-soft); font-size: .75rem; }
.auth-foot { text-align: center; margin-top: 16px; color: var(--white); font-size: .9rem; }
.auth-foot a { color: var(--white); font-weight: 700; }

/* ---------- Dashboard ---------- */
.hello h1 { margin-bottom: 2px; }
.next-shift { background: var(--ems-green-dark); color: var(--white); border-color: var(--ems-green-dark); }
.next-shift h2, .next-shift .label { color: var(--white); }
.next-shift .big { font-size: 1.4rem; font-weight: 800; }
.next-shift .countdown { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; margin-bottom: 4px; }
.next-shift .countdown small { font-size: 1rem; font-weight: 600; }
.next-shift .btn { background: var(--white); color: var(--ems-green-dark); border-color: var(--white); }
.quick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.next-empty { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
.next-empty > i { font-size: 1.8rem; color: var(--ems-green); }
.quick a { display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: 8px; min-height: 44px; padding: 8px 12px; white-space: nowrap; background: var(--white); border: 1px solid var(--grey-300); border-radius: var(--r-card); text-decoration: none; color: var(--ems-green-dark); font-weight: 800; box-shadow: var(--shadow-sm); }
.quick a i { font-size: 1.15rem; color: var(--ems-green); }
.quick a.primary { background: var(--ems-green); color: var(--white); border-color: var(--ems-green); }
.quick a.primary i { color: var(--white); }
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: flex; gap: 8px; padding: 4px 0; line-height: 1.3; border-bottom: 1px solid var(--grey-100); align-items: flex-start; }
.activity li:last-child { border-bottom: 0; }
.activity i { color: var(--ems-green); margin-top: 2px; }
.emergency { font-size: .85rem; color: var(--ink-soft); display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 16px; }

/* ---------- Misc ---------- */
.install-card ol { margin: 8px 0 0 1.2em; padding: 0; }
.attend-grid { display: grid; gap: 12px; }
.person-line { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--grey-100); }
.person-line:last-child { border-bottom: 0; }
.person-line .comment { background: var(--grey-50); border-radius: var(--r-sm); padding: 6px 10px; margin-top: 4px; font-size: .92rem; }
.pickers { max-height: 220px; overflow-y: auto; border: 1px solid var(--grey-300); border-radius: var(--r-sm); margin-top: 6px; }
.pick { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 12px; border: 0; border-bottom: 1px solid var(--grey-100); background: var(--white); width: 100%; text-align: left; font: inherit; cursor: pointer; }
.pick[aria-pressed="true"] { background: var(--ems-green-tint); font-weight: 700; }
.callsign-grid { display: grid; gap: 6px; }
.cs-option { display: flex; gap: 10px; align-items: center; border: 2px solid var(--grey-300); border-radius: var(--r-card); padding: 6px 10px; min-height: 48px; cursor: pointer; background: var(--white); }
.cs-option input { width: 22px; height: 22px; accent-color: var(--ems-green); flex: none; }
.cs-option:has(input:checked) { border-color: var(--ems-green); background: var(--ems-green-tint); }
.cs-option strong { font-size: 1.05rem; color: var(--ems-green-dark); }
.summary dt { color: var(--ink-soft); font-weight: 600; }

/* ---------- Phone refinements ---------- */
@media (max-width: 959px) {
  .signout-btn { display: none; } /* Sign out lives in the menu; keeps it away from the profile tap target */
  .content { padding-top: 12px; }
  .page-head { margin-bottom: 12px; }
  .section-title { margin-top: 20px; }
  .bottom-nav { box-shadow: 0 -4px 16px rgba(15,30,25,.08); }
  .bottom-nav a { font-size: .75rem; }
  .bottom-nav a[aria-current="page"] { font-weight: 800; }
  .bottom-nav a.nav-book i { box-shadow: 0 2px 8px rgba(0,67,42,.35); }
}
@media (max-width: 639px) {
  /* Forms inside the app: primary action stays reachable above the bottom bar */
  .content .card > form > .btn-row:last-child { position: sticky; bottom: calc(var(--nav-h) + var(--sab)); z-index: 30; background: var(--white); margin: 8px -16px -16px; padding: 12px 16px; border-top: 1px solid var(--grey-300); border-radius: 0 0 var(--r-card) var(--r-card); }
  .content .card > form > .btn-row:last-child > .btn { flex: 1; }
  .content .card > form > .btn-row:last-child > .btn[type=submit] { flex: 2; }
}

/* ---------- Wider screens ---------- */
@media (min-width: 480px) { .quick { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 640px) {
  .brand-name .short { display: none; } .brand-name .long { display: inline; }
  .card { padding: 20px; }
  .cols-2 { grid-template-columns: 1fr 1fr; }
  dialog.sheet { max-height: 86dvh; }
  dialog.sheet.full { width: 100%; max-height: 100dvh; }
  .sheet-grab { display: none; }
  .month .day { min-height: 92px; padding: 6px; }
  .month .day .dots { display: none; }
  .month .day .chips { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  .month .day .chip { font-size: .75rem; font-weight: 700; padding: 1px 5px; border-radius: 4px; background: var(--cat-shared-tint); border-left: 3px solid var(--cat-shared); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .month .day .chip.personal { background: var(--cat-personal-tint); border-left-style: dashed; border-left-color: var(--cat-personal); }
  .month .day .chip.other { background: var(--cat-other-tint); border-left-style: dotted; border-left-color: var(--cat-other); }
  .month .day .chip.scheme { background: var(--cat-scheme-tint); border-left-style: double; border-left-width: 4px; border-left-color: var(--cat-scheme); }
  .month .day .chip.training { background: var(--cat-training-tint); border-left-style: groove; border-left-width: 4px; border-left-color: var(--cat-training); }
  .month .day .more { font-size: .75rem; color: var(--ink-soft); font-weight: 700; }
  .week { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}
@media (min-width: 960px) {
  .week { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  :root { --nav-h: 0px; }
  .header-user { display: block; }
  .bottom-nav { display: none; }
  .toasts { bottom: 24px; }
  .app-body { display: grid; grid-template-columns: 248px minmax(0, 1fr); align-items: start; max-width: none; margin: 0; }
  .sidebar { display: block; position: sticky; top: calc(var(--header-h) + var(--sat)); height: calc(100dvh - var(--header-h) - var(--sat)); overflow-y: auto; background: var(--ems-green-dark); padding: 12px 8px; color: var(--white); }
  .sidebar .nav-link { color: var(--white); }
  .sidebar .nav-link:hover { background: rgba(255,255,255,.12); }
  .sidebar .nav-link[aria-current="page"] { background: var(--ems-green); color: var(--white); }
  .sidebar .nav-group { color: #b6d6c5; }
  .app-header-inner { max-width: none; }
  .content { padding-bottom: 40px; width: 100%; max-width: none; margin: 0; }
  .menu-btn { display: none; }
  .quick { grid-template-columns: repeat(4, 1fr); }
  .card { padding: 28px; }
  .stack.tight .card { padding: 20px; }
}
@media (min-width: 1500px) {
  .app-header-inner { max-width: none; }
  .app-body { max-width: none; grid-template-columns: 280px minmax(0, 1fr); }
  .content { max-width: none; padding-left: 40px; padding-right: 40px; }
}
@media (min-width: 1100px) { .dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; } .dash-grid > * + * { margin-top: 0; } }
@media (max-width: 380px) { .btn { padding: 8px 12px; } .cal-views .seg button { font-size: .9rem; } .two { gap: 8px; } }
@media (max-width: 330px) { .two { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; } }
@media (forced-colors: active) { .btn, .shift, .card { border: 1px solid CanvasText; } }

/* ---------- Hours progress & reports ---------- */
.hours-card .hours-figure { font-size: 1.6rem; font-weight: 800; line-height: 1.2; }
.hours-card .hours-figure small { font-size: 1rem; font-weight: 600; color: var(--ink-soft); }
.meter { height: 14px; border-radius: var(--r-pill); background: var(--grey-100); overflow: hidden; margin: 10px 0 6px; border: 1px solid var(--grey-300); }
.meter > span { display: block; height: 100%; background: var(--ems-green); border-radius: var(--r-pill); min-width: 0; }
.report-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.report-table th[scope="row"] { text-align: left; font-weight: 600; white-space: nowrap; }
.report-table td.met { background: var(--ems-green-tint); color: var(--ems-green-dark); font-weight: 700; }
.report-table td.strong, .report-table tfoot { font-weight: 800; }
.report-table tfoot th, .report-table tfoot td { border-top: 2px solid var(--grey-300); }

/* Mobile "install this app" prompt */
.install-banner { position: fixed; z-index: 1900; left: 12px; right: 12px; bottom: calc(var(--sab) + 12px); display: flex; align-items: center; gap: 10px; max-width: 520px; margin: 0 auto; background: var(--white); border: 1px solid var(--grey-300); border-radius: var(--r-card); box-shadow: var(--shadow-lg); padding: 10px 6px 10px 12px; animation: sheet-up .2s ease-out; }
body:has(.bottom-nav) .install-banner { bottom: calc(var(--nav-h) + var(--sab) + 12px); }
.install-banner img { border-radius: 10px; flex: none; }
.install-banner .msg { flex: 1; display: grid; line-height: 1.25; }
@media (min-width: 900px) { .install-banner { display: none; } }
.install-screen { position: fixed; inset: 0; z-index: 2500; display: grid; place-items: center; padding: 16px; background: var(--ems-green-dark); overflow-y: auto; }
.install-screen-card { width: 100%; max-width: 420px; display: grid; gap: 14px; justify-items: center; text-align: center; background: var(--white); border-radius: var(--r-card); padding: 28px 22px; box-shadow: var(--shadow-lg); }
.install-screen-card img { border-radius: 18px; }
.install-screen-card h1 { margin: 0; font-size: 1.4rem; }
.install-screen-card p { margin: 0; }
.install-screen-card ol { text-align: left; margin: 0; padding-left: 1.2rem; display: grid; gap: 8px; }
.install-screen-body { display: grid; gap: 14px; justify-items: center; }
.install-screen-card .btn-outline { color: var(--ems-green) !important; border-color: var(--grey-300); }

/* Segmented link tabs (Reflections & clinical skills): explicit, high-contrast states with comfortable padding */
.seg { padding: 4px; gap: 4px; margin: 4px 0 12px; }
.seg > * + * { border-left: 0; }
.seg a, .seg a:link, .seg a:visited { min-height: 44px; padding: 10px 20px; border-radius: var(--r-pill); background: var(--white); color: var(--ems-green-dark); font-weight: 700; }
.seg button, .seg label { border-radius: var(--r-pill); }
.seg a:hover { background: var(--ems-green-tint); color: var(--ems-green-dark); }
.seg a.on, .seg a.on:link, .seg a.on:visited, .seg a.on:hover, .seg a[aria-current="page"], .seg a[aria-current="page"]:link, .seg a[aria-current="page"]:visited, .seg a[aria-current="page"]:hover { background: var(--ems-green-dark); color: #fff; }

.calendar-card input[readonly] { width: 100%; font-family: monospace; font-size: .8rem; }
.push-card .callout { margin: 16px 0; }
.push-card .btn-row { margin-bottom: 16px; }
.push-card .btn-row + .hint { margin-top: 0; }
.calendar-card details { margin: 12px 0; }
.calendar-card details ul { margin: 8px 0 0 1.2em; padding: 0; }

/* Vehicle off road (VOR): always text-labelled, never colour alone */
.vor-note { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; margin-top: 6px; border-radius: var(--r-sm); border: 2px solid var(--donate-dark); background: #fdecea; color: #6d150d; min-height: 44px; }
.vor-note i { color: var(--donate-dark); font-size: 1.1rem; margin-top: 1px; }
.month .day .vor-flag { font-size: .7rem; font-weight: 800; line-height: 1.4; padding: 0 4px; border-radius: 4px; background: var(--donate-dark); color: #fff; align-self: flex-start; }
.month .day.has-vor { background-image: repeating-linear-gradient(135deg, rgba(168,29,19,.10) 0 6px, transparent 6px 12px); }
.tl-vor { position: absolute; top: 0; bottom: 0; background: var(--donate-dark); color: #fff; font-size: .8rem; font-weight: 800; display: flex; align-items: center; justify-content: center; overflow: hidden; background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.22) 0 4px, transparent 4px 8px); }
