/* Milky Way — one stylesheet for the whole app.
   Design system carried over from the LMS workspace (Apple-style): the system font,
   light grey page with white cards, soft radii and shadows, bold tight headings. */

:root {
  /* Milky Way palette, shared with the product home page (website/index.html). */
  --text: #17201C;
  --text-2: #4E5A54;
  --muted: #6B746F;
  --border: #E7E2D8;
  --border-strong: #D8D0C2;
  --surface: #ffffff;
  --surface-2: #F7F5F0;
  --surface-3: #F1EEE7;
  --page: #FBF9F5;
  --primary: #0B352A;
  --primary-hover: #134A3A;
  --primary-soft: #E4EFE8;
  --primary-tint: #F2F7F3;
  --primary-ink: #155E46;
  --link: #1E6B52;
  --gold: #B8872A;
  --gold-ink: #8A6416;
  --gold-light: #E3B85A;
  --success: #157a3c;
  --success-soft: #e6f7ec;
  --warning: #8a5300;
  --warning-soft: #fff3df;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --radius: 14px;
  --radius-lg: 22px;
  --shadow-card: 0 14px 40px rgba(11, 30, 24, .04);
  --shadow-pop: 0 12px 32px rgba(11, 30, 24, .12), 0 2px 6px rgba(11, 30, 24, .06);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--surface); color: var(--text); font: 16px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; color: var(--text); }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; }
.icon { flex: none; }
:focus-visible { outline: 3px solid rgba(184, 135, 42, .7); outline-offset: 2px; }
[hidden] { display: none !important; }
.skip { position: absolute; left: 12px; top: -120px; z-index: 100; padding: 10px 14px; border-radius: 8px; background: #fff; box-shadow: var(--shadow-pop); }
.skip:focus { top: 12px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; height: 46px; padding: 0 22px; border: 1.5px solid transparent; border-radius: 10px; font-size: 16px; font-weight: 600; line-height: 1; white-space: nowrap; cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
.btn:hover { text-decoration: none; }
.btn-lg { height: 56px; padding: 0 28px; font-size: 18px; border-radius: 12px; }
.btn-sm { height: 36px; padding: 0 14px; font-size: 15px; border-radius: 8px; gap: 6px; }
.btn-block { display: flex; width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: #fff; color: var(--text); border-color: var(--border-strong); }
.btn-outline:hover { background: var(--surface-3); }
.btn-quiet { background: var(--surface-3); color: var(--text-2); }
.btn-quiet:hover { background: #E9E5DC; color: var(--text); }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 10px; background: none; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

/* ---------- pills & tags ---------- */
.pill { display: inline-flex; align-items: center; height: 26px; padding: 0 11px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); font-size: 13.5px; font-weight: 600; white-space: nowrap; vertical-align: middle; }
.pill-active { background: var(--success-soft); color: var(--success); }
.pill-applied, .pill-under_review { background: var(--primary-soft); color: var(--primary-ink); }
.pill-suspended { background: var(--warning-soft); color: var(--warning); }
.pill-closed, .pill-rejected { background: var(--surface-3); color: var(--muted); }
.viewing-tag { display: inline-flex; align-items: center; gap: 6px; color: var(--success); font-size: 15px; font-weight: 600; white-space: nowrap; }

/* ---------- dropdown menus (<details class="menu">) ---------- */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel { position: absolute; top: calc(100% + 8px); left: 0; z-index: 40; min-width: 260px; padding: 6px; background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-pop); }
.menu-right { left: auto; right: 0; }
.menu-panel a, .menu-panel button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; border-radius: 8px; background: none; color: var(--text); font-size: 15px; text-align: left; cursor: pointer; }
.menu-panel a:hover, .menu-panel button:hover { background: var(--surface-3); text-decoration: none; }
.menu-panel form { margin: 0; }
.menu-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-check { color: var(--primary); }
.menu-label { padding: 8px 12px 4px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.menu-head { padding: 10px 12px 12px; margin-bottom: 6px; border-bottom: 1px solid var(--border); }
.menu-head strong { display: block; }
.menu-head span { display: block; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }

.avatar { display: grid; place-items: center; width: 46px; height: 46px; flex: none; border-radius: 50%; background: var(--primary); color: var(--gold-light); font-size: 17px; font-weight: 600; letter-spacing: .02em; user-select: none; }
.avatar-sm { width: 40px; height: 40px; background: var(--primary-soft); color: var(--primary-ink); font-size: 15px; }

/* =====================================================================
   App shell: sidebar + top bar
   ===================================================================== */
.app { background: var(--surface); }
.app-shell { display: grid; grid-template-columns: 290px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 22px 14px 18px; background: var(--surface-2); border-right: 1px solid var(--border); overflow-y: auto; }
.org-switch { display: flex; align-items: center; gap: 4px; }
.org-menu { flex: 1; min-width: 0; }
.org-menu > summary, .org-static { display: flex; align-items: center; gap: 14px; padding: 8px; border-radius: 12px; }
.org-menu > summary:hover { background: #EFEBE2; }
.org-logo { display: grid; place-items: center; width: 46px; height: 46px; flex: none; border-radius: 11px; background: var(--primary); color: #fff; }
.org-logo-image { overflow: hidden; background: #fff; border: 1px solid var(--border); }
.org-logo-image img { width: 100%; height: 100%; object-fit: contain; }
.org-text { flex: 1; min-width: 0; }
.org-text strong { display: block; font-size: 18px; letter-spacing: -.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.org-text span { display: block; color: var(--text-2); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.org-caret { color: var(--text-2); }
.role-chip { display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; margin: 14px 0 0 10px; padding: 5px 12px 5px 10px; border-radius: 999px; background: #fff; border: 1px solid var(--border); color: var(--text-2); font-size: 13.5px; font-weight: 600; }
.sidebar-close { display: none; }
.side-nav ul { margin: 0; padding: 0; list-style: none; }
.side-nav:first-of-type { margin-top: 26px; }
.side-nav li + li { margin-top: 4px; }
.side-nav a { display: flex; align-items: center; gap: 16px; padding: 13px 18px; border-radius: 10px; color: #1C2621; font-size: 17px; font-weight: 500; }
.side-nav a .icon { color: #34403A; }
.side-nav a:hover { background: #EFEBE2; text-decoration: none; }
.side-nav a.active { background: #E4EFE8; color: var(--primary); font-weight: 600; }
.side-nav a.active .icon { color: var(--primary); }
.side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }
.sidebar > .side-nav:not(.side-foot) { margin-bottom: 24px; }
.sidebar-scrim { display: none; }

.app-main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; height: 76px; padding: 0 28px 0 44px; background: rgba(255, 255, 255, .86); -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px); border-bottom: 1px solid var(--border); }
.menu-toggle { display: none; }
.topbar-context { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-context form { margin: 0; }
.context-chip { display: inline-flex; align-items: center; gap: 10px; min-width: 0; height: 40px; padding: 0 14px; border-radius: 10px; background: var(--surface-3); color: var(--text-2); font-size: 15.5px; }
.context-chip strong { color: var(--text); }
.context-chip.is-centre { background: var(--primary-soft); color: var(--primary-ink); }
.context-chip.is-centre strong { color: var(--primary-ink); }
.context-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 16px; margin-left: auto; }

.toasts { position: fixed; right: 24px; bottom: 24px; z-index: 60; display: grid; gap: 8px; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 18px 12px 14px; border-radius: 12px; background: var(--text); color: #fff; font-size: 15px; box-shadow: var(--shadow-pop); transition: opacity .3s, transform .3s; }
.toast .icon { color: #4ade80; }
.toast.error .icon { color: #fca5a5; }
.toast.is-hiding { opacity: 0; transform: translateY(6px); }

/* ---------- page content ---------- */
.content { max-width: 1320px; padding: 34px 32px 56px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.page-head h1 { font-size: 36px; line-height: 1.15; font-weight: 800; letter-spacing: -.03em; }
.page-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 6px; color: var(--text-2); font-size: 18px; }
.page-head-actions { display: flex; align-items: center; gap: 14px; padding-top: 4px; }
.page-head-actions form { margin: 0; }
.back-link { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 14px; color: var(--text-2); font-size: 16px; font-weight: 500; }
.back-link:hover { color: var(--text); text-decoration: none; }
.section-gap { margin-top: 28px; }

.notice { display: flex; align-items: center; gap: 12px; margin-top: 22px; padding: 14px 18px; border-radius: 12px; background: var(--primary-tint); border: 1px solid #CFE0D5; color: var(--primary-ink); font-size: 16px; }
.notice-warning { background: var(--warning-soft); border-color: #f6dfb5; color: var(--warning); }

/* stat cards */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 20px; margin-top: 30px; }
.stat-card { display: flex; align-items: center; gap: 18px; padding: 22px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; color: var(--text); transition: border-color .15s, box-shadow .15s; }
.stat-card:hover { border-color: #C9DCCF; box-shadow: var(--shadow-card); text-decoration: none; }
.stat-icon { display: grid; place-items: center; width: 56px; height: 56px; flex: none; border-radius: 14px; }
.stat-body { min-width: 0; }
.stat-value { display: block; font-size: 32px; line-height: 1.1; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-value-sm { font-size: 16px; line-height: 1.3; }
.stats .stat-value:not(.stat-value-sm) { font-size: clamp(20px, 1.7vw, 32px); white-space: nowrap; }
.stat-body { min-width: 0; }
.stat-label { display: block; margin-top: 2px; color: var(--text-2); font-size: 15.5px; }
.tone-green { background: var(--success-soft); color: #16a34a; }
.tone-blue { background: var(--primary-soft); color: var(--primary); }
.tone-amber { background: var(--warning-soft); color: #c27803; }
.tone-neutral { background: var(--surface-3); color: var(--text-2); }

/* cards */
.card { min-width: 0; padding: 22px 22px 20px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.card h2 { font-size: 22px; font-weight: 800; letter-spacing: -.025em; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-link { display: inline-flex; align-items: center; gap: 2px; font-size: 16px; font-weight: 600; }
.card-count { display: inline-grid; place-items: center; min-width: 30px; height: 26px; padding: 0 8px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); font-size: 14px; font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.empty-note { margin-top: 14px; color: var(--text-2); }

/* details list */
.details { margin: 14px 0 0; }
.details > div { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 12px; padding: 12px 0; border-bottom: 1px solid #EEEAE2; }
.details > div:last-child { border-bottom: 0; padding-bottom: 0; }
.details dt { color: var(--text-2); }
.details dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

/* people list */
.people { margin: 10px 0 0; padding: 0; list-style: none; }
.people li { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid #EEEAE2; }
.people li:last-child { border-bottom: 0; padding-bottom: 0; }
.person { flex: 1; min-width: 0; }
.person strong { display: block; }
.person span { display: block; color: var(--text-2); font-size: 15px; }

/* tables */
.table-wrap { margin-top: 16px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 16px; }
.data-table thead th { padding: 11px 14px; background: var(--surface-3); color: var(--text-2); font-size: 14.5px; font-weight: 600; text-align: left; white-space: nowrap; }
.data-table thead th:first-child { border-radius: 8px 0 0 8px; }
.data-table thead th:last-child { border-radius: 0 8px 8px 0; }
.data-table tbody th, .data-table tbody td { padding: 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid #EEEAE2; font-variant-numeric: tabular-nums; }
.data-table tbody tr:last-child th, .data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody th { font-weight: 600; }
.row-title { color: var(--text); font-weight: 600; }
.row-sub { display: block; color: var(--muted); font-size: 14px; font-weight: 400; }
.cell-action { text-align: right !important; white-space: nowrap; }
.cell-action form { margin: 0; display: inline; }
.card > .table-wrap:first-child { margin-top: 0; }

/* search + filters */
.toolbar { display: flex; gap: 12px; margin-top: 26px; }
.search-field { display: flex; flex: 1; align-items: center; gap: 12px; max-width: 640px; height: 48px; padding: 0 16px; border: 1px solid #DDD6CA; border-radius: 10px; background: #F8F6F1; color: var(--text-2); }
.search-field:focus-within { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 4px rgba(30, 107, 82, .12); }
.search-field input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: transparent; font-size: 16.5px; color: var(--text); }
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 18px; }
.chip { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: 999px; background: #fff; color: var(--text); font-size: 15px; font-weight: 500; }
.chip:hover { background: var(--surface-3); text-decoration: none; }
.chip.is-active { background: var(--text); border-color: var(--text); color: #fff; }
.chip-count { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip.is-active .chip-count { color: #CBC5B9; }
.pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 18px; color: var(--text-2); }

/* forms */
.form-card { max-width: 620px; margin-top: 24px; padding: 28px; }
.field { margin: 0 0 20px; text-align: left; }
.field > label { display: block; margin: 0 0 8px; font-size: 16.5px; font-weight: 600; }
.field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea { width: 100%; height: 52px; padding: 0 16px; border: 1.5px solid var(--border-strong); border-radius: 12px; background: #fff; font-size: 17px; transition: border-color .15s, box-shadow .15s; }
.field textarea { height: auto; min-height: 110px; padding: 12px 16px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 4px rgba(30, 107, 82, .14); }
.field input::placeholder { color: #8C918B; }
.field.has-error input { border-color: #d92d20; }
.field-help { margin-top: 8px; color: var(--muted); font-size: 14.5px; }
.field-help ul { margin: 4px 0 0; padding-left: 18px; }
.field-error { margin-top: 8px; color: var(--danger); font-size: 15px; }
.form-alert { margin: 0 0 20px; padding: 14px 16px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); }
.form-actions { display: flex; gap: 12px; margin-top: 8px; }
.input-wrap { position: relative; }
.input-wrap input { padding-right: 60px !important; }
.reveal { position: absolute; top: 50%; right: 8px; display: grid; place-items: center; width: 42px; height: 42px; margin-top: -21px; border: 0; border-radius: 8px; background: none; color: var(--text-2); cursor: pointer; }
.reveal[aria-pressed=true] { color: var(--primary); }

/* =====================================================================
   Affiliation, documents, review, team
   ===================================================================== */
.btn-danger { background: #fff; color: var(--danger); border-color: #f1c6c1; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-success { background: var(--success-soft); color: var(--success); border-color: #bfe5cc; }
.btn-success:hover { background: #d6f1df; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.icon-btn-sm { width: 36px; height: 36px; border-radius: 8px; }
.pill-draft { background: var(--surface-3); color: var(--text-2); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-missing { background: var(--surface-3); color: var(--muted); }
.pill-doc-pending { background: var(--primary-soft); color: var(--primary-ink); }
.pill-doc-accepted { background: var(--success-soft); color: var(--success); }
.pill-doc-rejected { background: var(--danger-soft); color: var(--danger); }
.pill-visit-satisfactory { background: var(--success-soft); color: var(--success); }
.pill-visit-needs_fixes { background: var(--warning-soft); color: var(--warning); }
.pill-visit-unsatisfactory { background: var(--danger-soft); color: var(--danger); }
.notice > div p { margin-top: 2px; }
.notice-danger { background: var(--danger-soft); border-color: #f5cdc8; color: var(--danger); }
.notice-cta { justify-content: flex-start; }
.notice-cta > span { flex: 1; }
.notice + .notice { margin-top: 10px; }
.lede { margin-top: 14px; max-width: 760px; color: var(--text-2); font-size: 17px; }
.card-sub { margin-top: 4px; color: var(--text-2); font-size: 15px; }
.stack { display: grid; gap: 20px; align-content: start; min-width: 0; }
.section-gap-sm { margin-top: 16px; }
.step-label { margin-bottom: 4px; color: var(--primary); font-size: 14px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }

/* two-column layouts */
.review-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 22px; align-items: start; }
.review-layout > aside { position: sticky; top: 96px; }
.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.form-card-flush { padding: 26px; }

/* form controls */
.optional { color: var(--muted); font-size: 13.5px; font-weight: 500; }
fieldset.field { margin: 0 0 20px; padding: 0; border: 0; min-width: 0; }
fieldset.field legend { padding: 0; margin: 0 0 10px; font-size: 16.5px; font-weight: 600; }
.choice-group { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; }
.choice { position: relative; display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 12px 14px; border: 1.5px solid var(--border-strong); border-radius: 12px; background: #fff; font-size: 15.5px; line-height: 1.3; cursor: pointer; transition: border-color .15s, background .15s; }
.choice:hover { border-color: #BDB7AB; }
.choice input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--primary); }
.choice:has(input:checked) { border-color: var(--primary); background: var(--primary-tint); box-shadow: 0 0 0 1px var(--primary) inset; }
.choice:has(input:focus-visible) { outline: 3px solid rgba(30, 107, 82, .5); outline-offset: 2px; }
.field-check { margin-bottom: 12px; }
.check-row { display: flex; align-items: center; gap: 12px; font-size: 16px; cursor: pointer; }
.check-row input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--primary); }
.field > label.check-row { display: flex; margin: 0; font-size: 16px; font-weight: 500; }
.notice + .field { margin-top: 20px; }
.field input[type=date] { font-variant-numeric: tabular-nums; }
.locate-btn { margin: -6px 0 6px; }
.locate-status:empty { display: none; }

/* section cards on the overview */
.section-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.step-dot { display: grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 50%; background: var(--surface-3); color: var(--text-2); font-size: 14px; font-weight: 700; }
.step-dot.is-done { background: var(--success); color: #fff; }
.missing-note { margin-top: 10px; padding: 8px 12px; border-radius: 8px; background: var(--warning-soft); color: var(--warning); font-size: 14.5px; }
.details-compact { margin-top: 8px; }
.details-compact > div { grid-template-columns: 200px minmax(0, 1fr); padding: 9px 0; font-size: 15.5px; }

/* documents */
.doc-list { margin: 12px 0 0; padding: 0; list-style: none; }
.doc-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 14px; align-items: center; padding: 14px 0; border-top: 1px solid #EEEAE2; }
.doc-list > .doc-row:first-child { border-top: 0; }
.details + .doc-list > .doc-row:first-child, .missing-note + .doc-list > .doc-row:first-child { border-top: 1px solid #EEEAE2; }
.doc-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--surface-3); color: var(--text-2); }
.doc-icon.doc-accepted { background: var(--success-soft); color: var(--success); }
.doc-icon.doc-pending { background: var(--primary-soft); color: var(--primary); }
.doc-icon.doc-rejected { background: var(--danger-soft); color: var(--danger); }
.doc-main { min-width: 0; }
.doc-main strong { display: block; font-size: 15.5px; }
.doc-person { color: var(--text-2); font-weight: 500; }
.doc-meta { display: block; color: var(--text-2); font-size: 14px; overflow-wrap: anywhere; }
.doc-note { display: flex; align-items: center; gap: 6px; margin-top: 4px; color: var(--danger); font-size: 14px; }
.doc-actions { grid-column: 2 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.doc-actions form { margin: 0; }
.doc-upload { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.file-input input { max-width: 240px; font-size: 14px; color: var(--text-2); }
.file-input input::file-selector-button { margin-right: 10px; padding: 7px 12px; border: 1.5px solid var(--border-strong); border-radius: 8px; background: #fff; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.date-input { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 14px; }
.date-input input { height: 36px; padding: 0 10px; border: 1.5px solid var(--border-strong); border-radius: 8px; background: #fff; }
.inline-form { position: relative; }
.inline-form > summary { list-style: none; }
.inline-form > summary::-webkit-details-marker { display: none; }
.inline-form[open] > form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.inline-form input[type=text], .inline-form textarea { flex: 1 1 220px; min-width: 0; height: 36px; padding: 0 10px; border: 1.5px solid var(--border-strong); border-radius: 8px; font-size: 15px; }
.inline-form textarea { width: 100%; height: auto; padding: 8px 10px; }

/* checks and actions */
.check-list { margin: 12px 0 0; padding: 0; list-style: none; }
.check { display: flex; gap: 10px; padding: 9px 0; border-top: 1px solid #EEEAE2; font-size: 15px; }
.check:first-child { border-top: 0; }
.check strong { display: block; font-weight: 600; }
.check .check-icon { color: #B8B3A8; padding-top: 1px; }
.check.is-ok .check-icon { color: #16a34a; }
.check-detail { display: block; color: var(--text-2); font-size: 14px; }
.action-list { display: grid; gap: 10px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.action-list form { margin: 0; }
.action-form[open] > form { display: grid; gap: 8px; }
.action-form label { font-size: 14.5px; font-weight: 600; }
.action-hint { margin-top: 6px; color: var(--muted); font-size: 13.5px; text-align: center; }

/* site visits */
.visit { padding: 12px 0; border-top: 1px solid #EEEAE2; }
.card-head + .visit { border-top: 0; }
.visit-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.visit-checklist { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 8px 0 0; padding: 0; list-style: none; color: var(--muted); font-size: 13.5px; }
.visit-checklist li { display: inline-flex; align-items: center; gap: 4px; }
.visit-checklist li.is-ok { color: var(--success); }
.visit-notes { margin-top: 6px; font-size: 15px; }
.visit-by { margin-top: 4px; color: var(--muted); font-size: 13.5px; }
.visit-form { margin-top: 12px; }
.visit-form[open] > form { display: block; margin-top: 12px; }
.visit-form .choice-group { grid-template-columns: minmax(0, 1fr); }
.visit-form textarea { min-height: 80px; }

/* timeline */
.timeline { margin: 12px 0 0; padding: 0; list-style: none; }
.timeline li { position: relative; display: flex; gap: 12px; padding: 0 0 14px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 14px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline-dot { width: 12px; height: 12px; flex: none; margin-top: 5px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.timeline-meta { display: block; color: var(--muted); font-size: 13.5px; }
.timeline-note { margin-top: 4px; padding: 8px 10px; border-radius: 8px; background: var(--surface-3); font-size: 14.5px; }

/* dashboard lists */
.link-list { margin: 10px 0 0; padding: 0; list-style: none; }
.link-list li + li { border-top: 1px solid #EEEAE2; }
.link-list a { display: flex; align-items: center; gap: 12px; padding: 12px 4px; color: var(--text); }
.link-list a:hover { text-decoration: none; background: var(--surface-2); }
.link-chevron { color: #9C9F98; }

/* team */
.people li.is-off .person { opacity: .55; }
.person .you { display: inline; color: var(--muted); font-size: 13px; font-weight: 500; }
.doc-expired { color: var(--danger); font-weight: 600; }
.row-menu .menu-panel { min-width: 280px; }
.person-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.credentials { display: flex; gap: 16px; margin-top: 22px; padding: 20px 22px; border: 1px solid #bfe5cc; border-radius: var(--radius); background: var(--success-soft); color: #14532d; }
.credentials h2 { font-size: 19px; color: #14532d; }
.credentials-icon { display: grid; place-items: center; width: 46px; height: 46px; flex: none; border-radius: 12px; background: #fff; color: var(--success); }
.credentials-list { display: flex; flex-wrap: wrap; gap: 8px 32px; margin: 10px 0; }
.credentials-list dt { font-size: 13.5px; }
.credentials-list dd { margin: 0; font-size: 20px; font-weight: 700; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .02em; }
.danger-zone { border-color: #f5cdc8; }
.danger-zone h2 { font-size: 19px; }
.auth-card-wide { max-width: 640px; }
.apply-note { margin-top: 10px; padding-top: 16px; border-top: 1px solid var(--border); }

/* =====================================================================
   Farmers and rates
   ===================================================================== */
fieldset.form-group { margin: 0 0 8px; padding: 0; border: 0; min-width: 0; }
fieldset.form-group + fieldset.form-group { margin-top: 18px; padding-top: 20px; border-top: 1px solid var(--border); }
fieldset.form-group > legend { padding: 0; margin-bottom: 14px; font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; margin-top: 14px; }
.field-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.show-sm { display: none; }
.farmer-table .cell-number { width: 64px; color: var(--text-2); font-weight: 600; }
.data-table tr.is-off .row-title, .data-table tr.is-off td { color: var(--muted); }
.steps-list { margin: 0; padding: 0; list-style: none; counter-reset: step; }
.steps-list li { position: relative; padding: 0 0 18px 44px; counter-increment: step; }
.steps-list li::before { content: counter(step); position: absolute; left: 0; top: -2px; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.steps-list strong { display: block; }
.steps-list span { display: block; margin: 2px 0 10px; color: var(--text-2); font-size: 15px; }
.issue-list { margin: 12px 0 0; padding: 0; list-style: none; max-height: 560px; overflow-y: auto; }
.issue-list li { display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid #EEEAE2; font-size: 15px; }
.issue-list li:first-child { border-top: 0; }
.issue-line { flex: none; width: 64px; color: var(--muted); font-variant-numeric: tabular-nums; }
.issue-list strong { display: block; }
.issue-error { display: block; color: var(--danger); }
.issue-warning { display: block; color: var(--warning); }
.change-list { margin: 6px 0 0; padding: 8px 10px; list-style: none; border-radius: 8px; background: var(--surface-3); font-size: 14px; }
.change-field { color: var(--text-2); }

.rate-hero { display: block; margin-top: 14px; padding: 18px 20px; border-radius: 14px; background: linear-gradient(135deg, var(--primary-tint), #fff); border: 1px solid #CFE0D5; color: var(--text); }
.rate-hero:hover { text-decoration: none; border-color: #B5D0C0; }
.rate-hero-label { display: block; color: var(--success); font-size: 13.5px; font-weight: 700; }
.rate-hero-value { display: block; margin-top: 4px; font-size: 40px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.rate-hero-value small { font-size: 17px; font-weight: 600; color: var(--text-2); letter-spacing: 0; }
.rate-hero-sub { display: block; color: var(--text-2); }
.rate-hero-rule { display: block; margin-top: 8px; color: var(--text-2); font-size: 14.5px; }
.rate-card .form-actions { margin-top: 12px; }
.plan-list { margin-top: 16px; border-top: 1px solid var(--border); }
.rate-form { max-width: 820px; display: grid; gap: 18px; }
.rate-form .form-card-flush > .field:last-child { margin-bottom: 0; }

.grid-card { padding-bottom: 14px; }
.legend { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13.5px; }
.legend-ref, .legend-override { display: inline-block; width: 14px; height: 14px; border-radius: 4px; }
.legend-ref { box-shadow: 0 0 0 2px var(--primary) inset; }
.legend-override { background: #fff1d6; margin-left: 8px; }
.rate-grid-wrap { margin-top: 14px; max-height: 70vh; overflow: auto; border: 1px solid var(--border); border-radius: 12px; }
.rate-grid { border-collapse: separate; border-spacing: 0; font-size: 14px; font-variant-numeric: tabular-nums; }
.rate-grid th, .rate-grid td { padding: 6px 8px; border-right: 1px solid #EEEAE2; border-bottom: 1px solid #EEEAE2; text-align: right; white-space: nowrap; }
.rate-grid thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-3); color: var(--text-2); font-weight: 700; }
.rate-grid tbody th { position: sticky; left: 0; z-index: 1; background: var(--surface-3); color: var(--text-2); font-weight: 700; }
.rate-grid .corner { left: 0; z-index: 3; text-align: left; font-size: 11.5px; line-height: 1.2; }
.rate-grid .corner span { display: block; }
.rate-grid th.is-base { color: var(--primary); }
.rate-grid td.is-override { background: #fff1d6; }
.rate-grid td.is-ref { box-shadow: 0 0 0 2px var(--primary) inset; font-weight: 700; }
.rate-grid td.is-hit { background: var(--primary); color: #fff; font-weight: 700; }
.rate-grid td.is-changed { background: var(--primary-soft); }
.rate-grid.is-editable td { padding: 2px; }
.rate-grid input { width: 62px; height: 30px; padding: 0 6px; border: 1px solid transparent; border-radius: 6px; background: transparent; text-align: right; font: inherit; }
.rate-grid input:hover { border-color: var(--border-strong); }
.rate-grid input:focus { border-color: var(--primary); background: #fff; outline: none; box-shadow: 0 0 0 3px rgba(30, 107, 82, .15); }
.sticky-actions { align-items: center; }
.rule-text { margin-top: 10px; font-size: 16px; font-weight: 600; }
.calc { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-top: 12px; }
.calc label { display: grid; gap: 4px; font-size: 14px; font-weight: 600; }
.calc input { width: 90px; height: 44px; padding: 0 12px; border: 1.5px solid var(--border-strong); border-radius: 10px; font-size: 17px; }
.calc-result { margin-top: 14px; font-size: 32px; font-weight: 800; letter-spacing: -.02em; }
.calc-result small { font-size: 15px; font-weight: 600; color: var(--text-2); letter-spacing: 0; }
.calc-result.is-rejected { color: var(--danger); font-size: 24px; }

/* printable rate chart */
.print-page { padding: 24px; background: #fff; }
.print-bar { display: flex; gap: 10px; margin-bottom: 20px; }
.print-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 12px; }
.print-head h1 { font-size: 24px; letter-spacing: -.02em; }
.print-head p { color: var(--text-2); }
.print-rule { max-width: 380px; text-align: right; font-size: 14px; }
.print-page .rate-grid-wrap { max-height: none; overflow: visible; }
.print-page .rate-grid { width: 100%; }
.print-foot { margin-top: 12px; color: var(--text-2); font-size: 13px; }
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  .print-bar { display: none; }
  .print-page { padding: 0; }
  .print-page .rate-grid { font-size: 10px; }
  .print-page .rate-grid th, .print-page .rate-grid td { padding: 2px 4px; }
  .print-page .rate-grid thead th, .print-page .rate-grid tbody th { position: static; }
  .print-page .rate-grid-wrap { border: 0; }
}

/* =====================================================================
   Milk collection
   ===================================================================== */
.shift-nav { flex-wrap: wrap; justify-content: flex-end; }
.day-nav { display: inline-flex; align-items: center; gap: 4px; }
.day-form { margin: 0; }
.day-form input { height: 44px; padding: 0 10px; border: 1.5px solid var(--border-strong); border-radius: 10px; background: #fff; font-variant-numeric: tabular-nums; }
.flip { display: inline-grid; transform: scaleX(-1); }
.icon-btn.is-disabled { opacity: .35; cursor: default; }
.segmented { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--surface-3); }
.segmented a { padding: 8px 16px; border-radius: 9px; color: var(--text-2); font-weight: 600; }
.segmented a:hover { text-decoration: none; color: var(--text); }
.segmented a.is-active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(11, 30, 24, .12); }

.device-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: -6px 0 16px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.device-group { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.device-group select { height: 36px; max-width: 240px; padding: 0 8px; border: 1.5px solid var(--border-strong); border-radius: 8px; background: #fff; font-size: 14px; }
.device-status { flex-basis: 100%; color: var(--text-2); font-size: 13.5px; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.device-status:empty { display: none; }
.device-status.is-bad { color: var(--danger); font-family: var(--font); }
.entry-field input[data-from-device] { border-color: #8FBFA5; background: var(--primary-tint); }
.water-warning { margin-top: 12px; padding: 10px 14px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.device-tag { color: var(--primary); font-weight: 600; }
.text-danger { color: var(--danger); font-weight: 600; }
.sheet-mark { color: var(--primary); font-size: 10px; vertical-align: 1px; }
@media (max-width: 600px) {
  .device-bar { gap: 10px; }
  .device-group { width: 100%; flex-wrap: wrap; }
  .device-group select { flex: 1 1 calc(100% - 30px); max-width: none; min-width: 0; }
}
.entry-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
.entry-card { padding: 24px; }
.entry-farmer { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 14px; align-items: end; }
.entry-field { display: grid; gap: 6px; font-size: 14.5px; font-weight: 600; color: var(--text-2); }
.entry-field input { width: 100%; height: 60px; padding: 0 14px; border: 1.5px solid var(--border-strong); border-radius: 12px; background: #fff;
  color: var(--text); font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.entry-field input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.entry-field input[type=number]::-webkit-inner-spin-button, .entry-field input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.entry-field input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 4px rgba(30, 107, 82, .15); }
.entry-field .field-error { margin: 0; min-height: 0; font-weight: 500; }
.farmer-card { display: flex; flex-direction: column; justify-content: center; min-height: 60px; padding: 8px 16px; border-radius: 12px; background: var(--surface-3); color: var(--text-2); }
.farmer-card strong { color: var(--text); font-size: 20px; letter-spacing: -.01em; }
.farmer-card span { font-size: 14.5px; }
.farmer-card.is-known { background: var(--success-soft); }
.farmer-card.is-unknown { background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.entry-milk { display: flex; gap: 8px; margin: 14px 0 0; padding: 0; border: 0; }
.milk-choice { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border: 1.5px solid var(--border-strong); border-radius: 999px; font-weight: 600; cursor: pointer; }
.milk-choice input { width: 18px; height: 18px; margin: 0; accent-color: var(--primary); }
.milk-choice:has(input:checked) { border-color: var(--primary); background: var(--primary-tint); color: var(--primary-ink); }
.entry-readings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.entry-readings [hidden] { display: none !important; }
.link-btn { margin-top: 8px; padding: 0; border: 0; background: none; color: var(--primary); font-size: 14.5px; font-weight: 600; cursor: pointer; }
.entry-preview { display: flex; align-items: baseline; gap: 12px; min-height: 48px; margin-top: 16px; padding: 10px 16px; border-radius: 12px; background: var(--surface-2); color: var(--text-2); }
.entry-preview:empty { visibility: hidden; }
.entry-preview strong { color: var(--text); font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.entry-preview.is-good { background: var(--success-soft); }
.entry-preview.is-bad { background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.entry-actions { display: flex; align-items: center; gap: 16px; margin-top: 16px; }
.entry-actions kbd { margin-left: 6px; padding: 2px 6px; border-radius: 5px; background: rgba(255, 255, 255, .22); font: 600 12px var(--font); }
.entry-status { flex: 1; color: var(--text-2); font-size: 15px; }
.entry-status.is-ok { color: var(--success); font-weight: 600; }
.entry-status.is-error { color: var(--danger); font-weight: 600; }
.totals { margin: 12px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 14px 12px; }
.totals div { min-width: 0; }
.totals dt { color: var(--text-2); font-size: 13.5px; }
.totals dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.totals-main dd { font-size: 26px; letter-spacing: -.02em; }
.totals div:not(.totals-main) { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 12px; padding-top: 10px; border-top: 1px solid #EEEAE2; }
.totals-note { color: var(--danger); font-weight: 500; }
.entry-table tr.is-rejected th, .entry-table tr.is-rejected td { background: #fffafa; }
.entry-table tr.is-fresh { animation: fresh 1.6s ease-out; }
@keyframes fresh { from { background: var(--success-soft); } to { background: transparent; } }
.reopen-form[open] > form { display: flex; gap: 8px; }
.overview-table td { vertical-align: top; }

/* printed shift sheet and slip */
.sheet-table { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.sheet-table th, .sheet-table td { padding: 5px 8px; border-bottom: 1px solid #E7E2D8; text-align: right; }
.sheet-table .left { text-align: left; }
.sheet-table thead th { background: var(--surface-3); }
.sheet-table tfoot th { border-top: 2px solid var(--text); font-size: 14.5px; }
.sheet-table tr.is-rejected td { color: var(--danger); }
.sheet-note { margin-top: 8px; color: var(--text-2); font-size: 13px; }
.sheet-h2 { margin-top: 18px; font-size: 16px; }
.sheet-changes { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.signatures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px; margin-top: 48px; }
.signatures div { padding-top: 8px; border-top: 1px solid var(--text); color: var(--text-2); font-size: 13px; }
.slip-page { padding: 16px; background: #fff; }
.slip { width: 72mm; padding: 4mm; font: 13px/1.35 ui-monospace, "SF Mono", Menlo, monospace; color: #000; }
.slip-centre { text-align: center; }
.slip-title { margin: 6px 0; padding: 4px 0; border-top: 1px dashed #000; border-bottom: 1px dashed #000; text-align: center; font-weight: 700; }
.slip dl { margin: 0; }
.slip dl div { display: flex; justify-content: space-between; gap: 8px; }
.slip dt { font-weight: 400; }
.slip dd { margin: 0; text-align: right; font-weight: 700; }
.slip-amount { margin-top: 4px; padding-top: 4px; border-top: 1px dashed #000; font-size: 15px; }
.slip-foot { margin-top: 8px; text-align: center; font-size: 11px; }
@media print {
  .sheet-page { font-size: 12px; }
  @page :first { margin-top: 10mm; }
  .slip-page { padding: 0; }
  .slip-page .print-bar { display: none; }
}

/* =====================================================================
   Payments and reports
   ===================================================================== */
.pill-run-draft { background: var(--primary-soft); color: var(--primary-ink); }
.pill-run-approved { background: var(--warning-soft); color: var(--warning); }
.pill-run-paid { background: var(--success-soft); color: var(--success); }
a.pill:hover { text-decoration: none; filter: brightness(.97); }
.text-warning { color: var(--warning); font-weight: 600; }
.select { height: 46px; padding: 0 36px 0 14px; border: 1.5px solid var(--border-strong); border-radius: 10px; background: #fff; font-size: 16px; }
.period-list { margin: 10px 0 0; padding: 0; list-style: none; }
.period-list li { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-top: 1px solid #EEEAE2; }
.period-list li:first-child { border-top: 0; }
.period-main { flex: 1; min-width: 0; }
.period-main strong { display: block; font-size: 16.5px; }
.period-main > span { display: block; color: var(--text-2); font-size: 14.5px; }
.period-action { width: 120px; text-align: right; }
.period-action form { margin: 0; }
.filter-chips-tight { margin: 0; }
.action-bar { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px; }
.action-bar form { margin: 0; }
.action-bar .action-form[open] > form { min-width: 300px; }
.action-bar .action-hint { align-self: center; margin: 0; }
.filter-chips-tight .chip { height: 32px; padding: 0 12px; font-size: 14px; }
.toolbar-tight { margin-top: 0; }
.deduction-list li .num { text-align: right; }
.deduction-list form { margin: 0; }
.report-tabs { margin-top: 22px; }
.report-range { margin-top: 16px; align-items: center; flex-wrap: wrap; }
.report-table tfoot th, .report-table tfoot td { padding: 12px 14px; border-top: 2px solid var(--border-strong); }
.statement { max-width: 820px; margin: 0 auto 32px; padding-bottom: 24px; border-bottom: 1px dashed var(--border-strong); }
.statement-head { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 12px; }
.statement-head h1 { font-size: 22px; letter-spacing: -.02em; }
.statement-head p { color: var(--text-2); }
.statement-from { text-align: right; font-size: 13.5px; color: var(--text-2); }
.sheet-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 600px) {
  .print-page { padding: 16px; }
  .statement .sheet-table { font-size: 12.5px; }
  .statement .sheet-table th, .statement .sheet-table td { padding: 5px 6px; white-space: nowrap; }
}
.statement-sums { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin-top: 10px; }
.statement-sums dl { margin: 0 0 0 auto; width: min(100%, 420px); }
.statement-sums dl div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 14px; }
.statement-sums dd { margin: 0; font-variant-numeric: tabular-nums; }
.statement-net { margin-top: 4px; padding-top: 8px !important; border-top: 2px solid var(--text); font-size: 17px !important; font-weight: 800; }
.statement-sums p { color: var(--text-2); font-size: 13.5px; }
@media print {
  .statement { page-break-after: always; border: 0; margin: 0; max-width: none; }
  .statement:last-child { page-break-after: auto; }
}

/* =====================================================================
   Milk movement
   ===================================================================== */
.send-card { max-width: 860px; }
.shift-picks { display: grid; gap: 6px; }
.shift-pick { padding: 10px 12px; border: 1.5px solid var(--border-strong); border-radius: 10px; }
.shift-pick:has(input:checked) { border-color: var(--primary); background: var(--primary-tint); }
.shift-pick .row-sub { display: inline; margin-left: 6px; }
.send-help { margin: -10px 0 18px; }
.empty-block { display: grid; justify-items: center; gap: 8px; padding: 24px; color: var(--success); text-align: center; }
.empty-block p { color: var(--text-2); }
.dispatch-table tr.is-flagged th, .dispatch-table tr.is-flagged td { background: #fffafa; }
.facility-card { display: flex; align-items: center; gap: 16px; color: var(--text); }
.facility-card:hover { text-decoration: none; border-color: #C9DCCF; }
.facility-card .person span { font-size: 14.5px; }
.compare-table td, .compare-table th { white-space: nowrap; }
.staff-form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.staff-form input { height: 40px; padding: 0 12px; border: 1.5px solid var(--border-strong); border-radius: 8px; }

/* =====================================================================
   Farmer page (on the farmer's phone)
   ===================================================================== */
.portal { background: var(--page); }
.portal-shell { max-width: 560px; min-height: 100vh; margin: 0 auto; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.portal-header { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: rgba(251, 249, 245, .85); -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px); border-bottom: 1px solid var(--border); }
.portal-header .org-logo { width: 40px; height: 40px; border-radius: 10px; }
.portal-who { flex: 1; min-width: 0; }
.portal-who strong { display: block; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-who span { display: block; color: var(--text-2); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-main { display: grid; gap: 14px; padding: 16px; }
.portal-title { font-size: 30px; font-weight: 800; letter-spacing: -.03em; }
.portal-card { display: block; padding: 18px; border-radius: 18px; background: #fff; border: 1px solid var(--border); }
.portal-card .card-head h2 { font-size: 19px; }
.hero-card { background: linear-gradient(160deg, #0B352A, #1E6B52); border: 0; color: #fff; }
.hero-label { font-size: 14px; font-weight: 600; opacity: .85; }
.hero-amount { margin-top: 2px; font-size: 42px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.hero-sub { font-size: 15.5px; }
.hero-note { margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, .25); font-size: 13.5px; opacity: .85; }
.link-card { display: flex; align-items: center; gap: 12px; color: var(--text); }
.link-card:hover { text-decoration: none; }
.link-amount { font-size: 18px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.milk-list { margin: 8px 0 0; padding: 0; list-style: none; }
.milk-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 12px 0; border-top: 1px solid #EEEAE2; }
.milk-row:first-child { border-top: 0; }
.milk-row span { display: block; }
.milk-row > span > span { color: var(--text-2); font-size: 13.5px; }
.milk-money { text-align: right; font-variant-numeric: tabular-nums; }
.milk-row.is-rejected .milk-what strong { color: var(--muted); }
.period-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.period-chips .chip { flex: none; }
.portal-totals { margin: 0; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr); max-width: 560px; margin: 0 auto;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, .9); -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px); border-top: 1px solid var(--border); }
.tabbar a { display: grid; justify-items: center; gap: 2px; padding: 6px 0; border-radius: 10px; color: var(--muted); font-size: 11.5px; font-weight: 600; }
.tabbar a:hover { text-decoration: none; }
.tabbar a.is-active { color: var(--primary); }
.portal-login { display: grid; justify-items: center; gap: 10px; padding: 40px 4px 16px; text-align: center; }
.portal-login h1 { font-size: 30px; letter-spacing: -.03em; }
.portal-login-mark { border-radius: 16px; object-fit: contain; }
.portal-lede { color: var(--text-2); font-size: 16.5px; }
.portal-login .portal-card { width: 100%; margin-top: 10px; text-align: left; }
.portal-note { color: var(--text-2); font-size: 14.5px; }
.pin-input { letter-spacing: .4em; font-variant-numeric: tabular-nums; }
.choose-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 4px; border: 0; border-top: 1px solid #EEEAE2; background: none; text-align: left; cursor: pointer; }
.choose-row:first-of-type { border-top: 0; }
.portal .toasts { left: 16px; right: 16px; bottom: calc(90px + env(safe-area-inset-bottom)); }

/* PIN slips to cut out */
.pin-slips { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.pin-slip { padding: 14px 16px; border: 1.5px dashed var(--border-strong); border-radius: 10px; break-inside: avoid; }
.pin-slip-centre { color: var(--text-2); font-size: 13px; }
.pin-slip-name { font-size: 17px; font-weight: 700; }
.pin-slip dl { display: flex; gap: 24px; margin: 8px 0; }
.pin-slip dt { color: var(--text-2); font-size: 12.5px; }
.pin-slip dd { margin: 0; font-size: 20px; font-weight: 700; }
.pin-slip-how { margin-top: 4px; color: var(--text-2); font-size: 12.5px; overflow-wrap: anywhere; }
.pick-list li { padding: 8px 0; }
.select-all { margin-bottom: 8px; }
@media print { .pin-slips { grid-template-columns: 1fr 1fr; } }

/* =====================================================================
   Sign-in and message pages
   ===================================================================== */
.auth { display: flex; flex-direction: column; min-height: 100vh; background: var(--page); }
.auth-header { display: flex; align-items: center; height: 80px; padding: 0 40px; background: #fff; border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 14px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { object-fit: contain; }
.brand-wordmark { display: flex; flex-direction: column; gap: 2px; line-height: 1.15; }
.brand-wordmark strong { font-size: 22px; letter-spacing: -.02em; }
.brand-wordmark small { color: #4E5A54; font-size: 12.5px; font-weight: 500; letter-spacing: .02em; }
.auth-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 20px; }
.auth-messages { width: 100%; max-width: 560px; margin: 0 auto 16px; }
.auth-message { margin: 0 0 8px; padding: 12px 16px; border-radius: 10px; background: #EEF5F0; color: #0B352A; }
.auth-hero { display: block; width: 100%; max-width: 560px; height: auto; margin: 0 0 20px; border: 1.5px solid var(--border); border-radius: var(--radius-lg); background: #fbf9f5; }
.auth-card { width: 100%; max-width: 560px; padding: 44px 46px; background: #fff; border: 1.5px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); }
.auth-card.center { text-align: center; }
.auth-card h1 { font-size: 38px; line-height: 1.1; font-weight: 800; letter-spacing: -.035em; }
.auth-card .eyebrow { margin-bottom: 8px; color: var(--muted); font-size: 12.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.auth-card .subtitle { margin: 10px 0 28px; color: var(--text-2); font-size: 18px; line-height: 1.45; }
.card-icon { display: grid; place-items: center; width: 72px; height: 72px; margin: 0 auto 20px; border-radius: 50%; }
.after-note { margin-top: 20px; color: var(--text-2); font-size: 15.5px; text-align: center; }
.auth-footer { padding: 20px 40px; border-top: 1px solid var(--border); color: #8C918B; font-size: 14.5px; text-align: center; }

/* =====================================================================
   Responsive
   ===================================================================== */
@media (max-width: 1180px) {
  .entry-layout { grid-template-columns: minmax(0, 1fr); }
  .review-layout { grid-template-columns: minmax(0, 1fr); }
  .review-layout > aside { position: static; order: -1; }
}
@media (max-width: 1080px) {
  .grid-2, .form-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 920px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 50; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); transform: translateX(-100%); visibility: hidden; transition: transform .22s ease, visibility .22s; box-shadow: var(--shadow-pop); }
  .sidebar-open .sidebar { transform: none; visibility: visible; }
  .sidebar-close { display: inline-grid; }
  .sidebar-scrim { position: fixed; inset: 0; z-index: 45; background: rgba(11, 30, 24, .35); }
  .sidebar-open .sidebar-scrim { display: block; }
  .menu-toggle { display: inline-grid; margin-left: -8px; }
  .topbar { padding: 0 20px; gap: 12px; }
}
@media (max-width: 760px) {
  .topbar { height: 64px; padding: 0 12px 0 16px; gap: 8px; }
  .topbar-context .btn { display: none; }
  .context-chip { height: 36px; padding: 0 10px; font-size: 14.5px; }
  .avatar { width: 40px; height: 40px; font-size: 15px; }
  .content { padding: 22px 16px 40px; }
  .page-head { flex-direction: column; gap: 14px; }
  .page-head h1 { font-size: 28px; }
  .page-sub { font-size: 16px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 22px; }
  .stat-card { flex-direction: column; align-items: flex-start; gap: 12px; padding: 16px; }
  .stat-icon { width: 46px; height: 46px; }
  .stat-value { font-size: 26px; }
  .card { padding: 16px; }
  .card h2 { font-size: 20px; }
  .details > div, .details-compact > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .doc-row { grid-template-columns: auto minmax(0, 1fr); }
  .doc-side { grid-column: 2; }
  .doc-actions { grid-column: 1 / -1; }
  .file-input input { max-width: 100%; }
  .form-card-flush { padding: 18px; }
  .choice-group { grid-template-columns: minmax(0, 1fr); }
  .credentials { flex-direction: column; }
  .field-grid, .field-grid-3 { grid-template-columns: minmax(0, 1fr); }
  .page-head-actions { flex-wrap: wrap; }
  .show-sm { display: inline; }
  .period-list li { flex-wrap: wrap; }
  .period-action { width: auto; }
  .statement-head { flex-direction: column; }
  .statement-from { text-align: left; }
  .entry-card { padding: 16px; }
  .entry-farmer { grid-template-columns: 120px minmax(0, 1fr); gap: 10px; }
  .entry-readings { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .entry-field input { height: 54px; padding: 0 10px; font-size: 22px; }
  .entry-actions { flex-direction: column; align-items: stretch; }
  .shift-nav { justify-content: flex-start; }
  .entry-table .cell-action { grid-column: 2; grid-row: 3; }
  .notice-cta { flex-wrap: wrap; }
  .data-table { font-size: 15px; }
  .data-table thead th, .data-table tbody th, .data-table tbody td { padding: 10px 8px; }
  .hide-sm { display: none; }
  /* tables marked .stack-sm become a list: name and place on the left, status and action on the right */
  .table-wrap:has(.stack-sm) { overflow: visible; }
  .stack-sm, .stack-sm tbody { display: block; }
  .stack-sm thead { display: none; }
  .stack-sm tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 14px 0; border-bottom: 1px solid #EEEAE2; }
  .stack-sm tbody tr:first-child { padding-top: 0; }
  .stack-sm tbody tr:last-child { border-bottom: 0; padding-bottom: 0; }
  .stack-sm tbody th, .stack-sm tbody td { display: block; padding: 0; border: 0; }
  .stack-sm tbody .hide-sm { display: none; }
  .stack-sm tbody th { grid-column: 1; grid-row: 1; }
  .stack-sm .cell-location { grid-column: 1; grid-row: 2; color: var(--text-2); }
  .stack-sm .cell-location .row-sub { display: inline; }
  .stack-sm .cell-location .row-sub::before { content: " · "; }
  .stack-sm .cell-status { grid-column: 2; grid-row: 1; justify-self: end; }
  .stack-sm .cell-action { grid-column: 2; grid-row: 2; justify-self: end; }
  .toolbar { flex-direction: column; }
  .search-field { flex: none; max-width: none; }
  .toasts { left: 16px; right: 16px; bottom: 16px; }
  .auth-header { height: 64px; padding: 0 16px; }
  .brand-wordmark strong { font-size: 19px; }
  .auth-main { justify-content: flex-start; padding: 24px 16px; }
  .auth-card { padding: 28px 20px; border-radius: 18px; }
  .auth-card h1 { font-size: 30px; }
  .auth-card .subtitle { font-size: 16.5px; }
}
@media (max-width: 340px) {
  .stats { grid-template-columns: minmax(0, 1fr); }
  .stat-card { flex-direction: row; align-items: center; }
}

/* ---- collapsible sidebar (wide screens only; phones keep the slide-in drawer) ---- */
.sidebar-collapse { display: inline-grid; flex: none; width: 40px; height: 40px; margin-left: -24px; color: var(--text-2); }
.sidebar-collapse .icon { transition: transform .2s ease; }
@media (min-width: 921px) {
  .app-shell { transition: grid-template-columns .2s ease; }
  .sidebar-collapsed .app-shell { grid-template-columns: 76px minmax(0, 1fr); }
  .sidebar-collapsed .sidebar { z-index: 30; padding: 18px 10px; overflow-x: hidden; }
  .sidebar-collapsed .org-switch { justify-content: center; }
  .sidebar-collapsed .org-menu { flex: none; }
  .sidebar-collapsed .org-menu > summary, .sidebar-collapsed .org-static { gap: 0; padding: 4px; justify-content: center; }
  .sidebar-collapsed .org-text, .sidebar-collapsed .org-caret, .sidebar-collapsed .role-chip { display: none; }
  .sidebar-collapsed .sidebar-collapse .icon { transform: scaleX(-1); }
  .sidebar-collapsed .org-menu .menu-panel { position: fixed; top: 18px; left: 84px; }
  .sidebar-collapsed .side-nav:first-of-type { margin-top: 22px; }
  .sidebar-collapsed .side-nav a { position: relative; justify-content: center; gap: 0; padding: 12px 0; }
  .sidebar-collapsed .side-nav a > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
@media (max-width: 920px) { .sidebar-collapse { display: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---- Plant: silos, batches, quality -------------------------------------------------------- */
a.stat-link { color: inherit; text-decoration: none; transition: box-shadow .15s, transform .15s; }
a.stat-link:hover { box-shadow: var(--shadow-md, 0 6px 18px rgba(11, 30, 24, .08)); text-decoration: none; }
.pill-batch-planned { background: var(--surface-3); color: var(--text-2); }
.pill-batch-making { background: var(--primary-soft); color: var(--primary-ink); }
.pill-batch-testing { background: var(--warning-soft); color: var(--warning); }
.pill-batch-released { background: var(--success-soft); color: var(--success); }
.pill-batch-rejected { background: var(--danger-soft); color: var(--danger); }
h1 .pill { vertical-align: 8px; margin-left: 6px; }
.notice-success { background: var(--success-soft); border-color: #cde9d6; color: var(--success); }
.silo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-top: 16px; }
.silo-tile { display: flex; flex-direction: column; gap: 8px; padding: 16px; border: 1px solid var(--border); border-radius: 14px; color: inherit; background: var(--surface-2); transition: border-color .15s, background .15s; }
.silo-tile:hover { text-decoration: none; border-color: var(--border-strong); background: #fff; }
.silo-top { display: flex; flex-direction: column; gap: 2px; }
.silo-code { color: var(--text-2); font-size: 13.5px; }
.silo-litres { font-size: 24px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.silo-litres small { color: var(--text-2); font-size: 14px; font-weight: 500; letter-spacing: 0; }
.fill-bar { display: block; height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.fill-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--primary); }
.silo-quality { color: var(--text-2); font-size: 14px; font-variant-numeric: tabular-nums; }
.row-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; justify-content: flex-end; }
.row-form select, .row-form input[type=text] { height: 36px; min-width: 0; max-width: 260px; padding: 0 10px; border: 1.5px solid var(--border-strong); border-radius: 8px; background: #fff; font-size: 15px; }
.row-form input[type=text] { width: 110px; }
.text-in { color: var(--success); font-weight: 600; }
.text-out { color: var(--text); }
.filter-form select, .filter-form input[type=date] { height: 44px; padding: 0 12px; border: 1.5px solid var(--border-strong); border-radius: 10px; background: #fff; font-size: 15.5px; }
.filter-form { flex-wrap: wrap; margin-top: 0; }
.page-head .filter-form { margin-top: 0; }
.batch-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.batch-side { position: sticky; top: 92px; }
.batch-side h2 { font-size: 19px; }
.step-no { display: inline-grid; place-items: center; width: 28px; height: 28px; margin-right: 10px; border-radius: 50%; background: var(--surface-3); color: var(--text-2); font-size: 15px; vertical-align: 2px; }
.compact-table { margin-top: 14px; font-size: 15.5px; }
.compact-table tbody th, .compact-table tbody td { padding: 11px 12px; }
.compact-table + .compact-table, .table-wrap + .table-wrap { margin-top: 6px; }
.add-panels { display: grid; gap: 10px; margin-top: 18px; }
.add-panel { border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.add-panel > summary { display: flex; align-items: center; gap: 8px; padding: 13px 16px; color: var(--primary); font-weight: 600; cursor: pointer; list-style: none; }
.add-panel > summary::-webkit-details-marker { display: none; }
.add-panel[open] > summary { border-bottom: 1px solid var(--border); }
.add-panel > form { padding: 16px; }
.add-panel .field:last-of-type { margin-bottom: 0; }
.packs-table input { width: 130px; height: 42px; padding: 0 12px; border: 1.5px solid var(--border-strong); border-radius: 10px; font-size: 17px; font-variant-numeric: tabular-nums; }
.qc-table td { vertical-align: top; }
.qc-table tr.is-fail th { color: var(--danger); }
.qc-result { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.qc-result.is-pass { color: var(--success); }
.qc-result.is-fail { color: var(--danger); }
.qc-form { justify-content: flex-start; margin-top: 6px; }
.qc-result + .row-sub + .qc-form { margin-top: 8px; }
.balance-table th, .balance-table td { font-size: 15px; }
.balance-loss th, .balance-loss td { font-weight: 700; }
.totals .sub dt, .totals .sub dd { font-size: 13px; font-weight: 500; color: var(--text-2); }
.formset-table input[type=text], .formset-table input[type=number], .formset-table select { width: 100%; min-width: 80px; height: 38px; padding: 0 8px; border: 1.5px solid var(--border-strong); border-radius: 8px; background: #fff; font-size: 15px; }
.formset-table td.narrow input { min-width: 64px; max-width: 90px; }
.formset-table input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--primary); }
.formset-table td { vertical-align: top; }
@media (max-width: 1100px) {
  .batch-layout { grid-template-columns: minmax(0, 1fr); }
  .batch-side { position: static; }
}
@media (max-width: 600px) {
  .row-form { justify-content: flex-start; }
  .row-form select { max-width: 100%; flex: 1 1 100%; }
  .packs-table input { width: 90px; }
  h1 .pill { vertical-align: 4px; }
}
.formset-table .field-error, .packs-table .field-error, .qc-table .field-error { display: block; }
.formset-table td:first-child input { min-width: 190px; }
.qc-change { margin-top: 4px; }
.qc-change > summary { display: inline-block; color: var(--primary); font-size: 14px; font-weight: 600; cursor: pointer; list-style: none; }
.qc-change > summary::-webkit-details-marker { display: none; }
.qc-change[open] > summary { margin-bottom: 2px; }
.balance-warning { margin: 12px 0 4px; font-size: 14.5px; align-items: flex-start; }

/* ---- Stock ---------------------------------------------------------------------------------- */
.tone-red { background: var(--danger-soft); color: var(--danger); }
.stock-table tbody.stock-group + tbody.stock-group tr.stock-sku > * { border-top: 8px solid #fff; }
.stock-table tr.stock-sku > * { background: var(--surface-2); }
.stock-table tr.stock-sku > :first-child { border-radius: 10px 0 0 10px; }
.stock-table tr.stock-sku > :last-child { border-radius: 0 10px 10px 0; }
.stock-table tr.stock-line > :first-child { padding-left: 34px; }
.stock-table tr.stock-line td { font-size: 15px; padding-top: 10px; padding-bottom: 10px; }
.stock-table tr.stock-line a { font-weight: 600; }
.fresh-ok { color: var(--text-2); font-size: 14px; white-space: nowrap; }
@media (max-width: 600px) {
  .stock-table tr.stock-line > :first-child { padding-left: 18px; }
  .stock-table .cell-action .pill { font-size: 12.5px; padding: 0 8px; }
}
.nowrap { white-space: nowrap; }

/* ---- Cold chain ------------------------------------------------------------------------------ */
.alarm-chip { display: inline-flex; align-items: center; gap: 6px; height: 36px; margin-right: 12px; padding: 0 12px; border-radius: 999px; background: var(--danger-soft); color: var(--danger); font-size: 14.5px; font-weight: 600; white-space: nowrap; }
.alarm-chip:hover { text-decoration: none; filter: brightness(.97); }
.topbar-actions { display: flex; align-items: center; }
.temp-state { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; font-size: 14px; }
.temp-state.is-ok { color: var(--success); }
.temp-state.is-bad { color: var(--danger); }
.temp-state.is-quiet { color: var(--text-2); }
.sensor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-top: 16px; }
.sensor-tile { display: flex; flex-direction: column; gap: 8px; padding: 16px; border: 1px solid var(--border); border-radius: 14px; background: #fff; color: inherit; transition: border-color .15s, box-shadow .15s; }
.sensor-tile:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow-card); }
.sensor-tile.state-warm, .sensor-tile.state-cold { border-color: #f1b7af; background: #fffafa; }
.sensor-top { display: flex; flex-direction: column; gap: 1px; }
.sensor-top span { color: var(--text-2); font-size: 13.5px; }
.sensor-temp { font-size: 30px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.sensor-temp small { font-size: 16px; font-weight: 500; color: var(--text-2); letter-spacing: 0; }
.state-warm .sensor-temp, .state-cold .sensor-temp { color: var(--danger); }
.state-offline .sensor-temp, .state-new .sensor-temp { color: var(--muted); }
.sparkline { width: 100%; height: 40px; overflow: visible; }
.spark-band { fill: var(--surface-3); }
.spark-line { fill: none; stroke: var(--primary); stroke-width: 2px; stroke-linejoin: round; stroke-linecap: round; }
.sensor-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sensor-limits, .sensor-seen { color: var(--text-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.alert-list { margin: 12px 0 0; padding: 0; list-style: none; }
.alert-row { display: flex; align-items: flex-start; gap: 12px; padding: 14px 0; border-bottom: 1px solid #EEEAE2; }
.alert-row:last-child { border-bottom: 0; padding-bottom: 0; }
.alert-icon { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 10px; }
.alert-icon.is-bad { background: var(--danger-soft); color: var(--danger); }
.alert-icon.is-quiet { background: var(--surface-3); color: var(--text-2); }
.alert-body { flex: 1; min-width: 0; }
.alert-title { margin: 0; }
.alert-meta { margin: 2px 0 0; color: var(--text-2); font-size: 14px; }
.alert-note { margin: 6px 0 0; color: var(--success); font-size: 14.5px; }
.alert-note .icon { display: inline; vertical-align: -2px; }
.alert-note span { color: var(--text-2); }
.ack-form { justify-content: flex-start; margin-top: 8px; }
.ack-form input[type=text] { flex: 1 1 260px; width: auto; max-width: none; }
.chart { position: relative; margin-top: 14px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; outline: none; }
.chart svg:focus-visible { box-shadow: 0 0 0 3px rgba(30, 107, 82, .25); border-radius: 8px; }
.chart .grid { stroke: #EFECE5; stroke-width: 1; }
.chart .tick { fill: var(--text-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .band { fill: #F3F0E9; }
.chart .limit { stroke: #CFC8BB; stroke-width: 1; }
.chart .limit-label { fill: var(--text-2); font-size: 11.5px; }
.chart .alert-band { fill: rgba(208, 59, 59, .10); }
.chart .alert-label { fill: var(--danger); font-size: 11.5px; font-weight: 600; }
.chart .series { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .end-dot, .chart .hover-dot { fill: var(--primary); stroke: #fff; stroke-width: 2; }
.chart .crosshair { stroke: #9C9F98; stroke-width: 1; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart-tip { position: absolute; display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: #fff; box-shadow: var(--shadow-card); pointer-events: none; font-size: 13px; white-space: nowrap; }
.chart-tip strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.chart-tip span { color: var(--text-2); }
@media (max-width: 600px) {
  .alarm-chip span { display: none; }
  .alarm-chip { width: 36px; padding: 0; justify-content: center; margin-right: 8px; }
}
.chart-sm { display: none; }
@media (max-width: 700px) {
  .chart-lg { display: none; }
  .chart-sm { display: block; }
  .card-head:has(.segmented) { flex-wrap: wrap; }
  .segmented a { padding: 7px 12px; white-space: nowrap; }
}
.live-temp { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); }
.live-temp.is-bad { color: var(--danger); }
.live-temp.is-quiet { color: var(--muted); }
.side-nav .nav-group { padding: 16px 14px 4px; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.side-nav .nav-group:first-child { padding-top: 4px; }
html.sidebar-collapsed .side-nav .nav-group span { display: none; }
html.sidebar-collapsed .side-nav .nav-group { padding: 6px 0; border-top: 1px solid var(--border); margin: 6px 12px 0; }

/* ---- Sales and the distributor app ---------------------------------------------------------- */
.search-row { margin-top: 4px; }
.search-row input[type=search] { width: 100%; max-width: 420px; height: 44px; padding: 0 14px; border: 1.5px solid var(--border-strong); border-radius: 10px; background: #fff; font-size: 16px; }
.order-total { margin-top: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.order-total:empty { display: none; }
.order-grid input { width: 110px; }
.day-card { position: relative; }
.day-card.is-next { border-color: #B5D0C0; box-shadow: 0 0 0 3px rgba(30, 107, 82, .08); }
.day-card .person span.day-cutoff { color: var(--muted); font-size: 12.5px; }
.order-card h2 { font-size: 18px; margin-bottom: 4px; }
.qty-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid #EEEAE2; }
.order-card h2 + .qty-row { border-top: 0; }
.qty-row label { display: flex; flex-direction: column; min-width: 0; cursor: pointer; }
.qty-row label span { color: var(--text-2); font-size: 13.5px; }
.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--border-strong); border-radius: 12px; overflow: hidden; flex: none; }
.stepper .step { width: 42px; height: 44px; border: 0; background: var(--surface-2); color: var(--primary); font-size: 22px; font-weight: 600; cursor: pointer; }
.stepper .step:active { background: var(--surface-3); }
.stepper input { width: 64px; height: 44px; border: 0; border-left: 1px solid var(--border); border-right: 1px solid var(--border); text-align: center; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stepper input:focus { outline: none; background: var(--primary-tint); }
.order-bar { position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px;
  border-radius: 16px; background: rgba(255, 255, 255, .94); -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px); border: 1px solid var(--border); box-shadow: var(--shadow-card); }
.order-bar [data-order-total] { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 15px; }
.order-sum { display: flex; justify-content: space-between; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 17px; }
.order-row { grid-template-columns: minmax(0, 1fr) 0 auto; }
.cancel-form { text-align: center; }
.portal-input { width: 100%; height: 46px; margin-top: 6px; padding: 0 12px; border: 1.5px solid var(--border-strong); border-radius: 12px; font-size: 16px; }
.field-label { font-weight: 600; }

/* ---- Dispatch and invoices -------------------------------------------------------------------- */
.stop-list { margin: 10px 0 0; padding: 0; list-style: none; }
.stop { display: flex; align-items: flex-start; gap: 14px; padding: 14px 0; border-bottom: 1px solid #EEEAE2; }
.stop:last-child { border-bottom: 0; }
.stop-no { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-ink); font-weight: 700; font-size: 14px; }
.stop.is-done .stop-no { background: var(--surface-3); color: var(--text-2); }
.stop-body { flex: 1; min-width: 0; }
.stop-title { margin: 0; }
.stop-meta { margin: 3px 0 0; color: var(--text-2); font-size: 14px; }
.stop-action { flex: none; }
.packs-table select { height: 42px; padding: 0 8px; border: 1.5px solid var(--border-strong); border-radius: 10px; background: #fff; font-size: 15px; max-width: 260px; }
.invoice-page { max-width: 900px; margin: 0 auto; }
.invoice { position: relative; padding: 28px; border: 1px solid var(--border); border-radius: 12px; }
.invoice-void { margin-bottom: 14px; padding: 8px 12px; border-radius: 8px; background: var(--danger-soft); color: var(--danger); font-weight: 700; }
.invoice-head { display: flex; justify-content: space-between; gap: 24px; padding-bottom: 14px; border-bottom: 2px solid var(--text); }
.invoice-head h1 { font-size: 22px; letter-spacing: -.02em; }
.invoice-head p { margin-top: 3px; color: var(--text-2); font-size: 13.5px; }
.invoice-title { text-align: right; }
.invoice-title h2 { font-size: 20px; text-transform: uppercase; letter-spacing: .06em; }
.invoice-title dl { margin: 8px 0 0; display: grid; gap: 2px; font-size: 13.5px; }
.invoice-title dl div { display: flex; justify-content: flex-end; gap: 10px; }
.invoice-title dt { color: var(--text-2); }
.invoice-title dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.invoice-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin: 14px 0; font-size: 14px; }
.invoice-parties h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); margin-bottom: 4px; }
.invoice-table .cell-sub { display: block; color: var(--text-2); font-size: 11px; }
.invoice-grand th { font-size: 17px; }
.invoice-words { margin-top: 10px; font-weight: 600; font-size: 14px; }
.invoice-tax { width: auto; min-width: 360px; margin-top: 12px; }
.invoice-foot { margin-top: 18px; color: var(--text-2); font-size: 12.5px; }
.sign-cell { min-width: 160px; }
@media print {
  .invoice { border: 0; padding: 0; }
  .print-bar { display: none; }
}
@media (max-width: 700px) {
  .invoice-page { padding: 12px; }
  .invoice { padding: 16px; }
  .invoice-head { flex-direction: column; gap: 10px; }
  .invoice-head h1 { font-size: 19px; }
  .invoice-title { text-align: left; }
  .invoice-title dl div { justify-content: flex-start; }
  .invoice-parties { grid-template-columns: 1fr; gap: 12px; }
  .invoice-table { min-width: 620px; }
  .invoice-tax { min-width: 0; width: 100%; }
}
.cost-chip { display: inline-block; margin: 2px 6px 2px 0; padding: 3px 9px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.page-head-actions .filter-form { flex-wrap: nowrap; }
.data-table .inline-form > summary.btn-quiet { height: 28px; padding: 0 8px; font-size: 13px; margin-top: 4px; }
@media (max-width: 700px) { .page-head-actions .filter-form { flex-wrap: wrap; } }

/* ---- Insights ---------------------------------------------------------------------------------- */
.stats-sm { margin-top: 16px; }
.stats-sm .stat-card { padding: 16px 18px; }
.bar-chart .bar { fill: var(--primary); }
.bar-chart .bar.is-hot { fill: var(--gold); }
.bar-chart .bar-hit { fill: transparent; cursor: pointer; outline: none; }
.bar-chart .bar-hit:focus-visible { stroke: var(--primary); stroke-width: 2; }
.bar-chart .baseline { stroke: #CFC8BB; stroke-width: 1; }
.bar-chart .chart-tip { top: 0; }
.table-view > summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.table-view[open] > summary { margin-bottom: 8px; }
.forecast-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.forecast-day { display: flex; flex-direction: column; gap: 2px; padding: 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.forecast-day span { color: var(--text-2); font-size: 13px; }
.forecast-day strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.forecast-day small { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.trace-flow { display: grid; gap: 16px; }
.trace-step { position: relative; padding-left: 64px; }
.trace-no { position: absolute; left: 20px; top: 22px; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-ink); font-weight: 700; }
.trace-chips { margin-top: 10px; }
@media (max-width: 700px) {
  .forecast-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .trace-step { padding-left: 20px; padding-top: 58px; }
  .trace-no { top: 18px; }
}
.bar-chart .tick { font-size: 12.5px; }
.lang-switch { margin: 0; }
.lang-switch-top { display: flex; justify-content: flex-end; }
