/* ============================================================
   ddkn.cn 缠论统计展示站 —— 样式
   独立、无外部依赖（不引用任何 CDN）
   ============================================================ */

:root {
    --bg:        #0b1220;
    --bg-soft:   #0f172a;
    --panel:     #151f33;
    --panel-2:   #1b2740;
    --border:    #26344f;
    --border-2:  #334155;
    --text:      #e6edf7;
    --text-dim:  #93a4bd;
    --text-mute: #6b7d99;
    --accent:    #38bdf8;
    --accent-2:  #22d3ee;
    --up:        #f2545b;   /* 涨（国内习惯：红） */
    --down:      #21c07a;   /* 跌（绿） */
    --warn:      #f5a524;
    --ok:        #22c55e;
    --radius:    10px;
    --shadow:    0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

/* ---------------- 顶栏 ---------------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 14px 22px;
    background: linear-gradient(180deg, #101a2e 0%, #0d1526 100%);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-text h1 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: .3px; }
.brand-text span { display: block; font-size: 11.5px; color: var(--text-mute); margin-top: 1px; }

.topbar-actions { display: flex; align-items: center; gap: 12px; }
.meta { font-size: 12px; color: var(--text-mute); font-variant-numeric: tabular-nums; }

.btn {
    appearance: none;
    border: 1px solid var(--border-2);
    background: var(--panel-2);
    color: var(--text);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #22314f; border-color: #3f5170; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: #0e7490; border-color: #0e7490; }
.btn-primary:hover { background: #0891b2; border-color: #0891b2; }
.btn-sm { padding: 3px 10px; font-size: 12px; border-radius: 6px; }

/* ---------------- 标签页 ---------------- */
.tabs {
    display: flex;
    gap: 2px;
    padding: 0 14px;
    background: var(--bg-soft);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: thin;
    position: sticky;
    top: 61px;
    z-index: 19;
}
.tab {
    appearance: none;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-dim);
    padding: 10px 14px;
    font-size: 13.5px;
    cursor: pointer;
    white-space: nowrap;
    transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ---------------- 布局 ---------------- */
.view { padding: 20px 22px 40px; max-width: 1560px; margin: 0 auto; }
.loading, .empty { padding: 44px 8px; text-align: center; color: var(--text-mute); font-size: 13.5px; }
.error-box {
    margin: 16px 0; padding: 14px 16px; border-radius: var(--radius);
    background: rgba(242,84,91,.09); border: 1px solid rgba(242,84,91,.4); color: #ffb4b8; font-size: 13px;
}
.error-box code { background: rgba(0,0,0,.35); padding: 1px 6px; border-radius: 4px; }

.section { margin-bottom: 22px; }
.section-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 0 0 10px; }
.section-head h2 { margin: 0; font-size: 15px; font-weight: 650; }
.section-head .hint { font-size: 12px; color: var(--text-mute); }

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 18px;
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h3 { margin: 0; font-size: 14px; font-weight: 620; color: #d5e2f5; }
.card-head .sub { font-size: 11.5px; color: var(--text-mute); font-weight: 400; margin-left: 8px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

/* ---------------- KPI ---------------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 12px; }
.kpi {
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 13px 15px;
}
.kpi .label { font-size: 11.5px; color: var(--text-mute); margin-bottom: 5px; }
.kpi .value { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: .2px; }
.kpi .value small { font-size: 12px; font-weight: 400; color: var(--text-dim); margin-left: 4px; }
.kpi .foot { font-size: 11px; color: var(--text-mute); margin-top: 4px; }

/* ---------------- 图表 ---------------- */
.chart { width: 100%; height: 340px; }
.chart.tall { height: 420px; }
.chart.short { height: 280px; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 16px; }

/* ---------------- 统计量 ---------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 10px; }
.stat { background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; }
.stat .k { font-size: 11px; color: var(--text-mute); }
.stat .v { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }

/* ---------------- 表单 ---------------- */
.controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.control { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-dim); }
select, input[type="text"], input[type="number"] {
    appearance: none;
    background: var(--panel-2);
    color: var(--text);
    border: 1px solid var(--border-2);
    border-radius: 7px;
    padding: 5px 9px;
    font-size: 12.5px;
    min-width: 84px;
}
select:focus, input:focus { outline: none; border-color: var(--accent); }
.seg-btns { display: inline-flex; border: 1px solid var(--border-2); border-radius: 7px; overflow: hidden; }
.seg-btns button {
    appearance: none; border: none; background: var(--panel-2); color: var(--text-dim);
    padding: 5px 12px; font-size: 12.5px; cursor: pointer; border-right: 1px solid var(--border-2);
}
.seg-btns button:last-child { border-right: none; }
.seg-btns button.is-active { background: #0e7490; color: #fff; font-weight: 600; }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow: auto; max-height: 620px; border: 1px solid var(--border); border-radius: 8px; }
table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data th, table.data td { padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data thead th {
    position: sticky; top: 0; background: #182238; color: var(--text-dim);
    font-weight: 550; font-size: 11.5px; z-index: 1; cursor: default;
}
table.data thead th.sortable { cursor: pointer; user-select: none; }
table.data thead th.sortable:hover { color: var(--accent); }
table.data tbody tr:hover { background: rgba(56,189,248,.06); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.5px; }

.pager { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 12px; color: var(--text-dim); }
.pager button { appearance: none; background: var(--panel-2); color: var(--text); border: 1px solid var(--border-2);
    border-radius: 6px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
.pager button:disabled { opacity: .45; cursor: not-allowed; }

/* ---------------- 徽标 / 提示 ---------------- */
.badge { display: inline-block; padding: 1px 7px; border-radius: 99px; font-size: 11px; line-height: 1.6; }
.badge.ok   { background: rgba(34,197,94,.16);  color: #6ee7a8; }
.badge.bad  { background: rgba(242,84,91,.16);  color: #ffa8ad; }
.badge.dim  { background: rgba(148,163,184,.14); color: #a8b7cc; }
.badge.warn { background: rgba(245,165,36,.16); color: #f7c46c; }

.note { font-size: 11.5px; color: var(--text-mute); margin-top: 8px; line-height: 1.6; }
.copy-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.copy-row code {
    background: #0b1220; border: 1px solid var(--border); padding: 6px 10px; border-radius: 7px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; color: var(--accent-2);
    word-break: break-all;
}

/* ---------------- 页脚 ---------------- */
.footer {
    display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap;
    padding: 14px 22px 26px; color: var(--text-mute); font-size: 11.5px;
    border-top: 1px solid var(--border); margin-top: 12px;
}
.footer-meta { line-height: 1.7; }
.footer-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.footer-health { font-variant-numeric: tabular-nums; }
/* ICP 备案号：按工信部要求公开展示在页脚，链接到备案查询系统 */
.footer-icp {
    color: var(--text-dim);
    text-decoration: none;
    padding: 2px 9px;
    border: 1px solid var(--border);
    border-radius: 99px;
    white-space: nowrap;
    transition: color .15s, border-color .15s;
}
.footer-icp:hover { color: var(--accent); border-color: var(--accent); }

/* ---------------- Toast ---------------- */
.toast {
    position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
    background: #1e293b; border: 1px solid var(--border-2); color: var(--text);
    padding: 9px 18px; border-radius: 99px; font-size: 13px; z-index: 100;
    box-shadow: 0 10px 30px -10px rgba(0,0,0,.8);
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 860px) {
    .view { padding: 14px 12px 30px; }
    .topbar { padding: 12px 14px; }
    .tabs { top: 0; position: static; }
    .chart { height: 300px; }
    .chart.tall { height: 340px; }
    .grid-2 { grid-template-columns: 1fr; }
}
