.automation-view {
  display: none;
  gap: 16px;
}
.automation-view.active {
  display: grid;
}
.automation-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 26px;
  border: 1px solid #cad8ea;
  border-radius: 16px;
  background: linear-gradient(125deg, #102a49, #183f68 62%, #245d87);
  color: #fff;
  box-shadow: 0 14px 34px #14304d24;
}
.automation-hero small,
.automation-guard > small {
  color: #78b7eb;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 1.8px;
}
.automation-hero h2 {
  margin: 6px 0;
  font-size: 24px;
}
.automation-hero p {
  margin: 0;
  color: #c8d9ea;
  font-size: 11px;
}
.automation-hero-actions {
  display: flex;
  gap: 9px;
}
.automation-hero .secondary {
  border-color: #6d8dad;
  background: #ffffff12;
  color: #fff;
}
.automation-hero .secondary.danger {
  border-color: #ffb7b7;
  color: #ffd6d6;
}
.automation-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 11px;
}
.automation-metrics article {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 17px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.automation-metrics span,
.automation-metrics small {
  color: var(--muted);
  font-size: 9px;
}
.automation-metrics strong {
  font-size: 22px;
}
.automation-metrics strong.good {
  color: #137d5a;
}
.automation-metrics strong.policy {
  font-size: 15px;
  color: #2f6398;
}
.automation-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 270px;
  gap: 14px;
}
.automation-panel {
  overflow: hidden;
}
.automation-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}
.automation-panel-head span {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.automation-panel-head b {
  font-size: 14px;
}
.automation-panel-head small {
  color: var(--muted);
  font-size: 9px;
}
.automation-panel-head > i {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #567087;
  font-size: 9px;
  font-style: normal;
}
.automation-panel-head em {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #1b9b6c;
  box-shadow: 0 0 0 4px #1b9b6c18;
}
.automation-rules {
  display: grid;
  gap: 0;
}
.automation-rule {
  display: grid;
  grid-template-columns: minmax(210px, 1.1fr) minmax(230px, 1.5fr) 125px 150px;
  align-items: center;
  gap: 16px;
  padding: 17px 18px;
  border-bottom: 1px solid var(--line);
}
.automation-rule:last-child {
  border-bottom: 0;
}
.automation-rule-identity {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.automation-rule-identity > i {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 10px;
  background: #eaf1f9;
  color: #366996;
  font-size: 10px;
  font-style: normal;
  font-weight: 900;
}
.automation-rule-identity span,
.automation-rule-reply {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
}
.automation-rule b {
  font-size: 11px;
}
.automation-rule small {
  color: var(--muted);
  font-size: 8px;
  line-height: 1.5;
}
.automation-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.automation-keywords i {
  padding: 4px 7px;
  border-radius: 999px;
  background: #edf3f9;
  color: #3d6488;
  font-size: 8px;
  font-style: normal;
  font-weight: 800;
}
.automation-rule-reply b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.automation-rule-status {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.automation-rule-status i {
  width: max-content;
  padding: 5px 8px;
  border-radius: 999px;
  background: #f0f2f5;
  color: #687585;
  font-size: 8px;
  font-style: normal;
  font-weight: 900;
}
.automation-rule-status i.enabled {
  background: #e9f7f1;
  color: #147653;
}
.automation-rule-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}
.automation-rule-actions button {
  padding: 7px 9px;
  font-size: 9px;
}
.automation-rule-actions .danger {
  color: #b33333;
}
.automation-empty {
  padding: 46px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
}
.automation-guard {
  align-self: start;
  padding: 20px;
  border: 1px solid #cbd9e8;
  border-radius: 14px;
  background: linear-gradient(160deg, #f8fbff, #edf4fa);
}
.automation-guard h3 {
  margin: 7px 0 16px;
  font-size: 16px;
}
.automation-guard p {
  display: flex;
  gap: 10px;
  margin: 0;
  padding: 12px 0;
  border-top: 1px solid #dbe5ef;
}
.automation-guard p > i {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 7px;
  background: #1d4f7b;
  color: #fff;
  font-size: 9px;
  font-style: normal;
  font-weight: 900;
}
.automation-guard p span {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.automation-guard p b {
  font-size: 10px;
}
.automation-guard p small {
  color: #66788a;
  font-size: 8px;
  line-height: 1.45;
}
.automation-rule-modal {
  width: min(680px, calc(100vw - 30px));
}
.automation-rule-form {
  display: grid;
  gap: 12px;
}
.automation-rule-form textarea {
  min-height: 76px;
}
.automation-template-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
  align-items: end;
}
.automation-template-picker button {
  min-height: 38px;
}
.automation-template-tips {
  display: grid;
  gap: 4px;
  border: 1px solid #bed7f3;
  border-radius: 10px;
  padding: 11px 13px;
  background: #f1f7ff;
  color: #4f6682;
  font-size: 9px;
  line-height: 1.6;
}
.automation-template-tips b {
  color: #285e9d;
  font-size: 10px;
}
.automation-confirm-modal {
  width: min(650px, calc(100vw - 30px));
}
.automation-confirm-summary {
  display: grid;
  gap: 8px;
}
.automation-confirm-summary > div {
  display: grid;
  gap: 5px;
  border: 1px solid #dce5ef;
  border-radius: 9px;
  padding: 11px 13px;
  background: #f9fbfd;
}
.automation-confirm-summary small {
  color: #748397;
  font-size: 9px;
}
.automation-confirm-summary b {
  color: #263c57;
  font-size: 10px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.automation-confirm-check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 14px;
  border: 1px solid #f0d59d;
  border-radius: 9px;
  padding: 11px 13px;
  background: #fff9ea;
  color: #765c25;
  font-size: 9px;
  line-height: 1.6;
}
.automation-confirm-check input {
  margin-top: 2px;
}
.automation-form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.automation-security-note {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #d4e3f1;
  border-radius: 8px;
  background: #f3f8fc;
  color: #486780;
  font-size: 9px;
  line-height: 1.5;
}
.automation-schedule {
  display: grid;
  gap: 10px;
  border: 1px solid #dbe5ef;
  border-radius: 10px;
  padding: 12px;
  background: #f8fbfe;
}
.automation-schedule-toggle {
  color: #365978;
  font-size: 10px;
  font-weight: 800;
}
.automation-weekdays {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.automation-weekdays label {
  display: flex;
  gap: 4px;
  align-items: center;
  border: 1px solid #d7e1ec;
  border-radius: 7px;
  padding: 5px 7px;
  background: #fff;
  font-size: 9px;
}
.automation-executions-panel {
  overflow: hidden;
}
.automation-panel-head select {
  height: 32px;
  border: 1px solid #d7e1ec;
  border-radius: 7px;
  padding: 0 9px;
  background: #fff;
  font-size: 9px;
}
.automation-executions td {
  font-size: 9px;
}
.automation-executions code {
  color: #6b7a8b;
  font-size: 8px;
}
.execution-outcome {
  display: inline-flex;
  border-radius: 999px;
  padding: 5px 8px;
  background: #fff2e2;
  color: #98611f;
  font-size: 8px;
  font-style: normal;
  font-weight: 800;
}
.execution-outcome.queued {
  background: #e9f7f1;
  color: #147653;
}
body.theme-dark .automation-metrics article,
body.theme-dark .automation-panel,
body.theme-dark .automation-guard {
  border-color: #334353;
  background: #171d25;
  color: #edf2f7;
}
body.theme-dark .automation-rule {
  border-color: #313d49;
}
body.theme-dark .automation-keywords i {
  background: #26384a;
  color: #a9c7e2;
}
body.theme-dark .automation-security-note {
  border-color: #35485b;
  background: #1b2937;
  color: #a9bfd3;
}
@media (max-width: 1050px) {
  .automation-layout {
    grid-template-columns: 1fr;
  }
  .automation-guard {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0 16px;
  }
  .automation-guard > small,
  .automation-guard > h3 {
    grid-column: 1/-1;
  }
  .automation-rule {
    grid-template-columns: 1fr 1.3fr 110px;
  }
  .automation-rule-actions {
    grid-column: 1/-1;
    justify-content: flex-start;
  }
}
@media (max-width: 760px) {
  .automation-hero {
    align-items: flex-start;
    flex-direction: column;
  }
  .automation-metrics {
    grid-template-columns: repeat(2, 1fr);
  }
  .automation-rule {
    grid-template-columns: 1fr;
  }
  .automation-guard {
    grid-template-columns: 1fr;
  }
  .automation-form-grid {
    grid-template-columns: 1fr;
  }
  .automation-template-picker {
    grid-template-columns: 1fr;
  }
}
