:root {
  --bg: #f5f5f2;
  --card: #ffffff;
  --ink: #141414;
  --ink-2: #545454;
  --ink-3: #8f8f8a;
  --line: #e6e5e0;
  --line-2: #efeeea;
  --side: #0f0f0f;
  --side-ink: #a9a9a4;
  --red: #e5322d;
  --orange: #f7941d;
  --grad: linear-gradient(90deg, #e5322d, #f7941d);
  --accent: #ec5a24;
  --accent-soft: #fdeee6;
  --uv: #2b2b2b;
  --good: #1f8a55;
  --bad: #c8372d;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 14px; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.side { width: 220px; flex-shrink: 0; background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 22px 20px 26px; color: #fff; }
.brand-mark { width: 30px; height: 30px; }
.brand-name { font-size: 16px; font-weight: 600; letter-spacing: .5px; }
.brand-sub { font-size: 11px; color: #6f6f6a; letter-spacing: 1.5px; margin-top: 2px; }
.nav { padding: 0 10px; flex: 1; }
.nav-label { font-size: 11px; color: #5e5e59; padding: 14px 12px 6px; letter-spacing: 1px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; margin-bottom: 2px; transition: background .15s, color .15s; }
.nav a:hover { background: #1c1c1c; color: #fff; }
.nav a.on { background: #1f1f1f; color: #fff; }
.nav a.on::before { content: ""; width: 3px; height: 16px; border-radius: 2px; background: var(--grad); margin-left: -6px; margin-right: -1px; }
.nav svg { width: 16px; height: 16px; flex-shrink: 0; }
.side-foot { padding: 16px 20px; border-top: 1px solid #1f1f1f; font-size: 12px; }
.side-foot .who { color: #e8e8e4; margin-bottom: 2px; }
.side-foot button { background: none; border: 0; color: var(--side-ink); padding: 0; cursor: pointer; margin-top: 8px; }
.side-foot button:hover { color: #fff; }

.main { flex: 1; min-width: 0; padding: 28px 36px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 600; margin: 0; letter-spacing: .3px; }
.page-desc { color: var(--ink-3); margin-top: 6px; font-size: 13px; }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- 基础组件 ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 13px; white-space: nowrap; transition: border-color .15s, background .15s; }
.btn:hover { border-color: #c9c8c2; }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-primary:hover { background: #2a2a2a; border-color: #2a2a2a; }
.btn-grad { background: var(--grad); color: #fff; border: 0; }
.btn-grad:hover { filter: brightness(1.05); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: #ecebe6; }
.btn-danger { color: var(--bad); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 6px; gap: 10px; }
.card-title { font-size: 14px; font-weight: 600; }
.card-sub { font-size: 12px; color: var(--ink-3); }
.card-body { padding: 8px 18px 16px; }

.tabs { display: inline-flex; background: #f1f0ec; border-radius: 7px; padding: 2px; }
.tabs button { border: 0; background: none; padding: 4px 10px; border-radius: 5px; font-size: 12px; color: var(--ink-2); cursor: pointer; }
.tabs button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; background: #fff; overflow: hidden; }
.seg button { border: 0; background: none; height: 32px; padding: 0 12px; cursor: pointer; font-size: 13px; color: var(--ink-2); border-right: 1px solid var(--line-2); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--ink); color: #fff; }

input.inp, select.inp, textarea.inp { height: 34px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; background: #fff; outline: none; width: 100%; }
textarea.inp { height: 70px; padding: 8px 10px; resize: vertical; }
.inp:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--ink-3); margin-top: 5px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.pill { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 20px; background: #f0efea; color: var(--ink-2); }
.pill-on { background: #e5f4ec; color: var(--good); }
.pill-off { background: #f9e7e5; color: var(--bad); }
.pill-acc { background: var(--accent-soft); color: var(--accent); }
.dot-live { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #22b46b; box-shadow: 0 0 0 0 rgba(34,180,107,.5); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(34,180,107,.45); } 70% { box-shadow: 0 0 0 7px rgba(34,180,107,0); } 100% { box-shadow: 0 0 0 0 rgba(34,180,107,0); } }
.muted { color: var(--ink-3); }
.empty { padding: 40px 10px; text-align: center; color: var(--ink-3); font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }

/* ---------- 表格 ---------- */
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-weight: 500; font-size: 12px; color: var(--ink-3); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: #fafaf8; }
.tbl .r { text-align: right; }
.tbl-wrap { overflow-x: auto; }

/* ---------- 站点卡片 ---------- */
.site-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.site-card { padding: 18px 18px 14px; cursor: pointer; transition: border-color .15s, transform .15s, box-shadow .15s; display: block; }
.site-card:hover { border-color: #cfcec8; box-shadow: 0 6px 20px rgba(0,0,0,.05); transform: translateY(-1px); }
.site-card .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.site-card .name { font-weight: 600; font-size: 15px; }
.site-card .domain { color: var(--ink-3); font-size: 12px; margin-top: 3px; }
.site-card .client { font-size: 12px; color: var(--ink-2); margin-top: 10px; }
.site-card .metrics { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 14px; gap: 8px; }
.site-card .m-v { font-size: 20px; font-weight: 600; }
.site-card .m-l { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.site-card .spark { margin-top: 12px; height: 40px; }
.site-card .live { font-size: 12px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }

/* ---------- 报表 ---------- */
.site-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.site-switch { height: 36px; font-size: 15px; font-weight: 600; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 0 30px 0 12px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; cursor: pointer; max-width: 320px; }
.sub-tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); margin: 4px 0 20px; }
.sub-tabs a { padding: 10px 0; color: var(--ink-3); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.sub-tabs a.on { color: var(--ink); border-image: var(--grad) 1; border-bottom: 2px solid; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.date-custom { display: inline-flex; align-items: center; gap: 6px; }
.date-custom input { width: 140px; height: 32px; }

.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0; margin-bottom: 16px; }
.kpi { padding: 16px 18px; border-right: 1px solid var(--line-2); cursor: default; }
.kpi:last-child { border-right: 0; }
.kpi .l { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.kpi .v { font-size: 26px; font-weight: 600; margin-top: 6px; letter-spacing: -.3px; }
.kpi .d { font-size: 12px; margin-top: 4px; }
.kpi .up { color: var(--good); }
.kpi .down { color: var(--bad); }
.kpi.hi .v { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.full { margin-bottom: 16px; }

.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .tip { position: absolute; pointer-events: none; background: #141414; color: #fff; font-size: 12px; padding: 8px 10px; border-radius: 7px; white-space: nowrap; transform: translate(-50%, -110%); opacity: 0; transition: opacity .1s; z-index: 5; }
.chart .tip b { font-weight: 600; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }

/* 横向条形列表 */
.bars { list-style: none; margin: 0; padding: 0; }
.bars li { position: relative; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 10px; margin-bottom: 4px; border-radius: 6px; font-size: 13px; overflow: hidden; }
.bars li .fill { position: absolute; left: 0; top: 0; bottom: 0; background: #f4f1ec; border-radius: 6px; z-index: 0; }
.bars li.acc .fill { background: var(--accent-soft); }
.bars li > span { position: relative; z-index: 1; }
.bars .k { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.bars .k small { color: var(--ink-3); margin-left: 6px; }
.bars .n { color: var(--ink-2); flex-shrink: 0; }
.bars .n em { font-style: normal; color: var(--ink-3); font-size: 11px; margin-left: 6px; display: inline-block; width: 40px; text-align: right; }
.list-head { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-3); padding: 4px 10px 6px; }

.donut-wrap { display: flex; align-items: center; gap: 22px; padding: 6px 0; }
.donut-legend { flex: 1; }
.donut-legend div { display: flex; justify-content: space-between; font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--line-2); }
.donut-legend div:last-child { border-bottom: 0; }
.donut-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 8px; }

.hours { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 10px; }
.hours div { flex: 1; background: #ebe8e2; border-radius: 3px 3px 0 0; position: relative; min-height: 2px; transition: background .15s; }
.hours div:hover { background: var(--accent); }
.hours div.peak { background: var(--grad); }
.hours-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-3); margin-top: 6px; }

.log { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow-y: auto; }
.log li { display: grid; grid-template-columns: 86px 1fr auto; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line-2); font-size: 13px; align-items: center; }
.log li:last-child { border-bottom: 0; }
.log .t { color: var(--ink-3); font-size: 12px; }
.log .main-l { min-width: 0; }
.log .main-l div:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log .meta { font-size: 12px; color: var(--ink-3); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rt-big { display: flex; align-items: baseline; gap: 10px; }
.rt-big .v { font-size: 56px; font-weight: 600; letter-spacing: -1px; line-height: 1; }

/* ---------- 弹窗 / 提示 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15,15,15,.45); display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px; z-index: 100; overflow-y: auto; animation: fade .15s; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 520px; box-shadow: 0 20px 60px rgba(0,0,0,.2); animation: rise .18s; }
.modal.wide { max-width: 720px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px 8px; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 10px 22px 6px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 22px 20px; }
.x { border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--ink-3); line-height: 1; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
pre.code { background: #141414; color: #f1efe9; border-radius: 9px; padding: 14px 16px; font-size: 12.5px; line-height: 1.6; overflow-x: auto; white-space: pre-wrap; word-break: break-all; margin: 0 0 10px; }
pre.code .c { color: #8b8b85; }
pre.code .a { color: #f7a35c; }
.cred { background: #faf8f4; border: 1px dashed #d9d5cc; border-radius: 9px; padding: 14px 16px; line-height: 1.9; }
.steps { padding-left: 18px; margin: 6px 0 14px; color: var(--ink-2); line-height: 1.8; font-size: 13px; }
#toast { position: fixed; left: 50%; top: 22px; transform: translateX(-50%); z-index: 200; }
#toast div { background: #141414; color: #fff; padding: 10px 16px; border-radius: 9px; margin-bottom: 8px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: rise .2s; }
#toast div.err { background: var(--bad); }

/* ---------- 登录 ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: var(--side); color: #fff; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-art h1 { font-size: 40px; font-weight: 600; line-height: 1.25; margin: 0 0 16px; letter-spacing: .5px; }
.login-art h1 span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-art p { color: #9c9c96; max-width: 420px; line-height: 1.8; margin: 0; }
.login-art .art-bars { position: absolute; right: 48px; bottom: 120px; display: flex; align-items: flex-end; gap: 12px; opacity: .9; }
.login-art .art-bars i { display: block; width: 26px; border-radius: 4px; background: var(--grad); }
.login-art .foot { color: #5f5f5a; font-size: 12px; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 40px; background: #fff; }
.login-form form { width: 100%; max-width: 340px; }
.login-form h2 { margin: 0 0 6px; font-size: 22px; }
.login-form .muted { margin-bottom: 26px; }
.login-form .inp { height: 42px; }
.login-form .btn { width: 100%; height: 42px; justify-content: center; font-size: 14px; margin-top: 6px; }
.login-err { color: var(--bad); font-size: 13px; min-height: 20px; margin-top: 10px; }

@media (max-width: 1200px) { .kpis { grid-template-columns: repeat(3, 1fr); } .kpi:nth-child(3) { border-right: 0; } .kpi:nth-child(-n+3) { border-bottom: 1px solid var(--line-2); } }
@media (max-width: 960px) {
  .side { display: none; }
  .main { padding: 20px 16px 40px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .mobile-nav { display: flex !important; }
}
.mobile-nav { display: none; gap: 6px; margin-bottom: 16px; overflow-x: auto; }
@media (max-width: 560px) { .kpis { grid-template-columns: repeat(2, 1fr); } .kpi { border-right: 0 !important; border-bottom: 1px solid var(--line-2); } .row2 { grid-template-columns: 1fr; } }
