
/* ==============================================================
   应用外壳：侧边栏 + 内容区
   桌面固定左栏；手机抽屉 + 顶部条
   ============================================================== */
:root {
  --side-w: 246px;
  /* 方案 C · 蓝白：白色侧栏 */
  --side-bg: #ffffff;
  --side-bg-2: #eef1f8;
  --side-line: #eceef4;
  --side-ink: #1c1f26;
  --side-ink-2: #5d6575;
  --accent: #00a1d6;
}

body { background: var(--bg); }

.shell { display: flex; min-height: 100vh; }

/* ---------- 侧边栏 ---------- */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--side-w);
  display: flex;
  flex-direction: column;
  background: var(--side-bg);
  color: var(--side-ink);
  z-index: 60;
  border-right: 1px solid var(--side-line);
}

.side-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--side-line);
}
.side-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  flex: 1;
  min-width: 0;
  color: var(--side-ink);
  text-decoration: none;
}
.side-logo {
  width: 34px; height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #6c5cff);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
}
.side-brand-text { display: flex; flex-direction: column; min-width: 0; }
.side-brand-name {
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-brand-sub {
  font-size: 11px;
  color: var(--side-ink-2);
  letter-spacing: .02em;
}
.side-close {
  display: none;
  width: 28px; height: 28px;
  border: none;
  border-radius: 8px;
  background: var(--side-bg-2);
  color: var(--side-ink-2);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.side-nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 10px 20px;
  scrollbar-width: thin;
}
.side-nav::-webkit-scrollbar { width: 5px; }
.side-nav::-webkit-scrollbar-thumb { background: var(--side-line); border-radius: 3px; }

.side-group { margin-bottom: 20px; }
.side-group:last-child { margin-bottom: 4px; }
.side-group-title {
  display: block;
  padding: 0 12px 7px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: #5d6575;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  margin-bottom: 2px;
  border-radius: 9px;
  color: var(--side-ink-2);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background .16s ease, color .16s ease;
}
.side-link:hover { background: var(--side-bg-2); color: var(--side-ink); }
.side-link.active {
  background: linear-gradient(90deg, rgba(0, 161, 214, .14), rgba(0, 161, 214, .04));
  color: var(--side-ink);
  font-weight: 650;
  box-shadow: inset 2px 0 0 var(--accent);
}
.side-glyph {
  width: 18px;
  flex: 0 0 18px;
  text-align: center;
  font-size: 13px;
  opacity: .85;
}
.side-link.active .side-glyph { color: var(--accent); opacity: 1; }
.side-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.side-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--side-line);
  background: var(--side-bg-2);
}
.side-user {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  color: var(--side-ink);
  text-decoration: none;
}
.avatar {
  width: 32px; height: 32px;
  flex: 0 0 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #2d3340, #434a5b);
  color: #dfe4ec;
  font-size: 13px;
  font-weight: 700;
}
.avatar-sm { width: 27px; height: 27px; flex-basis: 27px; font-size: 11.5px; }
.side-user-info { display: flex; flex-direction: column; min-width: 0; }
.side-user-name {
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-user-role { font-size: 10.5px; letter-spacing: .02em; }
.role-admin { color: #ffb454; }
.role-user { color: #6fb3ff; }
.role-guest { color: #8b93a3; }

.side-logout {
  width: 30px; height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--side-ink-2);
  font-size: 14px;
  text-decoration: none;
  transition: all .16s ease;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
}
.side-logout-form { display: flex; flex-shrink: 0; }
.side-logout:hover { background: var(--side-bg-2); color: #d9534f; }

.side-scrim { display: none; }

/* ---------- 主区 ---------- */
.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--side-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.mobilebar { display: none; }

.content { flex: 1; padding: 26px 30px 60px; }
.content > .wrap { max-width: none; padding: 0; }

.messages {
  max-width: 1240px;
  margin: 18px auto 0;
  padding: 0 30px;
}
.messages .msg { margin-bottom: 8px; }

/* ---------- 门户首页 ---------- */
.portal {
  max-width: 980px;
  margin: 0 auto;
  padding: 34px 4px 60px;
}
.portal-head { margin-bottom: 26px; }
.portal-title {
  margin: 0 0 6px;
  font-size: 27px;
  font-weight: 800;
  letter-spacing: -.025em;
}
.portal-sub { margin: 0; color: var(--ink-2); font-size: 13.5px; }

.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
}

.portal-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 22px;
  border-radius: 18px;
  border: 1px solid var(--line-2);
  background: var(--bg);
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  transition: transform .22s cubic-bezier(.2, .8, .3, 1), box-shadow .22s ease, border-color .22s ease;
  min-height: 250px;
}
.portal-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 36px rgba(15, 17, 21, .1);
}

.portal-live {
  border-color: #bfe2f2;
  background: linear-gradient(160deg, #fff 30%, #eef7fd 100%);
}
.portal-live:hover { border-color: #7cc4e8; }

.portal-glow {
  position: absolute;
  top: -70px; right: -60px;
  width: 210px; height: 210px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 161, 214, .14), transparent 68%);
  pointer-events: none;
}

.portal-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.portal-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .01em;
}
.portal-tag-live {
  background: #eefaf2;
  color: #1c7a45;
  border: 1px solid #cdeedb;
}
.portal-tag-soon {
  background: var(--bg-2);
  color: var(--ink-3);
  border: 1px solid var(--line-2);
}
.live-pin {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #22a35c;
  box-shadow: 0 0 0 0 rgba(34, 163, 92, .5);
  animation: live-pulse 2s infinite;
}
.portal-arrow {
  font-size: 17px;
  color: var(--ink-3);
  transition: transform .2s ease, color .2s ease;
}
.portal-card:hover .portal-arrow { transform: translateX(4px); color: var(--accent); }

.portal-name {
  margin: 0 0 5px;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -.02em;
}
.portal-desc { margin: 0 0 20px; color: var(--ink-2); font-size: 13px; }

.portal-stats {
  display: flex;
  gap: 26px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.pstat { display: flex; flex-direction: column; gap: 2px; }
.pstat-num {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.pstat-label { font-size: 11.5px; color: var(--ink-3); }

.portal-foot {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-2);
}

.portal-soon { background: linear-gradient(160deg, #fbfbfc 40%, #f3f4f6 100%); }
.portal-ascii {
  position: relative;
  flex: 1;
  min-height: 62px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  opacity: .5;
}
.portal-ascii .lane {
  height: 2px;
  border-radius: 2px;
  background: repeating-linear-gradient(90deg, #c9ced8 0 12px, transparent 12px 24px);
}
.portal-ascii .lane:nth-child(2) { width: 72%; }
.portal-ascii .lane:nth-child(3) { width: 44%; }
.portal-ascii .cone {
  position: absolute;
  left: 50%;
  bottom: -4px;
  transform: translateX(-50%);
  font-size: 22px;
  color: #b9c0cc;
}

.dot-muted { background: #c9ced8; }

/* ---------- 此路不通 ---------- */
.soon {
  max-width: 440px;
  margin: 0 auto;
  padding: 76px 20px;
  text-align: center;
}
.soon-art {
  position: relative;
  height: 88px;
  margin-bottom: 26px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
}
.soon-road {
  height: 3px;
  border-radius: 3px;
  background: repeating-linear-gradient(90deg, #d3d8e1 0 16px, transparent 16px 32px);
}
.soon-cone { font-size: 40px; line-height: 1; color: #c2c9d4; }
.soon-title {
  margin: 0 0 10px;
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -.02em;
}
.soon-text { margin: 0 0 28px; color: var(--ink-2); font-size: 14px; line-height: 1.7; }
.soon-back { display: inline-block; text-decoration: none; }

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
  :root { --side-w: 218px; }
  .content { padding: 22px 20px 56px; }
}

@media (max-width: 860px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .26s cubic-bezier(.3, .8, .3, 1);
    width: 272px;
    box-shadow: 0 0 40px rgba(0, 0, 0, .3);
  }
  body.side-open .sidebar { transform: translateX(0); }
  .side-close { display: grid; place-items: center; }

  .side-scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(10, 12, 16, .45);
    opacity: 0;
    pointer-events: none;
    transition: opacity .24s ease;
    z-index: 55;
    -webkit-backdrop-filter: blur(1px);
    backdrop-filter: blur(1px);
  }
  body.side-open .side-scrim { opacity: 1; pointer-events: auto; }
  body.side-open { overflow: hidden; }

  .main { margin-left: 0; }

  .mobilebar {
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 40;
    padding: 11px 14px;
    background: rgba(255, 255, 255, .88);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
  }
  .burger {
    width: 36px; height: 36px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: 1px solid var(--line-2);
    border-radius: 10px;
    background: var(--bg);
    cursor: pointer;
    padding: 0;
  }
  .burger span {
    display: block;
    width: 15px; height: 1.8px;
    border-radius: 2px;
    background: var(--ink);
  }
  .mobile-title {
    flex: 1;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .content { padding: 16px 14px 52px; }
  .messages { padding: 0 14px; }

  .portal { padding: 18px 0 40px; }
  .portal-title { font-size: 22px; }
  .portal-grid { grid-template-columns: 1fr; gap: 14px; }
  .portal-card { min-height: 0; padding: 18px; }
  .portal-name { font-size: 18.5px; }

  /* 表格自带 440/620px 最小宽度，网格列默认 min-width:auto 会被它撑破
     手机屏幕，这里显式归零让卡片留在视口内，横向滚动交给表格自己 */
  .grid-2, .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .grid-2 > *, .detail-grid > * { min-width: 0; }
  .card { min-width: 0; }

  /* 表格在手机上不再横向滚动：620/440px 的最小宽度只能看到三分之一，
     剩下的列全被裁在屏幕外。这里改成「一张记录一张卡」，每格带上列名，
     所有字段都读得到，不用左右拖。 */
  .table-stack,
  .table-stack tbody,
  .table-stack tr,
  .table-stack td {
    display: block;
    width: auto;
    min-width: 0;
    white-space: normal;
  }
  .table-stack { overflow: visible; }
  .table-stack thead { display: none; }
  .table-stack tbody { min-width: 0; }

  .table-stack tr {
    position: relative;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 13px 15px;
    margin-bottom: 10px;
    background: var(--bg);
  }
  /* tr 上的 display:block 会盖掉浏览器对 [hidden] 的默认隐藏，
     活动页的展开行必须显式关掉 */
  .table-stack tr[hidden] { display: none; }
  .table-stack tbody tr:last-child { margin-bottom: 0; }
  .table-stack tbody tr:hover { background: var(--bg); }
  .table-stack tr.row-active { background: #fffafb; border-color: #f3d3d9; }
  .table-stack tr.row-live { background: #fbfefc; border-color: #d6ecdf; }

  .table-stack td {
    padding: 3.5px 0;
    border: 0;
    overflow-wrap: anywhere;
  }
  /* 省略号在卡片里会把内容吞掉，这里放开换行 */
  .table-stack td.ellipsis { max-width: none; overflow: visible; text-overflow: clip; }

  .table-stack td[data-label] {
    display: grid;
    grid-template-columns: 62px minmax(0, 1fr);
    gap: 10px;
    align-items: baseline;
  }
  .table-stack td[data-label]::before {
    content: attr(data-label);
    font-size: 11.5px;
    font-weight: 600;
    color: var(--ink-3);
    letter-spacing: .02em;
  }
  .table-stack td.cell-title {
    font-size: 14.5px;
    font-weight: 600;
    padding: 0 0 8px;
    margin-bottom: 5px;
    border-bottom: 1px solid var(--line);
  }
  /* 只有右上角真的放了按钮/徽章时才让出那条空间 */
  .table-stack tr:has(> .cell-aside) > td.cell-title { padding-right: 52px; }
  .table-stack td.cell-aside {
    position: absolute;
    top: 11px;
    right: 11px;
    padding: 0;
  }

  /* 展开的详情行属于上一张卡，去掉外框贴着走 */
  .table-stack tr.detail-row {
    border: 0;
    padding: 0 0 0 6px;
    margin: -6px 0 12px;
    background: transparent;
  }
  .table-stack tr.detail-row[hidden] { display: none; }
  .table-stack tr.detail-row > td { display: block; }
  .table-stack tr.detail-row .detail-grid { grid-template-columns: minmax(0, 1fr); }

  /* 卡片内的紧凑表：细线分隔，不再套一层边框 */
  .table-stack-lite,
  .table-stack-lite tbody,
  .table-stack-lite tr,
  .table-stack-lite td {
    display: block;
    width: auto;
    min-width: 0;
    white-space: normal;
  }
  .table-stack-lite { overflow: visible; }
  .table-stack-lite thead { display: none; }
  .table-stack-lite tbody { min-width: 0; }
  .table-stack-lite tr {
    padding: 9px 0;
    border-bottom: 1px solid var(--line);
  }
  .table-stack-lite tr:last-child { border-bottom: 0; }
  .table-stack-lite td { padding: 1.5px 0; border: 0; overflow-wrap: anywhere; }
  .table-stack-lite td.ellipsis { max-width: none; overflow: visible; text-overflow: clip; }
  .table-stack-lite td[data-label] {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 8px;
    align-items: baseline;
  }
  .table-stack-lite td[data-label]::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    color: var(--ink-3);
  }
  .table-stack-lite td.cell-title { font-weight: 600; padding-bottom: 2px; }

  .btn-primary, .btn-ghost { padding: 10px 16px; font-size: 13.5px; min-height: 42px; }
  .btn-sm { padding: 8px 12px; min-height: 40px; }
  .tab { padding: 8px 13px; min-height: 40px; }

  /* 手机端点按目标不小于 40px，按钮铺满可点区域 */
  .side-close { width: 40px; height: 40px; font-size: 20px; }
  .module-actions { gap: 8px; }
  .module-actions button { flex: 1; min-height: 40px; }
  .preset-forms { gap: 8px; }
  .preset-forms .role-btn, .role-btn { min-height: 40px; padding: 8px 14px; }
  .prize-block { min-width: 30px; min-height: 30px; }
  /* 行内文字链接默认只有 17px 高，手机上很难点中：撑满所在表格行 */
  .link, .row-link { display: inline-flex; align-items: center; min-height: 40px; }
  .mini-link { min-height: 34px; padding: 4px 10px; }
  .expand-btn { width: 36px; height: 36px; font-size: 13px; }
  .side-logout { width: 40px; height: 40px; font-size: 16px; }

  .page-title { font-size: 21px; }
  .page-head { margin-bottom: 16px; }

  .filterbar { gap: 8px; }
  .filterbar .input { min-width: 0; }

  .admin-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

@media (max-width: 480px) {
  .portal-stats { gap: 18px; }
  .pstat-num { font-size: 17px; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* 内容区最大宽度，避免超宽屏拉伸 */
.content > .wrap,
.content > .portal { max-width: 1320px; margin-left: auto; margin-right: auto; }

/* 未登录：登录页等 */
.anon-wrap { min-height: 100vh; background: var(--bg); }

/* 未登录：主区占满，无侧栏偏移 */
.shell-anon .main { margin-left: 0; }
.shell-anon { background: var(--bg); }
