:root {
    --app-header-height: 56px;
    --app-logo-bg: #2b3a4a;
    --app-sidebar-bg: #001529;
    --app-sidebar-text: #b7c3cd;
    --app-sidebar-active: #409EFF;
    --app-bg: #f0f2f5;
    --app-card-bg: #ffffff;
    --app-text: #303133;
    --app-text-sub: #909399;
    --app-border: #e4e7ed;
}

html, body, #app {
    height: 100%;
    margin: 0;
    padding: 0;
    background: var(--app-bg);
    font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
    color: var(--app-text);
}

* { box-sizing: border-box; }

/* ============ 顶栏 ============ */
.app-header {
    height: var(--app-header-height);
    display: flex;
    align-items: center;
    background: var(--app-card-bg);
    border-bottom: 1px solid var(--app-border);
    position: relative;
    z-index: 10;
    flex-shrink: 0;
}
.app-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 210px;
    height: var(--app-header-height);
    background: var(--app-sidebar-bg);
    color: #fff;
    flex-shrink: 0;
    overflow: hidden;
    transition: width .2s;
}
.app-logo.collapsed { width: 64px; }
.app-logo .logo-icon { font-size: 26px; margin-right: 8px; }
.app-logo.collapsed .logo-text { display: none; }
.app-header-left { display: flex; align-items: center; padding: 0 12px; }
.header-tools { margin-left: auto; display: flex; align-items: center; height: 100%; }
.header-tools .tool-item {
    height: var(--app-header-height);
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    color: var(--app-text-sub);
    font-size: 18px;
}
.header-tools .tool-item:hover { color: var(--app-text); background: rgba(0,0,0,.04); }
.header-user { display: inline-flex; align-items: center; cursor: pointer; height: var(--app-header-height); padding: 0 10px; }
.header-user:hover { background: rgba(0,0,0,.04); }
.header-clock { font-size: 13px; color: var(--app-text-sub); margin: 0 8px; white-space: nowrap; }

/* ============ 布局骨架 ============ */
.app-root { height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.app-body { flex: 1 1 0; min-height: 0; display: flex; }
.app-aside {
    height: 100%;
    background: var(--app-sidebar-bg);
    transition: width .2s;
    overflow-y: auto;
    overflow-x: hidden;
}
.app-aside .el-menu { height: 100%; border-right: none; background: transparent; }
.app-aside .el-submenu__title, .app-aside .el-menu-item { color: var(--app-sidebar-text); }
.app-aside .el-menu-item:hover, .app-aside .el-submenu__title:hover { background: rgba(255,255,255,.06); color: #fff; }
.app-aside .el-menu-item.is-active { color: var(--app-sidebar-active); background: rgba(64,158,255,.12); }
.app-aside .el-submenu .el-menu { background: rgba(0,0,0,.3); }
.app-main { flex: 1 1 0; min-width: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; }

/* ============ 远程终端占满主区域 ============ */
.app-main.app-main-term { padding: 0; overflow: hidden; }
.local-shell-page { height: 100%; display: flex; flex-direction: column; }
.shell-term { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }
.term-toolbar {
    height: 38px; flex-shrink: 0;
    display: flex; align-items: center; gap: 10px;
    padding: 0 12px;
    background: #141d29; color: #d7e0e8; font-size: 13px;
}
.term-toolbar .term-status { font-size: 12px; opacity: .9; }
.term-toolbar .term-status.is-ok { color: #67C23A; }
.term-toolbar .term-status.is-err { color: #F56C6C; }
.term-body { flex: 1 1 0; min-height: 0; background: #0d1520; padding: 4px 0 0; }
.term-body .xterm { height: 100%; }

/* ============ 通用卡片 ============ */
.app-card { background: var(--app-card-bg); border: 1px solid var(--app-border); border-radius: 4px; padding: 14px; }
.filter-bar { margin-bottom: 14px; }
.filter-bar .el-form-item { margin-bottom: 8px; }
.table-card { background: var(--app-card-bg); border: 1px solid var(--app-border); border-radius: 4px; padding: 6px 14px 14px; }
.table-toolbar { display: flex; align-items: center; justify-content: space-between; margin: 8px 0; }
.pager-wrap { display: flex; justify-content: flex-end; margin-top: 12px; }
.fixed-right { text-align: right; }

/* ============ 登录页 ============ */
.login-page {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1f3b57 0%, #2b5876 100%);
}
.login-card { width: 400px; background: var(--app-card-bg); border-radius: 8px; padding: 36px 34px 26px; box-shadow: 0 8px 32px rgba(0,0,0,.24); }
.login-title { text-align: center; font-size: 22px; font-weight: 600; margin-bottom: 4px; }
.login-sub { text-align: center; color: var(--app-text-sub); margin-bottom: 22px; }
.qr-box { display: flex; justify-content: center; margin: 8px 0; }
.bind-manual { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; margin-top: 6px; font-size: 13px; color: var(--app-text-sub); }
.bind-manual .bind-secret { user-select: all; color: var(--app-text); background: rgba(64,158,255,.1); padding: 2px 6px; border-radius: 3px; font-size: 13px; }

/* ============ 锁屏 ============ */
.lock-mask {
    position: fixed; left: 0; top: 0; right: 0; bottom: 0; z-index: 3000;
    background: rgba(20, 30, 45, .96); display: flex; flex-direction: column;
    align-items: center; justify-content: center; color: #dfe6ed;
}
.lock-clock { font-size: 72px; font-weight: 300; letter-spacing: 2px; }
.lock-date { margin: 8px 0 30px; color: #9fb0c0; font-size: 16px; }

/* ============ 状态标签 ============ */
.tag-running { color: #67C23A; }
.text-muted { color: var(--app-text-sub); }
.welcome-card { margin-bottom: 14px; }
.welcome-greeting { font-size: 18px; font-weight: 600; }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.quick-item { cursor: pointer; padding: 18px 16px; border: 1px solid var(--app-border); border-radius: 6px; display: flex; align-items: center; background: var(--app-card-bg); transition: all .15s; }
.quick-item:hover { border-color: var(--app-sidebar-active); transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.quick-item .qi-icon { font-size: 26px; color: var(--app-sidebar-active); margin-right: 12px; }
.quick-item .qi-name { font-weight: 600; }
.build-log-pre { white-space: pre-wrap; word-break: break-all; background: #0e1520; color: #9fd0ff; padding: 12px; border-radius: 4px; font-size: 12px; line-height: 1.6; max-height: 60vh; overflow: auto; font-family: Menlo, Consolas, monospace; }
.danger-link { color: #F56C6C !important; }
.runtime-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.runtime-card {
    background: var(--app-card-bg); border: 1px solid var(--app-border); border-radius: 6px;
    padding: 18px; display: flex; flex-direction: column;
}
.rt-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.rt-icon {
    width: 40px; height: 40px; border-radius: 8px; color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 20px; font-weight: 600;
}
.rt-name { font-size: 18px; font-weight: 600; text-transform: lowercase; }
.rt-status { font-size: 15px; margin-bottom: 6px; color: #E6A23C; }
.rt-status.is-installed { color: #67C23A; font-weight: 600; }
.rt-version { font-family: Menlo, Consolas, monospace; font-size: 13px; color: var(--app-text-sub); word-break: break-all; }
.rt-message { font-size: 12px; color: #F56C6C; margin-top: 6px; word-break: break-all; }
.rt-foot { margin-top: auto; padding-top: 14px; }

/* ============ 深色主题 ============ */
body.dark {
    --app-bg: #141a21;
    --app-card-bg: #1c2530;
    --app-text: #dfe6ed;
    --app-text-sub: #8b98a5;
    --app-border: #2a3644;
}
body.dark .app-header { background: #1c2530; }
body.dark .el-table { background: transparent; color: var(--app-text); }
body.dark .el-table th, body.dark .el-table tr { background: transparent; }
body.dark .el-table--enable-row-hover .el-table__body tr:hover > td { background: #26313d; }
body.dark .el-table td, body.dark .el-table th.is-leaf { border-bottom: 1px solid var(--app-border); }
body.dark .el-dialog, body.dark .el-drawer, body.dark .el-message-box, body.dark .el-popper {
    background: #1c2530; color: var(--app-text);
}
body.dark .el-input__inner, body.dark .el-textarea__inner, body.dark .el-select .el-input.is-focus .el-input__inner {
    background-color: #141a21; border-color: #2a3644; color: var(--app-text);
}
body.dark .el-pagination.is-background .el-pager li { background: #141a21; color: var(--app-text); }
body.dark .el-pagination.is-background .el-pager li.active { background: #409EFF; color: #fff; }
body.dark .login-card { background: #1c2530; }
body.dark .el-form-item__label, body.dark .el-dialog__title { color: var(--app-text); }
body.dark .el-table__empty-block { background: transparent; }
body.dark .quick-item { border-color: var(--app-border); }
.db-body { display: flex; gap: 14px; align-items: flex-start; }
.db-tree-card { width: 280px; flex-shrink: 0; }
.db-tree-toolbar { display: flex; gap: 8px; margin-bottom: 8px; }
.db-tree-card .el-tree { overflow: auto; max-height: calc(100vh - 260px); }
.db-main { flex: 1; min-width: 0; }
.db-tabs-head { margin-bottom: 10px; }
.db-data-toolbar { display: flex; align-items: center; margin-bottom: 8px; }
.cell-edit { cursor: pointer; display: inline-block; width: 100%; }
.cell-edit:hover { background: rgba(64, 158, 255, .14); }
.el-drawer__body { display: flex; flex-direction: column; }
.el-drawer__body > div { flex: 1 1 auto; min-height: 0; }
.rt-service { font-size: 14px; margin-top: 2px; }
.rt-service.is-running { color: #67C23A; }
.rt-service.is-stopped { color: #E6A23C; }

/* ============ 首页服务器监控 ============ */
.monitor-card { margin-bottom: 14px; }
.monitor-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.monitor-head-text { min-width: 0; }
.monitor-title { font-size: 16px; font-weight: 600; }
.monitor-meta { margin-top: 6px; font-size: 12px; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.monitor-head-tools { flex-shrink: 0; }
.monitor-alert { margin-bottom: 12px; }
.monitor-alert-item { font-size: 12px; line-height: 1.6; word-break: break-all; }
.monitor-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.monitor-cell {
    min-width: 0; padding: 10px 12px 6px;
    border: 1px solid var(--app-border); border-radius: 6px; background: var(--app-card-bg);
}
.cell-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 14px; font-weight: 600; }
.cell-extra { font-size: 12px; font-weight: 400; color: var(--app-text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart-wrap { position: relative; }
.chart-box { width: 100%; height: 220px; }
.cell-empty {
    position: absolute; top: 0; right: 0; bottom: 0; left: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; color: var(--app-text-sub); background: var(--app-card-bg);
}
@media (max-width: 1400px) {
    .monitor-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
    .monitor-head { flex-direction: column; }
    .monitor-grid { grid-template-columns: minmax(0, 1fr); }
}
