/* ============================================================================
 * 页面层（Pages / Layout）
 * ============================================================================
 *
 * 第四层：壳层布局 + 页面级排版。`.p-` 前缀。
 *
 * 结构对齐 DSH：
 *
 *   ┌──────────┬──────────────────────────────────────────┐
 *   │ ⚡ ltjz   │ 功能与配置                    刷新       │  .p-head
 *   │          ├──────────────────────────────────────────┤
 *   │ 概览     │ 核心流程   进度与解锁   经济与奖励        │  .p-tabs（二级）
 *   │ 功能与配置│ ▔▔▔▔▔▔▔▔▔▔▔                             │
 *   │ 用户存档  ├──────────────────────────────────────────┤
 *   │ 活动时间表│                                          │
 *   │ 请求日志  │  内容                                    │  .p-body
 *   │ ──────── │                                          │
 *   │ ◐ 13 账号│                                          │
 *   └──────────┴──────────────────────────────────────────┘
 *
 * 层级职责：
 *   左侧栏  = 一级导航（页面）
 *   顶部 tab = 二级导航（页面内分组）
 *   顶栏    = 页面名 + 页面操作
 * ========================================================================== */

/* ---------------------------------------------------------------------------
 * 壳层
 * ------------------------------------------------------------------------- */
.p-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--surface-canvas);
}

/* ---------------------------------------------------------------------------
 * 左侧栏
 * ------------------------------------------------------------------------- */
.p-sidebar {
  display: flex;
  flex-direction: column;
  background: var(--surface-raised);
  border-right: 1px solid var(--dsw-alias-border-l2);
  overflow: hidden;
}

.p-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 7px;
  height: var(--header-h);
  flex: 0 0 auto;
  padding: 0 var(--sp-4);
  border-bottom: 1px solid var(--dsw-alias-border-l2);
}

.p-sidebar__brand-icon {
  font-size: 15px;
  line-height: 1;
}

.p-sidebar__brand-name {
  font-size: var(--fs-md);
  font-weight: 600;
  letter-spacing: 0.2px;
}

.p-sidebar__nav {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--sp-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* 一级导航项 */
.p-navitem {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 10px;
  font-family: inherit;
  font-size: var(--fs-md);
  color: var(--dsw-alias-label-secondary);
  background: none;
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  transition: background var(--ds-transition-duration) var(--ds-ease-in-out),
    color var(--ds-transition-duration) var(--ds-ease-in-out);
}

.p-navitem:hover {
  background: var(--surface-hover);
  color: var(--dsw-alias-label-primary);
  text-decoration: none;
}

.p-navitem[aria-current='page'] {
  background: var(--surface-sunken);
  color: var(--dsw-alias-label-primary);
  font-weight: 500;
}

.p-navitem__icon {
  flex: 0 0 16px;
  text-align: center;
  font-size: var(--fs-sm);
  opacity: 0.75;
  line-height: 1;
}

.p-navitem__label {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 侧栏底部：主题 + 状态 */
.p-sidebar__foot {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex: 0 0 auto;
  padding: var(--sp-2) var(--sp-3);
  border-top: 1px solid var(--dsw-alias-border-l2);
  font-size: var(--fs-xs);
  color: var(--dsw-alias-label-caption);
}

.p-sidebar__iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 13px;
  color: var(--dsw-alias-label-tertiary);
  background: none;
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  flex: 0 0 auto;
  transition: background var(--ds-transition-duration) var(--ds-ease-in-out);
}
.p-sidebar__iconbtn:hover {
  background: var(--surface-hover);
  color: var(--dsw-alias-label-primary);
}

.p-sidebar__status {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  margin-left: auto;
}

.p-sidebar__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--semantic-ok);
  flex: 0 0 auto;
  transition: background var(--ds-transition-duration) var(--ds-ease-in-out);
}
.p-sidebar__dot[data-off='true'] {
  background: var(--semantic-err);
}

/* ---------------------------------------------------------------------------
 * 主区
 * ------------------------------------------------------------------------- */
.p-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: var(--surface-canvas);
}

/* 顶栏：页面名 + 操作 */
.p-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  height: var(--header-h);
  flex: 0 0 auto;
  padding: 0 var(--sp-5);
  background: var(--surface-canvas);
}

.p-head__title {
  font-size: var(--fs-xl);
  font-weight: 600;
  letter-spacing: -0.1px;
}

.p-head__spacer {
  flex: 1 1 auto;
}

.p-head__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* ---------------------------------------------------------------------------
 * 二级 tab（页面内分组，DSH 风格：文字 + 下划线）
 * ------------------------------------------------------------------------- */
.p-tabs {
  display: flex;
  align-items: stretch;
  gap: 4px;
  height: 38px;
  flex: 0 0 auto;
  padding: 0 var(--sp-5);
  border-bottom: 1px solid var(--dsw-alias-border-l2);
  overflow-x: auto;
  scrollbar-width: none;
}
.p-tabs::-webkit-scrollbar {
  display: none;
}
.p-tabs[hidden] {
  display: none;
}

.p-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  font-family: inherit;
  font-size: var(--fs-md);
  font-weight: 400;
  color: var(--dsw-alias-label-tertiary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  /* 下划线与文字底部对齐 */
  margin-bottom: -1px;
  transition: color var(--ds-transition-duration) var(--ds-ease-in-out),
    border-color var(--ds-transition-duration) var(--ds-ease-in-out);
}

.p-tab:hover {
  color: var(--dsw-alias-label-primary);
}

.p-tab[aria-selected='true'] {
  color: var(--dsw-alias-label-primary);
  font-weight: 500;
  border-bottom-color: var(--accent);
}

.p-tab__count {
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  color: var(--dsw-alias-label-caption);
  padding: 0 5px;
  border-radius: var(--r-full);
  background: var(--surface-sunken);
}

.p-tab[aria-selected='true'] .p-tab__count {
  color: var(--dsw-alias-label-secondary);
}

/* ---------------------------------------------------------------------------
 * 内容区
 * ------------------------------------------------------------------------- */
/* body 的左右内边距必须和 .p-head 一致（都是 sp-5），
 * 否则内容左边缘和页标题错开。 */
.p-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--sp-4) var(--sp-5) var(--sp-6);
}

/* 页面根节点：默认窄栏（表单类），--wide 用于列表/表格 */
/* 页面内容默认左对齐（与顶栏标题同一左边缘），不再居中
 *
 * 之前用 `margin: 0 auto` 居中 —— 侧栏占 216px 后，
 * 内容左边缘跑到 x≈400，而顶栏标题在 x≈237，两条竖线不齐，看着别扭。
 * DSH 的做法是内容与顶栏左对齐。 */
.p-page {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 900px;
  width: 100%;
}

/* 宽栏（列表/表格类） */
.p-page--wide {
  max-width: 100%;
}

/* 两栏（列表 + 详情） */
.p-split {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  gap: var(--sp-3);
  align-items: start;
}

/* 网格 */
.p-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 10px;
}

/* ---------------------------------------------------------------------------
 * 日志页专用
 * ------------------------------------------------------------------------- */
.p-loglist {
  display: flex;
  flex-direction: column;
  font-family: var(--dsw-font-mono);
  font-size: var(--fs-sm);
  line-height: 1.7;
}
.p-logrow {
  display: grid;
  grid-template-columns: 76px 56px minmax(0, 1fr) 64px 60px;
  gap: var(--sp-2);
  padding: 2px var(--sp-4);
  border-bottom: 1px solid var(--dsw-alias-border-l2);
}
.p-logrow:hover {
  background: var(--surface-hover);
}
.p-logrow--err {
  color: var(--semantic-err);
}
.p-logrow__ts {
  color: var(--dsw-alias-label-caption);
}

/* ---------------------------------------------------------------------------
 * 窄屏：侧栏收起
 * ------------------------------------------------------------------------- */
@media (max-width: 760px) {
  .p-shell {
    grid-template-columns: 0 minmax(0, 1fr);
  }
  .p-sidebar {
    display: none;
  }
  .p-split {
    grid-template-columns: 1fr;
  }
  .p-body,
  .p-head,
  .p-tabs {
    padding-left: var(--sp-3);
    padding-right: var(--sp-3);
  }
}

/* Audit and inventory tables remain readable at small widths. */
.p-audit-note { padding: var(--sp-3) var(--sp-4); color: var(--dsw-alias-label-secondary); line-height: 1.7; font-size: var(--fs-sm); }
.p-logentry > summary { cursor: pointer; list-style: none; }
.p-logentry pre { margin: 0; padding: var(--sp-3) var(--sp-4); max-height: 360px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.p-page .c-card__body { min-width: 0; overflow-x: auto; }
.p-page pre { max-width: 100%; overflow-x: auto; }
@media (max-width: 760px) {
  .p-shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .p-sidebar { display: block; width: auto; border-right: 0; border-bottom: 1px solid var(--dsw-alias-border-l2); padding: 4px 8px; }
  .p-sidebar__brand { display: none; }
  .p-sidebar__foot { display: flex; padding: 4px 8px; margin-top: 4px; }
  .p-sidebar__status { flex: 1; }
  .p-sidebar__nav { display: flex; flex-direction: row; overflow-x: auto; padding: 0; }
  .p-navitem { flex: 0 0 auto; }
  .p-main { min-height: 0; }
  .c-stats { flex-wrap: wrap; }
  .p-logrow { grid-template-columns: 70px 42px minmax(0,1fr) 45px 34px; gap: 4px; padding: 6px 8px; }
}
.p-table-scroll { overflow-x: auto; }
.p-table-scroll .c-table { min-width: 900px; }
.p-table-scroll .c-table td { word-break: normal; }
@media (max-width: 760px) {
  .p-navitem { width: auto; min-width: 104px; }
}
@media (max-width: 760px) {
  .p-page .c-card__head { flex-wrap: wrap; align-items: flex-start; }
  .p-page .c-card__title { flex-shrink: 0; max-width: 100%; }
  .p-page .c-card__sub { flex-basis: 100%; overflow-wrap: anywhere; }
}

/* Wide encounter contracts stay readable inside the card on narrow screens. */
.p-hyper-boss-table .c-table { min-width: 1450px; }
.p-hyper-boss-table .c-table th,
.p-hyper-boss-table .c-table td:nth-child(-n+6),
.p-hyper-boss-table .c-table td:last-child { white-space: nowrap; }
.p-hyper-boss-table .c-table td:nth-child(7) { min-width: 240px; }
.p-hyper-boss-table .c-table td:nth-child(8) { min-width: 360px; }

/* Silk presets share the client's row/column anchor geometry. */
.p-silk-grid{position:relative;display:grid;width:min(100%,320px);aspect-ratio:1;isolation:isolate;margin:12px 0;background:var(--dsw-alias-bg-skeleton);border-radius:12px}
.p-silk-grid svg{position:absolute;inset:0;width:100%;height:100%;pointer-events:none;color:var(--dsw-static-deepseek-500);z-index:-1}
.p-silk-anchor{justify-self:center;align-self:center;width:36px;height:36px;border:1px solid currentColor;border-radius:50%;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);cursor:pointer}
.p-silk-anchor[aria-pressed=true]{outline:3px solid var(--dsw-static-deepseek-500);outline-offset:3px}
.p-silk-line{display:flex;align-items:center;gap:16px;padding:3px 0}

/* Login has its own vertical form at every width; admin parameter rows use a
 * different grid and must not determine credential input sizing. */
.p-login {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}
.p-login__card {
  width: 100%;
  max-width: 440px;
  min-width: 0;
  padding: 36px;
  background: var(--surface-raised);
  border: 1px solid var(--dsw-alias-border-l2);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgb(0 0 0 / 4%);
}
.p-login__header { margin-bottom: 28px; }
.p-login__header h1 { font-size: 24px; line-height: 1.4; }
.p-login__header p {
  margin-top: 10px;
  font-size: 14px;
  color: var(--dsw-alias-label-secondary);
}
.p-login__form { display: grid; gap: 20px; }
.p-login__field { display: grid; gap: 8px; min-width: 0; }
.p-login__field label {
  font-size: 14px;
  font-weight: 500;
  color: var(--dsw-alias-label-secondary);
}
.p-login .c-input {
  width: 100%;
  max-width: none;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  font-size: 16px;
  border-radius: 8px;
}
.p-login .c-btn { min-height: 44px; font-size: 15px; border-radius: 8px; }
.p-login__message { color: var(--semantic-err); font-size: 13px; overflow-wrap: anywhere; }
.p-login__hint {
  margin-top: 24px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--dsw-alias-label-tertiary);
}
@media (max-width: 480px) {
  .p-login { padding: 24px 16px; }
  .p-login__card { padding: 28px 24px; }
  .p-login__header h1 { font-size: 22px; }
}

.p-sidebar__foot .p-sidebar__iconbtn {
  width: auto;
  min-width: 28px;
  padding: 0 6px;
  white-space: nowrap;
}
