:root {
  --bg0: #060b18;
  --bg1: #0a1428;
  --panel: rgba(16, 28, 52, 0.72);
  --panel-border: rgba(64, 158, 255, 0.28);
  --accent: #38bdf8;
  --accent2: #22d3ee;
  --ok: #34d399;
  --warn: #fbbf24;
  --demo: #a78bfa;
  --text: #e6f1ff;
  --text-dim: #8aa2c8;
  --grid: rgba(80, 140, 220, 0.08);
}

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

html, body {
  height: 100%;
  background:
    radial-gradient(1200px 700px at 75% -10%, rgba(34, 211, 238, 0.10), transparent 60%),
    radial-gradient(900px 600px at 10% 110%, rgba(56, 189, 248, 0.08), transparent 60%),
    linear-gradient(160deg, var(--bg0), var(--bg1));
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.scanline {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,0.012) 0 1px, transparent 1px 3px);
}

/* ---------------- Top bar ---------------- */
.topbar {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 32px;
  border-bottom: 1px solid var(--panel-border);
  background: linear-gradient(180deg, rgba(10,20,40,0.9), rgba(10,20,40,0.4));
  backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: 16px; }
.logo {
  width: 52px; height: 52px; border-radius: 14px;
  display: grid; place-items: center;
  font-size: 26px; font-weight: 800; color: #04121f;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  box-shadow: 0 0 22px rgba(56, 189, 248, 0.5);
}
.brand-text h1 { font-size: 26px; letter-spacing: 2px; font-weight: 700; }
.brand-text p { font-size: 12px; color: var(--text-dim); letter-spacing: 1px; margin-top: 2px; }

.status-cluster { text-align: right; }
.clock { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent2); letter-spacing: 2px; }
.meta { margin-top: 4px; display: flex; gap: 14px; align-items: center; justify-content: flex-end; font-size: 13px; color: var(--text-dim); }
.meta-item b { color: var(--text); font-weight: 600; }
.refresh-btn {
  background: rgba(56,189,248,0.12); color: var(--accent2);
  border: 1px solid var(--panel-border); border-radius: 8px;
  padding: 6px 14px; font-size: 13px; cursor: pointer; transition: .2s;
}
.refresh-btn:hover { background: rgba(56,189,248,0.25); }

/* ---------------- Layout ---------------- */
.layout {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 22px 32px 8px;
  max-width: 1680px; margin: 0 auto;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 18px 20px;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 40px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.04);
}
.cards-panel { grid-column: 1 / -1; }
.sources-panel { grid-column: 1 / -1; }

.panel-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 16px; border-left: 3px solid var(--accent); padding-left: 12px; }
.panel-head h2 { font-size: 19px; font-weight: 700; letter-spacing: 1px; }
.panel-sub { font-size: 12px; color: var(--text-dim); }

/* ---------------- Cards ---------------- */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.card {
  position: relative;
  background: linear-gradient(180deg, rgba(20,36,66,0.85), rgba(12,22,44,0.85));
  border: 1px solid var(--panel-border);
  border-radius: 14px; padding: 16px; overflow: hidden;
  transition: transform .2s, box-shadow .2s;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 10px 30px rgba(56,189,248,0.18); }
.card .city { font-size: 20px; font-weight: 700; }
.card .src-badge {
  position: absolute; top: 14px; right: 14px;
  font-size: 11px; padding: 3px 9px; border-radius: 20px;
  border: 1px solid var(--panel-border); color: var(--text-dim);
}
.src-badge.demo { color: var(--demo); border-color: rgba(167,139,250,0.4); background: rgba(167,139,250,0.1); }
.src-badge.live { color: var(--ok); border-color: rgba(52,211,153,0.4); background: rgba(52,211,153,0.08); }

.card-top { display: flex; align-items: flex-end; gap: 10px; margin: 6px 0 4px; }
.temp { font-size: 52px; font-weight: 800; line-height: 1; color: #fff; font-variant-numeric: tabular-nums; }
.temp-unit { font-size: 20px; color: var(--text-dim); margin-bottom: 8px; }
.cond { font-size: 15px; color: var(--accent2); margin-bottom: 12px; }

.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin-top: 10px; }
.metric { display: flex; flex-direction: column; }
.metric .k { font-size: 11px; color: var(--text-dim); }
.metric .v { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.metric .v small { font-size: 11px; color: var(--text-dim); font-weight: 400; }

.card-foot { margin-top: 12px; font-size: 11px; color: var(--text-dim); display: flex; justify-content: space-between; align-items: center; }
.card .mini-compass { position: absolute; right: 12px; bottom: 56px; opacity: 0.9; }

/* forecast strip */
.forecast { margin-top: 12px; display: flex; gap: 8px; border-top: 1px dashed rgba(120,160,220,0.2); padding-top: 10px; }
.fc-day { flex: 1; text-align: center; }
.fc-day .d { font-size: 11px; color: var(--text-dim); }
.fc-day .t { font-size: 13px; margin: 2px 0; }
.fc-day .r { font-size: 12px; color: var(--accent2); font-variant-numeric: tabular-nums; }

/* ---------------- Wind panel ---------------- */
.wind-body { display: grid; grid-template-columns: 1.15fr 1fr; gap: 20px; }
.wind-bars { display: flex; flex-direction: column; gap: 14px; justify-content: center; }
.wbar { display: grid; grid-template-columns: 64px 1fr 96px; align-items: center; gap: 10px; }
.wbar .name { font-size: 14px; font-weight: 600; }
.wbar .track { height: 16px; background: rgba(120,160,220,0.12); border-radius: 8px; overflow: hidden; }
.wbar .fill { height: 100%; border-radius: 8px; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .6s ease; box-shadow: 0 0 12px rgba(56,189,248,0.5); }
.wbar .val { font-size: 14px; text-align: right; font-variant-numeric: tabular-nums; }
.wbar .val small { color: var(--text-dim); font-size: 11px; }

.compass-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; align-content: center; }
.compass-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.compass-cell .cn { font-size: 13px; color: var(--text-dim); }

/* ---------------- Enterprise ---------------- */
.tag { font-size: 12px; padding: 2px 10px; border-radius: 20px; background: rgba(167,139,250,0.15); color: var(--demo); border: 1px solid rgba(167,139,250,0.4); vertical-align: middle; }
.tag.live { background: rgba(52,211,153,0.12); color: var(--ok); border-color: rgba(52,211,153,0.4); }
.ent-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.ent-card { background: linear-gradient(180deg, rgba(22,40,72,0.8), rgba(12,22,44,0.8)); border: 1px solid var(--panel-border); border-radius: 12px; padding: 14px; }
.ent-card .st { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.ent-card .st::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--accent2); box-shadow: 0 0 8px var(--accent2); }
.ent-card .st.live::before { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.ent-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.ent-grid .k { font-size: 11px; color: var(--text-dim); }
.ent-grid .v { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ent-grid .v small { font-size: 11px; color: var(--text-dim); font-weight: 400; }
.ent-note { margin-top: 12px; font-size: 12px; color: var(--text-dim); line-height: 1.6; }

/* ---------------- Sources ---------------- */
.sources { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.src-item { display: flex; flex-direction: column; gap: 6px; padding: 14px; border: 1px solid var(--panel-border); border-radius: 12px; background: rgba(12,22,44,0.6); }
.src-item .row1 { display: flex; justify-content: space-between; align-items: center; }
.src-item .nm { font-size: 15px; font-weight: 700; }
.src-item .st { font-size: 11px; padding: 2px 9px; border-radius: 20px; }
.st.s-ready { color: var(--ok); background: rgba(52,211,153,0.12); }
.st.s-need { color: var(--warn); background: rgba(251,191,36,0.12); }
.st.s-demo { color: var(--demo); background: rgba(167,139,250,0.12); }
.src-item .desc { font-size: 12px; color: var(--text-dim); line-height: 1.5; }
.src-item .cov { font-size: 11px; color: var(--accent2); }

/* ---------------- Foot ---------------- */
.foot { text-align: center; font-size: 12px; color: var(--text-dim); padding: 16px; position: relative; z-index: 1; }

@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .layout { grid-template-columns: 1fr; }
  .wind-body { grid-template-columns: 1fr; }
}

/* ---------------- History page ---------------- */
.nav { display: flex; gap: 10px; }
.nav-btn {
  background: rgba(56,189,248,0.10); color: var(--text-dim);
  border: 1px solid var(--panel-border); border-radius: 9px;
  padding: 8px 16px; font-size: 14px; text-decoration: none; letter-spacing: 1px; transition: .2s;
}
.nav-btn:hover { color: var(--accent2); background: rgba(56,189,248,0.2); }
.nav-btn.active { color: #04121f; background: linear-gradient(135deg, var(--accent2), var(--accent)); border-color: transparent; font-weight: 700; }
.history-layout { grid-template-columns: 1fr 1fr; }
.history-layout .panel:first-child { grid-column: 1 / -1; }
.history-layout .panel:last-child { grid-column: 1 / -1; }
.summary-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.sum-card {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(135deg, rgba(20,36,66,0.9), rgba(12,22,44,0.9));
  border: 1px solid var(--panel-border); border-left: 4px solid var(--accent2);
  border-radius: 14px; padding: 16px 22px;
  transition: transform .2s, box-shadow .2s;
}
.sum-card:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(0,0,0,0.3); }
.sum-card.tg { border-left-color: #f59e0b; }
.sum-card.mn { border-left-color: #38bdf8; }
.sum-left { display: flex; flex-direction: column; gap: 5px; }
.sum-title { font-size: 18px; font-weight: 700; color: #e6f1ff; letter-spacing: 1px; }
.sum-sub { font-size: 12px; color: var(--text-dim); letter-spacing: 0.5px; }
.sum-num { font-size: 44px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; text-align: right; }
.sum-card.tg .sum-num { color: #f59e0b; text-shadow: 0 0 18px rgba(245,158,11,0.35); }
.sum-card.mn .sum-num { color: #38bdf8; text-shadow: 0 0 18px rgba(56,189,248,0.35); }
.sum-unit { font-size: 16px; font-weight: 600; margin-left: 4px; opacity: 0.7; }
.chart-wrap { position: relative; height: 320px; }
.table-wrap { max-height: 460px; overflow: auto; }
.warn-table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
.warn-table th, .warn-table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--panel-border); }
.warn-table th { color: var(--text-dim); font-weight: 600; position: sticky; top: 0; background: var(--panel); }
.warn-table th:nth-child(4), .warn-table td:nth-child(4) { width: 110px; white-space: nowrap; }
.warn-table th:nth-child(5), .warn-table td:nth-child(5) { width: 100px; white-space: nowrap; }
.warn-table th:nth-child(1), .warn-table td:nth-child(1),
.warn-table th:nth-child(2), .warn-table td:nth-child(2) { width: 170px; white-space: nowrap; }
.warn-table th:nth-child(3), .warn-table td:nth-child(3) { width: 120px; white-space: nowrap; }
.warn-table tbody tr:hover { background: rgba(56,189,248,0.06); }
.empty-note { padding: 30px; text-align: center; color: var(--text-dim); line-height: 1.8; }

/* ---------------- Status cluster (nav + clock) ---------------- */
.status-cluster { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.status-cluster .nav { justify-content: flex-end; }

/* ---------------- Future wind forecast chart ---------------- */
.fc-chart-wrap { margin-top: 18px; padding-top: 16px; border-top: 1px dashed rgba(120,160,220,0.2); }
.fc-chart-title { font-size: 14px; color: var(--accent2); margin-bottom: 10px; letter-spacing: 1px; }
.fc-chart-canvas { position: relative; height: 260px; }

/* ---------------- Year selector & level tags ---------------- */
.year-selector { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.year-selector label { font-size: 14px; color: var(--text-dim); }
.year-selector select {
  background: rgba(12,22,44,0.8); color: var(--text); border: 1px solid var(--panel-border);
  border-radius: 8px; padding: 8px 16px; font-size: 15px; cursor: pointer; outline: none;
}
.year-selector select:focus { border-color: var(--accent); }
.year-count { font-size: 13px; color: var(--accent2); }
.export-btn {
  margin-left: auto; cursor: pointer;
  background: rgba(52,211,153,0.12); color: var(--ok);
  border: 1px solid rgba(52,211,153,0.4); border-radius: 8px;
  padding: 8px 18px; font-size: 14px; letter-spacing: 1px; transition: .2s;
}
.export-btn:hover { background: rgba(52,211,153,0.25); }
.lvl-tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 20px; border: 1px solid; }
