:root {
  --bg: #f5f5f7;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-solid: #ffffff;
  --text: #1d1d1f;
  --secondary: #6e6e73;
  --tertiary: #8e8e93;
  --separator: rgba(60, 60, 67, 0.16);
  --separator-strong: rgba(60, 60, 67, 0.28);
  --blue: #007aff;
  --green: #34c759;
  --orange: #ff9500;
  --red: #ff3b30;
  --fill: rgba(120, 120, 128, 0.12);
  --fill-hover: rgba(120, 120, 128, 0.18);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.08);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 10%, rgba(0, 122, 255, 0.13), transparent 32rem),
    radial-gradient(circle at 88% 0%, rgba(52, 199, 89, 0.12), transparent 26rem),
    var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
}

button:not(:disabled) {
  cursor: pointer;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--fill);
  color: var(--text);
  outline: none;
  padding: 11px 13px;
}

textarea {
  min-height: 118px;
  resize: vertical;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(0, 122, 255, 0.72);
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.14);
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  padding: 32px;
  border: 1px solid var(--separator);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

.app-logo {
  width: 62px;
  height: 62px;
  border-radius: 18px;
  margin-bottom: 20px;
  display: block;
  object-fit: cover;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.55), 0 14px 30px rgba(52, 199, 89, 0.22);
}

.login-panel h1,
.topbar h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.08;
  font-weight: 750;
}

.login-panel p,
.path-label,
.panel-head p {
  margin: 8px 0 0;
  color: var(--secondary);
  line-height: 1.5;
}

.login-form {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.login-form label,
.field span {
  color: var(--secondary);
  font-size: 13px;
  font-weight: 600;
}

.app-shell {
  width: min(1280px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

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

.brand-line {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  object-fit: cover;
  box-shadow: 0 10px 24px rgba(52, 199, 89, 0.18);
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 650;
}

.top-actions,
.form-actions,
.ops-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.button,
.icon-button {
  min-height: 40px;
  border-radius: 999px;
  padding: 0 16px;
  background: var(--fill);
  color: var(--text);
  font-weight: 650;
  transition: transform 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.button.compact {
  min-height: 38px;
  padding: 0 12px;
  font-size: 13px;
}

.button:hover,
.icon-button:hover {
  background: var(--fill-hover);
}

.button:active,
.icon-button:active {
  transform: scale(0.98);
}

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

.button.secondary {
  background: rgba(120, 120, 128, 0.12);
}

.button.danger {
  background: rgba(255, 59, 48, 0.12);
  color: var(--red);
}

.icon-button {
  width: 40px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 18px;
}

.icon-button.compact {
  width: 38px;
  min-height: 38px;
  font-size: 15px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.summary-card,
.site-list-panel,
.detail-panel,
.ops-card {
  border: 1px solid var(--separator);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.summary-card {
  padding: 16px;
}

.summary-card span {
  display: block;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 650;
}

.summary-card strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  line-height: 1;
}

.notice {
  display: none;
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(0, 122, 255, 0.1);
  color: #0051a8;
}

.notice.show {
  display: block;
}

.notice.error {
  background: rgba(255, 59, 48, 0.1);
  color: var(--red);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.88fr) minmax(480px, 1.12fr);
  gap: 16px;
  align-items: start;
}

.ops-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
  align-items: start;
}

.ops-card {
  overflow: hidden;
}

.ops-card.wide {
  grid-column: 1 / -1;
}

.ops-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--separator);
}

.ops-head h2 {
  margin: 0;
  font-size: 17px;
}

.ops-head p {
  margin: 6px 0 0;
  color: var(--secondary);
  font-size: 12px;
  word-break: break-all;
}

.kv-list {
  margin: 0;
  padding: 6px 18px 16px;
}

.kv-list div,
.compact-row {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  border-bottom: 1px solid var(--separator);
}

.kv-list div:last-child,
.compact-row:last-child {
  border-bottom: 0;
}

.kv-list dt {
  color: var(--secondary);
  font-size: 13px;
}

.kv-list dd {
  grid-column: span 2;
  margin: 0;
  min-width: 0;
  word-break: break-word;
  font-size: 13px;
  font-weight: 650;
}

.compact-list {
  padding: 6px 18px 16px;
  min-height: 92px;
}

.compact-row {
  grid-template-columns: 1fr auto;
  padding: 8px 0;
}

.compact-main {
  min-width: 0;
}

.compact-title {
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-subtitle {
  margin-top: 3px;
  color: var(--secondary);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-output {
  margin: 0;
  min-height: 180px;
  max-height: 360px;
  overflow: auto;
  padding: 16px 18px;
  background: rgba(29, 29, 31, 0.92);
  color: #f5f5f7;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.diff-output {
  margin: 0 18px 18px;
  min-height: 150px;
  max-height: 320px;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.audit-list {
  padding: 6px 18px 16px;
}

.audit-row {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(0, 1.2fr);
  gap: 14px;
  align-items: start;
  padding: 12px 0;
  border-bottom: 1px solid var(--separator);
}

.audit-row:last-child {
  border-bottom: 0;
}

.audit-main {
  min-width: 0;
}

.audit-row pre {
  margin: 0;
  max-height: 120px;
  overflow: auto;
  padding: 10px;
  border-radius: var(--radius-md);
  background: var(--fill);
  color: var(--secondary);
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.is-loading {
  position: relative;
}

.is-loading::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-left: 8px;
  border-radius: 999px;
  display: inline-block;
  background: currentColor;
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 0.35;
    transform: scale(0.85);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--separator);
}

.panel-head h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.2;
}

.panel-head input {
  width: min(220px, 45%);
}

.list-filters {
  width: min(440px, 58%);
  display: grid;
  grid-template-columns: minmax(130px, 0.78fr) minmax(160px, 1fr);
  gap: 8px;
}

.list-filters input,
.list-filters select {
  width: 100%;
}

.site-list {
  max-height: calc(100vh - 310px);
  min-height: 420px;
  overflow: auto;
  padding: 8px;
}

.site-row {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border-radius: var(--radius-lg);
  padding: 14px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.site-row:hover,
.site-row.active {
  background: var(--fill);
}

.site-row:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.14);
}

.site-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.site-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 700;
}

.site-url {
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--secondary);
  font-size: 12px;
}

.site-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--fill);
  color: var(--secondary);
  font-size: 12px;
  font-weight: 650;
}

.badge.ok {
  background: rgba(52, 199, 89, 0.14);
  color: #1f8f3a;
}

.badge.low {
  background: rgba(255, 59, 48, 0.13);
  color: var(--red);
}

.badge.error {
  background: rgba(255, 149, 0, 0.14);
  color: #b56400;
}

.balance-number {
  min-width: 84px;
  text-align: right;
  font-size: 24px;
  line-height: 1;
  font-weight: 760;
}

.balance-number.pending {
  color: var(--tertiary);
  font-size: 14px;
}

.site-side {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.sort-actions,
.compact-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.site-form {
  padding: 18px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.span-2 {
  grid-column: 1 / -1;
}

.secret-input {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.checkbox-field {
  align-content: end;
  gap: 10px;
}

.checkbox-field label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}

.checkbox-field input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--blue);
}

.form-actions {
  padding-top: 18px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 240px;
  color: var(--secondary);
  text-align: center;
  padding: 24px;
}

@media (prefers-reduced-motion: reduce) {
  .button,
  .icon-button {
    transition: none;
  }
}

@media (max-width: 980px) {
  .workspace,
  .summary-grid,
  .ops-grid {
    grid-template-columns: 1fr;
  }

  .site-list {
    max-height: none;
    min-height: 240px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100vw - 20px, 1280px);
    padding-top: 14px;
  }

  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .form-actions,
  .ops-actions {
    justify-content: flex-start;
  }

  .panel-head input,
  .list-filters,
  .field-grid {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .site-row,
  .audit-row {
    grid-template-columns: 1fr;
  }

  .site-side {
    justify-items: start;
  }

  .span-2 {
    grid-column: auto;
  }
}
