/* ============================================================
   KEKE 企业管理平台 · 静态 Demo
   layout.css — 外壳 / 侧边栏 / 顶栏 / 模块条 / 页面骨架
   视觉语言参考 PreAdmin(Kanakku)：深色菜单 + 白色顶栏 + 浅灰画布
   ============================================================ */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  align-items: start;
  transition: grid-template-columns .22s var(--ease);
}
.app.is-collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

/* ==================== 侧边栏 ==================== */
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
  color: var(--sidebar-item);
  background: var(--sidebar-bg);
  border-right: 1px solid rgba(255, 255, 255, .06);
  overflow: hidden;
}

/* 品牌区 */
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  height: 68px;
  padding: 0 20px;
  flex: none;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.brand__mark {
  width: 36px;
  height: 36px;
  flex: none;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(201, 162, 39, .45));
  transition: transform .22s var(--ease);
}
.brand:hover .brand__mark { transform: scale(1.06); }
.brand__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand__name {
  font-size: var(--fs-15);
  font-weight: 700;
  letter-spacing: .30em;
  color: #F3E6C2;
  line-height: 1.1;
}
.brand__sub {
  font-size: var(--fs-11);
  letter-spacing: .04em;
  color: rgba(190, 202, 220, .55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app.is-collapsed .brand { padding: 0; justify-content: center; }
.app.is-collapsed .brand__text { display: none; }

/* 导航 */
.nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 12px 20px;
}
.nav__section { margin-bottom: 4px; }

/* 模块头（当前模块） */
.nav__modhead {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 40px;
  padding: 0 11px;
  margin-bottom: 2px;
}
.nav__modhead .ico { color: var(--accent); flex: none; }
.nav__modname { font-size: var(--fs-14); font-weight: 600; color: #EEF3FA; }
.nav__count {
  margin-left: auto;
  font-size: var(--fs-11);
  color: rgba(190, 202, 220, .45);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* 分组标题（可折叠，与下方条目同字号） */
.nav__label {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  height: 34px;
  padding: 0 11px 0 35px;
  font-size: var(--fs-14);
  font-weight: 500;
  color: rgba(255, 255, 255, .52);
  text-align: left;
  transition: color .18s var(--ease);
}
.nav__label:hover { color: rgba(255, 255, 255, .85); }
.nav__label > .ico { flex: none; color: var(--gold); opacity: .85; }
.nav__label .nav__fold-caret {
  margin-left: auto;
  color: rgba(255, 255, 255, .35);
  transform: rotate(90deg);
  transition: transform .2s var(--ease), color .2s var(--ease);
}
.nav__label:hover .nav__fold-caret { color: rgba(255, 255, 255, .7); }
.nav__label.is-folded .nav__fold-caret { transform: rotate(0deg); }
.nav__label--top { padding-left: 11px; }
.nav__fold { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .24s var(--ease); }
.nav__fold > div { overflow: hidden; min-height: 0; }
.nav__fold.is-folded { grid-template-rows: 0fr; }
.app.is-collapsed .nav__label { justify-content: center; padding: 0; }
.app.is-collapsed .nav__label-text { display: none; }
.app.is-collapsed .nav__label .nav__fold-caret { transform: none; }

/* 栏目项 */
.nav__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 0 11px 0 35px;
  height: 36px;
  border-radius: var(--r-sm);
  font-size: var(--fs-14);
  font-weight: 400;
  color: var(--sidebar-item);
  text-align: left;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.nav__item + .nav__item { margin-top: 1px; }
.nav__item .ico { flex: none; color: rgba(170, 176, 186, .75); transition: color .18s var(--ease); }
.nav__item:hover { background: var(--sidebar-hover); color: #EDF2F8; }
.nav__item:hover .ico { color: var(--primary-200); }
.nav__item.is-active {
  color: #FFFFFF;
  font-weight: 500;
  background: var(--sidebar-active);
}
.nav__item.is-active .ico { color: var(--primary-200); }
.nav__item.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 16px;
  border-radius: 0 3px 3px 0;
  background: var(--primary);
}
.nav__text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 总览上下文：模块目录 */
.nav__item--mod { padding-left: 11px; height: 38px; }
.nav__item--mod .nav__modicon { flex: none; }
.nav__item .nav__modicon .ico { color: inherit; }

/* 模块首页行 */
.nav__home { font-weight: 500; color: #DEE7F4; }
.nav__home .nav__modicon { flex: none; }
.nav__home:not(.is-active):hover .ico { color: var(--primary-200); }
.app.is-collapsed .nav__text,
.app.is-collapsed .nav__count { display: none; }
.app.is-collapsed .nav__item { justify-content: center; padding: 0; }
.app.is-collapsed .nav__modhead { justify-content: center; padding: 0; }
.app.is-collapsed .nav__modname { display: none; }

/* 侧栏底部 */
.sidebar__foot {
  flex: none;
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, .07);
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar__foot .btn-ghost-dark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  color: rgba(190, 202, 220, .8);
  font-size: var(--fs-13);
  transition: background .18s var(--ease), color .18s var(--ease);
  width: 100%;
}
.sidebar__foot .btn-ghost-dark:hover { background: var(--sidebar-hover); color: #E9EFF7; }
.app.is-collapsed .sidebar__foot .btn-ghost-dark span { display: none; }
.app.is-collapsed .sidebar__foot { justify-content: center; }

/* ==================== 顶栏 ==================== */
.topbar-wrap {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  height: var(--topbar-h);
}

/* 面包屑 */
.crumbs { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 0 1 auto; overflow: hidden; }
.crumbs__grp { font-size: var(--fs-13); font-weight: 400; color: var(--muted); white-space: nowrap; }
.crumbs__sep { color: var(--border); font-size: var(--fs-13); }
.crumbs__cur { font-size: var(--fs-13); font-weight: 600; color: var(--heading); white-space: nowrap; }
.crumbs__tab { font-size: var(--fs-13); font-weight: 400; color: var(--muted); white-space: nowrap; }

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

/* 搜索 */
.searchbox {
  position: relative;
  display: flex;
  align-items: center;
  width: 268px;
  flex: 0 1 268px;
  min-width: 130px;
}
.searchbox .ico {
  position: absolute;
  left: 12px;
  color: var(--muted);
  pointer-events: none;
}
.searchbox input {
  width: 100%;
  height: 36px;
  padding: 0 36px 0 34px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--light);
  font-size: var(--fs-13);
  color: var(--heading);
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease);
}
.searchbox input::placeholder { color: var(--faint); }
.searchbox input:focus {
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .12);
}
.searchbox__kbd {
  position: absolute;
  right: 10px;
  font-size: var(--fs-11);
  color: var(--faint);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  padding: 1px 5px;
  background: var(--surface);
  pointer-events: none;
}
.searchbox input:focus ~ .searchbox__kbd { opacity: 0; }

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: 340px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-pop);
  padding: 6px;
  z-index: 60;
}
.search-results__item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: var(--fs-13);
  color: var(--heading);
  text-align: left;
}
.search-results__item:hover { background: var(--light); }
.search-results__item .ico { color: var(--muted); }
.search-results__meta { margin-left: auto; font-size: var(--fs-11); color: var(--faint); }

/* 图标按钮 */
.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  color: var(--body);
  border: 1px solid transparent;
  position: relative;
  transition: background .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease);
}
.iconbtn:hover { background: var(--light); color: var(--heading); }
.iconbtn--bordered { border-color: var(--border); background: var(--surface); }
.iconbtn--bordered:hover { border-color: var(--primary); color: var(--primary); }
.iconbtn__badge {
  position: absolute;
  top: 5px;
  right: 5px;
  min-width: 8px;
  height: 8px;
  border-radius: 99px;
  background: var(--danger);
  border: 1.5px solid var(--surface);
}

/* 用户 */
.userchip {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 38px;
  padding: 0 12px 0 5px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: box-shadow .18s var(--ease), border-color .18s var(--ease);
}
.userchip:hover { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .10); }
.userchip__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-gradient);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: var(--fs-12);
  font-weight: 700;
}
.userchip__name { font-size: var(--fs-13); font-weight: 600; line-height: 1.2; color: var(--heading); }
.userchip__role { font-size: var(--fs-11); color: var(--muted); line-height: 1.2; }

/* ==================== 顶部模块条 ==================== */
.modrail {
  display: flex;
  align-items: center;
  gap: 2px;
  height: var(--rail-h);
  padding: 0 16px 0 12px;
  background: var(--light);
  border-top: 1px solid var(--border-soft);
  overflow-x: auto;
  scrollbar-width: none;
}
.modrail::-webkit-scrollbar { display: none; }
.modrail__item {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  font-size: var(--fs-13);
  font-weight: 500;
  color: var(--body);
  white-space: nowrap;
  transition: color .18s var(--ease), background .18s var(--ease);
}
.modrail__item .ico { color: var(--accent); opacity: .62; transition: opacity .18s var(--ease); }
.modrail__item:hover { background: var(--surface); color: var(--heading); }
.modrail__item:hover .ico { opacity: 1; }
.modrail__item.is-active { color: var(--primary); background: var(--surface); box-shadow: 0 1px 2px rgba(92,92,92,.06); }
.modrail__item.is-active .ico { opacity: 1; }
.modrail__item.is-active::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: -7px;
  height: 2px;
  border-radius: 2px;
  background: var(--primary);
}
.modrail__sep { width: 1px; height: 16px; margin: 0 8px; background: var(--border); flex: none; }

/* ==================== 内容区 ==================== */
.workspace { display: block; min-width: 0; min-height: 0; }
.content {
  position: relative;
  background: var(--light);
}
.content__inner {
  max-width: 1680px;
  margin: 0 auto;
  padding: 24px 24px 40px;
}

/* ==================== 页面头 ==================== */
.page-head {
  display: flex;
  align-items: flex-end;
  gap: 20px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.page-head::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 56px;
  height: 2px;
  background: var(--primary);
  border-radius: 2px;
}
.page-head__main { flex: 1; min-width: 260px; }
.page-head__eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 8px;
  font-size: var(--fs-11);
  font-weight: 650;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
.page-head__eyebrow .tag-code {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--r-xs);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: var(--fs-11);
  letter-spacing: .1em;
}
.page-head__eyebrow .sep { width: 1px; height: 10px; background: var(--border); }
.page-head h1 {
  font-size: var(--fs-24);
  font-weight: 600;
  letter-spacing: -.01em;
  line-height: var(--lh-tight);
  color: var(--heading);
}
.page-head__desc {
  margin-top: 6px;
  font-size: var(--fs-13);
  color: var(--muted);
  max-width: 780px;
}
.page-head__actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }

/* ==================== 栅格 ==================== */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 20px; }
.grid > .col { min-width: 0; display: flex; flex-direction: column; }
.grid > .col > .grid { flex: 1 1 auto; min-height: 0; align-content: stretch; }
.grid > .col > .card:only-child { height: 100%; }
.grid > .col > .grid > .col > .card:only-child { height: 100%; }
.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; }
.col-8 { grid-column: span 8; }
.col-9 { grid-column: span 9; }
.col-12 { grid-column: span 12; }

@media (max-width: 1440px) {
  .col-3 { grid-column: span 6; }
  .col-8 { grid-column: span 12; }
  .col-9 { grid-column: span 12; }
  .col-7 { grid-column: span 12; }
}
@media (max-width: 1180px) {
  .col-4 { grid-column: span 6; }
}
@media (max-width: 1080px) {
  .col-5, .col-6 { grid-column: span 12; }
  .searchbox { width: 200px; flex: 0 1 200px; }
}
@media (max-width: 900px) {
  .searchbox { flex: 0 1 150px; }
  .userchip__name, .userchip__role { display: none; }
  .userchip { padding: 0 4px; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
  .content__inner { padding: 18px 14px 32px; }
}
@media (max-width: 700px) {
  .searchbox { display: none; }
  .topbar { gap: 8px; padding: 0 12px; }
}
