/* ============================================================
   ScriptDeck — 极简白 + 毛玻璃
   ============================================================ */
:root {
  --bg: #f5f6fa;
  --ink: #171a22;
  --ink-soft: #3a3f4b;
  --muted: #737a8a;
  --faint: #9aa1b0;
  --line: rgba(24, 30, 60, 0.08);
  --line-strong: rgba(24, 30, 60, 0.14);

  --accent: #5b5bd6;
  --accent-soft: rgba(91, 91, 214, 0.1);
  --accent-ink: #4a4ac2;

  --green: #1f9d63;
  --red: #d13d3d;
  --amber: #c8860d;

  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-bg-strong: rgba(255, 255, 255, 0.72);
  --glass-border: 1px solid rgba(255, 255, 255, 0.72);
  --glass-blur: blur(22px) saturate(165%);
  --glass-shadow: 0 12px 40px rgba(24, 30, 60, 0.09), inset 0 1px 0 rgba(255, 255, 255, 0.85);

  --radius: 20px;
  --radius-sm: 13px;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "Inter", "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  letter-spacing: -0.005em;
}

/* ---------- 背景光斑 ---------- */
.bg-blobs {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.bg-blobs::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(60% 55% at 12% 8%, #e6e2ff 0%, transparent 60%),
    radial-gradient(55% 50% at 92% 10%, #d9ecff 0%, transparent 58%),
    radial-gradient(60% 60% at 78% 96%, #ffe6dd 0%, transparent 60%),
    radial-gradient(50% 50% at 25% 100%, #e2f3ea 0%, transparent 62%);
  opacity: 0.9;
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.5;
}
.b1 { width: 460px; height: 460px; background: #cfc8ff; top: -140px; left: -80px; }
.b2 { width: 420px; height: 420px; background: #c6e6ff; top: -120px; right: -100px; }
.b3 { width: 520px; height: 520px; background: #ffd9cc; bottom: -220px; right: 8%; }

/* ---------- 通用玻璃 ---------- */
.glass {
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: var(--glass-border);
  box-shadow: var(--glass-shadow);
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: relative;
  z-index: 3;
  margin: 16px 20px 0;
  height: 62px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
}
.brand { display: flex; align-items: center; gap: 13px; }
.logo {
  width: 38px; height: 38px;
  border-radius: 11px;
  display: grid; place-items: center;
  color: #fff;
  background: linear-gradient(140deg, #6d6df0, #4a4ac2);
  box-shadow: 0 6px 16px rgba(74, 74, 194, 0.32);
}
.brand-text h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.brand-text p {
  margin: 1px 0 0;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.01em;
}
.topbar-actions { display: flex; align-items: center; gap: 14px; }

.status-dot {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--muted);
}
.status-dot i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--amber); box-shadow: 0 0 0 3px rgba(200,134,13,0.14);
  transition: 0.3s;
}
.status-dot.online i { background: var(--green); box-shadow: 0 0 0 3px rgba(31,157,99,0.16); }
.status-dot.offline i { background: var(--red); box-shadow: 0 0 0 3px rgba(209,61,61,0.16); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: inherit; font-size: 13px; font-weight: 500;
  padding: 9px 15px; border-radius: 11px;
  border: 1px solid var(--line-strong);
  background: rgba(255,255,255,0.6);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background .18s, border-color .18s, transform .1s, box-shadow .18s;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  white-space: nowrap;
}
.btn:hover { background: rgba(255,255,255,0.9); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn.ghost { box-shadow: 0 1px 2px rgba(24,30,60,0.04); }
.btn.primary {
  color: #fff;
  border: none;
  background: linear-gradient(140deg, #6d6df0, #4a4ac2);
  box-shadow: 0 8px 20px rgba(74, 74, 194, 0.3);
}
.btn.primary:hover { background: linear-gradient(140deg, #7a7af4, #5252cc); box-shadow: 0 10px 26px rgba(74,74,194,0.38); }
.btn.primary:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn.stop { color: var(--red); border-color: rgba(209,61,61,0.3); }
.btn.stop:hover { background: rgba(209,61,61,0.08); }
.icon-btn {
  border: 1px solid var(--line); background: rgba(255,255,255,0.5);
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  color: var(--muted); cursor: pointer; transition: .18s;
}
.icon-btn:hover { color: var(--ink); background: rgba(255,255,255,0.95); }

/* ---------- 布局 ---------- */
.layout {
  position: relative;
  z-index: 2;
  height: calc(100vh - 94px);
  margin: 14px 20px 20px;
  display: grid;
  grid-template-columns: 318px minmax(0, 1fr);
  gap: 16px;
}

/* ---------- 侧栏 ---------- */
.sidebar {
  border-radius: var(--radius);
  padding: 18px 14px 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 8px 12px;
}
.panel-head.sub { padding-top: 16px; border-top: 1px solid var(--line); margin-top: 8px; }
.panel-head h2 {
  margin: 0; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted);
}
.count {
  font-size: 11px; font-weight: 600; color: var(--accent-ink);
  background: var(--accent-soft); padding: 2px 8px; border-radius: 20px;
}
.search {
  display: flex; align-items: center; gap: 8px;
  margin: 0 4px 10px; padding: 9px 12px;
  background: rgba(255,255,255,0.55);
  border: 1px solid var(--line); border-radius: 11px;
  color: var(--faint);
}
.search input {
  border: none; background: transparent; outline: none;
  font-family: inherit; font-size: 13px; color: var(--ink); width: 100%;
}
.search input::placeholder { color: var(--faint); }

.script-list, .run-list {
  overflow-y: auto;
  padding: 2px 2px;
  min-height: 0;
}
.script-list { flex: 1; }
.run-list { max-height: 190px; flex-shrink: 0; }

.script-item {
  padding: 12px 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .16s, border-color .16s, transform .1s;
  margin-bottom: 3px;
}
.script-item:hover { background: rgba(255,255,255,0.55); }
.script-item.active {
  background: rgba(255,255,255,0.85);
  border-color: rgba(91,91,214,0.28);
  box-shadow: 0 6px 18px rgba(74,74,194,0.1);
}
.script-item .si-name {
  font-size: 13.5px; font-weight: 600; color: var(--ink);
  display: flex; align-items: center; gap: 8px;
}
.script-item .si-desc {
  font-size: 11.5px; color: var(--muted); margin-top: 3px;
  line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.script-item .si-meta { margin-top: 7px; display: flex; gap: 6px; flex-wrap: wrap; }
.mini-tag {
  font-size: 10px; font-weight: 500; color: var(--accent-ink);
  background: var(--accent-soft); padding: 2px 7px; border-radius: 6px;
}
.mini-tag.gray { color: var(--muted); background: rgba(24,30,60,0.05); }

.run-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 10px; cursor: pointer;
  transition: background .16s;
}
.run-item:hover { background: rgba(255,255,255,0.55); }
.run-item .ri-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.ri-dot.success { background: var(--green); }
.ri-dot.failed { background: var(--red); }
.ri-dot.timeout { background: var(--amber); }
.ri-dot.running { background: var(--accent); animation: pulse 1.1s infinite; }
.ri-dot.canceled, .ri-dot.interrupted { background: var(--faint); }
.ri-body { min-width: 0; flex: 1; }
.ri-name { font-size: 12px; font-weight: 500; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ri-time { font-size: 10.5px; color: var(--faint); margin-top: 1px; }

.empty-mini { font-size: 12px; color: var(--faint); padding: 14px 10px; text-align: center; }

/* ---------- 工作区 ---------- */
.workspace { min-height: 0; }
.stage {
  height: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.empty-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  padding: 40px; color: var(--muted);
}
.empty-illustration {
  width: 74px; height: 74px; border-radius: 22px;
  display: grid; place-items: center; margin-bottom: 20px;
  color: var(--accent);
  background: rgba(255,255,255,0.6);
  border: 1px solid rgba(255,255,255,0.8);
  box-shadow: 0 10px 30px rgba(74,74,194,0.12);
}
.empty-state h3 { margin: 0 0 8px; font-size: 17px; font-weight: 500; color: var(--ink-soft); }
.empty-state p { margin: 0; font-size: 13px; color: var(--muted); }

.script-panel {
  flex: 1; display: flex; flex-direction: column;
  min-height: 0; padding: 24px 26px 20px;
  gap: 16px;
}

.script-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 20px;
}
.script-title { min-width: 0; }
.title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.title-row h2 {
  margin: 0; font-size: 25px; font-weight: 300;
  letter-spacing: -0.03em; color: var(--ink);
}
.pill {
  font-size: 11px; font-weight: 500; padding: 4px 10px; border-radius: 20px;
  color: var(--muted); background: rgba(24,30,60,0.05);
}
.pill.runtime { font-family: var(--font-mono); font-size: 11px; color: var(--accent-ink); background: var(--accent-soft); }
.script-desc { margin: 9px 0 0; font-size: 13.5px; color: var(--muted); line-height: 1.55; max-width: 640px; }
.tags { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

.run-controls { display: flex; align-items: center; gap: 12px; flex-shrink: 0; padding-top: 4px; }
.run-status {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--muted); font-weight: 500;
}
.run-status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.run-status.running .dot { background: var(--accent); animation: pulse 1.1s infinite; }
.run-status.success .dot { background: var(--green); }
.run-status.failed .dot { background: var(--red); }
.run-status.timeout .dot { background: var(--amber); }

/* ---------- 输入区 ---------- */
.inputs-section {
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.42);
  border: 1px solid var(--line);
  padding: 16px 18px;
}
.section-label {
  font-size: 12px; font-weight: 600; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 13px;
  display: flex; align-items: center; gap: 10px;
}
.section-label .hint {
  text-transform: none; letter-spacing: 0; font-weight: 400;
  color: var(--faint); font-size: 11.5px;
}
.inputs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px 16px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 12.5px; font-weight: 500; color: var(--ink-soft);
  display: flex; align-items: center; gap: 6px;
}
.field label .req { color: var(--red); font-size: 12px; }
.field label .ftype {
  font-family: var(--font-mono); font-size: 9.5px; color: var(--faint);
  background: rgba(24,30,60,0.05); padding: 1px 6px; border-radius: 5px; font-weight: 400;
}
.field .fdesc { font-size: 11px; color: var(--faint); margin-top: -1px; }
.field input[type="text"],
.field input[type="number"],
.field input[type="password"],
.field select,
.field textarea {
  font-family: inherit; font-size: 13px; color: var(--ink);
  padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: rgba(255,255,255,0.7);
  outline: none; width: 100%;
  transition: border-color .16s, box-shadow .16s, background .16s;
}
.field textarea { resize: vertical; min-height: 64px; font-family: var(--font-mono); font-size: 12.5px; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: rgba(91,91,214,0.55);
  box-shadow: 0 0 0 3px rgba(91,91,214,0.12);
  background: #fff;
}
.field input::placeholder, .field textarea::placeholder { color: var(--faint); }

/* toggle */
.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.toggle input { display: none; }
.toggle .track {
  width: 40px; height: 23px; border-radius: 20px;
  background: rgba(24,30,60,0.16); position: relative; transition: background .2s;
}
.toggle .track::after {
  content: ""; position: absolute; top: 2.5px; left: 2.5px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25); transition: transform .2s;
}
.toggle input:checked + .track { background: var(--accent); }
.toggle input:checked + .track::after { transform: translateX(17px); }
.toggle .tlabel { font-size: 12.5px; color: var(--ink-soft); }

/* ---------- 控制台 ---------- */
.console-wrap {
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 160px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: rgba(250, 250, 253, 0.66);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.console-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.4);
}
.console-title { display: flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.traffic { display: inline-flex; gap: 5px; }
.traffic i { width: 9px; height: 9px; border-radius: 50%; background: rgba(24,30,60,0.14); }
.traffic i:nth-child(1) { background: #ff6058; }
.traffic i:nth-child(2) { background: #ffbd2e; }
.traffic i:nth-child(3) { background: #28c840; }
.console-tools { display: flex; align-items: center; gap: 14px; }
.meta-info { font-family: var(--font-mono); font-size: 11px; color: var(--faint); }
.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); cursor: pointer; }
.switch input { accent-color: var(--accent); }

.console {
  flex: 1;
  margin: 0; padding: 14px 16px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 12.5px; line-height: 1.62;
  color: var(--ink-soft);
  white-space: pre-wrap;
  word-break: break-word;
}
.console-placeholder { color: var(--faint); }
.line { display: block; }
.line.stdout { color: #2b3040; }
.line.stderr { color: var(--red); }
.line.system { color: var(--accent-ink); }
.line.exit-ok { color: var(--green); font-weight: 600; }
.line.exit-bad { color: var(--red); font-weight: 600; }

/* ---------- 结果卡 ---------- */
.result-card {
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.5);
  padding: 12px 16px;
  animation: rise .3s ease;
}
.result-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.result-badge {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; padding: 6px 13px; border-radius: 20px;
}
.result-badge.success { color: var(--green); background: rgba(31,157,99,0.1); }
.result-badge.failed { color: var(--red); background: rgba(209,61,61,0.1); }
.result-badge.timeout { color: var(--amber); background: rgba(200,134,13,0.1); }
.result-badge .rbadge-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.result-metrics { display: flex; gap: 22px; flex: 1; }
.metric { display: flex; flex-direction: column; gap: 1px; }
.metric .m-k { font-size: 10.5px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.05em; }
.metric .m-v { font-size: 14px; font-weight: 600; color: var(--ink); font-family: var(--font-mono); }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* scrollbars */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(24,30,60,0.14); border-radius: 20px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(24,30,60,0.24); background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 900px) {
  html, body { height: auto; overflow-y: auto; }
  .topbar { margin: 10px 12px 0; height: 56px; padding: 0 14px; }
  .brand-text p { display: none; }
  .layout {
    display: block;
    height: auto;
    margin: 10px 12px 16px;
  }
  .sidebar {
    height: auto;
    max-height: none;
    overflow: visible;
    margin-bottom: 12px;
    padding: 14px 12px 10px;
  }
  /* 脚本列表单独限高、可滚动，绝不被"最近运行"挤掉 */
  .script-list { flex: none; max-height: 46vh; overflow-y: auto; }
  .run-list { max-height: 28vh; }

  .workspace { min-height: 0; }
  .stage { height: auto; min-height: 74vh; }
  .script-panel { padding: 16px 14px 14px; gap: 12px; }
  .script-head { flex-direction: column; align-items: stretch; gap: 12px; }
  .run-controls { justify-content: space-between; padding-top: 0; }
  .title-row h2 { font-size: 21px; }
  .script-desc { font-size: 13px; }
  .inputs-grid { grid-template-columns: 1fr; }
  .console-wrap { min-height: 44vh; }
  .result-head { gap: 10px; }
  .result-metrics { gap: 14px; flex-wrap: wrap; }
}

/* ============================================================
   登录页
   ============================================================ */
.login-body { display: grid; place-items: center; min-height: 100vh; overflow: auto; }
.login-wrap { position: relative; z-index: 2; width: 100%; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 372px;
  border-radius: 26px;
  padding: 40px 34px 30px;
  text-align: center;
  animation: rise .4s ease;
}
.login-logo {
  width: 54px; height: 54px; margin: 0 auto 18px;
  border-radius: 16px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(140deg, #6d6df0, #4a4ac2);
  box-shadow: 0 10px 24px rgba(74, 74, 194, 0.34);
}
.login-card h1 { margin: 0; font-size: 24px; font-weight: 300; letter-spacing: -0.03em; }
.login-sub { margin: 7px 0 26px; font-size: 12.5px; color: var(--muted); }
.login-field { display: block; text-align: left; margin-bottom: 14px; }
.login-field span { display: block; font-size: 12px; font-weight: 500; color: var(--ink-soft); margin-bottom: 7px; }
.login-field input {
  width: 100%; font-family: inherit; font-size: 14px; color: var(--ink);
  padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: rgba(255,255,255,0.72);
  outline: none; transition: border-color .16s, box-shadow .16s, background .16s;
}
.login-field input:focus { border-color: rgba(91,91,214,0.55); box-shadow: 0 0 0 3px rgba(91,91,214,0.12); background: #fff; }
.login-err { display: none; margin: 0 0 14px; font-size: 12.5px; color: var(--red); text-align: left; }
.login-btn { width: 100%; justify-content: center; padding: 12px; font-size: 14px; }
.login-foot { margin: 20px 0 0; font-size: 11px; color: var(--faint); }

/* 已终止 / 已中断（非失败）状态 */
.run-status.canceled .dot { background: var(--faint); }
.result-badge.canceled { color: var(--muted); background: rgba(24, 30, 60, 0.06); }
