/*
 * 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;
}
.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; }

  /* 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;
}
