/* Greenhouse digital twin — pairs with greenhouse.js. Uses tokens from styles.css. */

.gh, .gh-dialog, .gh-toast {
  --gh-ok: #2f9e44;
  --gh-ok-soft: rgba(47, 158, 68, 0.1);
  --gh-warn: #d97706;
  --gh-warn-soft: rgba(217, 119, 6, 0.12);
  --gh-danger: #dc2626;
  --gh-danger-soft: rgba(220, 38, 38, 0.1);
  --gh-leaf-soft: rgba(16, 185, 129, 0.08);
  --gh-soil: #8d5524;
  --gh-air: #0c8599;
}

.gh {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.gh[hidden] { display: none; }

.gh h2, .gh h3 { font-family: var(--font-display); margin: 0; color: var(--text); }
.gh h2 { font-size: 1.35rem; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.gh h3 { font-size: 1rem; display: flex; align-items: center; gap: 0.5rem; }
.gh code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8em; direction: ltr; unicode-bidi: embed; }
.gh-fine { color: var(--dim); font-size: 0.82rem; margin: 0.25rem 0 0; }
.gh-unit { color: var(--dim); font-size: 0.75rem; font-weight: 500; font-family: var(--font-body); }

.lvl-ok { color: var(--gh-ok); }
.lvl-warn { color: var(--gh-warn); }
.lvl-danger { color: var(--gh-danger); }

/* ── Buttons & segmented controls ───────────────────────── */
.gh-btn {
  font: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  min-height: 40px;
  padding: 0.45rem 0.95rem;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--bg1);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.gh-btn:hover { background: var(--bg-elevated); }
.gh-btn:active { transform: translateY(1px); }
.gh-btn:focus-visible, .gh-seg button:focus-visible, .gh-house:focus-visible, .gh-link:focus-visible { outline: 3px solid var(--leaf-border); outline-offset: 2px; }
.gh-btn.primary { background: var(--leaf); border-color: var(--leaf); color: #fff; }
.gh-btn.primary:hover { background: #047857; }
.gh-btn.ghost { background: transparent; }
.gh-btn.small { min-height: 34px; padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.gh-btn.danger-ghost { background: transparent; color: var(--gh-danger); border-color: transparent; }
.gh-btn.danger-ghost:hover { background: var(--gh-danger-soft); }
.gh-btn:disabled { opacity: 0.6; cursor: progress; }
.gh-link { font: inherit; font-size: 0.82rem; color: var(--leaf); background: none; border: 0; padding: 0.2rem 0.3rem; cursor: pointer; font-weight: 600; }
.gh-link:hover { text-decoration: underline; }
.gh-back { font: inherit; font-weight: 600; color: var(--muted); background: none; border: 0; cursor: pointer; padding: 0.3rem 0; }
.gh-back:hover { color: var(--leaf); }

.gh-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

.gh-seg { display: inline-flex; background: var(--bg-elevated); border-radius: 10px; padding: 3px; gap: 2px; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.gh-seg::-webkit-scrollbar { display: none; }
.gh-seg.wrap { flex-wrap: wrap; overflow: visible; margin-bottom: 0.6rem; }
.gh-seg button { font: inherit; font-size: 0.8rem; font-weight: 600; border: 0; background: transparent; color: var(--muted); padding: 0.35rem 0.7rem; border-radius: 8px; cursor: pointer; white-space: nowrap; min-height: 32px; }
.gh-seg button.on { background: var(--bg1); color: var(--text); box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12); }

/* ── Pills, chips, dots ─────────────────────────────────── */
.gh-pill { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.72rem; font-weight: 700; padding: 0.15rem 0.6rem; border-radius: 999px; font-family: var(--font-body); white-space: nowrap; }
.gh-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.gh-pill.st-ok { background: var(--gh-ok-soft); color: var(--gh-ok); }
.gh-pill.st-warn { background: var(--gh-warn-soft); color: var(--gh-warn); }
.gh-pill.st-danger { background: var(--gh-danger-soft); color: var(--gh-danger); }
.gh-pill.st-danger::before { animation: gh-pulse 1.6s infinite; }
.gh-pill.st-empty { background: var(--bg-elevated); color: var(--dim); }
@keyframes gh-pulse { 50% { opacity: 0.25; } }

.gh-chip { display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 0.15rem 0.55rem; border-radius: 999px; background: var(--bg-elevated); color: var(--muted); margin: 0; }
.gh-chip.lvl-ok { background: var(--gh-ok-soft); color: var(--gh-ok); }
.gh-chip.lvl-warn { background: var(--gh-warn-soft); color: var(--gh-warn); }
.gh-chip.lvl-danger { background: var(--gh-danger-soft); color: var(--gh-danger); }
.gh-count { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--gh-danger); color: #fff; font-size: 0.75rem; font-weight: 700; display: inline-grid; place-items: center; }
.gh-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-inline-end: 0.35rem; vertical-align: middle; }
.gh-dot.on { background: var(--gh-ok); box-shadow: 0 0 0 3px var(--gh-ok-soft); }
.gh-dot.off { background: #94a3b8; }
.gh-kind { display: inline-block; font-size: 0.68rem; font-weight: 700; padding: 0.05rem 0.45rem; border-radius: 6px; }
.gh-kind.climate { background: rgba(12, 133, 153, 0.12); color: var(--gh-air); }
.gh-kind.soil { background: rgba(141, 85, 36, 0.12); color: var(--gh-soil); }

/* ── Layout blocks ──────────────────────────────────────── */
.gh-toolbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.gh-panel { background: var(--bg1); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow-card); min-width: 0; }
.gh-panel > h3 { margin-bottom: 0.75rem; }
.gh-panel-head { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.75rem; }

.gh-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; }
.gh-kpi { background: var(--bg1); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.8rem 1rem; display: flex; flex-direction: column; gap: 0.15rem; }
.gh-kpi .v { font-family: var(--font-display); font-size: 1.5rem; font-weight: 800; line-height: 1.2; }
.gh-kpi .v small { font-size: 0.9rem; color: var(--dim); font-weight: 600; }
.gh-kpi .l { color: var(--muted); font-size: 0.8rem; }
.gh-kpi[role="button"] { cursor: pointer; }
.gh-kpi.alert { border-color: rgba(220, 38, 38, 0.3); }
.gh-kpi.alert .v { color: var(--gh-danger); }

/* ── House cards (overview) ─────────────────────────────── */
.gh-houses { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.gh-house { background: var(--bg1); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1rem; display: flex; flex-direction: column; gap: 0.7rem; cursor: pointer; box-shadow: var(--shadow-card); transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s; border-top: 4px solid var(--line); }
.gh-house:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-2px); }
.gh-house.st-ok { border-top-color: var(--gh-ok); }
.gh-house.st-warn { border-top-color: var(--gh-warn); }
.gh-house.st-danger { border-top-color: var(--gh-danger); }
.gh-house.inactive { opacity: 0.65; }
.gh-house header { display: flex; justify-content: space-between; gap: 0.5rem; align-items: flex-start; }
.gh-house header p { margin: 0.15rem 0 0; color: var(--dim); font-size: 0.8rem; }
.gh-house-badges { display: flex; gap: 0.35rem; align-items: center; flex-shrink: 0; }
.gh-house footer { display: flex; justify-content: space-between; color: var(--dim); font-size: 0.78rem; border-top: 1px dashed var(--line); padding-top: 0.55rem; }
.gh-mini-twin { border-radius: 12px; background: #f1f5f4; padding: 0.35rem; }

.gh-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.4rem; }
.gh-m { background: var(--bg0); border-radius: 10px; padding: 0.4rem 0.5rem; display: flex; flex-direction: column; border: 1px solid transparent; }
.gh-m .l { font-size: 0.68rem; color: var(--dim); }
.gh-m .v { font-family: var(--font-display); font-weight: 700; font-size: 0.98rem; color: var(--text); white-space: nowrap; }
.gh-m.lvl-warn { border-color: rgba(217, 119, 6, 0.35); background: var(--gh-warn-soft); }
.gh-m.lvl-danger { border-color: rgba(220, 38, 38, 0.35); background: var(--gh-danger-soft); }
.gh-tip { margin: 0; font-size: 0.82rem; line-height: 1.5; padding: 0.45rem 0.6rem; border-radius: 10px; background: var(--bg0); color: var(--muted); border-inline-start: 3px solid var(--line-strong); }
.gh-tip.lvl-danger { border-color: var(--gh-danger); color: var(--text); background: var(--gh-danger-soft); }
.gh-tip.lvl-warn { border-color: var(--gh-warn); color: var(--text); background: var(--gh-warn-soft); }

.gh-tray-list { display: flex; flex-direction: column; gap: 0.5rem; }
.gh-tray-item { display: grid; grid-template-columns: auto 1fr auto auto; gap: 0.75rem; align-items: center; padding: 0.55rem 0.7rem; border: 1px dashed var(--line-strong); border-radius: 10px; }
.gh-tray-item code { display: block; color: var(--dim); }

/* ── Twin (floor plan) ──────────────────────────────────── */
.gh-twin { background: #eef3f1; border-radius: 14px; padding: 0.5rem; }
.gh-twin-svg { width: 100%; height: auto; display: block; max-height: 62vh; touch-action: none; user-select: none; }
.gh-twin-svg.mini { max-height: 150px; pointer-events: none; }
.gh-floor { fill: #dfe7e3; }
.gh-heat { opacity: 0.78; }
.gh-shell { fill: none; stroke: #2f4f3a; vector-effect: non-scaling-stroke; stroke-width: 2px; }
.gh-hoop { stroke: rgba(15, 23, 42, 0.16); vector-effect: non-scaling-stroke; stroke-width: 1px; }
.gh-ridge { stroke: rgba(15, 23, 42, 0.35); vector-effect: non-scaling-stroke; stroke-width: 1px; stroke-dasharray: 6 4; }
.gh-gutter { stroke: rgba(15, 23, 42, 0.45); vector-effect: non-scaling-stroke; stroke-width: 1.5px; }
.gh-door { fill: #f8fafc; stroke: #2f4f3a; vector-effect: non-scaling-stroke; stroke-width: 1px; }
.gh-tick { stroke: #64748b; vector-effect: non-scaling-stroke; stroke-width: 1px; }
.gh-tick-label { fill: #64748b; text-anchor: middle; font-family: var(--font-body); }

.gh-node { cursor: pointer; }
.gh-node-halo { fill: rgba(255, 255, 255, 0.35); }
.gh-node-dot { fill: #fff; stroke: var(--gh-ok); vector-effect: non-scaling-stroke; stroke-width: 3px; }
.gh-node-glyph { fill: var(--gh-ok); }
.gh-node.lvl-warn .gh-node-dot { stroke: var(--gh-warn); }
.gh-node.lvl-warn .gh-node-glyph { fill: var(--gh-warn); }
.gh-node.lvl-danger .gh-node-dot { stroke: var(--gh-danger); }
.gh-node.lvl-danger .gh-node-glyph { fill: var(--gh-danger); }
.gh-node.lvl-danger .gh-node-halo { fill: rgba(220, 38, 38, 0.22); animation: gh-pulse 1.6s infinite; }
.gh-node.muted .gh-node-dot { stroke: #64748b; }
.gh-node.muted .gh-node-glyph { fill: #64748b; }
.gh-node.offline .gh-node-dot { stroke: #94a3b8; stroke-dasharray: 3 3; fill: #e2e8f0; }
.gh-node.offline .gh-node-glyph { fill: #94a3b8; }
.gh-node-value { text-anchor: middle; font-family: var(--font-display); font-weight: 800; fill: #0f172a; paint-order: stroke; stroke: rgba(255, 255, 255, 0.92); stroke-width: 4px; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.gh-node-name { text-anchor: middle; font-family: var(--font-body); fill: #334155; paint-order: stroke; stroke: rgba(255, 255, 255, 0.9); stroke-width: 3px; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.gh-node:hover .gh-node-halo, .gh-node:focus .gh-node-halo { fill: rgba(16, 185, 129, 0.28); }
.gh-node:focus { outline: none; }
.gh-twin-svg.editing .gh-node { cursor: grab; }
.gh-twin-svg.editing .gh-node.auto .gh-node-halo { fill: rgba(217, 119, 6, 0.25); }
.gh-twin-svg.editing .gh-node.dragging { cursor: grabbing; }
.gh-twin-svg.editing .gh-node.dragging .gh-node-halo { fill: rgba(16, 185, 129, 0.4); }

.gh-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.6rem; margin-top: 0.6rem; font-size: 0.78rem; color: var(--muted); }
.gh-swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.gh-legend-bar.lux { width: 90px; height: 10px; border-radius: 6px; background: linear-gradient(to left, #facc15, #334155); }
.gh-legend .sep { color: var(--dim); }
.gh-hint { margin: 0 0 0.6rem; padding: 0.5rem 0.75rem; border-radius: 10px; background: var(--gh-warn-soft); color: #92400e; font-size: 0.85rem; }

/* ── House view grid ────────────────────────────────────── */
.gh-house-head { display: grid; grid-template-columns: 1fr; gap: 0.35rem; justify-items: start; }
.gh-house-head .gh-actions { justify-content: flex-start; }
.gh-house-title p { margin: 0.2rem 0 0; }
.gh-house-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.gh-twin-panel { grid-column: span 2; grid-row: span 2; }
.gh-chart-panel { grid-column: span 2; }
.gh-health { grid-column: 1 / -1; }
.gh-house-alerts { grid-column: span 2; }

.gh-readouts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; margin-bottom: 0.9rem; }
.gh-readout { background: var(--bg0); border-radius: 12px; padding: 0.55rem 0.7rem; border: 1px solid var(--line); }
.gh-readout .l { display: block; font-size: 0.75rem; color: var(--dim); }
.gh-readout .v { font-family: var(--font-display); font-size: 1.45rem; font-weight: 800; color: var(--text); }
.gh-readout.lvl-warn { border-color: rgba(217, 119, 6, 0.4); background: var(--gh-warn-soft); }
.gh-readout.lvl-danger { border-color: rgba(220, 38, 38, 0.4); background: var(--gh-danger-soft); }

.gh-gauge { margin-top: 0.8rem; }
.gh-gauge-head { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.82rem; color: var(--muted); margin-bottom: 0.35rem; }
.gh-gauge-head strong { font-family: var(--font-display); color: var(--text); }
.gh-band { position: relative; height: 12px; border-radius: 999px; background: linear-gradient(to right, rgba(234, 88, 12, 0.35), rgba(148, 163, 184, 0.2) 50%, rgba(79, 70, 229, 0.3)); }
.gh-band-ok { position: absolute; top: 0; bottom: 0; background: rgba(47, 158, 68, 0.55); border-radius: 999px; }
.gh-band-marker { position: absolute; top: -4px; width: 4px; height: 20px; margin-inline-start: -2px; border-radius: 2px; background: var(--text); box-shadow: 0 0 0 2px #fff; }
.gh-band-scale { display: flex; justify-content: space-between; font-size: 0.7rem; color: var(--dim); margin-top: 0.25rem; }
.gh-meter { height: 10px; border-radius: 999px; background: var(--bg-elevated); overflow: hidden; }
.gh-meter span { display: block; height: 100%; border-radius: 999px; background: var(--gh-ok); }
.gh-meter.lvl-warn span { background: var(--gh-warn); }
.gh-meter.lvl-danger span { background: var(--gh-danger); }

.gh-recs-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.gh-recs-list li { padding: 0.55rem 0.7rem; border-radius: 10px; font-size: 0.88rem; line-height: 1.55; background: var(--bg0); border-inline-start: 4px solid var(--line-strong); }
.gh-recs-list li.lvl-danger { background: var(--gh-danger-soft); border-color: var(--gh-danger); }
.gh-recs-list li.lvl-warn { background: var(--gh-warn-soft); border-color: var(--gh-warn); }
.gh-recs-list li.lvl-info { border-color: var(--cyan); }
.gh-allgood { margin: 0; padding: 0.7rem; border-radius: 10px; background: var(--gh-ok-soft); color: #1b5e2f; font-size: 0.9rem; }

.gh-chart-box { position: relative; }
.gh-chart-box canvas { display: block; width: 100%; }
.gh-chart-empty { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: var(--dim); }
.gh-chart-empty[hidden] { display: none; }
.gh-chart-tip { position: absolute; top: 4px; min-width: 140px; background: rgba(15, 23, 42, 0.92); color: #fff; font-size: 0.75rem; padding: 0.4rem 0.55rem; border-radius: 8px; pointer-events: none; }
.gh-chart-tip span { display: block; color: #cbd5e1; margin-bottom: 0.15rem; }
.gh-chart-tip i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-inline-end: 0.3rem; }

.gh-dli-row { display: grid; grid-template-columns: 7.5rem 1fr 3rem; gap: 0.6rem; align-items: center; font-size: 0.85rem; margin-bottom: 0.5rem; }
.gh-dli-row strong { font-family: var(--font-display); text-align: end; }

.gh-gdd { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.35rem; height: 130px; align-items: end; direction: ltr; } /* oldest → newest, like the chart */
.gh-gdd-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 0.15rem; }
.gh-gdd-col .bar { width: 70%; background: linear-gradient(to top, #2f9e44, #94d82d); border-radius: 6px 6px 2px 2px; min-height: 0; }
.gh-gdd-col .val { font-size: 0.72rem; font-weight: 700; }
.gh-gdd-col .day { font-size: 0.68rem; color: var(--dim); }

.gh-donuts { display: flex; justify-content: space-around; gap: 1rem; }
.gh-donut { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 0.3rem; }
.gh-donut svg { width: 96px; height: 96px; }
.gh-donut .track { fill: none; stroke: var(--bg-elevated); stroke-width: 3.6; }
.gh-donut .fill { fill: none; stroke: var(--gh-ok); stroke-width: 3.6; stroke-linecap: round; }
.gh-donut.lvl-warn .fill { stroke: var(--gh-warn); }
.gh-donut.lvl-danger .fill { stroke: var(--gh-danger); }
.gh-donut figcaption { text-align: center; display: flex; flex-direction: column; }
.gh-donut strong { font-family: var(--font-display); font-size: 1.15rem; }
.gh-donut span { font-size: 0.78rem; color: var(--dim); }

.gh-irrigation, .gh-uni { list-style: none; margin: 0 0 0.6rem; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.gh-irrigation li, .gh-uni li { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; font-size: 0.86rem; }
.gh-irrigation li > div { display: flex; flex-direction: column; }
.gh-uni strong { font-family: var(--font-display); }

.gh-stats { width: 100%; border-collapse: collapse; font-size: 0.8rem; margin-top: 0.4rem; }
.gh-stats th, .gh-stats td { padding: 0.3rem 0.25rem; text-align: start; border-bottom: 1px solid var(--line); }
.gh-stats thead td, .gh-stats thead th { color: var(--dim); font-weight: 600; }
.gh-stats tbody th { font-weight: 600; color: var(--muted); }

.gh-table-wrap { overflow-x: auto; }
.gh-table-wrap.tall { max-height: 55vh; overflow-y: auto; }
.gh-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.gh-table th { text-align: start; font-weight: 600; color: var(--dim); font-size: 0.76rem; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; background: var(--bg1); }
.gh-table td { padding: 0.55rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.gh-table tr.inactive { opacity: 0.55; }
.gh-row-actions { white-space: nowrap; }

.gh-alerts { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.gh-alerts li { display: flex; gap: 0.75rem; justify-content: space-between; align-items: flex-start; padding: 0.7rem 0.8rem; border-radius: 12px; background: var(--bg0); border-inline-start: 4px solid var(--gh-warn); }
.gh-alerts li.sev-critical { border-color: var(--gh-danger); background: var(--gh-danger-soft); }
.gh-alerts li.sev-info { border-color: var(--gh-ok); }
.gh-alerts li.done { opacity: 0.6; border-color: var(--line-strong); background: var(--bg0); }
.gh-alert-main { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.gh-alert-main p { margin: 0.2rem 0; font-size: 0.86rem; color: var(--muted); }
.gh-alert-head { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.gh-sev { font-size: 0.72rem; font-weight: 700; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--gh-warn-soft); color: var(--gh-warn); }
.gh-sev.sev-critical { background: var(--gh-danger); color: #fff; }
.gh-sev.sev-info { background: var(--gh-ok-soft); color: var(--gh-ok); }
.gh-alert-facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.2rem 0.75rem; margin: 0.2rem 0 0; font-size: 0.86rem; }
.gh-alert-facts div { display: contents; }
.gh-alert-facts dt { color: var(--muted); font-weight: 600; }
.gh-alert-facts dd { margin: 0; }
.gh-alert-status { font-style: italic; }

.gh-detail-meta { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; color: var(--muted); font-size: 0.82rem; margin-bottom: 0.75rem; }

/* ── Empty / loading ────────────────────────────────────── */
.gh-empty-state { text-align: center; padding: 2.5rem 1rem; background: var(--bg1); border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); display: flex; flex-direction: column; align-items: center; gap: 0.6rem; }
.gh-empty-state h2 { justify-content: center; }
.gh-empty-state p { max-width: 520px; color: var(--muted); margin: 0; }
.gh-empty-art svg { width: 140px; height: auto; }
.gh-loading { display: flex; align-items: center; justify-content: center; gap: 0.6rem; padding: 3rem 1rem; color: var(--dim); }
.gh-loading.small { padding: 1rem; justify-content: flex-start; }
.gh-spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--leaf); animation: gh-spin 0.8s linear infinite; }
@keyframes gh-spin { to { transform: rotate(360deg); } }

/* ── Dialog & forms ─────────────────────────────────────── */
.gh-dialog { border: 0; padding: 0; border-radius: 18px; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25); background: var(--bg1); color: var(--text); }
.gh-dialog::backdrop { background: rgba(15, 23, 42, 0.45); backdrop-filter: blur(2px); }
.gh-dialog:has(.gh-form.wide) { width: min(820px, calc(100vw - 32px)); }
.gh-form { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.gh-form header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.1rem; border-bottom: 1px solid var(--line); }
.gh-form header h2 { font-family: var(--font-display); font-size: 1.1rem; margin: 0; }
.gh-x { font-size: 1.5rem; line-height: 1; border: 0; background: none; cursor: pointer; color: var(--dim); width: 36px; height: 36px; border-radius: 8px; }
.gh-x:hover { background: var(--bg-elevated); }
.gh-form-body { padding: 1rem 1.1rem; overflow-y: auto; display: flex; flex-direction: column; gap: 0.75rem; }
.gh-form footer { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; padding: 0.8rem 1.1rem; border-top: 1px solid var(--line); }
.gh-form footer > div { display: flex; gap: 0.5rem; }
.gh-form label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.84rem; font-weight: 600; color: var(--muted); }
.gh-form input, .gh-form select, .gh-form textarea { font: inherit; font-weight: 400; font-size: 0.95rem; color: var(--text); background: var(--bg1); border: 1px solid var(--line-strong); border-radius: 10px; padding: 0.55rem 0.7rem; min-height: 42px; width: 100%; }
.gh-form input:focus, .gh-form select:focus, .gh-form textarea:focus { outline: none; border-color: var(--leaf); box-shadow: 0 0 0 3px var(--leaf-dim); }
.gh-form input[readonly] { background: var(--bg-elevated); color: var(--muted); }
.gh-form fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 0.6rem 0.8rem 0.8rem; margin: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.gh-form legend { font-weight: 700; font-size: 0.86rem; padding: 0 0.3rem; }
.gh-form legend .gh-fine { font-weight: 400; display: block; }
.gh-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.gh-row.three { grid-template-columns: 1.4fr 1fr 1fr; }
.gh-check { flex-direction: row !important; align-items: center; gap: 0.5rem !important; }
.gh-check input { width: 18px; min-height: 18px; height: 18px; }
.gh-form-error { margin: 0 1.1rem; padding: 0.5rem 0.7rem; border-radius: 8px; background: var(--gh-danger-soft); color: var(--gh-danger); font-size: 0.85rem; }
.gh-form-error[hidden] { display: none; }

.gh-toast { position: fixed; bottom: 1.25rem; left: 50%; transform: translate(-50%, 150%); background: #0f172a; color: #fff; padding: 0.65rem 1.1rem; border-radius: 12px; font-size: 0.9rem; z-index: 1000; transition: transform 0.25s ease; box-shadow: 0 10px 30px rgba(15, 23, 42, 0.3); max-width: calc(100vw - 32px); }
.gh-toast.show { transform: translate(-50%, 0); }
.gh-toast[data-kind="error"] { background: var(--gh-danger); }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1024px) {
  .gh-house-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gh-twin-panel, .gh-chart-panel, .gh-house-alerts { grid-column: 1 / -1; grid-row: auto; }
}
@media (max-width: 640px) {
  .gh { padding: 0.75rem 0.75rem 2.5rem; }
  .gh-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gh-houses { grid-template-columns: 1fr; }
  .gh-house-grid { grid-template-columns: 1fr; }
  .gh-house-grid > * { grid-column: 1 / -1; }
  .gh-row, .gh-row.three { grid-template-columns: 1fr; }
  .gh-tray-item { grid-template-columns: auto 1fr; }
  .gh-readout .v { font-size: 1.25rem; }
  /* long houses stay legible: scroll the plan sideways instead of shrinking it */
  .gh-twin { overflow-x: auto; }
  .gh-twin-svg:not(.mini) { min-width: 560px; max-height: none; }
  .gh-dli-row { grid-template-columns: 6rem 1fr 2.5rem; }
  .gh-toolbar .gh-actions { width: 100%; }
  .gh-toolbar .gh-actions .gh-btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .gh *, .gh *::before { animation: none !important; transition: none !important; }
}
