:root {
  --bg: #f2f5f4;
  --panel: #ffffff;
  --panel-2: #f8faf9;
  --line: #dce3e0;
  --text: #14201c;
  --muted: #5d6b66;
  --accent: #0b6e5a;
  --accent-soft: #dff3ec;
  --danger: #b42318;
  --warn-bg: #fff4d6;
  --warn-text: #7a4d00;
  --log-bg: #111a17;
  --mono: "Cascadia Mono", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  margin-bottom: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 18px;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.run-state {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

.state-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #9aa5a0;
}

.state-dot.running {
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.state-dot.error {
  background: var(--danger);
}

.state-dot.success {
  background: #15803d;
}

.layout {
  display: grid;
  grid-template-columns: minmax(340px, 430px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.compact {
  margin-bottom: 16px;
}

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

.panel-head h2,
.panel-head h3 {
  margin: 0 0 4px;
  font-size: 15px;
  line-height: 1.3;
}

.panel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.pill {
  flex: 0 0 auto;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.pill.ok {
  background: var(--accent-soft);
  border-color: #b6e3d2;
  color: #0b5d4c;
}

.pill.warn {
  background: var(--warn-bg);
  border-color: #eed9a2;
  color: var(--warn-text);
}

.pill.bad {
  background: #fee4e2;
  border-color: #f4b4ae;
  color: #9f1d13;
}

.field {
  display: block;
  margin: 0 0 14px;
  border: 0;
  padding: 0;
  min-width: 0;
}

.field-label,
legend.field-label {
  display: block;
  margin: 0 0 6px;
  color: #34423c;
  font-size: 12px;
  font-weight: 600;
}

input[type="text"],
input[type="date"],
input[type="time"],
input[type="number"],
input[type="email"],
input[type="password"],
select.select {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid #c9d3cf;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  outline: none;
}

select.select {
  appearance: auto;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

select.select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 16px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  cursor: pointer;
  font-size: 12px;
}

.check-row input {
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.check-row.compact {
  margin: 0;
  padding: 7px 9px;
}

.mail-box {
  margin: 0 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.advanced-box {
  margin: 18px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.advanced-box > summary {
  padding: 11px 12px;
  cursor: pointer;
  color: #34423c;
  font-size: 13px;
  font-weight: 600;
  list-style-position: inside;
}

.advanced-box[open] > summary {
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}

.advanced-box > .field,
.advanced-box > .grid-2,
.advanced-box > .mail-box {
  margin-left: 12px;
  margin-right: 12px;
}

.advanced-box > .mail-box {
  width: calc(100% - 24px);
}

.advanced-actions {
  padding: 4px 12px 14px;
  text-align: right;
}

.mail-box summary {
  padding: 10px 12px;
  cursor: pointer;
  color: #34423c;
  font-size: 13px;
  font-weight: 600;
  list-style-position: inside;
}

.mail-box[open] summary {
  border-bottom: 1px solid var(--line);
}

.mail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px;
}

.mail-grid .field {
  margin: 0;
  min-width: 0;
}

.mail-grid .field.wide {
  grid-column: 1 / -1;
}

.mail-options {
  display: flex;
  gap: 8px;
  padding: 0 12px 10px;
}

.mail-box > .btn {
  margin: 0 12px 12px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  margin-bottom: 10px;
  background: #e9eeec;
  border: 1px solid #d9e1dd;
  border-radius: 8px;
}

.segment {
  min-height: 32px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #4c5a54;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}

.segment.active {
  background: #fff;
  border-color: #cdd8d3;
  box-shadow: 0 1px 2px rgba(20, 32, 28, 0.08);
  color: var(--text);
  font-weight: 600;
}

.inline-fields,
.time-range {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.time-option-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.time-option {
  min-height: 44px;
  border: 1px solid #c9d3cf;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
}

.time-option.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #0b5d4c;
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.mini-field {
  display: block;
  min-width: 0;
  flex: 1 1 0;
}

.mini-field span {
  display: block;
  margin-bottom: 4px;
  color: #66736d;
  font-size: 11px;
}

.range-sep {
  flex: 0 0 auto;
  padding: 10px 0;
  color: var(--muted);
  font-size: 12px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.switch-field {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-width: 150px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  margin-top: 6px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #c4cdc9;
  transition: background 0.15s ease;
  cursor: pointer;
}

.switch span::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(20, 32, 28, 0.25);
  transition: transform 0.15s ease;
}

.switch input:checked + span {
  background: var(--accent);
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.btn {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid #c9d3cf;
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  background: #0a5d4b;
}

.btn.ghost {
  width: 100%;
  margin: 2px 0 14px;
  background: var(--panel-2);
  border-style: dashed;
  color: #3d5a50;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.text-btn {
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 0;
}

.text-btn:disabled {
  color: #9aa5a0;
  cursor: not-allowed;
}

.identity-panel {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

#identityFields .field {
  margin-bottom: 10px;
}

.right-column {
  min-width: 0;
}

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

.profile-grid > div {
  min-width: 0;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.profile-grid dt {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
}

.profile-grid dd {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
}

.slot-summary {
  display: grid;
  gap: 8px;
  max-height: 230px;
  overflow: auto;
}

.slot-summary.empty {
  color: var(--muted);
  font-size: 13px;
}

.slot-date {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
}

.slot-date-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
}

.slot-times {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
}

.slot-chip {
  padding: 4px 8px;
  border-radius: 6px;
  background: #e8f5ef;
  color: #0b5d4c;
  font-size: 12px;
  white-space: nowrap;
}

.slot-chip.paid {
  background: #f3edff;
  color: #6442a6;
}

.slot-chip.target {
  outline: 2px solid var(--accent);
}

.log-panel {
  min-height: 260px;
  display: flex;
  flex-direction: column;
}

.pass-panel {
  margin-bottom: 16px;
  text-align: center;
}

.pass-panel .panel-head {
  text-align: left;
}

.pass-panel .panel-head p {
  margin: 0;
}

.pass-image {
  display: block;
  width: min(340px, 100%);
  margin: 0 auto 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.pass-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.account-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 34px;
  gap: 6px;
  align-items: center;
}

.account-rows {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
}

.account-row input {
  min-width: 0;
}

.account-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 10px;
}

.account-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
  color: #66736d;
  font-size: 11px;
}

.account-card-head span:first-child {
  flex: 1 1 0;
}

.account-card-head span:nth-child(2) {
  flex: 0 0 110px;
}

.account-card-head span:last-child {
  flex: 0 0 32px;
}

.account-target {
  display: grid;
  grid-template-columns: minmax(140px, 210px) 1fr;
  gap: 10px;
  align-items: end;
  margin-top: 8px;
}

.account-target .mini-field {
  min-width: 0;
}

.account-target .mini-field span {
  color: #66736d;
  font-size: 11px;
}

.account-times {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.account-times-label {
  margin-top: 6px;
  color: #7a8781;
  font-size: 11px;
}

.time-option {
  min-height: 34px;
  border: 1px solid #c9d3cf;
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.time-option.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #0b5d4c;
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.remove-account {
  width: 32px;
  height: 32px;
  border: 1px solid #d8b4b0;
  border-radius: 7px;
  background: #fff5f4;
  color: #b42318;
  cursor: pointer;
}

.remove-account:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.job-list {
  display: grid;
  gap: 10px;
}

.job-list .empty {
  padding: 22px;
  border: 1px dashed #c9d3cf;
  border-radius: 8px;
  color: #84928c;
  text-align: center;
  background: #fbfdfc;
}

.job-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  overflow: hidden;
}

.job-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
}

.job-uid {
  min-width: 0;
  font-size: 14px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-status {
  flex: 0 0 auto;
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  background: #e9eeec;
  color: #5d6b66;
}

.job-status.running {
  background: var(--accent-soft);
  color: #0b5d4c;
}

.job-status.waiting {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.job-status.success,
.job-status.booked {
  background: #e2f4e9;
  color: #137a3b;
}

.job-status.error,
.job-status.stopped {
  background: #fee4e2;
  color: #9f1d13;
}

.job-body {
  padding: 12px;
}

.job-meta {
  margin: 0 0 10px;
  color: #52605a;
  font-size: 13px;
  line-height: 1.7;
  word-break: break-word;
}

.job-meta strong {
  color: var(--text);
}

.job-pass {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.job-pass img {
  width: min(260px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.job-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.job-identity {
  display: grid;
  gap: 8px;
}

.job-identity .field {
  margin: 0;
}

.log-list {
  height: 300px;
  overflow: auto;
  padding: 10px 12px;
  background: var(--log-bg);
  border-radius: 7px;
  color: #d8e2dd;
  font: 12px/1.65 var(--mono);
  white-space: pre-wrap;
  word-break: break-word;
}

.log-line {
  margin: 0 0 3px;
}

.log-line .time {
  color: #84958e;
}

.log-line.ok {
  color: #9be8c7;
}

.log-line.warn {
  color: #f8d884;
}

.log-line.error {
  color: #ffb3ad;
}

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

  .log-list {
    height: 260px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 10px;
  }

  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

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

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

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

  .mail-options {
    flex-direction: column;
    align-items: flex-start;
  }

  .account-target {
    grid-template-columns: 1fr;
  }
}
