:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --text: #182230;
  --muted: #667085;
  --border: #dce1e8;
  --border-strong: #c8d0dc;
  --primary: #2457d6;
  --primary-hover: #1948bf;
  --primary-soft: #edf3ff;
  --success: #16794b;
  --success-soft: #eaf7f0;
  --warning: #a15c07;
  --warning-soft: #fff6e8;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { max-width: 100%; min-height: 100%; }
body { margin: 0; color: var(--text); background: var(--bg); font-size: 14px; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .46; }
.hidden { display: none !important; }

.topbar { position: sticky; top: 0; z-index: 10; height: 64px; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { width: min(1080px, calc(100% - 40px)); height: 100%; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand-mark, .login-icon { display: grid; place-items: center; flex: none; color: white; background: #243247; font-size: 11px; font-weight: 800; letter-spacing: .02em; }
.brand-mark { width: 34px; height: 34px; border-radius: 7px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 14px; line-height: 1.3; }
.brand small { margin-top: 1px; color: var(--muted); font-size: 11px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.badge { display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px; color: var(--muted); background: var(--surface-muted); border: 1px solid var(--border); border-radius: 6px; font-size: 11px; font-weight: 650; }
.badge i { width: 6px; height: 6px; background: #98a2b3; border-radius: 50%; }
.badge-online { color: var(--success); background: var(--success-soft); border-color: #c9ead8; }
.badge-online i { background: var(--success); }

.page-shell { width: min(1080px, calc(100% - 40px)); margin: 0 auto; padding: 32px 0 64px; }
.workspace { display: grid; gap: 18px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding: 2px 0 6px; }
.page-heading h1 { margin: 0 0 5px; font-size: 24px; line-height: 1.25; letter-spacing: -.02em; }
.page-heading p { margin: 0; color: var(--muted); font-size: 13px; }

.login-panel { width: min(440px, 100%); margin: 80px auto 0; padding: 28px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 30px rgba(16, 24, 40, .07); }
.login-header { display: flex; align-items: center; gap: 14px; padding-bottom: 22px; border-bottom: 1px solid var(--border); }
.login-icon { width: 42px; height: 42px; border-radius: 8px; }
.login-header h1 { margin: 0 0 4px; font-size: 18px; }
.login-header p { margin: 0; color: var(--muted); font-size: 12px; }
.key-form { margin-top: 22px; }
.key-form > label:first-child { display: block; margin-bottom: 7px; font-size: 12px; font-weight: 650; }
.key-row { display: flex; gap: 8px; }
.key-row input { min-width: 0; flex: 1; height: 40px; padding: 0 11px; color: var(--text); background: white; border: 1px solid var(--border-strong); border-radius: 7px; outline: none; }
.key-row input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(36, 87, 214, .12); }
.check-row { display: flex; align-items: center; gap: 7px; margin: 13px 0 18px; color: var(--muted); font-size: 12px; }
.check-row input { accent-color: var(--primary); }
.form-error { margin: 10px 0 0; color: var(--danger); font-size: 12px; }

.button { min-height: 36px; padding: 0 14px; color: var(--text); background: var(--surface); border: 1px solid transparent; border-radius: 7px; font-size: 12px; font-weight: 650; transition: background .15s, border-color .15s, box-shadow .15s; }
.button-primary { color: white; background: var(--primary); }
.button-primary:hover:not(:disabled) { background: var(--primary-hover); }
.button-secondary { background: var(--surface); border-color: var(--border-strong); }
.button-secondary:hover:not(:disabled) { background: var(--surface-muted); border-color: #aeb8c7; }
.button-quiet { min-height: 30px; padding: 0 8px; color: var(--muted); background: transparent; }
.button-quiet:hover { color: var(--text); background: var(--surface-muted); }
.button-wide { width: 100%; }

.panel { padding: 22px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.panel-heading > div { display: flex; align-items: center; gap: 10px; }
.panel-heading h2 { margin: 0; font-size: 15px; }
.section-index { width: 24px; height: 24px; display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); border-radius: 6px; font-size: 11px; font-weight: 750; }
.selection-hint { max-width: 62%; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; text-align: right; }

.upload-section { padding: 24px; }
.drop-zone { position: relative; display: grid; place-items: center; min-height: 270px; padding: 30px; text-align: center; background: #fbfcfe; border: 1.5px dashed #aeb9c8; border-radius: 9px; outline: none; transition: background .15s, border-color .15s; }
.drop-zone:hover, .drop-zone:focus, .drop-zone.dragging { background: #f5f8ff; border-color: var(--primary); }
.drop-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-icon { width: 42px; height: 42px; display: grid; place-items: center; margin-bottom: 13px; color: var(--primary); background: var(--primary-soft); border-radius: 8px; font-size: 20px; }
.drop-zone > strong { font-size: 15px; font-weight: 650; }
.drop-zone > p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.folder-summary { margin-top: 14px; padding: 6px 10px; color: #344054; background: white; border: 1px solid var(--border); border-radius: 6px; font-size: 11px; font-weight: 650; }
.panel-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 16px; }
.panel-actions > span { color: var(--muted); font-size: 11px; }
.panel-actions .button { min-width: 112px; }

.change-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.change-summary article { display: flex; align-items: center; justify-content: space-between; min-height: 54px; padding: 12px 14px; background: var(--surface-muted); border: 1px solid var(--border); border-radius: 7px; }
.change-summary span { color: var(--muted); font-size: 11px; }
.change-summary b { font-size: 20px; }
.change-summary .change-added b { color: var(--success); }
.change-summary .change-modified b { color: var(--primary); }
.change-summary .change-deleted b { color: var(--danger); }
.change-list { max-height: 320px; margin-top: 14px; overflow: auto; border: 1px solid var(--border); border-radius: 7px; }
.change-item { display: grid; grid-template-columns: 70px minmax(0, 1fr) 80px; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 11px; }
.change-item:last-child { border-bottom: 0; }
.change-kind { width: fit-content; padding: 3px 7px; border-radius: 5px; font-size: 10px; font-weight: 700; }
.kind-added { color: var(--success); background: var(--success-soft); }
.kind-modified { color: var(--primary); background: var(--primary-soft); }
.kind-deleted { color: var(--danger); background: var(--danger-soft); }
.change-path { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.change-size { color: var(--muted); text-align: right; }
.empty-changes { margin: 0; padding: 18px; color: var(--muted); text-align: center; font-size: 12px; }

.workflow { position: relative; }
.publish-card { display: grid; grid-template-columns: 36px minmax(0, 1fr) 170px; gap: 16px; align-items: center; padding: 18px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; }
.publish-card.locked { background: #fafbfc; opacity: .64; }
.stage-marker { width: 30px; height: 30px; display: grid; place-items: center; align-self: start; color: var(--primary); background: var(--primary-soft); border: 1px solid #cedcff; border-radius: 50%; font-size: 12px; font-weight: 750; }
.publish-production .stage-marker { color: var(--success); background: var(--success-soft); border-color: #c7e8d6; }
.stage-content { min-width: 0; }
.stage-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.environment-label { color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .1em; }
.stage-heading h3 { margin: 2px 0 0; font-size: 15px; }
.status-chip { padding: 4px 7px; border-radius: 5px; font-size: 10px; font-weight: 700; }
.status-test { color: var(--warning); background: var(--warning-soft); }
.status-production { color: var(--success); background: var(--success-soft); }
.stage-meta { display: grid; grid-template-columns: minmax(180px, 1.4fr) 80px minmax(150px, 1fr); gap: 18px; margin: 15px 0 11px; }
.stage-meta div { min-width: 0; }
.stage-meta dt { margin-bottom: 3px; color: var(--muted); font-size: 10px; }
.stage-meta dd { margin: 0; font-size: 11px; font-weight: 650; overflow-wrap: anywhere; }
.path-link { color: var(--primary); font-size: 11px; font-weight: 650; text-decoration: none; }
.path-link:hover { text-decoration: underline; }
.lock-text { margin: 8px 0 0; color: var(--muted); font-size: 10px; }
.stage-action { display: flex; justify-content: flex-end; }
.stage-action .button { width: 154px; }
.button-test { color: var(--warning); background: var(--warning-soft); border-color: #f2d6a6; }
.button-test:hover:not(:disabled) { background: #ffedce; }
.button-production { color: white; background: var(--success); }
.button-production:hover:not(:disabled) { background: #11643e; }
.workflow-connector { position: relative; height: 42px; margin-left: 32px; padding-left: 30px; display: flex; align-items: center; color: var(--muted); font-size: 10px; }
.workflow-connector::before { content: ""; position: absolute; left: 3px; top: 0; bottom: 0; width: 1px; background: var(--border-strong); }
.workflow-connector::after { content: "↓"; position: absolute; left: -4px; bottom: -1px; width: 16px; height: 16px; display: grid; place-items: center; color: var(--muted); background: var(--surface); font-size: 11px; }

.activity-section { padding: 18px 22px; }
.activity-heading { display: flex; align-items: center; justify-content: space-between; }
.activity-heading h2 { margin: 0; font-size: 14px; }
.activity-list { list-style: none; padding: 0; margin: 12px 0 0; }
.activity-list li { position: relative; padding: 9px 0 9px 18px; color: #344054; border-top: 1px solid var(--border); font-size: 11px; line-height: 1.45; }
.activity-list li::before { content: ""; position: absolute; left: 2px; top: 14px; width: 6px; height: 6px; background: #98a2b3; border-radius: 50%; }
.activity-list li.error { color: var(--danger); }
.activity-list li.error::before { background: var(--danger); }
.activity-list .muted { color: var(--muted); }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; max-width: min(420px, calc(100vw - 48px)); padding: 11px 14px; color: white; background: #243247; border-radius: 7px; box-shadow: 0 10px 30px rgba(16, 24, 40, .2); font-size: 12px; }
.toast.error { background: var(--danger); }
.busy { pointer-events: none; }

@media (max-width: 800px) {
  .topbar-inner, .page-shell { width: min(100% - 24px, 680px); }
  .page-heading { align-items: stretch; flex-direction: column; }
  .page-heading .button { width: 100%; }
  .publish-card { grid-template-columns: 34px minmax(0, 1fr); }
  .stage-action { grid-column: 2; justify-content: stretch; }
  .stage-action .button { width: 100%; }
  .stage-meta { grid-template-columns: 1fr 70px; }
  .stage-meta div:last-child { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
  .topbar { height: 58px; }
  .brand small, .badge { display: none; }
  .page-shell { padding-top: 22px; }
  .login-panel { margin-top: 32px; padding: 22px; }
  .panel { padding: 17px; }
  .panel-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
  .selection-hint { max-width: 100%; text-align: left; }
  .drop-zone { min-height: 230px; padding: 22px; }
  .panel-actions { align-items: stretch; flex-direction: column; }
  .panel-actions .button { width: 100%; }
  .change-summary { grid-template-columns: 1fr 1fr; }
  .change-item { grid-template-columns: 62px minmax(0, 1fr); }
  .change-size { grid-column: 2; text-align: left; }
  .publish-card { padding: 15px; gap: 10px; }
  .stage-meta { grid-template-columns: 1fr; gap: 10px; }
  .stage-meta div:last-child { grid-column: auto; }
  .workflow-connector { margin-left: 26px; }
}
