/* 渠道差价维护系统 · Clean Data Stream 基底（frontend-dev）
   配色方向：ui-ux-pro-max 检索（Analytics Dashboard 蓝调 slate 板 + Professional navy 侧栏 + 密度 8/10）
   精修准则：impeccable craft-floor / polish（对比度 ≥4.5:1、浏览器表面主题化、reduced-motion、语义 token） */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #eff6ff;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #64748b;
  --line: #e2e8f0;
  --line-soft: #eef2f7;
  --bg: #f8fafc;
  --head-bg: #f1f5f9;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --red-line: #fecaca;
  --green: #16a34a;
  --green-bg: #f0fdf4;
  --green-line: #bbf7d0;
  --amber: #d97706;
  --amber-bg: #fffbeb;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-muted: #8b9bb0;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, .08);
  --radius: 12px;
}
html { -webkit-font-smoothing: antialiased; }
body { font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
::selection { background: #bfdbfe; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 4px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── 布局 ── */
.layout { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; padding: 28px 32px 52px; }
.page-title { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.page-desc { color: var(--text-3); font-size: 13px; margin-top: 5px; margin-bottom: 24px; }

/* ── 深色侧栏（截图同款 · navy） ── */
.sidebar { width: 216px; flex-shrink: 0; background: var(--sidebar-bg); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .14); border: none; border-radius: 2px; }
.side-logo { padding: 22px 20px 6px; font-size: 15px; font-weight: 700; color: #fff; letter-spacing: .01em; }
.side-logo-sub { padding: 0 20px 18px; font-size: 11px; color: var(--sidebar-muted); }
.side-nav { flex: 1; padding: 0 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 8px; color: var(--sidebar-text); text-decoration: none; font-size: 13px; transition: background .15s, color .15s; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item:hover { color: #e2e8f0; background: rgba(255, 255, 255, .07); text-decoration: none; }
.nav-item:focus-visible { outline-color: #93c5fd; }
.nav-item.active { color: #fff; background: var(--accent); font-weight: 600; box-shadow: 0 2px 8px rgba(37, 99, 235, .35); }
.side-foot { padding: 14px 20px; border-top: 1px solid rgba(255, 255, 255, .08); display: flex; align-items: center; justify-content: space-between; }
.side-foot .who { font-size: 12px; color: var(--sidebar-muted); }
.side-foot a { font-size: 12px; color: var(--sidebar-text); text-decoration: none; }
.side-foot a:hover { color: #fff; }

/* ── 卡片（一行排列 · 文字居中 · 色点极简） ── */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 26px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; text-align: center; box-shadow: var(--shadow-sm); transition: box-shadow .15s; }
.card:hover { box-shadow: var(--shadow-md); }
.card .label { font-size: 12px; color: var(--text-3); display: flex; align-items: center; justify-content: center; gap: 6px; }
.card .dot { width: 7px; height: 7px; border-radius: 50%; }
.card .value { font-size: 25px; font-weight: 800; margin-top: 6px; letter-spacing: -.02em; }
.card .sub { font-size: 12px; color: var(--text-3); margin-top: 3px; }

/* ── 区块与表格 ── */
.section { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 22px; box-shadow: var(--shadow-sm); }
.section-head { padding: 14px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.section-title { font-size: 14px; font-weight: 600; }
.section-foot { padding: 12px 20px; border-top: 1px solid var(--line); color: var(--text-3); font-size: 12px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--text-3); font-weight: 500; padding: 10px 18px; background: var(--head-bg); white-space: nowrap; }
th[onclick] { cursor: pointer; user-select: none; }
th[onclick]:hover { color: var(--accent); }
td { padding: 10px 18px; border-top: 1px solid var(--line-soft); font-size: 13px; }
tbody tr { transition: background .12s; }
tr:hover td { background: var(--bg); }
/* 表头固定：表格放进独立滚动容器（.tblwrap），只有数据行滚动 */
.tblwrap { overflow: auto; max-height: calc(100vh - 300px); }
.tblwrap::-webkit-scrollbar { width: 8px; height: 8px; }
.tblwrap::-webkit-scrollbar-thumb { background: #cbd5e1; border: none; border-radius: 4px; }
.tblwrap table { border-collapse: separate; border-spacing: 0; }
.tblwrap thead th { position: sticky; top: 0; z-index: 10; background: var(--head-bg); box-shadow: 0 1px 0 var(--line); }
.num { font-variant-numeric: tabular-nums; }
/* 已对接本站行：平台色的加深版（未对接行不着色，2026-09-11 主人要求） */
tr.imp-ok td { background: var(--green-bg); }
tr.imp-ok:hover td { background: #e5f7ec; }
tr.imp-ok.plat-claude td { background: #ead9ff; }
tr.imp-ok.plat-claude:hover td { background: #ddc2ff; }
tr.imp-ok.plat-gpt td { background: #b8f2e6; }
tr.imp-ok.plat-gpt:hover td { background: #9ae9d8; }
tr.imp-ok.plat-gemini td { background: #c7ddfc; }
tr.imp-ok.plat-gemini:hover td { background: #aacbfb; }
tr.imp-ok.plat-deepseek td { background: #ffdfc0; }
tr.imp-ok.plat-deepseek:hover td { background: #ffcda1; }
tr.imp-ok.plat-glm td { background: #fbd0e5; }
tr.imp-ok.plat-glm:hover td { background: #f8b4d4; }
tr.imp-ok.plat-grok td { background: #e7e5e4; }
tr.imp-ok.plat-grok:hover td { background: #d6d3d1; }
tr.imp-ok.plat-kimi td { background: #f9f0bb; }
tr.imp-ok.plat-kimi:hover td { background: #f5e68f; }
tr.imp-ok.plat-qwen td { background: #c8e7fa; }
tr.imp-ok.plat-qwen:hover td { background: #a5d8f6; }
/* 本站渠道页：按分组着色（12 色循环，2026-09-11 主人要求） */
tr.sg-0 td { background: #ead9ff; } tr.sg-0:hover td { background: #ddc2ff; }
tr.sg-1 td { background: #b8f2e6; } tr.sg-1:hover td { background: #9ae9d8; }
tr.sg-2 td { background: #c7ddfc; } tr.sg-2:hover td { background: #aacbfb; }
tr.sg-3 td { background: #ffdfc0; } tr.sg-3:hover td { background: #ffcda1; }
tr.sg-4 td { background: #fbd0e5; } tr.sg-4:hover td { background: #f8b4d4; }
tr.sg-5 td { background: #f9f0bb; } tr.sg-5:hover td { background: #f5e68f; }
tr.sg-6 td { background: #c8e7fa; } tr.sg-6:hover td { background: #a5d8f6; }
tr.sg-7 td { background: #d8f5c8; } tr.sg-7:hover td { background: #bdeea4; }
tr.sg-8 td { background: #ffd6d6; } tr.sg-8:hover td { background: #ffb8b8; }
tr.sg-9 td { background: #e0e0f8; } tr.sg-9:hover td { background: #c6c6f2; }
tr.sg-10 td { background: #f0e6d2; } tr.sg-10:hover td { background: #e6d4b4; }
tr.sg-11 td { background: #e7e5e4; } tr.sg-11:hover td { background: #d6d3d1; }
.right { text-align: right; }

/* ── 徽标 ── */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge.ok { color: var(--green); background: var(--green-bg); }
.badge.err { color: var(--red); background: var(--red-bg); }
.badge.warn { color: var(--amber); background: var(--amber-bg); }
.badge.info { color: var(--accent); background: var(--accent-light); }
.badge.gray { color: var(--text-2); background: var(--line); }

/* ── 按钮（触感反馈 scale .98） ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 16px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--text-2); font-size: 13px; cursor: pointer; text-decoration: none; transition: all .15s; white-space: nowrap; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; box-shadow: 0 1px 3px rgba(37, 99, 235, .3); }
.btn.primary:hover { background: var(--accent-hover); color: #fff; }
.btn.sm { padding: 4px 12px; font-size: 12px; }
.btn.danger { color: var(--red); border-color: var(--red-line); }
.btn.danger:hover { background: var(--red-bg); border-color: var(--red); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── 表单控件 ── */
.input, .select { padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; outline: none; background: #fff; color: var(--text); caret-color: var(--accent); transition: border-color .15s, box-shadow .15s; }
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.input::placeholder { color: var(--text-3); }
.select { cursor: pointer; }
input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }
.filters { padding: 12px 20px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; border-bottom: 1px solid var(--line); }

/* ── 弹窗 ── */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 50; overflow: auto; backdrop-filter: blur(2px); }
.modal-box { background: #fff; margin: 56px auto; max-width: 1100px; border-radius: 14px; padding: 20px 24px; box-shadow: 0 20px 60px rgba(15, 23, 42, .25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; }
.modal-title { font-size: 15px; font-weight: 700; }

/* ── 简易条形 ── */
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-track { flex: 1; height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width .4s; }
.bar-fill.green { background: var(--green); }
.bar-fill.amber { background: var(--amber); }
.bar-fill.red { background: var(--red); }

/* ── 其他 ── */
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--text-2); }
.muted { color: var(--text-3); font-size: 12px; }
.banner { display: flex; align-items: center; gap: 10px; padding: 11px 18px; border-radius: 10px; font-size: 13px; margin-bottom: 20px; flex-wrap: wrap; }
.banner.red { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-line); }
.banner.blue { background: var(--accent-light); color: var(--accent); border: 1px solid #bfdbfe; }
.tabs { display: flex; gap: 6px; align-items: center; }
.tab { padding: 5px 14px; border-radius: 7px; font-size: 12px; color: var(--text-2); background: var(--bg); border: 1px solid var(--line); cursor: pointer; transition: all .12s; }
.tab:hover { color: var(--accent); border-color: var(--accent); }
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.actions { display: flex; gap: 8px; align-items: center; }
.skeleton { background: linear-gradient(90deg, var(--line) 25%, #f3f4f6 50%, var(--line) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 6px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
a { color: var(--accent); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
td a { text-decoration: none; }
td a:hover { text-decoration: underline; }

/* ── 仪表盘原型组件（2026-09-11 首页重写） ── */
.topbar { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.topbar .page-sub { color: var(--text-3); font-size: 13px; margin-top: 4px; }
.status-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 20px; background: #fff; border: 1px solid var(--line); font-size: 12px; color: var(--text-2); }
.pill .pdot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .35); } 50% { box-shadow: 0 0 0 4px rgba(22, 163, 74, 0); } }
.grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(300px, 3fr); gap: 16px; align-items: start; }
.grid .col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.grid .col .section { margin-bottom: 0; }
.section-title .sq { width: 8px; height: 8px; border-radius: 3px; background: var(--accent); display: inline-block; margin-right: 8px; }
.card .value.green { color: var(--green); }
.card .value.red { color: var(--red); }
.card .value.blue { color: var(--accent); }
/* 收支双色柱状图 */
.chart { display: flex; align-items: flex-end; gap: 5px; height: 130px; padding: 18px 18px 4px; }
.chart .col-bars { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 2px; height: 100%; cursor: pointer; }
.chart .b-inc { width: 42%; background: var(--accent); border-radius: 3px 3px 0 0; opacity: .9; transition: opacity .12s; }
.chart .b-cost { width: 42%; background: #cbd5e1; border-radius: 3px 3px 0 0; transition: background .12s; }
.chart .col-bars:hover .b-inc { opacity: 1; }
.chart .col-bars:hover .b-cost { background: #94a3b8; }
.chart-x { display: flex; gap: 5px; padding: 6px 18px 12px; }
.chart-x span { flex: 1; text-align: center; font-size: 10px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-3); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }
/* 时间线 */
.timeline { padding: 14px 18px; }
.tl-item { position: relative; padding: 0 0 16px 22px; }
.tl-item:last-child { padding-bottom: 2px; }
.tl-item::before { content: ''; position: absolute; left: 5px; top: 16px; bottom: -2px; width: 1px; background: var(--line); }
.tl-item:last-child::before { display: none; }
.tl-dot { position: absolute; left: 0; top: 4px; width: 11px; height: 11px; border-radius: 50%; border: 2.5px solid var(--accent); background: #fff; }
.tl-dot.red { border-color: var(--red); }
.tl-dot.amber { border-color: var(--amber); }
.tl-time { font-size: 11px; color: var(--text-3); }
.tl-body { font-size: 13px; margin-top: 2px; line-height: 1.55; }
/* 告警行 */
.alert-row { display: flex; gap: 10px; padding: 10px 18px; border-top: 1px solid var(--line-soft); font-size: 13px; align-items: flex-start; }
.alert-row:first-of-type { border-top: none; }
@media (max-width: 1200px) { .grid { grid-template-columns: 1fr; } }

/* ── 移动端适配（≤860px · 2026-09-13 主人要求 · ui-ux-pro-max 移动端准则） ──
   抽屉式侧栏 / 触控目标 ≥34px / 输入框 16px 防 iOS 聚焦缩放 / 表格横滑+表头固定 / 安全区适配 */
.mobile-topbar { display: none; }
.scrim { display: none; }
@media (max-width: 860px) {
  html, body { overflow-x: hidden; }
  body { overscroll-behavior-y: none; }  /* 防误触下拉刷新 */
  /* 顶部栏 + 汉堡按钮（触控目标 40px） */
  .mobile-topbar { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 55;
    background: var(--sidebar-bg); color: #fff; font-size: 15px; font-weight: 700;
    padding: 12px 14px; padding-top: calc(12px + env(safe-area-inset-top)); }
  .menu-btn { width: 40px; height: 40px; flex-shrink: 0; border: none; background: rgba(255,255,255,.09);
    border-radius: 10px; color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }
  .menu-btn svg { width: 20px; height: 20px; }
  .menu-btn:active { transform: scale(.94); }
  /* 侧栏 → 左滑抽屉 + 遮罩 */
  .layout { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; height: 100vh; height: 100dvh; width: 250px; z-index: 60;
    transform: translateX(-105%); transition: transform .22s ease; }
  .sidebar.open { transform: none; box-shadow: 0 0 60px rgba(15,23,42,.5); }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 59;
    opacity: 0; pointer-events: none; transition: opacity .2s; }
  .scrim.show { opacity: 1; pointer-events: auto; }
  .nav-item { padding: 12px 14px; font-size: 14px; }  /* 触控目标 ≥44px */
  .nav-item svg { width: 18px; height: 18px; }
  /* 主区收窄 */
  .main { padding: 16px 12px calc(40px + env(safe-area-inset-bottom)); }
  .page-title { font-size: 18px; }
  .page-desc { font-size: 12px; margin-bottom: 16px; }
  /* 卡片两列等分 */
  .cards { grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 16px; }
  .card { padding: 12px 10px; }
  .card .value { font-size: 21px; }
  /* 区块紧凑 */
  .section { border-radius: 10px; margin-bottom: 14px; }
  .section-head { padding: 12px 14px; }
  .section-foot { padding: 10px 14px; }
  /* 筛选控件：自动平分换行，16px 字号防 iOS 聚焦自动缩放 */
  .filters { padding: 10px 12px; gap: 8px; }
  .filters .input, .filters .select { flex: 1 1 44%; min-width: 0; font-size: 16px; padding: 9px 10px; }
  .filters .input[id="kw"] { flex-basis: 100%; }  /* 搜索框独占一行 */
  /* 表格：横向滑动 + 内部纵滚保住表头固定（铁律） */
  .tblwrap { -webkit-overflow-scrolling: touch; max-height: calc(100dvh - 210px); }
  /* 未包 tblwrap 的表格（设置页等）：表格自身可横滑，防止被裁掉 */
  .section > table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  th, td { padding: 8px 10px; font-size: 12px; }
  th { font-size: 11px; }
  /* 按钮触控目标加大 */
  .btn { min-height: 38px; padding: 8px 14px; }
  .btn.sm { min-height: 34px; padding: 6px 12px; font-size: 13px; }
  input[type="checkbox"] { width: 18px; height: 18px; }
  /* 弹窗近全屏 */
  .modal-box { margin: 12px auto; max-width: calc(100vw - 20px); padding: 14px 14px; border-radius: 10px; }
  /* 首页组件紧凑 */
  .topbar { margin-bottom: 14px; }
  .pill { padding: 5px 10px; font-size: 11px; }
  .chart { height: 110px; padding: 14px 12px 4px; }
  .chart-x { padding: 6px 12px 10px; }
  .banner { padding: 10px 12px; font-size: 12px; }
}
