:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-panel: #fff;
  --bg-terminal: #1e1e1e;
  --bg-toolbar: #2d2d2d;
  --bg-sidebar: #252525;
  --bg-input: #fff;
  --bg-hover: #3d3d3d;
  --text-primary: #333;
  --text-secondary: #666;
  --text-light: #fff;
  --text-muted: #999;
  --border-color: #e0e0e0;
  --border-dark: #3d3d3d;
  --accent: #4a90d9;
  --accent-hover: #357abd;
  --success: #28a745;
  --danger: #dc3545;
  --warning: #ffc107;
  --info: #17a2b8;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; width: 100%; overflow: hidden; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg-primary); }

/* 启动画面 */
.splash-screen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(135deg, var(--bg-primary), var(--bg-secondary));
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  transition: opacity 0.5s;
}
.splash-content { text-align: center; color: var(--text-light); }
.splash-logo { font-size: 64px; margin-bottom: 20px; color: var(--accent); }
.splash-content h1 { font-size: 28px; margin-bottom: 20px; }
.splash-loader {
  width: 40px; height: 40px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 15px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 锁定屏幕 */
.lock-screen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9998;
}
.lock-content { text-align: center; color: var(--text-light); }
.lock-icon { font-size: 64px; margin-bottom: 20px; color: var(--accent); }
.lock-content h2 { margin-bottom: 20px; }
.lock-content input {
  padding: 12px 20px;
  border: 2px solid var(--border-dark);
  border-radius: var(--radius);
  background: #333;
  color: #fff;
  font-size: 16px;
  margin-bottom: 15px;
  width: 250px;
}

/* 连接面板 */
.connect-panel {
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  background: linear-gradient(135deg, var(--bg-primary), var(--bg-secondary));
}
.connect-container {
  background: var(--bg-panel);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 30px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}
h2 { color: var(--text-primary); margin-bottom: 25px; text-align: center; font-size: 22px; }
h2 i { margin-right: 8px; color: var(--accent); }

.form-row { display: flex; gap: 12px; }
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.form-group { margin-bottom: 16px; }
label { display: block; margin-bottom: 6px; color: var(--text-secondary); font-size: 13px; font-weight: 500; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 14px;
  transition: border-color 0.3s;
  outline: none;
  background: var(--bg-input);
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; font-family: monospace; font-size: 13px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
  gap: 6px;
}
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-hover)); color: #fff; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(74,144,217,0.4); }
.btn-secondary { background: #6c757d; color: #fff; }
.btn-info { background: var(--info); color: #fff; }
.btn-small { padding: 6px 12px; font-size: 12px; }
.btn-text { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 12px; }
.btn-group { display: flex; gap: 10px; margin-top: 20px; }
.btn-group .btn { flex: 1; }

/* 已保存账号 */
.saved-accounts { margin-bottom: 20px; padding: 12px; background: #f8f9fa; border-radius: var(--radius); }
.saved-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.saved-header label { margin-bottom: 0; font-weight: 600; }
.account-list { display: flex; flex-wrap: wrap; gap: 8px; }
.account-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; background: #fff; border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); cursor: pointer; font-size: 13px;
}
.account-item:hover { border-color: var(--accent); background: #f0f7ff; }
.account-item .account-delete { background: none; border: none; color: var(--danger); cursor: pointer; }

.status { margin-top: 15px; padding: 10px; border-radius: var(--radius-sm); font-size: 13px; text-align: center; display: none; }
.status.error { display: block; background: #fde8e8; color: var(--danger); }
.status.connecting { display: block; background: #fff3cd; color: #856404; }
.status.success { display: block; background: #d4edda; color: #155724; }

/* 主界面 */
.main-panel { height: 100%; display: flex; flex-direction: column; background: var(--bg-terminal); }

/* 工具栏 */
.toolbar { display: flex; justify-content: space-between; align-items: center; padding: 4px 8px; background: var(--bg-toolbar); border-bottom: 1px solid var(--border-dark); min-height: 36px; }
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 2px; }
.toolbar-btn { background: none; border: none; color: #ccc; cursor: pointer; padding: 5px 8px; border-radius: var(--radius-sm); font-size: 13px; transition: all 0.2s; }
.toolbar-btn:hover { background: var(--bg-hover); color: #fff; }
.toolbar-btn.active { background: var(--accent); color: #fff; }

/* 标签栏 */
.tab-bar { display: flex; gap: 2px; overflow-x: auto; max-width: calc(100vw - 500px); }
.tab {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px; background: #3d3d3d;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer; font-size: 12px; color: #ccc;
  white-space: nowrap; max-width: 150px;
}
.tab:hover { background: #4d4d4d; }
.tab.active { background: var(--bg-terminal); color: #fff; }
.tab .tab-close { background: none; border: none; color: #999; cursor: pointer; font-size: 12px; padding: 0 2px; }
.tab .tab-close:hover { color: var(--danger); }
.tab .tab-status { width: 6px; height: 6px; border-radius: 50%; background: var(--success); }
.tab .tab-status.disconnected { background: var(--danger); }

/* 搜索栏 */
.search-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; background: #333; border-bottom: 1px solid var(--border-dark);
}
.search-bar input { flex: 1; padding: 6px 10px; background: #222; border: 1px solid #555; color: #fff; border-radius: var(--radius-sm); font-size: 13px; }
.search-bar button { background: none; border: none; color: #ccc; cursor: pointer; padding: 4px 8px; }
.search-bar button:hover { color: #fff; }
.search-count { color: #999; font-size: 12px; min-width: 60px; text-align: center; }

/* 内容区域 */
.content-area { flex: 1; display: flex; overflow: hidden; }
.terminal-wrapper { flex: 1; display: flex; overflow: hidden; }
.terminal-container { flex: 1; display: flex; flex-wrap: wrap; padding: 2px; }
.terminal-instance { flex: 1; min-width: 300px; min-height: 200px; }
.terminal-instance .xterm { height: 100%; width: 100%; }

/* 分屏分隔线 */
.terminal-instance.split-h { border-bottom: 2px solid var(--border-dark); }
.terminal-instance.split-v { border-right: 2px solid var(--border-dark); }

/* 右侧面板 */
.right-panel { width: 350px; background: var(--bg-sidebar); border-left: 1px solid var(--border-dark); display: flex; flex-direction: column; overflow: hidden; }
.panel-header { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border-dark); font-size: 13px; color: #ccc; }
.panel-header button { background: none; border: none; color: #ccc; cursor: pointer; }

/* 系统监控面板 */
.monitor-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.monitor-content { flex: 1; overflow-y: auto; padding: 12px; }
.monitor-info { margin-bottom: 15px; }
.info-item { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border-dark); font-size: 12px; }
.info-item label { color: #999; }
.info-item span { color: #ccc; }
.monitor-charts { margin-bottom: 15px; }
.chart-item { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.chart-label { width: 40px; color: #999; font-size: 12px; }
.chart-bar { flex: 1; height: 16px; background: #1e1e1e; border-radius: 8px; overflow: hidden; }
.chart-fill { height: 100%; background: linear-gradient(90deg, var(--success), var(--accent)); border-radius: 8px; transition: width 0.5s; }
.chart-fill.warning { background: linear-gradient(90deg, var(--warning), #ff9800); }
.chart-fill.danger { background: linear-gradient(90deg, var(--danger), #ff5722); }
.chart-value { width: 50px; text-align: right; color: #ccc; font-size: 12px; }
.monitor-extra { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.monitor-section { margin-bottom: 12px; }
.monitor-section h4 { color: #999; font-size: 11px; text-transform: uppercase; margin-bottom: 8px; padding-bottom: 4px; border-bottom: 1px solid var(--border-dark); }
.extra-item { background: #1e1e1e; padding: 8px 10px; border-radius: var(--radius-sm); }
.extra-item.full { grid-column: span 2; }
.extra-item label { display: block; color: #999; font-size: 11px; margin-bottom: 4px; }
.extra-item span { color: #ccc; font-size: 13px; }
.net-detail, .disk-io-detail { margin-top: 8px; }
.net-iface, .disk-io-item { display: flex; justify-content: space-between; padding: 4px 8px; background: #1e1e1e; border-radius: var(--radius-sm); margin-bottom: 4px; font-size: 11px; }
.net-iface span:first-child, .disk-io-item span:first-child { color: #999; }
.net-iface span:last-child, .disk-io-item span:last-child { color: #ccc; font-family: monospace; }

/* 快捷命令栏 */
.quick-command-bar { background: #2a2a2a; border-top: 1px solid var(--border-dark); max-height: 120px; overflow: hidden; display: flex; flex-direction: column; }
.qc-header { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; font-size: 12px; color: #ccc; border-bottom: 1px solid var(--border-dark); }
.qc-header button { background: none; border: none; color: #ccc; cursor: pointer; font-size: 11px; padding: 2px 6px; }
.qc-header button:hover { color: #fff; }
.qc-list { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px; overflow-y: auto; }
.qc-item { display: flex; align-items: center; gap: 6px; padding: 4px 10px; background: #3d3d3d; border-radius: var(--radius-sm); cursor: pointer; font-size: 12px; color: #ccc; }
.qc-item:hover { background: var(--accent); color: #fff; }
.qc-item .qc-delete { background: none; border: none; color: #999; cursor: pointer; font-size: 10px; }
.qc-item .qc-delete:hover { color: var(--danger); }

/* 命令历史面板 */
.command-history-panel { background: #2a2a2a; border-top: 1px solid var(--border-dark); max-height: 180px; overflow: hidden; display: flex; flex-direction: column; }
.ch-header { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; font-size: 12px; color: #ccc; border-bottom: 1px solid var(--border-dark); }
.ch-header input { background: #1e1e1e; border: 1px solid var(--border-dark); color: #fff; padding: 4px 8px; border-radius: var(--radius-sm); font-size: 11px; width: 120px; }
.ch-header button { background: none; border: none; color: #ccc; cursor: pointer; font-size: 11px; padding: 2px 6px; }
.ch-header button:hover { color: #fff; }
.ch-list { flex: 1; overflow-y: auto; padding: 5px 10px; }
.ch-item { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: var(--radius-sm); cursor: pointer; font-size: 12px; color: #ccc; font-family: monospace; }
.ch-item:hover { background: var(--bg-hover); }
.ch-item .ch-time { color: #666; font-size: 10px; min-width: 45px; }
.ch-item .ch-cmd { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-item .ch-actions { display: none; gap: 4px; }
.ch-item:hover .ch-actions { display: flex; }
.ch-item .ch-action-btn { background: none; border: none; color: #999; cursor: pointer; padding: 2px 4px; font-size: 11px; }
.ch-item .ch-action-btn:hover { color: #fff; }

/* 右键菜单 */
.context-menu {
  position: fixed;
  background: #333;
  border: 1px solid #555;
  border-radius: var(--radius-sm);
  padding: 4px 0;
  min-width: 160px;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.context-item { padding: 8px 16px; color: #ccc; cursor: pointer; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.context-item:hover { background: var(--accent); color: #fff; }
.context-divider { height: 1px; background: #555; margin: 4px 0; }

/* 弹窗 */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: flex; justify-content: center; align-items: center; z-index: 1000; }
.modal-content { background: #fff; border-radius: 12px; width: 90%; max-width: 500px; box-shadow: var(--shadow); }
.modal-sm { max-width: 360px; }
.modal-settings { max-width: 500px; max-height: 80vh; overflow-y: auto; }
.modal-editor { max-width: 800px; width: 95%; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--border-color); }
.modal-header h3 { font-size: 16px; color: var(--text-primary); }
.modal-header h3 i { margin-right: 8px; color: var(--accent); }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: #666; }
.modal-close:hover { color: #333; }
.modal-body { padding: 20px; }

.link-box { display: flex; gap: 10px; margin-bottom: 12px; }
.link-box input { flex: 1; font-size: 12px; font-family: monospace; }
.link-warning { color: var(--danger); font-size: 12px; }
.link-warning i { margin-right: 4px; }

/* 设置 */
.settings-section { margin-bottom: 20px; }
.settings-section h4 { font-size: 14px; color: var(--text-primary); margin-bottom: 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border-color); }
.settings-group { margin-bottom: 12px; }
.settings-group label { display: block; margin-bottom: 6px; font-weight: 500; }
.settings-range { display: flex; align-items: center; gap: 10px; }
.settings-range input[type="range"] { flex: 1; padding: 0; border: none; }
.settings-range span { min-width: 40px; text-align: right; font-size: 13px; color: var(--text-secondary); }

/* 快捷键列表 */
.shortcut-list { max-height: 200px; overflow-y: auto; }
.shortcut-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid #eee; font-size: 13px; }
.shortcut-item .shortcut-key { background: #f0f0f0; padding: 2px 8px; border-radius: 4px; font-family: monospace; font-size: 12px; }

/* 滚动条 */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #555; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #777; }

/* 响应式 */
@media (max-width: 768px) {
  .right-panel { position: fixed; top: 36px; right: 0; width: 100%; height: calc(100% - 36px); z-index: 50; }
  .tab { max-width: 100px; }
  .toolbar-right .toolbar-btn span { display: none; }
}
