.automation-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  min-height: calc(100vh - 150px);
  color: #34271f;
}

.automation-main,
.automation-inspector {
  overflow: hidden;
  border: 1px solid rgba(172, 132, 84, 0.28);
  border-radius: 22px;
  background: rgba(255, 251, 245, 0.96);
  box-shadow: 0 18px 44px rgba(97, 70, 43, 0.10), inset 0 1px 0 #fff;
}

.automation-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 16px;
  border-bottom: 1px solid rgba(172, 132, 84, 0.22);
  background: linear-gradient(135deg, #fffaf2 0%, #f4eadc 100%);
  color: #49372a;
  flex-wrap: wrap;
}

.automation-toolbar input,
.automation-toolbar select,
.automation-inspector input,
.automation-inspector select {
  border: 1px solid #d7c4ad;
  background: rgba(255, 255, 255, 0.92);
  color: #2f241d;
  border-radius: 10px;
  padding: 9px 11px;
  box-shadow: inset 0 1px 2px rgba(80, 52, 25, 0.05);
}

.automation-toolbar input:focus,
.automation-toolbar select:focus,
.automation-inspector input:focus,
.automation-inspector select:focus {
  outline: 3px solid rgba(20, 155, 184, 0.16);
  border-color: #159bb8;
}

.automation-rule-name { min-width: 260px; flex: 1; }

.automation-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid #e4a13d;
  background: #fff0d2;
  color: #9a5a05;
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.automation-toolbar button,
.automation-inspector button {
  border: 1px solid #98cbd6;
  background: #eaf7f9;
  color: #15546a;
  border-radius: 10px;
  padding: 9px 13px;
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 3px 9px rgba(24, 111, 132, 0.08);
}

.automation-toolbar button:hover,
.automation-inspector button:hover {
  border-color: #1498b7;
  background: #daf2f6;
  transform: translateY(-1px);
}

#automationSaveDraft {
  border-color: #daa85c;
  background: #fff1d8;
  color: #8a5104;
}

#automationSimulate {
  border-color: #087e99;
  background: linear-gradient(135deg, #1198b7, #08788e);
  color: #fff;
  box-shadow: 0 6px 16px rgba(10, 126, 153, 0.22);
}

.automation-toolbar button:disabled {
  opacity: 1;
  border-color: #ddd2c4;
  background: #ece7df;
  color: #9b9185;
  cursor: not-allowed;
  box-shadow: none;
}

#automationBlockly {
  width: 100%;
  height: calc(100vh - 235px);
  min-height: 590px;
  background-color: #0b2234;
  background-image: radial-gradient(rgba(66, 196, 224, 0.23) 1px, transparent 1px);
  background-size: 24px 24px;
  border-top: 1px solid #24485d;
}

.automation-inspector {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #fffaf3 0%, #f3eadf 100%);
}

.automation-inspector h3 {
  margin: 0;
  padding: 16px;
  border-bottom: 1px solid rgba(172, 132, 84, 0.22);
  background: linear-gradient(135deg, #f6ead9, #fffaf3);
  color: #392b22;
  font-size: 20px;
}

.automation-inspector-scroll {
  padding: 14px;
  overflow: auto;
  display: grid;
  gap: 12px;
}

.automation-card {
  border: 1px solid rgba(173, 139, 100, 0.24);
  background: rgba(255, 255, 255, 0.82);
  border-radius: 14px;
  padding: 13px;
  box-shadow: 0 7px 18px rgba(91, 62, 32, 0.07);
}

.automation-card h4 { margin: 0 0 9px; font-size: 14px; color: #17627a; }
.automation-card p { margin: 5px 0; font-size: 12px; color: #725f50; line-height: 1.6; }
.automation-card strong { color: #30231b; }

.automation-validation {
  border-left: 4px solid #e7a337;
  background: #fff7e8;
  color: #89510a;
}
.automation-validation.ok {
  border-left-color: #1faf77;
  background: #ebfaf3;
  color: #157451;
}
.automation-validation.bad {
  border-left-color: #e45072;
  background: #fff0f3;
  color: #a62e4a;
}

.automation-json {
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0 -4px -4px;
  padding: 12px;
  border-radius: 10px;
  background: #102737;
  color: #d9f3fb;
  font: 11px/1.5 Consolas, monospace;
}

.automation-sensor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.automation-sensor-grid span {
  border: 1px solid #c9e3e9;
  background: linear-gradient(145deg, #f4fbfc, #edf5f4);
  border-radius: 9px;
  padding: 8px;
  font-size: 11px;
  color: #627279;
}
.automation-sensor-grid b { display: block; margin-top: 4px; color: #15566b; font-size: 15px; }

.automation-empty {
  min-height: 420px;
  display: grid;
  place-items: center;
  color: #6f6257;
}

.automation-sim-result { font-size: 13px; line-height: 1.65; }
.automation-sim-result .pass { color: #13825b; }
.automation-sim-result .fail { color: #c83c5c; }

.automation-main .blocklyToolboxDiv {
  background: #10283a !important;
  border-right: 1px solid #31566c !important;
}

.automation-main .blocklyTreeLabel { color: #f4f9fb !important; font-weight: 700; }
.automation-main .blocklyTreeRow { border-radius: 0 9px 9px 0; margin: 3px 8px 3px 0; }
.automation-main .blocklyTreeSelected { background-color: #1d4d65 !important; }
.automation-main .blocklyFlyoutBackground { fill: #173448 !important; fill-opacity: 0.98 !important; }
.automation-main .blocklyMainBackground { stroke: #2d5d75 !important; stroke-width: 1px !important; }
.automation-main .blocklyScrollbarHandle { fill: #4a819a !important; }

@media (max-width: 1100px) {
  .automation-shell { grid-template-columns: 1fr; }
  .automation-inspector { max-height: none; }
  #automationBlockly { height: 640px; }
}

@media (max-width: 720px) {
  .automation-rule-name { min-width: 100%; }
  #automationBlockly { height: 520px; min-height: 520px; }
  .automation-shell { min-height: auto; }
}
