/* CMS 后台样式。必须外链：CSP 为 default-src 'self'，内联 <style> 会被浏览器整块丢弃
   （现象是「未登录时退出按钮也可见」——.hidden 根本没加载）。

   设计口径（2026-11-24 改为 Apple 风格）：
     · 系统字体栈优先 -apple-system（macOS 上即 SF Pro），中文回落苹方；不引外部字体（CSP 只允许 self）
     · 浅灰底 #f5f5f7 + 纯白卡片 + 极浅发丝线，层级靠留白与字重，不靠边框和阴影堆叠
     · 唯一的彩色强调是系统蓝 #0071e3；按钮一律胶囊形，聚焦环是蓝色柔光
     · 数字与路径用等宽字体，避免表格里数字跳动 */

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #fbfbfd;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #7f7f86;
  --line: #d2d2d7;
  --hairline: rgba(60, 60, 67, .14);

  /* iOS 毛玻璃材质：半透明白 + 背景模糊 + 内侧高光。
     只有背景有色彩时模糊才看得见，所以底色见 body 的多层光斑。 */
  --glass: rgba(255, 255, 255, .62);
  --glass-strong: rgba(255, 255, 255, .76);
  --glass-line: rgba(255, 255, 255, .8);
  --glass-blur: saturate(200%) blur(32px);
  --glass-shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 18px 44px -24px rgba(16, 24, 40, .38);
  --glass-inner: inset 0 1px 0 rgba(255, 255, 255, .8);

  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-tint: rgba(0, 113, 227, .1);
  --green: #1d8a4b;
  --red: #d70015;
  --orange: #a34f00;

  --radius-sm: 10px;
  --radius: 12px;
  --radius-lg: 18px;

  --shadow-card: 0 1px 2px rgba(0, 0, 0, .04), 0 6px 20px rgba(0, 0, 0, .05);
  --shadow-pop: 0 24px 70px rgba(0, 0, 0, .22);
}

/* ---------------- 每个项目一套主色 ----------------
   键是入口段（服务端把 data-app 写在 <html> 上，见 server.js 的 serveIndex）。
   没配的项目落到默认系统蓝；新增项目在这里补一行即可，样式其余部分不用动。
   只换主色、不换底色：六套底色会让人以为进了六个不同的后台。 */
[data-app="xuzhou"]       { --accent: #a8451f; --accent-hover: #b94e26; --accent-tint: rgba(168, 69, 31, .1) }
[data-app="airport"]      { --accent: #0a7ea4; --accent-hover: #0b8ab3; --accent-tint: rgba(10, 126, 164, .1) }
[data-app="jichang"]      { --accent: #0f6f6a; --accent-hover: #127c76; --accent-tint: rgba(15, 111, 106, .1) }
[data-app="niudan"]       { --accent: #8a3ea8; --accent-hover: #9848b8; --accent-tint: rgba(138, 62, 168, .1) }
[data-app="offshore-oil"] { --accent: #12636f; --accent-hover: #15717e; --accent-tint: rgba(18, 99, 111, .1) }

* { box-sizing: border-box }
.hidden { display: none !important }

body {
  margin: 0;
  /* 光斑跟随项目主色（--accent），每个项目的后台底色带一点自己的色温；
     background-attachment: fixed 让光斑不随滚动跑，玻璃才有「贴在窗后」的稳定感。 */
  background-color: #eaedf4;
  background-image:
    radial-gradient(900px 620px at 6% -14%, color-mix(in srgb, var(--accent) 38%, #ffffff) 0%, rgba(255, 255, 255, 0) 60%),
    radial-gradient(780px 540px at 96% -6%, rgba(255, 138, 74, .18) 0%, rgba(255, 138, 74, 0) 58%),
    radial-gradient(960px 680px at 90% 106%, color-mix(in srgb, var(--accent) 26%, #c3d6ff) 0%, rgba(195, 214, 255, 0) 62%),
    radial-gradient(760px 540px at 0% 98%, rgba(112, 164, 255, .2) 0%, rgba(112, 164, 255, 0) 64%),
    radial-gradient(130% 110% at 50% 0%, rgba(255, 255, 255, 0) 46%, rgba(16, 24, 40, .05) 100%);
  background-attachment: fixed;
  background-repeat: no-repeat;
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -.005em;
}

h1, h2 { margin: 0; font-weight: 600; letter-spacing: -.022em }
h1 { font-size: 30px; line-height: 1.14 }
h2 { font-size: 20px; line-height: 1.3 }
.sub { color: var(--text-2); margin: 8px 0 26px; font-size: 14px; letter-spacing: 0 }
.muted { color: var(--text-3); font-size: 12.5px }
code {
  background: rgba(0, 0, 0, .05); border-radius: 5px; padding: 1px 5px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace; font-size: .92em;
}

/* ---------------- 登录 ---------------- */

.loginwrap {
  min-height: 100vh;
  /* 用 flex 而不是 grid：grid 的隐式列按 max-content 定宽，卡片（max-width 420）
     在窄屏会把整列撑到 420 并水平溢出，右侧被裁掉。flex 里 width:100% 才按容器算。 */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  /* 不要再铺一层白渐变：那样会把 body 上的彩色光斑盖住，卡片就「浮」不起来了。
     登录页现在直接坐在 body 的毛玻璃底色上。 */
  background: transparent;
}

.auth {
  width: 100%;
  max-width: 420px;
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-line);
  border-radius: 22px;
  padding: 46px 42px 36px;
  box-shadow: var(--glass-shadow), var(--glass-inner);
  text-align: center;
}
.auth-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; margin: 0 auto 20px;
  border-radius: 13px;
  background: var(--accent);
  color: #fff;
  font-size: 13px; font-weight: 600; letter-spacing: .04em;
}
.auth h1 { font-size: 26px; letter-spacing: -.02em }
.auth .sub { margin: 8px 0 30px; font-size: 13.5px }
.auth label { text-align: left }
.auth-hint { margin: 22px 0 0; color: var(--text-3); font-size: 12px }

/* ---------------- 表单控件 ---------------- */

label {
  display: block; margin: 18px 0 7px;
  color: var(--text-2); font-size: 12.5px; font-weight: 500; letter-spacing: 0;
}
.auth label:first-of-type { margin-top: 0 }

input, select, textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
  font-size: 15px;
  background: var(--surface);
  color: var(--text);
  transition: border-color .18s ease, box-shadow .18s ease;
  -webkit-appearance: none; appearance: none;
}
input::placeholder, textarea::placeholder { color: var(--text-3) }
input:hover, select:hover, textarea:hover { border-color: #b6b6bb }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-tint);
}
textarea { resize: vertical; min-height: 150px; line-height: 1.55; font-size: 14px }
input.bad, textarea.bad { border-color: var(--red); box-shadow: 0 0 0 4px rgba(215, 0, 21, .1) }

/* ---------------- 密码框里的眼睛 ---------------- */

.pwd { position: relative; display: block }
.pwd input { padding-right: 46px }

.eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--text-3);
  border: 0; border-radius: 9px; cursor: pointer;
}
.eye:hover { background: rgba(0, 0, 0, .06); color: var(--text-2) }
.eye:active { transform: translateY(-50%) scale(.94) }
.eye:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-tint) }
.eye svg {
  width: 19px; height: 19px;
  fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
}
/* 默认「看不见」：带一道斜杠；点开后斜杠消失（open eye） */
.eye .slash { opacity: 1; transition: opacity .15s ease }
.eye[aria-pressed="true"] .slash { opacity: 0 }

/* ---------------- 按钮 ---------------- */

button {
  padding: 9px 18px;
  border: 0;
  border-radius: 980px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -.005em;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease, transform .12s ease;
}
button:hover { background: var(--accent-hover) }
button:active { transform: scale(.985) }
button:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--accent-tint) }
button[disabled] { opacity: .38; cursor: not-allowed; transform: none }

button.ghost { background: rgba(0, 0, 0, .05); color: var(--text) }
button.ghost:hover { background: rgba(0, 0, 0, .08) }
button.primary { background: var(--accent); color: #fff }
button.danger { background: rgba(215, 0, 21, .08); color: var(--red) }
button.danger:hover { background: rgba(215, 0, 21, .13) }

.linkbtn {
  background: none; border: 0; color: var(--accent);
  padding: 2px 0; margin: 0; font-size: 13.5px; font-weight: 400;
  border-radius: 6px; transition: opacity .15s ease;
}
.linkbtn:hover { background: none; opacity: .7 }
.danger-text { color: var(--red) }
.danger-text:hover { opacity: .7 }
.topbar button { margin: 0 }
.auth > button { width: 100%; margin-top: 26px; padding: 12px 18px; font-size: 15px }

/* 表单提示：一行带角标的文字，不再是一整条粉底。
   粉底会把卡片撑高、也让人以为「出大事了」；口令错这种常规反馈，一句红字就够。 */
.msg {
  margin-top: 12px;
  display: none; align-items: flex-start; gap: 7px;
  font-size: 12.5px; line-height: 1.5; text-align: left;
}
.msg.err { display: flex; color: var(--red) }
.msg.ok { display: flex; color: var(--green) }
.msg::before {
  content: "!";
  flex: 0 0 auto;
  width: 15px; height: 15px; margin-top: 1px;
  border-radius: 50%;
  background: var(--red); color: #fff;
  font-size: 10.5px; font-weight: 700; line-height: 15px; text-align: center;
}
.msg.ok::before { content: "✓"; background: var(--green) }

/* ---------------- 外壳 ---------------- */

.app { min-height: 100vh; display: flex; flex-direction: column }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px; height: 52px;
  background: rgba(255, 255, 255, .6);
  backdrop-filter: saturate(190%) blur(32px);
  -webkit-backdrop-filter: saturate(190%) blur(32px);
  border-bottom: 1px solid rgba(255, 255, 255, .55);
  box-shadow: 0 1px 0 rgba(60, 60, 67, .08), 0 8px 24px -18px rgba(16, 24, 40, .5);
}
.brand { font-size: 13px; font-weight: 600; letter-spacing: .06em; color: var(--text) }
.crumb {
  color: var(--text-3); font-size: 12.5px;
  display: flex; align-items: center; flex-wrap: wrap; gap: 2px;
}
.crumb .sep { color: #c7c7cc; padding: 0 5px }
.crumb .here { color: var(--text); font-weight: 500 }
.spacer { flex: 1 }
.who { color: var(--text-2); font-size: 12.5px; white-space: nowrap }
/* 只作用于顶栏的**直接子按钮**：面包屑里的按钮是 .linkbtn（导航文字），
   用后代选择器会把它们也套成灰药丸，「项目 / 青藤大学官网」看起来像两个开关。 */
.topbar > button { padding: 6px 13px; font-size: 12.5px; background: rgba(0, 0, 0, .05); color: var(--text) }
.topbar > button:hover { background: rgba(0, 0, 0, .08) }
.topbar .linkbtn { padding: 0; background: none; font-size: 12.5px; color: var(--text-2) }
.topbar .linkbtn:hover { background: none; color: var(--text) }

.main { width: 100%; max-width: 1000px; margin: 0 auto; padding: 44px 24px 96px; flex: 1 }

/* ---------------- 卡片网格（项目 / 表） ---------------- */

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(228px, 1fr)); gap: 16px }

.tile {
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start; text-align: left;
  background: var(--glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-line);
  color: var(--text);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  cursor: pointer;
  box-shadow: var(--glass-shadow), var(--glass-inner);
  transition: transform .2s cubic-bezier(.2, .8, .3, 1), box-shadow .2s ease, background .2s ease;
}
.tile:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, .78);
  box-shadow: 0 2px 6px rgba(16, 24, 40, .06), 0 22px 46px -20px rgba(16, 24, 40, .42), var(--glass-inner);
}
.tile:active { transform: translateY(0) scale(.995) }
.tile-id { font-size: 16px; font-weight: 600; letter-spacing: -.015em }
.tile-go, .tile-meta { color: var(--text-3); font-size: 12.5px; letter-spacing: 0 }
.tile-meta { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace; font-size: 12px }
.tile-go { color: var(--accent); font-weight: 500; margin-top: 4px }

/* ---------------- 环境切换：iOS 分段控件 ---------------- */

.envbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0 0 22px;
}
.envbtn {
  margin: 0; padding: 6px 15px;
  background: rgba(118, 118, 128, .12); color: var(--text);
  border: 0; border-radius: 980px;
  font-size: 13px; font-weight: 400;
  transition: background .18s ease, color .18s ease;
}
.envbtn:hover { background: rgba(118, 118, 128, .18) }
/* 「正式数据」带 danger 类只是为了选中时换橙色，未选中时不能套用 button.danger 的红底——
   否则它看起来像个危险操作按钮，而它其实只是另一个标签页。 */
.envbtn.danger { background: rgba(118, 118, 128, .12); color: var(--text) }
.envbtn.danger:hover { background: rgba(118, 118, 128, .18) }
.envbtn.on { background: var(--text); color: #fff; font-weight: 500 }
.envbtn.danger.on { background: var(--orange); color: #fff }
.envhint { color: var(--orange); font-size: 12.5px; margin-left: 2px }
/* 停在「预览数据」时那句提示不该是警告色：预览本身不是危险动作。 */
.envbtn.on:not(.danger) ~ .envhint { color: var(--text-3) }

/* ---------------- 工具条 ---------------- */

.toolbar { display: flex; gap: 10px; margin: 0 0 18px; align-items: center; flex-wrap: wrap }
.toolbar .search { max-width: 300px }
/* 控件默认 width:100%，在 flex 里会把按钮挤成竖排（「导出 CSV」变成「导/出/C/S/V」）。
   给输入类留伸展、给按钮留自然宽度——这是 flex 里放全宽控件的固定坑。 */
.toolbar > select, .toolbar > input { flex: 1 1 150px; width: auto; min-width: 0; padding: 9px 13px; font-size: 14px }
.toolbar > button { flex: 0 0 auto; white-space: nowrap; margin: 0 }
.toolbar > .linkbtn { flex: 0 0 auto; padding: 6px 0 }

/* ---------------- 表格 ---------------- */

/* 表格套一层滚动容器：列数由甲方配置，多了不能把页面撑出横向滚动条，
   也不能让右侧的列直接被裁掉（app.js 的 tableWrap 负责这层 DOM）。 */
.tablewrap {
  background: var(--glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow), var(--glass-inner);
  overflow-x: auto;
  overflow-y: hidden;
  /* 列多时右侧会被裁，给一条细滚动条做提示（macOS 默认滚动条是隐藏的） */
  scrollbar-width: thin;
  scrollbar-color: rgba(60, 60, 67, .28) transparent;
}
table.rows {
  width: 100%;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: transparent;
}
table.rows th, table.rows td {
  text-align: left; padding: 13px 20px;
  border-bottom: 1px solid var(--hairline);
  vertical-align: middle; font-size: 14px;
}
table.rows th {
  background: rgba(255, 255, 255, .32);
  color: var(--text-3);
  font-weight: 500; font-size: 12px; letter-spacing: .01em;
  white-space: nowrap;
  padding-top: 14px; padding-bottom: 11px;
}
table.rows tbody tr { transition: background .12s ease }
table.rows tbody tr:hover { background: var(--surface-2) }
table.rows tbody tr:last-child td { border-bottom: 0 }
table.rows td { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
table.rows td.pk {
  color: var(--text-3); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 12.5px; font-variant-numeric: tabular-nums;
}
table.rows td.act, table.rows th.act { width: 118px; white-space: nowrap; text-align: right }
table.rows td.act .linkbtn + .linkbtn { margin-left: 14px }
table.rows td select { margin: 0 }
table.rows .muted { white-space: nowrap }

.badge {
  display: inline-block;
  font-size: 11.5px; line-height: 1.55; padding: 1px 9px; border-radius: 980px;
  vertical-align: middle; white-space: nowrap;
}
.badge-live { background: rgba(29, 138, 75, .12); color: var(--green) }
.badge-prev { background: var(--accent-tint); color: var(--accent) }
.badge-ro { background: rgba(118, 118, 128, .12); color: var(--text-2) }
.badge-off { background: rgba(215, 0, 21, .09); color: var(--red) }

/* ---------------- 分页 / 空态 / 加载 ---------------- */

.pager { display: flex; align-items: center; gap: 14px; margin-top: 18px }
.pager button { margin: 0 }
.pginfo { color: var(--text-3); font-size: 12.5px; font-variant-numeric: tabular-nums }

.empty {
  background: var(--glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-line);
  border-radius: var(--radius-lg);
  padding: 44px 28px 40px;
  color: var(--text-2);
  text-align: center;
  font-size: 14px;
  box-shadow: var(--glass-shadow), var(--glass-inner);
}

.loading { display: flex; align-items: center; gap: 10px; color: var(--text-2); padding: 26px 4px; font-size: 13.5px }
.loading::before {
  content: ""; width: 15px; height: 15px;
  border: 2px solid rgba(0, 0, 0, .1); border-top-color: var(--text-3);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }

/* 有些视图把 .loading 当容器复用（clear() 之后往里塞表格）。有内容时它不该再带
   加载态的内边距与转圈图标，否则表格会整体右移 4px、上方多出一块空白、左边挂个孤零零的圈。
   注意要写在这组规则**之后**：:has(> *) 的优先级与 .loading 相同，放在前面会被覆盖。 */
.loading:has(> *) { display: block; padding: 0 }
.loading:has(> *)::before { display: none }
@media (prefers-reduced-motion: reduce) {
  .loading::before { animation: none }
  .tile, button { transition: none }
}

/* ---------------- 编辑弹层 ---------------- */

.overlay {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(16, 18, 22, .28);
  backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
  /* flex 居中 + 内容高于视口时，顶部会被挤到可视区外且滚不上去（auto 边距能同时兼顾两种情况） */
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow: auto;
}
.dialog {
  /* 弹层压在 .overlay 的暗色遮罩上：再用 .76 的玻璃会透出灰底，整块发闷。
     这里调到接近实心，只留一点透光，字才立得住。 */
  background: rgba(255, 255, 255, .94);
  -webkit-backdrop-filter: saturate(180%) blur(40px);
  backdrop-filter: saturate(180%) blur(40px);
  border: 1px solid rgba(255, 255, 255, .6);
  border-radius: 22px;
  padding: 30px 30px 24px;
  width: 100%; max-width: 620px;
  margin: auto;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  box-shadow: var(--shadow-pop);
}
.dialog h2 { margin: 0 0 22px; font-size: 22px; letter-spacing: -.02em }
.field { margin-bottom: 16px }
.field label { margin-top: 0 }
.form label:first-child { margin-top: 0 }
.ro {
  padding: 11px 13px;
  border-radius: var(--radius);
  color: var(--text-2);
  background: rgba(0, 0, 0, .035);
  white-space: pre-wrap; word-break: break-word;
  font-size: 13.5px; line-height: 1.55;
}
.dialog-actions {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  margin-top: 26px;
}
.dialog-actions button { margin: 0 }

/* ---------------- 浮层提示 ---------------- */

.toast {
  position: fixed; left: 50%; bottom: 34px; z-index: 40;
  transform: translate(-50%, 14px); opacity: 0; pointer-events: none;
  padding: 11px 20px; border-radius: 980px;
  font-size: 13.5px; max-width: 80vw;
  background: rgba(29, 29, 31, .92);
  color: #fff;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 12px 34px rgba(0, 0, 0, .24);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0) }
.toast.ok { background: rgba(29, 29, 31, .92) }
.toast.err { background: rgba(190, 20, 30, .95) }

/* ---------------- 账号页与只读态 ---------------- */

.role-sel { width: auto; min-width: 168px; padding: 6px 11px; font-size: 13px; border-radius: 9px }
.hint { color: var(--text-3); font-size: 12px; margin-top: 6px }
.card { background: var(--surface); border-radius: 20px; padding: 40px; width: 100%; max-width: 400px; box-shadow: var(--shadow-card) }

/* 不支持 backdrop-filter 时退回实色：宁可没有玻璃，也不要半透明压在文字上读不清。 */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .auth, .tile, .tablewrap, .empty, .dialog { background: #fff }
  .topbar { background: rgba(255, 255, 255, .92) }
}

/* 细窄屏：收紧留白，标题降一级，顶栏允许换行。 */
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 10px }
  .main { padding: 28px 16px 72px }
  h1 { font-size: 24px }
  .auth { padding: 34px 24px 28px }
  .dialog { padding: 24px 20px 20px; border-radius: 18px }
  .overlay { padding: 20px 12px; align-items: flex-start }
}
