/* Farm site. Tokens follow the Pulse design system: ink first, white cards,
   black primary buttons, blue only to mark the active item. */
:root {
  --bg: #FBFBFC; --card: #FFFFFF; --line: #EEF0F3; --line2: #E2E5EA;
  --ink: #0B0F19; --ink2: #5C6473; --ink3: #9099A8;
  --accent: #2563EB; --crit: #B42318; --warn: #B54708;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1113; --card: #181B1F; --line: #262A2F; --line2: #343A41;
    --ink: #E8E8E8; --ink2: #A3A8B0; --ink3: #7A808A;
    --accent: #60A5FA; --crit: #F97066; --warn: #FDB022;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1113; --card: #181B1F; --line: #262A2F; --line2: #343A41;
  --ink: #E8E8E8; --ink2: #A3A8B0; --ink3: #7A808A;
  --accent: #60A5FA; --crit: #F97066; --warn: #FDB022;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 400 15px/1.45 Inter, system-ui, -apple-system, sans-serif;
  font-feature-settings: "tnum";
  -webkit-font-smoothing: antialiased;
}
.h { font-family: Manrope, system-ui, sans-serif; font-weight: 800; letter-spacing: -.025em; margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* header */
.top {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px; padding-top: 14px; padding-bottom: 14px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; min-width: 0; }
.brand .h { font-size: 18px; }
.meta { font-size: 13px; color: var(--ink3); }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.switch { font-size: 14px; color: var(--ink2); text-decoration: none; padding: 8px 12px; border-radius: 8px; }
.switch:hover { color: var(--ink); background: var(--line); }
button.ghost {
  font: 500 14px Inter, system-ui, sans-serif; color: var(--ink);
  background: var(--card); border: 1px solid var(--line2); border-radius: 8px;
  padding: 8px 12px; cursor: pointer;
}

/* layout: nav on the left, screen on the right */
.layout {
  display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px;
  max-width: 1200px; margin: 0 auto; padding-top: 24px; padding-bottom: 48px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  align-items: start;
}
#nav { display: flex; flex-direction: column; gap: 2px; min-width: 0; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
#nav a { font-size: 14px; color: var(--ink2); text-decoration: none; padding: 8px 10px; border-radius: 8px; }
#nav a:hover { color: var(--ink); background: var(--line); }
#nav a[aria-current="page"] {
  color: var(--accent); background: var(--card); font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--line2);
}
.screen { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.screen.all { gap: 48px; }
.page-block { display: flex; flex-direction: column; gap: 16px; min-width: 0; scroll-margin-top: 16px; }
.screen-title { font-size: 22px; margin: 0; }
.sgrp { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink3); padding: 14px 10px 4px; }
#nav .sgrp:first-child { padding-top: 0; }
.phone-wrap { max-width: 390px; margin: 0 auto; width: 100%; }

/* investor login: only the form */
body.login-screen .layout { grid-template-columns: minmax(0, 1fr); max-width: 440px; }
body.login-screen #nav,
body.login-screen .switch,
body.login-screen .meta { display: none; }

/* cards and sections */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; min-width: 0; }
.section { display: flex; flex-direction: column; gap: 12px; }
.section h2 { font: 700 16px/1.3 Manrope, system-ui, sans-serif; letter-spacing: -.01em; margin: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; min-width: 0; }
.lbl { font-size: 13px; color: var(--ink3); }
.sec-note { font-size: 13px; color: var(--ink2); margin: 0; }
.note { font-size: 12px; color: var(--ink3); margin: 0; }

/* numbers */
.big { font: 800 28px/1.15 Manrope, system-ui, sans-serif; letter-spacing: -.025em; }
.huge { font: 800 44px/1.05 Manrope, system-ui, sans-serif; letter-spacing: -.03em; }
.xl { font-size: clamp(44px, 10vw, 72px); }
.big-screen { padding: 40px 28px; gap: 14px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi { display: flex; flex-direction: column; gap: 4px; padding: 16px; }
.kpi .val { font: 800 26px/1.15 Manrope, system-ui, sans-serif; letter-spacing: -.02em; }
.kpi .cap { font-size: 12px; color: var(--ink3); }
.kpis-compact { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.kpis-compact .kpi { padding: 12px; }
.kpis-compact .val { font-size: 18px; }

/* bars and stacked share */
.bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ink); border-radius: 999px; }
.seg { display: flex; height: 14px; border-radius: 999px; overflow: hidden; gap: 2px; }
.seg i { display: block; height: 100%; min-width: 4px; }
.s1 { background: var(--ink); }
.s2 { background: var(--ink2); }
.s3 { background: var(--ink3); }
.s4 { background: var(--line2); }

/* rows and tables */
.row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px;
}
.row:first-child { border-top: 0; padding-top: 0; }
.row b { font-weight: 600; text-align: right; }
.wrapx { overflow-x: auto; min-width: 0; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 500; font-size: 13px; color: var(--ink3); white-space: nowrap; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* payback */
.pb { display: flex; flex-direction: column; gap: 6px; padding: 12px 0; border-top: 1px solid var(--line); }
.pb-top { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.pb-top span { color: var(--ink2); font-variant-numeric: tabular-nums; }

/* alerts: colour plus a text label */
.alerts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.alerts li { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; }
.dot { flex: none; width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; background: var(--ink3); }
.d-crit { background: var(--crit); }
.d-warn { background: var(--warn); }
.tag { font-weight: 600; white-space: nowrap; }

/* chart: fact solid, plan dashed, horizontal grid only */
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--line2); stroke-width: 1; }
.chart .axis { font-family: Inter, system-ui, sans-serif; font-size: 22px; fill: var(--ink3); }
.chart .plan { fill: none; stroke: var(--ink3); stroke-width: 3; stroke-dasharray: 10 8; stroke-linejoin: round; stroke-linecap: round; }
.chart .fact { fill: none; stroke: var(--ink); stroke-width: 4; stroke-linejoin: round; stroke-linecap: round; }
.chart .pt { fill: var(--ink); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--ink2); }
.legend > span { display: inline-flex; align-items: center; gap: 8px; }
.legend i { display: inline-block; width: 26px; border-top: 4px solid var(--ink); }
.legend .lp { border-top: 3px dashed var(--ink3); }

/* forms, errors, invite links. [hidden] wins over the display set by the classes above. */
[hidden] { display: none !important; }
.error { color: var(--crit); font-size: 14px; margin: 0; }
.error:empty { display: none; }
.sub { font: 700 14px/1.3 Manrope, system-ui, sans-serif; margin: 14px 0 2px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.inline-form label { display: flex; flex-direction: column; gap: 6px; flex: 1 1 220px; min-width: 0; font-size: 13px; color: var(--ink2); }
.inline-form input,
.inline-form select {
  width: 100%; min-width: 0; font: 15px Inter, system-ui, sans-serif; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line2); border-radius: 10px; padding: 10px 12px;
}
.inline-form .btn { flex: none; }
.invite-link {
  font: 13px/1.45 ui-monospace, Menlo, Consolas, monospace; word-break: break-all;
  background: var(--bg); border: 1px solid var(--line2); border-radius: 8px; padding: 10px 12px;
}
button.small { padding: 6px 10px; font-size: 13px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
button.ghost:hover { background: var(--line); }

/* investor login */
.login {
  display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 360px; margin: 24px auto 0;
  padding: 24px; background: var(--card); border: 1px solid var(--line); border-radius: 12px;
}
.login label { font-size: 13px; color: var(--ink2); }
.login input {
  font: 16px Inter, system-ui, sans-serif; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line2); border-radius: 10px; padding: 12px 14px; min-width: 0;
}
.btn {
  font: 600 15px Inter, system-ui, sans-serif; color: var(--card); background: var(--ink);
  border: 0; border-radius: 10px; padding: 12px 16px; cursor: pointer;
}
.btn-block { width: 100%; }

/* phone width: single column, nav scrolls sideways, no page scroll */
@media (max-width: 760px) {
  .top { padding-top: 12px; padding-bottom: 12px; }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 16px; padding-top: 16px; padding-bottom: 16px; }
  #nav { flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 4px; position: static; max-height: none; }
  #nav .sgrp { display: none; }
  #nav a { flex: none; white-space: nowrap; border: 1px solid var(--line); }
  .huge { font-size: 38px; }
}
