/* ==========================================================================
   PiLive — 控制台外壳
   SaaS 规范：两级导航 / 应用栏 / 视图页头 / 页内标签 / 浮层
   界面文案一律中文；等宽字体只用于数字、时间与标识符
   ========================================================================== */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns var(--dur-base) var(--ease-out);
}

.app.is-collapsed { grid-template-columns: var(--sidebar-w-min) minmax(0, 1fr); }

/* --------------------------------------------------------------------------
   侧边栏
   -------------------------------------------------------------------------- */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper-0);
  border-right: 1px solid var(--line);
  min-width: 0;
}

.sidebar__top { padding: 10px; border-bottom: 1px solid var(--line-soft); }

/* 工作区切换器 */
.ws {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: var(--r-md);
  text-align: left;
  transition: background var(--dur-fast) var(--ease-out);
}

.ws:hover { background: var(--paper-2); }
.ws[aria-expanded="true"] { background: var(--paper-2); }

.ws__logo {
  width: 26px; height: 26px;
  flex: none;
  border-radius: 6px;
  background: var(--violet);
  color: oklch(100% 0 0);
  display: grid;
  place-items: center;
  font-size: var(--t-xs);
  font-weight: 700;
}

.ws__text { flex: 1; min-width: 0; }

.ws__name {
  display: block;
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--ink-900);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ws__plan { display: block; font-size: var(--t-2xs); color: var(--ink-400); }
.ws__caret { width: 14px; height: 14px; flex: none; color: var(--ink-300); }

/* 导航 */
.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 10px 16px;
  scrollbar-width: thin;
}

.navitem {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 9px;
  border-radius: var(--r-md);
  font-size: var(--t-sm);
  color: var(--ink-700);
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}

.navitem > svg { width: 16px; height: 16px; flex: none; color: var(--ink-400); }
.navitem:hover { background: var(--paper-2); color: var(--ink-900); }
.navitem:hover > svg { color: var(--ink-700); }

.navitem[aria-current="page"] {
  background: var(--violet-wash);
  color: var(--violet-deep);
  font-weight: 600;
}

.navitem[aria-current="page"] > svg { color: var(--violet); }

.navitem__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.navitem__count {
  font-family: var(--font-mono);
  font-size: var(--t-2xs);
  color: var(--ink-300);
  font-variant-numeric: tabular-nums;
}

/* 分组（可折叠） */
.navsec { margin-top: 2px; }

.navsec__head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 9px;
  border-radius: var(--r-md);
  font-size: var(--t-sm);
  color: var(--ink-700);
  transition: background var(--dur-fast) var(--ease-out);
}

.navsec__head:hover { background: var(--paper-2); color: var(--ink-900); }
.navsec__head > svg:first-child { width: 16px; height: 16px; flex: none; color: var(--ink-400); }
.navsec__head .navitem__label { text-align: left; }

.navsec__chev {
  width: 13px; height: 13px;
  flex: none;
  color: var(--ink-300);
  transition: transform var(--dur-base) var(--ease-out);
}

.navsec[data-open="true"] .navsec__chev { transform: rotate(90deg); }

.navsec__body {
  display: none;
  margin: 2px 0 4px 18px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}

.navsec[data-open="true"] .navsec__body { display: block; }

.navsec__body .navitem { height: 31px; font-size: var(--t-sm); }

/* 底部 */
.sidebar__foot {
  padding: 10px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.usage { padding: 8px 9px; border-radius: var(--r-md); background: var(--paper-1); }
.usage__top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.usage__name { font-size: var(--t-2xs); color: var(--ink-500); }
.usage__num { font-family: var(--font-mono); font-size: var(--t-2xs); color: var(--ink-700); font-variant-numeric: tabular-nums; }
.usage__track { height: 3px; border-radius: 2px; background: var(--paper-3); overflow: hidden; }
.usage__fill { height: 100%; background: var(--violet); border-radius: 2px; }

/* 收起态：只留图标 */
.app.is-collapsed .ws__text,
.app.is-collapsed .ws__caret,
.app.is-collapsed .navitem__label,
.app.is-collapsed .navitem__count,
.app.is-collapsed .navsec__chev,
.app.is-collapsed .navsec__body,
.app.is-collapsed .usage,
.app.is-collapsed .badge--live span { display: none; }

.app.is-collapsed .navitem,
.app.is-collapsed .navsec__head { justify-content: center; padding: 0; }

/* 收起后「直播中」只保留脉冲点 */
.app.is-collapsed .badge--live {
  position: absolute;
  margin-left: 22px;
  height: auto;
  padding: 0;
  background: none;
}

.app.is-collapsed .sidebar__nav { padding-inline: 8px; }

/* --------------------------------------------------------------------------
   应用栏
   -------------------------------------------------------------------------- */

.appbar {
  position: sticky;
  top: 0;
  z-index: 60;
  height: var(--appbar-h);
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 0 var(--view-pad);
  background: oklch(100% 0 0 / 0.86);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.crumb {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: var(--t-sm);
  color: var(--ink-400);
  min-width: 0;
}

.crumb a { color: var(--ink-500); }
.crumb a:hover { color: var(--violet); }
.crumb b { color: var(--ink-900); font-weight: 500; }
.crumb i { font-style: normal; opacity: 0.45; }

/* 全局搜索 */
.omnibox {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  width: clamp(180px, 22vw, 300px);
  height: 32px;
  padding: 0 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--paper-1);
  color: var(--ink-400);
  font-size: var(--t-sm);
  transition: border-color var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out);
}

.omnibox:hover { border-color: var(--line-strong); background: var(--paper-0); }
.omnibox svg { width: 14px; height: 14px; flex: none; }
.omnibox span { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.kbd {
  font-family: var(--font-mono);
  font-size: var(--t-2xs);
  color: var(--ink-400);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  background: var(--paper-0);
}

.appbar__right { display: flex; align-items: center; gap: 4px; }

.iconbtn {
  position: relative;
  width: 32px; height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  color: var(--ink-500);
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.iconbtn svg { width: 16px; height: 16px; }
.iconbtn:hover { background: var(--paper-2); color: var(--ink-900); }
.iconbtn[aria-expanded="true"] { background: var(--paper-2); color: var(--ink-900); }

.iconbtn__dot {
  position: absolute;
  top: 6px; right: 7px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--violet);
  border: 1.5px solid var(--paper-0);
}

.avatar {
  width: 28px; height: 28px;
  margin-left: 4px;
  border-radius: 50%;
  background: var(--ink-900);
  color: oklch(100% 0 0);
  display: grid;
  place-items: center;
  font-size: var(--t-2xs);
  font-weight: 600;
}

.avatar:hover { background: var(--violet-deep); }

/* --------------------------------------------------------------------------
   浮层菜单
   -------------------------------------------------------------------------- */

.pop { position: relative; }

.menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: var(--z-menu);
  min-width: 216px;
  padding: 6px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--paper-0);
  box-shadow: var(--shadow-lift);
  display: none;
}

.menu.is-open { display: block; animation: menuIn var(--dur-fast) var(--ease-out); }
.menu--right { left: auto; right: 0; }
.menu--wide { min-width: 320px; }

/* 工作区菜单贴着侧栏内缘，不顶到视口边 */
.sidebar__top .menu { left: 10px; min-width: 258px; }

@keyframes menuIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

.menu__label {
  padding: 7px 9px 5px;
  font-size: var(--t-2xs);
  color: var(--ink-400);
}

.menu__item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: var(--r-sm);
  font-size: var(--t-sm);
  color: var(--ink-700);
  text-align: left;
  transition: background var(--dur-fast) var(--ease-out);
}

.menu__item:hover { background: var(--paper-2); color: var(--ink-900); }
.menu__item svg { width: 15px; height: 15px; flex: none; color: var(--ink-400); }
.menu__item[aria-checked="true"] { color: var(--violet-deep); font-weight: 600; }
.menu__item[aria-checked="true"] svg { color: var(--violet); }
.menu__sep { height: 1px; margin: 5px 0; background: var(--line-soft); }
.menu__tail { margin-left: auto; font-size: var(--t-2xs); color: var(--ink-300); font-family: var(--font-mono); }

/* 通知条目 */
.notif {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  gap: 9px;
  padding: 9px;
  border-radius: var(--r-sm);
  transition: background var(--dur-fast) var(--ease-out);
}

.notif:hover { background: var(--paper-2); }
.notif::before { content: ""; width: 6px; height: 6px; margin-top: 6px; border-radius: 50%; background: var(--line-strong); }
.notif.is-new::before { background: var(--violet); }
.notif__t { display: block; font-size: var(--t-sm); color: var(--ink-900); margin-bottom: 2px; }
.notif__d { display: block; font-size: var(--t-xs); color: var(--ink-500); line-height: 1.6; }
.notif__time { display: block; margin-top: 4px; font-size: var(--t-2xs); color: var(--ink-300); font-family: var(--font-mono); }

/* --------------------------------------------------------------------------
   视图容器
   -------------------------------------------------------------------------- */

.content { min-width: 0; background: var(--paper-1); display: flex; flex-direction: column; }

.view { padding: var(--view-pad) var(--view-pad) 72px; max-width: 1520px; width: 100%; }

.view-head {
  display: flex;
  align-items: flex-start;
  gap: var(--s-5);
  flex-wrap: wrap;
  margin-bottom: var(--s-4);
}

.view-head__main { flex: 1; min-width: 260px; }

.view-head__title {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-size: var(--t-xl);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.3;
  color: var(--ink-900);
}

.view-head__desc {
  margin-top: 5px;
  font-size: var(--t-sm);
  color: var(--ink-500);
  max-width: 74ch;
  line-height: 1.65;
}

.view-head__actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }

/* 页内标签 —— 模块内视图切换 */
.tabbar {
  display: flex;
  align-items: center;
  gap: var(--s-5);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--s-5);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabbar::-webkit-scrollbar { display: none; }

.tabbar__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 0 10px;
  font-size: var(--t-sm);
  color: var(--ink-500);
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease-out);
}

.tabbar__item:hover { color: var(--ink-900); }

.tabbar__item[aria-current="page"],
.tabbar__item[aria-selected="true"] { color: var(--violet-deep); font-weight: 600; }

.tabbar__item[aria-current="page"]::after,
.tabbar__item[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: var(--violet);
  border-radius: 1px;
}

.tabbar__num {
  font-family: var(--font-mono);
  font-size: var(--t-2xs);
  color: var(--ink-300);
  font-variant-numeric: tabular-nums;
}

/* 工具栏：筛选在左，操作在右 */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex-wrap: wrap;
  margin-bottom: var(--s-4);
}

.toolbar__spacer { flex: 1 1 auto; min-width: 0; }

/* 步骤条 —— 流程型模块的进度指示 */
.steps-bar { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }

.steps-bar__item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px 5px 7px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--paper-0);
  font-size: var(--t-xs);
  color: var(--ink-500);
  transition: all var(--dur-fast) var(--ease-out);
}

.steps-bar__item:hover { border-color: var(--line-strong); color: var(--ink-900); }

.steps-bar__n {
  width: 18px; height: 18px;
  flex: none;
  border-radius: 50%;
  background: var(--paper-3);
  color: var(--ink-500);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: var(--t-2xs);
  font-weight: 600;
}

.steps-bar__item[aria-current="step"] {
  border-color: var(--line-violet);
  background: var(--violet-wash);
  color: var(--violet-deep);
  font-weight: 600;
}

.steps-bar__item[aria-current="step"] .steps-bar__n { background: var(--violet); color: oklch(100% 0 0); }
.steps-bar__item.is-done .steps-bar__n { background: var(--ds-pos); color: oklch(100% 0 0); }
.steps-bar__sep { width: 14px; height: 1px; background: var(--line); flex: none; }

/* --------------------------------------------------------------------------
   徽标 / 状态
   -------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 19px;
  padding: 0 7px;
  border-radius: var(--r-xs);
  font-size: var(--t-2xs);
  font-weight: 600;
  background: var(--paper-3);
  color: var(--ink-500);
}

.badge--live { background: var(--violet-wash); color: var(--violet-deep); }

.badge--live::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--violet);
  animation: blip 2s var(--ease-io) infinite;
}

@keyframes blip { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* --------------------------------------------------------------------------
   模态框
   -------------------------------------------------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  background: oklch(21% 0.021 291 / 0.34);
  backdrop-filter: blur(2px);
  display: none;
  place-items: center;
  padding: var(--s-5);
}

.overlay.is-open { display: grid; animation: fadeIn var(--dur-fast) var(--ease-out); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: min(520px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--paper-0);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lift);
  animation: modalIn var(--dur-base) var(--ease-out);
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

.modal__head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 16px var(--s-5);
  border-bottom: 1px solid var(--line-soft);
}

.modal__title { font-size: var(--t-md); font-weight: 650; color: var(--ink-900); }
.modal__body { padding: var(--s-5); }
.modal__foot {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  justify-content: flex-end;
  padding: 14px var(--s-5);
  border-top: 1px solid var(--line-soft);
  background: var(--paper-1);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* 表单 */
.formrow { margin-bottom: var(--s-4); }
.formrow:last-child { margin-bottom: 0; }
.formrow__label { display: block; font-size: var(--t-sm); font-weight: 550; color: var(--ink-900); margin-bottom: 6px; }
.formrow__hint { display: block; font-size: var(--t-xs); color: var(--ink-400); margin-top: 6px; }

.input, .select {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--paper-0);
  font-size: var(--t-sm);
  color: var(--ink-900);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}

.input::placeholder { color: var(--ink-300); }
.input:focus, .select:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px var(--violet-a14); }
.select { appearance: none; padding-right: 30px; cursor: pointer; }

/* --------------------------------------------------------------------------
   轻提示
   -------------------------------------------------------------------------- */

.toaster {
  position: fixed;
  right: var(--s-5);
  bottom: var(--s-5);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
  max-width: 360px;
  padding: 11px 14px;
  border-radius: var(--r-md);
  background: var(--ink-900);
  color: oklch(100% 0 0 / 0.92);
  font-size: var(--t-sm);
  box-shadow: var(--shadow-lift);
  animation: toastIn var(--dur-base) var(--ease-out);
}

.toast svg { width: 15px; height: 15px; flex: none; color: var(--violet-soft); }
.toast.is-out { animation: toastOut var(--dur-base) var(--ease-out) forwards; }

@keyframes toastIn  { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }

/* --------------------------------------------------------------------------
   表格增强 / 空状态 / 分页
   -------------------------------------------------------------------------- */

.check {
  width: 15px; height: 15px;
  flex: none;
  border-radius: 3px;
  border: 1px solid var(--line-strong);
  background: var(--paper-0);
  display: inline-grid;
  place-items: center;
  transition: all var(--dur-fast) var(--ease-out);
}

.check::after {
  content: "";
  width: 4px; height: 7px;
  border-right: 1.6px solid oklch(100% 0 0);
  border-bottom: 1.6px solid oklch(100% 0 0);
  transform: rotate(42deg) translateY(-1px);
  opacity: 0;
}

.check[aria-checked="true"] { background: var(--violet); border-color: var(--violet); }
.check[aria-checked="true"]::after { opacity: 1; }
.tbl td .check, .tbl th .check { vertical-align: middle; }

.tbl tbody tr.is-picked { background: var(--violet-wash); }

.rowact {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-out);
}

.tbl tbody tr:hover .rowact,
.tbl tbody tr:focus-within .rowact { opacity: 1; }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 56px var(--s-5);
  text-align: center;
}

.empty svg { width: 26px; height: 26px; color: var(--ink-300); }
.empty__t { font-size: var(--t-sm); font-weight: 600; color: var(--ink-700); }
.empty__d { font-size: var(--t-xs); color: var(--ink-400); max-width: 40ch; line-height: 1.7; }

.pager {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 12px var(--s-4);
  border-top: 1px solid var(--line-soft);
  font-size: var(--t-xs);
  color: var(--ink-400);
}

.pager__nums { margin-left: auto; display: flex; align-items: center; gap: 3px; }

.pager__n {
  min-width: 26px; height: 26px;
  padding: 0 7px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  color: var(--ink-500);
  transition: background var(--dur-fast) var(--ease-out);
}

.pager__n:hover { background: var(--paper-2); color: var(--ink-900); }
.pager__n[aria-current="page"] { background: var(--violet); color: oklch(100% 0 0); font-weight: 600; }

/* --------------------------------------------------------------------------
   响应
   -------------------------------------------------------------------------- */

@media (max-width: 1080px) {
  .app { grid-template-columns: minmax(0, 1fr); }

  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: var(--sidebar-w);
    z-index: var(--z-overlay);
    transform: translateX(-100%);
    transition: transform var(--dur-base) var(--ease-out);
    box-shadow: var(--shadow-lift);
  }

  .app.is-open .sidebar { transform: none; }
  .app.is-collapsed { grid-template-columns: minmax(0, 1fr); }
  .appbar__toggle { display: grid !important; }
  .omnibox span, .omnibox .kbd { display: none; }
  .omnibox { width: 32px; padding: 0; justify-content: center; }
}

@media (min-width: 1081px) {
  .appbar__toggle { display: none; }
}

@media (max-width: 720px) {
  .view-head__actions { width: 100%; }
  .toaster { right: var(--s-3); left: var(--s-3); bottom: var(--s-3); }
  .toast { max-width: none; }
}
