/* =====================================================================
   站群后台管理系统 - 全局样式
   ===================================================================== */

:root {
    --sn-primary: #2563eb;
    --sn-primary-dark: #1d4ed8;
    --sn-bg: #f4f6fb;
    --sn-border: #e6e9f0;
    --sn-text: #1f2937;
    --sn-muted: #6b7280;
    --sn-radius: 12px;
    --sn-sidebar-w: 226px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--sn-bg);
    color: var(--sn-text);
    font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; }

/* ---------------- 骨架 ---------------- */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    width: var(--sn-sidebar-w);
    flex: 0 0 var(--sn-sidebar-w);
    background: #fff;
    border-right: 1px solid var(--sn-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1040;
    transition: transform .25s ease;
}

.sidebar-brand {
    height: 60px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 18px;
    border-bottom: 1px solid var(--sn-border);
    font-weight: 700;
    font-size: 16px;
    color: var(--sn-text);
}
.brand-icon {
    width: 30px; height: 30px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 8px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    font-size: 15px;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 10px; }
.nav-group { margin-bottom: 14px; }
.nav-group-title {
    font-size: 11px;
    letter-spacing: .08em;
    color: #9aa3b2;
    padding: 6px 10px;
    text-transform: uppercase;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 9px;
    color: #47506a;
    font-size: 14px;
    margin-bottom: 2px;
    transition: all .16s ease;
}
.nav-item i { font-size: 15px; width: 18px; text-align: center; color: #8b93a7; }
.nav-item:hover { background: #f1f5fd; color: var(--sn-primary); }
.nav-item:hover i { color: var(--sn-primary); }
.nav-item.active {
    background: #eaf1ff;
    color: var(--sn-primary-dark);
    font-weight: 600;
}
.nav-item.active i { color: var(--sn-primary-dark); }

.sidebar-footer {
    padding: 12px 18px;
    border-top: 1px solid var(--sn-border);
    font-size: 12px;
    color: var(--sn-muted);
}
.sf-line { line-height: 1.7; }

.app-main {
    flex: 1;
    margin-left: var(--sn-sidebar-w);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-topbar {
    height: 60px;
    background: #fff;
    border-bottom: 1px solid var(--sn-border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 1030;
    gap: 10px;
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar-title .subtitle { font-size: 12px; color: var(--sn-muted); margin-top: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.user-btn { display: flex; align-items: center; gap: 8px; border: 1px solid var(--sn-border); }
.avatar {
    width: 26px; height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, #60a5fa, #2563eb);
    color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 600;
}

.app-content { flex: 1; padding: 20px; min-width: 0; }
.app-footer {
    padding: 14px 20px;
    font-size: 12px;
    color: var(--sn-muted);
    border-top: 1px solid var(--sn-border);
    background: #fff;
}

.sidebar-mask {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15,23,42,.35);
    z-index: 1035;
}

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.show { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .sidebar-mask.show { display: block; }
}

/* ---------------- 卡片 / 面板 ---------------- */
.card-panel {
    background: #fff;
    border: 1px solid var(--sn-border);
    border-radius: var(--sn-radius);
    box-shadow: 0 1px 2px rgba(16,24,40,.04);
    margin-bottom: 18px;
}
.card-panel > .panel-head {
    padding: 14px 18px;
    border-bottom: 1px solid var(--sn-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}
.panel-head .panel-title {
    font-size: 15px;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.panel-head .panel-title i { color: var(--sn-primary); }
.card-panel > .panel-body { padding: 16px 18px; }
.card-panel > .panel-body.p-0 { padding: 0; }

/* ---------------- 统计卡片 ---------------- */
.stat-card {
    background: #fff;
    border: 1px solid var(--sn-border);
    border-radius: var(--sn-radius);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    height: 100%;
    transition: box-shadow .18s ease, transform .18s ease;
}
.stat-card:hover { box-shadow: 0 6px 18px rgba(37,99,235,.10); transform: translateY(-2px); }
.stat-icon {
    width: 46px; height: 46px;
    flex: 0 0 46px;
    border-radius: 12px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 20px;
}
.stat-body { min-width: 0; }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 12.5px; color: var(--sn-muted); margin-top: 3px; }

.bg-soft-blue   { background: #e8f0ff; color: #2563eb; }
.bg-soft-green  { background: #e6f7ee; color: #16a34a; }
.bg-soft-orange { background: #fff3e6; color: #ea8a13; }
.bg-soft-purple { background: #f1ebff; color: #7c3aed; }
.bg-soft-cyan   { background: #e5f7fb; color: #0891b2; }
.bg-soft-red    { background: #ffeaea; color: #dc2626; }

/* ---------------- 表格 ---------------- */
.table-sn { margin: 0; font-size: 13px; }
.table-sn > thead > tr > th {
    background: #fafbfe;
    border-bottom: 1px solid var(--sn-border);
    color: #5b6478;
    font-weight: 600;
    font-size: 12.5px;
    padding: 10px 11px;
    white-space: nowrap;
}
.table-sn > tbody > tr > td {
    padding: 10px 11px;
    border-bottom: 1px solid #f1f3f8;
    vertical-align: middle;
}
/* 表格内的徽标与按钮统一紧凑化，避免宽表横向溢出 */
.table-sn .badge-soft { white-space: nowrap; }
.table-sn .btn {
    padding: 3px 8px;
    font-size: 12px;
    line-height: 1.5;
    border-radius: 6px;
    margin: 1px 0;
}
.table-sn .btn i { font-size: 12px; }

/* 固定列宽表格：列宽严格按表头 width 渲染，配合 .text-ellipsis 可彻底避免横向溢出 */
.table-fixed { table-layout: fixed; width: 100%; }
.table-fixed > tbody > tr > td { overflow: hidden; }
.table-sn > tbody > tr:hover { background: #fafbfe; }
.table-sn > tbody > tr:last-child > td { border-bottom: none; }

/* 站点列表专属：行高加大 + 操作按钮分两行排列，缓解拥挤 */
.table-site > thead > tr > th { padding: 13px 12px; }
.table-site > tbody > tr > td { padding: 15px 12px; }
.site-ops {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-width: 162px;   /* 超过即换行：第一行「修改 + 查看统计」，第二行「接入代码 + 启停 + 删除」 */
}
.site-ops .btn { margin: 0; }
.table-empty { padding: 46px 10px; text-align: center; color: #9aa3b2; }
.table-empty i { font-size: 34px; display: block; margin-bottom: 8px; color: #cbd5e1; }

/* ---------------- 徽标 ---------------- */
.badge-soft {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.5;
}
.badge-on   { background: #e6f7ee; color: #15803d; }
.badge-off  { background: #f1f2f6; color: #6b7280; }
.badge-pc   { background: #e8f0ff; color: #2563eb; }
.badge-wap  { background: #f1ebff; color: #7c3aed; }
.badge-num  { background: #eaf1ff; color: #2563eb; font-weight: 600; }
.badge-gray { background: #f1f2f6; color: #4b5563; }

/* ---------------- 工具条 ---------------- */
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 14px 18px;
    border-bottom: 1px solid var(--sn-border);
}
.toolbar .form-control, .toolbar .form-select { height: 34px; font-size: 13.5px; }
.toolbar .search-box { position: relative; width: 240px; max-width: 100%; }
.toolbar .search-box .bi-search {
    position: absolute; left: 10px; top: 50%;
    transform: translateY(-50%);
    color: #9aa3b2; font-size: 13px;
}
.toolbar .search-box input { padding-left: 30px; }
.toolbar-spacer { flex: 1; }

/* ---------------- 分页 ---------------- */
.sn-pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 18px;
    border-top: 1px solid var(--sn-border);
}
.sn-pager .pager-info { font-size: 12.5px; color: var(--sn-muted); }
.sn-pager .pagination .page-link {
    border-radius: 8px;
    margin: 0 2px;
    border-color: var(--sn-border);
    color: #4b5563;
    min-width: 30px;
    text-align: center;
}
.sn-pager .pagination .page-link.active,
.sn-pager .pagination .page-item.active .page-link {
    background: var(--sn-primary);
    border-color: var(--sn-primary);
    color: #fff;
}
.sn-pager-sm { padding: 10px 0 0; border-top: none; }

/* ---------------- 服务器信息列表 ---------------- */
.info-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0 22px; }
.info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px dashed #eef1f6;
    font-size: 13px;
}
.info-row:last-child { border-bottom: none; }
.info-row .k { color: var(--sn-muted); white-space: nowrap; }
.info-row .v { font-weight: 600; text-align: right; word-break: break-all; }

.ext-tags { display: flex; flex-wrap: wrap; gap: 7px; }
.ext-tag {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    background: #f1f2f6;
    color: #6b7280;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.ext-tag.ok   { background: #e6f7ee; color: #15803d; }
.ext-tag.no   { background: #ffeaea; color: #dc2626; }

.progress-sn { height: 8px; background: #eef1f6; border-radius: 20px; overflow: hidden; }
.progress-sn > span { display: block; height: 100%; background: linear-gradient(90deg, #60a5fa, #2563eb); }

/* ---------------- 30 日点击条形 ---------------- */
.day-bar {
    height: 8px;
    border-radius: 20px;
    background: #eef1f6;
    overflow: hidden;
    min-width: 60px;
}
.day-bar > span {
    display: block; height: 100%;
    background: linear-gradient(90deg, #7dd3fc, #2563eb);
    border-radius: 20px;
}
.day-zero { color: #c2c8d4; }

/* ---------------- 弹窗 ---------------- */
.modal-content { border: none; border-radius: 14px; box-shadow: 0 18px 50px rgba(15,23,42,.18); }
.modal-header { border-bottom: 1px solid var(--sn-border); padding: 14px 18px; }
.modal-title { font-size: 15.5px; font-weight: 700; display: flex; align-items: center; }
.modal-body { padding: 18px; }
.modal-footer { border-top: 1px solid var(--sn-border); padding: 12px 18px; }
.modal-header .btn-close { font-size: 11px; }
.modal-dialog-scrollable .modal-body { max-height: calc(100vh - 220px); }

.form-label { font-size: 13px; font-weight: 600; margin-bottom: 5px; color: #374151; }
.form-label.required::after { content: " *"; color: #dc2626; }
.form-control, .form-select { font-size: 13.5px; border-color: #dfe3ec; }
.form-control:focus, .form-select:focus {
    border-color: #93b4fd;
    box-shadow: 0 0 0 3px rgba(37,99,235,.10);
}
.form-text { font-size: 12px; }
.required::after { content: " *"; color: #dc2626; }

/* ---------------- 汇总小卡（统计弹窗内） ---------------- */
.mini-stat {
    background: #fafbfe;
    border: 1px solid var(--sn-border);
    border-radius: 10px;
    padding: 12px 14px;
    height: 100%;
}
.mini-stat .ms-value { font-size: 20px; font-weight: 700; line-height: 1.25; }
.mini-stat .ms-label { font-size: 12px; color: var(--sn-muted); margin-top: 2px; }

.stat-tabs .nav-link {
    font-size: 13.5px;
    color: #4b5563;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 9px 14px;
}
.stat-tabs .nav-link.active {
    color: var(--sn-primary);
    border-bottom-color: var(--sn-primary);
    background: transparent;
    font-weight: 600;
}

/* ---------------- 提示条 / 代码 ---------------- */
.code-box {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 10px;
    padding: 12px 14px;
    font: 12.5px/1.8 Consolas, Monaco, monospace;
    overflow-x: auto;
    white-space: pre;
    margin: 0;
}
.api-tip {
    display: flex; align-items: center; gap: 8px;
    background: #f0f6ff;
    border: 1px solid #dbe8ff;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13px;
    color: #1e40af;
}
.api-tip code {
    background: #fff; padding: 1px 6px; border-radius: 5px;
    color: #2563eb; font-size: 12.5px;
    border: 1px solid #dbe8ff;
}

/* ---------------- Toast ---------------- */
.sn-toast-wrap {
    position: fixed;
    top: 74px;
    right: 22px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.sn-toast {
    min-width: 240px;
    max-width: 380px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 10px 32px rgba(15,23,42,.16);
    border-left: 4px solid var(--sn-primary);
    padding: 12px 16px;
    font-size: 13.5px;
    display: flex;
    align-items: flex-start;
    gap: 9px;
    animation: snToastIn .22s ease;
    pointer-events: auto;
}
.sn-toast.success { border-left-color: #16a34a; }
.sn-toast.error   { border-left-color: #dc2626; }
.sn-toast.warning { border-left-color: #ea8a13; }
.sn-toast i { font-size: 15px; margin-top: 1px; }
.sn-toast.success i { color: #16a34a; }
.sn-toast.error i   { color: #dc2626; }
.sn-toast.warning i { color: #ea8a13; }
.sn-toast.info i    { color: var(--sn-primary); }
@keyframes snToastIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }

/* ---------------- 确认弹窗 ---------------- */
.confirm-icon { font-size: 32px; color: #f59e0b; margin-bottom: 10px; }
.confirm-text { font-size: 14px; color: #374151; line-height: 1.7; }

/* ---------------- 登录页 ---------------- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #eef4ff 0%, #f7f9fc 55%, #eaf1ff 100%);
    padding: 24px;
}
.login-box {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(37,99,235,.14);
    padding: 34px 32px 28px;
}
.login-logo {
    width: 52px; height: 52px;
    border-radius: 14px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px;
    margin: 0 auto 16px;
}
.login-title { text-align: center; font-size: 19px; font-weight: 700; margin-bottom: 4px; }
.login-sub { text-align: center; font-size: 12.5px; color: var(--sn-muted); margin-bottom: 24px; }
.login-footer { text-align: center; font-size: 12px; color: #9aa3b2; margin-top: 18px; }
.login-box .form-control { height: 42px; font-size: 14px; }

/* ---------------- 其它 ---------------- */
.text-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cursor-pointer { cursor: pointer; }
.mono { font-family: Consolas, Monaco, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.table-responsive { border-radius: 0 0 var(--sn-radius) var(--sn-radius); }
.empty-icon { font-size: 40px; color: #cbd5e1; }
