/* ===== 布局 ===== */

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 18px 14px;
  background:
    linear-gradient(180deg, rgba(255, 234, 25, 0.08), transparent 148px),
    var(--brand-black);
  color: #eff6f0;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 18px;
  border-bottom: 1px solid rgba(255, 234, 25, 0.22);
}

.brand-mark {
  position: relative;
  display: grid;
  width: 48px;
  height: 48px;
  overflow: hidden;
  place-items: center;
  border: 1px solid rgba(255, 234, 25, 0.32);
  border-radius: 13px;
  background: var(--brand-yellow);
  color: var(--brand-black);
  font-weight: 800;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.22);
}

.brand-mark img {
  grid-area: 1 / 1;
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-fallback {
  grid-area: 1 / 1;
  color: var(--brand-black);
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
}

.brand-block h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.brand-block p,
.hierarchy-box span,
.user-chip span {
  margin: 0;
  color: rgba(239, 246, 240, 0.68);
  font-size: 12px;
}

.nav-list {
  display: grid;
  flex: 1 1 auto;
  gap: 7px;
  min-height: 0;
  margin-top: 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 2px 12px 0;
}

.nav-item,
.nav-group-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(239, 246, 240, 0.82);
  text-align: left;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
}

.nav-group {
  display: grid;
  gap: 3px;
}

.nav-group-button span:nth-child(2) { flex: 1; }

.nav-chevron {
  display: grid;
  width: 18px; height: 18px;
  place-items: center;
  color: rgba(239, 246, 240, 0.52);
  transition: transform 0.16s ease;
}

.nav-children {
  display: grid;
  gap: 2px;
  padding-left: 8px;
}

.nav-child {
  min-height: 36px;
  padding-left: 30px;
  font-size: 14px;
}

.nav-child .nav-icon {
  width: 18px; height: 18px;
  color: rgba(255, 234, 25, 0.84);
  font-size: 12px;
}

.nav-group.is-collapsed .nav-children { display: none; }
.nav-group.is-collapsed .nav-chevron { transform: rotate(-90deg); }

.nav-item:hover,
.nav-item.is-active,
.nav-group-button:hover,
.nav-group.is-active .nav-group-button {
  background: rgba(255, 234, 25, 0.13);
  color: #ffffff;
}

.nav-item.is-active,
.nav-group.is-active .nav-group-button {
  box-shadow: inset 3px 0 0 var(--brand-yellow);
}

.nav-icon {
  display: grid;
  width: 22px; height: 22px;
  place-items: center;
  color: var(--brand-yellow);
  font-weight: 700;
  position: relative;
  flex: 0 0 auto;
}

.nav-icon::before,
.nav-icon::after {
  content: "";
  position: absolute;
  box-sizing: border-box;
  border-color: currentColor;
}

.icon-dashboard::before {
  width: 15px;
  height: 12px;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 2px 2px 3px 3px;
  bottom: 3px;
}

.icon-dashboard::after {
  width: 11px;
  height: 11px;
  border-left: 2px solid currentColor;
  border-top: 2px solid currentColor;
  transform: translateY(-4px) rotate(45deg);
}

.icon-ops::before,
.icon-site::before {
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-radius: 4px;
}

.icon-ops::after,
.icon-site::after {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.icon-cabinet::before,
.icon-log::before,
.icon-billing::before {
  width: 15px;
  height: 16px;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.icon-cabinet::after {
  width: 9px;
  height: 8px;
  border-top: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

.icon-meter::before {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.icon-meter::after {
  width: 8px;
  height: 2px;
  background: currentColor;
  transform: rotate(-34deg) translate(2px, 1px);
  transform-origin: left center;
}

.icon-contract::before {
  width: 14px;
  height: 17px;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.icon-contract::after,
.icon-log::after,
.icon-billing::after {
  width: 8px;
  height: 7px;
  border-top: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

.icon-move::before {
  width: 2px;
  height: 16px;
  background: currentColor;
}

.icon-move::after {
  width: 12px;
  height: 12px;
  border-top: 2px solid currentColor;
  border-left: 2px solid currentColor;
  transform: rotate(45deg);
  top: 2px;
}

.icon-task::before,
.icon-role::before {
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-radius: 4px;
}

.icon-task::after {
  width: 9px;
  height: 5px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg) translate(1px, -1px);
}

.icon-finance::before,
.icon-settlement::before {
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.icon-finance::after {
  width: 9px;
  height: 9px;
  border-left: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: rotate(90deg);
}

.icon-settlement::after {
  width: 14px;
  height: 7px;
  border-top: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  bottom: 3px;
}

.icon-notice::before {
  width: 15px;
  height: 13px;
  border: 2px solid currentColor;
  border-radius: 8px 8px 4px 4px;
  border-bottom-width: 3px;
}

.icon-notice::after {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  bottom: 1px;
}

.icon-growth::before {
  width: 15px;
  height: 15px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

.icon-growth::after {
  width: 10px;
  height: 10px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: rotate(-45deg);
  top: 4px;
}

.icon-suggestion::before {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-radius: 50% 50% 44% 44%;
  top: 2px;
}

.icon-suggestion::after {
  width: 8px;
  height: 4px;
  border-top: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  bottom: 2px;
}

.icon-invite::before {
  width: 14px;
  height: 10px;
  border: 2px solid currentColor;
  border-radius: 8px;
  transform: rotate(-28deg);
}

.icon-invite::after {
  width: 14px;
  height: 10px;
  border: 2px solid currentColor;
  border-radius: 8px;
  transform: rotate(28deg);
  opacity: 0.75;
}

.icon-approval::before {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.icon-approval::after {
  width: 12px;
  height: 5px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
}

.icon-system::before {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.icon-system::after {
  width: 6px;
  height: 6px;
  border: 2px solid currentColor;
  border-radius: 50%;
  background: var(--brand-black);
}

.icon-init::before {
  width: 15px;
  height: 15px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

.icon-init::after {
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 8px solid currentColor;
  left: 8px;
}

.icon-agent::before {
  width: 5px;
  height: 5px;
  border: 2px solid currentColor;
  border-radius: 2px;
  top: 2px;
}

.icon-agent::after {
  width: 16px;
  height: 9px;
  border-left: 2px solid currentColor;
  border-right: 2px solid currentColor;
  border-top: 2px solid currentColor;
  bottom: 3px;
}

.icon-brand::before {
  width: 15px;
  height: 12px;
  border: 2px solid currentColor;
  border-radius: 3px;
  transform: rotate(-18deg);
}

.icon-brand::after {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  left: 6px;
  top: 6px;
}

.icon-maintainer::before {
  width: 15px;
  height: 4px;
  border: 2px solid currentColor;
  border-radius: 6px;
  transform: rotate(-45deg);
}

.icon-maintainer::after {
  width: 6px;
  height: 6px;
  border: 2px solid currentColor;
  border-radius: 50%;
  right: 3px;
  top: 3px;
}

.icon-user::before {
  width: 8px;
  height: 8px;
  border: 2px solid currentColor;
  border-radius: 50%;
  top: 2px;
}

.icon-user::after {
  width: 15px;
  height: 8px;
  border: 2px solid currentColor;
  border-radius: 9px 9px 3px 3px;
  bottom: 2px;
}

.icon-role::after {
  width: 7px;
  height: 7px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
}

.icon-integration::before {
  width: 15px;
  height: 12px;
  border: 2px solid currentColor;
  border-radius: 6px;
}

.icon-integration::after {
  width: 8px;
  height: 8px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: translate(6px, -5px) rotate(45deg);
}

.icon-help::before {
  content: "?";
  position: static;
  display: grid;
  width: 17px;
  height: 17px;
  place-items: center;
  border: 2px solid currentColor;
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
  font-weight: 800;
}

.hierarchy-box {
  display: grid;
  flex: 0 0 auto;
  gap: 6px;
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255, 234, 25, 0.2);
  border-radius: 8px;
  background: rgba(255, 234, 25, 0.08);
}

.hierarchy-box strong { font-size: 14px; }

/* 主区域 */
.main-area { min-width: 0; }

.mobile-topbar-leading,
.mobile-bottom-nav,
.sidebar-backdrop {
  display: none;
}

.topbar {
  position: sticky;
  top: 0; z-index: 8;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 254, 247, 0.93);
  backdrop-filter: blur(16px);
}

.route-tabs {
  position: sticky;
  top: 67px; z-index: 7;
  display: block;
  padding: 8px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 254, 247, 0.95);
  backdrop-filter: blur(16px);
}

.route-tabs.is-hidden { display: none; }

.route-tab-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.route-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #fffdf4;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.route-tab:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.route-tab.is-active {
  border-color: var(--brand-black);
  background: var(--brand-yellow);
  color: var(--brand-black);
}

.route-tab i {
  display: grid;
  width: 14px; height: 14px;
  place-items: center;
  border-radius: 50%;
  font-style: normal;
  line-height: 1;
  color: inherit;
  opacity: 0.8;
}

.route-tab i:hover {
  background: rgba(255, 255, 255, 0.22);
  opacity: 1;
}

.account-menu {
  position: relative;
  grid-column: 2;
}

.user-chip {
  display: flex;
  align-items: center;
  min-width: 152px;
  min-height: 44px;
  padding: 4px 8px 4px 12px;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  text-align: left;
  transition: background var(--transition);
}

.user-chip:hover,
.user-chip:focus-visible,
.account-menu.is-open .user-chip {
  background: #fffdf4;
}

.user-chip:focus-visible {
  outline: 2px solid rgba(255, 234, 25, 0.72);
  outline-offset: 2px;
}

.user-chip-content {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.user-copy {
  display: block;
  min-width: 0;
}

.user-avatar {
  display: grid;
  width: 36px; height: 36px;
  place-items: center;
  border-radius: 50%;
  background: var(--brand-yellow);
  color: var(--brand-black);
  font-weight: 800;
}

.user-chip strong {
  display: block;
  font-size: 14px;
}

.user-chip span { color: var(--muted); }

.account-menu-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  display: grid;
  width: 176px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-strong);
}

.account-menu-popover[hidden] { display: none; }

.account-menu-item {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-weight: 700;
}

.account-menu-item:hover,
.account-menu-item:focus-visible {
  background: var(--surface-2);
  outline: none;
}

.account-menu-logout { color: var(--rose); }

.content-area {
  display: grid;
  gap: 18px;
  padding: 24px;
}

.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.view-header h2 {
  margin: 0 0 6px;
  font-size: 26px;
  line-height: 1.2;
  letter-spacing: 0;
}

.view-header p {
  max-width: 820px;
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.action-row,
.toolbar,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.page-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff 0%, #fffdf4 100%);
  box-shadow: 0 10px 24px rgba(17, 20, 17, 0.04);
}

.page-filter-controls {
  display: flex;
  flex: 0 1 auto;
  flex-wrap: nowrap;
  gap: 10px;
  align-items: end;
}

.mobile-filter-toggle { display: none; }

.page-search {
  flex: 1 1 320px;
  min-width: 240px;
}

.page-search input,
.page-filter-select select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  outline: none;
}

.page-search input { padding: 0 12px; }

.page-filter-select {
  display: grid;
  flex: 0 1 150px;
  gap: 5px;
  min-width: 132px;
}

.page-filter-select span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.page-filter-select select { padding: 0 28px 0 10px; }

.page-search input:focus,
.page-filter-select select:focus {
  border-color: var(--brand-yellow-strong);
  box-shadow: 0 0 0 3px rgba(255, 234, 25, 0.28);
}

.page-filter-reset { min-width: 82px; }

/* 网格布局 */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.split-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

/* 响应式 */
@media (max-width: 1180px) {
  .page-filter-controls { flex-wrap: wrap; }
  .summary-grid, .grid-3, .role-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid-2, .split-view { grid-template-columns: 1fr; }
  .detail-panel { position: static; }
  .route-tabs { position: static; }
  .user-chip { border-left: 0; padding-left: 0; }
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: min(310px, 84vw);
    height: 100dvh;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 18px 0 40px rgba(12, 18, 15, 0.22);
  }
  body.is-sidebar-open { overflow: hidden; }
  body.is-sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 49;
    width: 100%;
    height: 100%;
    border: 0;
    background: rgba(12, 18, 15, 0.48);
  }
  .sidebar-backdrop:not([hidden]) { display: block; }
  .nav-list { grid-template-columns: 1fr; }
  .hierarchy-box { display: grid; }
  .main-area { padding-bottom: var(--mobile-bottom-nav-height, 66px); }
  .topbar {
    position: sticky;
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 58px;
    padding: 7px 12px;
    border-bottom-color: rgba(255, 234, 25, 0.2);
    background: var(--brand-black);
  }
  .mobile-topbar-leading {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
  }
  .mobile-menu-button {
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid rgba(255, 234, 25, 0.5);
    border-radius: var(--radius);
    background: transparent;
    color: var(--brand-yellow);
    font-size: 12px;
    font-weight: 800;
  }
  .mobile-page-title {
    position: absolute;
    left: 50%;
    display: grid;
    min-width: 0;
    transform: translateX(-50%);
    text-align: center;
  }
  .mobile-page-title strong {
    overflow: hidden;
    color: #fff;
    font-size: 16px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mobile-page-title span {
    color: rgba(255, 255, 255, 0.7);
    font-size: 11px;
  }
  .user-chip {
    min-width: auto;
    min-height: 40px;
    padding: 2px;
    background: transparent;
  }
  .user-copy { display: none; }
  .user-avatar {
    width: 34px;
    height: 34px;
    background: var(--brand-yellow);
    color: var(--brand-black);
  }
  .user-chip:hover,
  .user-chip:focus-visible,
  .account-menu.is-open .user-chip {
    background: rgba(255, 234, 25, 0.11);
  }
  .account-menu-popover {
    position: fixed;
    top: 58px;
    right: 10px;
    width: 168px;
  }
  .route-tabs { display: none; }
  .content-area { padding: 14px 12px 24px; gap: 14px; }
  .view-header { display: grid; }
  .view-header h2 { font-size: 22px; }
  .view-header p { font-size: 13px; line-height: 1.55; }
  .action-row { width: 100%; }
  .action-row > button { flex: 1 1 auto; }
  .summary-grid, .grid-3, .role-grid, .form-grid { grid-template-columns: 1fr; }
  .page-filter-bar { align-items: stretch; }
  .page-filter-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 10px;
  }
  .page-search { min-width: 0; }
  .mobile-filter-toggle {
    display: inline-flex;
    min-width: 72px;
    align-items: center;
    justify-content: center;
  }
  .page-filter-controls {
    display: none;
    grid-column: 1 / -1;
  }
  .page-filter-bar.is-expanded .page-filter-controls {
    display: grid;
    grid-template-columns: 1fr;
  }
  .page-filter-select, .page-filter-reset { min-width: 0; }
  .field.wide { grid-column: auto; }
  .bar-row { grid-template-columns: 1fr; }
  .map-toolbar { grid-template-columns: 1fr; }
  .mobile-bottom-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 45;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    min-height: var(--mobile-bottom-nav-height, 66px);
    padding: 5px max(6px, env(safe-area-inset-right)) max(5px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    border-top: 1px solid rgba(255, 234, 25, 0.28);
    background: rgba(17, 20, 17, 0.97);
    box-shadow: 0 -10px 28px rgba(17, 20, 17, 0.18);
  }
  .mobile-bottom-nav button {
    position: relative;
    min-width: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: rgba(255, 255, 255, 0.72);
    font-size: 12px;
    font-weight: 700;
    outline: none;
  }
  .mobile-bottom-nav button:focus-visible {
    outline: 2px solid rgba(255, 234, 25, 0.55);
    outline-offset: -2px;
  }
  .mobile-bottom-nav button.is-active {
    background: var(--brand-yellow);
    color: var(--brand-black);
  }
  .mobile-bottom-nav i {
    position: absolute;
    top: 2px;
    left: calc(50% + 11px);
    display: grid;
    min-width: 17px;
    height: 17px;
    place-items: center;
    padding: 0 4px;
    border-radius: 9px;
    background: var(--rose);
    color: #fff;
    font-size: 10px;
    font-style: normal;
  }
}
