/* Wenzhou Risk Dashboard — Unified Styles */
:root {
  --pri: #c62828; --ok: #00897b; --warn: #e65100; --info: #1565c0; --gold: #f59e0b;
  --bg: #f0f4f8; --card-bg: #fff; --text: #1e293b; --muted: #64748b; --border: #e2e8f0;
  --radius: 16px; --shadow: 0 2px 16px rgba(0,0,0,0.07);
}

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

body {
  font-family: 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh;
}

/* ── header ── */
.hdr {
  background: linear-gradient(135deg, #1a0505 0%, #3b0a0a 40%, #7b1a1a 70%, var(--pri) 100%);
  color: #fff; padding: 0 32px; position: relative; overflow: hidden;
}
.hdr::before {
  content: ''; position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C%2Fg%3E%3C%2Fsvg%3E");
  pointer-events: none;
}
.hdr-inner { max-width: 1440px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 18px 0; position: relative; z-index: 1; }
.hdr-left { display: flex; align-items: center; gap: 14px; }
.hdr-emblem { width: 48px; height: 48px; background: rgba(255,255,255,.12); border: 1.5px solid rgba(255,255,255,.25); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; backdrop-filter: blur(4px); }
.hdr-title h1 { font-size: 1.2rem; font-weight: 800; letter-spacing: .04em; }
.hdr-title p { font-size: .74rem; color: rgba(255,255,255,.6); margin-top: 2px; }
.hdr-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hdr-badge { padding: 5px 14px; border-radius: 20px; font-size: .78rem; font-weight: 600; border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.1); color: #fff; white-space: nowrap; }
.hdr-badge.alert-red { background: rgba(198,40,40,.5); border-color: rgba(255,100,100,.5); animation: pulse 1.8s infinite; }
.hdr-badge.alert-orange { background: rgba(230,81,0,.45); border-color: rgba(255,140,0,.45); }
.hdr-badge.alert-yellow { background: rgba(249,168,37,.3); border-color: rgba(249,200,50,.4); }
.hdr-badge.alert-green { background: rgba(0,137,123,.35); border-color: rgba(0,200,170,.4); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(198,40,40,.4); } 50% { box-shadow: 0 0 0 8px rgba(198,40,40,0); } }

/* ── tabs ── */
.tab-bar { background: #fff; border-bottom: 2px solid var(--border); position: sticky; top: 0; z-index: 50; box-shadow: 0 2px 10px rgba(0,0,0,.07); }
.tab-inner { max-width: 1440px; margin: 0 auto; padding: 0 32px; display: flex; align-items: center; gap: 0; overflow-x: auto; }
.tab-btn { padding: 15px 22px; font-size: .88rem; font-weight: 700; color: var(--muted); border: none; background: none; cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; transition: .2s; white-space: nowrap; }
.tab-btn:hover { color: var(--pri); }
.tab-btn.act { color: var(--pri); border-bottom-color: var(--pri); }

/* ── content / cards ── */
.content { max-width: 1440px; margin: 0 auto; padding: 24px 32px; }
.tab-page { display: none; }
.tab-page.on { display: block; }
.card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 20px; }
.card-title { font-size: .95rem; font-weight: 800; color: var(--text); margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.ct-bar { width: 4px; height: 18px; border-radius: 2px; background: var(--pri); }
.card-sub { font-size: .76rem; color: #94a3b8; margin-left: auto; font-weight: 400; }

/* ── grids ── */
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.g3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.g5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.g13 { display: grid; grid-template-columns: 1.4fr 2fr; gap: 20px; }
.mb20 { margin-bottom: 20px; }

/* ── KPIs ── */
.kpi-strip { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 20px; }
.kpi { background: var(--card-bg); border-radius: 14px; padding: 18px 20px; box-shadow: var(--shadow); border-left: 5px solid var(--c, var(--pri)); display: flex; align-items: center; gap: 14px; }
.kpi-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--bg, #ffebee); display: flex; align-items: center; justify-content: center; font-size: 1.3rem; flex-shrink: 0; }
.kpi-val { font-size: 1.75rem; font-weight: 900; color: var(--c, var(--pri)); line-height: 1; }
.kpi-lbl { font-size: .75rem; color: var(--muted); margin-top: 3px; }
.kpi-chg { font-size: .72rem; margin-top: 2px; font-weight: 600; }
.up { color: var(--pri); }
.dn { color: var(--ok); }

/* ── alert levels ── */
.alert-strip { display: flex; gap: 10px; margin-bottom: 20px; }
.alv { flex: 1; padding: 14px; border-radius: 12px; text-align: center; border: 2px solid transparent; transition: .2s; }
.alv.cur { transform: scale(1.05); box-shadow: 0 6px 24px rgba(0,0,0,.18); }
.alv-none { background: #f1f5f9; border-color: #cbd5e1; color: #475569; }
.alv-low { background: #e8f5e9; border-color: #c8e6c9; color: #1b5e20; }
.alv-mid { background: #fff8e1; border-color: #ffecb3; color: #e65100; }
.alv-high { background: #fff3e0; border-color: #ffe0b2; color: #bf360c; }
.alv-crit { background: #ffebee; border-color: #ffcdd2; color: #b71c1c; }
.alv-num { font-size: 1.5rem; font-weight: 900; line-height: 1.1; }
.alv-name { font-size: .8rem; font-weight: 700; margin: 4px 0 2px; }
.alv-range { font-size: .68rem; opacity: .75; }

/* ── tables ── */
.dtable { width: 100%; border-collapse: collapse; font-size: .84rem; }
.dtable thead tr { background: #f8fafc; }
.dtable th { padding: 9px 14px; text-align: left; font-weight: 700; color: var(--muted); font-size: .74rem; text-transform: uppercase; border-bottom: 1px solid var(--border); }
.dtable td { padding: 9px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.dtable tr:last-child td { border-bottom: none; }

/* ── tags ── */
.tag { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: .72rem; font-weight: 700; }
.tag-none { background: #f1f5f9; color: #475569; }
.tag-low { background: #dcfce7; color: #166534; }
.tag-mid { background: #fef9c3; color: #854d0e; }
.tag-high { background: #fff3e0; color: #9a3412; }
.tag-crit { background: #fef2f2; color: #991b1b; }

/* ── formulas ── */
.formula-box { background: #0f1923; color: #e2e8f0; font-family: 'Consolas', 'Courier New', monospace; font-size: .83rem; padding: 18px 22px; border-radius: 12px; line-height: 2; overflow-x: auto; margin: 14px 0; }
.formula-box .cm { color: #6b7280; }
.formula-box .op { color: #60cdff; font-weight: 600; }
.formula-box .weight { color: #f59e0b; font-weight: 700; }
.formula-box .val { color: #4ade80; }

/* ── loading skeleton ── */
.skeleton { background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: 8px; }
.skeleton-chart { width: 100%; height: 300px; }
.skeleton-text { height: 16px; width: 60%; margin: 8px 0; }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

/* ── method box ── */
.method-box { background: linear-gradient(135deg, #fff7f0, #fff5f5); border: 1.5px solid #fecdd3; border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.method-title { font-size: .92rem; font-weight: 800; color: var(--pri); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.method-body { font-size: .8rem; color: #475569; line-height: 1.9; }

/* ── weight bars ── */
.wt-bar-wrap { margin: 12px 0; }
.wt-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.wt-bar-label { font-size: .78rem; font-weight: 700; min-width: 120px; color: var(--text); }
.wt-bar-track { flex: 1; height: 18px; background: #f1f5f9; border-radius: 9px; overflow: hidden; position: relative; }
.wt-bar-fill { height: 100%; border-radius: 9px; display: flex; align-items: center; padding-left: 8px; font-size: .72rem; font-weight: 700; color: #fff; transition: .6s; }
.wt-bar-pct { font-size: .78rem; font-weight: 700; min-width: 36px; text-align: right; }

/* ── gauge ── */
.gauge-wrap { position: relative; display: flex; flex-direction: column; align-items: center; padding: 10px 0; }

/* ── responsive ── */
@media (max-width: 1024px) {
  .g2, .g13 { grid-template-columns: 1fr; }
  .g5, .kpi-strip { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .content { padding: 12px 10px; }
  .hdr { padding: 0 12px; }
  .hdr-inner { flex-wrap: wrap; }
  .g5, .kpi-strip { grid-template-columns: 1fr; }
  .g2, .g13, .g3 { grid-template-columns: 1fr; }
}
