:root {
  --bg: #040b1a;
  --panel: rgba(8, 26, 54, 0.78);
  --line: rgba(58, 209, 255, 0.28);
  --cyan: #3ad1ff;
  --txt: #d6e6ff;
  --dim: #7f97b8;
  --green: #22e39a;
  --yellow: #ffd23f;
  --orange: #ff8a1f;
  --red: #ff3b4e;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: radial-gradient(ellipse at 50% 0%, #0c2550 0%, var(--bg) 60%) fixed;
  color: var(--txt);
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  font-size: 13px;
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; }

/* ---------- 顶部 ---------- */
.hd {
  height: 64px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(14, 45, 92, 0.9), rgba(4, 11, 26, 0.4));
}
.hd-left { display: flex; align-items: center; gap: 12px; }
.logo { width: 40px; height: 40px; color: var(--cyan); fill: var(--cyan); filter: drop-shadow(0 0 6px var(--cyan)); }
.hd h1 {
  font-size: 24px; letter-spacing: 4px; font-weight: 700;
  background: linear-gradient(180deg, #ffffff, #8fdcff); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hd .sub { font-size: 11px; color: var(--dim); letter-spacing: 1px; margin-top: 2px; }
.nav { display: flex; gap: 4px; margin-left: 22px; }
.nav a { color: var(--dim); text-decoration: none; padding: 7px 14px; border-radius: 4px; font-size: 14px; border: 1px solid transparent; }
.nav a:hover { color: #fff; border-color: var(--line); }
.nav a.active { color: #fff; background: rgba(58, 209, 255, 0.18); border-color: var(--cyan); }
.hd-right { display: flex; align-items: center; gap: 18px; }
.sim-ctl { display: flex; align-items: center; gap: 6px; }
.ctl-label { color: var(--dim); font-size: 12px; margin-right: 2px; }
.sim-ctl button {
  background: rgba(58, 209, 255, 0.08); border: 1px solid var(--line); color: var(--txt);
  padding: 5px 10px; border-radius: 4px; font-size: 12px;
}
.sim-ctl button:hover { border-color: var(--cyan); }
.sim-ctl button.active { background: rgba(58, 209, 255, 0.3); border-color: var(--cyan); color: #fff; }
.sim-ctl .btn-warn { border-color: rgba(255, 138, 31, 0.6); color: #ffc58f; }
.clock { display: flex; flex-direction: column; align-items: flex-end; min-width: 150px; }
.clock span { color: var(--dim); font-size: 12px; }
.clock b { font-size: 26px; font-family: "DIN Alternate", "Consolas", monospace; color: #fff; letter-spacing: 2px; }

/* ---------- 布局 ---------- */
.grid {
  height: calc(100vh - 64px); display: grid; grid-template-columns: 300px minmax(0, 1fr) 340px;
  gap: 10px; padding: 10px;
}
.col { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 10px 12px; position: relative; min-height: 0;
  box-shadow: inset 0 0 24px rgba(58, 209, 255, 0.06);
}
.panel::before, .panel::after {
  content: ""; position: absolute; width: 10px; height: 10px; border: 2px solid var(--cyan);
}
.panel::before { left: -1px; top: -1px; border-right: 0; border-bottom: 0; }
.panel::after { right: -1px; bottom: -1px; border-left: 0; border-top: 0; }
.panel.grow { flex: 1; display: flex; flex-direction: column; }
.panel h3 {
  font-size: 15px; font-weight: 600; padding-left: 10px; margin-bottom: 8px;
  border-left: 3px solid var(--cyan); line-height: 1.1; display: flex; align-items: center; gap: 8px;
}
.panel h3 small { color: var(--dim); font-weight: 400; font-size: 11px; }
.ai-tag {
  font-size: 10px; padding: 1px 6px; border-radius: 3px; color: #fff;
  background: linear-gradient(90deg, #7c4dff, #3ad1ff);
}

/* ---------- KPI ---------- */
.kpi { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpi .k {
  background: rgba(58, 209, 255, 0.06); border: 1px solid rgba(58, 209, 255, 0.15); border-radius: 4px;
  padding: 6px 8px; text-align: center;
}
.kpi .k b { display: block; font-size: 24px; font-family: "DIN Alternate", Consolas, monospace; color: #fff; }
.kpi .k b small { font-size: 13px; color: var(--dim); }
.kpi .k > span { color: var(--dim); font-size: 12px; }

/* ---------- 风场卡片 ---------- */
.farms { display: flex; flex-direction: column; gap: 6px; }
.farm-card {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 7px 9px; border-radius: 4px;
  background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(58, 209, 255, 0.12); cursor: pointer;
}
.farm-card:hover, .farm-card.active { border-color: var(--cyan); background: rgba(58, 209, 255, 0.1); }
.farm-card .fn { font-weight: 600; font-size: 14px; }
.farm-card .fn i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--c); }
.farm-card .fm { color: var(--dim); font-size: 12px; }
.farm-card .fr { text-align: right; }
.lv-badge { font-size: 11px; padding: 1px 6px; border-radius: 3px; color: #04101f; font-weight: 600; background: var(--c); white-space: nowrap; }

/* ---------- 船舶列表 ---------- */
.ship-list { overflow-y: auto; flex: 1; }
.ship-row {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 6px; padding: 6px 8px; border-radius: 4px;
  border: 1px solid transparent; cursor: pointer; margin-bottom: 3px; background: rgba(255, 255, 255, 0.02);
}
.ship-row:hover { background: rgba(58, 209, 255, 0.08); }
.ship-row.sel { border-color: var(--cyan); background: rgba(58, 209, 255, 0.14); }
.ship-row.danger { border-color: var(--red); animation: blink 1s infinite; }
.ship-row .sn { font-weight: 600; }
.ship-row .sn em { font-style: normal; color: var(--dim); font-weight: 400; font-size: 11px; margin-left: 4px; }
.ship-row .si { color: var(--dim); font-size: 12px; grid-column: 1 / -1; display: flex; justify-content: space-between; }
.st-badge { font-size: 11px; padding: 1px 7px; border-radius: 10px; border: 1px solid var(--c); color: var(--c); white-space: nowrap; }

/* ---------- 地图 ---------- */
.center .map-wrap { flex: 1; padding: 0; overflow: hidden; }
#map { position: absolute; inset: 0; border-radius: 6px; background: #071a33; }
.tile-dark { filter: invert(1) hue-rotate(195deg) brightness(0.8) contrast(1.05) saturate(0.7); }
.tile-sat { filter: brightness(0.75) saturate(0.9); }
.map-tabs, .map-layer { position: absolute; top: 10px; z-index: 500; display: flex; gap: 4px; }
.map-tabs { left: 12px; }
.map-layer { right: 12px; }
.map-tabs button, .map-layer button {
  background: rgba(4, 18, 40, 0.85); border: 1px solid var(--line); color: var(--txt);
  padding: 6px 12px; border-radius: 4px; font-size: 13px;
}
.map-tabs button.active, .map-layer button.active { background: rgba(58, 209, 255, 0.35); border-color: var(--cyan); color: #fff; }
.legend {
  position: absolute; left: 12px; bottom: 10px; z-index: 500; display: flex; gap: 10px; align-items: center;
  background: rgba(4, 18, 40, 0.85); border: 1px solid var(--line); padding: 5px 10px; border-radius: 4px; font-size: 12px;
}
.legend .dot, .legend .tb { display: inline-block; width: 9px; height: 9px; margin-right: 4px; background: var(--c); vertical-align: -1px; }
.legend .dot { clip-path: polygon(50% 0, 100% 100%, 50% 75%, 0 100%); width: 11px; height: 11px; }
.legend .tb { border-radius: 50%; }
.legend .sep { width: 1px; height: 12px; background: var(--line); }
.legend .attr { color: var(--dim); font-size: 11px; }
.leaflet-container { font-family: inherit; }
.leaflet-tooltip.tip {
  background: rgba(4, 18, 40, 0.92); color: var(--txt); border: 1px solid var(--cyan); border-radius: 4px;
  box-shadow: 0 0 10px rgba(58, 209, 255, 0.3); font-size: 12px; line-height: 1.6;
}
.leaflet-tooltip.tip::before { display: none; }
.leaflet-tooltip.lbl {
  background: transparent; border: 0; box-shadow: none; color: #bfe9ff; font-size: 12px; font-weight: 600;
  text-shadow: 0 0 3px #000, 0 0 6px #000; padding: 0;
}
.leaflet-tooltip.lbl::before { display: none; }
.leaflet-tooltip.ty-link {
  background: rgba(255, 59, 78, 0.9); color: #fff; border: 0; font-weight: 600; font-size: 12px;
}
.leaflet-tooltip.ty-link::before { display: none; }

/* 船舶图标 */
.ship-mk { position: relative; width: 24px; height: 24px; color: var(--cyan); }
.ship-mk .arrow { width: 24px; height: 24px; transition: transform 0.3s; filter: drop-shadow(0 0 4px currentColor); }
.ship-mk svg { width: 24px; height: 24px; fill: currentColor; stroke: #04101f; stroke-width: 1; }
.ship-mk .lbl {
  position: absolute; left: 26px; top: 3px; white-space: nowrap; font-size: 12px; font-weight: 600; color: #fff;
  text-shadow: 0 0 3px #000, 0 0 6px #000; pointer-events: none;
}
.ship-mk .ring { position: absolute; inset: -8px; border-radius: 50%; border: 2px solid transparent; }
.ship-mk.sel .ring { border-color: #fff; box-shadow: 0 0 10px #fff; }
.ship-mk.danger .ring { border-color: var(--red); animation: pulse 1s infinite; }
.dock-mk {
  width: 26px; height: 26px; border-radius: 50%; background: #0b2e57; border: 2px solid var(--cyan);
  display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.sub-mk { width: 16px; height: 16px; background: #b18cff; border: 2px solid #fff; transform: rotate(45deg); box-shadow: 0 0 8px #b18cff; }
.farm-badge {
  background: rgba(4, 18, 40, 0.92); border: 1px solid var(--c); border-radius: 6px; padding: 6px 10px;
  white-space: nowrap; box-shadow: 0 0 12px var(--c); cursor: pointer; transform: translate(-50%, -50%);
  position: absolute; left: 0; top: 0;
}
.farm-badge b { font-size: 14px; color: #fff; }
.farm-badge div { font-size: 12px; color: var(--txt); margin-top: 2px; }
.ty-mk { width: 44px; height: 44px; font-size: 40px; line-height: 44px; text-align: center; animation: spin 2.4s linear infinite; filter: drop-shadow(0 0 8px #ff3b4e); }

/* ---------- 底部 ---------- */
.bottom { height: 170px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bottom .panel { display: flex; flex-direction: column; }
.chart-box { flex: 1; position: relative; min-height: 0; }
#chart { position: absolute; inset: 0; width: 100%; height: 100%; }
.events { flex: 1; overflow-y: auto; font-size: 12px; }
.ev { display: grid; grid-template-columns: 42px 40px 1fr; gap: 4px; padding: 3px 0; border-bottom: 1px dashed rgba(58, 209, 255, 0.1); }
.ev .t { color: var(--dim); font-family: Consolas, monospace; }
.ev .f { color: var(--c); }
.ev.warn .x { color: var(--yellow); }
.ev.danger .x { color: #ff8b95; font-weight: 600; }
.ev.ok .x { color: #9ff5cf; }

/* ---------- 台风 ---------- */
.ty-head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.ty-head .ty-icon { font-size: 34px; animation: spin 2.4s linear infinite; }
.ty-head b { font-size: 15px; color: #fff; }
.ty-head .m { color: var(--dim); font-size: 12px; line-height: 1.6; }
.ty-farm { display: grid; grid-template-columns: 44px 1fr 70px 74px; align-items: center; gap: 6px; margin: 4px 0; font-size: 12px; }
.ty-bar { height: 6px; background: rgba(255, 255, 255, 0.08); border-radius: 3px; position: relative; overflow: hidden; }
.ty-bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--c); border-radius: 3px; }
.ty-rules { display: flex; gap: 6px; margin: 8px 0 4px; font-size: 11px; color: var(--dim); flex-wrap: wrap; }
.ty-rules span { border-left: 3px solid var(--c); padding-left: 4px; }
.ty-act { margin-top: 6px; padding: 6px 8px; border-radius: 4px; font-size: 12px; background: rgba(255, 255, 255, 0.04); border-left: 3px solid var(--c); }

/* ---------- 预测 ---------- */
.predict { overflow-y: auto; flex: 1; }
.pd-head { display: flex; justify-content: space-between; align-items: center; }
.pd-name { font-size: 18px; font-weight: 700; color: #fff; }
.pd-sub { color: var(--dim); font-size: 12px; margin: 2px 0 8px; }
.pd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.pd-grid div { background: rgba(255, 255, 255, 0.03); padding: 5px 8px; border-radius: 4px; }
.pd-grid span { display: block; color: var(--dim); font-size: 11px; }
.pd-grid b { font-size: 13px; color: #fff; font-weight: 600; }
.pd-block { border: 1px solid rgba(58, 209, 255, 0.18); border-radius: 5px; padding: 8px 10px; margin-bottom: 8px; }
.pd-title { font-size: 13px; font-weight: 600; color: var(--cyan); margin-bottom: 6px; }
.big { display: flex; align-items: baseline; gap: 8px; }
.big b { font-size: 30px; font-family: "DIN Alternate", Consolas, monospace; color: #fff; }
.big span { color: var(--dim); }
.pd-line { color: var(--dim); font-size: 12px; line-height: 1.7; }
.pd-line b { color: var(--txt); font-weight: 600; }
.tl { list-style: none; margin: 4px 0; }
.tl li { position: relative; padding-left: 14px; font-size: 12px; line-height: 1.8; color: var(--txt); }
.tl li::before { content: ""; position: absolute; left: 2px; top: 8px; width: 6px; height: 6px; border-radius: 50%; background: var(--cyan); }
.tl li em { font-style: normal; color: var(--dim); font-family: Consolas, monospace; margin-right: 6px; }
.slack { height: 8px; background: rgba(255, 255, 255, 0.08); border-radius: 4px; overflow: hidden; margin: 6px 0 2px; }
.slack i { display: block; height: 100%; background: var(--c); }
.pd-block.ai { border-color: rgba(124, 77, 255, 0.6); background: linear-gradient(135deg, rgba(124, 77, 255, 0.12), rgba(58, 209, 255, 0.05)); }
.pd-block.ai .pd-title { color: #c6b3ff; }
.rec { background: rgba(0, 0, 0, 0.2); border-radius: 4px; padding: 8px; margin-bottom: 6px; }
.rec .rt { font-size: 14px; font-weight: 600; color: #fff; }
.rec .rt em { font-style: normal; font-size: 11px; padding: 0 5px; border-radius: 3px; margin-left: 4px; background: var(--c); color: #04101f; }
.btn-dispatch {
  margin-top: 6px; width: 100%; padding: 7px; border: 0; border-radius: 4px; color: #fff; font-size: 13px; font-weight: 600;
  background: linear-gradient(90deg, #7c4dff, #3ad1ff);
}
.btn-dispatch:hover { filter: brightness(1.15); }
.alt { font-size: 12px; color: var(--dim); display: flex; justify-content: space-between; padding: 3px 0; border-top: 1px dashed rgba(255, 255, 255, 0.08); }
.alt a { color: var(--cyan); cursor: pointer; }
.pd-foot { color: var(--dim); font-size: 11px; line-height: 1.6; }
.empty { color: var(--dim); padding: 20px 0; text-align: center; }

/* ---------- 报警弹窗 ---------- */
.alarm {
  position: fixed; left: 50%; top: 76px; transform: translateX(-50%); z-index: 2000; min-width: 560px; max-width: 760px;
  background: rgba(60, 0, 8, 0.95); border: 2px solid var(--red); border-radius: 8px; padding: 14px 18px;
  box-shadow: 0 0 40px rgba(255, 59, 78, 0.7); animation: alarmGlow 1s infinite;
}
.alarm.hidden { display: none; }
.alarm h4 { font-size: 18px; color: #fff; margin-bottom: 6px; }
.alarm p { font-size: 14px; line-height: 1.7; color: #ffd6da; }
.alarm button { margin-top: 10px; padding: 7px 18px; background: var(--red); color: #fff; border: 0; border-radius: 4px; font-size: 14px; font-weight: 600; }
body.alerting::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 1500;
  box-shadow: inset 0 0 120px rgba(255, 59, 78, 0.55); animation: blink 1s infinite;
}

/* ---------- 实时船队（AIS） ---------- */
.live-panel { position: absolute; top: 48px; right: 12px; z-index: 500; width: 250px; background: rgba(6, 20, 44, 0.92); border: 1px solid rgba(255, 106, 213, 0.55); border-radius: 6px; font-size: 12px; }
.live-panel .lp-hd { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-bottom: 1px solid rgba(255, 106, 213, 0.25); }
.live-panel .lp-hd b { color: #ff6ad5; font-size: 13px; }
.live-panel .lp-hd span { color: var(--dim); flex: 1; }
.live-panel .lp-hd button { background: none; border: 1px solid var(--line); color: var(--txt); border-radius: 3px; width: 22px; height: 20px; line-height: 1; padding: 0; }
.live-panel.fold .lp-bd { display: none; }
.live-panel.fold [data-fold] { transform: rotate(-90deg); }
.live-panel .lp-bd { max-height: 330px; overflow-y: auto; padding: 4px 0; }
.live-panel .lp-ok, .live-panel .lp-err { padding: 4px 10px 6px; color: var(--dim); }
.live-panel .lp-err { color: #ffc58f; }
.live-panel .lp-row { display: flex; align-items: center; gap: 7px; padding: 5px 10px; cursor: pointer; }
.live-panel .lp-row:hover, .live-panel .lp-row.sel { background: rgba(255, 106, 213, 0.12); }
.live-panel .lp-row i { width: 8px; height: 8px; border-radius: 50%; flex: none; background: #22e39a; box-shadow: 0 0 6px #22e39a; }
.live-panel .lp-row.off i { background: #8aa0b8; box-shadow: none; }
.live-panel .lp-row.none i { background: none; border: 1px dashed #8aa0b8; box-shadow: none; }
.live-panel .lp-row b { color: #fff; font-weight: 500; flex: 1; }
.live-panel .lp-row span { color: var(--dim); }
.live-panel .lp-row.none b { color: var(--dim); }
.live-mk { position: relative; width: 22px; height: 22px; color: var(--c, #3ad1ff); }
.live-mk .ring { position: absolute; inset: -7px; border-radius: 50%; border: 2px solid transparent; }
.live-mk.sel .ring { border-color: #fff; box-shadow: 0 0 10px #fff; }
.live-mk.danger .ring { border-color: var(--red); animation: pulse 1s infinite; }
.live-mk .arrow { width: 22px; height: 22px; filter: drop-shadow(0 0 4px currentColor); }
.live-mk svg { width: 22px; height: 22px; fill: currentColor; stroke: #fff; stroke-width: 1.2; }
.live-mk .lbl { position: absolute; left: 24px; top: 2px; white-space: nowrap; font-size: 12px; color: #fff; background: rgba(4, 16, 36, 0.8); border: 1px solid currentColor; border-radius: 3px; padding: 0 4px; }
.ship-list .src { font-size: 11px; padding: 2px 4px 6px; color: var(--dim); }
.ship-list .src.bad { color: #ffc58f; }
.live-mk.sel .arrow { filter: drop-shadow(0 0 8px #fff); }

/* ---------- 风机二维码弹窗 ---------- */
.tb-modal { position: fixed; inset: 0; z-index: 2100; background: rgba(2, 8, 20, 0.6); display: flex; align-items: center; justify-content: center; }
.tb-modal.hidden { display: none; }
.tb-box { position: relative; width: 620px; background: rgba(8, 26, 54, 0.97); border: 1px solid var(--cyan); border-radius: 8px; padding: 16px 18px; box-shadow: 0 0 30px rgba(58, 209, 255, 0.35); }
.tb-box h4 { font-size: 18px; color: #fff; margin-bottom: 12px; }
.tb-box h4 small { font-size: 12px; color: var(--dim); font-weight: 400; margin-left: 8px; }
.tb-x { position: absolute; right: 10px; top: 8px; background: none; border: 0; color: var(--dim); font-size: 22px; cursor: pointer; }
.tb-body { display: flex; gap: 16px; }
.tb-qr { flex: none; width: 190px; text-align: center; font-size: 12px; color: var(--dim); }
.tb-qr svg { width: 190px; height: 190px; background: #fff; border-radius: 4px; display: block; margin-bottom: 6px; }
.tb-recs { flex: 1; }
.tb-sub { color: var(--dim); font-size: 12px; margin-bottom: 6px; }
.tb-rec { border-left: 3px solid var(--c); padding: 5px 8px; margin-bottom: 6px; background: rgba(58, 209, 255, 0.06); font-size: 13px; }
.tb-rec span { display: block; color: var(--dim); font-size: 12px; margin-top: 2px; }
.tb-act { display: flex; gap: 10px; margin-top: 12px; }
.tb-act a { flex: 1; text-align: center; padding: 7px 0; border: 1px solid var(--cyan); border-radius: 4px; color: var(--cyan); text-decoration: none; font-size: 14px; }
.tb-act a:hover { background: rgba(58, 209, 255, 0.15); }
.sim-ctl a { text-decoration: none; }

@keyframes spin { to { transform: rotate(-360deg); } }
@keyframes blink { 50% { opacity: 0.45; } }
@keyframes pulse { 0% { transform: scale(0.8); opacity: 1; } 100% { transform: scale(1.8); opacity: 0; } }
@keyframes alarmGlow { 50% { box-shadow: 0 0 12px rgba(255, 59, 78, 0.4); } }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: rgba(58, 209, 255, 0.3); border-radius: 3px; }
