/* Desktop Web shell and reusable page composition. */

.web-shell {
  display: grid;
  grid-template:
    "sidebar header" var(--web-header-height)
    "sidebar main" minmax(0, 1fr)
    / var(--web-sidebar-width) minmax(0, 1fr);
  width: 100%;
  min-width: 1024px;
  min-height: 100dvh;
  background: var(--el-bg-color-page);
}

.web-header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  height: var(--web-header-height);
  padding: 0 var(--web-page-padding);
  gap: var(--space-4);
  border-bottom: 1px solid var(--el-border-color-light);
  background: rgb(255 255 255 / 96%);
}

.web-header__leading,
.web-header__trailing,
.web-header__project,
.web-header__user {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: var(--space-3);
}

.web-header__leading { flex: 1 1 auto; }
.web-header__trailing { flex: 0 0 auto; }
.web-header__project {
  max-width: 420px;
  min-height: 40px;
  padding: 4px 10px;
  border: 1px solid var(--el-border-color-light);
  border-radius: var(--radius-base);
  background: var(--el-bg-color);
}
.web-header__project-label { color: var(--el-text-color-secondary); font-size: 12px; }
.web-header__project-name { color: var(--el-text-color-primary); font-weight: 600; }
.web-header__user { min-height: 40px; padding: 4px 8px 4px 4px; border-radius: var(--radius-round); }
.web-header__user:hover { background: var(--el-fill-color-light); }
.web-header__avatar { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; flex: 0 0 auto; border-radius: 50%; color: #fff; font-weight: 600; background: var(--el-color-primary); }
.web-header__role { color: var(--el-text-color-secondary); font-size: 12px; }

.web-sidebar {
  position: sticky;
  top: 0;
  z-index: calc(var(--z-sticky) + 1);
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  width: var(--web-sidebar-width);
  height: 100dvh;
  overflow: hidden;
  color: #dce6f2;
  background: var(--color-shell);
}

.web-sidebar__brand {
  display: flex;
  align-items: center;
  height: var(--web-header-height);
  padding: 0 16px;
  gap: var(--space-3);
  border-bottom: 1px solid rgb(255 255 255 / 10%);
}
.web-sidebar__mark { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; flex: 0 0 auto; border-radius: var(--radius-base); color: #fff; background: var(--el-color-primary); }
.web-sidebar__brand-copy { min-width: 0; }
.web-sidebar__name { color: #fff; font-size: 15px; font-weight: 600; line-height: 20px; }
.web-sidebar__edition { color: var(--color-shell-muted); font-size: 11px; line-height: 16px; }

.web-sidebar__scroll {
  flex: 1 1 auto;
  min-height: 0;
  padding: 10px 8px 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: rgb(255 255 255 / 18%) transparent;
  scrollbar-width: thin;
}
.web-nav-section + .web-nav-section { margin-top: 12px; }
.web-nav-section__label { padding: 8px 12px 5px; color: #91a4bd; font-size: 11px; font-weight: 600; letter-spacing: .04em; }
.web-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 12px;
  gap: 10px;
  border-radius: var(--radius-base);
  color: #c6d3e2;
  transition: color var(--motion-base), background-color var(--motion-base);
}
.web-nav-item:hover { color: #fff; background: rgb(255 255 255 / 7%); }
.web-nav-item.is-active { color: #fff; font-weight: 600; background: #173d6f; }
.web-nav-item.is-active::before { content: ""; position: absolute; top: 9px; bottom: 9px; left: 0; width: 3px; border-radius: 0 2px 2px 0; background: #60a5fa; }
.web-nav-item__icon { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; flex: 0 0 auto; font-size: 20px; }
.web-nav-item__label { min-width: 0; flex: 1 1 auto; }
.web-nav-item__badge { min-width: 20px; height: 18px; padding: 0 6px; border-radius: var(--radius-round); color: #fff; font-size: 11px; line-height: 18px; text-align: center; background: var(--el-color-danger); }
.web-sidebar__footer { padding: 12px; border-top: 1px solid rgb(255 255 255 / 10%); color: var(--color-shell-muted); }

.web-main {
  grid-area: main;
  min-width: 0;
  min-height: 0;
}

.web-content {
  width: 100%;
  max-width: 1920px;
  min-height: calc(100dvh - var(--web-header-height));
  padding: var(--web-page-padding);
  margin: 0 auto;
}

.standard-page {
  display: grid;
  align-content: start;
  min-width: 0;
  gap: var(--space-4);
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  min-width: 0;
  gap: var(--space-5);
}
.page-header__main { min-width: 0; }
.page-title { margin: 0; color: var(--el-text-color-primary); font-size: 22px; font-weight: 650; line-height: 30px; }
.page-subtitle { max-width: 780px; margin-top: 4px; color: var(--el-text-color-secondary); }
.page-header__actions { display: flex; align-items: center; flex: 0 0 auto; gap: var(--space-2); }

.el-breadcrumb { display: flex; align-items: center; flex-wrap: wrap; min-height: 20px; margin-bottom: 6px; gap: 6px; color: var(--el-text-color-secondary); font-size: 12px; }
.el-breadcrumb__item { display: inline-flex; align-items: center; gap: 6px; }
.el-breadcrumb__item:not(:last-child)::after { content: "/"; color: var(--el-text-color-placeholder); }
.el-breadcrumb__item:last-child { color: var(--el-text-color-regular); }

.page-section { display: grid; align-content: start; min-width: 0; gap: var(--space-3); }
.page-section__header { display: flex; align-items: center; justify-content: space-between; min-height: 32px; gap: var(--space-3); }
.page-section__title { margin: 0; color: var(--el-text-color-primary); font-size: 16px; font-weight: 600; }
.page-section__description { color: var(--el-text-color-secondary); }

.layout-grid { display: grid; min-width: 0; gap: var(--space-4); }
.layout-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.layout-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.layout-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.layout-grid--aside { grid-template-columns: minmax(0, 1fr) 320px; }
.layout-grid--rail { grid-template-columns: 260px minmax(0, 1fr); }
.layout-span-full { grid-column: 1 / -1; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); }
.metric-card { display: grid; min-height: 112px; padding: 16px; gap: 6px; border: 1px solid var(--el-border-color-light); border-radius: var(--radius-card); background: var(--el-bg-color); box-shadow: var(--shadow-card); }
.metric-card__label { color: var(--el-text-color-secondary); }
.metric-card__value { color: var(--el-text-color-primary); font-size: 26px; font-weight: 650; line-height: 34px; font-variant-numeric: tabular-nums; }
.metric-card__meta { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); color: var(--el-text-color-secondary); font-size: 12px; }

.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; min-height: 0; gap: var(--space-4); }
.detail-layout__main,
.detail-layout__aside { display: grid; align-content: start; min-width: 0; gap: var(--space-4); }
.sticky-aside { position: sticky; top: calc(var(--web-header-height) + var(--web-page-padding)); align-self: start; max-height: calc(100dvh - var(--web-header-height) - 48px); overflow-y: auto; }

.split-view { display: grid; grid-template-columns: minmax(320px, 42%) minmax(0, 1fr); min-height: calc(100dvh - var(--web-header-height) - 48px); overflow: hidden; border: 1px solid var(--el-border-color-light); border-radius: var(--radius-card); background: var(--el-bg-color); }
.split-view__source,
.split-view__work { min-width: 0; min-height: 0; overflow: auto; }
.split-view__source { border-right: 1px solid var(--el-border-color-light); background: var(--el-fill-color-lighter); }

.web-shell.is-sidebar-collapsed {
  grid-template-columns: var(--web-sidebar-collapsed-width) minmax(0, 1fr);
}
.web-shell.is-sidebar-collapsed .web-sidebar { width: var(--web-sidebar-collapsed-width); }
.web-shell.is-sidebar-collapsed .web-sidebar__brand { justify-content: center; padding-inline: 8px; }
.web-shell.is-sidebar-collapsed .web-sidebar__brand-copy,
.web-shell.is-sidebar-collapsed .web-nav-section__label,
.web-shell.is-sidebar-collapsed .web-nav-item__label,
.web-shell.is-sidebar-collapsed .web-nav-item__badge,
.web-shell.is-sidebar-collapsed .web-sidebar__footer { display: none; }
.web-shell.is-sidebar-collapsed .web-nav-item { justify-content: center; padding-inline: 8px; }

.login-page {
  display: grid;
  grid-template-columns: minmax(420px, 1.1fr) minmax(420px, .9fr);
  min-height: 100dvh;
  background: var(--el-bg-color);
}
.login-page__context { display: flex; flex-direction: column; justify-content: flex-end; padding: 64px; color: #fff; background: var(--color-shell); }
.login-page__context-title { max-width: 720px; margin: 0; font-size: clamp(32px, 4vw, 52px); line-height: 1.16; }
.login-page__context-copy { max-width: 620px; margin-top: var(--space-5); color: #b9c8da; font-size: 16px; }
.login-page__form-side { display: flex; align-items: center; justify-content: center; padding: 48px; }
.login-card { width: min(440px, 100%); }
.login-card__title { margin: 0; font-size: 26px; line-height: 36px; }
.login-card__subtitle { margin-top: 6px; color: var(--el-text-color-secondary); }
.login-card__form { margin-top: 28px; }

@media (max-width: 1439px) {
  .web-content { padding: var(--web-page-padding-compact); }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout-grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout-grid--aside { grid-template-columns: minmax(0, 1fr) 280px; }
}

@media (max-width: 1199px) {
  .web-shell { grid-template-columns: var(--web-sidebar-collapsed-width) minmax(0, 1fr); }
  .web-sidebar { width: var(--web-sidebar-collapsed-width); }
  .web-sidebar__brand { justify-content: center; padding-inline: 8px; }
  .web-sidebar__brand-copy,
  .web-nav-section__label,
  .web-nav-item__label,
  .web-nav-item__badge,
  .web-sidebar__footer { display: none; }
  .web-nav-item { justify-content: center; padding-inline: 8px; }
  .detail-layout { grid-template-columns: minmax(0, 1fr) 300px; }
  .layout-grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1023px) {
  .web-shell { min-width: 768px; }
  .web-header { padding-inline: var(--space-4); }
  .web-content { padding: var(--space-4); }
  .detail-layout,
  .layout-grid--aside,
  .layout-grid--rail { grid-template-columns: 1fr; }
  .sticky-aside { position: static; max-height: none; }
  .split-view { grid-template-columns: 1fr; }
  .split-view__source { min-height: 360px; border-right: 0; border-bottom: 1px solid var(--el-border-color-light); }
  .login-page { grid-template-columns: 1fr; }
  .login-page__context { min-height: 300px; padding: 40px; }
}

@media print {
  .web-sidebar,
  .web-header,
  .page-header__actions,
  .query-panel,
  .action-bar,
  .el-pagination { display: none !important; }
  .web-shell { display: block; min-width: 0; background: #fff; }
  .web-content { max-width: none; padding: 0; }
}
