/* 柚子效率魔盒 执行器界面
   视觉参考 Google Gemini：柔和 surface、大圆角、蓝→紫→粉渐变强调色、亮暗双主题。 */

:root {
  --grad: linear-gradient(112deg, #4285F4 8%, #9B72CB 52%, #D96570 96%);
  --grad-soft: linear-gradient(112deg, rgba(66,133,244,.14) 8%, rgba(155,114,203,.14) 52%, rgba(217,101,112,.14) 96%);

  --bg: #F8FAFD;
  --surface: #FFFFFF;
  --surface-2: #EEF2FA;
  --surface-3: #E3E9F3;
  --outline: #DDE3EC;
  --text: #1F1F1F;
  --text-2: #5F6368;
  --text-3: #80868B;
  --blue: #0B57D0;
  --green: #146C2E;
  --green-bg: #E6F4EA;
  --red: #B3261E;
  --red-bg: #FCE8E6;
  --amber: #8A5A00;
  --amber-bg: #FEF7E0;
  --shadow-1: 0 1px 2px rgba(60,64,67,.08), 0 1px 3px 1px rgba(60,64,67,.06);
  --shadow-2: 0 2px 6px 2px rgba(60,64,67,.08), 0 1px 2px rgba(60,64,67,.10);
  --radius-l: 28px;
  --radius-m: 20px;
  --radius-s: 12px;
  --sidebar-w: 232px;
}

:root[data-theme="dark"], html.dark {
  --bg: #131314;
  --surface: #1E1F20;
  --surface-2: #282A2C;
  --surface-3: #333537;
  --outline: #3C4043;
  --text: #E3E3E3;
  --text-2: #C4C7C5;
  --text-3: #9AA0A6;
  --blue: #A8C7FA;
  --green: #6DD58C;
  --green-bg: #1F3D28;
  --red: #F2B8B5;
  --red-bg: #452021;
  --amber: #F9CF63;
  --amber-bg: #423519;
  --shadow-1: 0 1px 3px rgba(0,0,0,.4);
  --shadow-2: 0 4px 12px rgba(0,0,0,.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131314;
    --surface: #1E1F20;
    --surface-2: #282A2C;
    --surface-3: #333537;
    --outline: #3C4043;
    --text: #E3E3E3;
    --text-2: #C4C7C5;
    --text-3: #9AA0A6;
    --blue: #A8C7FA;
    --green: #6DD58C;
    --green-bg: #1F3D28;
    --red: #F2B8B5;
    --red-bg: #452021;
    --amber: #F9CF63;
    --amber-bg: #423519;
    --shadow-1: 0 1px 3px rgba(0,0,0,.4);
    --shadow-2: 0 4px 12px rgba(0,0,0,.5);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Google Sans", "Google Sans Text", Roboto, -apple-system, BlinkMacSystemFont,
               "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.icon { width: 20px; height: 20px; fill: currentColor; flex: none; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }

/* ---------- 布局 ---------- */
.shell { display: flex; height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--bg);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-right: 1px solid transparent;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 6px 12px 22px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 12px; background: var(--grad);
  display: grid; place-items: center; color: #fff; flex: none;
}
.brand-name { font-size: 15px; font-weight: 500; letter-spacing: .1px; }
.brand-sub { font-size: 11px; color: var(--text-3); }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; border-radius: 999px;
  color: var(--text-2); cursor: pointer; user-select: none;
  border: none; background: none; width: 100%; text-align: left;
  font-size: 14px; font-family: inherit; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--surface-3); color: var(--text); font-weight: 500; }
.nav-item.active .icon { color: var(--blue); }
.nav-spacer { flex: 1; }

.nav-foot { padding: 10px 16px; font-size: 11px; color: var(--text-3); line-height: 1.5; }

.main {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 22px 0 0 0;
  margin: 8px 0 0 0; overflow: hidden;
}
:root[data-theme="dark"] .main, html.dark .main { background: var(--surface); }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 28px; border-bottom: 1px solid var(--outline);
  flex: none;
}
.topbar h1 { font-size: 20px; font-weight: 400; margin: 0; letter-spacing: -.2px; }
.topbar .sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.topbar-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }

.content { flex: 1; overflow-y: auto; padding: 24px 28px 96px; }
.page { display: none; }
.page.active { display: block; animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 9px 20px; border-radius: 999px; border: 1px solid var(--outline);
  background: var(--surface); color: var(--text); cursor: pointer;
  font-size: 14px; font-family: inherit; font-weight: 500;
  transition: background .15s, box-shadow .15s, opacity .15s; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--grad); color: #fff; border-color: transparent; box-shadow: var(--shadow-1); }
.btn-primary:hover { box-shadow: var(--shadow-2); background: var(--grad); }
.btn-danger { color: var(--red); border-color: var(--outline); }
.btn-danger:hover { background: var(--red-bg); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-icon { padding: 8px; border-radius: 50%; border-color: transparent; background: transparent; color: var(--text-2); }
.btn-icon:hover { background: var(--surface-2); color: var(--text); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--outline);
  border-radius: var(--radius-m); padding: 20px 22px; margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.card-head h2 { font-size: 16px; font-weight: 500; margin: 0; }
.card-head .spacer { flex: 1; }
.card-desc { font-size: 12px; color: var(--text-3); margin: -10px 0 16px; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

/* 统计卡 */
.stat {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--outline);
  border-radius: var(--radius-m); padding: 18px 20px;
}
.stat::after {
  content: ""; position: absolute; inset: 0; background: var(--grad-soft);
  opacity: 0; transition: opacity .2s;
}
.stat:hover::after { opacity: 1; }
.stat > * { position: relative; z-index: 1; }
.stat-label { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); }
.stat-value { font-size: 30px; font-weight: 400; letter-spacing: -.5px; margin: 8px 0 2px; }
.stat-value .unit { font-size: 14px; color: var(--text-3); margin-left: 4px; }
.stat-foot { font-size: 11px; color: var(--text-3); }
.stat-hero .stat-value {
  background: var(--grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; font-weight: 500;
}

/* ---------- 表格 / 列表 ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-weight: 500; color: var(--text-2); font-size: 12px;
  padding: 10px 12px; border-bottom: 1px solid var(--outline); white-space: nowrap;
}
td { padding: 12px; border-bottom: 1px solid var(--outline); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
.table-wrap { overflow-x: auto; margin: 0 -6px; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 500;
  background: var(--surface-2); color: var(--text-2); white-space: nowrap;
}
.chip-success { background: var(--green-bg); color: var(--green); }
.chip-failed { background: var(--red-bg); color: var(--red); }
.chip-running { background: rgba(66,133,244,.14); color: var(--blue); }
.chip-stopped { background: var(--amber-bg); color: var(--amber); }
.chip-pending { background: var(--surface-2); color: var(--text-3); }

/* 脚本卡片 */
.script-item {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 18px; border: 1px solid var(--outline); border-radius: var(--radius-m);
  margin-bottom: 12px; background: var(--surface); transition: box-shadow .18s, border-color .18s;
}
.script-item:hover { box-shadow: var(--shadow-1); border-color: var(--surface-3); }
.script-item.disabled { opacity: .55; }
.script-order {
  width: 30px; height: 30px; border-radius: 10px; background: var(--surface-2);
  display: grid; place-items: center; font-size: 12px; color: var(--text-2); flex: none; font-weight: 500;
}
.script-main { flex: 1; min-width: 0; }
.script-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.script-title b { font-weight: 500; font-size: 15px; }
.script-meta { font-size: 12px; color: var(--text-3); margin-top: 4px; display: flex; gap: 14px; flex-wrap: wrap; }
.script-actions { display: flex; gap: 4px; align-items: center; flex: none; }

/* 开关 */
.switch { position: relative; width: 40px; height: 22px; flex: none; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--surface-3); transition: background .2s;
}
.switch .thumb {
  position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--text-3); transition: transform .2s, background .2s;
}
.switch input:checked + .track { background: rgba(66,133,244,.4); }
.switch input:checked + .track .thumb { transform: translateX(18px); background: var(--blue); }

/* ---------- 表单 ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 6px; font-weight: 500; }
.field .hint { font-size: 11px; color: var(--text-3); margin-top: 5px; }
input[type="text"], input[type="number"], input[type="password"], input[type="url"], select, textarea {
  width: 100%; padding: 11px 14px; border-radius: var(--radius-s);
  border: 1px solid var(--outline); background: var(--surface);
  color: var(--text); font-size: 14px; font-family: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: #4285F4; box-shadow: 0 0 0 3px rgba(66,133,244,.16);
}
textarea { resize: vertical; min-height: 96px; line-height: 1.6; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }

.dropzone {
  border: 1.5px dashed var(--outline); border-radius: var(--radius-m);
  padding: 28px; text-align: center; color: var(--text-3); cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over { border-color: #9B72CB; background: var(--grad-soft); color: var(--text-2); }

.file-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px;
  background: var(--surface-2); border-radius: 999px; font-size: 12px; margin: 4px 6px 0 0;
}

/* ---------- 运行监视器 ---------- */
.monitor {
  position: fixed; right: 24px; bottom: 24px; width: 480px; max-width: calc(100vw - 48px);
  background: var(--surface); border: 1px solid var(--outline); border-radius: var(--radius-m);
  box-shadow: var(--shadow-2); overflow: hidden; z-index: 40;
  transform: translateY(calc(100% + 40px)); transition: transform .28s cubic-bezier(.2,0,0,1);
}
.monitor.show { transform: none; }
.monitor-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-bottom: 1px solid var(--outline); background: var(--surface);
}
.monitor-title { font-size: 13px; font-weight: 500; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.monitor-log {
  height: 240px; overflow-y: auto; padding: 12px 16px; margin: 0;
  font-family: "SF Mono", "Cascadia Code", Consolas, monospace; font-size: 11.5px;
  line-height: 1.7; color: var(--text-2); background: var(--bg); white-space: pre-wrap; word-break: break-all;
}
.monitor.collapsed .monitor-log { height: 0; padding: 0; }

.pulse { width: 8px; height: 8px; border-radius: 50%; background: #4285F4; flex: none;
  animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.75); } }

.progress-line { height: 3px; background: var(--surface-2); overflow: hidden; }
.progress-line::after {
  content: ""; display: block; height: 100%; width: 35%; background: var(--grad);
  animation: slide 1.5s ease-in-out infinite;
}
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(380%); } }

/* ---------- 图表 ---------- */
.chart { width: 100%; height: 160px; display: block; }
.chart-bar { fill: url(#gemGrad); rx: 3; transition: opacity .15s; }
.chart-bar:hover { opacity: .75; }
.chart-axis { font-size: 9px; fill: var(--text-3); }

/* ---------- 弹层 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 60;
  display: none; align-items: center; justify-content: center; padding: 24px;
  backdrop-filter: blur(2px);
}
.modal-mask.show { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius-l); width: 100%; max-width: 620px;
  max-height: 86vh; display: flex; flex-direction: column; box-shadow: var(--shadow-2);
  animation: pop .22s cubic-bezier(.2,0,0,1);
}
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px); } to { opacity: 1; transform: none; } }
.modal-head { padding: 22px 26px 8px; display: flex; align-items: center; gap: 12px; }
.modal-head h3 { margin: 0; font-size: 18px; font-weight: 400; flex: 1; }
.modal-body { padding: 12px 26px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 14px 26px 22px; display: flex; gap: 10px; justify-content: flex-end; }
.modal-wide { max-width: 860px; }

pre.log-view {
  background: var(--bg); border: 1px solid var(--outline); border-radius: var(--radius-s);
  padding: 14px 16px; font-family: "SF Mono", "Cascadia Code", Consolas, monospace;
  font-size: 11.5px; line-height: 1.7; color: var(--text-2);
  max-height: 52vh; overflow: auto; white-space: pre-wrap; word-break: break-all; margin: 0;
}

/* ---------- 提示条 ---------- */
.toast-wrap { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 90;
  display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 11px 18px; border-radius: 999px;
  background: #202124; color: #E8EAED; font-size: 13px; box-shadow: var(--shadow-2);
  animation: drop .25s cubic-bezier(.2,0,0,1); max-width: 70vw;
}
:root[data-theme="dark"] .toast, html.dark .toast { background: #E3E3E3; color: #1F1F1F; }
.toast-error { background: #8C1D18; color: #FFDAD6; }
.toast-success { background: #0B5227; color: #B7F0C6; }
@keyframes drop { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }

/* ---------- 其他 ---------- */
.empty { text-align: center; padding: 52px 20px; color: var(--text-3); }
.empty .icon { width: 40px; height: 40px; opacity: .35; margin-bottom: 10px; }
.empty p { margin: 6px 0 16px; font-size: 13px; }

.banner {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px;
  border-radius: var(--radius-m); background: var(--amber-bg); color: var(--amber);
  font-size: 13px; margin-bottom: 16px;
}
.banner .spacer { flex: 1; }
.banner-info { background: var(--grad-soft); color: var(--text-2); }

.kv { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--outline); font-size: 13px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--text-3); width: 130px; flex: none; }
.kv .v { flex: 1; word-break: break-all; }

.mono { font-family: "SF Mono", "Cascadia Code", Consolas, monospace; font-size: 12px; }
.muted { color: var(--text-3); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.divider { height: 1px; background: var(--outline); margin: 18px 0; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 999px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 后台专用 ---------- */

.login-wrap {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: var(--bg); z-index: 100; padding: 24px;
}
.login-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--outline); border-radius: var(--radius-l);
  padding: 40px 36px; box-shadow: var(--shadow-1);
}
.login-mark {
  width: 52px; height: 52px; border-radius: 16px; background: var(--grad);
  display: grid; place-items: center; color: #fff; margin: 0 auto 18px;
}
.login-card h1 { font-size: 22px; font-weight: 400; text-align: center; margin: 0 0 6px; }
.login-card .sub { text-align: center; color: var(--text-3); font-size: 13px; margin-bottom: 28px; }
.login-card .btn { width: 100%; margin-top: 8px; padding: 12px; }
.login-error { color: var(--red); font-size: 12px; text-align: center; min-height: 18px; margin-top: 10px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--outline); margin-bottom: 18px; }
.tab {
  padding: 10px 18px; border: none; background: none; cursor: pointer;
  font-size: 14px; font-family: inherit; color: var(--text-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 500; }

.version-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  border-radius: var(--radius-s); background: var(--surface-2); margin-bottom: 8px; font-size: 13px;
}
.version-row .spacer { flex: 1; }
.version-row.current { background: var(--grad-soft); }

.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--grad);
  color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 500; flex: none;
}

.req-card { border: 1px solid var(--outline); border-radius: var(--radius-m); padding: 18px 20px; margin-bottom: 12px; }
.req-card:hover { box-shadow: var(--shadow-1); }
.req-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.req-head b { font-size: 15px; font-weight: 500; }
.req-desc { color: var(--text-2); font-size: 13px; white-space: pre-wrap; margin: 8px 0 12px; }
.req-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.status-flow { display: flex; gap: 6px; flex-wrap: wrap; }
.status-flow .btn { padding: 5px 12px; font-size: 12px; }
