/* ════════════════ ZIWA — smart farm dashboard theme ════════════════ */
/* Brand tokens aligned to ziwaland.com (ziwa.dark #004225 · lime #5BB32E · gold #D4AF37) */
:root {
  --bg: #04140c;
  --bg2: #07190f;
  --card: #11221646;
  --card-solid: #0d2117;
  --edge: #1c4029;
  --edge-soft: #163321;
  --green: #5BB32E;
  --green-soft: #7ACC4E;
  --green-pale: #b5e89a;
  --gold: #D4AF37;
  --text: #e9f5ec;
  --muted: #84a591;
  --muted-2: #5d7a68;
  --amber: #fbbf24;
  --red: #f87171;
  --blue: #38bdf8;
  --mono: "Share Tech Mono", ui-monospace, monospace;
  --r: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  background:
    radial-gradient(1100px 600px at 80% -10%, #14301c55, transparent),
    radial-gradient(900px 500px at -10% 110%, #10281755, transparent),
    var(--bg);
  color: var(--text);
  font-family: "DM Sans", "Inter", system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
}

.mono { font-family: var(--mono); }
.dim { color: var(--muted-2); font-weight: 400; }
.ok { color: var(--green-soft); }
.hidden { display: none !important; }

#dash { display: flex; height: 100vh; }

/* ─────────── sidebar ─────────── */
#sidebar {
  width: 212px; flex: none;
  background: linear-gradient(180deg, #0e1d12, #0b1710);
  border-right: 1px solid var(--edge-soft);
  display: flex; flex-direction: column;
  padding: 20px 14px;
  gap: 18px;
}
.logo { font-weight: 800; font-size: 26px; letter-spacing: 3px; padding-left: 6px; }
.profile {
  display: flex; gap: 10px; align-items: center;
  background: #13271a; border: 1px solid var(--edge-soft);
  border-radius: var(--r); padding: 10px;
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, #5BB32E, #004225);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #04120a;
}
.p-name { font-size: 13px; font-weight: 600; }
.p-role { font-size: 10.5px; color: var(--muted); }
.p-badge { font-size: 9.5px; color: var(--green-soft); margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  font-size: 12.5px; font-weight: 500; color: var(--muted);
  padding: 8px 10px; border-radius: 10px; cursor: pointer;
}
.nav a span { width: 18px; text-align: center; font-size: 13px; filter: grayscale(.4); }
.nav a:hover { background: #14271a; color: var(--text); }
.nav a.on { background: linear-gradient(90deg, #1b3b24, #14271a); color: var(--green-pale); font-weight: 600; }

.side-foot { border-top: 1px solid var(--edge-soft); padding-top: 12px; }
.level { display: flex; gap: 10px; align-items: center; font-size: 12px; }
.level b { display: block; font-size: 13px; }
.level i { font-style: normal; color: var(--muted); font-size: 10.5px; }
.trophy { font-size: 20px; }

/* ─────────── main / header ─────────── */
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; padding: 18px 20px 14px; gap: 14px; }

#welcome { display: flex; align-items: center; gap: 26px; flex: none; }
.hello { font-size: 12px; color: var(--muted); }
#welcome h1 { font-size: 26px; font-weight: 800; line-height: 1.1; }
#welcome .sub { font-size: 11.5px; color: var(--muted-2); }

.head-stats { display: flex; gap: 12px; margin-left: auto; }
.hstat {
  background: var(--card-solid); border: 1px solid var(--edge-soft); border-radius: var(--r);
  padding: 10px 16px; min-width: 122px;
}
.hstat label { display: block; font-size: 8.5px; letter-spacing: 1.5px; color: var(--muted-2); font-weight: 600; }
.hstat b { display: block; font-size: 21px; font-weight: 700; margin: 2px 0 1px; }
.hstat i { font-style: normal; font-size: 9.5px; color: var(--muted); }

.head-meta { display: flex; flex-direction: column; gap: 6px; }
.chip {
  font-size: 10.5px; color: var(--muted); background: var(--card-solid);
  border: 1px solid var(--edge-soft); border-radius: 99px; padding: 4px 10px; white-space: nowrap;
}

/* ─────────── grid of cards ─────────── */
#grid {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 320px;
  grid-template-rows: 1fr 232px;
  grid-template-areas:
    "farm farm farm irr"
    "growth yield roi fai";
  gap: 14px;
}

.card {
  background: linear-gradient(180deg, #11241740, #0e1d1240), var(--card-solid);
  border: 1px solid var(--edge-soft);
  border-radius: var(--r);
  padding: 14px 16px;
  display: flex; flex-direction: column;
  min-height: 0; min-width: 0;
  overflow: hidden;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex: none; }
.card-head h2 { font-size: 14px; font-weight: 700; }
.pill {
  font-size: 9.5px; font-weight: 600; padding: 3px 10px; border-radius: 99px;
  background: #14271a; border: 1px solid var(--edge); color: var(--muted);
  white-space: nowrap;
}
.pill.ok { color: var(--green-soft); border-color: #1f4a2c; }
.pill.warn { color: var(--amber); border-color: #4a3a14; }

/* ─────────── farm card ─────────── */
#farm-card { grid-area: farm; padding-bottom: 10px; }
.head-actions { display: flex; gap: 8px; align-items: center; }

select, input[type="text"], input[type="number"] {
  background: #0d1c12; color: var(--text);
  border: 1px solid var(--edge); border-radius: 9px; padding: 7px 10px;
  font-family: "DM Sans", "Inter", sans-serif; font-size: 12px; outline: none;
}
select:focus, input:focus { border-color: var(--green); }

.btn {
  border-radius: 10px; padding: 7px 13px; font-size: 12px; font-weight: 600;
  font-family: "DM Sans", "Inter", sans-serif; cursor: pointer; border: 1px solid transparent;
  transition: all .15s; white-space: nowrap;
}
.btn.primary { background: var(--green); color: #04120a; }
.btn.primary:hover { background: var(--green-soft); box-shadow: 0 4px 18px #5BB32E44; }
.btn.ghost { background: #14271a; color: var(--text); border-color: var(--edge); }
.btn.ghost:hover { border-color: var(--green); }
.btn.danger-ghost { background: transparent; color: var(--red); border-color: #4a2222; }
.btn.danger-ghost:hover { background: #2a1414; }
.btn.wide { width: 100%; margin-top: 10px; }

.tools-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex: none; flex-wrap: wrap; }
.tools { display: flex; gap: 5px; flex-wrap: wrap; }
.tool {
  font-size: 11.5px; font-weight: 600; font-family: "DM Sans", "Inter", sans-serif;
  background: #0d1c12; color: var(--muted); border: 1px solid var(--edge);
  border-radius: 9px; padding: 6px 10px; cursor: pointer; transition: all .12s;
}
.tool:hover { color: var(--text); border-color: var(--green); }
.tool.on { background: #1b3b24; color: var(--green-pale); border-color: var(--green); }
.tool.danger.on { background: #3b1b1b; color: #fca5a5; border-color: var(--red); }

.tools-right { display: flex; align-items: center; gap: 10px; }
.seg { display: flex; border: 1px solid var(--edge); border-radius: 9px; overflow: hidden; }
.seg button {
  background: transparent; color: var(--muted); border: none;
  font-size: 10.5px; font-weight: 600; font-family: "DM Sans", "Inter", sans-serif;
  padding: 6px 10px; cursor: pointer;
}
.seg button.on { background: #1b3b24; color: var(--green-pale); }
.toggle { display: flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.toggle input { accent-color: var(--green); }
input[type="range"] { accent-color: var(--green); width: 90px; }
#sun-readout { font-size: 11px; color: var(--amber); }

#stage {
  flex: 1; min-height: 0; position: relative;
  border-radius: 12px; overflow: hidden;
  border: 1px solid var(--edge-soft);
}
#scene { width: 100%; height: 100%; display: block; cursor: crosshair; }

#readout { display: flex; justify-content: space-between; gap: 14px; padding-top: 8px; flex: none; overflow: hidden; }
#readout-main { font-size: 10.5px; color: var(--green-pale); white-space: nowrap; }
#readout-hint { font-size: 9.5px; white-space: nowrap; }

/* ─────────── irrigation card ─────────── */
#irr-card { grid-area: irr; }
.irr-body { display: flex; gap: 14px; align-items: center; flex: none; }
.ring-wrap { position: relative; width: 110px; height: 110px; flex: none; }
.ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: #14271a; stroke-width: 9; }
.ring-fg {
  fill: none; stroke: var(--green); stroke-width: 9; stroke-linecap: round;
  stroke-dasharray: 326.7; stroke-dashoffset: 326.7; transition: stroke-dashoffset .6s, stroke .4s;
}
.ring-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-label b { font-size: 20px; font-weight: 800; }
.ring-label i { font-style: normal; font-size: 9px; color: var(--muted); }

.irr-stats { flex: 1; min-width: 0; }
.t-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  font-size: 11.5px; color: var(--muted); padding: 4px 0;
  border-bottom: 1px dashed #16301e;
}
.t-row b { color: var(--text); font-weight: 600; font-size: 11.5px; text-align: right; }

.balance-bar { height: 7px; background: #0d1c12; border-radius: 99px; margin-top: 12px; overflow: hidden; flex: none; }
#balance-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #0ea5e9, #5BB32E); transition: width .4s; border-radius: 99px; }
#balance-label { font-size: 10px; letter-spacing: 1px; margin-top: 5px; color: var(--muted); text-align: center; flex: none; }

.list-head { font-size: 9.5px; letter-spacing: 1.5px; font-weight: 700; color: var(--muted-2); margin: 12px 0 6px; flex: none; }
.well-list { overflow-y: auto; display: flex; flex-direction: column; gap: 5px; min-height: 0; }
.well-list::-webkit-scrollbar { width: 4px; }
.well-list::-webkit-scrollbar-thumb { background: var(--edge); border-radius: 4px; }
.well-list .empty { font-size: 10.5px; color: var(--muted-2); text-align: center; padding: 8px 0; }
.well-item {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; font-weight: 600;
  background: #0d1c12; border: 1px solid var(--edge-soft); border-radius: 9px;
  padding: 7px 10px; cursor: pointer; color: var(--green-pale); transition: all .12s;
  flex: none;
}
.well-item:hover { border-color: var(--green); }
.well-item span.sub { color: var(--muted); font-weight: 400; font-size: 10px; }

/* ─────────── growth / yield / roi cards ─────────── */
#growth-card { grid-area: growth; }
#growth-bars { flex: 1; display: flex; align-items: flex-end; gap: 8px; min-height: 0; padding: 4px 2px; }
.gbar { flex: 1; background: #163420; border-radius: 6px 6px 2px 2px; position: relative; transition: height .4s; min-height: 3px; }
.gbar.lit { background: linear-gradient(180deg, var(--green-soft), #16652f); }
.gbar.cur { outline: 2px solid var(--green-pale); outline-offset: 2px; }
.gbar .v {
  position: absolute; top: -16px; left: 50%; transform: translateX(-50%);
  font-size: 8.5px; color: var(--muted); white-space: nowrap;
}
#growth-card input[type="range"] { width: 100%; margin-top: 8px; flex: none; }
.axis { display: flex; justify-content: space-between; font-size: 8.5px; color: var(--muted-2); padding: 2px 4px 0; flex: none; }

#yield-card { grid-area: yield; }
.yield-big { display: flex; align-items: baseline; gap: 8px; margin: 2px 0 8px; }
.yield-big b { font-size: 34px; font-weight: 800; color: var(--green-soft); }
.yield-big span { font-size: 12px; color: var(--muted); }

#roi-card { grid-area: roi; }
#fai-card { grid-area: fai; overflow-y: auto; }
#fai-card .yield-big b { font-size: 26px; }
#fai-tiers .t-row { font-size: 10px; }
#fai-tiers .t-row b { font-size: 10px; }
.roi-big { display: flex; align-items: baseline; gap: 8px; margin: 0 0 6px; }
.roi-big b { font-size: 30px; font-weight: 800; }
.roi-big span { font-size: 11px; color: var(--muted); }
.row-2 { display: flex; gap: 6px; margin-top: 8px; }
.row-2 .btn { flex: 1; padding: 6px 4px; font-size: 11px; }

/* ─────────── modal ─────────── */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(3, 10, 6, .65); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }
.modal-card { width: 430px; max-width: 94vw; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 10px; font-weight: 600; letter-spacing: .5px; color: var(--muted); }
.form-grid label.span2 { grid-column: span 2; }
.computed { margin-top: 12px; padding: 9px; font-size: 11px; color: var(--amber); border: 1px dashed #4a3a14; border-radius: 9px; text-align: center; }
.modal-actions { display: flex; justify-content: space-between; margin-top: 14px; }

/* ─────────── toasts ─────────── */
#toasts { position: fixed; bottom: 22px; right: 22px; z-index: 70; display: flex; flex-direction: column; gap: 7px; align-items: flex-end; }
.toast {
  font-size: 11.5px; font-weight: 600;
  background: #122a1a; border: 1px solid var(--green); color: var(--green-pale);
  border-radius: 10px; padding: 9px 15px; animation: toast-in .2s ease-out;
  box-shadow: 0 8px 24px #0008;
}
.toast.warn { border-color: var(--amber); color: var(--amber); }
.toast.err { border-color: var(--red); color: var(--red); }
.toast.out { opacity: 0; transition: opacity .5s; }

/* ─────────── boot ─────────── */
#boot {
  position: fixed; inset: 0; z-index: 100; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  transition: opacity .6s;
}
#boot.done { opacity: 0; pointer-events: none; }
#boot-log { font-family: var(--mono); font-size: 13px; color: var(--green-soft); line-height: 1.9; min-width: 380px; }
#boot-log .ok { color: var(--green-pale); }

@keyframes toast-in { from { transform: translateX(20px); opacity: 0; } }

/* ─────────── embed mode (?embed=1 — iframe inside ziwaland.com) ─────────── */
body.embed #sidebar { display: none; }
body.embed #welcome > div:first-child { display: none; }  /* mock greeting */
body.embed .head-meta { display: none; }
body.embed .head-stats { margin-left: 0; width: 100%; }
body.embed .hstat { flex: 1; }
body.embed #main { padding: 12px 14px 10px; }

@media (max-width: 1480px) {
  .head-meta { display: none; }
  #grid { grid-template-columns: 1fr 1fr 1fr 290px; }
}
@media (max-width: 1280px) {
  #sidebar { width: 64px; }
  #sidebar .profile, #sidebar .side-foot, .nav a { font-size: 0; }
  .nav a span { font-size: 14px; }
  .logo { font-size: 16px; letter-spacing: 1px; }
  .profile { justify-content: center; }
  .profile > div { display: none; }
}
