:root {
  --bg: #05060a;
  --bg-panel: #0b0d14;
  --bg-card: #11131c;
  --border: #1e2230;
  --border-hover: #2a3050;
  --text: #f0f1f5;
  --text-secondary: #8b92a8;
  --accent: #00d4ff;
  --accent-soft: rgba(0,212,255,0.12);
  --danger: #ff4d4f;
  --warning: #faad14;
  --success: #52c41a;
  --purple: #a855f7;
}
* { margin:0; padding:0; box-sizing:border-box; }
html, body { height:100%; background:var(--bg); color:var(--text); font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"PingFang SC","Microsoft YaHei",sans-serif; overflow:hidden; }

.alert-bar {
  position:fixed; top:0; left:0; right:0; height:40px;
  background:linear-gradient(90deg, rgba(255,77,79,0.15), rgba(255,77,79,0.05));
  border-bottom:1px solid rgba(255,77,79,0.3);
  display:flex; align-items:center; justify-content:center; gap:12px;
  font-size:13px; color:#ffccc7; z-index:2000; transition:transform .3s;
}
.alert-bar.hidden { transform:translateY(-100%); }
.alert-bar .alert-dot { width:8px; height:8px; background:var(--danger); border-radius:50%; animation:pulse 1.5s infinite; }
.alert-bar .btn-fix {
  background:rgba(255,77,79,0.2); border:1px solid rgba(255,77,79,0.4); color:#ffccc7;
  padding:3px 10px; border-radius:4px; font-size:12px; cursor:pointer;
}

.top-nav {
  position:fixed; top:0; left:0; right:0; height:56px;
  background:rgba(11,13,20,0.85); backdrop-filter:blur(20px);
  border-bottom:1px solid var(--border); z-index:1999;
  display:flex; align-items:center; justify-content:space-between; padding:0 20px;
}
.top-nav.has-alert { top:40px; }
.logo { font-size:20px; font-weight:800; letter-spacing:-0.5px; display:flex; align-items:center; gap:8px; }
.logo::before { content:''; width:8px; height:8px; background:var(--accent); border-radius:50%; box-shadow:0 0 12px var(--accent); }
.nav-tabs { display:flex; gap:6px; }
.nav-tab {
  padding:8px 16px; border-radius:6px; font-size:13px; color:var(--text-secondary);
  cursor:pointer; border:1px solid transparent; transition:.2s;
}
.nav-tab:hover { color:var(--text); background:rgba(255,255,255,0.03); }
.nav-tab.active { color:var(--text); background:var(--accent-soft); border-color:rgba(0,212,255,0.25); }
.nav-right { display:flex; align-items:center; gap:16px; }
.status-pill {
  display:flex; align-items:center; gap:6px; font-size:12px; color:var(--text-secondary);
  background:var(--bg-card); border:1px solid var(--border); padding:4px 10px; border-radius:99px;
}
.status-pill .dot { width:6px; height:6px; border-radius:50%; }
.dot.ok { background:var(--success); box-shadow:0 0 6px rgba(82,196,26,0.5); }
.dot.warn { background:var(--warning); }
.dot.err { background:var(--danger); animation:pulse 1.5s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

.app { position:fixed; top:56px; left:0; right:0; bottom:0; display:flex; }
.app.has-alert { top:96px; }

.sidebar {
  width:240px; border-right:1px solid var(--border); background:var(--bg-panel);
  display:flex; flex-direction:column; padding:16px; gap:12px; flex-shrink:0;
}
.sidebar-section-title { font-size:11px; color:var(--text-secondary); text-transform:uppercase; letter-spacing:1px; margin-top:8px; }
.menu-item {
  display:flex; align-items:center; gap:10px; padding:10px 12px; border-radius:8px;
  font-size:13px; color:var(--text-secondary); cursor:pointer; transition:.2s;
}
.menu-item:hover { background:rgba(255,255,255,0.03); color:var(--text); }
.menu-item.active { background:var(--accent-soft); color:var(--accent); }
.menu-icon { font-size:15px; width:20px; text-align:center; }
.node-list { display:flex; flex-direction:column; gap:6px; }
.node-item {
  display:flex; align-items:center; justify-content:space-between; padding:8px 10px;
  background:var(--bg-card); border:1px solid var(--border); border-radius:6px; font-size:12px;
}
.node-item .node-name { color:var(--text); }
.node-item .node-status { width:6px; height:6px; border-radius:50%; }

.main { flex:1; overflow:hidden; display:flex; flex-direction:column; }
.page { flex:1; overflow-y:auto; padding:20px; }
.page.hidden { display:none; }
.page-header { margin-bottom:20px; }
.page-header h2 { font-size:22px; font-weight:700; margin-bottom:4px; }
.page-header p { font-size:13px; color:var(--text-secondary); }

.grid-4 { display:grid; grid-template-columns:repeat(4, 1fr); gap:16px; margin-bottom:20px; }
.grid-2 { display:grid; grid-template-columns:repeat(2, 1fr); gap:16px; margin-bottom:20px; }
@media (max-width:1200px){ .grid-4{grid-template-columns:repeat(2,1fr);} }
@media (max-width:900px){ .grid-4,.grid-2{grid-template-columns:1fr;} .sidebar{display:none;} }

.card {
  background:var(--bg-card); border:1px solid var(--border); border-radius:12px; padding:16px;
  transition:border-color .2s, transform .2s;
}
.card:hover { border-color:var(--border-hover); transform:translateY(-1px); }
.card-header { display:flex; justify-content:space-between; align-items:center; margin-bottom:12px; }
.card-title { font-size:13px; font-weight:600; color:var(--text-secondary); }
.card-value { font-size:28px; font-weight:700; margin-bottom:4px; }
.card-sub { font-size:12px; color:var(--text-secondary); }
.card-trend { font-size:11px; padding:2px 6px; border-radius:4px; }
.trend-up { background:rgba(82,196,26,0.12); color:var(--success); }
.trend-down { background:rgba(255,77,79,0.12); color:var(--danger); }

.task-columns { display:grid; grid-template-columns:repeat(3, 1fr); gap:16px; }
@media (max-width:900px){ .task-columns{grid-template-columns:1fr;} }
.task-col { background:var(--bg-panel); border:1px solid var(--border); border-radius:12px; display:flex; flex-direction:column; min-height:300px; }
.task-col-header { padding:14px 16px; border-bottom:1px solid var(--border); display:flex; justify-content:space-between; align-items:center; }
.task-col-title { font-size:12px; font-weight:600; text-transform:uppercase; letter-spacing:0.5px; }
.task-col-count { background:var(--bg-card); padding:2px 8px; border-radius:99px; font-size:11px; color:var(--text-secondary); }
.task-list { padding:12px; display:flex; flex-direction:column; gap:10px; flex:1; }
.task-card {
  background:var(--bg-card); border:1px solid var(--border); border-radius:10px; padding:14px; cursor:pointer; transition:.2s;
}
.task-card:hover { border-color:var(--border-hover); }
.task-card-header { display:flex; justify-content:space-between; margin-bottom:8px; }
.task-id { font-size:10px; color:var(--text-secondary); font-family:ui-monospace,monospace; }
.task-status { font-size:10px; padding:2px 8px; border-radius:4px; font-weight:500; }
.status-queued { background:rgba(139,146,168,0.15); color:var(--text-secondary); }
.status-running { background:var(--accent-soft); color:var(--accent); }
.status-windk_pending { background:rgba(168,85,247,0.15); color:var(--purple); }
.status-finished { background:rgba(82,196,26,0.15); color:var(--success); }
.status-failed { background:rgba(255,77,79,0.15); color:var(--danger); }
.task-desc { font-size:13px; margin-bottom:10px; line-height:1.5; }
.task-progress { height:4px; background:var(--border); border-radius:2px; overflow:hidden; margin-bottom:10px; }
.task-progress-bar { height:100%; background:var(--accent); border-radius:2px; transition:width .3s; }
.task-links { display:flex; gap:8px; flex-wrap:wrap; }
.task-link { font-size:11px; color:var(--accent); text-decoration:none; background:var(--accent-soft); padding:3px 8px; border-radius:4px; }

.chat-container { flex:1; display:flex; flex-direction:column; background:var(--bg-card); border:1px solid var(--border); border-radius:12px; overflow:hidden; }
.chat-messages { flex:1; overflow-y:auto; padding:16px; display:flex; flex-direction:column; gap:14px; }
.chat-msg { display:flex; gap:10px; max-width:85%; }
.chat-msg.user { align-self:flex-end; flex-direction:row-reverse; }
.chat-avatar { width:32px; height:32px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:13px; flex-shrink:0; }
.chat-msg.taizi .chat-avatar { background:linear-gradient(135deg,var(--accent),var(--purple)); }
.chat-msg.user .chat-avatar { background:var(--border); color:var(--text-secondary); }
.chat-bubble { padding:12px 14px; border-radius:14px; font-size:14px; line-height:1.6; }
.chat-msg.taizi .chat-bubble { background:var(--bg-panel); border:1px solid var(--border); border-top-left-radius:4px; }
.chat-msg.user .chat-bubble { background:var(--accent); color:var(--bg); border-top-right-radius:4px; font-weight:500; }
.chat-input-wrap {
  border-top:1px solid var(--border); padding:12px 16px; display:flex; gap:10px; background:var(--bg-panel);
}
.chat-input {
  flex:1; background:var(--bg); border:1px solid var(--border); border-radius:10px; padding:10px 14px;
  color:var(--text); font-size:14px; outline:none; resize:none; min-height:40px; max-height:120px;
}
.chat-input:focus { border-color:var(--accent); }
.chat-send {
  width:40px; height:40px; border-radius:50%; background:var(--accent); border:none; color:var(--bg);
  font-size:16px; display:flex; align-items:center; justify-content:center; cursor:pointer; flex-shrink:0;
}
.chat-send:disabled { opacity:.5; cursor:not-allowed; }
.quick-chips { display:flex; gap:8px; padding:8px 16px; overflow-x:auto; border-top:1px solid var(--border); background:var(--bg-panel); }
.quick-chip { flex-shrink:0; padding:6px 12px; background:var(--bg-card); border:1px solid var(--border); border-radius:99px; font-size:12px; color:var(--text-secondary); cursor:pointer; }
.quick-chip:hover { border-color:var(--border-hover); color:var(--text); }

.memory-toolbar { display:flex; gap:10px; margin-bottom:16px; }
.memory-toolbar input { flex:1; padding:10px 14px; background:var(--bg-card); border:1px solid var(--border); border-radius:8px; color:var(--text); font-size:14px; }
.memory-toolbar input:focus { outline:none; border-color:var(--accent); }
.memory-toolbar button { padding:10px 18px; background:var(--accent); border:none; border-radius:8px; color:var(--bg); font-size:13px; font-weight:600; cursor:pointer; }
.memory-list { display:flex; flex-direction:column; gap:10px; }
.memory-item { background:var(--bg-card); border:1px solid var(--border); border-radius:10px; padding:14px; border-left:3px solid var(--purple); }
.memory-content { font-size:13px; line-height:1.6; margin-bottom:8px; }
.memory-meta { font-size:11px; color:var(--text-secondary); display:flex; gap:16px; }

.drawer {
  position:fixed; top:56px; right:0; bottom:0; width:420px; background:var(--bg-panel);
  border-left:1px solid var(--border); z-index:1500; transform:translateX(100%); transition:transform .3s;
  display:flex; flex-direction:column;
}
.app.has-alert .drawer { top:96px; }
.drawer.open { transform:translateX(0); }
.drawer-header { padding:16px 20px; border-bottom:1px solid var(--border); display:flex; justify-content:space-between; align-items:center; }
.drawer-header h3 { font-size:16px; font-weight:600; }
.drawer-close { background:none; border:none; color:var(--text-secondary); font-size:20px; cursor:pointer; }
.drawer-body { flex:1; overflow-y:auto; padding:20px; }
.drawer-overlay {
  position:fixed; inset:0; background:rgba(0,0,0,0.4); z-index:1400; opacity:0; pointer-events:none; transition:opacity .3s;
}
.drawer-overlay.open { opacity:1; pointer-events:auto; }

.topo-canvas { background:var(--bg-card); border:1px solid var(--border); border-radius:12px; height:240px; display:flex; align-items:center; justify-content:center; position:relative; overflow:hidden; }
.topo-line { position:absolute; height:1px; background:var(--border); }
.topo-node { position:absolute; background:var(--bg-panel); border:1px solid var(--border); border-radius:8px; padding:8px 14px; font-size:12px; text-align:center; min-width:80px; }
.topo-node.active { border-color:var(--accent); box-shadow:0 0 16px var(--accent-soft); }
.topo-node.warn { border-color:var(--warning); }

.login-overlay { position:fixed; inset:0; background:var(--bg); z-index:3000; display:flex; align-items:center; justify-content:center; }
.login-box { background:var(--bg-card); border:1px solid var(--border); border-radius:16px; padding:32px; width:320px; text-align:center; }
.login-title { font-size:20px; font-weight:700; margin-bottom:6px; }
.login-sub { font-size:13px; color:var(--text-secondary); margin-bottom:20px; }
.pwd-input { width:100%; padding:12px 14px; background:var(--bg); border:1px solid var(--border); border-radius:10px; color:var(--text); font-size:14px; margin-bottom:12px; }
.pwd-input:focus { outline:none; border-color:var(--accent); }
.pwd-btn { width:100%; padding:12px; background:var(--accent); border:none; border-radius:10px; color:var(--bg); font-size:14px; font-weight:600; cursor:pointer; }
.pwd-err { color:var(--danger); font-size:12px; margin-top:10px; display:none; }
.pwd-err.show { display:block; }

.hidden { display:none !important; }
/* ========== 手机适配紧急修复 ========== */
@media (max-width: 768px) {
  html, body { overflow: auto; height: auto; }

  .app {
    position: relative;
    top: 0;
    min-height: 100vh;
    flex-direction: column;
  }
  .app.has-alert { top: 0; }

  .top-nav {
    position: sticky;
    top: 0;
    height: 48px;
    padding: 0 12px;
    z-index: 1999;
  }
  .top-nav.has-alert { top: 40px; position: fixed; }
  .logo { font-size: 16px; }
  .nav-tabs {
    gap: 4px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .nav-tabs::-webkit-scrollbar { display: none; }
  .nav-tab {
    padding: 6px 10px;
    font-size: 12px;
  }
  .nav-right { gap: 8px; }
  .status-pill { font-size: 11px; padding: 3px 8px; }

  .alert-bar {
    position: sticky;
    top: 0;
    z-index: 2000;
  }

  .sidebar { display: none; }

  .main {
    width: 100%;
    overflow-y: auto;
    min-height: calc(100vh - 48px);
  }

  .page {
    overflow-y: auto;
    padding: 12px;
    min-height: auto;
  }

  .page-header h2 { font-size: 18px; }
  .page-header p { font-size: 12px; }

  .grid-4, .grid-2 { grid-template-columns: 1fr !important; gap: 12px; }
  .card { padding: 14px; }
  .card-value { font-size: 22px; }
  .card-title { font-size: 12px; }

  .task-columns { grid-template-columns: 1fr !important; gap: 12px; }
  .task-col { min-height: 200px; }

  .chat-container { min-height: 320px; height: auto; }
  .chat-messages { padding: 12px; }
  .chat-msg { max-width: 92%; }
  .chat-bubble { padding: 10px 12px; font-size: 13px; }
  .chat-input-wrap { padding: 10px 12px; }
  .quick-chips { padding: 6px 12px; }
  .quick-chip { font-size: 11px; padding: 5px 10px; }

  .memory-toolbar { flex-direction: column; gap: 8px; }
  .memory-toolbar input, .memory-toolbar button { width: 100%; }
  .memory-item { padding: 12px; }

  .drawer {
    width: 100%;
    max-width: 100%;
    top: 48px;
  }
  .app.has-alert .drawer { top: 88px; }
  .drawer-header h3 { font-size: 15px; }

  .topo-canvas { height: 180px; }
  .topo-node { font-size: 11px; padding: 6px 10px; min-width: 60px; }

  .login-box {
    width: 90%;
    max-width: 320px;
    padding: 24px;
  }
  .login-title { font-size: 18px; }
}

.command-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  height: calc(100% - 80px);
}

@media (max-width: 768px) {
  .command-layout {
    grid-template-columns: 1fr !important;
    height: auto !important;
    min-height: calc(100vh - 140px);
  }
  .command-layout .chat-container {
    min-height: 360px;
    height: auto;
    order: 1;
  }
  .command-layout > div:nth-child(2) {
    order: 2;
    flex-direction: row !important;
    flex-wrap: wrap;
  }
  .command-layout > div:nth-child(2) .card {
    flex: 1 1 45%;
    min-width: 140px;
  }
  .command-layout .chat-messages {
    min-height: 180px;
  }
}
