/* Agri Control Center. Tokens dealt by tasteskill: palette blue-black-cornflower, type host,
   radius soft, buttons arrow, mark dots. Motion follows the kit's tokens (motion.md). */

@font-face { font-family: "Host Grotesk"; src: url("/static/fonts/host-grotesk-latin-wght-normal.woff2") format("woff2-variations"); font-weight: 300 800; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("/static/fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2-variations"); font-weight: 100 800; font-display: swap; }

:root {
  --p-bg: #0a0d14; --p-surface: #131824; --p-ink: #e9edf3; --p-muted: #8891a1;
  --p-accent: #5ab9fc; --p-action: #5ab9fc; --p-action-ink: #0a0d14;
  --surface-2: #1a2030;
  --line: rgba(233, 237, 243, .09); --line-strong: rgba(233, 237, 243, .22);
  --ok: #4cc38a; --warn: #f0b429; --bad: #ff7a70;
  --font-text: "Host Grotesk", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --r-lg: 16px; --r-md: 12px; --r-sm: 8px; --r-btn: 10px;
  --btn-h: 44px;
  --ease: cubic-bezier(.2, .8, .2, 1); --ease-enter: cubic-bezier(.22, 1, .36, 1);
  --m-in: 150ms; --m-out: 120ms; --m-press: 90ms;
  --side-w: 256px;
  /* names app.js reads for charts */
  --bg: var(--p-bg); --panel: var(--p-surface); --ink: var(--p-ink); --muted: var(--p-muted); --accent: var(--p-accent);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--p-bg); color: var(--p-ink); font: 400 15px/1.5 var(--font-text); -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
.muted { color: var(--p-muted); } .small { font-size: 13px; }
code { font-family: var(--font-mono); font-size: .9em; }
h1, h2, h3 { font-weight: 500; letter-spacing: -0.02em; margin: 0; }
h1 { font-size: clamp(26px, 2.4vw, 34px); letter-spacing: -0.035em; line-height: 1.1; }
h2 { font-size: 17px; margin-bottom: 14px; }
h3 { font-size: 15px; }

/* links: one look, a faint hairline and an ink line that draws on hover */
a { color: inherit; text-decoration: none; }
.view a:not(.btn):not(.tabs a), .link {
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat, linear-gradient(var(--line-strong), var(--line-strong)) 0 100% / 100% 1px no-repeat;
  transition: background-size var(--m-out) var(--ease);
}
@media (hover: hover) and (pointer: fine) {
  .view a:not(.btn):not(.tabs a):hover, .link:hover { background-size: 100% 1px, 100% 1px; transition-duration: var(--m-in); }
}

/* focus: 2px ring in the action colour, 2px off, never animated */
:focus-visible { outline: 2px solid var(--p-action); outline-offset: 2px; transition: none; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--p-action); color: var(--p-action-ink); padding: 10px 16px; border-radius: var(--r-btn); font-weight: 500; }
.skip:focus { top: 12px; }

/* brand + dealt mark (dots) */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -0.01em; font-size: 16px; }
.mark { width: 22px; height: 22px; flex: none; background: var(--p-ink);
  -webkit-mask: url("/static/favicon.svg") center / contain no-repeat; mask: url("/static/favicon.svg") center / contain no-repeat; position: relative; }
.mark::after { content: ""; position: absolute; right: 0; bottom: 0; width: 9.2px; height: 9.2px; border-radius: 1.5px; background: var(--p-accent); }

/* ---------------------------------------------------------------- buttons (look: arrow) */
.btn {
  font: 500 15px/1 var(--font-text); min-height: var(--btn-h); padding: 0 6px; border-radius: var(--r-btn);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; cursor: pointer;
  border: 1px solid transparent; background: none; color: var(--p-ink);
  text-decoration: underline; text-underline-offset: 5px; text-decoration-color: var(--line-strong);
  transition: transform var(--m-out) var(--ease), background-color var(--m-out) var(--ease), text-decoration-color var(--m-out) var(--ease);
}
.btn::after { content: ""; flex: none; width: 12px; height: 12px; margin-right: -2px; background: currentColor;
  -webkit-mask: var(--glyph) center / contain no-repeat; mask: var(--glyph) center / contain no-repeat; transition: transform var(--m-out) var(--ease);
  --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M1.5 6h8.5M6.5 2.5 10 6l-3.5 3.5' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.btn:not(.primary)::after { display: none; }
.btn.primary { background: var(--p-action); color: var(--p-action-ink); text-decoration: none; padding: 0 24px; }
.btn.wide { width: 100%; }
.btn.small { min-height: 36px; font-size: 14px; padding: 0 4px; }
.btn.danger { color: var(--bad); text-decoration-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.btn:disabled { opacity: .5; cursor: default; }
@media (hover: hover) and (pointer: fine) {
  .btn:not(:disabled):hover { text-decoration-color: currentColor; transition-duration: var(--m-in); }
  .btn:not(:disabled):hover::after { transform: translateX(3px); transition-duration: var(--m-in); }
  .btn.primary:not(:disabled):hover { background: color-mix(in srgb, var(--p-action) 86%, var(--p-ink)); transform: translateY(-1px); }
}
.btn:not(:disabled):active { transform: translateY(1px) scale(.985); transition-duration: var(--m-press); }
.btn:not(.primary):not(:disabled):active { transform: scale(.985); }

/* ---------------------------------------------------------------- fields */
.field { display: grid; gap: 8px; }
label { font-size: 14px; font-weight: 500; }
input, select {
  font: inherit; min-height: 44px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--p-bg); color: var(--p-ink); transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease);
}
input:focus-visible, select:focus-visible { outline: none; border-color: var(--p-action); box-shadow: 0 0 0 3px color-mix(in srgb, var(--p-action) 28%, transparent); }
.error { color: var(--bad); margin: 0; min-height: 1.5em; font-size: 14px; }

/* ---------------------------------------------------------------- sign in */
.login { min-height: 100vh; min-height: 100svh; display: grid; grid-template-columns: 7fr 5fr; }
.login__intro {
  padding: clamp(28px, 5vw, 72px); display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
  border-right: 1px solid var(--line);
  background:
    radial-gradient(60% 50% at 0% 100%, color-mix(in srgb, var(--p-accent) 14%, transparent), transparent 70%),
    var(--p-bg);
}
.login__h1 { font-size: clamp(44px, 6.4vw, 96px); letter-spacing: -0.045em; line-height: .98; font-weight: 500; margin-top: auto; }
.login__h1 .line { display: block; padding-block: .16em; margin-block: -.16em; }
.login__h1 .line + .line { color: var(--p-muted); }
.login__lead { font-size: 18px; max-width: 34ch; color: var(--p-muted); margin: 0; }
.login__apps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, max-content); gap: 10px 22px; font-size: 14px; color: var(--p-muted); }
.login__apps li { display: flex; align-items: center; gap: 8px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--app); box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.login__form { align-self: center; justify-self: center; width: min(400px, 100% - 48px); display: grid; gap: 20px; padding: 40px 0; }
.login__form h2 { font-size: 24px; margin: 0; }

/* one entrance on load: lines rise out of their masks, then the rest fades up 12px */
@media (prefers-reduced-motion: no-preference) {
  .login:not(.hidden) .login__h1 .line { overflow: hidden; }
  .login:not(.hidden) .login__h1 .line > span { display: inline-block; animation: rise 700ms var(--ease-enter) both; }
  .login:not(.hidden) .login__h1 .line + .line > span { animation-delay: 80ms; }
  .login:not(.hidden) :is(.login__lead, .login__apps, .login__form) { animation: up 520ms var(--ease-enter) both; animation-delay: 380ms; }
  .login:not(.hidden) .login__apps { animation-delay: 440ms; }
  .login:not(.hidden) .login__form { animation-delay: 500ms; }
}
@keyframes rise { from { transform: translateY(105%); } }
@keyframes up { from { opacity: 0; transform: translateY(12px); } }

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; background: linear-gradient(to right, var(--p-surface) calc(var(--side-w) - 1px), var(--line) 0 var(--side-w), transparent 0); }
.topbar { display: none; }
.side {
  background: var(--p-surface); border-right: 1px solid var(--line); padding: 22px 16px;
  display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.side__brand { padding: 0 10px; }
.side nav { display: grid; gap: 2px; }
.side nav a {
  min-height: 40px; padding: 0 10px 0 14px; border-radius: var(--r-sm); display: flex; align-items: center; gap: 10px;
  color: var(--p-muted); position: relative; transition: color var(--m-out) var(--ease), background-color var(--m-out) var(--ease);
}
.side nav a::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2px; border-radius: 2px; background: var(--p-accent); transform: scaleY(0); }
@media (hover: hover) and (pointer: fine) { .side nav a:hover { color: var(--p-ink); background: rgba(233,237,243,.04); transition-duration: var(--m-in); } }
.side nav a[aria-current="page"] { color: var(--p-ink); background: rgba(233,237,243,.06); }
.side nav a[aria-current="page"]::before { transform: none; }
.nav-label { font: 500 13px/1 var(--font-text); color: var(--p-muted); margin: 20px 14px 8px; }
.side-foot { margin-top: auto; display: grid; gap: 4px; padding: 14px 10px 0; border-top: 1px solid var(--line); }
.side-foot .btn { justify-self: start; }
#me { overflow-wrap: anywhere; }

.view { padding: 36px clamp(20px, 3vw, 44px) 72px; max-width: 1360px; width: 100%; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.page-head .sub { color: var(--p-muted); margin-top: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- panels, stats */
.panel { background: var(--p-surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 20px; min-width: 0; }
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0; background: var(--p-surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.g4 > .panel { border: 0; border-radius: 0; background: none; box-shadow: 1px 0 0 var(--line), 0 1px 0 var(--line); }
.g3 { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.g2 { grid-template-columns: repeat(auto-fill, minmax(460px, 1fr)); }
.stack { display: grid; gap: 22px; }

.stat .label { color: var(--p-muted); font-size: 13px; }
.stat .value { font: 500 26px/1.15 var(--font-mono); letter-spacing: -0.03em; margin-top: 8px; font-variant-numeric: tabular-nums; }
.stat .hint { font-size: 13px; color: var(--p-muted); margin-top: 6px; }
.stat.alert .value { color: var(--bad); }
.stat .cfg { font-size: 13px; color: var(--warn); margin-top: 6px; }

.app-card { display: grid; gap: 18px; position: relative; overflow: hidden; }
.app-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--app, var(--p-accent)); }
.app-card .top { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.app-card h2 { margin-bottom: 4px; }
.app-card .kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.app-card .kpis .value { font-size: 19px; }
.app-card .foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 14px; font-size: 13px; color: var(--p-muted); }
.app-card .foot a { color: var(--p-ink); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--p-muted); flex: none; }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }
.dot.warn { background: var(--warn); }
.pill { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; padding: 4px 10px; border-radius: 99px; background: var(--p-bg); border: 1px solid var(--line); white-space: nowrap; }
.tag { font: 500 13px/1 var(--font-text); padding: 6px 9px; border-radius: 6px; background: var(--p-bg); color: var(--p-muted); border: 1px solid var(--line); margin: 2px 4px 2px 0; display: inline-block; }
button.tag { cursor: pointer; min-height: 32px; background: none; border-color: transparent; color: color-mix(in srgb, var(--p-muted) 75%, transparent); transition: border-color var(--m-out) var(--ease), color var(--m-out) var(--ease), background-color var(--m-out) var(--ease); }
@media (hover: hover) and (pointer: fine) { button.tag:hover { border-color: var(--line-strong); color: var(--p-ink); } }
.tag.on, button.tag.on { background: var(--p-accent); color: var(--p-action-ink); border-color: var(--p-accent); }
@media (hover: hover) and (pointer: fine) { button.tag.on:hover { color: var(--p-action-ink); border-color: var(--p-ink); } }

/* tabs (software): the active tab is an ink pill */
.tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 22px; background: var(--p-surface); border: 1px solid var(--line); border-radius: calc(var(--r-sm) + 4px); width: max-content; max-width: 100%; overflow-x: auto; }
.tabs a { min-height: 38px; display: inline-flex; align-items: center; padding: 0 16px; border-radius: var(--r-sm); color: var(--p-muted); white-space: nowrap; transition: color var(--m-out) var(--ease); }
@media (hover: hover) and (pointer: fine) { .tabs a:hover { color: var(--p-ink); } }
.tabs a.active { background: var(--p-ink); color: var(--p-bg); font-weight: 500; }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font: 500 13px/1.2 var(--font-text); color: var(--p-muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td.num, th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
tbody tr { transition: background-color var(--m-out) var(--ease); }
@media (hover: hover) and (pointer: fine) { tbody tr:hover { background: rgba(233,237,243,.025); } }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; margin: 0 -8px; padding: 0 8px; }

.meter { height: 6px; background: var(--p-bg); border-radius: 99px; overflow: hidden; margin-top: 14px; }
.meter > span { display: block; height: 100%; background: var(--p-accent); border-radius: 99px; }
.meter.warn > span { background: var(--warn); } .meter.bad > span { background: var(--bad); }

.chart-box { position: relative; height: 260px; }
.spark { position: relative; height: 44px; min-width: 140px; }
.note { font-size: 13px; color: var(--warn); }
.toolbar { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input { min-width: min(320px, 100%); }

dialog { border: 1px solid var(--line-strong); border-radius: var(--r-lg); background: var(--p-surface); color: var(--p-ink); width: min(1000px, 94vw); padding: 0; }
dialog::backdrop { background: rgba(5, 7, 12, .7); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 15px; }
dialog pre { margin: 0; padding: 16px 18px; max-height: 70vh; overflow: auto; font: 12px/1.55 var(--font-mono); white-space: pre-wrap; word-break: break-all; }

/* ---------------------------------------------------------------- tablet and phone */
@media (max-width: 1000px) {
  .login { grid-template-columns: 1fr; }
  .login__apps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .login__intro { border-right: 0; border-bottom: 1px solid var(--line); min-height: 52svh; }
  .login__form { padding: 36px 0 56px; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; background: none; }
  .topbar { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 20; height: 60px; padding: 0 16px; background: var(--p-surface); border-bottom: 1px solid var(--line); }
  .menu-btn { font: 500 15px var(--font-text); color: var(--p-ink); background: none; border: 1px solid var(--line-strong); border-radius: var(--r-btn); min-height: 44px; padding: 0 16px; cursor: pointer; }
  .side { position: fixed; inset: 60px 0 0 0; height: auto; z-index: 19; border-right: 0; opacity: 0; visibility: hidden; transform: translateY(-6px); transition: opacity 120ms var(--ease), transform 120ms var(--ease), visibility 0s 120ms; }
  .side.open { opacity: 1; visibility: visible; transform: none; transition: opacity 200ms var(--ease), transform 200ms var(--ease); }
  .side__brand { display: none; }
  .side nav a { min-height: 48px; font-size: 16px; }
  .view { padding: 24px 16px 56px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .scroll-scrim { overflow: hidden; }
}
@media (max-width: 520px) {
  .g4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat .value { font-size: 21px; }
  .panel { padding: 16px; }
  .page-head .btn { width: 100%; justify-content: flex-start; }
  .app-card .kpis { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 360px) { .g4 { grid-template-columns: 1fr; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-property: opacity, color, background-color, border-color, text-decoration-color !important; }
  .btn:active { transform: none; }
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* status error text: one line; full text in the title */
td .note.small { max-width: 32ch; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 6px; }
.page-head .sub .btn { min-height: 32px; margin-left: 4px; }

@media (max-width: 640px) {
  .table-wrap { margin: 0; padding: 0; overflow: visible; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-wrap tr { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .table-wrap tr:last-child { border-bottom: 0; }
  .table-wrap td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; align-items: center; gap: 16px; text-align: right; }
  .table-wrap td.num { justify-content: space-between; }
  .table-wrap td::before { content: attr(data-label); color: var(--p-muted); font: 400 13px/1.4 var(--font-text); text-align: left; flex: none; }
  .table-wrap td:not([data-label])::before, .table-wrap td[data-label=""]::before { content: none; }
  .table-wrap td:first-child { font-weight: 500; text-align: left; justify-content: flex-start; }
  .table-wrap td:first-child::before { content: none; }
  .table-wrap td > div { text-align: right; }
  td .note.small { max-width: 60vw; }
  .spark { min-width: 120px; width: 50%; }
}

/* ---------------------------------------------------------------- every device and orientation */
/* notches and rounded corners (phones in landscape) */
.topbar { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
@media (max-width: 900px) {
  .view { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); padding-bottom: max(56px, env(safe-area-inset-bottom)); }
  .side { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); overscroll-behavior: contain; }
}
.login__intro { padding-left: max(clamp(28px, 5vw, 72px), env(safe-area-inset-left)); }
/* heights follow the browser's own bars as they show and hide */
.side { height: 100dvh; }
.login { min-height: 100dvh; }

/* four headline numbers: one row, or two by two, never three and one */
.g4:has(> :nth-child(4):last-child) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g4:has(> :nth-child(4):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* stacked rows: long values wrap instead of pushing the page sideways */
@media (max-width: 640px) {
  .table-wrap td { flex-wrap: wrap; min-width: 0; overflow-wrap: anywhere; }
  .table-wrap td:has(button.tag) { justify-content: flex-start; gap: 4px 6px; }
  .table-wrap td:has(button.tag)::before { width: 100%; margin-bottom: 2px; }
  .table-wrap td:has([data-ban]) { justify-content: flex-start; }
}

/* short screens (phones on their side): keep sign-in side by side, tighten the bars */
@media (orientation: landscape) and (max-height: 560px) {
  .login { grid-template-columns: 1fr 1fr; }
  .login__intro { border-right: 1px solid var(--line); border-bottom: 0; min-height: 0; padding-top: 24px; padding-bottom: 24px; gap: 16px; }
  .login__h1 { font-size: clamp(30px, 6vh + 1vw, 48px); }
  .login__lead { font-size: 15px; }
  .login__apps { grid-template-columns: repeat(3, max-content); gap: 6px 16px; font-size: 13px; }
  .login__form { padding: 20px 0; gap: 14px; width: min(360px, 100% - 40px); }
  .topbar { height: 52px; }
  .side { inset: 52px 0 0 0; }
  .side nav a { min-height: 44px; }
  .view { padding-top: 18px; }
  .page-head { margin-bottom: 18px; }
}
@media (max-width: 900px) { .side { height: auto; } }
