/* ============================================================
   DB Manager —— 深色导航 + 平面卡片风（参考企业级安全平台视觉）
   主色 #396fff / 导航 #1d2939-#131e2c / 页面底 #f2f4f9
   ============================================================ */
:root {
    --blue: #396fff;
    --blue-dark: #295fcc;
    --blue-hover: #4d84ff;
    --blue-bg: #e6eeff;
    --blue-bg-soft: rgba(57, 111, 255, .08);
    --nav-bg-1: #1d2939;
    --nav-bg-2: #131e2c;
    --page-bg: #f2f4f9;
    --card-bg: #ffffff;
    --border: #e4e7ed;
    --border-light: #ebeef5;
    --text-1: #303133;
    --text-2: #606266;
    --text-3: #909399;
    --green: #390;
    --green-bg: #f0f9eb;
    --red: #f33;
    --red-bg: #ffebeb;
    --orange: #ff8000;
    --orange-bg: #fff2e6;
    --nav-text: rgba(230, 238, 255, .65);
}
* { box-sizing: border-box; margin: 0; padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #c9cdd8; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #a8b0c2; }
::-webkit-scrollbar-track { background: transparent; }
.muted { color: var(--text-3); font-size: 12px; font-weight: 400; }
.spacer { flex: 1; }
.hint { font-size: 12px; color: var(--text-3); }

/* ================= 登录页 ================= */
.login-body {
    min-height: 100vh; display: flex; justify-content: center; align-items: center;
    background: radial-gradient(1100px 500px at 15% -10%, rgba(57, 111, 255, .28), transparent 60%),
                radial-gradient(900px 480px at 90% 110%, rgba(46, 107, 230, .22), transparent 60%),
                linear-gradient(160deg, #131e2c 0%, #0e1622 60%, #101a28 100%);
    position: relative; overflow: hidden;
}
.login-body::before {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background-image:
        linear-gradient(rgba(57, 111, 255, .05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(57, 111, 255, .05) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: radial-gradient(720px 480px at 50% 42%, #000 30%, transparent 78%);
    -webkit-mask-image: radial-gradient(720px 480px at 50% 42%, #000 30%, transparent 78%);
}
.login-container {
    width: 100%; max-width: 400px; padding: 42px 40px 34px; margin: 20px; position: relative;
    background: rgba(255, 255, 255, .98); border-radius: 10px;
    box-shadow: 0 24px 64px rgba(4, 12, 24, .55), 0 0 0 1px rgba(77, 132, 255, .18);
}
.login-logo { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 8px; }
.login-logo svg { width: 46px; height: 46px; filter: drop-shadow(0 4px 10px rgba(57, 111, 255, .45)); }
.login-logo .logo-name { font-size: 22px; font-weight: 700; color: var(--text-1); letter-spacing: .2px; }
.login-sub { text-align: center; font-size: 12px; color: var(--text-3); margin-bottom: 28px; letter-spacing: 3px; }
.captcha-box { display: flex; gap: 10px; }
.captcha-box img { border-radius: 4px; cursor: pointer; border: 1px solid var(--border); height: 40px; flex-shrink: 0; }
.captcha-box input { flex: 1; }
.error-msg { color: var(--red); font-size: 12px; text-align: center; margin-top: 14px; display: none; }
.login-tip { text-align: center; font-size: 12px; color: var(--text-3); margin-top: 16px;
    padding-top: 14px; border-top: 1px solid var(--border-light); }

/* ================= 框架布局 ================= */
.dashboard-body { background: var(--page-bg); height: 100vh; display: flex; overflow: hidden; color: var(--text-1); }
.sidebar {
    width: 224px; flex-shrink: 0; display: flex; flex-direction: column;
    background: linear-gradient(180deg, var(--nav-bg-1) 0%, var(--nav-bg-2) 100%);
    box-shadow: 4px 0 16px rgba(9, 18, 32, .25); position: relative; z-index: 10;
}
.logo-area { padding: 22px 18px 20px; display: flex; align-items: center; gap: 10px;
    border-bottom: 1px solid rgba(230, 238, 255, .08); }
.logo-area svg { width: 30px; height: 30px; flex-shrink: 0; }
.logo-text .logo-name { font-size: 17px; font-weight: 700; color: #fff; letter-spacing: .3px; line-height: 1.2; }
.logo-text .logo-desc { font-size: 11px; color: var(--nav-text); letter-spacing: .5px; }
.nav-menu { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-item {
    padding: 11px 14px; margin-bottom: 4px; border-radius: 6px; cursor: pointer; position: relative;
    display: flex; align-items: center; gap: 11px; font-size: 14px; font-weight: 500;
    color: var(--nav-text); transition: all .18s ease;
}
.nav-item:hover { background: rgba(230, 238, 255, .07); color: #fff; }
.nav-item.active { background: var(--blue); color: #fff; box-shadow: 0 4px 12px rgba(57, 111, 255, .4); }
.nav-item svg { width: 17px; height: 17px; fill: currentColor; flex-shrink: 0; opacity: .9; }
.sidebar-footer { padding: 14px 16px 16px; border-top: 1px solid rgba(230, 238, 255, .08); }
.whoami { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 13px; font-weight: 600; color: #fff; }
.role-badge { font-size: 11px; padding: 1px 8px; border-radius: 3px;
    background: rgba(57, 111, 255, .9); color: #fff; font-weight: 500; }
.sidebar-footer .btn.ghost { background: transparent; border-color: rgba(230, 238, 255, .25); color: var(--nav-text); }
.sidebar-footer .btn.ghost:hover { border-color: #fff; color: #fff; background: rgba(230, 238, 255, .08); }

.main-content { flex: 1; padding: 22px 26px; overflow-y: auto; }
.panel {
    background: var(--card-bg); border-radius: 8px; padding: 22px 26px;
    box-shadow: 0 1px 4px rgba(9, 18, 32, .06); border: 1px solid var(--border-light); display: none;
    animation: fadeIn .25s ease;
}
.panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
h2 { font-size: 18px; margin-bottom: 16px; font-weight: 600; color: var(--text-1); }
h3 { font-size: 15px; margin-bottom: 12px; font-weight: 600; color: var(--text-1); }
.section-title { margin: 24px 0 12px; font-size: 14px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px;
    padding-bottom: 14px; border-bottom: 1px solid var(--border-light); }
.panel-head h2 { margin-bottom: 0; }

/* ================= 表单 ================= */
.form-group { margin-bottom: 16px; }
.form-group label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); margin-bottom: 7px; font-weight: 500; flex-wrap: wrap; }
.form-row-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
input, textarea, select {
    padding: 9px 12px; border-radius: 4px; border: 1px solid #dcdfe6;
    background: #fff; font-size: 13px; color: var(--text-1); outline: none; transition: all .18s ease;
}
input::placeholder, textarea::placeholder { color: #a8abb2; }
input:hover, textarea:hover, select:hover { border-color: #c0c4cc; }
input:focus, textarea:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(57, 111, 255, .12); }
input[type="checkbox"] { width: auto; cursor: pointer; accent-color: var(--blue); }
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.code-input { width: 100%; min-height: 150px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px; line-height: 1.65; margin-bottom: 14px; background: #f7f8fb; }
.inline-input { width: auto; padding: 7px 10px; }
.inline-input.narrow { max-width: 120px; }
#browse_db, #sql_db, #exp_db, #imp_db, #bk_db { min-width: 220px; }

/* ================= 按钮 ================= */
button, .btn {
    padding: 9px 18px; border: 1px solid transparent; border-radius: 4px; background: var(--blue);
    color: #fff; font-size: 13px; font-weight: 500; cursor: pointer; transition: all .15s ease;
}
button:hover, .btn:hover { background: var(--blue-hover); }
button:active, .btn:active { background: var(--blue-dark); }
button:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: #fff; border-color: #dcdfe6; color: var(--text-2); }
.btn.ghost:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-bg-soft); }
.btn.ghost.warn { background: #fff; border-color: #f8dcb6; color: var(--orange); }
.btn.ghost.warn:hover { border-color: var(--orange); background: var(--orange-bg); }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #ff5c5c; }
.btn.ghost.danger { background: #fff; border-color: #fbcccc; color: var(--red); }
.btn.ghost.danger:hover { border-color: var(--red); background: var(--red-bg); }
.btn.warn { background: var(--orange); }
.btn.warn:hover { background: #ff9933; }
.btn.small { padding: 4px 10px; font-size: 12px; border-radius: 3px; width: auto; margin: 0 6px 6px 0; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.toolbar.wrap { flex-wrap: wrap; }
.toolbar .btn { width: auto; margin: 0; }

/* ================= 卡片 ================= */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.db-card {
    background: #fff; border: 1px solid var(--border-light); border-radius: 8px; padding: 16px 18px;
    transition: all .2s ease; display: flex; flex-direction: column; gap: 9px; position: relative;
}
.db-card::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px;
    border-radius: 0 3px 3px 0; background: var(--blue); opacity: 0; transition: opacity .2s; }
.db-card:hover { border-color: rgba(57, 111, 255, .45); box-shadow: 0 8px 22px rgba(57, 111, 255, .12); }
.db-card:hover::before { opacity: 1; }
.db-card-name { font-size: 15px; font-weight: 600; color: var(--blue); word-break: break-all; }
.db-card-meta { display: flex; gap: 12px; font-size: 12px; color: var(--text-3); flex-wrap: wrap; }
.db-card-users { display: flex; flex-wrap: wrap; gap: 6px; }
.db-card-actions { display: flex; flex-wrap: wrap; margin-top: 2px; }
.io-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card { background: #fff; border: 1px solid var(--border-light); border-radius: 8px; padding: 18px 20px; margin-bottom: 16px; }
.badge { font-size: 11px; padding: 2px 9px; border-radius: 3px;
    background: var(--blue-bg); color: var(--blue); font-weight: 500; }
.badge.soft { background: var(--green-bg); color: var(--green); }

/* ================= 表格 ================= */
.table-container { overflow-x: auto; margin-bottom: 16px; border-radius: 6px; border: 1px solid var(--border-light); }
table { width: 100%; border-collapse: collapse; background: #fff; text-align: left; }
th, td { padding: 10px 13px; border-bottom: 1px solid var(--border-light); font-size: 13px;
    white-space: nowrap; max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
th { background: #f7f8fb; font-weight: 600; color: var(--text-2); position: sticky; top: 0;
    border-bottom: 1px solid var(--border); }
th.pk-col { color: var(--orange); }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f5f8ff; }
.null-mark { color: #c0c4cc; font-style: italic; font-size: 11px; }
td input[type="checkbox"] { cursor: pointer; }
.row-sel { cursor: pointer; accent-color: var(--blue); vertical-align: middle; }

/* ================= Tab / 芯片 / 分页 ================= */
.subtabs { display: flex; gap: 26px; margin-bottom: 16px; border-bottom: 1px solid var(--border-light); }
.subtab { padding: 9px 2px; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--text-2);
    transition: all .18s; position: relative; margin-bottom: -1px; border-bottom: 2px solid transparent; }
.subtab:hover { color: var(--blue); }
.subtab.active { color: var(--blue); border-bottom-color: var(--blue); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
    background: var(--blue-bg-soft); color: var(--blue); width: auto; margin: 0;
    padding: 7px 14px; border-radius: 4px; font-size: 13px; display: flex; align-items: center; gap: 6px;
    border: 1px solid transparent;
}
.chip:hover { background: var(--blue-bg); border-color: rgba(57, 111, 255, .4); }
.chip-meta { font-size: 11px; opacity: .72; font-weight: 400; }
.pagination { display: flex; align-items: center; gap: 12px; justify-content: center; padding: 10px 0 2px; }
.pagination .muted { font-size: 12px; }

/* ================= SQL 结果 / 代码 ================= */
.sql-result { margin-bottom: 16px; }
.sql-result-title { font-size: 12px; font-weight: 600; color: var(--text-3); margin-bottom: 8px;
    text-transform: uppercase; letter-spacing: .5px; }
.sql-ok { background: var(--green-bg); color: var(--green); padding: 10px 14px; border-radius: 4px; font-size: 13px;
    border: 1px solid #e1f3d8; }
.sql-error { background: var(--red-bg); color: var(--red); padding: 10px 14px; border-radius: 4px; font-size: 13px;
    border: 1px solid #fbcccc; white-space: pre-wrap; word-break: break-all; }
.code-block {
    background: var(--nav-bg-2); color: #9fd8b4; padding: 18px 20px; border-radius: 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
    line-height: 1.7; overflow-x: auto; white-space: pre-wrap; word-break: break-word;
}
.empty-hint { text-align: center; color: var(--text-3); font-size: 13px; padding: 36px 0; }

/* ================= 弹窗 ================= */
#modalMask {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(9, 18, 32, .5); z-index: 9999; justify-content: center; align-items: center;
}
.modal {
    background: #fff; padding: 22px 26px; border-radius: 8px; width: 90%;
    max-width: 540px; max-height: 85vh; overflow-y: auto;
    box-shadow: 0 20px 56px rgba(9, 18, 32, .3);
    animation: fadeIn .2s ease;
}
.modal h3 { margin-bottom: 18px; font-size: 16px; word-break: break-all;
    padding-bottom: 12px; border-bottom: 1px solid var(--border-light); }
.modal-actions { margin-top: 20px; display: flex; justify-content: flex-end; gap: 10px; }
.modal-actions button, .modal-actions .btn { flex: 0 0 auto; width: auto; min-width: 88px; }
.field-group input, .field-group textarea { width: 100%; }
.null-toggle { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; font-size: 11px;
    color: var(--text-3); cursor: pointer; }

/* ================= Toast ================= */
#toastBox { position: fixed; top: 18px; right: 18px; z-index: 10000; display: flex; flex-direction: column; gap: 10px; }
.toast {
    background: var(--nav-bg-1); color: #fff; padding: 12px 18px; border-radius: 6px;
    font-size: 13px; max-width: 400px; box-shadow: 0 10px 30px rgba(9, 18, 32, .35);
    border-left: 3px solid var(--blue);
    opacity: 0; transform: translateX(30px); transition: all .3s ease; word-break: break-all;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast.err { border-left-color: var(--red); background: #2b1518; }
.toast.ok { border-left-color: var(--green); }

/* ================= 终端 ================= */
.terminal {
    background: #0f1826; border: 1px solid #22344d; border-radius: 8px; min-height: 380px; max-height: 62vh;
    overflow-y: auto; padding: 14px 16px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px; line-height: 1.65; cursor: text;
}
.terminal::-webkit-scrollbar-thumb { background: #2c405c; }
.term-line { display: flex; align-items: baseline; gap: 8px; }
.term-prompt { color: #6ea2ff; font-weight: 600; white-space: nowrap; }
.term-input {
    flex: 1; background: transparent; border: none !important; outline: none;
    color: #e6eeff; font-family: inherit; font-size: 13px; padding: 0;
    caret-color: #6ea2ff; box-shadow: none !important; min-width: 40px;
}
.term-cmd { color: #e6eeff; white-space: pre-wrap; word-break: break-all; }
.term-sys { color: rgba(230, 238, 255, .42); }
.term-ascii { color: #9fd8b4; overflow-x: auto; margin: 4px 0; }
.term-ok { color: #67c98a; }
.term-err { color: #ff7a76; white-space: pre-wrap; word-break: break-all; }
.badge.badge-err { background: var(--red-bg); color: var(--red); }

/* ================= 服务器监控 ================= */
.mon-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 4px; }
.mon-card { background: #fff; border: 1px solid var(--border-light); border-radius: 8px; padding: 18px; text-align: center; }
.mon-ring {
    width: 112px; height: 112px; border-radius: 50%; margin: 0 auto 12px;
    display: flex; align-items: center; justify-content: center; position: relative;
    transition: background .5s ease;
}
.mon-ring::before { content: ""; position: absolute; width: 84px; height: 84px; background: #fff; border-radius: 50%; }
.mon-ring span { position: relative; font-weight: 700; font-size: 18px; }
.mon-title { font-size: 13px; color: var(--text-2); font-weight: 600; }
.mon-sub { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.mon-stat { font-size: 24px; font-weight: 700; color: var(--blue); padding: 34px 0; }
.mon-stat.net { display: flex; flex-direction: column; gap: 8px; font-size: 15px; padding: 20px 0; }
.mon-stat.net .up { color: var(--green); }
.mon-stat.net .down { color: var(--blue); }
.mon-disks { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; }
.disk-item { background: #fafbfd; border: 1px solid var(--border-light); border-radius: 8px; padding: 12px 14px; }
.disk-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 12px; margin-bottom: 8px; }
.disk-head span:first-child { font-weight: 600; color: var(--text-1); font-size: 13px; }
.disk-bar { height: 8px; background: #e9eef7; border-radius: 4px; overflow: hidden; }
.disk-bar i { display: block; height: 100%; border-radius: 4px; transition: width .5s ease; }
.exec-out { white-space: pre-wrap; word-break: break-all; margin: 4px 0; color: #d9e4f5; }

/* 多来源行（创建数据库 · 访问来源） */
.rule-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.rule-row .rule-input { flex: 1; }
.rule-row .rule-del { margin: 0; padding: 8px 12px; flex-shrink: 0; line-height: 1; }

/* ================= 二级密钥果冻弹窗 ================= */
#secMask {
    position: fixed; inset: 0; background: rgba(9, 18, 32, .45);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    z-index: 10001; display: none; justify-content: center; align-items: center;
}
#secMask.show { display: flex; animation: secFade .25s ease; }
@keyframes secFade { from { opacity: 0; } to { opacity: 1; } }
.sec-modal {
    background: #fff; width: 380px; max-width: 92vw; border-radius: 18px; padding: 26px 26px 20px; text-align: center;
    box-shadow: 0 24px 64px rgba(9, 18, 32, .4); transform-origin: left center;
    animation: jellyInLeft .68s cubic-bezier(.18, .9, .32, 1.15) both;
}
@keyframes jellyInLeft {
    0%   { transform: translateX(-70vw) scale(.85, .85) rotate(-2deg); opacity: 0; }
    55%  { transform: translateX(0) scale(1.08, .88) rotate(0deg); opacity: 1; }
    72%  { transform: translateX(-8px) scale(.95, 1.06); }
    86%  { transform: translateX(4px) scale(1.03, .97); }
    100% { transform: translateX(0) scale(1, 1); }
}
.sec-modal.out { animation: jellyOutLeft .3s ease both; }
@keyframes jellyOutLeft { to { transform: translateX(-45vw) scale(.88); opacity: 0; } }
.sec-modal.shake { animation: secShake .45s ease; }
@keyframes secShake {
    0%, 100% { transform: translateX(0); }
    15% { transform: translateX(-12px) rotate(-1.2deg); }
    35% { transform: translateX(10px) rotate(1deg); }
    55% { transform: translateX(-7px) rotate(-.6deg); }
    75% { transform: translateX(4px); }
}
.sec-icon {
    width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 50%; background: var(--blue-bg);
    display: flex; align-items: center; justify-content: center;
    animation: iconPop .5s cubic-bezier(.18, .9, .32, 1.4) .18s both;
}
.sec-icon svg { width: 30px; height: 30px; fill: var(--blue); }
@keyframes iconPop { from { transform: scale(0) rotate(-20deg); } to { transform: scale(1) rotate(0); } }
.sec-modal h3 { border-bottom: none; padding-bottom: 0; margin-bottom: 6px; }
.sec-sub { font-size: 12px; color: var(--text-3); margin-bottom: 18px; }
.sec-modal input { width: 100%; margin-bottom: 10px; }
.sec-err { color: var(--red); font-size: 12px; margin-bottom: 8px; display: none; min-height: 15px; }

/* ================= 移动端 ================= */
@media (max-width: 768px) {
    .dashboard-body { flex-direction: column; }
    .sidebar { width: 100%; flex-direction: column; padding: 8px 10px; box-shadow: none; }
    .logo-area { padding: 8px 10px; border-bottom: none; }
    .logo-text .logo-desc { display: none; }
    .nav-menu { display: flex; padding: 0; overflow-x: auto; gap: 8px; }
    .nav-item { margin-bottom: 0; white-space: nowrap; padding: 8px 13px; }
    .sidebar-footer { padding: 8px 4px 0; display: flex; align-items: center; justify-content: space-between; border-top: none; }
    .whoami { margin-bottom: 0; font-size: 12px; }
    .main-content { padding: 12px; }
    .panel { padding: 16px; }
    .io-grid, .form-row-grid { grid-template-columns: 1fr; }
    .panel-head { flex-direction: column; align-items: flex-start; gap: 12px; }
    .subtabs { gap: 16px; }
}
