:root {
  color-scheme: dark;
  --bg: #07111f;
  --surface: #101d31;
  --surface-2: #152640;
  --surface-3: #1b3152;
  --line: #2a456c;
  --text: #eef7ff;
  --muted: #9fb4cc;
  --cyan: #54d7ff;
  --blue: #5793ff;
  --green: #55dda4;
  --yellow: #ffd166;
  --orange: #ff9f5a;
  --red: #ff7088;
  --purple: #a78bfa;
  --shadow: 0 18px 44px rgba(0, 0, 0, .26);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 8% -10%, rgba(87,147,255,.22), transparent 30%),
    radial-gradient(circle at 92% 0%, rgba(85,221,164,.12), transparent 28%),
    var(--bg);
}

a { color: inherit; }

button, input, select, textarea { font: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 12px clamp(18px, 4vw, 52px);
  border-bottom: 1px solid rgba(84,215,255,.18);
  background: rgba(7,17,31,.88);
  backdrop-filter: blur(14px);
}

.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: linear-gradient(135deg, var(--blue), var(--green)); }
.top-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.page { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 30px 0 64px; }

.hero {
  display: grid;
  grid-template-columns: 1.5fr .8fr;
  gap: 22px;
  align-items: stretch;
  margin-bottom: 22px;
}

.hero-card, .panel, .lab-card, .notice {
  border: 1px solid rgba(123,167,219,.2);
  background: linear-gradient(145deg, rgba(21,38,64,.96), rgba(13,27,47,.96));
  box-shadow: var(--shadow);
}

.hero-card { padding: clamp(24px, 4vw, 44px); border-radius: 24px; }
.eyebrow { color: var(--cyan); font-size: 13px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1 { margin: 10px 0 12px; font-size: clamp(30px, 5vw, 56px); line-height: 1.08; }
h2, h3 { margin-top: 0; }
.lead { margin: 0; max-width: 760px; color: #c6d7e8; font-size: clamp(16px, 2vw, 20px); line-height: 1.75; }

.hero-side { display: grid; gap: 12px; }
.metric { padding: 18px; border-radius: 18px; background: rgba(16,29,49,.9); border: 1px solid rgba(123,167,219,.2); }
.metric strong { display: block; margin-top: 6px; color: var(--green); font-size: 24px; }

.notice { margin: 18px 0; padding: 14px 18px; border-left: 4px solid var(--yellow); border-radius: 14px; color: #dce9f5; }
.notice strong { color: var(--yellow); }
.notice.danger { border-left-color: var(--red); }
.notice.danger strong { color: var(--red); }

.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.lab-card { display: flex; flex-direction: column; gap: 12px; min-height: 270px; padding: 24px; border-radius: 22px; }
.lab-card:hover { transform: translateY(-2px); border-color: rgba(84,215,255,.5); transition: .2s ease; }
.lab-card .icon { font-size: 34px; }
.lab-card p { margin: 0; color: var(--muted); line-height: 1.65; }
.lab-card .tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }

.tag, .pill { display: inline-flex; align-items: center; width: fit-content; padding: 5px 10px; border-radius: 999px; background: rgba(84,215,255,.1); color: #aeeeff; border: 1px solid rgba(84,215,255,.22); font-size: 12px; }
.pill.green { color: #a8f4cf; background: rgba(85,221,164,.1); border-color: rgba(85,221,164,.25); }
.pill.yellow { color: #ffe39a; background: rgba(255,209,102,.1); border-color: rgba(255,209,102,.25); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: white;
  text-decoration: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--blue), #7a67f8);
  box-shadow: 0 8px 24px rgba(87,147,255,.22);
}
.button:hover { filter: brightness(1.08); }
.button.secondary { background: rgba(84,215,255,.08); border-color: rgba(84,215,255,.3); box-shadow: none; }
.button.ghost { background: transparent; border-color: rgba(159,180,204,.28); box-shadow: none; color: #cfdeec; }
.button.warn { background: linear-gradient(135deg, #ef8354, #ff5f7c); }
.button.small { min-height: 34px; padding: 6px 10px; border-radius: 9px; font-size: 13px; }

.lab-layout { display: grid; grid-template-columns: minmax(280px, .78fr) minmax(0, 1.45fr); gap: 18px; }
.stack { display: grid; gap: 18px; align-content: start; }
.panel { padding: 22px; border-radius: 20px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.panel-head h2, .panel-head h3 { margin: 0; }
.panel-head p { margin: 5px 0 0; color: var(--muted); }

.controls { display: grid; gap: 17px; }
.control { display: grid; gap: 8px; }
.control-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.control label { color: #dceafb; font-weight: 700; }
.value { color: var(--cyan); font-variant-numeric: tabular-nums; font-weight: 800; }
input[type="range"] { width: 100%; accent-color: var(--cyan); }
input[type="number"], input[type="text"], select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--text);
  background: #0b1729;
  border: 1px solid #294361;
  border-radius: 10px;
}
textarea { min-height: 90px; resize: vertical; }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
.kpi { padding: 14px; border-radius: 14px; background: rgba(7,17,31,.52); border: 1px solid rgba(123,167,219,.18); }
.kpi span { display: block; color: var(--muted); font-size: 12px; }
.kpi strong { display: block; margin-top: 5px; font-size: 21px; font-variant-numeric: tabular-nums; }

.chart-wrap { position: relative; min-height: 310px; margin-top: 14px; padding: 12px; border-radius: 16px; background: #091629; border: 1px solid rgba(84,215,255,.15); }
canvas.chart { width: 100%; height: 285px; display: block; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: 5px; border-radius: 50%; }

.table-wrap { overflow-x: auto; border: 1px solid rgba(123,167,219,.18); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; min-width: 660px; }
th, td { padding: 11px 12px; border-bottom: 1px solid rgba(123,167,219,.14); text-align: left; font-size: 13px; }
th { color: #b9d4ec; background: rgba(7,17,31,.52); }
tbody tr:last-child td { border-bottom: 0; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

.sim-stage { position: relative; min-height: 250px; overflow: hidden; border-radius: 18px; background: linear-gradient(#193b5d 0 48%, #75523a 48% 100%); border: 1px solid rgba(84,215,255,.18); }
.sun { position: absolute; top: 25px; right: 38px; width: 58px; height: 58px; border-radius: 50%; background: #ffd166; box-shadow: 0 0 42px rgba(255,209,102,.6); }
.plant { position: absolute; left: 50%; bottom: 26px; width: 130px; height: 150px; transform: translateX(-50%); }
.stem { position: absolute; left: 63px; bottom: 0; width: 8px; height: 92px; border-radius: 8px; background: #58c885; transform-origin: bottom; transition: .4s ease; }
.leaf { position: absolute; width: 54px; height: 32px; background: #55dda4; border-radius: 100% 0 100% 0; transition: .4s ease; }
.leaf.a { left: 12px; top: 66px; transform: rotate(14deg); }
.leaf.b { right: 9px; top: 42px; transform: rotate(196deg); }
.leaf.c { left: 18px; top: 22px; transform: rotate(30deg) scale(.8); }
.sensor { position: absolute; left: 18px; bottom: 25px; padding: 8px 10px; border-radius: 10px; background: rgba(7,17,31,.84); border: 1px solid var(--cyan); color: var(--cyan); font-size: 12px; }
.pump { position: absolute; right: 20px; bottom: 25px; padding: 9px 12px; border-radius: 12px; background: rgba(7,17,31,.84); border: 1px solid var(--blue); }
.pump.on { color: white; background: rgba(87,147,255,.65); box-shadow: 0 0 24px rgba(87,147,255,.55); }

.filter-builder { display: grid; gap: 10px; }
.filter-layer { display: grid; grid-template-columns: 40px 1fr 110px 84px; gap: 10px; align-items: center; padding: 10px; border-radius: 12px; background: rgba(7,17,31,.5); border: 1px solid rgba(123,167,219,.18); }
.layer-index { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: rgba(84,215,255,.12); color: var(--cyan); font-weight: 800; }
.tower { width: 210px; margin: 0 auto; padding: 18px 18px 26px; border: 3px solid #7ba7db; border-top: 0; border-radius: 0 0 30px 30px; background: rgba(255,255,255,.06); }
.tower-water { height: 46px; display: grid; place-items: center; color: #4a2c1e; background: #a7784e; border-radius: 10px 10px 3px 3px; font-weight: 800; }
.tower-layer { min-height: 38px; display: grid; place-items: center; color: #07111f; font-weight: 800; border-top: 2px solid rgba(7,17,31,.2); }
.tower-out { width: 80px; height: 70px; margin: 6px auto 0; border: 2px solid #7ba7db; border-top: 0; border-radius: 0 0 14px 14px; background: linear-gradient(to top, rgba(84,215,255,.45) 65%, transparent 65%); }

.checklist { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.checklist li { padding: 12px 14px 12px 42px; position: relative; border-radius: 12px; background: rgba(7,17,31,.45); color: #d8e5f2; }
.checklist li::before { content: "✓"; position: absolute; left: 14px; color: var(--green); font-weight: 900; }

.footer { margin-top: 32px; color: var(--muted); text-align: center; font-size: 12px; }

@media (max-width: 850px) {
  .hero, .lab-layout { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 560px) {
  .page { width: min(100% - 20px, 1180px); padding-top: 18px; }
  .topbar { padding: 10px 12px; }
  .brand span:last-child { display: none; }
  .panel { padding: 16px; }
  .filter-layer { grid-template-columns: 34px 1fr; }
  .filter-layer input, .filter-layer .button { grid-column: 2; }
}

@media print {
  :root { color-scheme: light; }
  body { color: #111; background: white; }
  .topbar, .controls, .button-row, .notice { display: none !important; }
  .page { width: 100%; padding: 0; }
  .panel, .hero-card { color: #111; background: white; box-shadow: none; border: 1px solid #bbb; break-inside: avoid; }
  .table-wrap { border-color: #aaa; }
  th, td { color: #111; border-color: #ccc; }
}
