/* Grow — the shared base of the new design: colours (dark + light),
 * the navigation rail, buttons, form controls, dialogs and toasts.
 * Every page of the new design loads this; the overview adds next.css. */

/* Grow — the new overview. Self-contained: shares nothing with style.css. */

:root {
  --bg: #08090d;
  --bg-2: #0d0f15;
  --surface: #12141c;
  --surface-2: #181b25;
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.12);
  --text: #eef1f6;
  --text-2: #b8bfcc;
  --muted: #7b8496;
  --faint: #4b5262;

  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --water: #60a5fa;
  --night: #a78bfa;

  --veg: #34d399;
  --stretch: #a78bfa;
  --bulk: #fbbf24;
  --finish: #fb7185;
  --empty: #64748b;

  --r-xl: 22px;
  --r-lg: 16px;
  --r-md: 12px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 20px 40px -24px rgba(0, 0, 0, 0.8);
  --num: "Space Grotesk", "Inter", system-ui, sans-serif;
  color-scheme: dark;
}
[data-theme="light"] {
  /* Soft light: blue-grey paper instead of white, so it does not glare,
     with the same blue / green / amber / violet as the dark theme. */
  --bg: #e6ebf2;
  --bg-2: #dde3ec;
  --surface: #f1f4f8;
  --surface-2: #e9eef5;
  --line: rgba(32, 56, 96, 0.10);
  --line-2: rgba(32, 56, 96, 0.18);
  --text: #18212f;
  --text-2: #364357;
  --muted: #5d6a7e;
  --faint: #8d99ab;
  --good: #0f9f6e;
  --warn: #c7790a;
  --bad: #d23c3c;
  --water: #2f6fd6;
  --night: #7353d6;
  --veg: #0f9f6e;
  --stretch: #7353d6;
  --bulk: #c7790a;
  --finish: #cf3f68;
  --empty: #7a8699;
  --shadow: 0 1px 2px rgba(24, 33, 47, 0.05), 0 10px 26px -18px rgba(24, 33, 47, 0.25);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }

/* ===== Navigation: a rail on the left, a tab bar on phones ===== */
.nav {
  position: fixed; inset: 0 auto 0 0;
  width: 84px;
  display: flex; flex-direction: column; align-items: center;
  gap: 4px;
  padding: 16px 0;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  z-index: 20;
}
.nav-logo img { width: 40px; height: 40px; border-radius: 12px; display: block; margin-bottom: 14px; }
.nav-item {
  width: 68px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 0 8px;
  border-radius: 14px;
  color: var(--muted);
  font-size: 11px; font-weight: 500;
  background: none; border: 0; cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item:hover { color: var(--text); background: var(--surface); }
.nav-item.active { color: var(--text); background: var(--surface-2); }
.nav-item.active svg { color: var(--water); }
.nav-spacer { flex: 1; }

/* ===== Toasts, dialogs, drawer, popover ===== */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  background: var(--surface); border: 1px solid var(--line-2); color: var(--text);
  border-radius: 12px; padding: 10px 14px; font-size: 13px; box-shadow: var(--shadow);
  transform: translateY(8px); opacity: 0; transition: all .2s; max-width: 360px;
}
.toast.in { transform: none; opacity: 1; }
.toast.ok { border-left: 3px solid var(--good); }
.toast.bad { border-left: 3px solid var(--bad); }

.dlg-back, .drw-back {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(3, 5, 10, 0.55);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .2s;
}
.dlg-back { z-index: 80; display: grid; place-items: center; padding: 16px; }
.dlg-back.in, .drw-back.in { opacity: 1; }
.dlg {
  width: min(400px, 100%);
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 18px; padding: 20px; box-shadow: 0 30px 60px -20px rgba(0,0,0,.6);
}
.dlg-title { font: 600 17px/1.3 var(--num); }
.dlg-text { color: var(--text-2); margin-top: 8px; font-size: 13.5px; }
.dlg-input { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.dlg-input input {
  flex: 1; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; font: 600 16px var(--num);
}
.dlg-input span { color: var(--muted); }
.dlg-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.btn {
  border-radius: 10px; padding: 8px 14px; font-weight: 600; font-size: 13px;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text); cursor: pointer;
}
.btn.primary { background: var(--text); color: var(--bg); border-color: transparent; }
.btn.danger  { background: var(--bad); color: #fff; border-color: transparent; }
.btn.ghost   { background: transparent; }

/* Panels open as a window in the middle of the screen (full screen on phones).
   Centred with grid, not transform, so a full-screen chart inside still
   covers the whole screen. */
.drw-back { display: grid; place-items: center; padding: 3vh 2vw; }
.drw {
  position: relative;
  width: min(940px, 100%); max-height: 94vh;
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 22px;
  box-shadow: 0 40px 90px -30px rgba(0,0,0,.7);
  transform: translateY(10px) scale(.98); transition: transform .2s;
  overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column;
}
.drw-back.in .drw { transform: none; }
.drw .tp-head { border-radius: 22px 22px 0 0; }
body.no-scroll { overflow: hidden; }

.pop {
  position: fixed; z-index: 90; min-width: 240px; max-width: 320px;
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 14px; padding: 6px; box-shadow: 0 24px 50px -16px rgba(0,0,0,.6);
}
.pop-item {
  display: flex; gap: 10px; align-items: flex-start; width: 100%;
  background: none; border: 0; border-radius: 10px; padding: 8px 10px;
  text-align: left; cursor: pointer; color: var(--text);
}
.pop-item:hover { background: var(--surface-2); }
.pop-item.danger .pop-t { color: var(--bad); }
.pop-ico { width: 20px; text-align: center; flex: 0 0 auto; }
.pop-t { display: block; font-weight: 600; font-size: 13px; }
.pop-d { display: block; font-size: 11.5px; color: var(--muted); }
.pop-sep { height: 1px; background: var(--line); margin: 4px 6px; }

.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { background: none; border: 0; color: var(--muted); font-weight: 600; font-size: 12px; padding: 5px 10px; border-radius: 7px; cursor: pointer; }
.seg button.on { background: var(--surface-2); color: var(--text); box-shadow: 0 0 0 1px var(--line-2); }
/* forms inside panels */
.form { display: flex; flex-direction: column; gap: 14px; }
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; cursor: pointer;
}
.switch-row b { display: block; font-size: 14px; }
.switch-row small { color: var(--muted); font-size: 12px; }
.switch-row input { display: none; }
.switch { width: 44px; height: 26px; border-radius: 99px; background: var(--line-2); position: relative; flex: 0 0 auto; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch-row input:checked + .switch { background: var(--good); }
.switch-row input:checked + .switch::after { transform: translateX(18px); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.form-grid label {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px;
  color: var(--muted); font-size: 12.5px;
}
.form-grid input {
  width: 64px; margin-left: auto; text-align: right;
  background: transparent; border: 0; color: var(--text); font: 600 17px var(--num);
}
.form-grid input:focus { outline: none; }
.ti-preview { color: var(--text-2); font-size: 13px; background: var(--surface); border: 1px dashed var(--line-2); border-radius: 12px; padding: 10px 12px; }

.form-h { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-top: 4px; }
.form-grid select, .form-grid input.wide, .form-grid input[type="date"] {
  margin-left: auto; background: transparent; border: 0; color: var(--text);
  font: 600 14px "Inter", sans-serif; text-align: right; min-width: 0;
}
.form-grid input.wide { width: 60%; font-family: var(--num); }
.form-grid select:focus, .form-grid input:focus { outline: none; }
.form-grid select option { background: var(--surface); color: var(--text); }
.form-grid label:focus-within { border-color: var(--water); }

.ico { flex: 0 0 auto; vertical-align: -0.15em; }
.pop-ico { color: var(--muted); display: inline-flex; padding-top: 1px; }
.pop-item:hover .pop-ico { color: var(--text); }
.btn:disabled { opacity: .4; cursor: default; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: 0 0 auto; display: inline-block; }
.dot.on { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 22%, transparent); }
.dot.bad { background: var(--bad); }

/* ===== A normal scrolling page (Feed, Valves, …) ===== */
.page.sub { margin-left: 84px; padding: 24px 28px 48px; max-width: 1180px; }
.sub-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.sub-head h1 { margin: 0; font: 700 26px/1.1 var(--num); letter-spacing: -0.03em; }
.sub-head p { margin: 6px 0 0; color: var(--muted); font-size: 13.5px; max-width: 640px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 12px; font: 600 14px/1.2 "Inter", sans-serif; color: var(--text-2); }

@media (max-width: 760px) {
  .nav {
    inset: auto 0 0 0; width: auto; height: calc(64px + env(safe-area-inset-bottom));
    flex-direction: row; justify-content: space-around;
    padding: 6px 6px env(safe-area-inset-bottom);
    border-right: 0; border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--bg-2) 88%, transparent);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  }
  .nav-logo, .nav-spacer, #theme-btn { display: none; }
  .nav-item { width: auto; flex: 1; min-width: 0; padding: 6px 0; font-size: 10px; }
  .page.sub { margin-left: 0; padding: 16px 12px 96px; }
  .sub-head h1 { font-size: 22px; }
  .drw-back { padding: 0; }
  .drw { width: 100%; height: 100%; max-height: none; border: 0; border-radius: 0; }
  .drw .tp-head { border-radius: 0; }
  .form-grid { grid-template-columns: 1fr; }
}
