:root {
  color-scheme: light;
  --ink: #202a36;
  --muted: #697586;
  --line: #e1e6ed;
  --surface: #fff;
  --page: #f4f6f9;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #1b8a51;
  --red: #bd3b3b;
  --amber: #9a6411;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  color: var(--ink);
  background: var(--page);
  font-size: 15px;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--page); }
button, input, textarea { font: inherit; }
button { touch-action: manipulation; }
.app-shell { width: min(100% - 24px, 520px); margin: 16px auto 24px; }
.card, .top-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 2px 8px rgb(28 44 64 / 4%);
}
.top-card { padding: 14px 16px 12px; margin-bottom: 12px; }
.device-picker-row { display: flex; align-items: center; gap: 9px; margin: 2px 0 8px; }
.device-picker-row label { color: var(--muted); font-size: 13px; flex: 0 0 auto; }
.device-picker-row select { min-width: 0; max-width: 100%; flex: 1 1 auto; border: 1px solid #d0d5dd; border-radius: 9px; background: #fff; padding: 8px 10px; color: var(--ink); font: inherit; }
.device-picker-row select:disabled { color: var(--muted); background: #f8fafc; }
.top-title-row, .device-line, .connection-line, .section-heading, .panel-heading,
.task-title-row, .recent-main, .recent-meta { display: flex; align-items: center; }
.top-title-row, .section-heading, .panel-heading, .task-title-row, .recent-main {
  justify-content: space-between;
}
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: 19px; line-height: 1.25; }
h2 { margin: 0; font-size: 17px; font-weight: 650; }
.device-line { gap: 8px; min-height: 24px; font-weight: 600; }
.device-count { margin-left: auto; color: var(--muted); font-size: 14px; font-weight: 500; }
.connection-line { min-height: 19px; margin-top: 2px; font-size: 12px; }
.muted, .helper-text, .empty-note { color: var(--muted); }
.warning { color: var(--amber); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #9aa4b2; flex: 0 0 auto; }
.status-dot.online { background: var(--green); box-shadow: 0 0 0 3px rgb(27 138 81 / 11%); }
.status-dot.offline { background: var(--red); }
.status-dot.pending { background: #a6afbb; }
.card { padding: 15px; margin-bottom: 12px; }
.composer > h2 { margin-bottom: 13px; }
.choice-group { border: 0; margin: 0 0 14px; padding: 0; min-width: 0; }
.choice-group legend { margin-bottom: 7px; padding: 0; font-size: 14px; font-weight: 620; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 3px; border-radius: 10px; background: #eef1f5; }
.segmented button {
  min-height: 40px; border: 0; border-radius: 8px; background: transparent; color: #586273;
  font-weight: 620; cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: #fff; color: var(--blue-dark); box-shadow: 0 1px 4px rgb(28 44 64 / 12%); }
.input-panel { margin: 0 0 13px; }
.panel-heading { min-height: 28px; margin-bottom: 7px; font-size: 14px; font-weight: 620; }
.runtime-section { padding-top: 13px; padding-bottom: 12px; }
.runtime-line { margin: 6px 0; font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.runtime-section .section-heading { margin-bottom: 6px; }
.runtime-stop-row { display: flex; align-items: center; gap: 9px; margin: 9px 0 2px; }
.stop-button {
  min-width: 74px; min-height: 35px; padding: 5px 15px; border: 1px solid #e5a1a1;
  border-radius: 8px; background: #fff; color: var(--red); font-weight: 650; cursor: pointer;
}
.stop-button:hover:not(:disabled) { background: #fff3f3; border-color: var(--red); }
.stop-button:disabled { color: #8993a0; border-color: #d9dee6; background: #f5f6f8; cursor: not-allowed; }
.stop-dialog { width: min(420px, calc(100% - 32px)); padding: 19px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); box-shadow: 0 18px 60px rgb(20 35 55 / 24%); }
.stop-dialog::backdrop { background: rgb(23 32 45 / 38%); }
.stop-dialog h2 { margin-bottom: 12px; }
.stop-dialog p { margin-bottom: 7px; line-height: 1.45; }
.stop-confirm-device { font-weight: 650; }
.stop-dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 14px; }
.stop-dialog-actions button { min-height: 40px; padding: 7px 14px; border-radius: 8px; font-weight: 650; cursor: pointer; }
.dialog-cancel { border: 1px solid var(--line); background: #fff; color: var(--ink); }
.dialog-confirm { border: 1px solid var(--red); background: var(--red); color: #fff; }
.dialog-confirm:disabled { opacity: .58; cursor: wait; }
.ht-status-details { margin-top: 8px; border-top: 1px solid #edf0f4; padding-top: 7px; }
.ht-status-details summary { display: flex; justify-content: space-between; gap: 8px; cursor: pointer; font-size: 13px; font-weight: 620; }
.ht-status-list { display: grid; gap: 5px; margin-top: 9px; max-height: 270px; overflow-y: auto; }
.ht-status-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 7px; align-items: baseline; font-size: 12px; }
.ht-status-target { font-weight: 650; }
.ht-status-message { overflow-wrap: anywhere; }
.ht-status-message.warning { color: var(--amber); }
.ht-status-empty { color: var(--muted); }
.scheme-list { display: grid; gap: 6px; max-height: 250px; overflow-y: auto; overscroll-behavior: contain; }
.scheme-row {
  display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 9px; cursor: pointer;
}
.scheme-row:has(input:checked) { border-color: #9bbaf8; background: #f5f8ff; }
.scheme-row input { width: 18px; height: 18px; margin: 0; accent-color: var(--blue); flex: 0 0 auto; }
.scheme-name { min-width: 0; overflow-wrap: anywhere; line-height: 1.3; }
.scheme-count-note { margin-left: auto; white-space: nowrap; color: var(--muted); font-size: 12px; }
.empty-note { margin: 7px 0; font-size: 13px; }
textarea, input[type="text"], input[type="password"] {
  width: 100%; border: 1px solid #cdd5df; border-radius: 9px; background: #fff;
  color: var(--ink); outline: none;
}
textarea { min-height: 112px; padding: 10px 11px; resize: vertical; line-height: 1.45; }
input[type="text"], input[type="password"] { min-height: 43px; padding: 8px 10px; }
textarea:focus, input:focus { border-color: #6d9af2; box-shadow: 0 0 0 3px rgb(37 99 235 / 12%); }
.helper-text { margin: 6px 0 0; font-size: 12px; }
.chain-history-heading { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; border-top: 1px solid #edf0f4; }
.chain-history-list { display: grid; gap: 4px; max-height: 210px; overflow-y: auto; margin-top: 4px; }
.chain-history-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px; align-items: center; }
.chain-history-fill { min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; background: #fff; color: var(--ink); text-align: left; font-size: 12px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chain-history-delete { border: 0; background: transparent; color: var(--muted); padding: 6px 8px; font-size: 12px; cursor: pointer; }
.text-button { border: 0; background: transparent; min-height: 36px; padding: 4px 7px; color: var(--blue-dark); font-size: 13px; cursor: pointer; }
.submit-summary { margin: 5px 0 9px; color: #465264; font-size: 13px; text-align: center; }
.primary-button {
  display: block; width: 100%; min-height: 47px; border: 0; border-radius: 10px;
  background: var(--blue); color: white; font-weight: 700; cursor: pointer;
}
.primary-button:hover:not(:disabled) { background: var(--blue-dark); }
.primary-button:disabled { background: #aab5c4; cursor: not-allowed; }
.action-message { min-height: 19px; margin: 7px 0 0; color: var(--muted); text-align: center; font-size: 13px; }
.section-heading { min-height: 24px; margin-bottom: 10px; }
.status-chip { border-radius: 999px; padding: 4px 8px; background: #eef3fb; color: #455c7b; font-size: 12px; }
.task-title-row { align-items: flex-start; gap: 8px; }
.task-name { margin: 0 0 3px; font-size: 14px; font-weight: 650; }
.task-headline { margin: 0; color: var(--blue-dark); font-size: 14px; font-weight: 650; }
.task-time { white-space: nowrap; font-size: 12px; }
.step-list { list-style: none; margin: 12px 0 8px; padding: 0; display: grid; gap: 7px; }
.step-row { display: grid; grid-template-columns: 20px 1fr auto; gap: 7px; align-items: center; min-height: 24px; font-size: 13px; }
.step-icon { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; color: #8b95a3; font-size: 13px; }
.step-row.done .step-icon { color: var(--green); }
.step-row.active .step-icon { color: var(--blue); }
.step-row.partial .step-icon { color: var(--amber); }
.step-row.active .step-label { color: var(--blue-dark); font-weight: 650; }
.step-count { color: var(--muted); font-size: 12px; }
.result-line { margin: 10px 0 4px; padding: 9px 10px; border-radius: 8px; background: #f0f8f3; color: var(--green); font-weight: 700; }
.result-line.partial { background: #fff7e8; color: var(--amber); }
.result-line.failed { background: #fff0f0; color: var(--red); }
.failure-list { display: grid; gap: 5px; margin-top: 7px; color: #7f3333; font-size: 12px; }
.recent-list { display: grid; gap: 4px; }
.recent-item { width: 100%; padding: 9px 1px; border: 0; border-top: 1px solid #edf0f4; background: transparent; text-align: left; cursor: pointer; }
.recent-main { gap: 8px; font-size: 13px; }
.recent-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.recent-outcome { flex: 0 0 auto; color: var(--muted); }
.recent-meta { justify-content: space-between; gap: 8px; margin-top: 4px; color: var(--muted); font-size: 11px; }
.recent-detail { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.page-footer { margin: 12px 3px 0; color: #8590a0; font-size: 11px; text-align: center; line-height: 1.4; }
.login-shell { margin-top: max(8vh, 24px); }
.login-card { padding: 20px; }
.login-card h1 { margin-bottom: 4px; }
.login-card > .muted { margin-bottom: 20px; font-size: 13px; }
.field-label { display: block; margin: 14px 0 6px; font-size: 14px; font-weight: 600; }
.login-submit { margin-top: 19px; }
[hidden] { display: none !important; }

@media (min-width: 700px) {
  .app-shell { margin-top: 28px; }
  .top-card, .card { padding-left: 18px; padding-right: 18px; }
}
