:root {
  --ink: #17221f;
  --muted: #68766f;
  --line: #dce4df;
  --surface: #ffffff;
  --canvas: #f3f6f4;
  --green-900: #143d32;
  --green-700: #23644d;
  --green-500: #3c8a64;
  --green-100: #e4f2ea;
  --blue-700: #315d78;
  --blue-100: #e7f0f6;
  --amber-700: #8f5a16;
  --amber-100: #fff0d8;
  --red-700: #a13e3e;
  --red-100: #fae7e5;
  --shadow: 0 10px 26px rgba(18, 48, 39, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.hidden {
  display: none !important;
}

.muted {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green-700);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.brand-mark {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 6px;
  background: #ffffff;
  color: var(--green-900);
  font-size: 18px;
  font-weight: 800;
}

.brand-mark.small {
  width: 38px;
  height: 38px;
  border-color: var(--line);
  font-size: 14px;
}

.auth-view {
  min-height: 100vh;
  padding: 24px;
  background: #e8eeea;
}

.auth-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 1.05fr);
  width: min(980px, 100%);
  min-height: min(680px, calc(100vh - 48px));
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid #d4ddd7;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(38px, 7vw, 82px);
  background: var(--green-900);
  color: #ffffff;
}

.auth-brand .eyebrow {
  margin-top: 58px;
  color: #a9d6c0;
}

.auth-brand h1 {
  margin: 0;
  font-size: 48px;
  font-weight: 700;
  line-height: 1.18;
}

.auth-intro {
  max-width: 360px;
  margin: 28px 0 0;
  color: #d1e4da;
  font-size: 16px;
  line-height: 1.8;
}

.auth-meta {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: auto;
  color: #d1e4da;
  font-size: 12px;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: #57bc82;
  box-shadow: 0 0 0 3px rgba(87, 188, 130, 0.16);
}

.status-dot.offline {
  background: #b1bbb6;
  box-shadow: none;
}

.auth-card {
  align-self: center;
  width: min(420px, calc(100% - 64px));
  margin: 32px auto;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f5f7f6;
}

.auth-tab {
  border: 0;
  border-radius: 4px;
  padding: 10px;
  background: transparent;
  color: var(--muted);
}

.auth-tab.active {
  background: var(--surface);
  color: var(--green-900);
  box-shadow: 0 2px 8px rgba(20, 61, 50, 0.09);
  font-weight: 700;
}

.auth-form h2 {
  margin: 34px 0 24px;
  font-size: 24px;
}

.auth-form label,
.form-grid label {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
  color: #3f4d47;
  font-size: 13px;
  font-weight: 600;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cfd9d3;
  border-radius: 5px;
  outline: 0;
  background: #ffffff;
  color: var(--ink);
  padding: 9px 11px;
}

input:focus,
select:focus {
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(60, 138, 100, 0.13);
}

.btn {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 9px 15px;
  font-weight: 700;
}

.btn-primary {
  border-color: var(--green-700);
  background: var(--green-700);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--green-900);
}

.btn-quiet {
  border-color: #cfd9d3;
  background: #ffffff;
  color: #33443d;
}

.btn-quiet:hover {
  border-color: #aab9b1;
  background: #f6f8f7;
}

.btn-wide {
  width: 100%;
  margin-top: 8px;
}

.form-error {
  min-height: 22px;
  margin: 15px 0 0;
  color: var(--red-700);
  font-size: 13px;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  padding: 0 22px;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.product-name {
  color: var(--green-900);
  font-size: 17px;
  font-weight: 800;
}

.product-subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.service-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #43534c;
  font-size: 12px;
}

.icon-btn,
.text-btn,
.link-btn,
.mini-btn {
  border: 0;
  background: transparent;
  color: #3c4d45;
}

.icon-btn {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 20px;
}

.icon-btn:hover {
  background: #f2f5f3;
}

.text-btn,
.link-btn {
  padding: 7px 4px;
  color: var(--green-700);
  font-weight: 700;
}

.shell {
  display: grid;
  grid-template-columns: 222px minmax(0, 1fr);
  min-height: calc(100vh - 64px);
}

.sidebar {
  position: sticky;
  top: 64px;
  display: flex;
  height: calc(100vh - 64px);
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #edf2ef;
  padding: 22px 14px 16px;
}

.sidebar-section + .sidebar-section {
  margin-top: 28px;
}

.sidebar-label {
  margin: 0 10px 8px;
  color: #829088;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  width: 100%;
  min-height: 40px;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #526159;
  padding: 9px 10px;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: #ffffff;
  color: var(--green-900);
}

.nav-item.active {
  box-shadow: 0 2px 8px rgba(20, 61, 50, 0.08);
  font-weight: 700;
}

.nav-icon {
  display: inline-grid;
  width: 20px;
  height: 20px;
  place-items: center;
  color: var(--green-700);
  font-size: 16px;
}

.account-section {
  margin-top: auto !important;
}

.account-box,
.key-box {
  border: 1px solid #d7e0db;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.66);
  padding: 10px;
}

.account-box span,
.account-box small,
.key-box span,
.key-box code {
  display: block;
  overflow-wrap: anywhere;
}

.account-box span {
  font-size: 12px;
  font-weight: 700;
}

.account-box small,
.key-box span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.key-box {
  position: relative;
  margin-top: 8px;
  padding-right: 48px;
}

.key-box code {
  margin-top: 5px;
  color: var(--green-900);
  font-size: 11px;
  font-weight: 700;
}

.mini-btn {
  position: absolute;
  top: 16px;
  right: 7px;
  color: var(--green-700);
  font-size: 11px;
  font-weight: 700;
}

.sidebar-footer {
  margin-top: 14px;
  color: #87948d;
  font-size: 9px;
  line-height: 1.5;
}

.main-content {
  min-width: 0;
  padding: 30px clamp(20px, 3vw, 42px) 48px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.page-heading h1 {
  margin: 0 0 5px;
  font-size: 28px;
  line-height: 1.2;
}

.heading-date {
  color: #47564f;
  font-size: 13px;
  font-weight: 700;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 4px 14px rgba(18, 48, 39, 0.04);
}

.kpi-card {
  min-height: 142px;
  padding: 18px;
}

.kpi-card.accent {
  border-color: #cbdde8;
  background: var(--blue-100);
}

.kpi-label {
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.kpi-card strong {
  font-size: 30px;
  font-weight: 700;
}

.kpi-suffix {
  margin-left: 5px;
  color: var(--muted);
  font-size: 13px;
}

.kpi-track {
  height: 4px;
  margin-top: 23px;
  overflow: hidden;
  border-radius: 2px;
  background: #edf1ef;
}

.kpi-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--green-500);
  transition: width 220ms ease;
}

.kpi-note {
  display: flex;
  min-height: 20px;
  align-items: center;
  gap: 7px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.ai-decision-panel {
  margin-bottom: 16px;
  overflow: hidden;
  padding: 0;
  scroll-margin-top: 80px;
}

.ai-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--line);
}

.ai-panel-title {
  min-width: 0;
}

.ai-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.ai-title-row h2 {
  margin: 0;
  font-size: 19px;
}

.ai-mode-badge {
  display: inline-flex;
  min-height: 25px;
  align-items: center;
  border-radius: 4px;
  background: #edf1ef;
  color: #69766f;
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.ai-mode-badge.running,
.ai-mode-badge.irrigate {
  background: var(--green-100);
  color: var(--green-700);
}

.ai-mode-badge.complete,
.ai-mode-badge.hold,
.ai-mode-badge.scheduled {
  background: var(--blue-100);
  color: var(--blue-700);
}

.ai-mode-badge.waiting,
.ai-mode-badge.manual {
  background: var(--amber-100);
  color: var(--amber-700);
}

.ai-mode-badge.offline {
  background: var(--red-100);
  color: var(--red-700);
}

.ai-panel-title .muted {
  margin-top: 7px;
  overflow-wrap: anywhere;
}

.ai-data-health {
  width: 190px;
  flex: 0 0 190px;
}

.ai-data-health > div:first-child {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 10px;
}

.ai-data-health strong {
  color: var(--green-700);
  font-size: 17px;
}

.ai-data-health.partial strong {
  color: var(--amber-700);
}

.ai-data-health.low strong {
  color: var(--red-700);
}

.ai-data-track,
.ai-progress-track,
.ai-rain-track {
  overflow: hidden;
  background: #e9eeeb;
}

.ai-data-track {
  height: 4px;
  margin-top: 6px;
}

.ai-data-track span,
.ai-progress-track span,
.ai-rain-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--green-500);
  transition: width 220ms ease;
}

.ai-data-health.partial .ai-data-track span {
  background: #c48734;
}

.ai-data-health.low .ai-data-track span {
  background: var(--red-700);
}

.ai-data-health small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 10px;
  text-align: right;
}

.empty-ai-decision {
  display: grid;
  min-height: 170px;
  place-content: center;
  gap: 5px;
  color: var(--muted);
  text-align: center;
}

.empty-ai-decision strong {
  color: #405048;
  font-size: 14px;
}

.empty-ai-decision span {
  font-size: 11px;
}

.ai-decision-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.95fr) minmax(0, 1.1fr);
  border-bottom: 1px solid var(--line);
}

.ai-decision-grid > div {
  min-width: 0;
  padding: 20px 22px;
  border-right: 1px solid var(--line);
}

.ai-decision-grid > div:last-child {
  border-right: 0;
}

.ai-decision-summary {
  border-left: 4px solid var(--blue-700);
  background: #f7fafc;
}

.ai-decision-summary.running,
.ai-decision-summary.irrigate {
  border-left-color: var(--green-500);
  background: #f5faf7;
}

.ai-decision-summary.complete {
  border-left-color: var(--blue-700);
}

.ai-decision-summary.scheduled {
  border-left-color: var(--blue-700);
  background: #f7fafc;
}

.ai-decision-summary.waiting,
.ai-decision-summary.manual {
  border-left-color: #c48734;
  background: #fffaf2;
}

.ai-decision-summary.offline {
  border-left-color: var(--red-700);
  background: #fff8f7;
}

.ai-decision-summary.disabled {
  border-left-color: #98a39d;
  background: #f7f8f7;
}

.ai-decision-topline,
.ai-block-heading,
.ai-progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ai-decision-topline {
  color: var(--green-700);
  font-size: 10px;
  font-weight: 800;
}

.ai-decision-topline span:last-child {
  color: var(--muted);
  font-weight: 700;
}

.ai-decision-summary h3 {
  margin: 22px 0 8px;
  font-size: 24px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.ai-decision-summary p {
  margin: 0;
  color: #506058;
  font-size: 12px;
  line-height: 1.7;
}

.ai-block-heading {
  margin-bottom: 13px;
}

.ai-block-heading h3 {
  margin: 0;
  font-size: 13px;
}

.ai-block-heading > span {
  color: var(--muted);
  font-size: 9px;
  text-align: right;
}

.ai-plan-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.ai-plan-metrics > div {
  min-width: 0;
  min-height: 64px;
  padding: 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.ai-plan-metrics span,
.ai-plan-metrics strong {
  display: block;
}

.ai-plan-metrics span {
  color: var(--muted);
  font-size: 9px;
}

.ai-plan-metrics strong {
  margin-top: 5px;
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.ai-progress-meta {
  margin-top: 13px;
  color: var(--muted);
  font-size: 9px;
}

.ai-progress-meta strong {
  color: #425149;
  font-size: 10px;
}

.ai-progress-track {
  height: 5px;
  margin-top: 7px;
}

.ai-factor-list {
  border-top: 1px solid var(--line);
}

.ai-factor-row {
  display: flex;
  min-height: 47px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #edf1ef;
  padding: 7px 0;
}

.ai-factor-row:last-child {
  border-bottom: 0;
}

.ai-factor-row > div {
  min-width: 0;
}

.ai-factor-row span,
.ai-factor-row strong {
  display: block;
}

.ai-factor-row span {
  color: var(--muted);
  font-size: 9px;
}

.ai-factor-row strong {
  margin-top: 3px;
  font-size: 11px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.ai-factor-row em {
  flex: 0 0 auto;
  color: var(--blue-700);
  font-size: 9px;
  font-style: normal;
  font-weight: 700;
  text-align: right;
}

.ai-factor-row em.reduce {
  color: var(--green-700);
}

.ai-factor-row em.increase,
.ai-factor-row em.estimated {
  color: var(--amber-700);
}

.ai-factor-row em.missing {
  color: var(--red-700);
}

.ai-context-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
}

.ai-context-grid > div {
  min-width: 0;
  padding: 18px 22px 20px;
}

.ai-weather-block {
  border-right: 1px solid var(--line);
}

.ai-weather-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.ai-weather-day {
  min-width: 0;
  padding: 11px 12px;
  border-right: 1px solid var(--line);
}

.ai-weather-day:last-child {
  border-right: 0;
}

.ai-weather-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.ai-weather-heading strong {
  font-size: 11px;
}

.ai-weather-heading span {
  overflow: hidden;
  color: #4f5e57;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-weather-values {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 12px;
}

.ai-weather-values span,
.ai-weather-values strong {
  display: block;
}

.ai-weather-values span {
  color: var(--muted);
  font-size: 8px;
}

.ai-weather-values strong {
  margin-top: 3px;
  font-size: 10px;
  overflow-wrap: anywhere;
}

.ai-rain-track {
  height: 3px;
  margin-top: 10px;
}

.ai-rain-track span {
  width: var(--rain-risk);
  background: #5b87a2;
}

.ai-weather-empty {
  grid-column: 1 / -1;
  min-height: 98px;
  padding: 38px 12px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.ai-input-list {
  border-top: 1px solid var(--line);
}

.ai-input-row {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 39px;
  border-bottom: 1px solid #edf1ef;
}

.ai-input-row:last-child {
  border-bottom: 0;
}

.ai-input-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green-500);
}

.ai-input-row.estimated .ai-input-indicator {
  background: #c48734;
}

.ai-input-row.missing .ai-input-indicator {
  background: var(--red-700);
}

.ai-input-row strong,
.ai-input-row small {
  display: block;
}

.ai-input-row strong {
  font-size: 10px;
}

.ai-input-row small {
  overflow: hidden;
  margin-top: 2px;
  color: var(--muted);
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-input-state {
  color: var(--green-700);
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
}

.ai-input-row.estimated .ai-input-state {
  color: var(--amber-700);
}

.ai-input-row.missing .ai-input-state {
  color: var(--red-700);
}

.pulse-mark {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--amber-700);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(270px, 0.78fr) minmax(440px, 1.42fr);
  gap: 16px;
}

.panel {
  min-width: 0;
  padding: 20px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-header h2,
.section-heading h3 {
  margin: 0 0 4px;
  font-size: 17px;
}

.count-badge {
  display: inline-grid;
  min-width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 4px;
  background: var(--green-100);
  color: var(--green-900);
  font-size: 12px;
  font-weight: 800;
}

.device-list {
  display: grid;
  gap: 7px;
}

.device-item {
  display: grid;
  grid-template-columns: 11px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 72px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: #f6f8f7;
  padding: 11px;
  text-align: left;
}

.device-item:hover,
.device-item.active {
  border-color: #bfd2c7;
  background: #edf5f0;
}

.device-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #aab5af;
}

.device-indicator.online {
  background: #3b9b67;
}

.device-main {
  min-width: 0;
}

.device-main strong,
.device-main small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-main strong {
  color: #26342e;
  font-size: 13px;
}

.device-main small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
}

.device-state {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.device-state.running {
  color: var(--amber-700);
}

.device-state.irrigate,
.device-state.complete {
  color: var(--green-700);
}

.device-state.hold {
  color: var(--blue-700);
}

.device-state.scheduled {
  color: var(--blue-700);
}

.device-state.waiting,
.device-state.manual {
  color: var(--amber-700);
}

.device-state.offline {
  color: var(--red-700);
}

.detail-panel {
  min-height: 470px;
}

.empty-detail,
.empty-state {
  color: var(--muted);
  text-align: center;
}

.empty-detail {
  display: grid;
  min-height: 420px;
  place-content: center;
}

.empty-detail h2 {
  margin: 12px 0 5px;
  color: #405048;
  font-size: 17px;
}

.empty-glyph {
  color: #9bacA3;
  font-size: 44px;
}

.empty-state {
  padding: 32px 10px;
  font-size: 12px;
}

.detail-heading {
  margin-bottom: 12px;
}

.state-pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border-radius: 4px;
  background: #edf1ef;
  color: #67756e;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.state-pill.online {
  background: var(--green-100);
  color: var(--green-700);
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 0 16px;
  border-bottom: 1px solid var(--line);
}

.runtime-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 16px 0 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--line);
}

.runtime-strip div {
  min-width: 0;
  background: #f7f9f8;
  padding: 12px;
}

.runtime-strip span,
.runtime-strip strong {
  display: block;
}

.runtime-strip span {
  color: var(--muted);
  font-size: 10px;
}

.runtime-strip strong {
  overflow: hidden;
  margin-top: 5px;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 20px 0 10px;
}

.zone-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 5px;
}

.zone-field {
  min-width: 0;
  padding: 11px 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.zone-field:nth-child(3n) {
  border-right: 0;
}

.zone-field:nth-last-child(-n + 3) {
  border-bottom: 0;
}

.zone-field span,
.zone-field strong {
  display: block;
}

.zone-field span {
  color: var(--muted);
  font-size: 10px;
}

.zone-field strong {
  overflow: hidden;
  margin-top: 4px;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sensor-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.sensor-item-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #f8faf9;
  padding: 12px;
}

.sensor-item-card header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.sensor-item-card h4 {
  overflow: hidden;
  margin: 0;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sensor-item-card small {
  color: var(--muted);
  font-size: 9px;
}

.sensor-values {
  display: flex;
  gap: 14px;
}

.sensor-values div span,
.sensor-values div strong {
  display: block;
}

.sensor-values span {
  color: var(--muted);
  font-size: 9px;
}

.sensor-values strong {
  margin-top: 3px;
  font-size: 14px;
}

.events-panel {
  margin-top: 16px;
}

.event-list {
  border-top: 1px solid var(--line);
}

.event-row {
  display: grid;
  grid-template-columns: 118px 130px minmax(0, 1fr) 150px;
  gap: 12px;
  align-items: center;
  min-height: 48px;
  border-bottom: 1px solid #edf1ef;
  color: #43534c;
  font-size: 11px;
}

.event-row:last-child {
  border-bottom: 0;
}

.event-level {
  display: inline-flex;
  width: fit-content;
  border-radius: 3px;
  background: var(--blue-100);
  color: var(--blue-700);
  padding: 3px 6px;
  font-weight: 700;
}

.event-level.warn,
.event-level.error {
  background: var(--amber-100);
  color: var(--amber-700);
}

.event-time {
  color: var(--muted);
  text-align: right;
}

.config-dialog {
  width: min(720px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  padding: 0;
  box-shadow: 0 24px 64px rgba(18, 48, 39, 0.24);
}

.config-dialog::backdrop {
  background: rgba(12, 27, 22, 0.5);
}

.config-dialog form {
  padding: 22px;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.dialog-header h2 {
  margin: 0;
  font-size: 20px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 14px;
}

.form-grid .span-2 {
  grid-column: 1 / -1;
}

.form-grid .check-field {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 10px;
}

.check-field input {
  width: 17px;
  min-height: 17px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.toast {
  position: fixed;
  z-index: 100;
  top: 76px;
  right: 20px;
  max-width: min(360px, calc(100vw - 40px));
  transform: translateY(-10px);
  border: 1px solid #bdd2c6;
  border-radius: 5px;
  background: #ffffff;
  color: #2c3c35;
  padding: 11px 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.error {
  border-color: #e4b8b3;
  color: var(--red-700);
}

@media (max-width: 1180px) {
  .ai-decision-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ai-factor-block {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
  }

  .ai-decision-grid > .ai-plan-block {
    border-right: 0;
  }

  .ai-factor-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ai-factor-row {
    padding: 7px 12px 7px 0;
  }

  .ai-factor-row:nth-child(odd) {
    border-right: 1px solid var(--line);
  }

  .ai-factor-row:nth-child(even) {
    padding-left: 12px;
  }
}

@media (max-width: 1080px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid {
    grid-template-columns: minmax(230px, 0.7fr) minmax(400px, 1.3fr);
  }
}

@media (max-width: 840px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    display: none;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .devices-panel,
  .detail-panel {
    min-height: auto;
  }

  .event-row {
    grid-template-columns: 96px 112px minmax(0, 1fr);
  }

  .event-time {
    display: none;
  }
}

@media (max-width: 680px) {
  .auth-view {
    padding: 0;
  }

  .auth-layout {
    display: block;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .auth-brand {
    min-height: 260px;
    padding: 32px 24px;
  }

  .auth-brand .eyebrow {
    margin-top: 28px;
  }

  .auth-brand h1 {
    font-size: 36px;
  }

  .auth-intro {
    margin-top: 16px;
    font-size: 14px;
  }

  .auth-meta {
    margin-top: 22px;
  }

  .auth-card {
    width: calc(100% - 40px);
    margin: 28px auto 42px;
  }

  .topbar {
    min-height: 58px;
    padding: 0 12px;
  }

  .product-subtitle,
  .service-status,
  .text-btn {
    display: none;
  }

  .shell {
    min-height: calc(100vh - 58px);
  }

  .main-content {
    padding: 22px 12px 36px;
  }

  .page-heading {
    align-items: flex-start;
  }

  .heading-date {
    max-width: 115px;
    text-align: right;
  }

  .page-heading h1 {
    font-size: 23px;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .kpi-card {
    min-height: 126px;
    padding: 14px;
  }

  .kpi-card strong {
    font-size: 25px;
  }

  .kpi-note {
    margin-top: 14px;
  }

  .panel {
    padding: 15px;
  }

  .ai-decision-panel {
    padding: 0;
  }

  .ai-panel-header {
    display: grid;
    gap: 15px;
    padding: 17px 15px 14px;
  }

  .ai-title-row h2 {
    font-size: 17px;
  }

  .ai-data-health {
    width: 100%;
    flex-basis: auto;
  }

  .ai-data-health small {
    text-align: left;
  }

  .ai-decision-grid,
  .ai-context-grid {
    grid-template-columns: 1fr;
  }

  .ai-decision-grid > div,
  .ai-context-grid > div {
    padding: 17px 15px;
    border-right: 0;
  }

  .ai-decision-grid > div {
    border-bottom: 1px solid var(--line);
  }

  .ai-decision-grid > div:last-child {
    border-bottom: 0;
  }

  .ai-decision-summary h3 {
    margin-top: 18px;
    font-size: 21px;
  }

  .ai-factor-block {
    grid-column: auto;
    border-top: 0;
  }

  .ai-factor-list {
    grid-template-columns: 1fr;
  }

  .ai-factor-row,
  .ai-factor-row:nth-child(even) {
    padding-right: 0;
    padding-left: 0;
  }

  .ai-factor-row:nth-child(odd) {
    border-right: 0;
  }

  .ai-weather-block {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .ai-weather-list {
    grid-template-columns: 1fr;
  }

  .ai-weather-day {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .ai-weather-day:last-child {
    border-bottom: 0;
  }

  .ai-input-row small {
    white-space: normal;
  }

  .runtime-strip,
  .zone-summary {
    grid-template-columns: 1fr;
  }

  .runtime-strip div,
  .zone-field,
  .zone-field:nth-child(3n),
  .zone-field:nth-last-child(-n + 3) {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .runtime-strip div:last-child,
  .zone-field:last-child {
    border-bottom: 0;
  }

  .sensor-list,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-grid .span-2 {
    grid-column: auto;
  }

  .event-row {
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 8px;
    padding: 9px 0;
  }

  .event-row > :nth-child(2) {
    display: none;
  }

  .config-dialog form {
    padding: 16px;
  }
}
