:root {
  color-scheme: light;
  --bg: #f7fafc;
  --panel: #ffffff;
  --panel-soft: #f1f7fc;
  --text: #102033;
  --muted: #627389;
  --line: #d8e4ef;
  --primary: #168df5;
  --primary-strong: #0d6ed6;
  --primary-soft: #e4f3ff;
  --accent: #f8bd42;
  --accent-strong: #df981c;
  --ok: #1c9a68;
  --warn: #a86d12;
  --danger: #b83b4b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.icon-sprite {
  display: none;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.brand-mark img {
  width: 64px;
  height: 64px;
  padding: 5px;
}

.brand-copy {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--primary-strong);
  font-size: 13px;
  font-weight: 650;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  font-weight: 760;
  letter-spacing: 0;
}

h2 {
  font-size: 17px;
  font-weight: 720;
}

.actions,
.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  color: var(--text);
  background: var(--panel);
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

button:hover {
  border-color: var(--primary);
  color: var(--primary-strong);
  background: var(--primary-soft);
}

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

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

.primary:hover {
  background: var(--primary-strong);
  border-color: var(--primary-strong);
  color: #fff;
}

.accent {
  background: var(--accent);
  color: #102033;
}

.accent:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: #102033;
}

.ghost {
  border-color: var(--line);
  background: var(--panel);
}

.status-grid,
.app-layout {
  display: grid;
  gap: 14px;
}

.status-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 14px;
}

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

.metric {
  min-height: 82px;
  padding: 14px;
  position: relative;
  overflow: hidden;
}

.metric span,
label span,
.panel-head p {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 2px;
  font-size: 16px;
  overflow-wrap: anywhere;
}

.app-layout {
  grid-template-columns: minmax(420px, 0.9fr) minmax(360px, 1.1fr);
  align-items: start;
}

.config-column,
.side-column {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.side-column {
  position: sticky;
  top: 16px;
  align-self: start;
}

.panel {
  padding: 18px;
  min-width: 0;
}

details.panel {
  padding: 0;
}

details.panel > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

details.panel > summary::-webkit-details-marker {
  display: none;
}

details.panel > summary ~ * {
  margin: 0 16px 16px;
}

summary strong {
  display: block;
  font-size: 16px;
}

summary small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.disclosure {
  position: relative;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.disclosure::before,
.disclosure::after {
  content: "";
  position: absolute;
  top: 13px;
  left: 8px;
  width: 12px;
  height: 2px;
  border-radius: 2px;
  background: var(--primary);
  transition: transform 160ms ease;
}

.disclosure::after {
  transform: rotate(90deg);
}

details[open] .disclosure::after {
  transform: rotate(0deg);
}

details.panel[open] > summary {
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.panel-head {
  justify-content: space-between;
  margin-bottom: 16px;
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  background: #fff;
  outline: none;
  min-width: 0;
}

textarea {
  min-height: 70px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: none;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 14px;
}

.form-grid.compact {
  margin-top: 12px;
}

.task-group {
  display: grid;
  gap: 12px;
}

.task-group + .task-group {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.task-switch {
  background: #fff;
}

.push-error-only {
  align-self: end;
}

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

.push-channel {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.push-channel-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.push-channel-toggle {
  margin: 0;
  background: #fff;
}

.push-channel-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.push-channel-fields {
  margin-top: 0;
}

.task-group.is-disabled .chips,
.task-group.is-disabled .compact {
  opacity: 0.48;
}

.task-group.is-disabled .chip,
.task-group.is-disabled .compact .check-row {
  color: var(--muted);
  background: #f7fafc;
}

.task-group.is-disabled .chip,
.task-group.is-disabled .chip input,
.task-group.is-disabled .compact .check-row,
.task-group.is-disabled .compact input {
  cursor: not-allowed;
}

.section-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-top: -4px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.check-row input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--primary);
}

.check-row span {
  color: var(--text);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  background: #fff;
}

.chip input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--primary);
}

.account-row {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  min-width: 0;
}

.account-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.account-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: nowrap;
}

.account-row + .account-row {
  margin-top: 10px;
}

.account-title {
  min-width: 0;
}

.account-title strong,
.account-title small {
  display: flex;
  align-items: center;
  gap: 7px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-title small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  padding-left: 17px;
}

.account-name-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inline-name-input {
  width: min(360px, 100%);
  min-height: 32px;
  padding: 5px 8px;
  font-weight: 600;
}

.status-dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #c3cbd1;
}

.status-dot.ok {
  background: var(--ok);
}

.icon-only {
  width: 42px;
  padding: 0;
}

.hidden-field {
  display: none;
}

.is-hidden {
  display: none !important;
}

.account-login-slot {
  display: none;
  grid-column: 1 / -1;
}

.account-login-slot.active {
  display: block;
}

.inline-login {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
}

.inline-login img {
  width: 150px;
  height: 150px;
  image-rendering: pixelated;
}

.inline-login.pending {
  grid-template-columns: 48px minmax(0, 1fr);
}

.qr-loading {
  width: 42px;
  height: 42px;
  border: 3px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.inline-login p {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.empty-state {
  display: grid;
  gap: 4px;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel-soft);
}

.empty-state strong {
  color: var(--text);
  font-size: 15px;
}

.empty-state span {
  font-size: 13px;
}

.message {
  margin-top: 12px;
  color: var(--muted);
  min-height: 22px;
}

.logs {
  height: min(520px, calc(100vh - 210px));
  min-height: 320px;
  max-height: 560px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1d32;
  color: #dcecff;
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.log-panel {
  display: block;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  max-width: min(520px, calc(100% - 32px));
  padding: 10px 14px;
  border-radius: 8px;
  color: #fff;
  background: var(--primary);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.toast.show {
  opacity: 1;
}

@media (max-width: 860px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand-mark {
    width: 58px;
    height: 58px;
    border-radius: 14px;
  }


  .actions {
    width: 100%;
    justify-content: flex-start;
  }

  .status-grid,
  .app-layout,
  .form-grid.two,
  .form-grid.four {
    grid-template-columns: 1fr;
  }

  .status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  .account-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .side-column {
    position: static;
    max-height: none;
  }

  .icon-only {
    width: 100%;
  }

  .logs {
    height: auto;
    max-height: 420px;
    min-height: 300px;
  }

  .inline-login {
    grid-template-columns: 1fr;
    justify-items: center;
  }
}

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

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

  .actions button {
    width: 100%;
    min-width: 0;
  }

  .actions .accent {
    grid-column: 1 / -1;
  }

  .account-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }

  .account-actions button,
  .icon-only {
    width: 100%;
    min-width: 0;
  }

  .section-toolbar {
    justify-content: stretch;
  }

  .section-toolbar button {
    width: 100%;
    min-width: 0;
  }

  h1 {
    font-size: 26px;
  }

  .panel,
  .metric {
    padding: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* 密码认证页 */
.auth-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.auth-card {
  width: min(400px, calc(100% - 32px));
  padding: 32px 28px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  text-align: center;
}

.auth-card .brand-mark {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
}

.auth-card .brand-mark img {
  width: 60px;
  height: 60px;
}

.auth-card h2 {
  margin: 0 0 6px;
  font-size: 22px;
}

.auth-card .auth-subtitle {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 24px;
}

.auth-card input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 15px;
  margin-bottom: 16px;
  text-align: center;
  letter-spacing: 2px;
}

.auth-card input:focus {
  border-color: var(--primary);
}

.auth-card button {
  width: 100%;
  min-height: 44px;
  font-size: 15px;
}

.auth-card .auth-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  min-height: 20px;
}
