:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #172033;
  --muted: #657086;
  --line: #d8dee8;
  --accent: #1264a3;
  --accent-dark: #0b4778;
  --danger: #a33221;
  --success: #1f7a4d;
  --terminal: #111827;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.shell {
  width: 100%;
  min-height: 100vh;
  padding: 24px;
}

.workspace {
  max-width: 1180px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 8px 0 20px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  font-weight: 700;
}

h2 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
}

.license-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.license-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 10px;
  font-weight: 700;
  color: var(--accent-dark);
  background: #e5f1fb;
}

.license-pill.active {
  color: var(--success);
  background: #e7f6ed;
}

.license-pill.warning {
  color: #7a5a00;
  background: #fff3c4;
}

.license-pill.danger {
  color: var(--danger);
  background: #fbe9e6;
}

.license-gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(244, 246, 248, 0.86);
  backdrop-filter: blur(4px);
}

.license-gate[hidden] {
  display: none;
}

.license-dialog {
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: var(--panel);
  box-shadow: 0 22px 60px rgba(23, 32, 51, 0.18);
}

.license-dialog p {
  margin: 6px 0 18px;
  color: var(--muted);
  font-size: 14px;
}

.license-dialog .license-contact {
  margin: 14px 0 0;
}

.license-dialog a,
.page-footer a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.license-dialog a:hover,
.page-footer a:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

.license-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.update-notice {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(23, 32, 51, 0.42);
  backdrop-filter: blur(5px);
}

.update-notice[hidden] {
  display: none;
}

.update-dialog {
  width: min(560px, 100%);
  display: grid;
  gap: 16px;
  border: 1px solid #c8d7e8;
  border-radius: 10px;
  padding: 24px;
  background: #ffffff;
  box-shadow: 0 24px 72px rgba(23, 32, 51, 0.24);
}

.update-kicker {
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.update-dialog h2 {
  margin-bottom: 8px;
  font-size: 20px;
}

.update-dialog p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.update-command {
  display: grid;
  gap: 7px;
}

.update-command span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.update-command code {
  display: block;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #f7f9fc;
  color: var(--text);
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
  word-break: break-all;
}

.update-command.windows {
  opacity: 0.86;
}

.update-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.status {
  min-width: 96px;
  text-align: center;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
}

.status.running {
  color: var(--accent-dark);
  border-color: #83b7df;
}

.status.stopping,
.status.canceled {
  color: #7a5a00;
  border-color: #d4b455;
}

.status.succeeded {
  color: var(--success);
  border-color: #8bc9a7;
}

.status.failed {
  color: var(--danger);
  border-color: #d99a90;
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.panel,
.actions {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}

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

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

.account-strip div {
  display: grid;
  gap: 4px;
}

.account-strip strong {
  font-size: 14px;
}

.account-strip span {
  color: var(--muted);
  font-size: 13px;
}

.account-strip .account-email {
  color: var(--text);
  font-weight: 600;
}

.account-strip .account-actions {
  display: flex;
  gap: 10px;
  flex: 0 0 auto;
  white-space: nowrap;
}

.proxy-control-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto minmax(180px, 0.8fr);
  align-items: end;
  gap: 12px;
}

.proxy-input-field {
  min-width: 0;
}

#checkProxyButton {
  height: 42px;
  min-height: 42px;
}

#proxyCheckResult {
  display: flex;
  align-items: center;
  min-height: 42px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
  font: inherit;
  color: var(--text);
  background: #fff;
}

input:focus {
  outline: 3px solid rgba(18, 100, 163, 0.16);
  border-color: var(--accent);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.preset-list {
  display: grid;
  gap: 12px;
}

.preset-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #fff;
}

.preset-item.dragging {
  opacity: 0.55;
  border-color: var(--accent);
}

.preset-head {
  display: grid;
  grid-template-columns: 42px 88px minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.drag-handle {
  width: 42px;
  min-height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #f6f9fc;
  cursor: grab;
}

.drag-handle:active {
  cursor: grabbing;
}

.preset-check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.preset-check input {
  width: 18px;
  min-height: 18px;
}

textarea {
  display: none;
  width: 100%;
  min-height: 118px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  resize: vertical;
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color: var(--text);
}

.preset-item.expanded textarea {
  display: block;
}

textarea:focus {
  outline: 3px solid rgba(18, 100, 163, 0.16);
  border-color: var(--accent);
}

.inline-actions {
  display: flex;
  gap: 10px;
  margin: 0 0 12px;
}

.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  font: inherit;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

button.secondary {
  color: var(--text);
  background: #e8edf3;
}

button.secondary:hover {
  background: #dce4ee;
}

.drag-handle,
.drag-handle:hover {
  width: 42px;
  min-height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #f6f9fc;
  cursor: grab;
}

button.danger {
  background: #a33221;
}

button.danger:hover {
  background: #7c2418;
}

.output-panel {
  margin-top: 16px;
}

.history-panel {
  margin-top: 16px;
}

.output-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.history-head h2 {
  margin-bottom: 0;
}

.history-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.history-table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  font-size: 13px;
}

.history-table th,
.history-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.history-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f9fbfd;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.history-table td {
  background: #fff;
}

.history-table tr:last-child td {
  border-bottom: 0;
}

.history-table span {
  display: block;
  margin-bottom: 3px;
}

.history-table code {
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
  word-break: break-all;
}

.history-command-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 260px;
}

.history-command-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  max-width: 100%;
  margin: 0;
  padding: 3px 8px;
  border: 1px solid #c8d7e8;
  border-radius: 999px;
  color: #28506f;
  background: #eef5fb;
  font-size: 12px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-muted-inline {
  display: inline;
  margin: 0;
  color: var(--muted);
}

.history-muted {
  color: var(--muted);
  text-align: center;
}

.history-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 12px;
}

.history-pager button {
  min-height: 36px;
  padding: 0 14px;
}

.history-pager span {
  color: var(--muted);
  font-size: 13px;
}

.page-footer {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 18px 4px 4px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.footer-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #aab4c3;
}

#jobId {
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

.log-output {
  width: 100%;
  min-height: 320px;
  max-height: 520px;
  margin: 0;
  overflow: auto;
  background: var(--terminal);
  color: #e5e7eb;
  border-radius: 8px;
  padding: 16px;
  font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
}

.result {
  margin-top: 16px;
  border: 1px solid #8bc9a7;
  border-radius: 8px;
  padding: 14px;
  color: #174c32;
  background: #eef8f2;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}

@media (max-width: 760px) {
  .shell {
    padding: 16px;
  }

  .topbar,
  .actions,
  .output-head,
  .history-head,
  .history-pager {
    align-items: stretch;
    flex-direction: column;
  }

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

  .account-strip,
  .inline-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .proxy-control-row {
    grid-template-columns: minmax(220px, 1fr) auto minmax(150px, 0.7fr);
    align-items: end;
  }

  .account-actions button {
    width: auto;
    flex: 1;
  }

  .preset-head {
    grid-template-columns: 1fr;
  }

  .status {
    width: 100%;
  }

  button {
    width: 100%;
  }

  #checkProxyButton {
    width: auto;
  }

}

@media (max-width: 560px) {
  .proxy-control-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  #proxyCheckResult {
    grid-column: 1 / -1;
    min-height: 20px;
  }
}
