/* ===================================================================
   public/site.css — 全站统一视觉基线（2026-09-18）
   引入方式：各页面 </head> 之前最后引入（覆盖页面自身旧样式）
   职责：
     ① 统一页头配色（.topbar / .utopbar / .ubar —— 全站唯一渐变真源）
     ② 电脑端内容区加宽（--site-maxw），手机端保持紧凑
     ③ 全站自适应兜底（媒体元素不溢出、窄屏留白收缩、长表格可横滚）
   ── 配色（与 user-ui.css / home.css v2 同源）──
     主色 雾松绿 #8FB8A8 · 可用档 #6E9C89 · 加深档 #5F8B79 · 深底 #4F7A68
   =================================================================== */

:root {
  --site-brand: #8fb8a8;
  --site-primary: #6e9c89;
  --site-primary-dark: #5f8b79;
  --site-primary-deep: #46695c;
  /* 🔴 全站唯一页头渐变：任何页面都不得再自写页头底色 */
  --site-head-grad: linear-gradient(118deg, #4f7a68 0%, #5f8b79 48%, #6e9c89 100%);
  /* 内容区最大宽度（电脑端加框加宽） */
  --site-maxw: 1320px;
  --site-maxw-xl: 1460px;
  /* 左右安全留白：窄屏 14px，宽屏最多 34px */
  --site-gutter: clamp(14px, 2.4vw, 34px);
}

/* ===================================================================
   ① 页头统一：所有页面顶栏同一渐变 + 同一留白 + 同一阴影
   =================================================================== */
.topbar,
.utopbar,
.ubar {
  background: var(--site-head-grad) !important;
  background-image: var(--site-head-grad) !important;
  background-color: #5f8b79 !important;
  color: #fff !important;
  box-shadow: 0 2px 14px rgba(70, 105, 92, .22) !important;
  border-bottom: none !important;
}

/* 顶栏横向留白统一（纵向留白各页自定，不强行拉平，避免挤坏按钮） */
.utopbar,
.ubar {
  padding-left: var(--site-gutter) !important;
  padding-right: var(--site-gutter) !important;
  min-height: 58px;
}
.topbar {
  padding-left: var(--site-gutter) !important;
  padding-right: var(--site-gutter) !important;
  min-height: 58px;
}
/* 首页顶栏内层容器与内容区同宽 */
.topbar-inner {
  max-width: var(--site-maxw);
  margin: 0 auto;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* 顶栏文字：深底上统一白色（只处理文字，按钮保持各自底色确保可读） */
.topbar .title,
.topbar .brand,
.utopbar .brand,
.utopbar .utitle,
.ubar .ubar-brand {
  color: #fff !important;
}
.topbar .title small,
.topbar .title a,
.topbar a.back,
.topbar .brand small,
.utopbar .who,
.ubar .ubar-right {
  color: rgba(255, 255, 255, .9) !important;
}
/* 保存状态：沿用 user/builder 的深底高亮色板 */
.topbar .actions .save-status {
  color: rgba(255, 255, 255, .82) !important;
}
.topbar .actions .save-status.dirty { color: #fde68a !important; }
.topbar .actions .save-status.saving { color: #c7dbd2 !important; }
.topbar .actions .save-status.saved { color: #bbf7d0 !important; }

/* 后台侧栏顶部品牌区：与全站页头同渐变（后台的「页头」就是它） */
.app-sidebar .brand {
  background: var(--site-head-grad) !important;
  background-image: var(--site-head-grad) !important;
  color: #fff !important;
  border-bottom: none !important;
}
.app-sidebar .brand small {
  color: rgba(255, 255, 255, .82) !important;
}

/* 公开填写页顶栏（f.html；iframe 内嵌时由页面脚本自动隐藏） */
.site-fillbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 12px var(--site-gutter);
  background: var(--site-head-grad);
  color: #fff;
  box-shadow: 0 2px 14px rgba(70, 105, 92, .22);
  position: sticky;
  top: 0;
  z-index: 30;
}
.site-fillbar .sf-brand { font-weight: 700; font-size: 17px; letter-spacing: .3px; }
.site-fillbar .sf-sub { font-size: 13px; opacity: .9; }

/* ===================================================================
   ①b 页头布局统一：工作台 / 数据页 / 用户填写页共用一套结构
   左：统一品牌 + 当前页副标题（hb-sub）
   右：统一账号操作区（hb-right，由 /site-headbar.js 生成）
   =================================================================== */
.uhb {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  box-sizing: border-box;
  padding: 12px var(--site-gutter);
}
.uhb .hb-brand {
  font-weight: 700;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.uhb .hb-sep { opacity: .45; font-weight: 400; }
.uhb .hb-sub {
  font-size: 13px;
  font-weight: 500;
  opacity: .9;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.uhb .hb-right { display: flex; align-items: center; gap: 10px; font-size: 14px; flex: 0 0 auto; }
.uhb .hb-who { opacity: .9; white-space: nowrap; }
.uhb a.hb-link {
  color: #fff; opacity: .92; font-size: 14px; cursor: pointer;
  padding: 6px 12px; border-radius: var(--r-sm, 8px);
  border: 1px solid rgba(255, 255, 255, .55);
  transition: all .15s; text-decoration: none; white-space: nowrap;
}
.uhb a.hb-link:hover { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .85); }
@media (max-width: 900px) {
  .uhb .hb-brand { font-size: 16px; }
  .uhb .uc-name { max-width: 92px; }
}
@media (max-width: 640px) {
  .uhb { min-height: 52px; flex-wrap: wrap; row-gap: 8px; }
  .uhb .hb-brand { font-size: 15px; }
  .uhb .hb-right { gap: 6px; flex-wrap: wrap; flex: 1 1 100%; justify-content: flex-end; }
  .uhb a.hb-link { padding: 5px 9px; font-size: 13px; }
}

/* ===================================================================
   ② 电脑端内容区加宽（仅控制台类页面 body.site-wide）
   =================================================================== */
@media (min-width: 1280px) {
  body.site-wide .wrap,
  body.site-wide .container,
  body.site-wide .catnav,
  body.site-wide .section,
  body.site-wide .app-main,
  body.site-wide > main {
    max-width: var(--site-maxw) !important;
  }
  body.site-wide .container {
    margin-left: auto !important;
    margin-right: auto !important;
  }
  /* 电脑端更舒展的留白与圆角 */
  body.site-wide .card,
  body.site-wide .ucard,
  body.site-wide .panel {
    border-radius: 16px;
  }
  body.site-wide .page-title { font-size: 26px !important; }
}
@media (min-width: 1680px) {
  body.site-wide .wrap,
  body.site-wide .container,
  body.site-wide .catnav,
  body.site-wide .section {
    max-width: var(--site-maxw-xl) !important;
  }
}

/* 填写/落地页（body.site-form）：窄屏优先，电脑端适度加宽但不超过阅读舒适区 */
@media (min-width: 1024px) {
  body.site-form .wrap { max-width: 800px; }
}
@media (min-width: 1440px) {
  body.site-form .wrap { max-width: 860px; }
}

/* ===================================================================
   ③ 全站自适应兜底
   =================================================================== */
/* 媒体元素永不撑破容器 */
img, video, canvas, svg, iframe {
  max-width: 100%;
}
/* 代码块 / 长串 URL 可横向滚动，不撑破布局 */
pre, code, .code, .url-row input, .url-row .url {
  max-width: 100%;
  overflow-x: auto;
}
/* 长表格允许横向滚动（不改用 display:block，避免破坏表头 sticky） */
.table-scroll, .tablewrap {
  overflow-x: auto;
}

/* 窄屏：收缩左右留白，顶栏同样收缩 */
@media (max-width: 820px) {
  body.site-wide .wrap,
  body.site-wide .container,
  body.site-wide .section,
  body.site-wide .catnav {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }
  .topbar,
  .utopbar,
  .ubar {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }
  /* 顶栏在窄屏允许换行，避免按钮挤出屏幕 */
  .utopbar,
  .ubar {
    flex-wrap: wrap;
    row-gap: 8px;
  }
  .utopbar .utopbar-right,
  .ubar .ubar-right {
    flex-wrap: wrap;
    row-gap: 6px;
  }
  /* 工作台 5 列表格在窄屏退化为卡片流 */
  body.site-wide .act-table thead { display: none; }
  body.site-wide .act-table,
  body.site-wide .act-table tbody,
  body.site-wide .act-table tr,
  body.site-wide .act-table td {
    display: block;
    width: 100%;
  }
  body.site-wide .act-table tr {
    border: 1px solid var(--c-border, #e8e5de);
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 10px;
    background: #fff;
  }
  body.site-wide .act-table td {
    border: none !important;
    padding: 4px 0 !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    max-width: none !important;
  }
  body.site-wide .act-table td::before {
    content: attr(data-th);
    display: inline-block;
    min-width: 72px;
    color: #9aa49e;
    font-size: 12px;
  }
  /* 数据页双列提交卡在窄屏转单列 */
  .cards { grid-template-columns: 1fr !important; }
  .cards .empty { grid-column: 1 / 2 !important; }
  /* 页面标题行在窄屏改为上下排布，标题不再被按钮挤成竖排 */
  body.site-wide .head {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  body.site-wide .head h1 {
    flex: none;
    font-size: 17px !important;
    line-height: 1.45;
    white-space: normal;
    word-break: break-word;
  }
  body.site-wide .head .head-act {
    flex-wrap: wrap;
    justify-content: flex-start;
  }
  /* 控制台内的普通数据表：窄屏改为块级横向滚动，不再撑破屏幕 */
  body.site-wide table:not(.act-table) {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  body.site-wide .top-nums { gap: 20px; flex-wrap: wrap; }
  body.site-wide .top-nums .num b { font-size: 26px !important; }
  .site-fillbar { min-height: 52px; }
  .site-fillbar .sf-brand { font-size: 15px; }
}

/* ===================================================================
   填写页窄屏（≤640）：responsive.css 会给 body 加 12px 内边距，
   会把通栏页头顶偏、两页不一致 —— 这里清零，内容区间距由 .wrap 承担
   =================================================================== */
@media (max-width: 640px) {
  body.site-form { padding: 0 !important; }
}

/* ===================== 站点品牌 logo（息止办公） ===================== */
.site-logo { width: 25px; height: 25px; border-radius: 7px; flex: 0 0 auto; display: inline-block; vertical-align: -6px; }
.uhb .hb-brand .site-logo { width: 26px; height: 26px; }
@media (max-width: 640px) {
  .uhb .hb-brand .site-logo { width: 22px; height: 22px; }
}
