/* 天空之家运营中心 —— 配色与立体做法取自集团统一设计语言（theme.py / severity.py / design-qa.md）。
   铁律：框体一律中性碳灰，颜色只归数据；琥珀是告警级不是装饰色；无 emoji。 */
:root {
  color-scheme: dark;
  /* 层次阶梯：自底向上递亮，深度靠阶梯不靠纯黑 */
  --bg: #0A0F15; --bg2: #0E141D; --surf: #121B26; --surf2: #1B2632; --surf3: #243240;
  --line: #223040; --line2: #324658;
  --text: #F3F7FB; --text2: #C2CFDC; --muted: #8597AA;
  /* 主强调=青蓝 */
  --accent: #47B1EC; --accent2: #6FE0D4;
  --fill: #2C73B5; --fill-hover: #3A88CE; --on-fill: #F7FBFF;
  /* 徽底 */
  --dim-blue: #15314D; --dim-green: #14392B; --dim-amber: #352810; --dim-red: #391F22; --dim-violet: #241F44;
  /* severity：填充=严重度，全端一致 */
  --sev-offline: #5A6472; --sev-severe: #F56555; --sev-warning: #F0A63C; --sev-ready: #47B1EC; --sev-normal: #43D082;
  --glass: rgba(200, 245, 255, .14);
  --r: 6px; --r-lg: 10px;
  font-family: "PingFang SC", "Microsoft YaHei", "SF Pro Text", Inter, system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; color: var(--text); background: var(--bg); overflow: hidden; }

/* 座舱顶光 + 工程网格底纹：用 position:fixed 伪元素，避免多层 background-attachment 拖垮合成 */
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(120% 70% at 50% -18%, rgba(71, 177, 236, .13) 0, transparent 62%),
    linear-gradient(180deg, var(--bg2) 0, var(--bg) 46%);
}
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .5;
  background-image:
    linear-gradient(rgba(50, 70, 88, .16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(50, 70, 88, .16) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(to bottom, #000 0, transparent 72%);
}
button, input, select, textarea { font: inherit; color: inherit; }

/* ── 立体三基元 ───────────────────────────────────────────── */
.raise {
  background: linear-gradient(180deg, var(--surf2), var(--surf));
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 var(--glass), 0 1px 0 rgba(0,0,0,.55), 0 6px 18px rgba(0,0,0,.34);
}
.well {
  background: var(--bg2);
  box-shadow: inset 0 2px 5px -2px rgba(0,0,0,.85), inset 0 -1px 0 rgba(200,245,255,.07);
  border: 1px solid var(--line);
}

/* ── 登录 ─────────────────────────────────────────────────── */
.login-shell { position: relative; z-index: 1; height: 100vh; display: grid; place-items: center; padding: 1.25rem; overflow: auto; }
.login-card {
  width: min(100%, 27rem); padding: 2rem; border-radius: var(--r-lg);
  background: linear-gradient(180deg, var(--surf2), var(--surf));
  border: 1px solid var(--line2);
  box-shadow: inset 0 1px 0 var(--glass), 0 24px 64px rgba(0,0,0,.55);
}
.login-card::before {
  content: ""; display: block; height: 3px; margin: -2rem -2rem 1.6rem;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}
.brand-lockup { display: flex; align-items: center; gap: .85rem; }
.brand-lockup p, .eyebrow { margin: 0; color: var(--accent); font-size: .64rem; font-weight: 700; letter-spacing: .18em; }
.brand-lockup h1 { margin: .22rem 0 0; font-size: 1.3rem; font-weight: 600; letter-spacing: .5px; }
.brand-glyph {
  width: 2.9rem; height: 2.9rem; display: grid; place-items: center; border-radius: var(--r);
  color: var(--accent); font-size: 1.1rem; background: var(--dim-blue);
  border: 1px solid var(--line2); box-shadow: inset 0 1px 0 var(--glass);
}
.login-copy { margin: 1.5rem 0; color: var(--text2); font-size: .85rem; line-height: 1.7; }
label { display: block; margin: .9rem 0 .38rem; color: var(--muted); font-size: .74rem; font-weight: 600; letter-spacing: .04em; }
input, select, textarea {
  width: 100%; min-height: 2.65rem; padding: 0 .8rem; border-radius: var(--r);
  background: var(--bg2); border: 1px solid var(--line);
  box-shadow: inset 0 2px 5px -2px rgba(0,0,0,.85);
}
textarea { padding: .6rem .8rem; min-height: 5rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: inset 0 2px 5px -2px rgba(0,0,0,.85), 0 0 0 3px rgba(71,177,236,.2); }
.form-error { min-height: 1.1rem; margin: .55rem 0 0; color: var(--sev-severe); font-size: .78rem; }
.security-note { margin: 1.1rem 0 0; color: var(--muted); font-size: .72rem; text-align: center; }

/* ── 按钮 ─────────────────────────────────────────────────── */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 2.5rem; padding: 0 1rem; border-radius: var(--r); cursor: pointer;
  font-size: .82rem; font-weight: 600; letter-spacing: .02em;
  background: linear-gradient(180deg, var(--surf3), var(--surf2));
  border: 1px solid var(--line2); color: var(--text);
  box-shadow: inset 0 1px 0 var(--glass), 0 1px 0 rgba(0,0,0,.5);
}
.button:hover { background: linear-gradient(180deg, #2A3949, var(--surf3)); }
.button:active { transform: translateY(1px); box-shadow: inset 0 1px 3px rgba(0,0,0,.6); }
.button[disabled] { opacity: .45; cursor: not-allowed; }
.button-primary { background: linear-gradient(180deg, var(--fill-hover), var(--fill)); border-color: #4E96D8; color: var(--on-fill); width: 100%; }
.button-primary:hover { background: linear-gradient(180deg, #4694DC, var(--fill-hover)); }
.button-secondary { }
.button-quiet { background: transparent; border-color: var(--line); color: var(--text2); box-shadow: none; }
.button-quiet:hover { background: var(--surf2); color: var(--text); }
.button-warning { background: linear-gradient(180deg, #4A2A2E, var(--dim-red)); border-color: #6B3A3F; color: #FFC9C4; }
.icon-button {
  width: 2.4rem; height: 2.4rem; display: grid; place-items: center; cursor: pointer; border-radius: var(--r);
  background: var(--surf2); border: 1px solid var(--line); color: var(--text2);
  box-shadow: inset 0 1px 0 var(--glass);
}
.icon-button:hover { color: var(--accent); border-color: var(--line2); }

/* ── 应用骨架：顶栏 + 侧边栏 + 视图区 ─────────────────────── */
.app-shell { position: relative; z-index: 1; height: 100vh; display: grid; grid-template-rows: auto 1fr; }
.topbar {
  position: relative; display: flex; align-items: center; gap: 1rem; padding: .7rem 1.1rem;
  background: linear-gradient(180deg, var(--surf2), var(--surf));
  border-bottom: 1px solid var(--line);
  box-shadow: inset 0 1px 0 var(--glass), 0 2px 10px rgba(0,0,0,.4);
}
.topbar::before { content: ""; position: absolute; inset: 0 0 auto; height: 2px; background: linear-gradient(90deg, var(--accent), var(--accent2) 55%, transparent); }
.brand-lockup.compact h1 { font-size: 1rem; }
.brand-lockup.compact .brand-glyph { width: 2.3rem; height: 2.3rem; font-size: .95rem; }
.top-actions { display: flex; align-items: center; gap: .55rem; margin-left: auto; }
.admin-name { color: var(--text2); font-size: .8rem; }
.status-pill {
  display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .65rem; border-radius: 999px;
  font-size: .74rem; color: var(--text2); background: var(--dim-blue); border: 1px solid var(--line2);
}
.status-pill i { width: .45rem; height: .45rem; border-radius: 50%; background: var(--sev-normal); box-shadow: 0 0 6px rgba(67,208,130,.8); }
.status-pill.down i { background: var(--sev-severe); box-shadow: 0 0 6px rgba(245,101,85,.8); }

/* 全局搜索 */
.search { position: relative; margin: 0; }
.search input { min-width: 17rem; padding-left: 2rem; min-height: 2.4rem; }
.search > span { position: absolute; left: .65rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-results {
  position: absolute; top: calc(100% + .4rem); left: 0; right: 0; z-index: 40; max-height: 22rem; overflow: auto;
  border-radius: var(--r); padding: .35rem;
  background: linear-gradient(180deg, var(--surf2), var(--surf)); border: 1px solid var(--line2);
  box-shadow: 0 18px 44px rgba(0,0,0,.6);
}
.search-hit { display: block; width: 100%; text-align: left; padding: .5rem .6rem; border-radius: 4px; border: 0; background: transparent; cursor: pointer; }
.search-hit:hover { background: var(--surf3); }
.search-hit strong { display: block; font-size: .84rem; }
.search-hit span { color: var(--muted); font-size: .74rem; }

/* 主体 */
.workspace { display: grid; grid-template-columns: 13.5rem 1fr; min-height: 0; }
.sidebar {
  overflow: auto; padding: .8rem .6rem 2rem; border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(18,27,38,.92), rgba(10,15,21,.92));
}
.nav-group { margin: 0 0 .2rem; padding: .85rem .6rem .35rem; color: var(--muted); font-size: .64rem; font-weight: 700; letter-spacing: .16em; }
.nav-group:first-child { padding-top: .2rem; }
.tab {
  position: relative; display: flex; align-items: center; gap: .5rem; width: 100%;
  padding: .5rem .65rem; margin-bottom: 2px; border: 0; border-radius: var(--r);
  background: transparent; color: var(--text2); font-size: .84rem; text-align: left; cursor: pointer;
}
.tab:hover { background: var(--surf2); color: var(--text); }
.tab.active { background: linear-gradient(180deg, var(--surf3), var(--surf2)); color: var(--text); box-shadow: inset 0 1px 0 var(--glass); }
.tab.active::before { content: ""; position: absolute; left: 0; top: .35rem; bottom: .35rem; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.tab span { margin-left: auto; min-width: 1.25rem; padding: 0 .35rem; border-radius: 999px; text-align: center; font-size: .7rem; font-variant-numeric: tabular-nums; background: var(--dim-blue); color: var(--text2); }
.tab span:empty, .tab span.zero { display: none; }
.tab.alarm span { background: var(--dim-red); color: #FFC0BA; }

.viewport { overflow: auto; padding: 1.1rem 1.3rem 3rem; min-width: 0; }
.welcome { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.4rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.welcome h2 { margin: .25rem 0 .3rem; font-size: 1.32rem; font-weight: 600; }
.welcome p { margin: 0; color: var(--muted); font-size: .82rem; }
.welcome time { color: var(--muted); font-size: .76rem; font-variant-numeric: tabular-nums; }

/* ── 指标卡 ───────────────────────────────────────────────── */
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr)); gap: .7rem; margin-bottom: 1.3rem; }
.metric {
  position: relative; display: flex; flex-direction: column; gap: .18rem; padding: .85rem .9rem; border-radius: var(--r);
  background: linear-gradient(180deg, var(--surf2), var(--surf));
  border: 1px solid var(--line); box-shadow: inset 0 1px 0 var(--glass), 0 4px 14px rgba(0,0,0,.3);
}
.metric::before { content: ""; position: absolute; inset: 0 0 auto; height: 2px; border-radius: var(--r) var(--r) 0 0; background: var(--line2); }
.metric.primary::before { background: var(--sev-ready); }
.metric.warning::before { background: var(--sev-warning); }
.metric span { color: var(--muted); font-size: .74rem; }
.metric strong { font-size: 1.7rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.15; }
.metric small { color: var(--muted); font-size: .68rem; }
.metric.warning strong { color: var(--sev-warning); }

/* ── 分区标题 ─────────────────────────────────────────────── */
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.section-heading h2 { margin: .2rem 0 0; font-size: 1.05rem; font-weight: 600; }
.sub-heading { margin: 1.5rem 0 .6rem; font-size: .9rem; font-weight: 600; }
.boundary-badge { padding: .28rem .6rem; border-radius: 999px; font-size: .72rem; color: var(--text2); background: var(--dim-blue); border: 1px solid var(--line2); }
.boundary-copy { margin: 0 0 .9rem; color: var(--muted); font-size: .78rem; line-height: 1.75; max-width: 78ch; }
.range { display: inline-flex; align-items: center; gap: .45rem; margin: 0; color: var(--muted); font-size: .74rem; font-weight: 600; }
.range select, .range input { min-height: 2.2rem; width: auto; min-width: 8rem; }
.toolbar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .9rem; }

/* ── 记录列表 ─────────────────────────────────────────────── */
.record-list { display: flex; flex-direction: column; gap: .55rem; }
.record-card {
  display: grid; grid-template-columns: auto 1fr auto; gap: .85rem; align-items: start;
  padding: .85rem .95rem; border-radius: var(--r);
  background: linear-gradient(180deg, var(--surf2), var(--surf));
  border: 1px solid var(--line); box-shadow: inset 0 1px 0 var(--glass);
}
.record-card:hover { border-color: var(--line2); }
.record-main { min-width: 0; }
.avatar {
  width: 2.35rem; height: 2.35rem; display: grid; place-items: center; border-radius: var(--r);
  background: var(--dim-blue); border: 1px solid var(--line2); color: var(--accent); font-weight: 600; font-size: .9rem;
}
.record-heading { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.record-heading > div { min-width: 0; }
.record-heading strong { font-size: .95rem; font-weight: 600; }
.record-heading span { display: block; color: var(--muted); font-size: .76rem; }
.record-state {
  margin-left: auto; padding: .2rem .55rem; border-radius: 999px; font-size: .72rem; white-space: nowrap;
  background: var(--surf3); border: 1px solid var(--line2); color: var(--text2);
}
.record-state.active { background: var(--dim-green); border-color: #26603F; color: var(--sev-normal); }
.record-state.warning { background: var(--dim-amber); border-color: #63430F; color: var(--sev-warning); }
.record-state.severe { background: var(--dim-red); border-color: #6B3A3F; color: var(--sev-severe); }
.record-meta, .record-usage { margin: .35rem 0 0; color: var(--muted); font-size: .76rem; line-height: 1.6; }
.record-actions { display: flex; flex-direction: column; gap: .4rem; }
.record-detail { grid-column: 1 / -1; margin-top: .4rem; }
.record-detail summary { cursor: pointer; color: var(--accent); font-size: .78rem; padding: .3rem 0; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: .45rem; margin-top: .5rem; }
.detail-item { display: flex; flex-direction: column; gap: .12rem; padding: .5rem .6rem; border-radius: 4px; background: var(--bg2); border: 1px solid var(--line); }
.detail-item span { color: var(--muted); font-size: .7rem; }
.detail-item strong { font-size: .82rem; font-weight: 600; word-break: break-all; }
.detail-title { margin: 1.1rem 0 .45rem; font-size: .84rem; font-weight: 600; color: var(--accent); }

.data-table { display: flex; flex-direction: column; border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); }
.data-row { padding: .5rem .7rem; font-size: .78rem; line-height: 1.55; background: var(--bg2); border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.data-row:nth-child(even) { background: var(--surf); }
.data-row:last-child { border-bottom: 0; }
.data-row-warning { border-left: 3px solid var(--sev-severe); }
.position-table { max-height: 22rem; overflow: auto; }
.flight-detail { grid-column: 1 / -1; margin-top: .5rem; }
.audit-row { display: grid; grid-template-columns: 11rem 12rem 1fr; gap: .6rem; align-items: center; padding: .55rem .8rem; border-radius: var(--r); background: var(--bg2); border: 1px solid var(--line); font-size: .78rem; }
.audit-row + .audit-row { margin-top: .35rem; }
.audit-row time { color: var(--muted); font-variant-numeric: tabular-nums; }
.audit-row code { grid-column: 1 / -1; color: var(--muted); font-size: .72rem; word-break: break-all; }
.stat-row { display: flex; align-items: center; gap: .8rem; padding: .55rem .8rem; border-radius: var(--r); background: var(--bg2); border: 1px solid var(--line); }
.stat-row + .stat-row { margin-top: .35rem; }
.stat-row strong { font-size: .84rem; font-weight: 600; }
.stat-row span { flex: 1; min-width: 0; color: var(--muted); font-size: .74rem; }
.stat-row b { font-size: 1rem; font-variant-numeric: tabular-nums; }
.stat-row.muted { opacity: .55; }
.grant-row { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .5rem .75rem; border-radius: var(--r); background: var(--bg2); border: 1px solid var(--line); font-size: .78rem; }
.grant-row + .grant-row { margin-top: .35rem; }
.empty { margin: 0; padding: 1.6rem; text-align: center; color: var(--muted); font-size: .82rem; border-radius: var(--r); border: 1px dashed var(--line2); background: rgba(18,27,38,.5); }
.compact-empty { padding: .6rem .2rem; border: 0; background: none; text-align: left; }
.warning { color: var(--sev-warning); }

/* ── 趋势 ─────────────────────────────────────────────────── */
.trend-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: .7rem; }
.trend-card { padding: .85rem .95rem; border-radius: var(--r); background: linear-gradient(180deg, var(--surf2), var(--surf)); border: 1px solid var(--line); box-shadow: inset 0 1px 0 var(--glass); }
.trend-card.accent { border-color: var(--line2); }
.trend-card.warning { border-color: #6B3A3F; }
.trend-head { display: flex; align-items: baseline; justify-content: space-between; gap: .8rem; }
.trend-head span { color: var(--muted); font-size: .76rem; font-weight: 600; }
.trend-head strong { font-size: 1.4rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.trend-plot { display: flex; align-items: flex-end; gap: 2px; height: 4.2rem; margin: .8rem 0 .45rem; padding: .3rem; border-radius: 4px; background: var(--bg2); box-shadow: inset 0 2px 5px -2px rgba(0,0,0,.85); }
.trend-column { flex: 1; min-width: 2px; height: 100%; display: flex; align-items: flex-end; }
.trend-column i { display: block; width: 100%; min-height: 2px; border-radius: 2px 2px 0 0; background: var(--sev-ready); opacity: .85; }
.trend-card.warning .trend-column i { background: var(--sev-severe); }
.trend-axis { display: flex; justify-content: space-between; gap: .5rem; color: var(--muted); font-size: .68rem; font-variant-numeric: tabular-nums; }
.split-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 1.2rem; margin-top: 1.2rem; }

/* ── 导出 ─────────────────────────────────────────────────── */
.export-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: .7rem; }
.export-card { display: flex; flex-direction: column; gap: .3rem; padding: .95rem; border-radius: var(--r); color: inherit; text-decoration: none; background: linear-gradient(180deg, var(--surf2), var(--surf)); border: 1px solid var(--line); box-shadow: inset 0 1px 0 var(--glass); }
.export-card:hover { border-color: var(--accent); }
.export-card strong { font-size: .9rem; font-weight: 600; }
.export-card span { color: var(--muted); font-size: .75rem; line-height: 1.6; }
.track-download { display: inline-flex; margin-top: .7rem; text-decoration: none; }

/* ── 航迹图 ───────────────────────────────────────────────── */
.track-figure { margin: .6rem 0 0; padding: .6rem; border-radius: var(--r); background: var(--bg2); border: 1px solid var(--line); box-shadow: inset 0 2px 5px -2px rgba(0,0,0,.85); }
.track-figure svg { display: block; width: 100%; height: auto; }
.track-legend { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: .5rem; color: var(--muted); font-size: .72rem; }
.track-legend i { display: inline-block; width: .6rem; height: .6rem; border-radius: 2px; margin-right: .3rem; vertical-align: -1px; }

/* ── 弹窗 ─────────────────────────────────────────────────── */
.password-dialog, .user-dialog, .notify-dialog {
  color: var(--text); border: 1px solid var(--line2); border-radius: var(--r-lg); padding: 1.5rem;
  background: linear-gradient(180deg, var(--surf2), var(--surf));
  box-shadow: 0 30px 80px rgba(0,0,0,.65);
}
.password-dialog, .notify-dialog { width: min(100%, 26rem); }
.user-dialog { width: min(100%, 56rem); max-height: 88vh; }
dialog::backdrop { background: rgba(5, 9, 14, .74); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: .5rem; }
.dialog-heading h2 { margin: .2rem 0 0; font-size: 1.05rem; font-weight: 600; }
.dialog-copy { margin: 0 0 .6rem; color: var(--muted); font-size: .78rem; line-height: 1.7; }
.user-dialog-body { margin-top: .8rem; max-height: 68vh; overflow: auto; padding-right: .3rem; }
.user-dialog-body .detail-title:first-child { margin-top: 0; }

/* ── 服务状态 ─────────────────────────────────────────────── */
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: .55rem; }
.kv { display: flex; flex-direction: column; gap: .16rem; padding: .65rem .8rem; border-radius: var(--r); background: var(--bg2); border: 1px solid var(--line); }
.kv span { color: var(--muted); font-size: .72rem; }
.kv strong { font-size: .95rem; font-weight: 600; font-variant-numeric: tabular-nums; word-break: break-all; }

/* ── 提示条 ───────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 1.6rem; transform: translateX(-50%); z-index: 60;
  padding: .65rem 1.1rem; border-radius: var(--r); font-size: .84rem;
  background: linear-gradient(180deg, var(--surf3), var(--surf2)); border: 1px solid var(--line2);
  box-shadow: 0 14px 36px rgba(0,0,0,.6);
}
.toast.error { border-color: #6B3A3F; color: #FFC9C4; }

.pager { display: flex; align-items: center; gap: .6rem; margin-top: .8rem; color: var(--muted); font-size: .78rem; }
.pager b { color: var(--text2); font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .sidebar { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: .5rem; }
  .nav-group { display: none; }
  .tab { width: auto; white-space: nowrap; }
  .search input { min-width: 11rem; }
}
