:root {
  --bg: #F3EFE7; --card: #FFFFFF; --line: #E2DBCD; --line-2: #EDE8DD;
  --ink: #1E2A22; --muted: #6B6F66; --faint: #9A9C93;
  --green: #2E7D4F; --green-d: #1F3A2B; --green-dd: #172D21; --green-soft: #E4F0E7; --green-line: #2E7D4F;
  --red: #B83A2E; --red-soft: #F8E1DD; --amber: #B26A12; --amber-soft: #FBEBD3; --grey-soft: #ECE8DF;
  --blue: #2F6DB5; --blue-soft: #E1ECF8; --purple: #6B5B9A; --purple-soft: #ECE8F5; --brown: #B07A2E; --yellow: #D9A441;
  --r: 14px; --r-sm: 10px; --shadow: 0 1px 2px rgba(30, 42, 34, .05);
  --side: 252px;
}
* { box-sizing: border-box; }
html, body { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; overflow-x: hidden; margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 15px; -webkit-font-smoothing: antialiased; }
a { color: var(--green); }
h1 { font-size: 30px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 700; margin: 0 0 12px; letter-spacing: .03em; text-transform: uppercase; color: var(--ink); }
h3 { font-size: 16px; margin: 0 0 8px; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.red { color: var(--red); } .green { color: var(--green); } .amber { color: var(--amber); } .bold { font-weight: 700; }
.right { text-align: right; } .center { text-align: center; } .nowrap { white-space: nowrap; }
.row { display: flex; gap: 10px; align-items: center; } .row.wrap { flex-wrap: wrap; } .grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.spacer { height: 16px; }
.hidden { display: none !important; }

/* boot */
.boot { min-height: 100vh; display: grid; place-content: center; gap: 18px; justify-items: center; }
.boot img { width: 120px; height: 120px; border-radius: 50%; }
.boot-bar { width: 160px; height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.boot-bar span { display: block; height: 100%; width: 40%; background: var(--green); animation: boot 1.1s infinite ease-in-out; }
@keyframes boot { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }
#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: var(--red-soft); color: var(--red); padding: 12px 16px; z-index: 1000; font-weight: 600; }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }

/* shell */
.shell { display: flex; min-height: 100vh; }
.side { width: var(--side); background: var(--green-d); color: #E9EFE9; position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; padding: 20px 14px; overflow-y: auto; z-index: 20; }
.brand { display: flex; gap: 12px; align-items: center; padding: 6px 6px 22px; }
.brand img, .brand .logo-ph { width: 46px; height: 46px; border-radius: 12px; background: #fff; object-fit: contain; flex: none; }
.brand .logo-ph { display: grid; place-items: center; color: var(--green-d); font-size: 10px; font-weight: 700; }
.brand b { display: block; font-size: 16px; line-height: 1.2; color: #fff; }
.brand span { font-size: 13px; color: #A9BAAD; }
.nav a { display: flex; gap: 12px; align-items: center; padding: 8px 14px; border-radius: 10px; color: #DCE5DD; text-decoration: none; font-size: 15px; margin-bottom: 2px; }
.nav a:hover { background: rgba(255,255,255,.06); }
.nav-group { font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: #8FA596; padding: 14px 14px 5px; }
.nav-group:first-child { padding-top: 2px; }
.nav a.active { background: var(--green); color: #fff; font-weight: 600; }
.nav a svg { width: 19px; height: 19px; opacity: .85; flex: none; }
.nav .count, .bell .count { background: var(--red); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 7px; margin-left: auto; }
.bell { position: relative; color: var(--ink); text-decoration: none; }
.bell .count { position: absolute; top: -6px; right: -8px; margin: 0; }
.notif { display: flex; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line-2); text-decoration: none; color: inherit; }
.notif:last-child { border-bottom: 0; }
.notif .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); margin-top: 7px; flex: none; }
.notif.read .dot { background: transparent; }
.notif.read { opacity: .7; }
.side-foot { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; color: #A9BAAD; }
.side-foot button { background: none; border: 0; color: #DCE5DD; cursor: pointer; padding: 6px 0; display: flex; gap: 8px; align-items: center; white-space: nowrap; font: inherit; }
.side-foot button svg { flex: none; width: 18px; height: 18px; }
.main { margin-left: var(--side); flex: 1; min-width: 0; padding: 28px 36px 60px; }
.topbar { display: none; }
.bottomnav { display: none; }

.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .grow h1 + .muted { margin-top: 4px; }
.back { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; cursor: pointer; text-decoration: none; color: var(--ink); flex: none; }
.back svg { width: 20px; height: 20px; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; box-shadow: var(--shadow); }
.card.tight { padding: 14px 16px; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.grid > .card { margin-top: 0; }
.stats3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi .label { font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.kpi .value { font-size: 34px; font-weight: 700; margin: 6px 0 2px; letter-spacing: -.01em; }
.kpi .sub { font-size: 14px; color: var(--muted); }
.stat { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; background: var(--card); }
.stat .label { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.stat .value { font-size: 20px; font-weight: 700; margin-top: 2px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 10px; padding: 10px 16px; font-weight: 600; cursor: pointer; text-decoration: none; min-height: 42px; white-space: nowrap; }
.btn:hover { border-color: #CFC6B4; }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: #276B43; }
.btn.danger { color: var(--red); border-color: #E7C2BC; }
.btn.danger.solid { background: var(--red); color: #fff; border-color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: 14px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--green); font-weight: 600; text-decoration: underline; cursor: pointer; }
.iconbtn { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: var(--card); display: inline-grid; place-items: center; cursor: pointer; }
.iconbtn svg { width: 17px; height: 17px; }

/* forms */
label.f { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.input, select.input, textarea.input { font-size: 16px; width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 12px; min-height: 42px; outline: none; }
.input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(46,125,79,.15); }
.field { margin-bottom: 14px; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 6px 0; }
.check input { width: 20px; height: 20px; accent-color: var(--green); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 14px; cursor: pointer; font-weight: 500; min-height: 38px; display: inline-flex; align-items: center; gap: 6px; }
.chip.on { background: var(--green-soft); border-color: var(--green); color: var(--green-d); font-weight: 600; }
.chip.sm { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; padding: 8px 14px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--green-d); color: #fff; }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.t { width: 100%; border-collapse: collapse; font-size: 15px; }
table.t th { text-align: left; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 10px 8px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: #FAF8F3; }
.click { cursor: pointer; } .card.click:hover { border-color: var(--green, #2E7D4F); }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.t tr.dim td { color: var(--faint); }

/* badges & alerts */
.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 700; background: var(--grey-soft); color: var(--muted); white-space: nowrap; }
.badge.green { background: var(--green-soft); color: var(--green); } .badge.red { background: var(--red-soft); color: var(--red); }
.badge.amber { background: var(--amber-soft); color: var(--amber); } .badge.blue { background: var(--blue-soft); color: var(--blue); } .badge.purple { background: var(--purple-soft); color: var(--purple); }
.alert { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 12px; background: var(--grey-soft); margin-bottom: 10px; }
.alert .t { font-weight: 600; } .alert .d { font-size: 13px; color: var(--muted); margin-top: 2px; }
.alert.Danger { background: var(--red-soft); } .alert.Warning { background: var(--amber-soft); } .alert.Info { background: var(--grey-soft); }
.alert a, .alert .link { margin-left: auto; white-space: nowrap; font-size: 14px; }
.alert .x { background: none; border: 0; cursor: pointer; color: var(--faint); padding: 4px; }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty svg { width: 34px; height: 34px; opacity: .5; }

.tile { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fff; }
.tile b { display: block; }
.mini-list .tile { margin-bottom: 8px; }

/* tabs */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; touch-action: pan-x; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
.tabs > * { flex: none; }
.tabs button, .tabs a { border: 0; background: none; padding: 10px 14px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none; }
.tabs .on { color: var(--green-d); border-bottom-color: var(--green); }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(23, 45, 33, .45); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; overflow-y: auto; }
.modal { background: var(--bg); border-radius: 18px; width: 100%; max-width: 560px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px 6px; }
.modal-head h3 { margin: 0; font-size: 19px; flex: 1; }
.modal-body { padding: 10px 20px 20px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 0 20px 20px; flex-wrap: wrap; }

/* toasts */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 300; display: flex; flex-direction: column; gap: 8px; max-width: 360px; }
.toast { background: var(--green-d); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-weight: 500; animation: pop .2s ease-out; }
.toast.err { background: var(--red); }
.toast { display: flex; align-items: center; gap: 12px; } .toast-undo { margin-left: auto; background: #fff; color: var(--green-d); border: 0; border-radius: 8px; padding: 6px 12px; font-weight: 700; cursor: pointer; font: inherit; font-weight: 700; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal .dow { font-size: 12px; font-weight: 700; color: var(--muted); text-align: center; text-transform: uppercase; padding: 4px 0; }
.cal .day { background: #fff; border: 1px solid var(--line); border-radius: 10px; min-height: 96px; padding: 6px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; }
.cal .day.out { opacity: .45; } .cal .day.today { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); } .cal .day.sel { background: var(--green-soft); }
.cal .num { font-weight: 700; font-size: 13px; }
.cal .ev { font-size: 11px; border-radius: 5px; padding: 2px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; }
.cal.week .day { min-height: 150px; }
.k-Vaccine { background: var(--blue); } .k-FeedSwitch { background: var(--amber); } .k-Cleaning, .k-Sawdust, .k-Care { background: var(--purple); }
.k-Manual { background: #5C6B60; } .k-BatchEnd { background: var(--brown); } .k-Overdue { background: var(--red) !important; }
.ev.proj { opacity: .55; border: 1px dashed rgba(0,0,0,.25); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.task-item { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 12px 14px; display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.task-item .bar { width: 5px; align-self: stretch; border-radius: 4px; }

/* photos */
.photos { display: flex; gap: 10px; flex-wrap: wrap; }
.photo { width: 132px; height: 132px; border-radius: 12px; object-fit: cover; border: 1px solid var(--line); background: var(--grey-soft); cursor: zoom-in; }
.photo.lg { width: 100%; height: auto; max-height: 70vh; object-fit: contain; cursor: default; }
.daily { display: flex; gap: 4px; align-items: flex-end; height: 44px; }
.daily span { flex: 1; background: var(--red); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }

/* qr preview */
.label-preview { background: #fff; border: 2px solid var(--green-d); border-radius: 12px; padding: 18px; text-align: center; max-width: 320px; margin: 0 auto; }
.label-preview .code { font-size: 64px; font-weight: 800; color: var(--green-d); line-height: 1; }
.label-preview img.qr { width: 170px; height: 170px; }

/* wizard */
.steps { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.steps button { flex: 1; min-width: 110px; border: 0; border-top: 4px solid var(--line); background: none; text-align: left; padding: 8px 2px; font-weight: 600; color: var(--muted); cursor: pointer; }
.steps button.on { border-top-color: var(--green); color: var(--ink); }
.steps button.done { border-top-color: #9CC5AA; }
.rule { border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 12px 14px; margin-bottom: 8px; }
.rule.editing { border-color: var(--green); box-shadow: 0 0 0 3px rgba(46,125,79,.12); }
.rule .day { font-weight: 700; }

.swatch { width: 26px; height: 26px; border-radius: 7px; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; display: inline-block; }
.swatch.on { box-shadow: 0 0 0 2px var(--ink); }
.action-preview { border-radius: 14px; padding: 14px; color: #fff; display: grid; place-items: center; gap: 6px; font-weight: 700; min-height: 96px; width: 160px; }
.action-preview svg { width: 30px; height: 30px; }
.icon-pick { display: grid; grid-template-columns: repeat(auto-fill, 42px); gap: 6px; }
.icon-pick button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 9px; background: #fff; cursor: pointer; display: grid; place-items: center; }
.icon-pick button.on { border-color: var(--green); background: var(--green-soft); }
.icon-pick svg { width: 20px; height: 20px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 400px; padding: 30px; }
.login img { width: 130px; height: 130px; display: block; margin: 0 auto 10px; border-radius: 50%; }
.login img.wordmark { width: 230px; height: auto; border-radius: 0; margin-bottom: 4px; }

.progress { height: 8px; background: var(--grey-soft); border-radius: 6px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--green); }
.progress.warn span { background: var(--amber); } .progress.bad span { background: var(--red); }

/* ---- mobile: single column + bottom nav ---- */
@media (max-width: 900px) {
  .side { transform: translateX(-100%); transition: transform .2s; width: 280px; }
  .side.open { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.35); }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 15; }
  .main { margin-left: 0; padding: 0 16px 96px; }
  .topbar { display: flex; align-items: center; gap: 12px; padding: 14px 0 10px; position: sticky; top: 0; background: var(--bg); z-index: 10; }
  .topbar img { width: 42px; height: 42px; border-radius: 10px; background: #fff; }
  .topbar b { display: block; font-size: 16px; } .topbar span { font-size: 13px; color: var(--muted); }
  .bottomnav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); z-index: 12; padding-bottom: env(safe-area-inset-bottom); }
  .bottomnav a { flex: 1; text-align: center; padding: 8px 0 10px; font-size: 12px; color: var(--muted); text-decoration: none; font-weight: 600; }
  .bottomnav a svg { width: 22px; height: 22px; display: block; margin: 0 auto 3px; }
  .bottomnav a.active { color: var(--green); }
  h1 { font-size: 24px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .g4.kpis { grid-template-columns: 1fr 1fr; }
  /* Rows of headline figures sit two to a line on a phone, and a card inside a grid never gets the stacked-card gap. */
  .grid.g4:has(> .kpi), .grid.g3:has(> .kpi) { grid-template-columns: 1fr 1fr; gap: 10px; }
  .grid.g4 > .stat, .grid.g4:has(> .stat) { grid-template-columns: 1fr 1fr; }
  .kpi .value { overflow-wrap: anywhere; }
  /* A card heading with a control beside it: the words keep a full line and the control wraps underneath. */
  .row.wrap > div.grow { flex: 1 1 100%; }
  .seg { max-width: 100%; }
  .seg button { padding: 8px 12px; }
  /* A payment line: who and when on the first line, the amount and buttons after it. */
  .pay-row { flex-wrap: wrap; }
  .pay-row > .grow { flex: 1 1 60%; }
  .plans { grid-template-columns: 1fr; }
  .tabs { overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { flex: none; }
  /* Fields that are easy to hit with a thumb, and no zoom-in when one is tapped on an iPhone. */
  .input, select.input, textarea.input { font-size: 16px; min-height: 44px; }
  .btn { min-height: 44px; }
  .btn.sm { min-height: 38px; }
  .iconbtn { min-width: 40px; min-height: 40px; }
  .modal .footer, .modal-foot { flex-wrap: wrap; gap: 8px; }
  .kpi .value { font-size: 26px; }
  .card { padding: 14px; }
  .page-head .btn { min-height: 38px; padding: 8px 12px; }
  /* Title gets its own line (next to the back button); buttons and toggles wrap underneath. */
  .page-head { gap: 10px; margin-bottom: 16px; }
  .page-head > .grow { flex: 1 1 calc(100% - 60px); }
  .page-head > .grow .muted { font-size: 14px; }
  .row.wrap > .input, .row.wrap > select.input { flex: 1 1 140px; max-width: none !important; }
  .row.wrap > input[type=date].input { flex: 1 1 140px; }
  .chips { gap: 6px; }
  .legend { flex: 1 1 100% !important; gap: 8px 14px; }
  .modal-body .grid.g2, .modal-body .grid.g3 { grid-template-columns: 1fr; }
  .stat .value { font-size: 17px; }
  .toasts { left: 16px; right: 16px; bottom: 84px; max-width: none; }
  .hide-m { display: none !important; }
  .cal .day { min-height: 58px; } .cal .ev { font-size: 0; height: 6px; padding: 0; }
  .cal.week { grid-template-columns: 1fr; } .cal.week .dow { display: none; } .cal.week .day { min-height: 0; } .cal.week .ev { font-size: 12px; height: auto; padding: 3px 6px; }
  table.t { font-size: 14px; }
  /* No sideways scrolling on phones: each table row becomes a card, every value labelled with its column
     heading (labels are copied from the header by js/admin.js). */
  .table-wrap { overflow: visible; margin: 0; }
  table.t, table.t tbody, table.t tr, table.t td { display: block; width: 100%; }
  table.t thead { display: none; }
  table.t tr { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-bottom: 8px; background: #fff; }
  table.t tr.click:hover td { background: none; }
  table.t td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 5px 0; border: 0; text-align: right; white-space: normal; overflow-wrap: anywhere; min-width: 0; }
  table.t td[data-label]::before { content: attr(data-label); font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); text-align: left; flex: none; max-width: 45%; }
  table.t td[data-label=""]::before { display: none; }
  table.t td:empty { display: none; }
  table.t td.num { text-align: right; }
  table.t td > .input { max-width: 60%; }
  table.t td.right, table.t td:last-child:not([data-label]) { justify-content: flex-end; }
  .card > table.t tr, .card .table-wrap table.t tr { box-shadow: none; }
  .modal-back { padding: 0; align-items: flex-end; }
  .modal { border-radius: 18px 18px 0 0; max-height: 92vh; overflow-y: auto; }
}
@media (min-width: 901px) { .show-m { display: none !important; } }
@media print {
  .side, .bottomnav, .topbar, .page-head .btn, .no-print { display: none !important; }
  .main { margin: 0; padding: 0; }
  body { background: #fff; }
}

.ct-driver div { width: 34px; height: 34px; border-radius: 50%; background: #2F6DB5; color: #fff; display: grid; place-items: center; font-weight: 800; border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.map { height: 420px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); z-index: 0; }
.roster { border-collapse: collapse; font-size: 13px; width: 100%; }
.roster th.name, .roster td.name { width: 1%; white-space: nowrap; }
.roster th, .roster td { border: 1px solid var(--line); padding: 0; text-align: center; min-width: 30px; height: 34px; }
.roster th.name, .roster td.name { text-align: left; padding: 0 10px; min-width: 130px; position: sticky; left: 0; background: #fff; z-index: 1; }
.roster td.on { background: #EEF6F0; }
.roster td.off { background: #E9E6DF; color: var(--muted); }
.roster td.leave { background: #DCE8F7; color: #2F6DB5; font-weight: 700; }
.roster td.sick { background: #F7DEDA; color: #B83A2E; font-weight: 700; }
.roster td.training { background: #F5EBD3; color: #8A6516; font-weight: 700; }
.roster th.we { background: #F4F1EA; }
.roster td button { width: 100%; height: 100%; border: 0; background: none; cursor: pointer; font: inherit; color: inherit; }

/* ---- Tracker logbook map ---- */
.bookmap { height: 420px; border-radius: 12px; border: 1px solid var(--line); z-index: 0; }
.ct-pin div { width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); display: grid; place-items: center; }
.ct-pin span { transform: rotate(45deg); color: #fff; font-size: 11px; line-height: 1; }
table.t tr.pick { cursor: pointer; } table.t tr.pick:hover td { background: var(--bg); }
table.t tr.sel td { background: var(--blue-soft); }
@media (max-width: 900px) { .bookmap { height: 320px; } }

/* ---- Insights: charts ---- */
:root { --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a; --c4: #eda100; --good: #0ca30c; --warn: #fab219; --serious: #ec835a; --crit: #d03b3b; }
.ins-range { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ins-grid { display: grid; gap: 16px; grid-template-columns: repeat(12, minmax(0, 1fr)); margin-top: 16px; }
.ins-grid > .s4 { grid-column: span 4; } .ins-grid > .s5 { grid-column: span 5; } .ins-grid > .s6 { grid-column: span 6; }
.ins-grid > .s7 { grid-column: span 7; } .ins-grid > .s8 { grid-column: span 8; } .ins-grid > .s12 { grid-column: span 12; }
.ins-card { animation: ins-rise .5s cubic-bezier(.2,.7,.2,1) both; animation-delay: calc(var(--n, 0) * 60ms); }
.ins-card h3 { margin: 0; font-size: 16px; } .ins-card .ins-sub { color: var(--muted); font-size: 13px; margin: 2px 0 12px; }
.ins-section { margin: 30px 0 0; font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.ins-kpis { display: grid; gap: 14px; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.ins-kpi { padding: 16px 18px; animation: ins-rise .5s cubic-bezier(.2,.7,.2,1) both; animation-delay: calc(var(--n, 0) * 50ms); }
.ins-kpi .label { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ins-kpi .value { font-size: 28px; font-weight: 800; line-height: 1.15; margin-top: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ins-kpi .sub { font-size: 13px; color: var(--muted); margin-top: 4px; }
.ins-delta { display: inline-flex; align-items: center; gap: 3px; margin-top: 8px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--grey-soft); color: var(--muted); }
.ins-delta.good { background: var(--green-soft); color: var(--green); } .ins-delta.bad { background: var(--red-soft); color: var(--red); }
.ins-meter { height: 8px; border-radius: 4px; background: var(--bg); overflow: hidden; min-width: 70px; display: flex; gap: 2px; }
.ins-meter i { display: block; height: 100%; border-radius: 4px; transform-origin: left; animation: ins-grow-x .8s cubic-bezier(.2,.7,.2,1) both; }
.ins-split { display: flex; height: 14px; gap: 2px; border-radius: 4px; overflow: hidden; margin: 6px 0 8px; background: var(--bg); }
.ins-split i { display: block; height: 100%; border-radius: 4px; transform-origin: left; animation: ins-grow-x .8s cubic-bezier(.2,.7,.2,1) both; }
.ins-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; margin-bottom: 14px; }
.ins-facts div b { display: block; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; } .ins-facts div span { font-size: 12px; color: var(--muted); }
.ins-note { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; padding: 8px 0; border-top: 1px solid var(--line); }
.ins-note:first-of-type { border-top: 0; }
.ins-note .dot { flex: none; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 800; margin-top: 1px; }

.ch-top { display: flex; align-items: center; gap: 12px; min-height: 26px; margin-bottom: 8px; }
.ch-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; flex: 1; font-size: 13px; color: var(--muted); }
.ch-key { display: inline-flex; align-items: center; gap: 6px; }
.ch-key i { display: inline-block; width: 12px; }
.ch-key i.box { height: 12px; border-radius: 3px; background: var(--c); }
.ch-key i.line { height: 0; border-top: 3px solid var(--c); border-radius: 2px; width: 16px; }
.ch-key i.dash { height: 0; border-top: 2px dashed var(--c); width: 16px; }
.ch-switch { margin-left: auto; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 3px 10px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; }
.ch-switch:hover { color: var(--ink); border-color: var(--faint); }
.ch-frame { position: relative; margin-left: 40px; }
.ch-grid { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid #ECE7DC; }
.ch-grid.base { border-top-color: #CFC8B8; }
.ch-grid span { position: absolute; right: calc(100% + 8px); top: -8px; font-size: 11px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ch-plot { position: absolute; inset: 0; }
.ch-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; animation: ins-wipe 1.1s cubic-bezier(.3,.7,.2,1) both; }
.ch-bars { position: absolute; inset: 0; display: flex; align-items: flex-end; }
.ch-col { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; padding: 0 1px; min-width: 0;
  transform-origin: bottom; animation: ins-grow-y .7s cubic-bezier(.2,.7,.2,1) both; animation-delay: calc(var(--i) * 12ms); }
.ch-col.stack { flex-direction: column-reverse; align-items: center; justify-content: flex-start; }
.ch-bar { flex: 1 1 0; max-width: 24px; min-width: 2px; border-radius: 4px 4px 0 0; }
.ch-col.stack .ch-bar { flex: none; width: 100%; max-width: 24px; border-radius: 0; }
.ch-col.stack .ch-bar:last-child { border-radius: 4px 4px 0 0; }
.ch-col.on .ch-bar { filter: brightness(.88); }
.ch-hit { position: absolute; inset: 0; display: flex; } .ch-hit div { flex: 1; }
.ch-cross { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px solid var(--faint); pointer-events: none; }
.ch-dot { position: absolute; width: 10px; height: 10px; margin: 0 0 -5px -5px; border-radius: 50%; border: 2px solid #fff; pointer-events: none; }
.ch-tip { position: absolute; top: 4px; transform: translateX(12px); background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 12px;
  box-shadow: 0 6px 20px rgba(30,42,34,.14); pointer-events: none; z-index: 3; white-space: nowrap; color: var(--ink); }
.ch-tip.left { transform: translateX(calc(-100% - 12px)); }
.ch-tip b { display: block; margin-bottom: 4px; }
.ch-tip div { display: flex; align-items: center; gap: 6px; line-height: 1.6; } .ch-tip i { width: 8px; height: 8px; border-radius: 2px; } .ch-tip span { color: var(--muted); }
.ch-tip em { font-style: normal; font-weight: 700; margin-left: auto; padding-left: 14px; font-variant-numeric: tabular-nums; }
.ch-x { position: relative; height: 20px; margin: 6px 0 0 40px; }
.ch-x span { position: absolute; transform: translateX(-50%); font-size: 11px; color: var(--muted); white-space: nowrap; }
.ch-empty { display: grid; place-items: center; color: var(--faint); font-size: 14px; border: 1px dashed var(--line); border-radius: 10px; text-align: center; padding: 0 12px; }
.ch-table { max-height: 260px; overflow-y: auto; }
.hb { display: grid; gap: 10px; }
.hb-row { display: grid; grid-template-columns: minmax(70px, 34%) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.hb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-track { height: 14px; }
.hb-bar { height: 100%; border-radius: 0 4px 4px 0; transform-origin: left; animation: ins-grow-x .8s cubic-bezier(.2,.7,.2,1) both; animation-delay: calc(var(--i) * 50ms); }
.hb-val { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; } .hb-val span { font-weight: 500; color: var(--muted); margin-left: 6px; }
.spark { width: 90px; height: 24px; display: block; }
@keyframes ins-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes ins-grow-y { from { transform: scaleY(0); } to { transform: none; } }
@keyframes ins-grow-x { from { transform: scaleX(0); } to { transform: none; } }
@keyframes ins-wipe { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 -2% 0 0); } }
@media (max-width: 1300px) { .ins-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .ins-grid > * { grid-column: span 12 !important; }
  .ins-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .ins-kpi { padding: 12px 14px; } .ins-kpi .value { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) { .ins-card, .ins-kpi, .ch-svg, .ch-col, .hb-bar, .ins-meter i, .ins-split i { animation: none !important; } }
.ins-kpis > .card, .ins-grid > .card { margin: 0; }

/* ---- Buying & selling ---- */
table.trade-lines td { vertical-align: top; } table.trade-lines tfoot td { border-bottom: 0; padding-top: 12px; }
table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: var(--bg); }
.sheet { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 40px 44px; max-width: 820px; margin: 0 auto; color: #1a1a1a; }
.sheet-top { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; }
.sheet-top img { max-height: 70px; max-width: 200px; display: block; margin-bottom: 8px; }
.sheet-farm { font-size: 18px; font-weight: 800; }
.sheet-title { text-align: right; } .sheet-title h2 { margin: 0 0 8px; font-size: 24px; letter-spacing: .06em; }
.sheet-title table { margin-left: auto; font-size: 14px; } .sheet-title td { padding: 2px 0 2px 16px; text-align: right; } .sheet-title td:first-child { color: #666; }
.sheet .label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #666; margin-bottom: 4px; }
.sheet-party { margin: 30px 0 24px; font-size: 14px; line-height: 1.5; }
.sheet-lines { width: 100%; border-collapse: collapse; font-size: 14px; }
.sheet-lines th { text-align: left; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: #666; border-bottom: 2px solid #1a1a1a; padding: 8px 6px; }
.sheet-lines td { padding: 10px 6px; border-bottom: 1px solid #ddd; } .sheet-lines .num { text-align: right; white-space: nowrap; }
.sheet-lines tfoot td { border-bottom: 0; border-top: 2px solid #1a1a1a; font-weight: 800; font-size: 16px; }
.sheet-notes { margin-top: 24px; font-size: 14px; } .sheet-foot { margin-top: 40px; font-size: 13px; color: #666; text-align: center; }
@media print { .sheet { border: 0; padding: 0; max-width: none; } }
.sheet-lines tfoot tr.pay td { border-top: 0; font-weight: 400; font-size: 14px; padding-top: 2px; padding-bottom: 2px; }
.sheet-lines tfoot tr + tr:not(.pay) td { border-top: 1px solid #1a1a1a; }
.sheet-sign { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; margin-top: 70px; font-size: 12px; color: #666; }
.sheet-sign span { display: block; border-bottom: 1px solid #1a1a1a; height: 34px; margin-bottom: 6px; }
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0 4px; }
.plan { display: grid; gap: 2px; text-align: left; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff; cursor: pointer; font: inherit; color: inherit; }
.plan .amt { font-size: 22px; font-weight: 800; } .plan.on { border: 2px solid var(--green); background: var(--green-soft); padding: 11px 13px; }

/* ---- Help & manual ---- */
.help-sec { margin-bottom: 14px; scroll-margin-top: 16px; }
.help-topic { border-top: 1px solid var(--line); padding: 10px 0 2px; }
.help-topic summary { cursor: pointer; font-weight: 700; list-style-position: outside; }
.help-topic ol { margin: 8px 0 8px; padding-left: 22px; } .help-topic li { margin: 4px 0; line-height: 1.45; }
.help-note { margin: 0 0 8px 22px; }
@media print { .help-topic { break-inside: avoid; } .help-topic:not([open]) > *:not(summary) { display: block; } details.help-topic > ol, details.help-topic > .help-note { display: block !important; } }
table.pnl tr.head td { font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); padding-top: 14px; border-bottom: 0; }
table.pnl tr.sum td { font-weight: 700; border-top: 1px solid var(--ink); }
table.pnl tr.net td { font-weight: 800; font-size: 16px; border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); }
.phase-row { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 10px; }
.phase-n { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--green-d); color: #fff; display: grid; place-items: center; font-weight: 800; margin-top: 22px; }
.phase-grid { display: grid; grid-template-columns: minmax(140px, 1fr) auto; gap: 12px 16px; align-items: end; }
.phase-grid > div:nth-child(3) { grid-column: 1 / -1; }
.phase-grid label.f { margin-bottom: 4px; display: block; }
@media (max-width: 900px) { .phase-grid { grid-template-columns: 1fr; } .phase-n { margin-top: 0; } }

/* Sign-in: "or use your password" between the fingerprint button and the form */
.login-or { display: flex; align-items: center; gap: 10px; margin: 16px 0 6px; color: var(--muted); font-size: 13px; }
.login-or::before, .login-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.login .check { display: flex; align-items: center; gap: 8px; margin-top: 8px; }

/* Stock take: find, count, review */
.take-bar { margin-top: 6px; }
.take-progress { height: 8px; border-radius: 8px; background: var(--line-2); overflow: hidden; margin-bottom: 6px; }
.take-progress > div { height: 100%; background: var(--green); border-radius: 8px; transition: width .25s; }
.take-find { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.take-find > svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.take-find .input { flex: 1; }
.take-group { display: flex; align-items: center; gap: 10px; margin-top: 18px; padding: 8px 0; border-bottom: 2px solid var(--line); position: sticky; top: 0; background: var(--card); z-index: 2; }
.take-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(150px, auto); gap: 6px 14px; align-items: center; padding: 10px 8px; border-bottom: 1px solid var(--line-2); border-left: 3px solid transparent; }
.take-row.done { border-left-color: var(--green); background: #F6FAF6; }
.take-row.diff { border-left-color: var(--amber); background: #FFFaf0; }
.take-count { display: flex; align-items: center; gap: 6px; }
.take-count .input { width: 86px; text-align: center; font-weight: 700; font-size: 16px; }
.take-count .btn { min-width: 40px; justify-content: center; }
.take-var { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.take-why { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.take-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; position: sticky; bottom: 0; background: var(--card); border-top: 1px solid var(--line); margin: 16px -4px 0; padding: 12px 4px 4px; z-index: 3; }
@media (max-width: 900px) {
  .take-row { grid-template-columns: 1fr; }
  .take-var { justify-content: flex-start; }
  .take-count .input { flex: 1; width: auto; }
  .take-foot { bottom: 64px; }
  .take-foot .btn.primary { flex: 1 1 100%; justify-content: center; }
}

/* Banking */
.bank-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.bank-card { text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; cursor: pointer; font: inherit; color: inherit; }
.bank-card.on { border-color: var(--green); box-shadow: 0 0 0 2px var(--green-soft); }
.bank-card .label { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.bank-card .value { font-size: 22px; font-weight: 800; margin-top: 4px; }
.bank-card .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.bank-card.add { display: flex; align-items: center; justify-content: center; gap: 8px; border-style: dashed; color: var(--muted); font-weight: 600; }
.bank-card.add svg { width: 18px; height: 18px; }
.bank-bulk { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; padding: 10px 12px; background: var(--green-soft); border-radius: 12px; position: sticky; top: 0; z-index: 3; }
.bank-t tr.todo td { background: #FFFaf0; }
.bank-t input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--green); }
.alloc { border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 5px 10px; font: inherit; font-size: 13px; cursor: pointer; text-align: left; max-width: 260px; }
.alloc.none { border-style: dashed; color: var(--amber); font-weight: 600; }

/* Filter bar above a list */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
