:root {
  --bg: #f1eee6;
  --panel: #fbfaf6;
  --panel-2: #f5f2ea;
  --ink: #1c2420;
  --ink-2: #48534d;
  --muted: #7b847e;
  --line: #dbd5c7;
  --line-2: #e7e2d6;
  --leaf: #2f6b45;
  --leaf-soft: #dce8da;
  --water: #2a7fb8;
  --water-soft: #d9e8f2;
  --sun: #c97d12;
  --sun-soft: #f5e6cb;
  --alert: #cf4427;
  --alert-soft: #f6dbd2;
  --stage: #e8e4d8;
  --dot: rgba(28, 36, 32, .11);
  --logo-bg: #1c2420;
  --logo-fg: #ece6d6;

  --f-display: "Bai Jamjuree", "Anuphan", system-ui, sans-serif;
  --f-body: "Anuphan", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1311;
    --panel: #161b18;
    --panel-2: #1b211e;
    --ink: #e8e4da;
    --ink-2: #b4b9b1;
    --muted: #848b85;
    --line: #2a312d;
    --line-2: #222925;
    --leaf: #74c08b;
    --leaf-soft: #1c3024;
    --water: #61b5ea;
    --water-soft: #152e3d;
    --sun: #eeb14f;
    --sun-soft: #3a2c13;
    --alert: #f2806a;
    --alert-soft: #3d1f18;
    --stage: #131815;
    --dot: rgba(232, 228, 218, .07);
    --logo-bg: #e8e4da;
    --logo-fg: #131815;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; font-family: var(--f-display); }
h2 { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; letter-spacing: .1px; }
h2 .ic { width: 19px; height: 19px; color: var(--ink-2); }
h3 {
  font-family: var(--f-mono); font-size: 11px; font-weight: 500; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); margin: 4px 0 8px;
}
.mono { font-family: var(--f-mono); font-size: .92em; }

.ic {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: max(16px, env(safe-area-inset-top)) 16px 14px;
  max-width: 1240px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 40px; height: 40px; flex: none; }
.logo-bg { fill: var(--logo-bg); }
.logo-leaf { fill: none; stroke: var(--logo-fg); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.logo-drop { fill: var(--water); }
.top h1 { font-size: 21px; font-weight: 700; letter-spacing: .2px; }
.sub { margin: 1px 0 0; color: var(--muted); font-family: var(--f-mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.top-right { display: flex; align-items: center; gap: 8px; }
.status { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.icon-btn {
  border: 1px solid var(--line); background: var(--panel); border-radius: 11px;
  width: 40px; height: 40px; display: grid; place-items: center; cursor: pointer; flex: none;
  color: var(--ink);
}
.icon-btn:hover { border-color: var(--ink-2); }
@media (max-width: 640px) {
  .top { padding-left: 12px; padding-right: 12px; }
  .top-right { width: 100%; justify-content: space-between; align-items: flex-start; }
  .status { justify-content: flex-start; }
}

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--panel);
  padding: 4px 11px 4px 9px; font-size: 12.5px; color: var(--ink-2);
}
.pill b { font-weight: 500; }
.pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: none; }
.pill.ok i { background: var(--leaf); box-shadow: 0 0 0 3px var(--leaf-soft); }
.pill.warn i { background: var(--sun); }
.pill.bad i { background: var(--alert); }
.pill .ic { width: 15px; height: 15px; color: var(--alert); margin-left: -2px; }

/* ---------- 3D stage ---------- */
.stage {
  position: relative; height: 620px;
  max-width: 1208px; margin: 0 16px; border-radius: 22px;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 50% 46%, transparent 0 34%, var(--stage) 78%),
    radial-gradient(var(--dot) 1px, transparent 1.3px) 0 0 / 18px 18px,
    var(--stage);
  overflow: hidden; isolation: isolate;
}
@media (min-width: 1240px) { .stage { margin: 0 auto; } }
.stage-canvas { position: absolute; inset: 0; }
.stage-canvas canvas { display: block; width: 100%; height: 100%; outline: none; cursor: grab; }
.stage-canvas canvas:active { cursor: grabbing; }
.stage.no-3d .stage-canvas::after {
  content: "เบราว์เซอร์นี้แสดงภาพสามมิติไม่ได้ — ค่าต่างๆ ยังอ่านได้ตามปกติ";
  position: absolute; inset: 0; display: grid; place-items: center; padding: 30%;
  text-align: center; color: var(--muted); font-size: 13px;
}
.stage-hint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); margin: 0;
  display: inline-flex; align-items: center; gap: 6px; pointer-events: none;
  font-family: var(--f-mono); font-size: 11px; letter-spacing: .05em; color: var(--muted);
  transition: opacity .6s;
}
.stage-hint .ic { width: 16px; height: 16px; }
.stage.touched .stage-hint { opacity: 0; }
.stage-clock {
  position: absolute; right: 18px; bottom: 12px; margin: 0; pointer-events: none;
  font-family: var(--f-mono); font-size: 11px; color: var(--muted);
}

.leaders { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.ld-line { fill: none; stroke: var(--ink-2); stroke-width: 1; opacity: .55; transition: opacity .3s; }
.ld-dot { fill: var(--ink); }
.ld-ring { fill: none; stroke: var(--ink); stroke-width: 1; opacity: .35; }
.ld.far .ld-line { stroke-dasharray: 3 3; opacity: .3; }
.ld.far .ld-dot { opacity: .45; }
.ld.hot .ld-line { opacity: 1; stroke-width: 1.4; }
.ld.on .ld-dot { fill: var(--water); }
.ld.on .ld-ring { stroke: var(--water); opacity: .9; animation: ping 1.4s ease-out infinite; transform-box: fill-box; transform-origin: center; }
.ld.alert .ld-dot { fill: var(--alert); }
.ld.alert .ld-ring { stroke: var(--alert); opacity: .8; }
@keyframes ping { from { transform: scale(.6); opacity: .9; } to { transform: scale(1.8); opacity: 0; } }

/* callouts — ล็อกตำแหน่งบนจอ ไม่หมุนตามฉาก */
.co-col {
  position: absolute; top: 20px; bottom: 20px; width: 204px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 12px;
  pointer-events: none;
}
.co-a { left: 20px; }
.co-b { right: 20px; }
.co {
  pointer-events: auto; display: flex; gap: 11px; align-items: flex-start;
  padding: 12px 14px 12px 12px; border-radius: var(--r);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  border: 1px solid var(--line);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  color: inherit; text-decoration: none;
  transition: border-color .2s, transform .2s;
}
a.co:hover, .co.hot { border-color: var(--ink-2); }
a.co:active { transform: scale(.985); }
.co-ico {
  width: 34px; height: 34px; border-radius: 10px; flex: none; display: grid; place-items: center;
  background: var(--panel-2); border: 1px solid var(--line-2); color: var(--ink);
}
.co-ico .ic { width: 20px; height: 20px; }
.co-body { display: flex; flex-direction: column; min-width: 0; }
.co-k { font-size: 12.5px; color: var(--ink-2); line-height: 1.3; }
.co-v {
  font-family: var(--f-mono); font-size: 25px; font-weight: 500; line-height: 1.15;
  letter-spacing: -.02em; white-space: nowrap; margin-top: 2px; font-variant-numeric: tabular-nums;
}
.co-v small {
  font-family: var(--f-body); font-size: 12px; font-weight: 500; letter-spacing: 0;
  color: var(--ink-2); margin-left: 6px;
}
.co-v.txt { font-family: var(--f-display); font-size: 19px; font-weight: 600; letter-spacing: 0; padding: 3px 0 2px; }
.co-s { font-size: 11.5px; color: var(--muted); line-height: 1.35; margin-top: 2px; }
.co[data-anchor="temp"] .co-ico { color: var(--alert); }
.co[data-anchor="hum"] .co-ico,
.co[data-anchor="tank"] .co-ico { color: var(--water); }
.co[data-anchor="light"] .co-ico { color: var(--sun); }
.co[data-anchor="mist"] .co-ico,
.co[data-anchor="feed"] .co-ico { color: var(--leaf); }
.co.is-on { border-color: var(--water); }
.co.is-on .co-ico { background: var(--water-soft); border-color: transparent; }
.co.is-alert { border-color: var(--alert); }
.co.is-alert .co-s { color: var(--alert); }
.co.is-alert .co-ico { background: var(--alert-soft); border-color: transparent; color: var(--alert); }

@media (max-width: 900px) and (min-width: 721px) {
  .co-col { width: 172px; }
  .co-v { font-size: 22px; }
}
/* มือถือ: ป้ายเรียงบน 3 ล่าง 3 ฉากอยู่ตรงกลาง */
@media (max-width: 720px) {
  .stage { height: 640px; margin: 0 12px; border-radius: 18px; }
  .stage-canvas { top: 92px; bottom: 92px; }
  .co-col { left: 8px; right: 8px; width: auto; flex-direction: row; gap: 6px; }
  .co-a { top: 8px; bottom: auto; }
  .co-b { bottom: 8px; top: auto; }
  .co { flex: 1 1 0; min-width: 0; flex-direction: column; gap: 4px; padding: 9px 9px 10px; border-radius: 12px; height: 76px; }
  .co-ico { width: auto; height: auto; background: none; border: 0; display: flex; align-items: center; gap: 5px; }
  .co.is-on .co-ico, .co.is-alert .co-ico { background: none; }
  .co-ico .ic { width: 17px; height: 17px; }
  .co-k { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .co-body { width: 100%; }
  .co-v { font-size: 19px; margin-top: 0; }
  .co-v small { font-size: 11px; margin-left: 2px; }
  .co-v .ll { display: none; }
  .co-v.txt { font-size: 15px; padding: 2px 0 0; overflow: hidden; text-overflow: ellipsis; }
  .co-s { display: none; }
  .co { position: relative; }
  .co-ico { position: absolute; top: 9px; right: 8px; }
  .co-k { padding-right: 20px; }
  .stage-hint { bottom: 6px; }
  .stage-clock { display: none; }
}

/* ---------- layout ---------- */
.grid {
  display: grid; gap: 14px; padding: 14px 16px 16px;
  max-width: 1240px; margin: 0 auto;
  grid-template-columns: minmax(0, 1fr);
}
.stack { display: grid; gap: 14px; align-content: start; min-width: 0; }
@media (min-width: 900px) {
  .grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
.detail, .tasks-card, .section-title { grid-column: 1 / -1; }
.section-title {
  margin: 14px 2px -2px; font-size: 13px; font-family: var(--f-mono); font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.section-title .ic { color: var(--muted); width: 17px; height: 17px; }
@media (max-width: 720px) { .grid { padding: 12px; gap: 12px; } }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 16px; min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.head-actions { display: flex; gap: 6px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 10px 0 0; }

.badge {
  font-family: var(--f-mono); font-size: 11.5px; font-weight: 500; padding: 3px 9px; border-radius: 7px;
  background: var(--panel-2); border: 1px solid var(--line-2); color: var(--muted); white-space: nowrap;
}
.badge.ok { background: var(--leaf-soft); border-color: transparent; color: var(--leaf); }
.badge.on { background: var(--water-soft); border-color: transparent; color: var(--water); }
.badge.warn { background: var(--sun-soft); border-color: transparent; color: var(--sun); }
.badge.bad { background: var(--alert-soft); border-color: transparent; color: var(--alert); }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 12px;
  padding: 11px 16px; font-weight: 600; cursor: pointer; min-height: 48px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--f-display); font-size: 15px; letter-spacing: .1px;
  transition: transform .06s, opacity .15s, background .15s;
}
.btn:hover:not(:disabled) { border-color: var(--ink-2); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn.danger { color: var(--alert); border-color: color-mix(in srgb, var(--alert) 45%, transparent); background: transparent; }
.btn.feed { width: 100%; background: var(--leaf); border-color: var(--leaf); color: #fff; min-height: 54px; font-size: 16px; }
@media (prefers-color-scheme: dark) { .btn.feed { color: #0d1a12; } }
.btn.wide { width: 100%; margin-top: 16px; }
.wide-share { width: 100%; }
.btn-row { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; margin-top: 12px; }

.chip {
  border: 1px solid var(--line); background: transparent; border-radius: 9px;
  padding: 5px 11px; font-size: 13px; cursor: pointer; color: var(--ink-2);
}
.chip:hover { border-color: var(--ink-2); color: var(--ink); }
.chip.active { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip.add { margin-top: 8px; border-style: dashed; }
.chip:disabled { opacity: .4; cursor: not-allowed; }
.icon-chip { display: inline-flex; align-items: center; gap: 5px; }
.icon-chip .ic { width: 15px; height: 15px; }
@media (max-width: 420px) { .icon-chip span { display: none; } .icon-chip { padding: 6px 8px; } }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }

.row-input { display: flex; align-items: center; gap: 8px; margin-top: 12px; color: var(--ink-2); font-size: 14px; }
.row-input input { width: 84px; font-family: var(--f-mono); }

input, select {
  border: 1px solid var(--line); background: var(--bg); border-radius: 10px;
  padding: 9px 10px; width: 100%; min-height: 42px;
}
input:focus-visible, select:focus-visible, .btn:focus-visible, .chip:focus-visible, .co:focus-visible, .icon-btn:focus-visible {
  outline: 2px solid var(--water); outline-offset: 2px;
}

/* ---------- tank meter ---------- */
.meter-row { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.meter {
  position: relative; flex: 1; height: 12px; border-radius: 6px; overflow: hidden;
  background: var(--panel-2); border: 1px solid var(--line-2);
}
.water { position: absolute; left: 0; top: 0; bottom: 0; width: 0%; background: var(--water); transition: width .8s ease, background .3s; }
.water.mid { background: var(--sun); }
.water.low { background: var(--alert); }
.meter-line { position: absolute; top: -2px; bottom: -2px; width: 1.5px; background: var(--alert); opacity: .8; }
.meter-info { display: grid; grid-template-columns: auto auto; gap: 0 8px; margin: 0; font-size: 12px; flex: none; }
.meter-info dt { color: var(--muted); }
.meter-info dd { margin: 0; font-family: var(--f-mono); font-size: 11.5px; text-align: right; }

/* ---------- schedules ---------- */
.sched-cols { display: grid; gap: 18px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .sched-cols { grid-template-columns: 1fr 1fr; } }
.sched { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.sched li { display: flex; align-items: center; gap: 6px; }
.sched input { font-family: var(--f-mono); font-size: 14px; }
.sched input[type=time] { flex: 1.3; min-width: 0; }
.sched input[type=number] { flex: 1; min-width: 0; }
.sched .unit { color: var(--muted); font-size: 12px; }
.sched .del { border: 0; background: transparent; color: var(--muted); font-size: 16px; cursor: pointer; padding: 4px 6px; }
.sched .del:hover { color: var(--alert); }
.sched .empty { color: var(--muted); font-size: 13px; }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; z-index: 1; min-height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: .2s; }
.switch span::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + span { background: var(--leaf); }
.switch input:checked + span::after { transform: translateX(16px); }

/* ---------- log ---------- */
.log { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow: auto; font-size: 13px; }
.log li { padding: 7px 0; border-bottom: 1px solid var(--line-2); display: flex; gap: 10px; }
.log li:last-child { border-bottom: 0; }
.log time { color: var(--muted); flex: none; font-family: var(--f-mono); font-size: 11.5px; padding-top: 1px; }
.log .warn { color: var(--sun); }
.log .ok { color: var(--leaf); }
.log .bad { color: var(--alert); }
.log:empty::before { content: "ยังไม่มีเหตุการณ์"; color: var(--muted); font-size: 13px; }

.foot {
  text-align: center; color: var(--muted); font-family: var(--f-mono); font-size: 11px;
  padding: 6px 16px max(22px, env(safe-area-inset-bottom));
}

/* ---------- settings dialog ---------- */
dialog {
  border: 1px solid var(--line); border-radius: 20px; padding: 0; width: min(560px, calc(100% - 24px));
  background: var(--panel); color: var(--ink); max-height: calc(100dvh - 24px);
}
dialog::backdrop { background: rgba(10, 14, 12, .5); backdrop-filter: blur(2px); }
.settings-form { padding: 18px; }
fieldset { border: 1px solid var(--line); border-radius: 12px; margin: 0 0 12px; padding: 10px 12px 12px; }
legend { font-family: var(--f-display); font-weight: 600; padding: 0 6px; }
legend small, label small { color: var(--muted); font-weight: 400; font-family: var(--f-body); }
.settings-form label { display: block; font-size: 13px; margin-top: 8px; color: var(--ink-2); }
.settings-form label input, .settings-form label select { margin-top: 4px; color: var(--ink); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 420px) { .two { grid-template-columns: 1fr; } }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translate(-50%, 160%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px;
  transition: transform .25s; max-width: calc(100% - 32px); z-index: 10;
}
.toast.show { transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .ld.on .ld-ring { animation: none; }
}

/* ---------- toolbar (ตอนนี้ / เป้าหมาย) ---------- */
.toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  max-width: 1240px; margin: 0 auto; padding: 0 16px 12px;
}
.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--panel); border: 1px solid var(--line); }
.seg-btn {
  border: 0; background: transparent; border-radius: 8px; padding: 6px 14px; cursor: pointer;
  font-family: var(--f-display); font-weight: 600; font-size: 14px; color: var(--ink-2);
}
.seg-btn.active { background: var(--ink); color: var(--bg); }
.toolbar-note { margin: 0; flex: 1; color: var(--muted); font-size: 13px; min-width: 0; }
@media (max-width: 720px) { .toolbar { padding: 0 12px 10px; } .toolbar-note { order: 3; flex-basis: 100%; } }

/* ---------- ป้ายตู้ ---------- */
.co { font: inherit; text-align: left; cursor: pointer; width: 100%; }
.co-num { font-family: var(--f-mono); font-weight: 600; font-size: 17px; color: var(--ink); }
.co[data-tone="ok"] .co-num { background: var(--leaf-soft); color: var(--leaf); border-color: transparent; }
.co[data-tone="warn"] .co-num { background: var(--sun-soft); color: var(--sun); border-color: transparent; }
.co[data-tone="info"] .co-num { background: var(--water-soft); color: var(--water); border-color: transparent; }
.co[data-tone="warn"] .co-v { color: var(--sun); }
.co.selected { border-color: var(--water); box-shadow: 0 0 0 1px var(--water) inset; }
.co:hover { border-color: var(--ink-2); }
.co-v.txt { font-size: 16px; white-space: normal; line-height: 1.25; }
.ld.sel .ld-line { opacity: 1; stroke: var(--water); stroke-width: 1.5; }
.ld.sel .ld-dot { fill: var(--water); }
.ld.sel .ld-ring { stroke: var(--water); opacity: .9; }
.ld.dim .ld-line { opacity: .18; }
.ld.dim .ld-dot { opacity: .4; }
@media (max-width: 720px) {
  .co-num { font-size: 13px; padding: 1px 6px; border-radius: 6px; }
  .co-v.txt {
    font-size: 12.5px; font-family: var(--f-body); font-weight: 600;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; white-space: normal;
  }
  .co-k { font-size: 11px; }
}

/* ---------- รายละเอียดตู้ ---------- */
.num {
  display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 6px; border-radius: 8px;
  background: var(--ink); color: var(--bg); font-family: var(--f-mono); font-size: 14px; font-weight: 600;
}
.detail-title { font-size: 19px; gap: 10px; }
.detail-note { margin: -6px 0 14px; color: var(--ink-2); font-size: 14px; }
.detail-grid { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .detail-grid { grid-template-columns: 1.15fr 1fr 1fr; } }
.spec { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; margin: 0; font-size: 14px; align-content: start; }
.spec dt { color: var(--muted); font-size: 12.5px; padding-top: 1px; }
.spec dd { margin: 0; }
.spec small { color: var(--muted); }
.day { margin-left: 6px; padding: 1px 6px; border-radius: 6px; background: var(--water-soft); color: var(--water); font-size: 11.5px; }
.stocks { display: grid; gap: 12px; align-content: start; }
.stocks > div { padding: 10px 12px; border-radius: 12px; border: 1px dashed var(--line); }
.stocks > div.active { border-style: solid; border-color: var(--ink-2); background: var(--panel-2); }
.detail h3 { margin-top: 0; }
.stock { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.stock li { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 2px 10px; font-size: 14px; }
.stock li.empty { display: block; color: var(--muted); font-size: 13px; }
.sp-name small { display: block; color: var(--muted); font-size: 11.5px; }
.sp-note { grid-column: 2 / -1; color: var(--muted); font-size: 12px; line-height: 1.4; }
.sp-dot { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .15); }
.sp-dot[data-sp="coryGreen"] { background: #6f9a5b; }
.sp-dot[data-sp="coryJulii"] {
  background: radial-gradient(circle at 35% 40%, #2a2a28 0 1.5px, transparent 2px),
    radial-gradient(circle at 65% 60%, #2a2a28 0 1.5px, transparent 2px), #d9d5c6;
}
.sp-dot[data-sp="coryAlbino"] { background: #f3d8cb; }
.sp-dot[data-sp="neon"] { background: linear-gradient(#2fd4ff 0 50%, #e5323e 50%); }
.sp-dot[data-sp="shrimp"] { background: #d2382a; }
.sp-dot[data-sp="assassin"] { background: repeating-linear-gradient(90deg, #f2c94c 0 3px, #3b2a1c 3px 6px); }
.plan { margin: 8px 0 0; font-size: 12.5px; color: var(--ink-2); }
.sensors-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.sensors-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line-2); font-size: 13.5px;
}
.sensors-list small { display: block; color: var(--muted); font-size: 11px; font-family: var(--f-mono); }
.sensors-list b.pending { font-weight: 500; font-size: 12px; color: var(--muted); }
.sensors-list b.mono { font-size: 16px; }
.sensors-list + h3 { margin-top: 14px; }
.rules { margin: 0; padding-left: 18px; font-size: 13px; color: var(--ink-2); display: grid; gap: 4px; }
.rules li::marker { color: var(--alert); }

.overview { width: 100%; border-collapse: collapse; font-size: 14px; }
.overview tr { cursor: pointer; border-bottom: 1px solid var(--line-2); }
.overview tr:last-child { border-bottom: 0; }
.overview tr:hover { background: var(--panel-2); }
.overview td { padding: 9px 8px; vertical-align: middle; }
.overview td small { display: block; color: var(--muted); font-family: var(--f-mono); font-size: 11px; }
.overview td:first-child { width: 40px; }
@media (max-width: 640px) { .hide-sm { display: none; } }

/* ---------- งานที่ต้องทำ ---------- */
.tasks-card { display: grid; gap: 4px 28px; grid-template-columns: 1fr; }
.tasks-card > .card-head { grid-column: 1 / -1; }
@media (min-width: 900px) {
  .tasks-card { grid-template-columns: 1.6fr 1fr; }
  .tasks-card .tasks { grid-row: 2 / 6; }
  .tasks-card h3 { margin-top: 0; }
}
.tasks { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; align-content: start; }
.tasks li { display: flex; align-items: flex-start; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.tasks li:last-child { border-bottom: 0; }
.tasks label { display: flex; gap: 10px; flex: 1; cursor: pointer; }
.tasks input { width: 17px; height: 17px; min-height: 0; margin: 2px 0 0; accent-color: var(--leaf); flex: none; }
.tasks li.done span { text-decoration: line-through; color: var(--muted); }
.tank-tag {
  flex: none; border: 1px solid var(--line); background: transparent; border-radius: 7px; cursor: pointer;
  font-family: var(--f-mono); font-size: 11px; padding: 2px 7px; color: var(--ink-2);
}
.tank-tag:hover { border-color: var(--ink-2); }
.tasks-card .stock { margin-bottom: 12px; }
.plain { margin: 0; padding-left: 18px; font-size: 13.5px; color: var(--ink-2); }
