/* ============================================
   后台样式
   ============================================ */

:root {
    --text:    #1b1f33;
    --muted:   #6b7189;
    --faint:   #9aa0b5;
    --line:    #e6e9f2;
    --accent:  #7c5cff;
    --danger:  #e5484d;
    --ok:      #17a673;
    --radius:  14px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
                 "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: #f4f6fb;
    line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 登录页 ---------- */
.auth-body {
    display: grid;
    place-items: center;
    background: linear-gradient(160deg, #eef1fb, #f8eef8 60%, #eaf3fb);
    padding: 20px;
}
.auth-card {
    width: 100%;
    max-width: 380px;
    padding: 34px 30px;
    background: rgba(255, 255, 255, .72);
    backdrop-filter: blur(22px) saturate(170%);
    -webkit-backdrop-filter: blur(22px) saturate(170%);
    border: 1px solid rgba(255, 255, 255, .85);
    border-radius: 22px;
    box-shadow: 0 18px 50px rgba(27, 31, 51, .13);
}
.auth-card h1 { margin: 0 0 6px; font-size: 22px; }
.auth-card .sub { margin: 0 0 22px; color: var(--muted); font-size: 13.5px; }
.auth-card label { display: block; margin-bottom: 14px; font-size: 13.5px; color: var(--muted); }
.auth-card input { margin-top: 6px; }
.auth-card .tip { margin: 18px 0 0; text-align: center; font-size: 13px; }

/* ---------- 侧栏 + 主区 ---------- */
.side {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 208px;
    padding: 22px 14px;
    background: #fff;
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px 20px;
    font-size: 15px;
    font-weight: 700;
}
.brand::before {
    content: attr(data-i);
    display: grid;
    place-items: center;
    width: 32px; height: 32px;
    border-radius: 10px;
    color: #fff;
    font-size: 15px;
    background: linear-gradient(135deg, #7c5cff, #ff5c9d);
}
.brand span { font-weight: 400; color: var(--muted); font-size: 13px; }

.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a {
    padding: 9px 12px;
    border-radius: 10px;
    color: #4a5068;
    font-size: 13.5px;
    text-decoration: none;
    transition: background .16s, color .16s;
}
.side nav a:hover { background: #f2f4fa; text-decoration: none; }
.side nav a.on { background: linear-gradient(135deg, #7c5cff, #9b7bff); color: #fff; font-weight: 600; }

.side-foot { margin-top: auto; padding: 16px 12px 0; font-size: 13px; }

.main {
    margin-left: 208px;
    padding: 26px 30px 60px;
    max-width: 1280px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.topbar h1 { margin: 0; font-size: 21px; }
.who { font-size: 13px; color: var(--faint); }

/* ---------- 统计卡片 ---------- */
.grid-4 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}
.stat-card {
    padding: 18px 20px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(27, 31, 51, .04);
}
.stat-card.slim { padding: 15px 20px; }
.stat-num {
    font-size: 27px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    background: linear-gradient(135deg, #7c5cff, #ff5c9d);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.stat-lab { font-size: 13px; color: var(--muted); margin-top: 2px; }
.stat-sub { font-size: 12px; color: var(--faint); }

/* ---------- 柱状图 ---------- */
.chart {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    height: 170px;
    padding: 14px 18px 0;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.bar-col {
    flex: 1;
    height: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 3px;
    position: relative;
    padding-bottom: 22px;
}
.bar-pv, .bar-ips {
    width: 42%;
    border-radius: 5px 5px 0 0;
    transition: height .5s cubic-bezier(.22, 1, .36, 1);
    align-self: flex-end;
}
.bar-pv  { background: linear-gradient(180deg, #9b7bff, #7c5cff); }
.bar-ips { background: linear-gradient(180deg, #7fe0b0, #17a673); }
.bar-lab {
    position: absolute;
    bottom: 0;
    font-size: 11.5px;
    color: var(--faint);
    white-space: nowrap;
}
.chart-legend {
    display: flex;
    gap: 18px;
    margin-top: 10px;
    font-size: 12.5px;
    color: var(--muted);
}
.chart-legend .sw {
    display: inline-block;
    width: 10px; height: 10px;
    border-radius: 3px;
    margin-right: 6px;
}
.chart-legend .sw.pv  { background: #7c5cff; }
.chart-legend .sw.ips { background: #17a673; }

/* ---------- 表格 ---------- */
.h2 {
    margin: 28px 0 12px;
    font-size: 15.5px;
    font-weight: 600;
}
.table-wrap {
    overflow-x: auto;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
    padding: 11px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 12.5px;
    color: var(--muted);
    background: #fafbfe;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid #f2f4f9;
    vertical-align: top;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfe; }
tbody tr.row-hidden { background: #fff8f8; }
tbody tr.row-hidden:hover { background: #fff2f2; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.dim  { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.empty { padding: 34px; text-align: center; color: var(--faint); }
.cmt-cell { min-width: 200px; max-width: 420px; word-break: break-word; overflow-wrap: anywhere; }
.ua { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tag {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    white-space: nowrap;
}
.tag.ok  { background: #e7f8f0; color: #0f8a5f; }
.tag.off { background: #fdeaea; color: #c33; }

/* ---------- 按钮 ---------- */
.btn {
    display: inline-block;
    padding: 8px 16px;
    font: inherit;
    font-size: 13.5px;
    color: var(--text);
    cursor: pointer;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 9px;
    text-decoration: none;
    transition: background .16s, border-color .16s, transform .16s;
}
.btn:hover { background: #f6f7fc; border-color: #d5dae8; text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn.primary {
    color: #fff;
    background: linear-gradient(135deg, #7c5cff, #ff5c9d);
    border-color: transparent;
    box-shadow: 0 5px 16px rgba(124, 92, 255, .3);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); border-color: #f4cccc; }
.btn.danger:hover { background: #fdf2f2; border-color: #e9a8a8; }
.btn.tiny { padding: 4px 11px; font-size: 12.5px; border-radius: 7px; }
.btn.wide { width: 100%; padding: 11px; }

.inline { display: inline-block; margin-right: 4px; }

/* ---------- 表单 ---------- */
.form-card {
    padding: 22px 24px;
    margin-bottom: 8px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(27, 31, 51, .04);
}
.form-card .h2:first-child { margin-top: 0; }

label { display: block; margin-bottom: 14px; font-size: 13.5px; color: var(--muted); }

input[type=text], input[type=url], input[type=number], input[type=password], textarea {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 9px 12px;
    font: inherit;
    font-size: 14px;
    color: var(--text);
    background: #fbfcfe;
    border: 1px solid var(--line);
    border-radius: 9px;
    outline: none;
    transition: border-color .16s, box-shadow .16s, background .16s;
}
input:focus, textarea:focus {
    background: #fff;
    border-color: rgba(124, 92, 255, .6);
    box-shadow: 0 0 0 3px rgba(124, 92, 255, .12);
}
textarea { resize: vertical; font-family: inherit; }
textarea[name=json] { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

.form-foot {
    display: flex;
    gap: 10px;
    align-items: center;
    padding-top: 8px;
    border-top: 1px solid #f2f4f9;
    margin-top: 6px;
}

.hint { margin: -6px 0 12px; font-size: 12.5px; color: var(--faint); }
.hint code, .help code {
    padding: 1px 6px;
    background: #f2f4fa;
    border-radius: 5px;
    font-size: 12px;
}

/* ---------- 其它 ---------- */
.toolbar { display: flex; gap: 8px; margin-bottom: 14px; }
.chip {
    padding: 6px 15px;
    font-size: 13px;
    color: var(--muted);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 999px;
    text-decoration: none;
}
.chip:hover { text-decoration: none; background: #f6f7fc; }
.chip.on { color: #fff; background: #7c5cff; border-color: transparent; }

.flash {
    padding: 11px 16px;
    margin-bottom: 16px;
    border-radius: 10px;
    font-size: 13.5px;
}
.flash.ok  { background: #e7f8f0; color: #0f7a55; border: 1px solid #bfe9d7; }
.flash.err { background: #fdeaea; color: #b62b2b; border: 1px solid #f3c9c9; }

.pager { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.pager a, .pager .cur {
    padding: 5px 12px;
    font-size: 13px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    text-decoration: none;
}
.pager a:hover { background: #f6f7fc; text-decoration: none; }
.pager .cur { background: #7c5cff; color: #fff; border-color: transparent; }

.help {
    margin-top: 18px;
    padding: 16px 20px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: 13.5px;
}
.help summary { cursor: pointer; font-weight: 600; }
.help ol { margin: 12px 0 0; padding-left: 20px; color: #4a5068; }
.help li { margin-bottom: 6px; }
.help p { margin: 12px 0 0; color: #4a5068; }
kbd {
    padding: 1px 7px;
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 12px;
    background: #f2f4fa;
    border: 1px solid var(--line);
    border-bottom-width: 2px;
    border-radius: 5px;
}

/* ---------- 手机 ---------- */
@media (max-width: 780px) {
    .side {
        position: static;
        width: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        padding: 14px;
    }
    .side nav { flex-direction: row; flex-wrap: wrap; }
    .side nav a { padding: 7px 12px; font-size: 13px; }
    .side-foot { display: none; }
    .main { margin-left: 0; padding: 18px 14px 50px; }
    .row-2, .row-3 { grid-template-columns: 1fr; }
    .form-card { padding: 18px 16px; }
}
