/* DASHBOARD AUTOMATION ADMIN PANEL DARK - Design System */

:root {
  --bg-color: #0b1220;
  --glass-bg: rgba(30, 41, 59, 0.55);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.5);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  
  --accent-color: #3b82f6;
  --accent-hover: #60a5fa;
  
  --font-body: 'Inter', system-ui, sans-serif;
  --font-heading: 'Inter', system-ui, sans-serif;
  --font-mono: 'Fira Code', ui-monospace, monospace;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg-color);
  background-image: 
    radial-gradient(circle at 15% 50%, rgba(37, 99, 235, 0.06), transparent 25%),
    radial-gradient(circle at 85% 30%, rgba(124, 58, 237, 0.04), transparent 25%);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.6;
}

.font-mono, .pill-id, .metric-card strong, .status-indicator, code, pre, .files-breadcrumb {
  font-family: var(--font-mono);
}

button, input, select, textarea {
  font: inherit;
  transition: var(--transition);
}

/* Button System */
button {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-weight: 500;
  font-size: 14px;
  background: linear-gradient(135deg, var(--accent-color), #2563eb);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
  white-space: nowrap;
  flex-shrink: 0;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
  filter: brightness(1.05);
}

button:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  pointer-events: none;
  transform: none;
  box-shadow: none;
}

/* Alt / Ghost Button */
button.alt,
.icon-btn,
.tab-btn {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border: 1px solid var(--glass-border);
  box-shadow: none;
  text-shadow: none;
}

button.alt:hover,
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

button.danger {
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

button.danger:hover {
  background: rgba(239, 68, 68, 0.2);
  transform: translateY(-1px);
}

.icon-btn {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

/* Icons */
.lucide {
  stroke-width: 2;
}
.icon-sm {
  width: 18px;
  height: 18px;
}
.icon-md {
  width: 20px;
  height: 20px;
}
.btn-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Forms */
input, select, textarea {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-main);
  backdrop-filter: blur(8px);
}

input:hover, select:hover, textarea:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-color);
  background: rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

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

/* Utilities */
a { color: var(--accent-hover); text-decoration: none; }
a:hover { text-decoration: underline; }

.subtitle, .muted, .empty, .section-header p, .task-subtitle, .inline-check, .field-span-2 {
  color: var(--text-muted);
}

.hidden { display: none !important; }

/* Application shell */
.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.app-sidebar {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px 18px;
  border-right: 1px solid var(--glass-border);
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 6px 8px 34px;
}

.app-brand-code {
  flex: 0 0 auto;
  color: #60a5fa;
  font: 600 12px/1 var(--font-mono);
  letter-spacing: -0.04em;
}

.app-brand strong {
  overflow: hidden;
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 版本号:跟"当前账号"同一行右对齐。它和账号是同一类信息(这台机器的身份),
   单独占一行会变成一块飘在按钮下面、不对齐任何东西的补丁。 */
.app-version {
  flex: 0 0 auto;
  color: var(--text-muted);
  font: 500 11px/1 var(--font-mono);
  opacity: 0.75;
  white-space: nowrap;
}

.app-nav {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  gap: 7px;
}

.tab-btn-global { margin-top: auto; }

.tab-btn {
  position: relative;
  justify-content: flex-start;
  width: 100%;
  padding: 11px 13px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  box-shadow: none;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  transform: none;
}

.tab-btn.active {
  border-color: rgba(96, 165, 250, 0.24);
  background: rgba(59, 130, 246, 0.15);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--accent-color);
}

.topbar-user[hidden] { display: none; }
.topbar-user {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--glass-border);
}

.sidebar-account { grid-column: 1 / -1; min-width: 0; padding: 0 8px 4px; }
.sidebar-account-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-muted);
  font-size: 11px;
}
.topbar-username {
  display: block;
  overflow: hidden;
  color: var(--text-main);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-user button { min-width: 0; padding: 8px 9px; font-size: 12px; }

.app-workspace { min-width: 0; }
.workspace-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  min-height: 76px;
  padding: 14px 32px;
  border-bottom: 1px solid var(--glass-border);
  background: rgba(11, 18, 32, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.workspace-heading { min-width: 0; }
.workspace-heading h1 { margin: 0; font-size: 21px; letter-spacing: -0.3px; }
.workspace-heading p { margin: 1px 0 0; color: var(--text-muted); font-size: 12px; }
.workspace-header-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
  margin-left: auto;
  padding-left: 20px;
}
.workspace-header-actions[hidden] { display: none; }
.app-nav-toggle { display: none; margin-right: 12px; }
.app-nav-mask { display: none; }
.content { width: min(100%, 1440px); margin: 0 auto; padding: 28px 32px 48px; }

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.25s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.browser-session-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: -4px 0 20px;
  padding: 12px 14px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.025);
}
.browser-session-copy,
.browser-session-actions { display: flex; align-items: center; gap: 10px; }
.browser-session-copy > span { display: grid; line-height: 1.25; }
.browser-session-copy strong { font-size: 13px; }
.browser-session-copy small { color: var(--text-muted); font-size: 11px; }

.browser-launch-group {
  display: flex;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
}
.browser-launch-group select {
  min-width: 130px;
  max-width: 200px;
  height: 38px;
  padding: 0 10px;
  border: 0;
  border-right: 1px solid var(--glass-border);
  border-radius: 0;
  background: #172033;
  color-scheme: dark;
  font-size: 13px;
}
.browser-launch-group button {
  height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 0;
  font-size: 13px;
}
.browser-launch-group button:hover { transform: none; }


/* Sections */
.section-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
}
.section-header.compact { margin-bottom: 16px; }
.section-header.with-top-gap { margin-top: 24px; }
.section-header h2, .section-header h3, .section-header h4 { margin: 0 0 4px; }

.task-header-actions,
.backup-selection-bar,
.backup-import-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.backup-selection-bar {
  margin: -6px 0 16px;
  padding: 12px 14px;
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: var(--radius-md);
  background: rgba(59, 130, 246, 0.08);
}

.backup-selection-bar[hidden] { display: none; }
.backup-selection-count { margin-right: auto; }
.backup-secret-check { color: #fcd34d; }

.task-card.backup-selectable {
  position: relative;
  cursor: pointer;
}

.task-card.backup-selected {
  border-color: rgba(96, 165, 250, 0.7);
  box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.3), var(--glass-shadow);
}

.backup-task-check {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  width: 20px;
  height: 20px;
  accent-color: var(--accent-color);
}

.task-card.backup-selectable .task-card-top { padding-right: 32px; }
.backup-import-panel { width: min(760px, calc(100vw - 32px)); max-height: min(760px, calc(100vh - 48px)); overflow: auto; }
.backup-import-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 14px 0; }
.backup-summary-card { padding: 12px; border: 1px solid var(--glass-border); border-radius: var(--radius-md); background: rgba(255,255,255,0.035); }
.backup-summary-card strong { display: block; font-size: 22px; }
.backup-conflict-list { margin: 8px 0 16px; padding-left: 20px; max-height: 180px; overflow: auto; }
.backup-warning { color: #fcd34d; }
.backup-import-actions { justify-content: flex-end; margin-top: 20px; }

.task-groups {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
/*
 * 分组是筛选栏，不是每组一块网格：分组多了纵向堆叠会占满整屏，
 * 而且每块网格按自身宽度算列数，任务少的组会把卡片拉宽变形。
 * 这里固定成一行可横向滚动的 chip，卡片始终共用下方同一张网格。
 */
.task-group-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}
.task-group-bar::-webkit-scrollbar { height: 4px; }
.task-group-bar::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 4px; }
.task-group-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  max-width: 200px;
  padding: 5px 11px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.task-group-chip:hover { color: var(--text-main); }
.task-group-chip.is-active {
  border-color: transparent;
  background: var(--accent-color);
  color: #fff;
}
.task-group-chip span:not(.task-group-dot) { font-size: 12px; opacity: 0.75; }
.task-group-dot {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  flex: 0 0 auto;
}
.task-group-pill { flex-shrink: 0; }
.task-groups-modal { width: min(680px, calc(100vw - 32px)); }
.task-group-create-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-bottom: 16px; }
.task-groups-manage-list { display: grid; gap: 8px; }
.task-group-manage-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 36px 36px 36px; gap: 7px; align-items: center; }

/* Grid */
.task-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.task-grid .empty { grid-column: 1 / -1; margin: 0; }

.run-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.run-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

/* Glass Cards */
.task-card,
.script-card,
.run-card,
.metric-card,
.modal-panel,
.config-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-top-color: rgba(255, 255, 255, 0.12); /* Light reflection */
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
  padding: 24px;
  transition: var(--transition);
}

/* Global config: searchable index + sections */
#config-tab { scroll-margin-top: 12px; }
.config-page-header { align-items: flex-end; }
.config-page-header > div:first-child { align-self: flex-start; }
.config-search { position: relative; width: min(440px, 100%); }
.config-search > .field-label { display: block; margin-bottom: 5px; font-size: 12px; }
.config-search-field { position: relative; }
.config-search-field .lucide {
  position: absolute;
  top: 50%;
  left: 13px;
  z-index: 1;
  color: var(--text-muted);
  transform: translateY(-50%);
  pointer-events: none;
}
.config-search-field input { height: 42px; padding-left: 40px; }
.config-search-status { min-height: 18px; margin: 4px 2px 0; font-size: 11px; }
.config-search-results[hidden] { display: none; }
.config-search-results {
  position: absolute;
  top: calc(100% - 18px);
  right: 0;
  left: 0;
  z-index: 70;
  overflow: auto;
  max-height: 320px;
  padding: 6px;
  border: 1px solid rgba(96, 165, 250, 0.28);
  border-radius: var(--radius-md);
  background: #111b2d;
  box-shadow: var(--glass-shadow);
}
.config-search-result {
  display: block;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  box-shadow: none;
  color: var(--text-main);
  text-align: left;
  white-space: normal;
}
.config-search-result:hover,
.config-search-result.is-highlighted { background: rgba(59, 130, 246, 0.16); transform: none; }
.config-search-result strong,
.config-search-result span { display: block; }
.config-search-result span { margin-top: 1px; color: var(--text-muted); font-size: 11px; }
.config-search-empty { padding: 14px 12px; color: var(--text-muted); font-size: 13px; }

.config-layout {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.config-subnav {
  position: sticky;
  top: 94px;
  z-index: 20;
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.config-subnav-label,
.config-subnav-group {
  padding: 3px 9px 6px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.config-subnav-group { margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--glass-border); }
.config-subnav-btn {
  justify-content: flex-start;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  box-shadow: none;
  color: var(--text-muted);
  font-size: 13px;
  text-align: left;
}
.config-subnav-btn:hover { background: rgba(255, 255, 255, 0.06); color: var(--text-main); transform: none; }
.config-subnav-btn.active {
  border-color: rgba(96, 165, 250, 0.25);
  background: rgba(59, 130, 246, 0.18);
  color: #fff;
}
.config-subnav-child { padding-left: 22px; font-size: 12px; }
.config-subnav-child::before { content: '└'; margin-right: 5px; color: #64748b; }
.config-sections { min-width: 0; }
.config-section { margin-top: 16px; scroll-margin-top: 96px; }
.config-section:first-child { margin-top: 0; }
.config-details { scroll-margin-top: 96px; }
.config-search-target { animation: configTarget 1.4s ease; }
@keyframes configTarget {
  0%, 35% { border-color: rgba(96, 165, 250, 0.85); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16); }
  100% { border-color: var(--glass-border); }
}

/* 云端备份：设置表单下方的「立即备份 / 远端备份」分区 */
.cloud-backup-block {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.config-advanced .config-details {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md, 12px);
  background: rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

.config-details > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 14px 16px;
  user-select: none;
}

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

.config-details > summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 8px;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}

.config-details[open] > summary::before {
  transform: rotate(90deg);
}

.config-details-title {
  font-weight: 600;
  color: var(--text-main);
}

.config-details-body {
  padding: 0 16px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 14px;
}

@media (max-width: 1060px) {
  .config-layout { grid-template-columns: 1fr; }
  .config-subnav {
    top: 76px;
    display: flex;
    overflow-x: auto;
    gap: 6px;
    padding: 8px;
    scrollbar-width: thin;
  }
  .config-subnav-label,
  .config-subnav-group { display: none; }
  .config-subnav-btn { width: auto; flex: 0 0 auto; padding: 7px 11px; }
  .config-subnav-child { padding-left: 11px; }
  .config-subnav-child::before { display: none; }
}

@media (max-width: 640px) {
  .task-grid { grid-template-columns: minmax(0, 1fr); }
  .task-group-bar { margin-right: -16px; margin-left: -16px; padding-right: 16px; padding-left: 16px; }
  .task-group-manage-row { grid-template-columns: minmax(0, 1fr) auto auto auto auto; }
  .config-page-header { gap: 10px; }
  .config-search { width: 100%; }
  .config-subnav { margin-right: -16px; margin-left: -16px; border-right: 0; border-left: 0; border-radius: 0; }
  .config-section,
  .config-details { scroll-margin-top: 132px; }
}

.task-card { padding: 14px; }
.task-card, .script-card, .run-card {
  display: flex;
  flex-direction: column;
  height: auto;
  min-width: 0;
}
.script-card, .run-card { padding: 18px; }


.task-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px -14px rgba(0, 0, 0, 0.55);
  border-color: rgba(255, 255, 255, 0.13);
}

.script-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.6);
  border-color: rgba(255, 255, 255, 0.15);
}

.task-card-top, .run-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.task-card-top { position: relative; }

.task-card-head-main {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  /* Keep title row one line so profile slot below stays fixed */
  flex-wrap: nowrap;
}

.task-title-row h3, .script-card h3, .run-head strong {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  max-width: 100%;
}

.task-title-row .pill {
  flex-shrink: 0;
}

/* Fixed second-line slot: persistent/temp profile never jumps into title chips */
.task-profile-slot {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  min-width: 0;
}

.task-profile-pill {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/*
 * Metrics layout: always stacked full-width rows.
 * Schedule / HTTP / remaining-callback are mutually exclusive in practice —
 * only one "when it runs" block is shown under latest result (same as therose).
 */
.task-metrics {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 16px 0;
  flex: 1 1 auto;
  min-height: 0;
  align-content: start;
}

.task-metrics .metric-card {
  min-height: 88px;
  height: auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
}

.task-metrics .metric-schedule,
.task-metrics .metric-condition {
  min-height: 88px;
}

.metric-card {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.25);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.04);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0;
  min-width: 0;
}

.status-indicator > span:not(.dot) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.status-indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
}

.status-indicator .dot.success { background: #4ade80; box-shadow: 0 0 10px rgba(74, 222, 128, 0.6); }
.status-indicator .dot.failed { background: #f87171; box-shadow: 0 0 10px rgba(248, 113, 113, 0.6); }
.status-indicator .dot.idle { background: #64748b; box-shadow: 0 0 10px rgba(100, 116, 139, 0.3); }
.status-indicator .dot.active { background: #60a5fa; box-shadow: 0 0 10px rgba(96, 165, 250, 0.6); }

.metric-card .metric-label, .run-grid .label, .field-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
  flex-shrink: 0;
}

.metric-card .metric-value {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: auto;
  line-height: 1.4;
  word-break: break-word;
}

.metric-card.success { border-bottom: 2px solid rgba(34, 197, 94, 0.5); }
.metric-card.failed { border-bottom: 2px solid rgba(239, 68, 68, 0.5); }

/* Keep task cards in a row the same visual height within the grid */
.task-grid {
  align-items: stretch;
}
.task-card {
  min-height: 250px;
}
.task-card .task-actions {
  margin-top: auto;
}
.task-card .task-subtitle {
  display: none; /* script binding no longer shown on card */
}

/* Pills & Tags */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(4px);
}

.pill-id { color: #93c5fd; }
.pill-group {
  color: #fcd34d;
  background: rgba(245, 158, 11, 0.13);
  border-color: rgba(251, 191, 36, 0.26);
  max-width: 108px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pill-type {
  color: #c4b5fd;
  background: rgba(139, 92, 246, 0.13);
  border-color: rgba(167, 139, 250, 0.26);
  font-family: var(--font-body);
}

.pill-running {
  color: #93c5fd;
  background: rgba(37, 99, 235, 0.14);
  border-color: rgba(96, 165, 250, 0.28);
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.2);
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.task-running {
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.3), var(--glass-shadow);
}

.selected-script {
  border-color: var(--accent-color);
  background: rgba(59, 130, 246, 0.05);
}

/* Form block */
.stack-form { display: grid; gap: 16px; }
.grid { display: grid; gap: 16px; }
.grid.two-col-tight { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three-col-tight { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.single-col { grid-template-columns: 1fr; }

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

.locale-setting-control {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.locale-preset-select,
.locale-custom-input {
  width: 100%;
  min-width: 0;
}

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.task-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 8px;
}

.task-primary-action { width: 100%; min-height: 44px; }
.task-stop-action {
  border: 1px solid rgba(248, 113, 113, 0.3);
  background: rgba(239, 68, 68, 0.13);
  color: #fca5a5;
  box-shadow: none;
}
.task-stop-action:hover { background: rgba(239, 68, 68, 0.2); }
.task-overflow { position: relative; flex: 0 0 auto; }
.task-overflow-trigger {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 10px;
}
.task-overflow-panel {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  z-index: 20;
  display: grid;
  width: 160px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.98);
  box-shadow: 0 16px 34px -12px rgba(0, 0, 0, 0.7);
}
.task-overflow-panel[hidden] { display: none; }
.task-overflow-item {
  justify-content: flex-start;
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-main);
  box-shadow: none;
  text-shadow: none;
}
.task-overflow-item:hover {
  transform: none;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: none;
}
.task-overflow-danger { color: #fca5a5; }
.task-overflow-danger:hover { background: rgba(239, 68, 68, 0.12); }

.task-runs-block {
  margin-top: 12px;
  max-height: 360px;
  overflow: auto;
  overscroll-behavior: contain;
  display: grid;
  gap: 12px;
  padding-right: 4px;
}

.task-runs-block:empty {
  margin-top: 0;
  max-height: 0;
  overflow: hidden;
}

.task-runs-block .run-card {
  height: auto;
  min-height: 0;
  padding: 14px;
  box-shadow: none;
  background: rgba(0, 0, 0, 0.18);
}

.task-runs-block .run-head {
  align-items: center;
  gap: 8px;
}

.task-runs-block .run-head strong {
  min-width: 0;
  font-size: 15px;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-runs-block .run-status {
  flex-shrink: 0;
}

.task-runs-block .run-grid.compact {
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 10px;
}

.task-runs-block .run-grid.compact > div {
  min-width: 0;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
}

.task-runs-block .run-grid.compact span:not(.label) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-runs-block .run-grid .label {
  margin: 0;
}

.task-runs-block .row,
.task-runs-block a {
  min-width: 0;
}

.task-runs-block .row {
  gap: 8px;
  margin-top: 10px;
}

.task-runs-block pre {
  max-height: 120px;
  overflow: auto;
  margin-top: 10px;
  padding: 12px;
}

.runs-modal {
  width: min(900px, calc(100vw - 32px));
}

.runs-modal-body {
  padding: 24px;
}

.runs-modal-list {
  display: grid;
  gap: 12px;
  max-height: min(620px, calc(100vh - 180px));
  overflow: auto;
  padding-right: 4px;
}

.runs-modal-list .run-card {
  height: auto;
  min-height: 0;
}

.runs-modal-list .run-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.runs-modal-list .run-grid.compact > div {
  min-width: 0;
}

.runs-modal-list .run-grid.compact span:not(.label) {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.runs-modal-list pre {
  max-height: 160px;
  overflow: auto;
}

/* Status */
.run-status {
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255,255,255,0.05);
  font-size: 12px;
  font-weight: 500;
}
.run-status.success { color: #4ade80; border-color: rgba(74, 222, 128, 0.2); }
.run-status.failed { color: #f87171; border-color: rgba(248, 113, 113, 0.2); }

/* Modals */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 40;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(780px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  transform: translate(-50%, -48%) scale(0.96);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); /* bouncy open */
  z-index: 50;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-top-color: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-xl);
  box-shadow: 0 40px 100px -20px rgba(0, 0, 0, 0.8);
}

.modal.modal-wide { width: min(1200px, calc(100vw - 32px)); }

.modal.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.modal-header {
  padding: 24px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(0, 0, 0, 0.2);
}

.modal-header h2 { margin: 0; font-size: 24px; }
.modal-body { padding: 32px; }

/* 两步验证弹窗 */
.twofa-section {
  margin-bottom: 22px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.twofa-section:first-of-type { padding-top: 0; border-top: none; }
.twofa-section h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
}
.twofa-section h3 .lucide { color: var(--accent-color); }
.twofa-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
}
.twofa-row strong { font-size: 14px; }
.twofa-row p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}
.totp-setup {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
}
.totp-qr-wrap {
  display: flex;
  justify-content: center;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: #fff;
}
.totp-qr-wrap img { display: block; image-rendering: pixelated; }
.totp-secret-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.totp-secret-row code {
  flex: 1;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-all;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  user-select: all;
}
.passkey-list {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}
.passkey-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 14px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
}
.passkey-item strong { font-size: 14px; }
.passkey-item p {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
.twofa-add-row {
  display: flex;
  gap: 8px;
}
.twofa-add-row input {
  flex: 1;
  min-width: 0;
  width: auto;
}

.two-col-modal {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* Task create/edit modal: header toolbar + sectioned left form */
.task-modal {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 32px);
}

.task-modal-header {
  flex-shrink: 0;
  gap: 12px 16px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.task-modal-header-main {
  flex: 1;
  min-width: min(100%, 280px);
  display: grid;
  gap: 10px;
}

.task-modal-header-title h2 {
  margin: 0;
}

.task-modal-header-title #form-hint {
  margin: 4px 0 0;
  font-size: 13px;
}

.task-modal-header-summary {
  margin: 2px 0 0;
  font-size: 12px;
  opacity: 0.9;
}

.task-modal-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}

.task-modal-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 20px 24px 24px;
}

.task-modal-grid {
  align-items: start;
}

.task-modal-main {
  min-width: 0;
}

.task-modal-script {
  min-width: 0;
  position: sticky;
  top: 0;
  align-self: start;
  max-height: calc(100vh - 180px);
  overflow: auto;
}

.task-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
}

.task-subnav-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}

.task-subnav-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.task-subnav-btn.active {
  background: rgba(59, 130, 246, 0.22);
  border-color: rgba(96, 165, 250, 0.35);
  color: #fff;
}

.task-sections {
  display: grid;
  gap: 14px;
}

.task-section {
  scroll-margin-top: 16px;
}

.task-section-title {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 600;
}

.task-script-summary {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 13px;
}

.schedule-details,
.condition-details {
  margin-top: 8px;
  display: grid;
  gap: 12px;
}

/* .grid sets display:grid and would override the native [hidden] attribute */
.condition-details[hidden],
.condition-type-panel[hidden],
#condition-http-fields[hidden],
#condition-remaining-fields[hidden] {
  display: none !important;
}

.condition-type-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.condition-type-panel > .field-label.panel-title {
  margin: 0 0 2px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0.92;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .task-modal-grid {
    grid-template-columns: 1fr;
  }
  .task-modal-script {
    position: static;
    max-height: none;
  }
  .task-modal-header-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

.config-block {
  display: grid;
  gap: 16px;
  padding: 20px;
  border-radius: var(--radius-lg);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.2);
}

/* 运行日志查看器 */
.log-viewer-modal .log-viewer-body {
  max-height: min(72vh, 760px);
  overflow: auto;
}
.log-viewer-pre,
.log-viewer-summary {
  margin: 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: #dbe7ff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.log-viewer-toolbar .alt {
  min-height: 34px;
}

/* 运行日志抽屉 */
.log-drawer-mask {
  position: fixed;
  inset: 0;
  z-index: 10020;
  opacity: 0;
  background: rgba(2, 6, 23, 0.62);
  backdrop-filter: blur(4px);
  transition: opacity 0.25s ease;
}
.log-drawer-mask.open { opacity: 1; }
.log-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 10030;
  width: min(920px, calc(100vw - 48px));
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(24px);
  border-left: 1px solid var(--glass-border);
  box-shadow: -30px 0 80px rgba(0, 0, 0, 0.45);
}
.log-drawer.open { transform: translateX(0); }
.log-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--glass-border);
}
.log-drawer-header h2 { margin: 0 0 4px; font-size: 21px; }
.log-drawer-header p { margin: 0; }
.log-drawer-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--glass-border);
  background: rgba(0, 0, 0, 0.18);
}
.log-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.log-tools input[type="search"] { flex: 1 1 220px; min-width: 160px; }
.log-auto-scroll { display: inline-flex; align-items: center; gap: 5px; color: var(--text-muted); font-size: 13px; }
.log-match-count { min-width: 64px; font-size: 12px; }
.log-progress { min-height: 24px; padding: 5px 20px; font-size: 12px; border-bottom: 1px solid var(--glass-border); }

.resource-upload-progress {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.25);
}

.resource-upload-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
  font-size: 13px;
}

.resource-upload-progress-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resource-upload-progress-meter {
  display: block;
  width: 100%;
  height: 10px;
}
.log-terminal {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px 0 32px;
  background: #070c16;
  color: #dbe7ff;
  font-family: var(--font-heading);
  font-size: 12px;
  line-height: 1.55;
  tab-size: 2;
}
.log-line { display: flex; min-width: max-content; border-left: 2px solid transparent; }
.log-line:hover { background: rgba(255, 255, 255, 0.035); }
.log-line-no {
  position: sticky;
  left: 0;
  width: 62px;
  flex: 0 0 62px;
  padding-right: 12px;
  color: #53647e;
  text-align: right;
  user-select: none;
  background: #070c16;
  border-right: 1px solid rgba(255,255,255,.06);
}
.log-line-text { padding: 0 16px 0 12px; white-space: pre; }
.log-line.is-error { color: #fca5a5; border-left-color: #ef4444; }
.log-line.is-warn { color: #fde68a; border-left-color: #f59e0b; }
.log-line.is-success { color: #86efac; border-left-color: #22c55e; }
.log-line.is-match { background: rgba(59, 130, 246, 0.2); outline: 1px solid rgba(96, 165, 250, 0.35); }
@media (max-width: 900px) {
  .log-drawer { width: 100vw; }
  .log-drawer-toolbar { padding: 12px; }
  .log-tools { align-items: stretch; }
  .log-tools input[type="search"] { flex-basis: 100%; }
}

/* Vision 通道：[角标|URL|Key|Model|测试/主通道/删] */
.vision-channel-card {
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
}
.vision-channel-card.is-primary {
  border-color: rgba(167, 139, 250, 0.45);
  background: rgba(139, 92, 246, 0.08);
}
.vision-channel-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 0.9fr) auto;
  gap: 8px;
  align-items: center;
}
.vision-channel-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  min-width: 36px;
  padding: 0 6px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.vision-channel-card.is-primary .vision-channel-badge {
  color: #e9d5ff;
  background: rgba(139, 92, 246, 0.35);
  border-color: rgba(167, 139, 250, 0.55);
}
.vision-channel-row input {
  width: 100%;
  min-width: 0;
}
.vision-channel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
}
.vision-channel-actions .btn-with-icon {
  padding: 4px 8px;
  font-size: 12px;
  white-space: nowrap;
}
.vision-channel-actions .icon-btn {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}
.vision-channel-make-primary:disabled {
  opacity: 0.45;
  cursor: default;
}
/* Model 输入框 + 「▼」按钮：下拉面板的定位锚点 */
.vision-model-input-group {
  position: relative;
  display: flex;
  gap: 4px;
  align-items: center;
  min-width: 0;
}
.vision-model-input-group .vision-ch-model {
  flex: 1 1 auto;
  min-width: 0;
}
.vision-ch-model-toggle {
  width: 28px;
  height: 32px;
  flex-shrink: 0;
}
.vision-model-input-group.is-open .vision-ch-model-toggle {
  color: #e9d5ff;
  border-color: rgba(167, 139, 250, 0.8);
}
.vision-model-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  min-width: 260px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid rgba(167, 139, 250, 0.35);
  background: #14161f;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
}
.vision-model-search {
  width: 100%;
  margin-bottom: 6px;
  font-size: 12px;
}
.vision-model-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 260px;
  overflow-y: auto;
}
.vision-model-option {
  text-align: left;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  border-radius: 7px;
  padding: 5px 9px;
  font-size: 12px;
  cursor: pointer;
  word-break: break-all;
}
.vision-model-option:hover {
  border-color: rgba(167, 139, 250, 0.55);
  background: rgba(139, 92, 246, 0.14);
}
.vision-model-option.is-selected {
  background: rgba(139, 92, 246, 0.35);
  border-color: rgba(167, 139, 250, 0.8);
  color: #e9d5ff;
}
.vision-model-empty {
  padding: 10px 4px;
  font-size: 12px;
  color: #94a3b8;
  text-align: center;
}
.vision-model-empty.is-bad {
  color: #fca5a5;
}
.vision-model-dropdown-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 11px;
}
.vision-model-refresh {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  border-radius: 6px;
  padding: 3px 9px;
  font-size: 11px;
  cursor: pointer;
}
.vision-model-refresh:hover:not(:disabled) {
  border-color: rgba(167, 139, 250, 0.55);
}
.vision-model-refresh:disabled {
  opacity: 0.5;
  cursor: default;
}
@media (max-width: 900px) {
  .vision-channel-row {
    grid-template-columns: 36px 1fr;
    grid-template-areas:
      "badge base"
      ". key"
      ". model"
      ". actions";
  }
  .vision-channel-badge { grid-area: badge; }
  .vision-channel-row .vision-ch-base { grid-area: base; }
  .vision-channel-row .vision-ch-key { grid-area: key; }
  .vision-channel-row .vision-model-input-group { grid-area: model; }
  .vision-channel-actions { grid-area: actions; justify-content: flex-start; }
}

.profile-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 14px;
}

.profile-card {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  padding: 14px 14px 12px;
  display: grid;
  gap: 10px;
  min-width: 0;
  transition: var(--transition);
}

.profile-card:hover {
  border-color: rgba(96, 165, 250, 0.45);
  box-shadow: 0 10px 24px -12px rgba(37, 99, 235, 0.45);
  transform: translateY(-1px);
}

.profile-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.profile-card-name {
  display: block;
  font-size: 15px;
  line-height: 1.2;
}

.profile-card-id {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-heading);
}

.profile-card-actions {
  flex-shrink: 0;
}

.profile-card-actions button {
  padding: 7px 10px;
  font-size: 12px;
}

.profile-btn-danger {
  color: #fca5a5 !important;
  border-color: rgba(239, 68, 68, 0.25) !important;
  background: rgba(239, 68, 68, 0.08) !important;
}

.profile-btn-danger:hover {
  background: rgba(239, 68, 68, 0.16) !important;
}

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

.profile-kv {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.profile-kv-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.45px;
}

.profile-kv-value {
  font-size: 13px;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-path-block {
  min-width: 0;
  display: grid;
  gap: 4px;
  padding-top: 4px;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
}

.profile-path-value {
  font-family: var(--font-heading);
  font-size: 12px;
  color: #bfdbfe;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 6px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.schedule-note {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* 附加模块：导出前确认要跟主脚本一起打包的模块目录 */
.backup-assets-panel {
  width: min(680px, calc(100vw - 32px));
  max-height: min(720px, calc(100vh - 48px));
  overflow: auto;
}
.backup-assets-task {
  padding: 12px 0;
  border-bottom: 1px solid var(--glass-border);
}
.backup-assets-task:last-of-type { border-bottom: none; }
.backup-assets-task-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.backup-assets-task-head code { font-size: 12px; }
.backup-assets-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 4px;
}
.backup-assets-list .inline-check { gap: 8px; }
.backup-assets-list code {
  font-size: 12px;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.active-pane {
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(59, 130, 246, 0.3);
  background: rgba(37, 99, 235, 0.05);
}

.schedule-mode-select-wrap, .schedule-fields { margin-top: 8px; }
.schedule-pane { display: grid; gap: 16px; margin-top: 8px; }
.schedule-pane[hidden] { display: none !important; }

/* Misc Elements */
pre {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  background: #020617;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 12px;
  color: #fca5a5;
  font-family: var(--font-heading);
  font-size: 13px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Custom Checkbox */
.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.inline-check input { width: auto; cursor: pointer; }

/* Script lists */
.script-list { display: grid; gap: 12px; }
.script-picker { display: grid; gap: 12px; }
.script-picker-actions { justify-content: flex-start; }
.script-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.script-card .task-actions { margin-top: 0; flex-shrink: 0; }
.stack-form.with-bottom-gap { margin-bottom: 20px; }

/* Responsive */
@media (max-width: 1024px) {
  .two-col-modal { grid-template-columns: 1fr; }
  .modal.modal-wide { width: min(800px, calc(100vw - 32px)); }
}

@media (max-width: 900px) {
  body.app-nav-open { overflow: hidden; }
  .app-shell { display: block; }
  .app-sidebar {
    position: fixed;
    left: 0;
    width: min(320px, calc(100vw - 40px));
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
  }
  .app-shell.is-nav-open .app-sidebar { transform: translateX(0); }
  .app-nav-mask {
    position: fixed;
    inset: 0;
    z-index: 55;
    width: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: rgba(2, 6, 23, 0.68);
    box-shadow: none;
  }
  .app-nav-mask:not([hidden]) { display: block; }
  .app-nav-mask:hover { transform: none; filter: none; }
  .app-nav-toggle { display: inline-flex; }
  .workspace-header { min-height: 68px; padding: 11px 20px; align-items: flex-start; }
  .workspace-header-actions { padding-left: 12px; }
  .content { padding: 24px 20px 40px; }
}

@media (max-width: 768px) {
  .task-metrics, .grid.two-col-tight, .grid.three-col-tight, .run-grid.compact,
  .locale-setting-grid {
    grid-template-columns: 1fr;
  }
  .profile-card-grid,
  .profile-kv-grid { grid-template-columns: 1fr; }
  .profile-card-head,
  .task-page-header,
  .config-page-header,
  .run-head { flex-direction: column; align-items: stretch; }
  .profile-card-actions { width: 100%; }
  .profile-card-actions button { flex: 1; justify-content: center; }
  .browser-session-toolbar { align-items: stretch; flex-direction: column; }
  .browser-session-actions { justify-content: flex-end; }
  .workspace-header { flex-wrap: wrap; }
  .workspace-heading { flex: 1 1 180px; }
  .workspace-header-actions { width: 100%; margin-left: 0; padding-left: 0; }
}

@media (max-width: 520px) {
  .workspace-heading p { display: none; }
  .workspace-heading h1 { font-size: 18px; }
  .workspace-header-actions button { flex: 1 1 auto; padding-right: 10px; padding-left: 10px; }
  .content { padding: 20px 16px 36px; }
  .task-header-actions { width: 100%; }
  .task-header-actions button { flex: 1; padding-right: 10px; padding-left: 10px; }
  .browser-session-actions { align-items: stretch; flex-direction: column; }
  .browser-launch-group { width: 100%; }
  .browser-launch-group select { min-width: 0; max-width: none; flex: 1; }
  .browser-session-actions > button { width: 100%; }
  .task-overflow-panel { max-width: calc(100vw - 48px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .task-card:hover, .script-card:hover { transform: none; }
}

/* 移动端任务卡片高度固定：不管 1 个还是 100 个任务，每张卡片都是同一高度，
 * 内容多了自动截断（任务名/状态本身有 ellipsis），不会把卡片压扁或挤变形。
 * 只作用于手机单列（max-width: 640px），桌面端保持原样。
 * iOS WebKit 会把 height:100% 的 flex 项按内容压扁，用 !important 把
 * 卡片与网格行高全部钉死为同一值，不给协商空间。
 */
@media (max-width: 640px) {
  .task-grid {
    grid-auto-rows: 390px !important;
  }
  .task-grid .task-card {
    height: 390px !important;
    min-height: 390px !important;
    max-height: 390px !important;
  }
  .task-grid .task-actions {
    flex-shrink: 0 !important;
  }
}

.pill-temp {
  background: rgba(56, 189, 248, 0.13);
  color: #7dd3fc;
  border: 1px solid rgba(125, 211, 252, 0.24);
}

.pill-persistent {
  background: rgba(251, 191, 36, 0.12);
  color: #fcd34d;
  border: 1px solid rgba(252, 211, 77, 0.25);
}

/* Env editor — list + dialog (GitHub Secrets style) */
.env-editor {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.4);
  overflow: hidden;
}

.env-list-empty {
  padding: 20px 16px;
  text-align: center;
  font-size: 13px;
}

.env-list-head,
.env-list-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.1fr) minmax(120px, 1.4fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
}

.env-list-head {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--glass-border);
  background: rgba(30, 41, 59, 0.5);
}

.env-list-row {
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.env-list-row:last-child {
  border-bottom: none;
}

.env-list-row:hover {
  background: rgba(59, 130, 246, 0.06);
}

.env-list-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.env-list-name code {
  font-family: var(--font-heading);
  font-size: 13px;
  color: #e2e8f0;
  word-break: break-all;
}

.env-list-value {
  font-size: 13px;
  font-family: var(--font-heading);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.env-list-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}

.env-list-actions .alt {
  padding: 4px 10px;
  font-size: 12px;
}

.env-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

.env-badge-secret {
  background: rgba(251, 191, 36, 0.12);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.28);
}

.env-badge-var {
  background: rgba(56, 189, 248, 0.12);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.28);
}

.env-var-dialog .env-dlg-name[readonly] {
  opacity: 0.85;
  cursor: default;
}

.env-var-dialog .env-dlg-value {
  width: 100%;
  min-height: 140px;
  resize: vertical;
  font-family: var(--font-heading);
  font-size: 13px;
  line-height: 1.45;
}

.env-advanced {
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: rgba(15, 23, 42, 0.35);
}

.env-advanced summary {
  cursor: pointer;
  user-select: none;
}

.env-advanced textarea {
  width: 100%;
  margin-top: 8px;
  font-family: var(--font-heading);
  font-size: 12px;
}

@media (max-width: 720px) {
  .env-list-head,
  .env-list-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .env-list-actions {
    justify-content: flex-start;
  }
}

/* tasks/ file manager */
.files-list {
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.4);
  overflow: hidden;
  min-height: 120px;
  max-height: 420px;
  overflow-y: auto;
}

.files-list-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.files-row {
  display: grid;
  /* icon | name | size | mtime | actions */
  grid-template-columns: 28px minmax(0, 1fr) 72px 132px auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  cursor: default;
}

.files-row:last-child {
  border-bottom: none;
}

.files-row:hover {
  background: rgba(59, 130, 246, 0.06);
}

.files-row.is-dir {
  cursor: pointer;
}

.files-row-head {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(15, 23, 42, 0.92);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 8px;
  padding-bottom: 8px;
  cursor: default;
  pointer-events: none;
}

.files-row-head .files-name,
.files-row-head .files-meta,
.files-row-head .files-mtime {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  text-transform: none;
}

.files-name {
  font-family: var(--font-heading);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.files-meta {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.files-mtime {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 720px) {
  .files-row {
    grid-template-columns: 28px minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
  }
  .files-meta,
  .files-mtime {
    grid-column: 2;
    text-align: left;
  }
  .files-actions {
    grid-column: 3;
    grid-row: 1 / span 2;
  }
}

.files-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.files-actions .alt {
  padding: 3px 8px;
  font-size: 12px;
}

.files-breadcrumb code {
  font-size: 12px;
}

.files-editor-dialog .files-editor-area {
  width: 100%;
  min-height: 360px;
  font-family: var(--font-heading);
  font-size: 13px;
  line-height: 1.45;
  resize: vertical;
}

/* Toast System */
#toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.toast {
  background: rgba(15, 23, 42, 0.95);
  color: #fff;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  font-size: 14px;
  font-weight: 500;
  pointer-events: auto;
  transform: translateX(120%);
  opacity: 0;
  animation: toast-slide-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  max-width: 400px;
  word-break: break-word;
}

.toast.toast-fade-out {
  animation: toast-slide-out 0.3s forwards;
}

@keyframes toast-slide-in {
  to { transform: translateX(0); opacity: 1; }
}

@keyframes toast-slide-out {
  to { transform: translateX(120%); opacity: 0; }
}

.toast-success i { color: #10b981; }
.toast-error i { color: #ef4444; }
.toast-info i { color: #3b82f6; }
.toast-warn i { color: #f59e0b; }


/* Run screenshots gallery */
.shots-modal {
  width: min(1100px, calc(100vw - 32px));
}

.shots-modal-body {
  padding: 20px 24px 24px;
}

.shots-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 16px;
  min-height: min(620px, calc(100vh - 220px));
}

.shots-thumbs {
  display: grid;
  gap: 10px;
  align-content: start;
  max-height: min(620px, calc(100vh - 220px));
  overflow: auto;
  overflow-anchor: none; /* avoid scroll jump when active thumb styles change */
  padding-right: 4px;
  overscroll-behavior: contain;
}

.shot-thumb {
  display: grid;
  gap: 6px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.shot-thumb img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 6px;
  background: #0b0f14;
}

.shot-thumb span {
  font-size: 12px;
  color: rgba(255,255,255,0.72);
}

.shot-thumb.is-active {
  border-color: rgba(96, 165, 250, 0.55);
  box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.25) inset;
}

.shots-preview {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  min-width: 0;
}

.shots-preview-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.shots-preview-meta strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shots-preview-frame {
  min-height: 0;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  background: #0b0f14;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}

.shots-preview-frame img {
  max-width: 100%;
  max-height: min(560px, calc(100vh - 280px));
  object-fit: contain;
}

.shots-preview-actions {
  justify-content: space-between;
  align-items: center;
}

button.linkish {
  appearance: none;
  border: 0;
  background: transparent;
  color: #93c5fd;
  padding: 0;
  cursor: pointer;
  font: inherit;
}

button.linkish:hover {
  text-decoration: underline;
}

.warp-overview,
.warp-family-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.warp-overview > div,
.warp-family-card,
.warp-job {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.warp-overview > div {
  display: grid;
  gap: 4px;
}

.warp-overview code,
.warp-family-card dd {
  overflow-wrap: anywhere;
}

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

.warp-family-head,
.warp-job-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.warp-family-card dl {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 12px;
  margin: 12px 0 0;
}

.warp-family-card dt {
  color: var(--muted);
}

.warp-family-card dd {
  margin: 0;
  text-align: right;
}

.warp-family-error {
  margin: 10px 0 0;
  color: #fca5a5;
  overflow-wrap: anywhere;
}

.warp-job {
  margin-bottom: 14px;
}

.warp-job progress {
  width: 100%;
  margin-top: 10px;
}

.warp-actions {
  align-items: center;
}

@media (max-width: 900px) {
  .warp-overview,
  .warp-family-grid {
    grid-template-columns: 1fr;
  }
  .shots-layout {
    grid-template-columns: 1fr;
  }
  .shots-thumbs {
    grid-auto-flow: column;
    grid-auto-columns: 140px;
    overflow-x: auto;
    overflow-y: hidden;
    max-height: none;
  }
}

/* Vision AI test modal */
.vision-test-modal {
  width: min(640px, calc(100vw - 32px));
}
.vision-test-grid {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px;
  line-height: 1.45;
}
.vision-test-summary {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.4;
}
.vision-test-summary.is-ok {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #86efac;
}
.vision-test-summary.is-bad {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}
.vision-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.vision-model-chip {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.vision-model-chip:hover {
  border-color: rgba(167, 139, 250, 0.55);
}
.vision-model-chip.is-selected {
  background: rgba(139, 92, 246, 0.35);
  border-color: rgba(167, 139, 250, 0.8);
  color: #e9d5ff;
}
