/* =========================================
   蜘蛛统计平台 - 后台样式  v1001
   ========================================= */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
    background: #f0f4f8;
    color: #1e293b;
    font-size: 14px;
    line-height: 1.6;
}

a { text-decoration: none; color: inherit; }

/* ===== 整体布局 ===== */
.admin-wrap { display: flex; min-height: 100vh; }

.sidebar {
    width: 200px;
    background: #fff;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 10;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 16px;
    border-bottom: 1px solid #e2e8f0;
}

.brand-logo {
    width: 38px; height: 38px;
    background: #2563eb;
    color: #fff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    flex-shrink: 0;
}

.brand-name { font-size: 15px; font-weight: bold; color: #1e293b; }
.brand-domain { font-size: 11px; color: #94a3b8; }

.sidebar-menu { flex: 1; padding: 10px 8px; }

.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    color: #475569;
    margin-bottom: 2px;
    font-size: 14px;
}

.menu-item:hover { background: #f1f5f9; color: #1e293b; }

.menu-item.active {
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: bold;
    border-left: 3px solid #2563eb;
}

.menu-icon { width: 18px; text-align: center; font-size: 15px; }

.sidebar-foot { padding: 8px; border-top: 1px solid #e2e8f0; }
.menu-item.logout { color: #b91c1c; }
.menu-item.logout:hover { background: #fef2f2; color: #b91c1c; }

.admin-main {
    flex: 1;
    margin-left: 200px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.admin-topbar {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.page-title { font-size: 18px; font-weight: bold; color: #1e293b; }
.topbar-date { font-size: 13px; color: #64748b; }

.admin-content { padding: 20px 24px; flex: 1; }

/* ===== 统计卡片 ===== */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 18px 20px;
    border: 1px solid #e2e8f0;
    border-top: 3px solid #2563eb;
}

.stat-card:nth-child(2) { border-top-color: #059669; }
.stat-card:nth-child(3) { border-top-color: #d97706; }
.stat-card:nth-child(4) { border-top-color: #7c3aed; }

.stat-label { font-size: 13px; color: #64748b; margin-bottom: 6px; }

.stat-value {
    font-size: 28px;
    font-weight: bold;
    color: #1e293b;
    line-height: 1.2;
}

.stat-value small { font-size: 14px; color: #94a3b8; font-weight: normal; }

.stat-sub { font-size: 12px; color: #94a3b8; margin-top: 6px; }

.trend-up { color: #059669; font-weight: bold; margin-left: 4px; }
.trend-down { color: #dc2626; font-weight: bold; margin-left: 4px; }

/* ===== 面板 ===== */
.panel {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 20px;
}

.panel-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.panel-row .panel { margin-bottom: 0; }
.panel-row + .panel { margin-top: 20px; }

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid #e2e8f0;
}

.panel-head h2 { font-size: 15px; font-weight: bold; color: #1e293b; }
.panel-more { font-size: 13px; color: #2563eb; }
.panel-more:hover { text-decoration: underline; }

.panel-body { padding: 16px 20px; }

/* ===== 表格（data-table 风格）===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    font-size: 13px;
}

.data-table th {
    background: #f8fafc;
    color: #475569;
    font-weight: bold;
    text-align: left;
    padding: 10px 12px;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}

.data-table td {
    padding: 9px 12px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.data-table tbody tr:hover { background: #f8fafc; }

.td-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.td-time { white-space: nowrap; color: #64748b; font-size: 12px; }
.td-ip { font-family: Consolas, monospace; font-size: 12px; color: #475569; }
.td-url { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.url-path { color: #2563eb; margin-left: 4px; }
.td-check { width: 36px; text-align: center; }
.td-actions { white-space: nowrap; text-align: right; }

.data-table th.td-check input,
.data-table td.td-check input { cursor: pointer; }

.spider-tag {
    display: inline-block;
    background: #eff6ff;
    color: #1d4ed8;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 12px;
    white-space: nowrap;
}

.badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 12px;
}
.badge-on { background: #ecfdf5; color: #047857; }
.badge-off { background: #fef2f2; color: #b91c1c; }

.site-key {
    font-family: Consolas, monospace;
    font-size: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 1px 6px;
    border-radius: 4px;
    color: #475569;
}

.table-note { font-size: 12px; color: #94a3b8; margin-bottom: 12px; }

/* ===== 筛选栏（单行不换行）===== */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

.filter-inline { flex: 0 0 auto; }
.filter-sep { color: #94a3b8; font-size: 13px; }
.filter-hint { font-size: 12px; color: #94a3b8; white-space: nowrap; }

.input {
    height: 34px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 0 10px;
    font-size: 13px;
    color: #1e293b;
    background: #fff;
    outline: none;
    flex-shrink: 0;
}

.input:focus { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,.12); }
.input-w130 { width: 130px; }
.input-w150 { width: 150px; }
.input-w160 { width: 160px; }
.input-w180 { width: 180px; }
.input-w200 { width: 200px; }
.input-sm { height: 30px; font-size: 12px; padding: 0 8px; }

/* ===== 按钮（对比度均满足 WCAG AA）===== */
.btn {
    display: inline-block;
    height: 34px;
    line-height: 32px;
    padding: 0 16px;
    border-radius: 6px;
    font-size: 13px;
    border: 1px solid transparent;
    cursor: pointer;
    background: #fff;
    transition: all .15s;
    white-space: nowrap;
}

.btn:hover { opacity: .9; }

.btn-primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn-primary:hover { background: #1d4ed8; color: #fff; }

.btn-plain { background: #f1f5f9; color: #334155; border-color: #e2e8f0; }
.btn-plain:hover { background: #e2e8f0; color: #334155; }

.btn-block { display: block; width: 100%; }

.btn-sm { height: 28px; line-height: 26px; padding: 0 10px; font-size: 12px; }

.btn-edit { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.btn-edit:hover { background: #dbeafe; color: #1d4ed8; }

.btn-danger-plain { background: #fff; color: #b91c1c; border-color: #fca5a5; }
.btn-danger-plain:hover { background: #fef2f2; color: #b91c1c; }

.btn-armed, .btn-armed:hover {
    background: #b91c1c !important;
    color: #fff !important;
    border-color: #b91c1c !important;
}

.btn-toggle { min-width: 44px; }

.inline-form { display: inline-block; margin-left: 6px; }

/* ===== 批量操作栏 ===== */
.bulk-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    margin-bottom: 14px;
}

.bulk-info {
    color: #1e293b;
    font-size: 11pt;
    font-weight: bold;
    margin-right: auto;
}

.btn-select-all { background: #fff7ed; color: #9a3412; border-color: #fdba74; }
.btn-select-all:hover { background: #ffedd5; color: #9a3412; }

.btn-invert { background: #f1f5f9; color: #334155; border-color: #e2e8f0; }
.btn-invert:hover { background: #e2e8f0; color: #334155; }

.btn-bulk-del { background: #fff; color: #b91c1c; border-color: #fca5a5; }
.btn-bulk-del:hover { background: #fef2f2; color: #b91c1c; }

/* ===== 分页 ===== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
    flex-wrap: wrap;
    gap: 10px;
}

.page-info { font-size: 13px; color: #64748b; }

.page-btns { display: flex; gap: 6px; }

.page-btn {
    min-width: 32px;
    height: 30px;
    line-height: 28px;
    text-align: center;
    padding: 0 8px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 13px;
    color: #334155;
    background: #fff;
}

.page-btn:hover { border-color: #2563eb; color: #2563eb; }
.page-btn.active { background: #2563eb; color: #fff; border-color: #2563eb; font-weight: bold; }
.page-btn.disabled { color: #cbd5e1; cursor: not-allowed; background: #f8fafc; }
.page-ellipsis { color: #94a3b8; line-height: 28px; }

/* ===== 标签页（强对比：深底白字）===== */
.tabs { display: flex; gap: 4px; }

.tab {
    padding: 7px 18px;
    border-radius: 6px;
    font-size: 13px;
    color: #475569;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
}

.tab:hover { color: #1e293b; }

.tab.active {
    background: #1e293b;
    color: #fff;
    border-color: #1e293b;
    font-weight: bold;
}

/* ===== 柱状图 ===== */
.chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 220px;
    padding: 10px 4px 0;
}

.chart-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    min-width: 0;
}

.chart-bar-box {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.chart-bar {
    width: 62%;
    max-width: 34px;
    background: #93c5fd;
    border-radius: 3px 3px 0 0;
    min-height: 2px;
    transition: height .3s;
}

.chart-bar:hover { background: #2563eb; }
.chart-bar.today { background: #2563eb; }

.chart-x {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 6px;
    white-space: nowrap;
}

/* ===== 横向条形图 ===== */
.hbar-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.hbar-name { width: 76px; font-size: 13px; color: #334155; text-align: right; flex-shrink: 0; }

.hbar-track {
    flex: 1;
    height: 16px;
    background: #f1f5f9;
    border-radius: 8px;
    overflow: hidden;
}

.hbar-fill {
    height: 100%;
    background: linear-gradient(90deg, #60a5fa, #2563eb);
    border-radius: 8px;
    min-width: 2px;
}

.hbar-val { width: 52px; font-size: 12px; color: #64748b; flex-shrink: 0; font-variant-numeric: tabular-nums; }

.hbar-inline { display: flex; align-items: center; gap: 8px; min-width: 140px; }
.hbar-inline .hbar-track { height: 10px; }
.hbar-inline .hbar-val { width: auto; }

/* ===== 迷你趋势图 ===== */
.sparkline {
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
    height: 26px;
    min-width: 60px;
}

.spark-bar {
    display: inline-block;
    width: 5px;
    background: #93c5fd;
    border-radius: 1px;
    min-height: 2px;
}

.spark-bar:hover { background: #2563eb; }

/* ===== 空状态 ===== */
.empty-state {
    text-align: center;
    color: #94a3b8;
    padding: 48px 20px;
    font-size: 13px;
    background: #fafcfe;
    border: 1px dashed #e2e8f0;
    border-radius: 6px;
}

/* ===== 嵌入代码 ===== */
.embed-box { padding: 4px 0; }

.embed-tip { font-size: 13px; color: #475569; margin-bottom: 10px; }
.embed-tip b { color: #1e293b; }

.code-block {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 12px 14px;
    font-family: Consolas, "Courier New", monospace;
    font-size: 12px;
    line-height: 1.7;
    color: #1e293b;
    overflow-x: auto;
    white-space: pre;
}

.embed-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
}

.embed-note { font-size: 12px; color: #94a3b8; }

/* ===== Toast ===== */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-80px);
    background: #1e293b;
    color: #fff;
    padding: 10px 22px;
    border-radius: 6px;
    font-size: 14px;
    z-index: 999;
    opacity: 0;
    transition: all .35s;
    box-shadow: 0 4px 16px rgba(0,0,0,.18);
}

.toast-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== 登录页 ===== */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #eff6ff, #f0f4f8);
}

.login-card {
    width: 380px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 36px 34px;
    box-shadow: 0 8px 30px rgba(30,41,59,.08);
}

.login-brand { text-align: center; margin-bottom: 26px; }
.login-logo { margin: 0 auto 12px; width: 48px; height: 48px; font-size: 22px; border-radius: 10px; }
.login-brand h1 { font-size: 20px; color: #1e293b; }
.login-sub { font-size: 13px; color: #94a3b8; margin-top: 4px; }

.login-field { margin-bottom: 16px; }
.login-field label { display: block; font-size: 13px; color: #475569; margin-bottom: 6px; }

.login-field input {
    width: 100%;
    height: 40px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 0 12px;
    font-size: 14px;
    outline: none;
}

.login-field input:focus { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,.12); }

.login-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 13px;
    margin-bottom: 16px;
    text-align: center;
}

.login-tip { font-size: 12px; color: #94a3b8; text-align: center; margin-top: 16px; }

/* ===== 响应式 ===== */
@media (max-width: 1100px) {
    .stat-cards { grid-template-columns: repeat(2, 1fr); }
    .panel-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        position: static;
        width: 100%;
        flex-direction: row;
        align-items: center;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }
    .sidebar-brand { border-bottom: none; padding: 10px 14px; flex-shrink: 0; }
    .sidebar-menu { display: flex; padding: 6px; overflow-x: auto; }
    .menu-item { white-space: nowrap; margin-bottom: 0; margin-right: 2px; padding: 8px 10px; }
    .menu-item.active { border-left: none; border-bottom: 2px solid #2563eb; border-radius: 6px 6px 0 0; }
    .sidebar-foot { border-top: none; border-left: 1px solid #e2e8f0; }
    .brand-text .brand-domain { display: none; }
    .admin-main { margin-left: 0; }
    .admin-content { padding: 14px; }
    .stat-cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-value { font-size: 22px; }
    .filter-bar { flex-wrap: wrap; }
    .data-table { display: block; overflow-x: auto; }
    .td-url { max-width: 200px; }
    .page-info { width: 100%; }
}
