/*
 * SmartPonics platform styling.
 *
 * Colour has two separate jobs here and they never borrow from each other:
 *   - brand colours (the SmartPonics green/cyan) appear on the masthead and nowhere else;
 *   - data colours come from a validated categorical palette, with status colours reserved for
 *     good / warning / serious / critical and always paired with an icon and a word, so nothing
 *     is ever carried by hue alone.
 *
 * Both themes are selected rather than flipped: the dark values are their own steps chosen against
 * the dark surface. Layout uses logical properties throughout (inline-start/end rather than
 * left/right) so the Arabic RTL interface is a direction change, not a second stylesheet.
 */

/*
 * Dark is the default. The platform is read on a phone in a greenhouse and on a screen in a control
 * room, and both are better served by a dark surface — light stays available on the toggle.
 *
 * Two colour groups are deliberately NOT part of the visual refresh: the categorical chart series
 * and the four status colours. Those were chosen against colour-vision-deficiency and contrast
 * thresholds; a neon accent that looks good on a hero would fail both as a data colour. So the
 * accent dresses the chrome — buttons, brand, focus, glow — and never the data.
 */
:root {
  color-scheme: dark;

  /* Chrome and ink */
  --page:            #050b14;
  --surface-1:       #0b1524;
  --surface-2:       #101e30;
  --surface-glass:   rgba(11, 21, 36, 0.72);
  --text-primary:    #eaf2ff;
  --text-secondary:  #a7b6cc;
  --text-muted:      #6f8098;
  --grid:            #16273c;
  --axis:            #23384f;
  --border:          rgba(126, 168, 214, 0.14);
  --border-strong:   rgba(126, 168, 214, 0.28);
  --band-fill:       rgba(126, 168, 214, 0.07);
  --band-edge:       rgba(126, 168, 214, 0.2);
  --night-strip:     #23384f;
  --day-strip:       #f5c542;

  /* Categorical series — validated dark steps, unchanged by the refresh */
  --series-1:        #3987e5;
  --series-2:        #d95926;
  /* Added for the profile charts, which plot up to five series at once. Chosen to stay apart
     under the common colour-vision deficiencies, and kept clear of the status hues below. */
  --series-3:        #3fa66f;
  --series-4:        #a37ee8;
  --series-5:        #3fb6c4;

  /* Status — reserved, never reused as a series colour */
  --status-good:     #0ca30c;
  --status-warning:  #fab219;
  --status-serious:  #ec835a;
  --status-critical: #d03b3b;
  /* The light red used for cautionary prose. Deliberately not --status-critical: that one is sized
     for chips and dots, and at caption length on this dark ground it is hard to read. */
  --status-caution-text: #ff8f8f;

  /* Accent — chrome only: brand, buttons, focus, glow */
  --brand-green:     #3df57a;
  --brand-cyan:      #16c6f5;
  --accent-ink:      #041018;
  --accent-gradient: linear-gradient(135deg, var(--brand-cyan), var(--brand-green));
  --accent-glow:     0 0 0 1px rgba(61, 245, 122, 0.32), 0 10px 32px -10px rgba(61, 245, 122, 0.55);

  --radius:          14px;
  --shadow:          0 1px 2px rgba(0, 0, 0, 0.5);

  --font-display: "Space Grotesk", "Tajawal", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font: "DM Sans", "Tajawal", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* Light stays available; the accent deepens so it is readable on a white surface. */
:root[data-theme="light"] {
  color-scheme: light;
  --page:            #f6f8fb;
  --surface-1:       #ffffff;
  --surface-2:       #eef2f7;
  --surface-glass:   rgba(255, 255, 255, 0.78);
  --text-primary:    #08111d;
  --text-secondary:  #48596e;
  --text-muted:      #7c8ca1;
  --grid:            #e3e9f0;
  --axis:            #c6d0dc;
  --border:          rgba(8, 17, 29, 0.11);
  --border-strong:   rgba(8, 17, 29, 0.2);
  --band-fill:       rgba(8, 17, 29, 0.05);
  --band-edge:       rgba(8, 17, 29, 0.16);
  --night-strip:     #c6d0dc;
  --day-strip:       #eda100;
  --series-1:        #2a78d6;
  --series-2:        #eb6834;
  --series-3:        #2f8f5b;
  --series-4:        #7c53c9;
  --series-5:        #1f8f9e;
  --brand-green:     #16a34a;
  --brand-cyan:      #0284c7;
  --accent-ink:      #ffffff;
  --accent-glow:     0 0 0 1px rgba(22, 163, 74, 0.28), 0 10px 28px -12px rgba(22, 163, 74, 0.5);
  --shadow:          0 1px 2px rgba(8, 17, 29, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/*
 * A faint grid, the way a trading terminal draws one. It sits behind everything at very low
 * opacity — enough to give the dark surface texture, not enough to compete with a chart.
 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(to right, var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: 56px 56px;
  opacity: 0.35;
  mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, #000 40%, transparent 100%);
}

h1, h2, h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
}
h1 { font-size: 1.15rem; }
h2 { font-size: 1rem; }
h3 { font-size: 0.95rem; }
p  { margin: 0; }
a  { color: inherit; }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.9em; }

.muted { color: var(--text-muted); }
.small { font-size: 0.82rem; }
.num   { text-align: end; font-variant-numeric: tabular-nums; }
.sub-heading { margin: 18px 0 8px; color: var(--text-secondary); }

/* ------------------------------------------------------------------ masthead */

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  padding: 12px 24px;
  background: var(--surface-glass);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}
.masthead__home { display: block; line-height: 0; border-radius: 12px; }

/* The one place brand colour appears. */
.masthead::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: -1px;
  height: 2px;
  background: linear-gradient(to right, var(--brand-green), var(--brand-cyan));
}

.masthead__logo { width: 44px; height: 44px; object-fit: contain; flex: none; }
/*
 * The brand lockup, drawn to match the landing page exactly.
 *
 * Pinned to LTR as a whole: it is a company name, so it must read left to right and keep its order
 * inside an RTL page rather than being reflowed as though it were a sentence.
 */
.masthead__brandlink {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: inherit;
  direction: ltr;
  unicode-bidi: isolate;
}
.masthead__tile {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--surface-1);
  border: 1px solid var(--line);
  flex: none;
}
.masthead__tile img { width: 30px; height: 30px; object-fit: contain; }
.masthead__brandtext { display: flex; flex-direction: column; line-height: 1.24; }
.masthead__brandtext strong {
  font-family: var(--font-display);
  font-size: 1.06rem;
  letter-spacing: -0.02em;
}
.masthead__brandtext em { font-style: normal; font-size: 0.72rem; color: var(--text-muted); }

/* The house these readings belong to, in the cluster that is meant to change. */
.clock__house {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary, var(--text-primary));
  margin-block-start: 2px;
}
.clock__house:empty { display: none; }

.masthead__clock { margin-inline-start: auto; text-align: end; }
.clock__time { font-size: 1.2rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; }
.clock__meta { font-size: 0.75rem; }

.masthead__controls { display: flex; align-items: center; gap: 8px; }

/* Who is signed in. Quiet, but always visible — on a shared control-room screen the difference
   between two accounts is the difference between two farms' records. */
.masthead__who { display: flex; flex-direction: column; line-height: 1.25; text-align: end; }
.masthead__who[hidden] { display: none; }
.masthead__who strong { font-size: 0.85rem; }
.masthead__who span { font-size: 0.72rem; }

/* ------------------------------------------------------------------ the approval alert */

/*
 * Shown to an administrator while somebody waits to be let in. It sits between the masthead and the
 * sub-navigation so it is on every screen rather than only on the one nobody has opened yet, and it
 * uses the warning colour rather than the critical one — a person waiting is not an emergency.
 */
.app-alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 24px;
  font-size: 0.88rem;
  color: var(--text-primary);
  background: color-mix(in srgb, var(--status-warning) 13%, var(--surface-1));
  border-bottom: 1px solid color-mix(in srgb, var(--status-warning) 40%, transparent);
}
.app-alert[hidden] { display: none; }

/* Support access. Louder than the approval bar, because mistaking whose data is on screen is the
   whole risk of the feature — and the way out is in the bar itself, not buried in a menu. */
.app-alert--support {
  background: color-mix(in srgb, var(--status-critical) 16%, var(--surface-1));
  border-bottom-color: color-mix(in srgb, var(--status-critical) 55%, transparent);
}
.app-alert--support .app-alert__action {
  border: 1px solid currentColor;
  border-radius: 8px;
  padding: 4px 10px;
  background: none;
  font: inherit;
  font-weight: 700;
  color: inherit;
  cursor: pointer;
}
.app-alert__text { flex: 1; }

/* The pilot: information, not a warning — the brand's own colour rather than amber. */
.app-alert--pilot {
  background: color-mix(in srgb, var(--brand-cyan) 10%, var(--surface-1));
  border-bottom-color: color-mix(in srgb, var(--brand-cyan) 35%, transparent);
  flex-wrap: wrap;
}
.app-alert--pilot button.app-alert__action {
  background: none;
  border: 1px solid currentColor;
  border-radius: 8px;
  padding: 3px 10px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
/*
 * "You are looking at an older version of this page."
 *
 * Styled like the pilot bar rather than like a warning: nothing is wrong, something is newer. The
 * button is the only thing that resolves it, so it is the only thing in the bar that looks
 * pressable.
 */
.app-alert--build {
  background: color-mix(in srgb, var(--brand-cyan) 10%, var(--surface-1));
  border-bottom-color: color-mix(in srgb, var(--brand-cyan) 35%, transparent);
  flex-wrap: wrap;
}
.app-alert--build button.app-alert__action {
  background: none;
  border: 1px solid currentColor;
  border-radius: 8px;
  padding: 3px 10px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.app-alert__close {
  background: none;
  border: 0;
  color: var(--text-secondary);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.app-alert__action {
  color: var(--text-primary);
  font-weight: 700;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  white-space: nowrap;
}

/* The same number on the tab, so it is visible once the bar has been read and stopped registering. */
.tab__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 19px;
  height: 19px;
  margin-inline-start: 7px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--status-warning);
  color: #1a1200;
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

/* ------------------------------------------------------------------ navigation */

.tabs { display: flex; gap: 4px; flex-wrap: wrap; }

.tab {
  padding: 7px 16px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border: 1px solid transparent;
  transition: color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}
.tab:hover { background: var(--surface-2); color: var(--text-primary); }
.tab.is-active {
  background: var(--brand-green);
  color: var(--accent-ink);
  border-color: var(--brand-green);
  box-shadow: var(--accent-glow);
  font-weight: 700;
}

.subnav {
  display: flex;
  gap: 2px;
  padding: 0 24px;
  background: var(--surface-glass);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  position: sticky;
  top: 69px;
  z-index: 20;
}
.subnav__item {
  padding: 10px 14px;
  font-size: 0.86rem;
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.subnav__item:hover { color: var(--text-primary); }
.subnav__item.is-active {
  color: var(--text-primary);
  border-bottom-color: var(--brand-green);
  font-weight: 600;
}

/* ------------------------------------------------------------------ layout */

main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 24px 8px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px 18px;
}
.tile, .stat-card, .chart-card, .card, .mini-tile {
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.tile:hover, .stat-card:hover, .chart-card:hover, .card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: 0 14px 30px -18px rgba(0, 0, 0, 0.8);
}
.tile__value, .stat-card__value, .mini-tile__value, .clock__time {
  font-family: var(--font-display);
}
.panel--tall { display: flex; flex-direction: column; min-height: 60vh; }

.panel__head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.panel__note { font-size: 0.82rem; max-width: 80ch; flex: 1 1 340px; }

/*
 * A note that is a warning rather than a caption.
 *
 * Light red, on a faint red field with a red rule down its leading edge — the same shape the alert
 * notes use, so it is recognisable as "this one has a consequence" before a word of it is read. The
 * text colour is lightened well clear of the critical red used for alarm chips, because a full
 * saturated red on this dark ground is hard to read at caption size and reads as an error that has
 * already happened rather than as one to avoid.
 */
.panel__note--caution {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: none;
  margin: 0 0 4px;
  padding: 11px 14px;
  border-radius: 10px;
  line-height: 1.65;
  color: var(--status-caution-text);
  background: color-mix(in srgb, var(--status-critical) 11%, transparent);
  border: 1px solid color-mix(in srgb, var(--status-critical) 34%, transparent);
  border-inline-start: 3px solid var(--status-caution-text);
}
.panel__note--caution svg { flex: none; margin-block-start: 1px; }

.section-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.filters { margin-inline-start: auto; display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.toolbar {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: 12px 18px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ------------------------------------------------------------------ controls */

select, input, textarea, .ghost-button, .primary-button, .chip {
  font: inherit;
  font-size: 0.88rem;
  color: var(--text-primary);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 11px;
}
textarea { resize: vertical; line-height: 1.55; }
select, .ghost-button, .primary-button, .chip { cursor: pointer; }
select:hover, .ghost-button:hover, input:hover, textarea:hover { border-color: var(--border-strong); }
:focus-visible {
  outline: 2px solid var(--brand-green);
  outline-offset: 2px;
  border-radius: 8px;
}

.ghost-button, .primary-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  white-space: nowrap;
  font-family: var(--font-display);
  font-weight: 600;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}
.ghost-button:hover { transform: translateY(-1px); }
.primary-button {
  background: var(--brand-green);
  color: var(--accent-ink);
  border-color: var(--brand-green);
  font-weight: 700;
}
.primary-button:hover { transform: translateY(-1px); box-shadow: var(--accent-glow); }

.icon-button {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 6px;
  cursor: pointer;
  color: var(--text-secondary);
  line-height: 1;
}
.icon-button:hover { background: var(--surface-2); color: var(--text-primary); }
.icon-button--danger:hover { color: var(--status-critical); border-color: var(--status-critical); }

.link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--series-1);
  cursor: pointer;
  font: inherit;
  text-align: start;
}
.link-button:hover { text-decoration: underline; }

.chip {
  padding: 4px 12px;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8rem;
}
.chip:hover { background: var(--surface-2); }
.chip.is-selected {
  background: var(--brand-green);
  color: var(--accent-ink);
  border-color: var(--brand-green);
  font-weight: 700;
}

.field { display: flex; flex-direction: column; gap: 3px; }
.field__label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.76rem;
  color: var(--text-secondary);
}
.pill__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--night-strip); }
.pill--day .pill__dot { background: var(--day-strip); }

.badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  white-space: nowrap;
}
.badge--soft { background: var(--surface-2); }
.badge--answered { color: var(--status-good); border-color: var(--status-good); }
.badge--closed { color: var(--text-muted); }

.tag-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.tag {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-secondary);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
}
.icon { flex: none; vertical-align: -2px; }

/* ------------------------------------------------------------------ forms */

.form { display: flex; flex-direction: column; gap: 12px; }
.form--grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px 16px;
}
.form__row { display: flex; flex-direction: column; gap: 4px; }
.form__row--text, .form__row--array, .form__row--object { grid-column: 1 / -1; }
.form__label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}
/*
 * Hints take their direction from their own content.
 *
 * Most are Arabic prose, but many are a bare range — "0–0.5" for the ammonium share — and a range
 * inherits the paragraph's right-to-left order, so it was rendering as "0.5–0". A hint that reads
 * backwards is worse than no hint: the reader takes it for the allowed maximum and minimum in that
 * order. Done in CSS rather than as dir="auto" on each one, because there are several field helpers
 * across the views and the next one written would have the same bug.
 */
.form__hint { font-size: 0.7rem; font-weight: 400; unicode-bidi: plaintext; }
.form__error { font-size: 0.75rem; color: var(--status-critical); min-height: 0; }
.form__actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.form__row input[type="checkbox"] { width: 18px; height: 18px; }

.input-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  margin-top: 6px;
}
.input-grid__cell { display: flex; flex-direction: column; gap: 3px; }
.input-grid__cell .form__label { font-size: 0.75rem; }

.capex-rows { display: flex; flex-direction: column; gap: 6px; }
.capex-row { display: grid; grid-template-columns: 1fr 150px auto; gap: 8px; }

/* ------------------------------------------------------------------ bankable study

   An editable schedule that adds up in front of the reader: label, unit, quantity, rate, and the
   amount those make, recomputed as they type. A line that does not visibly multiply is a line
   somebody has to check with a calculator. */

.sched { display: flex; flex-direction: column; gap: 7px; }
.sched__head, .sched__row {
  display: grid;
  grid-template-columns: minmax(150px, 2.2fr) 90px 90px 120px 110px 40px;
  gap: 8px;
  align-items: center;
}
.sched__head--crop, .sched__row--crop {
  grid-template-columns: minmax(140px, 1.6fr) 84px 96px 84px 90px 76px 110px 40px;
}
.sched__head {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding-inline: 2px;
  margin-bottom: 2px;
}
.sched__head .num { text-align: end; }
.sched__row input, .sched__row select { width: 100%; padding: 8px 10px; font-size: 0.85rem; }
.sched__amount {
  text-align: end;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.88rem;
  padding-inline-end: 4px;
}

@media (max-width: 900px) {
  /* Below this the six columns stop being a table and become a wall, so the schedule scrolls as one
     block rather than each row wrapping into an unreadable stack. */
  .sched, .sched__head { min-width: 640px; }
  .sched__head--crop, .sched__row--crop { min-width: 780px; }
  .cost-section, .panel > .sched, .panel > div > .sched { overflow-x: auto; }
}

/* ------------------------------------------------------------------ lighting */

.spectrum-input {
  width: 100%;
  padding: 12px;
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, monospace;
  font-size: 0.82rem;
  line-height: 1.6;
  resize: vertical;
}

/* The chart leads the panel, so it gets the room a picture needs to be read as a shape. */
.spectrum-chart { margin-block-end: 6px; }
.spectrum-chart .chart-svg { width: 100%; height: auto; }

/* The numbers that draw it, folded away underneath. They are the input, and an input has no business
   being the first thing on a panel whose subject is what that input looks like. */
.spectrum-source { margin-block-start: 14px; }
.spectrum-source > summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 8px 0;
}
.spectrum-source > summary:hover { color: var(--text-primary); }

.feed-control { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.search-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.search-bar .search-input { flex: 1 1 280px; min-width: 0; }
.search-bar select { flex: 0 0 auto; }
.toggle { display: inline-flex; align-items: center; gap: 7px; font-size: 0.85rem; cursor: pointer; }
.toggle input { width: 17px; height: 17px; }

/* Held-back submissions sit above the board in a warning colour, because a queue nobody notices is
   a queue that quietly stops being read. */
.review-queue {
  border: 1px solid var(--status-warning);
  border-radius: 14px;
  padding: 14px 16px 16px;
  margin-bottom: 18px;
  background: color-mix(in srgb, var(--status-warning) 8%, transparent);
}
.review-queue .sub-heading { display: flex; align-items: center; gap: 8px; margin-top: 0; }
.review-queue__list { display: flex; flex-direction: column; gap: 8px; }
.review-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface-1);
}
.review-row__text { flex: 1 1 240px; min-width: 0; font-size: 0.9rem; }

.form__notice {
  margin: 0 0 14px;
  padding: 11px 13px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 0.84rem;
  line-height: 1.55;
}
.card__source { display: flex; align-items: center; gap: 6px; margin: 0 0 4px; }
.card__source .icon { color: var(--brand-cyan); flex: none; }

/* ------------------------------------------------------------------ greenhouse cards */

/*
 * A feasibility study covers a project of houses, and each house is a small form of its own. Boxing
 * them keeps it obvious which crop, area and capital list belong to which house once a project has
 * five of them and the page is a long way from its heading.
 */
.house-list { display: flex; flex-direction: column; gap: 14px; }
.house {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  padding: 16px 16px 18px;
}
.house__head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.house__head .icon { color: var(--brand-green); flex: none; }
.house__name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  flex: 1 1 auto;
  min-width: 0;
}
.house .form--grid { margin-top: 6px; }
.sub-heading--tight { margin: 14px 0 6px; font-size: 0.85rem; }

/*
 * The two stock tanks, told apart by more than a letter.
 *
 * The single mistake this panel exists to prevent is a salt going into the wrong tank, and two
 * identical grey headings above two identical tables do nothing to help. The colour is
 * reinforcement only: the letter names the tank, the description says what belongs in it, and the
 * red note above says what happens if they are combined. Nothing here is carried by hue.
 */
.sub-heading--tank {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 20px 0 9px;
  padding-inline-start: 11px;
  border-inline-start: 3px solid var(--border-strong);
  color: var(--text-primary);
}
.sub-heading--tank strong { font-family: var(--font-display); font-size: 0.96rem; }
.sub-heading--tank span { font-size: 0.8rem; font-weight: 400; color: var(--text-secondary); }
.sub-heading--tank-a { border-inline-start-color: var(--series-1); }
.sub-heading--tank-b { border-inline-start-color: var(--series-3); }
.form__actions--start { justify-content: flex-start; margin-top: 10px; }

.cost-section + .cost-section { border-top: 1px solid var(--border); padding-top: 4px; }
.cost-section .panel__note { margin: 0 0 8px; font-size: 0.78rem; }

/* The running total sits under its own list rather than in a summary elsewhere, so a reader can see
   at a glance whether the four fixed-cost lines still come to the figure they had in mind. */
.cost-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: 0.85rem;
}
.cost-total__value {
  font-family: var(--font-display);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

/* ------------------------------------------------------------------ stats and tiles */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}
.stat-card {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 11px 13px;
  background: var(--surface-1);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
/*
 * A marked card gets a tinted ground as well as an edge. A 3px stripe on the inline edge is easy
 * to miss in a row of five cards, which defeats the point of marking one of them at all.
 */
.stat-card--good {
  border-inline-start: 3px solid var(--status-good);
  background: color-mix(in srgb, var(--status-good) 7%, var(--surface-1));
}
.stat-card--warn {
  border-inline-start: 3px solid var(--status-warning);
  background: color-mix(in srgb, var(--status-warning) 8%, var(--surface-1));
}
.stat-card__label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}
.stat-card__value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
/* A verdict beside a figure — "in band" — is a marker, not a banner across the card. */
.stat-card > .pill { align-self: flex-start; margin-block-start: 3px; font-size: 0.72rem; padding: 3px 9px; }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(212px, 1fr));
  gap: 12px;
}
.tile {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 12px 13px 11px;
  background: var(--surface-1);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 150px;
}
.tile__label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}
.tile__value { font-size: 1.85rem; font-weight: 600; line-height: 1.05; letter-spacing: -0.02em; }
.tile__unit { font-size: 0.8rem; font-weight: 400; color: var(--text-muted); margin-inline-start: 4px; }
.tile__band { font-size: 0.76rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.tile__qualifier { font-size: 0.73rem; color: var(--text-muted); margin-top: auto; }

.mini-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.mini-tile {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
}
.mini-tile__label { font-size: 0.72rem; color: var(--text-secondary); }
.mini-tile__value { font-size: 1.15rem; font-weight: 600; }

/*
 * Where the reading sits relative to its band. The band is neutral; only the marker takes the
 * status colour, and the status word beside it is what actually carries the meaning.
 */
.meter {
  position: relative;
  height: 8px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin: 2px 0 1px;
}
.meter__band {
  position: absolute;
  top: 0; bottom: 0;
  background: var(--band-fill);
  border-inline: 1px solid var(--band-edge);
}
.meter__marker {
  position: absolute;
  top: 50%;
  width: 3px;
  height: 14px;
  margin-inline-start: -1.5px;
  transform: translateY(-50%);
  border-radius: 2px;
  box-shadow: 0 0 0 2px var(--surface-1);
}

/* ------------------------------------------------------------------ alerts and notes */

.alerts { display: flex; flex-direction: column; gap: 8px; }

.alert {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-inline-start-width: 4px;
  border-radius: 8px;
  background: var(--surface-2);
}
.alert--dangerous     { border-inline-start-color: var(--status-critical); }
.alert--out_of_target { border-inline-start-color: var(--status-warning); }
.alert__icon { margin-top: 2px; }
.alert__title { font-weight: 600; }
.alert__detail { font-size: 0.86rem; color: var(--text-secondary); }
.alert__consequence { font-size: 0.84rem; color: var(--text-muted); margin-top: 4px; max-width: 88ch; }
.alert__meta { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; text-align: end; }

.all-clear { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); font-size: 0.9rem; }

.notes { display: flex; flex-direction: column; gap: 8px; }
.note {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-2);
  border-inline-start: 3px solid var(--border);
  font-size: 0.86rem;
  color: var(--text-secondary);
}
.note--warn { border-inline-start-color: var(--status-warning); }
.note .icon { margin-top: 3px; }

.error-box {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--status-critical);
  color: var(--status-critical);
  font-size: 0.88rem;
}
.empty-state { padding: 22px 4px; font-size: 0.9rem; }

.steps { margin: 0; padding-inline-start: 20px; display: flex; flex-direction: column; gap: 7px; }
.steps li { font-size: 0.87rem; color: var(--text-secondary); }
.plain-list { margin: 6px 0 0; padding-inline-start: 18px; font-size: 0.86rem; color: var(--text-secondary); }
/*
 * A split application, in the cell where the schedule used to say "split this one".
 *
 * Two lines because they answer two questions: how much goes on each pass, and how long to wait
 * before the next. Putting the soak time in muted small type under the depth keeps the column
 * scannable — the depth is what somebody sets, the wait is what somebody checks.
 */
.split { display: inline-flex; flex-direction: column; gap: 1px; }
.split b {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.split__soak { font-size: 0.72rem; color: var(--text-secondary); white-space: nowrap; }

.deviation { font-family: var(--font-display); font-variant-numeric: tabular-nums; }
/*
 * A deviation worth acting on is given a filled ground, not just a colour.
 *
 * The column is a wall of near-zeros with two numbers in it that matter, and a hue change alone is
 * both easy to miss and useless to a reader with a colour-vision deficiency. The fill makes the row
 * findable at a glance; the number itself still says how far off it is.
 */
.deviation--off {
  color: var(--status-warning);
  font-weight: 700;
  background: color-mix(in srgb, var(--status-warning) 15%, transparent);
  border-radius: 6px;
  padding: 1px 7px;
}

/* ------------------------------------------------------------------ charts */

.charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(430px, 1fr));
  gap: 14px;
}
.chart-card {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 12px 13px 10px;
  background: var(--surface-1);
  overflow: hidden;
}
.chart-card__head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.chart-card__title { font-size: 0.9rem; font-weight: 600; }
.chart-card__unit { font-size: 0.78rem; color: var(--text-muted); }
.chart-card__toggle {
  margin-inline-start: auto;
  font: inherit;
  font-size: 0.74rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 8px;
  color: var(--text-secondary);
  cursor: pointer;
}
.chart-card__toggle:hover { background: var(--surface-2); }

.legend { display: flex; gap: 14px; flex-wrap: wrap; margin: 2px 0 6px; }
.legend__item { display: inline-flex; align-items: center; gap: 6px; font-size: 0.76rem; color: var(--text-secondary); }
.legend__swatch { width: 11px; height: 3px; border-radius: 2px; }

.chart-svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.chart-note { font-size: 0.74rem; color: var(--text-muted); margin-top: 4px; }

.chart-table { display: none; }
.chart-card.is-tabular .chart-svg,
.chart-card.is-tabular .legend { display: none; }
.chart-card.is-tabular .chart-table { display: block; max-height: 280px; overflow: auto; }

/* ------------------------------------------------------------------ tables */

/*
 * A table is where most of this platform's numbers are actually read, so it is worth more than a
 * grid of borders.
 *
 * Four things do the work. The wrap gives the table an edge, so it reads as one object rather than
 * as text that happens to line up. The header sits on its own surface, in the display face, so the
 * eye finds the column titles without hunting. Alternate rows are tinted very faintly — a wide row
 * of figures is where a reader's eye slips a line, and this is the cheapest fix there is. And the
 * numbers are set in the display face with tabular figures, so digits sit in columns and a decimal
 * point stays put down the whole column.
 *
 * Padding is symmetric and logical rather than "7px 10px 7px 0". That old value put the whole
 * gutter on the physical right, which is the start of the cell in English and the end of it in
 * Arabic — so every table on the platform was padded on the wrong side in one of its two languages.
 */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-1);
}

.data-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.data-table th {
  text-align: start;
  font-family: var(--font-display);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
  background: var(--surface-2);
  border-block-end: 1px solid var(--border-strong);
  padding: 10px 13px;
  white-space: nowrap;
}
.data-table th.num { text-align: end; }
.data-table td {
  padding: 10px 13px;
  border-block-end: 1px solid var(--grid);
  vertical-align: top;
}
/* The last row's rule would sit on the wrap's own border and read as a double line. */
.data-table tbody tr:last-child td { border-block-end: 0; }
.data-table tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--surface-2) 45%, transparent);
}
.data-table tbody tr:hover { background: var(--surface-2); }
/* The label column is what a row is found by, so it is inked like a heading rather than like data. */
.data-table td:first-child { color: var(--text-primary); font-weight: 500; }
.data-table td.num,
.data-table th.num { text-align: end; }
.data-table td.num {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
.row-actions { display: flex; gap: 4px; flex-wrap: wrap; }

/*
 * A chemical formula reads left to right in every language on earth. Without the direction pinned,
 * an RTL paragraph reorders "5Ca(NO3)2·NH4NO3·10H2O" into something that is not a compound.
 */
.formula {
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* What a salt actually delivers, as chips rather than as one run-on line of "CA 217.1 · N 182.09". */
.ion-list { display: flex; flex-wrap: wrap; gap: 4px; }
.ion-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 1px 7px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--series-1) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--series-1) 26%, transparent);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ion-chip b { font-family: var(--font-display); font-size: 0.7rem; letter-spacing: 0.03em; }

/* The element symbol is what a reader matches against a water report, so it is findable by scanning
   one column rather than by reading into the middle of a phrase. */
.element { display: inline-flex; align-items: baseline; gap: 8px; }
.element__symbol {
  flex: none;
  min-width: 30px;
  padding: 1px 6px;
  border-radius: 5px;
  text-align: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-family: var(--font-display);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* How many people are waiting, stated before the table rather than left to be counted from it. */
/* ------------------------------------------------------------------ connecting a farm */

.connect-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

.connect-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.connect-step > div { flex: 1; }
.connect-step.is-done { border-color: color-mix(in srgb, var(--status-good) 45%, transparent); }

.connect-step__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  font-weight: 700;
  font-family: var(--font-display);
}
.connect-step.is-done .connect-step__mark { border-color: var(--status-good); }
.connect-step__title { font-weight: 600; }
.connect-step__detail { font-size: 0.82rem; }

.wiring { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); }
.wiring__case {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.wiring__case h3 { margin: 0 0 8px; font-size: 0.95rem; }
/* The chain is pinned left-to-right: it is a sequence of devices, and reversing it in an RTL
   paragraph would put the greenhouse after the platform. */
.wiring__path {
  margin: 0 0 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--page);
  font-size: 0.8rem;
  line-height: 1.6;
}
.wiring__case p:last-child { margin-bottom: 0; font-size: 0.85rem; }

.connect-route { margin-top: 20px; }
.connect-route h3 { display: flex; align-items: center; gap: 9px; margin: 0 0 4px; font-size: 1rem; }
.connect-route__letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--brand-green);
  color: var(--accent-ink);
  font-size: 0.78rem;
  font-weight: 700;
}

/* The command is meant to be copied, so it never wraps mid-token — it scrolls instead. */
.connect-code {
  margin: 10px 0 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--page);
  border: 1px solid var(--border);
  overflow-x: auto;
  font-size: 0.8rem;
  line-height: 1.65;
}
.connect-keys { margin: 10px 0; }
.connect-keys code { font-size: 0.85rem; }

/* Which greenhouse the numbers on screen belong to. Stated, never left to be inferred. */
.house-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 0.92rem;
}

.admin-count { margin: 0 0 12px; color: var(--text-secondary); }
.admin-count strong {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--text-primary);
  margin-inline-end: 4px;
}

/* ------------------------------------------------------------------ cards */

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.card-grid--muted { opacity: 0.72; }

.card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  background: var(--surface-1);
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.card__head { display: flex; align-items: flex-start; gap: 10px; }
.card__title { flex: 1; }
.card__org { font-size: 0.86rem; font-weight: 500; color: var(--text-secondary); }
.card__summary { font-size: 0.88rem; color: var(--text-secondary); }
.card__meta { font-size: 0.78rem; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.card__actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.card__actions .row-actions { margin-inline-start: auto; }
.card__body {
  font-size: 0.87rem;
  color: var(--text-secondary);
  white-space: pre-wrap;
  border-top: 1px solid var(--grid);
  padding-top: 10px;
  margin-top: 4px;
}

.card--event { display: grid; grid-template-columns: 92px 1fr; gap: 14px; align-items: start; }
.event__date {
  display: flex;
  flex-direction: column;
  padding: 8px;
  border-radius: 8px;
  background: var(--surface-2);
  text-align: center;
}
.event__day { font-weight: 600; font-size: 0.85rem; }
.event__time { font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.event__body { display: flex; flex-direction: column; gap: 6px; }

.lesson-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.lesson { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.lesson summary { cursor: pointer; font-size: 0.87rem; display: flex; gap: 8px; align-items: center; }
.lesson__index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--surface-2);
  font-size: 0.72rem;
  flex: none;
}
.lesson__body {
  margin-top: 8px;
  font-size: 0.86rem;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

/* ------------------------------------------------------------------ discussions */

.thread-list { display: flex; flex-direction: column; gap: 14px; }
.card--thread { gap: 9px; }
.replies { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.reply {
  border-inline-start: 3px solid var(--border);
  padding: 6px 0 6px 12px;
  padding-inline-start: 12px;
}
.reply__head { display: flex; gap: 8px; align-items: baseline; font-size: 0.8rem; }
.reply__body { font-size: 0.87rem; color: var(--text-secondary); white-space: pre-wrap; }
.reply-form { display: grid; grid-template-columns: 180px 1fr auto; gap: 8px; align-items: start; margin-top: 8px; }

/* ------------------------------------------------------------------ assistant */

.thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 6px 2px 14px;
  max-height: 58vh;
}
.thread__empty { padding: 26px 4px; }

.bubble {
  border-radius: 12px;
  padding: 11px 14px;
  max-width: 88%;
  font-size: 0.9rem;
  line-height: 1.65;
}
.bubble--user {
  align-self: flex-end;
  background: var(--text-primary);
  color: var(--surface-1);
  white-space: pre-wrap;
}
.bubble--assistant {
  align-self: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.bubble__mode { font-size: 0.74rem; display: flex; align-items: center; gap: 5px; margin-bottom: 6px; }
.bubble__text .markdown > * + * { margin-top: 10px; }
.markdown p { white-space: pre-wrap; }
.markdown ul { margin: 0; padding-inline-start: 20px; }
.markdown code {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 4px;
}
.bubble__note { font-size: 0.78rem; margin-top: 8px; }
.bubble__sources { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 5px; align-items: center; font-size: 0.76rem; }
.bubble--pending { display: flex; align-items: center; gap: 8px; color: var(--text-muted); }

.spinner {
  width: 13px; height: 13px;
  border: 2px solid var(--border);
  border-top-color: var(--series-1);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ask-bar { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; margin-top: auto; }
.ask-input { min-height: 56px; }

/* ------------------------------------------------------------------ modal */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 11, 11, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 5vh 16px;
  z-index: 60;
  overflow-y: auto;
}
.modal {
  background: var(--surface-1);
  border-radius: 12px;
  border: 1px solid var(--border);
  width: min(680px, 100%);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
}
.modal__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal__head h3 { flex: 1; }
.modal__close {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
}
.modal__body { padding: 16px 18px; }

/* A one-hour credential shown once. Monospace and full width so the whole of it can be seen and
   checked before it is pasted into a message, rather than read as a truncated blur. */
.stack { display: flex; flex-direction: column; gap: 12px; }
.reset-link {
  width: 100%;
  padding: 10px 12px;
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, monospace;
  font-size: 0.8rem;
}
.modal__footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}

/* ------------------------------------------------------------------ tooltip and toasts */

.tooltip {
  position: fixed;
  z-index: 40;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--axis);
  border-radius: 7px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
  padding: 7px 9px;
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: nowrap;
}
.tooltip__time { color: var(--text-muted); margin-bottom: 3px; }
.tooltip__row { display: flex; align-items: center; gap: 6px; }
.tooltip__swatch { width: 9px; height: 3px; border-radius: 2px; }
.tooltip__value { font-variant-numeric: tabular-nums; margin-inline-start: auto; padding-inline-start: 10px; }

.toasts {
  position: fixed;
  inset-block-end: 20px;
  inset-inline-end: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 70;
}
.toast {
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
  font-size: 0.86rem;
}
.toast--good { border-inline-start: 3px solid var(--status-good); }
.toast--bad  { border-inline-start: 3px solid var(--status-critical); }

/* ------------------------------------------------------------------ colophon */

.colophon {
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px 24px 34px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ------------------------------------------------------------------ printing a study */

.export-actions { margin-bottom: 14px; }

/*
 * What a printed feasibility study is.
 *
 * The browser's own print-to-PDF is used rather than a bundled library, and the reason is Arabic: a
 * JavaScript PDF writer ships without an Arabic face and renders the whole study as boxes, while the
 * browser prints with the reader's own fonts and shapes the text correctly. What it needs from here
 * is for the application around the study to get out of the way.
 */
@media print {
  body.printing .masthead,
  body.printing .subnav,
  body.printing .colophon,
  body.printing .app-alert,
  body.printing .export-actions,
  body.printing .toasts,
  body.printing .wa-fab,
  body.printing .print-hide { display: none !important; }

  body.printing {
    background: #fff;
    color: #000;
  }
  body.printing::before { display: none; }

  body.printing main { padding: 0; }
  body.printing .panel {
    background: #fff;
    border: 1px solid #bbb;
    box-shadow: none;
    /* A cashflow table split across a page break is unreadable, and a study is mostly tables. */
    break-inside: avoid;
    page-break-inside: avoid;
  }
  body.printing .stat-card,
  body.printing table { background: #fff; color: #000; }
  body.printing th,
  body.printing td { border-color: #ccc; }

  /*
   * The table's screen dressing, re-set for paper. Its header band and alternate rows are dark
   * surfaces, and a reader who has "background graphics" switched on would otherwise get a page of
   * navy blocks. The striping is kept, in the faintest grey that still survives a laser printer.
   */
  body.printing .table-wrap { background: #fff; border-color: #bbb; }
  body.printing .data-table th { background: #f0f0f0; color: #000; border-color: #999; }
  body.printing .data-table tbody tr:nth-child(even) { background: #f6f6f6; }
  body.printing .data-table td:first-child { color: #000; }
  body.printing .ion-chip,
  body.printing .element__symbol { background: #fff; border-color: #999; color: #000; }
  body.printing .formula { color: #000; }
  body.printing .deviation--off { background: #fff; color: #96140f; }
  body.printing .stat-card--good { border-inline-start-color: #17651a; }
  body.printing .stat-card--warn { border-inline-start-color: #8a5a00; }
  body.printing .sub-heading--tank { color: #000; border-inline-start-color: #666; }
  body.printing .sub-heading--tank span { color: #333; }

  /*
   * Mulder's chart does print: it is a vector, it carries the one finding that explains a
   * shortfall, and a report that drops it loses the reason the recommendation under it exists.
   */
  body.printing .mulder__node circle { fill: #fff; stroke: #333; }
  body.printing .mulder__node text { fill: #000; }
  body.printing .mulder__node.is-high circle { fill: #fbe9e7; stroke: #96140f; }
  body.printing .mulder__node.is-low circle { fill: #fdf3e0; stroke: #8a5a00; }
  body.printing .mulder__node.is-on_target circle { stroke: #17651a; }
  body.printing .mulder__ring { stroke: #ddd; }
  body.printing .mulder__edge--anta { stroke: #bbb; }
  body.printing .mulder__edge--stim { stroke: #9ccc9e; }
  body.printing .mulder__edge--hot { stroke: #96140f; }
  body.printing .mulder__legend { color: #333; }

  body.printing .advice__mark { background: #f0f0f0; color: #000; border: 1px solid #999; }
  body.printing .advice__item { border-block-end-color: #ddd; }
  body.printing .brief__label { color: #333; }

  /* Charts are canvases and print as flat colour on a white page; the tables carry the same numbers. */
  body.printing canvas { display: none; }

  /*
   * The map is a grid of tile images fetched for the screen. On paper it is a grey rectangle at
   * best, and the coordinates it was used to choose are printed in the report anyway.
   */
  body.printing .map { display: none; }

  /* SVG charts do print, and legibly — but only if their strokes are not white on white. */
  body.printing svg text { fill: #000; }

  /*
   * The tank-separation warning, printed as dark red on white.
   *
   * Its screen colour is a pale red chosen to be readable on this platform's dark ground, and that
   * same pale red on paper is very nearly invisible — on precisely the sheet somebody carries to
   * the mixing station, where the entire purpose of the line is that it is read before a calcium
   * salt goes into a tank of sulfates. The icon's colour is set inline by the code that builds it,
   * so overriding it here needs the weight.
   */
  body.printing .panel__note--caution {
    color: #96140f;
    background: #fff;
    border: 1px solid #96140f;
    border-inline-start: 3px solid #96140f;
  }
  body.printing .panel__note--caution svg { color: #96140f !important; }
  /* Same reasoning, one step down: the solver's warnings are grey-on-grey by design and print faint. */
  body.printing .note { background: #fff; color: #000; border-inline-start-color: #999; }
  body.printing .note--warn { border-inline-start-color: #96140f; }
  body.printing .note--warn svg { color: #96140f !important; }
  body.printing .map__grid-line { stroke: #999; }

  /* A long table of days should break across pages rather than be squeezed onto one. */
  body.printing table { break-inside: auto; }
  body.printing thead { display: table-header-group; }
  body.printing tr { break-inside: avoid; }
}

/* ------------------------------------------------------------------ responsive */

@media (max-width: 900px) {
  .masthead { gap: 12px; padding: 10px 16px; }
  .masthead__clock { margin-inline-start: 0; text-align: start; }
  .masthead__who { display: none; }
  .tabs { order: 5; width: 100%; }
  .subnav { top: 0; position: static; padding: 0 16px; }
  main { padding: 14px 16px 4px; }
  .charts { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); }
  .reply-form { grid-template-columns: 1fr; }
  .capex-row { grid-template-columns: 1fr 110px auto; }
  .card--event { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition: none !important; }
}

/* ---------------------------------------------------------------- location picker

   The field irrigation screen's map. Deliberately plain: the map is a way to pick a coordinate,
   not a GIS, and every pixel of chrome added here is one that has to be maintained. */

.map {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
}

.map__viewport {
  position: relative;
  height: 340px;
  cursor: crosshair;
  touch-action: none;      /* the pointer handlers do the panning, not the browser */
  overflow: hidden;
}

.map__layer { position: absolute; inset: 0; }

.map__tile {
  position: absolute;
  width: 256px;
  height: 256px;
  user-select: none;
  -webkit-user-drag: none;
}

.map__grid { position: absolute; inset: 0; }
.map__grid-line { stroke: var(--border); stroke-width: 1; }
.map__grid-line--strong { stroke: var(--text-muted); stroke-width: 1.5; }

.map__marker {
  position: absolute;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 3px solid var(--brand-green);
  border-radius: 50%;
  background: var(--surface-1);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.map__hint {
  position: absolute;
  inset-inline-start: 8px;
  bottom: 8px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  font: 12px/1.6 var(--mono, monospace);
  direction: ltr;
  pointer-events: none;
}

.map__controls {
  position: absolute;
  inset-inline-end: 8px;
  top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.map__zoom {
  width: 30px;
  height: 30px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-1);
  color: var(--text-primary);
}

.map__zoom:hover { background: var(--surface-2); }

.map__attribution {
  margin: 0;
  padding: 3px 8px;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  direction: ltr;
  text-align: end;
}

.map-form {
  display: grid;
  grid-template-columns: minmax(320px, 1.4fr) minmax(260px, 1fr);
  gap: 16px;
  align-items: start;
}

.map-form__fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

@media (max-width: 820px) {
  .map-form { grid-template-columns: 1fr; }
  .map__viewport { height: 260px; }
}


/*
 * A disabled control has to look disabled.
 *
 * There was no rule for this anywhere in the platform, so a button that could not be pressed looked
 * exactly like one that could — which is worse than no gate at all, because it reads as the app
 * ignoring the click.
 */
button:disabled,
button[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.6);
}

button:disabled:hover,
button[disabled]:hover {
  /* Cancels whatever hover the button class would otherwise apply. */
  filter: grayscale(0.6);
}


/* ---------------------------------------------------------------- facility sizing

   The specification is long — geometry, envelope, two design conditions, equipment — so it is
   grouped rather than run as one column of thirty inputs. */

.facility-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.facility-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px 14px;
  margin: 0;
}

.facility-group legend {
  padding: 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.facility-group__fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}

/* The site group holds a map, not a row of boxes, so it stacks instead of gridding. */
.facility-group--wide { grid-column: 1 / -1; }

/*
 * A field the site fetch filled is marked, because the alternative is an engineer who cannot tell
 * which numbers came from measurements and which are still the defaults they were handed.
 */
.field__input--fetched {
  border-color: var(--brand-green);
  background: color-mix(in srgb, var(--brand-green) 8%, var(--surface-2));
}

/* ---------------------------------------------------------------- psychrometric chart

   Two thermodynamic coordinates rather than a measure against time, so it does not share the
   series charts' geometry. What it does share is that the numbers appear as a table underneath. */

.psy-chart { margin-top: 8px; }

.psy-svg {
  width: 100%;
  height: auto;
  display: block;
  touch-action: none;   /* the pointer readout, not a scroll gesture */
}

/*
 * Each caption sits over the axis it names, in both writing directions. The humidity scale is on
 * the right of every psychrometric chart ever printed, so its caption is pinned there rather than
 * left to a flex row that reverses in Arabic and lands it over the wrong edge.
 */
.psy-axis-caption {
  font-size: 11px;
  color: var(--text-muted);
  margin: 0;
}

.psy-axis-caption--y { text-align: right; padding-inline-end: 6px; margin-bottom: 2px; }
.psy-axis-caption--x { text-align: center; margin-top: 2px; }

.psy-axis-label { font-size: 9px; fill: var(--text-muted); }
.psy-curve-label { font-size: 8px; fill: var(--text-muted); opacity: 0.8; }
.psy-point-label { font-size: 10px; font-weight: 600; }

.psy-pressure {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  margin: 2px 0 0;
}

/* The readout under the chart: fixed cells, so the numbers do not jump as the pointer moves. */
.psy-readout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 8px;
  margin: 10px 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.psy-readout__cell { display: flex; flex-direction: column; gap: 2px; }

.psy-readout__label {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.psy-readout__value {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.psy-readout__unit {
  font-size: 10px;
  font-weight: 400;
  color: var(--text-muted);
  margin-inline-start: 3px;
}

/* ---------------------------------------------------------------- procurement

   The supplier directory and the quote comparison. Two pill states carry a claim about whether
   anybody has checked an entry, so they use the status colours the rest of the platform reserves
   for exactly that: saying something is fine, or saying nobody has looked. */

.pill--ok { color: var(--status-good); border-color: var(--status-good); }
.pill--warn { color: var(--status-warning); border-color: var(--status-warning); }

/* A card is a flex column, which stretches its children. A pill that spans the whole card reads as
   a banner rather than as the small status marker it is. */
.card > .pill { align-self: flex-start; }

.badge-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.field--wide { grid-column: 1 / -1; }

.checks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 6px;
}

.check {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.83rem;
  color: var(--text-secondary);
}

.check input { width: auto; margin: 0; }

/* The per-line winners are a second table inside a panel; folded away until asked for. */
.disclosure { margin-top: 10px; }

.disclosure summary {
  cursor: pointer;
  font-size: 0.83rem;
  color: var(--text-secondary);
  padding: 4px 0;
}

.disclosure summary:hover { color: var(--text-primary); }

.site-note { margin-top: 10px; }

.note-list {
  margin: 6px 0 0;
  padding-inline-start: 18px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* ---------------------------------------------------------------- profile charts

   The legend doubles as the control, so it has to read as pressable rather than as a caption. */

.profile-chart { margin-top: 8px; }

.profile-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.profile-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-1);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
}

.profile-legend__item:hover { border-color: var(--border-strong); }

/* A hidden series stays listed — it has to be findable to be switched back on. */
.profile-legend__item--off {
  opacity: 0.45;
  text-decoration: line-through;
}

.profile-legend__swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: none;
}

.profile-axes {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

/* ------------------------------------------------------------------ the printed document */

/*
 * The letterhead, the signature block and the platform's mark: on paper only.
 *
 * They are built at print time and removed afterwards, so on screen they do not exist at all; this
 * rule is the belt to that braces, and keeps them out of the way if a print is interrupted.
 */
.print-only { display: none; }

@media print {
  body.printing .print-only { display: block; }

  body.printing .doc-head {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding-bottom: 10px;
    margin-bottom: 14px;
    border-bottom: 2px solid #12b76a;
  }
  body.printing .doc-head__logo { width: 46px; height: 46px; object-fit: contain; flex: none; }
  body.printing .doc-head__who { display: flex; flex-direction: column; gap: 2px; flex: 1; }
  body.printing .doc-head__who strong { font-size: 1.05rem; color: #000; }
  body.printing .doc-head__who span { font-size: 0.78rem; color: #333; }
  body.printing .doc-head__meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: end;
    font-size: 0.78rem;
    color: #333;
  }
  body.printing .doc-head__meta strong { font-size: 0.92rem; color: #000; }

  body.printing .doc-foot {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-top: 18px;
    padding-top: 12px;
    border-top: 1px solid #bbb;
    /* A signature that lands on its own page, away from what it signs, signs nothing. */
    break-inside: avoid;
    page-break-inside: avoid;
  }
  body.printing .doc-foot__sign { display: flex; flex-direction: column; gap: 3px; min-width: 42%; }
  body.printing .doc-foot__label { font-size: 0.72rem; color: #666; letter-spacing: 0.04em; }
  body.printing .doc-foot__sign strong { font-size: 0.95rem; color: #000; }
  body.printing .doc-foot__sign span { font-size: 0.8rem; color: #333; }
  /* The line somebody signs on, above the word "signature". */
  body.printing .doc-foot__rule {
    display: block;
    height: 28px;
    border-bottom: 1px solid #333;
    margin-top: 6px;
  }

  body.printing .doc-seal { display: flex; flex-direction: column; align-items: center; gap: 6px; max-width: 52%; }
  /* Ink-saving green, and rotated a little: a seal applied by hand is never quite square. */
  body.printing .doc-seal__mark { width: 33mm; height: 33mm; color: #0f5132; transform: rotate(-7deg); }
  body.printing .doc-seal__note { font-size: 0.68rem; color: #555; line-height: 1.5; text-align: center; }
  body.printing .doc-head, body.printing .doc-foot, body.printing .doc-seal__mark {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
/*
 * Showing the working on the nutrient recipe.
 *
 * Growers said the steps were unclear, and the fix was not better prose: it was putting the
 * arithmetic on screen as a table they can hold against the bag in their hand. These rules are what
 * make that table readable — the summed rows standing apart from the rows they sum, and a status
 * column scannable in one pass down the page.
 */

/* The three rows at the foot are the method in miniature, so they must not read as more data. */
.data-table tfoot th,
.data-table tfoot td {
  padding: 10px 13px;
  border-block-start: 1px solid var(--border-strong);
  font-weight: 600;
  background: var(--surface-2);
  white-space: nowrap;
}
.data-table tfoot tr.is-total th,
.data-table tfoot tr.is-total td {
  border-block-start: 2px solid var(--border-strong);
  color: var(--text-primary);
}
.data-table tfoot tr.is-sum td { color: var(--text-secondary); }

.ion-status {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid currentColor;
}
.ion-status.is-ok   { color: var(--status-good); }
.ion-status.is-low  { color: var(--status-warning); }
.ion-status.is-high { color: var(--status-serious); }
.ion-status.is-none { color: var(--text-muted); border-color: transparent; }

/*
 * The balance block is a list of judgements, not a table: each line is one number with the reason
 * it matters beside it, because the number alone tells a grower nothing about what to do.
 */
.balance { display: grid; gap: 2px; }
.balance__row {
  display: grid;
  grid-template-columns: minmax(10rem, auto) minmax(5rem, auto) 1fr;
  gap: 6px 14px;
  align-items: baseline;
  padding: 9px 0;
  border-block-end: 1px solid var(--grid);
}
.balance__row:last-child { border-block-end: 0; }
.balance__label { font-weight: 600; }
.balance__value { font-variant-numeric: tabular-nums; font-weight: 600; }
.balance__note { line-height: 1.6; }
.balance__row.is-off .balance__value { color: var(--status-serious); }

@media (max-width: 640px) {
  .balance__row { grid-template-columns: 1fr auto; }
  .balance__note { grid-column: 1 / -1; }
}

/*
 * The mixing order, for a grower standing at one tank with no A and B drums to keep the calcium
 * away from the sulfate. Sequence is the only protection they have, so it is a numbered list they
 * can work down rather than a table they have to read across.
 */
.mix-order { margin: 0 0 18px; padding-inline-start: 1.4em; display: grid; gap: 14px; }
.mix-step__head { font-weight: 600; margin-block-end: 5px; }
.mix-step__salts { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.mix-step__salts li {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 5px 10px;
  border-radius: 3px;
  background: var(--surface-2);
  font-size: 0.86rem;
}
.mix-step__salts b { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* The concentrate fields appear only when something is being concentrated. */
.form__subgrid { display: contents; }
.form__subgrid[hidden] { display: none; }

/*
 * Turning a fertiliser down, and seeing every element move with it.
 *
 * The dial sits in the weigh-out table beside the weight it scales, because the question a grower
 * asks is always about one bag and the answer is always about the whole recipe.
 */
.dose-dial { display: inline-flex; align-items: baseline; gap: 2px; }
.dose-dial input {
  width: 4.2rem;
  text-align: end;
  padding: 3px 6px;
  font-variant-numeric: tabular-nums;
}
.data-table tr.is-adjusted { background: color-mix(in srgb, var(--status-warning) 10%, transparent); }
.data-table tr.is-adjusted td:first-child { font-weight: 600; }

.diagnose { display: grid; gap: 8px; width: 100%; }
.diagnose__head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.diagnose__head span[dir="ltr"] { font-variant-numeric: tabular-nums; }
.diagnose__from { margin: 0; padding: 0; list-style: none; display: grid; gap: 3px; }
.diagnose__from li {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.diagnose__from b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.diagnose__verdict { margin: 0; font-weight: 600; line-height: 1.7; }

/*
 * Which fertilisers this farm has, ticked inside the designer rather than printed as a catalogue.
 *
 * Folded shut and bordered off, so the section reads as a door into the form rather than another
 * row of it, with the count on the summary: the one thing a grower needs to know without opening
 * it is how many of these the recipe may be built from.
 */
.fert-pick {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-2);
  padding: 10px 12px 12px;
}

.fert-pick > .sub-heading {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 6px;
}

/*
 * The closed control: the button that opens the dialog, the count, and which fertilisers are left
 * out. The last of those is the point — a grower should be able to read the state of the selection
 * without opening anything.
 */
.fert-pick__bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.fert-pick__missing { margin: 0; flex: 1 1 14rem; }

.fert-dialog { display: flex; flex-direction: column; gap: 6px; }

.fert-dialog__head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.fert-dialog__head .fert-pick__tally { margin-inline-end: auto; }

.fert-pick .form__actions { margin-top: 8px; }

/* Two or three to a row where the screen allows, so fifteen of them stay one glance. */
.fert-pick__list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 2px 10px;
}

.fert-pick__tally {
  font-weight: 400;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Nothing ticked means no recipe at all, so the count says so before the button is pressed. */
.fert-pick__tally--none { color: var(--status-critical); }

.fert-pick__group { margin-top: 10px; }

.fert-pick__title {
  margin: 0 0 4px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: none;
}

/*
 * One row per fertiliser: the box, the name, the formula, then its analysis. The analysis is on
 * the row because the choice is not between names — a grower deciding whether they hold "potassium
 * sulfate" is deciding about the bag marked 0-0-50 with 18% sulfur.
 */
.fert-pick__row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 5px 7px;
  border-radius: 3px;
  font-size: 0.82rem;
  cursor: pointer;
}

.fert-pick__row:hover { background: var(--surface-1); }

/*
 * On a phone the list is one column, so fifteen three-line rows would be a long scroll between the
 * water analysis and the calculate button. The formula goes: it is there for a chemist checking
 * the library, and the name is what identifies the sack to everyone else.
 */
@media (max-width: 640px) {
  .fert-pick__row { padding: 4px 6px; gap: 6px; }
  .fert-pick__row .formula { display: none; }
  .fert-pick__row .ion-chip { font-size: 0.68rem; }
}
.fert-pick__row input[type="checkbox"] { width: auto; margin: 0; flex: none; }
.fert-pick__row .ion-list { margin-inline-start: auto; }
.fert-pick__name { font-weight: 600; }
.fert-pick__role { font-size: 0.75rem; }

/*
 * One box per element, labelled in words.
 *
 * The analysis is stored as a single object, and a form generated from that schema offers it as a
 * box of JSON — correct, and unusable by the person holding the bag. Laid out two or three to a
 * row so a fifteen-element label is entered by reading down the card rather than scrolling a
 * column, and the symbol sits beside the name because the bag prints both.
 */
.own-fert__form { display: flex; flex-direction: column; gap: 10px; }

.own-fert__heading {
  margin: 6px 0 0;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.own-fert__analysis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.own-fert__cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-2);
}

.own-fert__name { font-size: 0.78rem; color: var(--text-secondary); }

.own-fert__sym {
  font-size: 0.72rem;
  color: var(--text-secondary);
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}

.own-fert__cell input { width: 100%; }

.own-fert__sum { margin: 2px 0 0; font-size: 0.83rem; }
.own-fert__total { font-weight: 600; font-variant-numeric: tabular-nums; }
.own-fert__total--bad { color: var(--status-critical); }

/*
 * The designer's four steps, numbered.
 *
 * The screen asks for a crop, a water analysis, a store of fertilisers and a tank, in that order,
 * and the number is there so somebody halfway down knows how much is left before the button.
 */
.form-step {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
}

.form-step__n {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--brand-cyan) 18%, var(--surface-2));
  color: var(--text-primary);
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/*
 * What this crop will be fed, before anything is calculated.
 *
 * The ratios belong to the chosen recipe and the strength to the crop's own EC band, so this is
 * the target the solver will be given — printed where the choice is made rather than discovered
 * afterwards in a table of results.
 */
.composition {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-2);
}

.composition__head { margin: 0 0 6px; }
.composition__source { margin: 6px 0 0; font-size: 0.75rem; }

/* The button that produces the recipe, given room so it reads as the end of the form. */
.form__actions--calculate { margin-top: 20px; }

/* A catalogued product the recipe will never reach for: no tick box, so no promise. */
.fert-pick__row--note { cursor: default; opacity: 0.75; padding-inline-start: 26px; }
.fert-pick__row--note:hover { background: none; }

/* A price per kilogram, typed from an invoice. */
.price-row { justify-content: space-between; cursor: default; }
.price-row__box { display: flex; align-items: center; gap: 6px; margin-inline-start: auto; }
.price-row__box input { width: 7rem; }
.price-row__box .muted { font-size: 0.75rem; white-space: nowrap; }

/*
 * The grower's own composition, framed and laid across.
 *
 * Inside the form's grid these twelve boxes inherited a single column and became a column twelve
 * deep, which pushed the rest of the form off the screen and read as a separate form. Four across
 * and three down is the shape of the published table they are copied from. The frame is in the
 * brand's own colour because this block is the one place on the screen where the numbers are the
 * reader's rather than the platform's, and that distinction is worth a border.
 */
.own-recipe {
  grid-column: 1 / -1;
  margin-top: 4px;
  padding: 12px 14px 14px;
  border: 1px solid color-mix(in srgb, var(--brand-cyan) 55%, transparent);
  border-radius: 6px;
  background: color-mix(in srgb, var(--brand-cyan) 7%, var(--surface-2));
}

.own-recipe[hidden] { display: none; }
.own-recipe__head { margin-bottom: 8px; }
.own-recipe__title { margin: 0 0 2px; font-size: 0.86rem; color: var(--text-primary); }
.own-recipe__head p { margin: 0; }

.own-recipe__grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px 12px;
}

.own-recipe__grid .input-grid__cell { display: flex; flex-direction: column; gap: 3px; }
.own-recipe__grid .form__label { font-size: 0.75rem; }

@media (max-width: 760px) {
  .own-recipe__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/*
 * Mulder's chart, drawn against this recipe.
 *
 * The whole chart stays faint so the reader sees the context, and the interactions this particular
 * mix triggers are drawn over it. A node is coloured by where its element landed against target,
 * so the picture and the element table above it tell the same story.
 */
.mulder {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(260px, 1fr);
  gap: 18px;
  align-items: start;
}

.mulder__svg { width: 100%; height: auto; }
.mulder__ring { fill: none; stroke: var(--grid); stroke-width: 1; }

.mulder__edge { stroke-width: 1; }
.mulder__edge--anta { stroke: var(--border-strong); opacity: 0.45; }
.mulder__edge--stim { stroke: var(--status-good); opacity: 0.4; }
.mulder__edge--hot { stroke: var(--status-critical); stroke-width: 2.2; opacity: 1; }

.mulder__node circle {
  fill: var(--surface-2);
  stroke: var(--border-strong);
  stroke-width: 1.4;
}
.mulder__node text {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  fill: var(--text-secondary);
}
.mulder__node.is-high circle { fill: color-mix(in srgb, var(--status-critical) 22%, var(--surface-2)); stroke: var(--status-critical); }
.mulder__node.is-low circle { fill: color-mix(in srgb, var(--status-warning) 20%, var(--surface-2)); stroke: var(--status-warning); }
.mulder__node.is-on_target circle { stroke: var(--status-good); }
.mulder__node.is-high text,
.mulder__node.is-low text { fill: var(--text-primary); }

.mulder__read { display: flex; flex-direction: column; gap: 10px; }
.mulder__legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 0.76rem; color: var(--text-secondary); }
.mulder__legend span { display: inline-flex; align-items: center; gap: 6px; }
.mulder__key { width: 18px; height: 0; border-top-width: 2px; border-top-style: solid; display: inline-block; }
.mulder__key--hot { border-color: var(--status-critical); }
.mulder__key--stim { border-color: var(--status-good); }
.mulder__key--faint { border-color: var(--border-strong); opacity: 0.6; }

@media (max-width: 760px) {
  .mulder { grid-template-columns: 1fr; }
}

/* The one part of the report that says what to do, numbered and marked by kind. */
.advice { margin: 0; padding: 0; list-style: none; counter-reset: advice; }
.advice__item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 7px 0;
  border-block-end: 1px solid var(--grid);
  font-size: 0.86rem;
  line-height: 1.7;
}
.advice__item:last-child { border-block-end: 0; }
.advice__mark {
  flex: none;
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--text-secondary);
}
.advice__item--act .advice__mark { background: color-mix(in srgb, var(--status-warning) 22%, var(--surface-2)); color: var(--status-warning); }
.advice__item--buy .advice__mark { background: color-mix(in srgb, var(--brand-cyan) 20%, var(--surface-2)); }
.advice__item--ok .advice__mark { background: color-mix(in srgb, var(--status-good) 20%, var(--surface-2)); color: var(--status-good); }

/*
 * The brief at the head of the printed report.
 *
 * Hidden on screen, where the form above answers all of it. On paper it is the difference between
 * a document and a page of numbers: which crop, which stage, whose composition, what water.
 */
.brief__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 6px 20px;
}
.brief__item { display: flex; gap: 8px; font-size: 0.84rem; line-height: 1.8; }
.brief__label { color: var(--text-secondary); min-width: 7.5rem; }
.brief__value { font-weight: 600; }

/*
 * The band a row landed in, as a colour on its leading edge.
 *
 * The status word at the end of the row is the precise answer; this is the one the eye finds
 * first. Kept to the three bands the platform actually has, so a colour never means more than the
 * table already says.
 */
.data-table tbody tr.band { border-inline-start: 3px solid transparent; }
.data-table tbody tr.band--high { border-inline-start-color: var(--status-serious); }
.data-table tbody tr.band--low { border-inline-start-color: var(--status-warning); }
.data-table tbody tr.band--on_target { border-inline-start-color: var(--status-good); }

/*
 * ----------------------------------------------------------------------------------------------
 * The report on paper.
 *
 * It printed at seven pages for a one-tank recipe. None of that was content: panels that refused
 * to break left half-empty pages behind them, screen padding sized for a 1400-pixel window was
 * carried onto a 210-millimetre page, the headline figures printed as five cards the size of
 * postcards, and Mulder's chart — a decoration until it says something — took a page to itself.
 *
 * What follows is the same report at a document's proportions: tables that break between rows and
 * repeat their heading, panels at print spacing, one compact chart, and colour used only where it
 * carries meaning the reader would otherwise have to look up.
 */
@media print {
  @page { margin: 14mm 12mm; }

  body.printing { font-size: 9.5pt; line-height: 1.45; }
  body.printing .col-screen { display: none; }

  /*
   * Panels break where they must. "Never break a panel" is right for a single table and wrong for
   * a report made of them: a weigh-out of twenty salts that cannot break pushes a whole page down
   * and leaves the one before it half empty.
   */
  body.printing .panel {
    break-inside: auto;
    page-break-inside: auto;
    padding: 8px 10px;
    margin-bottom: 8px;
    border-radius: 0;
  }
  body.printing .panel__head { margin-bottom: 4px; }
  body.printing .panel h2 { font-size: 11.5pt; margin: 0 0 2px; }
  body.printing .panel h3,
  body.printing .sub-heading { font-size: 10pt; margin: 8px 0 3px; }
  body.printing .panel__note,
  body.printing .muted.small { font-size: 8pt; line-height: 1.4; }

  /* A row is the unit that must not split; the heading repeats on each page the table runs onto. */
  body.printing .table-wrap { break-inside: auto; overflow: visible; }
  body.printing .data-table { font-size: 8.5pt; }
  body.printing .data-table thead { display: table-header-group; }
  body.printing .data-table tr { break-inside: avoid; page-break-inside: avoid; }
  body.printing .data-table th,
  body.printing .data-table td { padding: 3px 6px; }
  body.printing .ion-list { gap: 2px; }
  body.printing .ion-chip { padding: 0 3px; font-size: 7.5pt; }

  /* The headline figures as a strip, not as five cards down the page. */
  body.printing .stat-row { display: flex; flex-wrap: wrap; gap: 6px; }
  body.printing .stat-card { flex: 1 1 110px; padding: 5px 7px; border-width: 1px; }
  body.printing .stat-card__value { font-size: 13pt; }
  body.printing .stat-card__label { font-size: 7.5pt; }

  /* The mixing order: a list of groups, at list spacing. */
  body.printing .mix-order { margin: 4px 0; }
  body.printing .mix-step { margin-bottom: 4px; }
  body.printing .mix-step__head { font-size: 9pt; margin-bottom: 2px; }
  body.printing .mix-step__salts { gap: 2px; }
  /* The step rows are a dark surface on screen; on paper they are a ruled list. */
  body.printing .mix-step__salts li {
    padding: 2px 6px;
    font-size: 8.5pt;
    background: #f6f6f6;
    color: #000;
    border: 1px solid #e3e3e3;
  }
  body.printing .mix-step__head { color: #000; }
  body.printing .note { padding: 5px 7px; font-size: 8.5pt; gap: 6px; }
  body.printing .notes { gap: 4px; }

  /*
   * The chart at the size of a figure in a report: a third of the width, the reading of it beside
   * it, and the whole thing kept on one page because a circle split across a fold is nothing.
   */
  body.printing .mulder {
    grid-template-columns: 58mm 1fr;
    gap: 10px;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  body.printing .mulder__svg { width: 58mm; height: 58mm; }
  /* The viewBox scales to 58mm, so the label is set a little larger to survive the reduction. */
  body.printing .mulder__node text { font-size: 13px; }
  body.printing .mulder__legend { font-size: 7.5pt; gap: 8px; }

  /* The bands, in ink rather than in screen colour. */
  body.printing .data-table tbody tr.band--high { border-inline-start-color: #b42318; }
  body.printing .data-table tbody tr.band--low { border-inline-start-color: #b54708; }
  body.printing .data-table tbody tr.band--on_target { border-inline-start-color: #067647; }
  body.printing .ion-status { border-width: 1px; padding: 0 5px; font-size: 7.5pt; }
  body.printing .ion-status.is-ok { color: #067647; }
  body.printing .ion-status.is-low { color: #b54708; }
  body.printing .ion-status.is-high { color: #b42318; }

  body.printing .advice__item { padding: 4px 0; font-size: 8.5pt; line-height: 1.5; }
  body.printing .brief__item { font-size: 8.5pt; line-height: 1.5; }
  body.printing .brief__grid { gap: 2px 14px; }
  body.printing .steps li { font-size: 8.5pt; line-height: 1.45; }

  /* The report's own sections begin pages; nothing else is forced. */
  body.printing .page-break { break-before: page; page-break-before: always; }
}

/* A counted-by-day chart on the metrics screen: the picture, and a line saying what it counts. */
.metric-figure { margin: 8px 0 14px; }
.metric-figure__title { margin-bottom: 4px; }
