.automation-page main { padding-bottom: 48px; }
.automation-intro { align-items: flex-end; }
.automation-save-note { color: var(--muted); font-size: 12px; font-weight: 650; }

.automation-overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.automation-stat {
  min-height: 132px;
  padding: 22px 24px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.automation-stat > * { position: relative; z-index: 1; }
.automation-stat > span { display: block; color: #9799ad; font-size: 12px; font-weight: 850; letter-spacing: .09em; }
.automation-stat > strong { display: block; margin-top: 8px; color: var(--ink); font-size: clamp(28px, 2.6vw, 38px); line-height: 1; letter-spacing: -.045em; }
.automation-stat > small { display: block; margin-top: 12px; color: var(--muted); font-size: 12px; line-height: 1.45; }

.automation-alert {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  margin-bottom: 18px;
  padding: 15px 18px;
  border: 1px solid #f0c9b6;
  border-radius: 16px;
  background: #fff8f3;
  color: #9c5738;
}
.automation-alert > span { display: grid; width: 24px; height: 24px; flex: 0 0 auto; place-items: center; border-radius: 50%; background: #efb08f; color: #fff; font-weight: 900; }
.automation-alert strong { display: block; font-size: 13px; }
.automation-alert p { margin: 4px 0 0; font-size: 12px; line-height: 1.5; }

.automation-jobs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.automation-job { min-width: 0; padding: 0; overflow: hidden; }
.job-heading { display: flex; justify-content: space-between; gap: 18px; min-height: 170px; padding: 28px 30px 24px; border-bottom: 1px solid var(--border); }
.job-heading > div { position: relative; }
.job-heading h2 { margin: 8px 0 7px; color: var(--ink); font-size: 28px; line-height: 1.05; letter-spacing: -.04em; }
.job-heading p { max-width: 520px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.job-state { position: relative; z-index: 2; align-self: flex-start; min-width: 70px; padding: 8px 10px; border-radius: 9px; background: #f0f1f6; color: #9699a9; font-size: 11px; font-weight: 900; letter-spacing: .07em; text-align: center; }
.job-state.is-running { background: #e9f7ef; color: #3f9d75; }
.job-state.is-paused { background: #f4f1ff; color: #7c70d6; }
.job-state.is-error { background: #fff0e8; color: #bf6f48; }

.job-schedule-summary { display: flex; min-height: 45px; align-items: center; justify-content: space-between; gap: 16px; padding: 0 30px; border-bottom: 1px solid var(--border); color: #9a9eaf; background: #fafbfe; font-size: 10px; }
.job-schedule-summary strong { color: #666b82; font-size: 11px; font-weight: 800; }

.job-runtime { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-bottom: 1px solid var(--border); }
.job-runtime > div { min-width: 0; padding: 18px 30px; }
.job-runtime > div + div { border-left: 1px solid var(--border); }
.job-runtime small { display: block; color: #a0a3b2; font-size: 11px; font-weight: 750; }
.job-runtime strong { display: block; overflow: hidden; margin-top: 5px; color: #555a70; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }

.job-form { display: grid; gap: 15px; padding: 25px 30px; }
.collection-mode-field { min-width: 0; margin: 0; padding: 0; border: 0; }
.collection-mode-field legend { margin-bottom: 8px; color: #676b80; font-size: 12px; font-weight: 800; }
.collection-mode-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.collection-mode-grid label { min-width: 0; cursor: pointer; }
.collection-mode-grid input { position: absolute; opacity: 0; }
.collection-mode-grid span { display: grid; min-height: 65px; align-content: center; gap: 4px; padding: 10px; border: 1px solid #dfe3ed; border-radius: 11px; background: #fff; transition: border-color .16s, background .16s, box-shadow .16s; }
.collection-mode-grid b { color: #666b80; font-size: 12px; }
.collection-mode-grid small { color: #9da0af; font-size: 9px; line-height: 1.35; }
.collection-mode-grid input:checked + span { border-color: #8d81e7; background: #f0edff; box-shadow: inset 0 0 0 1px rgba(111, 94, 220, .1); }
.collection-mode-grid input:checked + span b { color: #6758d2; }
.collection-mode-grid input:focus-visible + span { outline: 3px solid rgba(109, 95, 224, .2); outline-offset: 2px; }
.collection-mode-field:disabled { opacity: .6; }
.webhook-route-note { display: grid; grid-template-columns: 9px minmax(0, 1fr) auto; align-items: center; gap: 11px; padding: 12px 13px; border: 1px solid #e4e8f1; border-radius: 12px; background: #fafbfe; }
.webhook-route-note .runtime-dot { width: 8px; height: 8px; }
.webhook-route-note b { display: block; color: #606579; font-size: 11px; }
.webhook-route-note small { display: block; overflow: hidden; margin-top: 3px; color: #9ca0af; font-family: var(--font-mono); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.webhook-route-note a { color: #7367cf; font-size: 10px; font-weight: 800; white-space: nowrap; }
.automation-toggle { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 17px; border: 1px solid #dfe5f1; border-radius: 14px; background: #fafbfe; cursor: pointer; }
.automation-toggle span { min-width: 0; }
.automation-toggle b { display: block; color: #555a70; font-size: 13px; }
.automation-toggle small { display: block; margin-top: 4px; color: #9a9dad; font-size: 11px; line-height: 1.45; }
.automation-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.automation-toggle > i { position: relative; width: 39px; height: 22px; flex: 0 0 auto; border-radius: 20px; background: #d9dce5; transition: background .2s ease; }
.automation-toggle > i::after { content: ""; position: absolute; width: 16px; height: 16px; top: 3px; left: 3px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(51, 57, 79, .18); transition: transform .2s ease; }
.automation-toggle input:checked + i { background: #63bd94; }
.automation-toggle input:checked + i::after { transform: translateX(17px); }
.automation-toggle:has(input:focus-visible) { outline: 3px solid rgba(109, 95, 224, .2); outline-offset: 2px; }
.automation-toggle:has(input:disabled) { cursor: not-allowed; opacity: .6; }
.automation-toggle-compact { padding-block: 13px; }

.automation-field { display: block; }
.automation-field > span, .weekday-field legend { display: block; margin-bottom: 8px; color: #676b80; font-size: 12px; font-weight: 800; }
.automation-field select, .automation-field input { width: 100%; height: 45px; padding: 0 13px; border: 1px solid #dfe3ed; border-radius: 11px; background: #fff; color: #565b70; font: inherit; font-size: 13px; outline: none; }
.automation-field select:focus, .automation-field input:focus { border-color: #8f84e8; box-shadow: 0 0 0 3px rgba(117, 102, 223, .11); }
.automation-field small { display: block; margin-top: 7px; color: #a0a3b2; font-size: 11px; line-height: 1.45; }
.weekday-field { min-width: 0; margin: 0; padding: 0; border: 0; }
.weekday-field > div { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; }
.weekday-field label { cursor: pointer; }
.weekday-field input { position: absolute; opacity: 0; }
.weekday-field span { display: grid; height: 38px; place-items: center; border: 1px solid #dfe3ed; border-radius: 9px; background: #fff; color: #84889b; font-size: 12px; font-weight: 750; transition: .15s ease; }
.weekday-field input:checked + span { border-color: #9185e9; background: #eeeaff; color: #6859d0; }
.weekday-field input:focus-visible + span { outline: 3px solid rgba(109, 95, 224, .2); outline-offset: 2px; }
.weekday-field:disabled { opacity: .6; }

.job-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 19px 30px 25px; border-top: 1px solid var(--border); }
.job-actions > a { color: #74798f; font-size: 12px; font-weight: 750; }
.job-actions > a:hover { color: var(--purple); }

.manual-runs { margin-top: 18px; padding: 0; overflow: hidden; }
.manual-runs-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 22px; padding: 26px 30px 22px; border-bottom: 1px solid var(--border); }
.manual-runs-head h2, .automation-panel-head h2 { margin: 6px 0 0; color: var(--ink); font-size: 22px; letter-spacing: -.035em; }
.manual-runs-head p { max-width: 730px; margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.manual-runs-head > a, .automation-panel-head > a { flex: 0 0 auto; color: #7065cf; font-size: 12px; font-weight: 800; }
.manual-run-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.manual-run-grid article { min-width: 0; padding: 24px 30px 28px; }
.manual-run-grid article + article { border-left: 1px solid var(--border); }
.manual-run-grid article > span { color: #a09daf; font-size: 11px; font-weight: 900; letter-spacing: .1em; }
.manual-run-grid h3 { margin: 8px 0 5px; color: var(--ink); font-size: 21px; }
.manual-run-grid p { min-height: 38px; margin: 0 0 18px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.manual-run-button { display: flex; width: 100%; height: 44px; align-items: center; justify-content: space-between; padding: 0 15px; border: 1px solid #dddfee; border-radius: 11px; background: #f9f9fc; color: #686d82; font: inherit; font-size: 12px; font-weight: 800; cursor: pointer; }
.manual-run-button:hover:not(:disabled) { border-color: #a49bea; background: #f2efff; color: #6557d2; }
.manual-run-button:disabled { cursor: not-allowed; opacity: .5; }
.manual-run-button b { font-size: 16px; }

.automation-bottom-grid { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 18px; margin-top: 18px; }
.runtime-panel, .report-history-panel { padding: 0; overflow: hidden; }
.automation-panel-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 23px 26px 19px; border-bottom: 1px solid var(--border); }
.automation-panel-head > span { color: #a1a4b3; font-size: 11px; }
.runtime-list { padding: 5px 26px; }
.runtime-row { display: grid; grid-template-columns: 10px 1fr auto; gap: 13px; align-items: center; padding: 18px 0; }
.runtime-row + .runtime-row { border-top: 1px solid var(--border); }
.runtime-dot { width: 9px; height: 9px; border-radius: 50%; background: #c8cad4; box-shadow: 0 0 0 5px rgba(173, 176, 190, .12); }
.runtime-dot.is-ok { background: #5dbd91; box-shadow: 0 0 0 5px rgba(93, 189, 145, .12); }
.runtime-dot.is-error { background: #e58a63; box-shadow: 0 0 0 5px rgba(229, 138, 99, .12); }
.runtime-row strong { display: block; color: #565b70; font-size: 13px; }
.runtime-row small { display: block; margin-top: 4px; color: #969aaa; font-size: 11px; line-height: 1.45; }
.runtime-row > span { color: #8a8e9f; font-size: 11px; text-align: right; }

.automation-report-list { padding: 7px 26px; }
.automation-report-row { display: grid; grid-template-columns: auto 1fr auto; gap: 13px; align-items: center; padding: 13px 0; color: inherit; }
.automation-report-row + .automation-report-row { border-top: 1px solid var(--border); }
.automation-report-period { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 10px; background: #eeeaff; color: #7164d3; font-size: 11px; font-weight: 900; }
.automation-report-copy { min-width: 0; }
.automation-report-copy strong { display: block; overflow: hidden; color: #555a70; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.automation-report-copy small { display: block; margin-top: 4px; color: #9a9dac; font-size: 11px; }
.automation-report-row > span:last-child { color: #7b70d5; font-size: 16px; }
.automation-empty { padding: 31px 0; color: #a1a4b2; font-size: 12px; text-align: center; }

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

@media (max-width: 820px) {
  .automation-intro { align-items: flex-start; }
  .automation-intro .page-actions { width: 100%; justify-content: flex-start; }
  .automation-save-note { width: 100%; }
  .automation-bottom-grid { grid-template-columns: 1fr; }
}

@media (max-width: 650px) {
  .automation-overview { grid-template-columns: 1fr; }
  .automation-stat { min-height: 112px; }
  .job-heading, .job-schedule-summary, .job-form, .job-actions, .manual-runs-head, .automation-panel-head { padding-left: 20px; padding-right: 20px; }
  .job-runtime > div { padding-left: 20px; padding-right: 20px; }
  .job-actions, .manual-runs-head { align-items: stretch; flex-direction: column; }
  .job-actions .button { width: 100%; }
  .manual-run-grid { grid-template-columns: 1fr; }
  .manual-run-grid article { padding-left: 20px; padding-right: 20px; }
  .manual-run-grid article + article { border-top: 1px solid var(--border); border-left: 0; }
  .weekday-field > div { gap: 4px; }
  .runtime-list, .automation-report-list { padding-left: 20px; padding-right: 20px; }
  .collection-mode-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .automation-toggle > i, .automation-toggle > i::after, .manual-run-button { transition: none; }
}
