/* ── OXARROW theme tokens. Light is default; dark follows the OS unless the user picks a theme. ── */
:root {
  --bg: #f3f5f7; --card: #ffffff; --ink: #152534; --muted: #5b6876; --line: #dde3ea; --soft: #edf1f5;
  --brand: #1d3a55; --brand2: #b45f06; --accent: #e08a0b; --top: #152534; --on-brand: #ffffff;
  --good: #157a3c; --good-bg: #e2f4e8; --warn: #8a5a00; --warn-bg: #fdf1d8; --bad: #b3261e; --bad-bg: #fbe4e2;
  /* charts (validated: dataviz six checks, light surface #ffffff) */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --track: #e3e8ee; --grid: #e8edf2; --axis: #8a97a5;
  --st-good: #0ca30c; --st-warn: #fab219; --st-serious: #ec835a; --st-crit: #d03b3b;
  --r: 12px; --sh: 0 1px 2px rgba(15,30,45,.06), 0 4px 14px rgba(15,30,45,.05);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", Tahoma, sans-serif;
  font-size: 15px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    --bg: #0d141b; --card: #16202b; --ink: #e8edf2; --muted: #a2adb9; --line: #26313d; --soft: #1c2733;
    --brand: #2f5a82; --brand2: #f0a43a; --accent: #ef9a2a; --top: #0f1d2a; --on-brand: #ffffff;
    --good: #7fd19a; --good-bg: #1b3a2a; --warn: #f0c060; --warn-bg: #3a2f14; --bad: #ff8a80; --bad-bg: #40202a;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --track: #26313d; --grid: #212c38; --axis: #8d9aa8;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d141b; --card: #16202b; --ink: #e8edf2; --muted: #a2adb9; --line: #26313d; --soft: #1c2733;
  --brand: #2f5a82; --brand2: #f0a43a; --accent: #ef9a2a; --top: #0f1d2a; --on-brand: #ffffff;
  --good: #7fd19a; --good-bg: #1b3a2a; --warn: #f0c060; --warn-bg: #3a2f14; --bad: #ff8a80; --bad-bg: #40202a;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --track: #26313d; --grid: #212c38; --axis: #8d9aa8;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
a { color: var(--brand2); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: .2rem 0 1rem; } h2 { font-size: 1.1rem; margin: 0 0 .7rem; } h3 { font-size: .95rem; margin: .6rem 0 .4rem; color: var(--muted); }
small, .small { font-size: .82rem; } .muted { color: var(--muted); } .center { text-align: center; } .mono { font-family: ui-monospace, monospace; font-size: .85rem; }
.mt { margin-top: .8rem; } .err-t { color: var(--bad); } .warn-t { color: var(--warn); font-weight: 600; }
.row { display: flex; align-items: center; } .between { justify-content: space-between; } .end { justify-content: flex-end; } .gap { gap: .5rem; } .wrap { flex-wrap: wrap; } .stack > * + * { margin-top: .6rem; }

/* Layout */
.top { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  background: var(--top); color: #fff; padding: .55rem 1rem; padding-top: max(.55rem, env(safe-area-inset-top)); }
.top .link { color: #fff; } .brand { font-weight: 700; display: flex; gap: .4rem; align-items: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand.big { flex-direction: column; justify-content: center; margin-bottom: 1.4rem; color: var(--ink); gap: .2rem; }
.brand.big small { color: var(--brand2); font-size: .95rem; font-weight: 600; text-align: center; }
.logo { display: inline-flex; color: var(--accent); } .logo .leaf { width: 40px; height: 40px; } .logo.sm .leaf { width: 22px; height: 22px; }
.brand.big .logo { color: var(--brand2); }
.top .brand .wm { letter-spacing: .08em; } .top .brand .farm { font-weight: 500; opacity: .8; font-size: .9rem; border-inline-start: 1px solid rgba(255,255,255,.3); padding-inline-start: .55rem; margin-inline-start: .15rem; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 520px) { .top .brand .farm { max-width: 34vw; } }
.net { font-size: .75rem; padding: .15rem .5rem; border-radius: 99px; } .net.on { background: rgba(255,255,255,.18); } .net.off { background: var(--accent); color: #000; font-weight: 700; }
.side { position: fixed; top: 48px; bottom: 0; inset-inline-start: 0; width: 210px; background: var(--card); border-inline-end: 1px solid var(--line); padding: .6rem; overflow-y: auto; }
.side a { display: flex; gap: .6rem; align-items: center; padding: .55rem .7rem; border-radius: 8px; color: var(--ink); }
.side a i { font-style: normal; width: 1.3rem; text-align: center; } .side a.on { background: var(--brand); color: #fff; } .side a:hover { text-decoration: none; background: var(--bg); } .side a.on:hover { background: var(--brand); }
main { margin-inline-start: 210px; padding: 1.2rem; max-width: 1400px; }
.banner { padding: .5rem 1rem; text-align: center; } .banner.err { background: var(--bad-bg); color: var(--bad); font-weight: 600; } .banner.warn { background: var(--warn-bg); color: var(--warn); font-weight: 600; }
@media (max-width: 860px) {
  .side { top: auto; bottom: 0; width: 100%; height: auto; display: flex; overflow-x: auto; padding: .25rem; border-top: 1px solid var(--line); border-inline-end: 0; z-index: 20; padding-bottom: max(.25rem, env(safe-area-inset-bottom)); }
  .side a { flex-direction: column; gap: 2px; font-size: .68rem; min-width: 68px; padding: .35rem .3rem; text-align: center; }
  .side a i { font-size: 1.15rem; } main { margin: 0; padding: .8rem .8rem 6rem; }
}

/* Cards, KPIs */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem; margin-bottom: 1rem; box-shadow: var(--sh); }
.card.soft { background: var(--bg); box-shadow: none; } .card.narrow { max-width: 400px; width: 100%; } .card.err { color: var(--bad); }
.bare { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .7rem; margin-bottom: 1rem; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: .75rem .9rem; border-inline-start: 4px solid var(--brand2); }
.kpi b { display: block; font-size: 1.45rem; font-variant-numeric: tabular-nums; letter-spacing: -.01em; } .kpi span { color: var(--muted); font-size: .8rem; }
.kpi.good { border-inline-start-color: var(--good); } .kpi.warn { border-inline-start-color: var(--warn); } .kpi.bad { border-inline-start-color: var(--bad); } .kpi.bad b { color: var(--bad); }
.alert { padding: .5rem .75rem; border-radius: 8px; margin: .3rem 0; background: var(--bg); } .alert:empty { display: none; } .alert.warn { background: var(--warn-bg); color: var(--warn); } .alert.bad { background: var(--bad-bg); color: var(--bad); }
.grid4.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; } .facts span { display: block; color: var(--muted); font-size: .78rem; }
.empty { padding: 1.2rem; text-align: center; color: var(--muted); }
.steps li { margin: .35rem 0; }

/* Tables */
.tbl { overflow-x: auto; } table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: .5rem .55rem; border-bottom: 1px solid var(--line); text-align: start; white-space: nowrap; vertical-align: top; }
th { font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .02em; background: var(--card); }
tr.inactive td { opacity: .45; } tr.row-bad td { background: var(--bad-bg); } td.actions { text-align: end; white-space: normal; min-width: 150px; } td.actions .btn { margin: 2px 0; } td.lv { text-align: center; font-weight: 600; }
table.mini { font-size: .9rem; } table.mini td, table.mini th { padding: .3rem .5rem; } tr.tot td { font-weight: 700; border-top: 2px solid var(--ink); }
table.feed input, table.feed select { width: 90px; padding: .35rem; }
.timeline { list-style: none; padding: 0; margin: 0; } .timeline li { padding: .45rem 0; border-bottom: 1px dashed var(--line); } .timeline time { font-family: ui-monospace, monospace; color: var(--muted); margin-inline-end: .4rem; }
.timeline li.voided { text-decoration: line-through; opacity: .6; }

/* Pills */
.pill { display: inline-block; font-size: .74rem; padding: .1rem .5rem; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); white-space: nowrap; }
.pill.active, .pill.risk-low { background: var(--good-bg); color: var(--good); border-color: transparent; }
.pill.hospital, .pill.warn, .pill.risk-medium { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.pill.dead, .pill.culled, .pill.risk-high { background: var(--bad-bg); color: var(--bad); border-color: transparent; } .pill.sold { background: #e3ecfb; color: #1f4f9a; border-color: transparent; }

/* Forms */
input, select, textarea { font: inherit; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .55rem .65rem; width: 100%; min-height: 42px; }
input[type=checkbox] { width: auto; min-height: 0; accent-color: var(--brand); } textarea { min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand2); outline-offset: -1px; }
.fld { display: flex; flex-direction: column; gap: .25rem; } .fld > span, .lbl { font-size: .8rem; color: var(--muted); font-weight: 600; }
.grid2, .grid3 { display: grid; gap: .75rem; } .grid2 { grid-template-columns: repeat(2, 1fr); } .grid3 { grid-template-columns: repeat(3, 1fr); }
.span2 { grid-column: span 2; } .span3 { grid-column: 1 / -1; } .grid2 h3, .grid3 h3 { grid-column: 1 / -1; margin-bottom: 0; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } .span2 { grid-column: auto; } }
.filters { padding: .7rem; } .filters input, .filters select { width: auto; min-width: 160px; flex: 1; }
.checks { display: flex; flex-wrap: wrap; gap: .3rem .9rem; } .checks label, label.chk { display: flex; gap: .35rem; align-items: center; cursor: pointer; }
.perm { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .5rem; } .perm label span { font-size: .8rem; color: var(--muted); display: block; }
.prods { display: flex; flex-direction: column; gap: .35rem; } .prod { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .4rem .6rem; background: var(--bg); border-radius: 8px; }
.prod input.ml { width: 80px; min-height: 34px; padding: .3rem; }
.or { text-align: center; color: var(--muted); margin: .8rem 0; }
.blocked { font-size: 3rem; text-align: center; }
.sortg { padding: .4rem 0; border-bottom: 1px solid var(--line); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; background: var(--brand); color: var(--on-brand); border: 0; border-radius: 8px; padding: .6rem 1rem; font: inherit; font-weight: 600; cursor: pointer; min-height: 42px; white-space: nowrap; }
.btn:hover { background: var(--brand2); text-decoration: none; } .btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--brand2); border: 1px solid var(--line); } .btn.danger { background: var(--bad); }
.btn.sm { padding: .35rem .7rem; min-height: 32px; font-size: .85rem; } .btn.big { padding: .85rem 1.6rem; font-size: 1.05rem; } .btn.wide { width: 100%; }
.btn.google { background: #fff; color: #333; border: 1px solid #ccc; }
.link { background: none; border: 0; color: var(--brand2); cursor: pointer; font: inherit; padding: 0; }
.tabs { display: flex; gap: .3rem; overflow-x: auto; margin-bottom: 1rem; border-bottom: 1px solid var(--line); }
.tabs a { padding: .55rem .9rem; border-bottom: 3px solid transparent; color: var(--muted); white-space: nowrap; } .tabs a.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 700; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; } .switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; background: #c9c9c9; border-radius: 99px; transition: .2s; cursor: pointer; }
.switch i::before { content: ""; position: absolute; width: 20px; height: 20px; inset-inline-start: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + i { background: var(--good); } .switch input:checked + i::before { transform: translateX(20px); }
[dir=rtl] .switch input:checked + i::before { transform: translateX(-20px); }

/* Histogram */
.hist { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding-top: 1rem; }
.hist > div { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; position: relative; }
.hist i { display: block; width: 100%; background: var(--brand2); border-radius: 4px 4px 0 0; min-height: 2px; }
.hist span { font-size: .7rem; color: var(--muted); } .hist small { position: absolute; top: -2px; font-size: .7rem; }

/* Modal & toast */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 4vh 1rem; overflow-y: auto; }
.modal { background: var(--card); border-radius: 14px; padding: 1.3rem; width: 100%; max-width: 760px; position: relative; }
.modal .x { position: absolute; top: .5rem; inset-inline-end: .7rem; background: none; border: 0; font-size: 1.6rem; cursor: pointer; color: var(--muted); }
.toasts { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); z-index: 99; display: flex; flex-direction: column; gap: .4rem; align-items: center; pointer-events: none; }
.toast { background: #222; color: #fff; padding: .7rem 1.1rem; border-radius: 10px; max-width: 90vw; box-shadow: var(--sh); }
.toast.err { background: var(--bad); } .loading { padding: 2rem; text-align: center; color: var(--muted); }
th.rot { font-size: .68rem; }

@media print {
  .side, .top, .noprint, .btn, .banner, .tabs { display: none !important; } main { margin: 0; padding: 0; } .card { box-shadow: none; border: 0; }
  body { background: #fff; }
}

/* Phone layout: tables marked .cards become one card per row, with full-width action buttons. */
@media (max-width: 820px) {
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr { border: 1px solid var(--line); border-radius: var(--r); padding: .6rem .75rem; margin-bottom: .7rem; background: var(--card); }
  table.cards td { border: 0; padding: .25rem 0; white-space: normal; text-align: start; }
  table.cards td[data-l]::before { content: attr(data-l); display: block; font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
  table.cards td.actions { display: flex; gap: .5rem; padding-top: .6rem; min-width: 0; }
  table.cards td.actions .btn { flex: 1; min-height: 42px; }
  table.cards .hide-m { display: none; }
  table.cards td.empty { text-align: center; }
}
@media (min-width: 821px) { .show-m { display: none; } }

/* Help centre */
.help-btn { display: inline-flex; align-items: center; gap: .25rem; background: rgba(255,255,255,.15); padding: .2rem .6rem; border-radius: 99px; text-decoration: none !important; }
@media (max-width: 520px) { .help-btn span { display: none; } }
details.faq { border-bottom: 1px solid var(--line); padding: .55rem 0; }
details.faq summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; gap: .5rem; }
details.faq summary::before { content: '＋'; color: var(--brand2); } details.faq[open] summary::before { content: '－'; }
details.faq p { margin: .5rem 0 .2rem; line-height: 1.55; color: var(--ink); }
/* Guided tour */
.tour { position: fixed; inset: 0; z-index: 90; }
.tour-hole { position: fixed; border-radius: 10px; box-shadow: 0 0 0 9999px rgba(0,0,0,.6); outline: 3px solid var(--accent); transition: all .25s ease; pointer-events: none; }
.tour-card { position: fixed; background: var(--card); color: var(--ink); border-radius: 14px; padding: 1rem 1.1rem; box-shadow: 0 10px 30px rgba(0,0,0,.35); transition: top .25s, left .25s; }
.tour-card h3 { color: var(--brand); margin: .1rem 0 .4rem; font-size: 1.05rem; } .tour-card p { margin: 0 0 .9rem; line-height: 1.5; }
.tour-n { font-size: .75rem; color: var(--muted); }

/* Footer & disclaimer */
.foot { margin: 2rem 0 .5rem; padding-top: .8rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .78rem; }
.disc-mini { font-size: .78rem; color: var(--muted); margin: 1rem 0 0; } ol.disc li { margin: .55rem 0; line-height: 1.55; }
/* KPI tiles as links */
a.kpi { color: inherit; text-decoration: none !important; transition: transform .12s, box-shadow .12s; } a.kpi:hover { transform: translateY(-1px); box-shadow: var(--sh); }
.alert .ai { font-style: normal; font-weight: 800; display: inline-block; width: 1.1rem; text-align: center; }
/* Gauges */
.gauges { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .8rem; }
.gauge { margin: 0; background: var(--soft); border-radius: var(--r); padding: .6rem .6rem .7rem; text-align: center; cursor: default; }
.gauge svg { width: 100%; max-width: 190px; display: block; margin: 0 auto; }
.gauge .g-val { font-size: 24px; font-weight: 700; fill: var(--ink); font-variant-numeric: tabular-nums; } .gauge .g-unit { font-size: 11px; fill: var(--muted); }
.gauge figcaption { display: flex; flex-direction: column; gap: .15rem; font-size: .85rem; } .gauge figcaption small { color: var(--muted); }
.g-st { font-size: .78rem; font-weight: 600; } .g-st i { font-style: normal; display: inline-grid; place-items: center; width: 1.1rem; height: 1.1rem; border-radius: 50%; color: #fff; font-size: .7rem; margin-inline-end: .2rem; }
.g-good { color: var(--good); } .g-good i { background: var(--st-good); } .g-warn { color: var(--warn); } .g-warn i { background: var(--st-warn); color: #1b1c33; }
.g-bad { color: var(--bad); } .g-bad i { background: var(--st-crit); } .g-none { color: var(--muted); } .g-none i { background: var(--axis); }
/* Charts */
.viz-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 430px), 1fr)); gap: 0 1rem; }
.viz svg { width: 100%; height: auto; display: block; overflow: visible; --k: 1; } .viz .ax { font-size: calc(11px * var(--k)); fill: var(--muted); } .viz .dl { font-size: calc(11px * var(--k)); fill: var(--ink); font-weight: 600; }
.viz-wide svg { max-height: 300px; }
.viz [data-tip] { cursor: pointer; outline: none; } .viz g[data-tip]:hover path, .viz g[data-tip]:focus path { opacity: .82; }
.legend { display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-size: .8rem; color: var(--muted); margin: .2rem 0 .5rem; }
.legend i, .viz-tip i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: .35rem; vertical-align: -1px; }
.viz-tip { position: fixed; z-index: 120; pointer-events: none; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: .45rem .6rem; font-size: .8rem; box-shadow: 0 6px 20px rgba(0,0,0,.18); max-width: 260px; display: none; }
.viz-tip div { white-space: nowrap; }
.segbar { display: flex; gap: 2px; height: 28px; border-radius: 4px; overflow: hidden; margin: .4rem 0 .5rem; }
.segbar .seg { display: flex; align-items: center; padding-inline-start: .45rem; color: #fff; font-size: .78rem; font-weight: 700; min-width: 2px; border-radius: 4px; }
.lc { touch-action: pan-y; }
@media print { .foot { display: block !important; } .tbl-tg { display: none; } }

.top .link { white-space: nowrap; }

.kpi-t td { vertical-align: middle; } .kpi-t input { min-width: 90px; }

.order { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .8rem 0; border-bottom: 1px solid var(--line); } .order.late b { color: var(--bad); }

.qp .btn.on { background: var(--brand); color: var(--on-brand); }

/* OXARROW logo */
.lg { display: block; } .lg-dark { display: none; }
:root[data-theme="dark"] .lg-light { display: none; } :root[data-theme="dark"] .lg-dark { display: block; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .lg-light { display: none; } :root:where(:not([data-theme="light"])) .lg-dark { display: block; } }
.brand.big .lg { width: 200px; height: auto; margin: 0 auto .2rem; }
.top .brand .tm { height: 30px; width: auto; } .top .brand .tw { height: 17px; width: auto; margin-inline-start: .15rem; }
@media (max-width: 520px) { .top .brand .tw { display: none; } }

.paybox { margin-top: 1rem; border: 1px solid var(--line); border-radius: var(--r); padding: .8rem 1rem; background: var(--soft); text-align: start; }
.paybox h3 { margin: 0 0 .5rem; color: var(--ink); } .pb-row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; padding: .25rem 0; }
.pb-row span { color: var(--muted); min-width: 110px; font-size: .85rem; } .pb-row b { word-break: break-all; }
