@import './tokens.css';

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-family);
  font-size: var(--font-size-body);
  line-height: var(--line-height-body);
  color: var(--obs-neutral-900);
  background: var(--obs-bg-page);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--obs-brand); text-decoration: none; }
a:hover { text-decoration: none; }

/* —— Shell —— */
.app-shell { display: flex; min-height: 100vh; }

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-height);
  background: var(--obs-bg-card);
  border-bottom: 1px solid var(--obs-border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  z-index: 100;
  gap: 24px;
}

.topbar__logo {
  font-weight: 600;
  color: var(--obs-neutral-900);
  font-size: var(--font-size-md);
}

.topbar__nav { display: flex; gap: 20px; color: var(--obs-neutral-600); font-size: var(--font-size-sm); }
.topbar__nav a { color: inherit; text-decoration: none; }
.topbar__nav a:hover { color: var(--obs-brand); }
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--obs-neutral-500); font-size: var(--font-size-sm); }
.topbar__right a.topbar__workbench {
  color: var(--obs-neutral-600);
  text-decoration: none;
}
.topbar__right a.topbar__workbench:hover {
  color: var(--obs-brand);
  text-decoration: none;
}
.topbar__divider {
  flex-shrink: 0;
  width: 1px;
  height: 16px;
  background: var(--t-gray-7, #e7e7e7);
}
.topbar__user {
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar__avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: block;
  background: var(--obs-bg-icon-ph);
}
.topbar__username {
  color: var(--obs-neutral-600);
  font-size: var(--font-size-sm);
  line-height: 1;
}

/* 侧栏导航 — 对齐 Figma「左侧菜单」/ 视觉规范 §5.5 */
.sidebar {
  position: fixed;
  top: 48px;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--obs-bg-card);
  border-right: 1px solid var(--obs-border);
  overflow-x: hidden;
  overflow-y: auto;
  padding: var(--space-sm) 0 48px;
  z-index: 90;
}

.sidebar__group-title {
  position: relative;
  display: flex;
  align-items: center;
  min-height: var(--sidebar-group-height);
  padding: 0 var(--space-lg);
  margin-top: var(--space-xs);
  font-size: var(--font-size-xs);
  line-height: 20px;
  color: var(--obs-neutral-400);
  font-weight: 400;
  user-select: none;
}

/* 分组上方细分隔线（首组除外） */
.sidebar__item ~ .sidebar__group-title::before,
.sidebar__group-title ~ .sidebar__group-title::before {
  content: "";
  position: absolute;
  top: 0;
  left: var(--space-lg);
  right: var(--space-lg);
  height: 1px;
  background: var(--obs-border);
}

.sidebar__item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  height: var(--sidebar-item-height);
  margin: 0 var(--sidebar-item-inset);
  padding: 0 12px;
  border-radius: var(--sidebar-item-radius);
  color: var(--obs-neutral-600);
  text-decoration: none;
  font-size: var(--font-size-body);
  line-height: var(--line-height-body);
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar__item:hover {
  background: var(--obs-sidebar-hover);
  color: var(--obs-neutral-900);
  text-decoration: none;
}

.sidebar__item--active {
  background: var(--obs-surface-selected);
  color: var(--obs-brand);
  font-weight: 500;
}

.sidebar__item--active:hover {
  background: var(--obs-surface-selected);
  color: var(--obs-brand);
}

.sidebar__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar__icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: currentColor;
  background: none;
}

.sidebar__icon .sidebar__icon-svg {
  display: block;
  width: 16px;
  height: 16px;
  color: currentColor;
  fill: currentColor;
  background: none;
  transition: color 0.15s ease;
}

.sidebar__item:hover .sidebar__icon,
.sidebar__item:hover .sidebar__icon .sidebar__icon-svg,
.sidebar__nav-toggle:hover .sidebar__icon,
.sidebar__nav-toggle:hover .sidebar__icon .sidebar__icon-svg {
  color: #0052d9;
}

.sidebar__item--active .sidebar__icon,
.sidebar__item--active .sidebar__icon .sidebar__icon-svg {
  color: currentColor;
}

.sidebar__item--child {
  padding-left: 36px;
  height: 36px;
  font-size: var(--font-size-sm);
}

/* 可折叠侧栏：二级展开三级（业务观测） */
.sidebar__nav-group .sidebar__submenu {
  display: none;
  padding-bottom: 4px;
}
.sidebar__nav-group.is-open .sidebar__submenu {
  display: block;
}
.sidebar__nav-toggle {
  width: calc(100% - var(--sidebar-item-inset) * 2);
  margin: 0 var(--sidebar-item-inset);
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  text-align: left;
  color: inherit;
}
.sidebar__nav-toggle:hover {
  background: var(--obs-sidebar-hover);
  color: var(--obs-neutral-900);
}
.sidebar__chevron {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  margin-left: auto;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='black' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='black' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  opacity: 0.45;
  transition: transform 0.15s ease;
}
.sidebar__nav-group.is-open > .sidebar__nav-toggle .sidebar__chevron {
  transform: rotate(180deg);
}
.sidebar--biz-observe .sidebar__item--child {
  padding-left: 44px;
  height: 36px;
  font-size: var(--font-size-sm);
}
.sidebar--biz-observe .sidebar__item--child .sidebar__label {
  color: var(--obs-neutral-600);
}
.sidebar--biz-observe .sidebar__group-title {
  cursor: default;
  pointer-events: none;
}

.platform-empty {
  min-height: calc(100vh - var(--topbar-height));
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--obs-bg-page);
  border: none;
  box-shadow: none;
}
.platform-empty__inner {
  text-align: center;
  color: var(--obs-neutral-500);
  font-size: var(--font-size-base);
}

.main {
  margin-left: var(--sidebar-width);
  margin-top: 48px;
  flex: 1;
  padding: 0;
  min-width: 0;
}

/* —— Page header —— */
.page-header {
  background: var(--obs-bg-card);
  border-bottom: 1px solid var(--obs-border);
}

.page-header__title-row {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--obs-border);
}

.page-header__title-row:last-child {
  border-bottom: none;
}

.page-header__title {
  margin: 0;
  font-size: var(--font-size-lg);
  font-weight: 600;
  line-height: var(--header-height);
}

.page-header__toolbar {
  min-height: var(--header-content-height);
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

/* —— Tabs (capsule) —— */
.status-tabs { display: flex; gap: 24px; align-items: center; }
.status-tabs a {
  color: var(--obs-neutral-600);
  text-decoration: none;
  padding-bottom: 8px;
  border-bottom: 2px solid transparent;
  font-size: var(--font-size-base);
}
.status-tabs a:hover { color: var(--obs-brand); }
.status-tabs a.active {
  color: var(--obs-brand);
  font-weight: 500;
  border-bottom-color: var(--obs-brand);
}

.filter-chips { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.chip {
  height: var(--control-height);
  padding: 0 12px;
  border: 1px solid var(--obs-border);
  border-radius: 2px;
  background: var(--obs-bg-card);
  font-size: var(--font-size-sm);
  color: var(--obs-neutral-600);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
.chip--active { border-color: var(--obs-brand); color: var(--obs-brand); background: var(--obs-surface-selected); }

/* —— Buttons —— */
.btn {
  height: var(--control-height);
  padding: 0 16px;
  border-radius: 2px;
  font-size: var(--font-size-base);
  cursor: pointer;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
}
.btn--primary { background: var(--obs-brand); color: var(--obs-text-on-brand); }
.btn--primary:hover { filter: brightness(1.05); }
.btn--default { background: var(--obs-bg-card); border-color: var(--obs-border); color: var(--obs-neutral-600); }
.btn--text { background: none; border: none; color: var(--obs-brand); padding: 0 8px; height: auto; }
.btn--sm { height: 24px; padding: 0 12px; font-size: var(--font-size-sm); }

/* —— Table —— */
.content-panel { padding: 16px; }

.data-table-wrap {
  background: var(--obs-bg-card);
  border: 1px solid var(--obs-border);
  border-radius: 2px;
  overflow: auto;
}

.data-table { width: 100%; border-collapse: collapse; min-width: 1200px; }
.data-table th,
.data-table td {
  height: var(--table-row-height);
  padding: 0 var(--table-cell-padding-x, 16px);
  text-align: left;
  border-bottom: 1px solid var(--obs-border);
  font-size: var(--font-size-base);
  white-space: nowrap;
}
.data-table th {
  background: var(--obs-bg-table-header);
  color: var(--obs-neutral-600);
  font-weight: 500;
}
.data-table tbody tr:hover { background: var(--obs-bg-table-row-hover); }
.data-table .col-check { width: 48px; }
.data-table .col-actions { width: 140px; }
.data-table .text-ellipsis {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--obs-bg-card);
  border: 1px solid var(--obs-border);
  border-top: none;
  font-size: var(--font-size-sm);
  color: var(--obs-neutral-500);
}

.table-footer__pager {
  display: flex;
  align-items: center;
  gap: 12px;
}

.table-footer__size select {
  height: 32px;
  padding: 0 28px 0 8px;
  border: 1px solid var(--obs-border);
  border-radius: 2px;
  font-size: var(--font-size-sm);
  font-family: inherit;
  color: var(--obs-neutral-600);
  background: var(--obs-bg-card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M3 4.5 6 7.5 9 4.5'/%3E%3C/svg%3E") no-repeat right 8px center;
  appearance: none;
}

.table-footer__jump {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-sm);
  color: var(--obs-neutral-500);
}

.table-footer__jump input {
  width: 48px;
  height: 32px;
  border: 1px solid var(--obs-border);
  border-radius: 2px;
  text-align: center;
  font-size: var(--font-size-sm);
}

.pagination { display: flex; gap: 4px; align-items: center; }
.pagination button {
  min-width: 32px;
  height: 32px;
  border: 1px solid var(--obs-border);
  background: var(--obs-bg-card);
  border-radius: 2px;
  cursor: pointer;
  font-size: var(--font-size-sm);
}
.pagination button.active { background: var(--obs-brand); color: var(--obs-text-on-brand); border-color: var(--obs-brand); }
.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* —— Tags —— */
.tag {
  display: inline-flex;
  align-items: center;
  height: var(--tag-height-md);
  padding: 0 8px;
  border-radius: 2px;
  font-size: var(--font-size-xs);
  font-weight: 500;
}
.tag--error { background: rgba(245, 88, 99, 0.12); color: var(--obs-error); }
.tag--warning { background: rgba(255, 165, 76, 0.15); color: var(--t-orange); }
.tag--info { background: rgba(31, 105, 255, 0.1); color: var(--obs-brand); }
.tag--success { background: rgba(0, 168, 112, 0.12); color: var(--obs-success); }
.tag--neutral { background: var(--obs-bg-tag-neutral); color: var(--obs-neutral-600); }

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-base);
}
.status-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.status-dot--pending { color: var(--obs-pending); }
.status-dot--processing { color: var(--obs-processing); }
.status-dot--closed { color: var(--obs-neutral-500); }
.status-dot--alerting { color: var(--obs-error); }

/* —— Detail page —— */
.detail-layout { padding: 16px; }
.detail-card {
  background: var(--obs-bg-card);
  border: 1px solid var(--obs-border);
  border-radius: 2px;
}

.detail-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--obs-border);
}

.detail-topbar h1 { font-size: var(--font-size-lg); font-weight: 600; }
.detail-actions { display: flex; gap: 8px; }

.sub-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--obs-border);
  padding: 0 16px;
}
.sub-tabs a {
  padding: 12px 16px;
  color: var(--obs-neutral-600);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.sub-tabs a.active { color: var(--obs-brand); border-bottom-color: var(--obs-brand); font-weight: 500; }

.detail-body { padding: 20px 16px; }

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px 24px;
}
@media (max-width: 1100px) { .info-grid { grid-template-columns: repeat(2, 1fr); } }

.info-item label {
  display: block;
  color: var(--obs-neutral-500);
  font-size: var(--font-size-sm);
  margin-bottom: 4px;
}
.info-item .value { color: var(--obs-neutral-900); }

.info-block {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--obs-border);
}
.info-block h3 { font-size: var(--font-size-base); font-weight: 600; margin-bottom: 12px; }
.info-block .content-box {
  background: var(--obs-bg-table-header);
  border: 1px solid var(--obs-border);
  border-radius: 2px;
  padding: 12px 16px;
  color: var(--obs-neutral-600);
  line-height: 1.6;
}

.breadcrumb {
  padding: 12px 16px;
  font-size: var(--font-size-sm);
  color: var(--obs-neutral-500);
  background: var(--obs-bg-card);
  border-bottom: 1px solid var(--obs-border);
}
.breadcrumb a { color: var(--obs-neutral-600); }
.breadcrumb span { margin: 0 8px; color: var(--obs-neutral-400); }

.search-input {
  height: var(--control-height);
  width: 240px;
  padding: 0 12px;
  border: 1px solid var(--obs-border);
  border-radius: 2px;
  font-size: var(--font-size-base);
  font-family: inherit;
}
.search-input::placeholder { color: var(--obs-neutral-400); }

.link-group { color: var(--obs-brand); }
.link-group a + a::before { content: ' · '; color: var(--obs-neutral-400); }

/* —— Utilities —— */
.pagination__size { margin-left: 8px; }

.toolbar-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  align-items: center;
}

.text-ellipsis--wide { max-width: 280px; }

.text-muted {
  margin-top: 16px;
  font-size: var(--font-size-sm);
  color: var(--obs-neutral-500);
}

.content-box__desc {
  margin-top: 8px;
  color: var(--obs-neutral-500);
}

.info-block__link {
  font-size: var(--font-size-sm);
  font-weight: normal;
}

.search-input--wide {
  width: 320px;
  margin-bottom: 16px;
}

.search-input--block { margin-bottom: 16px; }

/* —— Icon placeholder —— */
.icon-ph {
  display: inline-block;
  background: var(--obs-bg-icon-ph);
  border-radius: 2px;
  vertical-align: middle;
}
.icon-ph--16 { width: 16px; height: 16px; }
.icon-ph--20 { width: 20px; height: 20px; }
.icon-ph--32 { width: 32px; height: 32px; }

/* —— Overview —— */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 16px;
}
.metric-card {
  background: var(--obs-bg-card);
  border: 1px solid var(--obs-border);
  border-radius: 2px;
  padding: 16px;
}
.metric-card__label { font-size: var(--font-size-sm); color: var(--obs-neutral-500); margin-bottom: 8px; }
.metric-card__value { font-size: var(--font-size-3xl); font-weight: 600; color: var(--obs-neutral-900); }

.panel-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 0 16px 16px;
}
.panel {
  background: var(--obs-bg-card);
  border: 1px solid var(--obs-border);
  border-radius: 2px;
  padding: 16px;
}
.panel h3 { font-size: var(--font-size-base); margin-bottom: 12px; }
.bar-row { display: grid; grid-template-columns: 48px 1fr 32px; gap: 8px; align-items: center; margin-bottom: 8px; font-size: var(--font-size-sm); }
.bar-track { height: 8px; background: var(--obs-bg-icon-ph); border-radius: 2px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--obs-brand); border-radius: 2px; }

/* —— Drawer / Modal —— */
.drawer-mask {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 200;
}
.drawer-mask.is-open { display: block; }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 560px;
  max-width: 100%;
  background: var(--obs-bg-card);
  z-index: 201;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.2s;
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.08);
}
.drawer-mask.is-open .drawer { transform: translateX(0); }
.drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 24px;
  border-bottom: 1px solid var(--obs-border);
  font-weight: 600;
}
.drawer__body { flex: 1; overflow: auto; padding: 24px; }
.drawer__foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--obs-border);
}

.intro-page {
  padding: 48px 24px;
  text-align: center;
  max-width: 720px;
  margin: 0 auto;
}
.intro-flow {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 24px 0 32px;
}
.intro-step {
  padding: 8px 16px;
  background: var(--obs-bg-card);
  border: 1px solid var(--obs-border);
  border-radius: 2px;
  font-size: var(--font-size-sm);
}

.form-grid label { display: block; font-size: var(--font-size-sm); color: var(--obs-neutral-500); margin-bottom: 4px; }
.form-grid input, .form-grid select, .form-grid textarea {
  width: 100%;
  height: var(--control-height);
  padding: 0 12px;
  border: 1px solid var(--obs-border);
  border-radius: 2px;
  font-family: inherit;
  font-size: var(--font-size-base);
  margin-bottom: 16px;
}
.form-grid textarea { height: 96px; padding: 8px 12px; resize: vertical; }

.card-list { padding: 16px; display: grid; gap: 12px; }
.config-card {
  background: var(--obs-bg-card);
  border: 1px solid var(--obs-border);
  border-radius: 2px;
  padding: 16px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.config-card__main { flex: 1; }
.config-card h3 { font-size: var(--font-size-md); margin-bottom: 4px; }
.config-card p { font-size: var(--font-size-sm); color: var(--obs-neutral-500); }

/* —— 全站 Hub（index.html）—— */
.hub-body { padding: 32px 40px 48px; max-width: 1200px; margin: 0 auto; }
.hub-top { margin-bottom: 24px; }
.hub-top h1 { font-size: var(--font-size-2xl); margin-bottom: 8px; }
.hub-top__desc { color: var(--obs-neutral-600); font-size: var(--font-size-base); margin-bottom: 16px; }
.hub-top__actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hub-filters { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; font-size: var(--font-size-sm); }
.hub-filters label { display: flex; align-items: center; gap: 8px; color: var(--obs-neutral-600); }
.hub-filters select { height: 32px; padding: 0 8px; border: 1px solid var(--obs-border); border-radius: 2px; }
.hub-section { margin-bottom: 28px; }
.hub-section h2 { font-size: var(--font-size-lg); margin-bottom: 12px; border-bottom: 1px solid var(--obs-border); padding-bottom: 8px; }
.hub-count { font-size: var(--font-size-sm); color: var(--obs-neutral-500); font-weight: normal; }
.hub-links { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 16px; }
.hub-links li { display: flex; align-items: center; gap: 8px; font-size: var(--font-size-sm); }
.hub-link--pending { color: var(--obs-neutral-500); }
.hub-tag { font-size: var(--font-size-xs); padding: 1px 6px; border-radius: 2px; flex-shrink: 0; }
.hub-tag--done { background: var(--t-green-light); color: var(--obs-success); }
.hub-tag--pending { background: var(--obs-surface-selected); color: var(--obs-brand); }

.hub-body--embed {
  padding: 20px 24px 32px;
  max-width: none;
  background: var(--obs-bg-card);
}
.hub-body--embed .hub-top {
  margin-bottom: 16px;
}
.hub-body--embed .hub-top h1 {
  font-size: var(--font-size-xl);
  margin-bottom: 6px;
}
.hub-body--embed .hub-top__desc {
  margin-bottom: 12px;
}
.hub-body--embed .hub-top__actions {
  display: none;
}
.hub-body--embed .hub-filters {
  margin-bottom: 16px;
}
.main--stub { margin: 48px auto 0; max-width: 720px; padding: 24px; }
.stub-meta { font-size: var(--font-size-sm); color: var(--obs-neutral-500); margin-top: 8px; }
.stub-panel { padding: 24px; font-size: var(--font-size-base); line-height: 1.6; }
.stub-panel p + p { margin-top: 12px; }
.topbar__logo a { color: inherit; text-decoration: none; }
.topbar__logo a:hover { text-decoration: none; color: var(--obs-neutral-900); }

/* —— 登录（无 Shell）—— */
.page-standalone { min-height: 100vh; }
.page-standalone .main { margin: 0; }

/* 登录页左侧：渐变背景由 aside 承载，内层 wb-welcome 仅放内容 */
html:has(body.login-page) {
  overflow: hidden;
}

.login-page {
  background: var(--obs-bg-card);
  overflow: hidden;
}

.login-layout {
  display: grid;
  grid-template-columns: minmax(420px, 1.15fr) minmax(360px, 0.85fr);
  min-height: 100vh;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

.login-layout--center { grid-template-columns: 1fr; place-items: center; }

.login-layout__welcome {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  padding: 24px;
  background: linear-gradient(
    to bottom left,
    rgb(118 169 255 / 90%) 0%,
    rgb(217 236 255 / 85%) 42%,
    rgba(255, 255, 255, 0.8) 100%
  );
}

.login-layout__welcome > .wb-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  max-width: 720px;
  margin: auto;
  min-height: min(100%, 640px);
  overflow: visible;
  background: none;
  border: none;
  box-shadow: none;
  border-radius: 0;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.login-layout__welcome .wb-welcome__globe {
  top: 50%;
  right: -18%;
  height: 110%;
  transform: translateY(-50%) scale(1.65);
}

.login-layout__welcome .wb-welcome__intro {
  padding: 24px 24px 20px;
}

.login-layout__welcome .wb-welcome__title {
  font-size: clamp(24px, 2.4vw, 36px);
}

.login-layout__welcome .wb-welcome__desc {
  max-width: 100%;
  font-size: var(--font-size-sm);
  line-height: 1.65;
}

.login-layout__welcome .wb-welcome__panel {
  margin: 0 16px 16px;
}

.login-layout__welcome .wb-quickstart {
  grid-template-columns: 1fr;
}

.login-layout__welcome .wb-quick-card:not(:first-child)::before {
  left: 20px;
  right: 20px;
  top: 0;
  bottom: auto;
  width: auto;
  height: 1px;
}

@media (min-width: 1100px) {
  .login-layout__welcome .wb-quickstart {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .login-layout__welcome .wb-quick-card:not(:first-child)::before {
    left: 0;
    top: 20px;
    bottom: 20px;
    width: 1px;
    height: auto;
  }
}

@media (max-width: 960px) {
  .login-layout {
    grid-template-columns: 1fr;
    height: auto;
    max-height: none;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .login-layout::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
  }

  .login-layout__welcome {
    min-height: auto;
    height: auto;
    padding: 16px;
  }

  .login-layout__welcome > .wb-welcome {
    min-height: auto;
  }

  .login-layout__form {
    padding: 32px 24px 48px;
  }
}

.login-layout__brand {
  background: var(--gradient-login-brand);
  color: var(--obs-text-on-brand);
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.login-layout__brand h1 { font-size: var(--font-size-4xl); margin-bottom: 12px; }
.login-layout__brand p { opacity: 0.9; font-size: var(--font-size-md); }
.login-layout__form {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px;
  margin: 0 auto;
  width: 100%;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: var(--obs-bg-card);
}
.login-layout__form-inner {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}
.login-form__head {
  margin-bottom: 40px;
}
.login-form__greet,
.login-form__title {
  margin: 0;
  font-size: 32px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--obs-neutral-900);
}
.login-form__field {
  margin-bottom: 24px;
}
.login-form__field:last-of-type {
  margin-bottom: 32px;
}
.login-form__label {
  display: block;
  margin-bottom: 8px;
  font-size: var(--font-size-base);
  color: var(--obs-neutral-600);
}
.login-form input[type="text"],
.login-form input[type="password"] {
  display: block;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--obs-border);
  border-radius: 4px;
  font-size: var(--font-size-base);
  color: var(--obs-neutral-900);
  background: var(--obs-bg-card);
}
.login-form input[type="text"]::placeholder,
.login-form input[type="password"]::placeholder {
  color: var(--obs-neutral-400);
}
.login-form__submit {
  height: 40px;
  margin-top: 0;
  border-radius: 4px;
  font-size: var(--font-size-lg);
  letter-spacing: 0.2em;
  padding-left: 0.2em;
  box-sizing: border-box;
  text-decoration: none;
}
.login-form__submit.btn--block {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 0;
}
.login-form__remember {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  font-size: var(--font-size-sm);
  color: var(--obs-neutral-600);
  cursor: pointer;
  user-select: none;
}
.login-form__remember input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--obs-brand);
  cursor: pointer;
}
.login-layout__form h2 { font-size: var(--font-size-2xl); margin-bottom: 24px; }
.login-form label { display: block; font-size: var(--font-size-sm); color: var(--obs-neutral-600); margin-bottom: 16px; }
.login-form input {
  display: block;
  width: 100%;
  height: var(--control-height);
  margin-top: 6px;
  padding: 0 12px;
  border: 1px solid var(--obs-border);
  border-radius: 2px;
  font-size: var(--font-size-base);
}
.btn--block { display: block; width: 100%; text-align: center; margin-top: 8px; }
.login-layout__hint { margin-top: 24px; font-size: var(--font-size-sm); color: var(--obs-neutral-500); text-align: center; }

/* —— 工作台 —— */
.workbench-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.workbench-grid--compact { grid-template-columns: repeat(3, 1fr); }
.workbench-card {
  display: block;
  padding: 20px;
  background: var(--obs-bg-card);
  border: 1px solid var(--obs-border);
  border-radius: 2px;
  text-decoration: none;
  color: inherit;
}
.workbench-card:hover { border-color: var(--obs-brand); box-shadow: 0 2px 8px rgba(31, 105, 255, 0.08); text-decoration: none; }
.workbench-card h3 { font-size: var(--font-size-md); margin-bottom: 8px; }
.workbench-card p { font-size: var(--font-size-sm); color: var(--obs-neutral-500); }
.workbench-card--static:hover { border-color: var(--obs-border); box-shadow: none; }
.workbench-list { list-style: none; font-size: var(--font-size-sm); line-height: 2; }
.workbench-shortcuts { display: flex; flex-wrap: wrap; gap: 12px; font-size: var(--font-size-sm); }
.onboarding-steps { display: flex; flex-direction: column; gap: 12px; max-width: 480px; }
.onboarding-step {
  display: flex;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--obs-border);
  border-radius: 2px;
  background: var(--obs-bg-card);
}
.onboarding-step--active { border-color: var(--obs-brand); background: var(--obs-surface-selected); }
.onboarding-step span {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--obs-brand);
  color: var(--obs-text-on-brand);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--font-size-sm); flex-shrink: 0;
}
.onboarding-step p { font-size: var(--font-size-sm); color: var(--obs-neutral-500); margin-top: 4px; }

.empty-state { text-align: center; padding: 48px 24px; }
.empty-state-icon { font-size: var(--font-size-6xl); margin-bottom: 16px; opacity: 0.6; }
.empty-state h3 { margin-bottom: 8px; }
.empty-state p { color: var(--obs-neutral-500); font-size: var(--font-size-base); }
.guide-list { font-size: var(--font-size-base); line-height: 2; color: var(--obs-neutral-600); }

.admin-menu-preview { font-size: var(--font-size-base); line-height: 1.8; max-width: 360px; }
.admin-menu-preview ul { margin-left: 20px; color: var(--obs-neutral-600); }

/* —— 仪表盘 / 指标（Phase 3）—— */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  padding: 16px;
}
.dashboard-card {
  display: block;
  padding: 20px;
  background: var(--obs-bg-card);
  border: 1px solid var(--obs-border);
  border-radius: 2px;
  text-decoration: none;
  color: inherit;
}
.dashboard-card:hover { border-color: var(--obs-brand); text-decoration: none; }
.dashboard-card h3 { font-size: var(--font-size-md); margin-bottom: 8px; }
.dashboard-card p { font-size: var(--font-size-sm); color: var(--obs-neutral-500); }
.dashboard-card--builtin { border-style: dashed; }

.dashboard-view { padding: 16px; }
.dashboard-view-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.dashboard-view-grid .panel--wide { grid-column: 1 / -1; }
.chart-placeholder {
  height: 160px;
  background: linear-gradient(180deg, #f0f4ff 0%, var(--obs-bg-table-header) 100%);
  border: 1px dashed var(--obs-border);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--obs-neutral-400);
  font-size: var(--font-size-sm);
  margin-top: 8px;
}
.chart-placeholder--metric { font-size: var(--font-size-4xl); font-weight: 600; color: var(--obs-brand); }

.main--ide .page-header { border-bottom: none; }
.ide-layout {
  display: grid;
  grid-template-columns: 200px 1fr 240px;
  min-height: calc(100vh - 120px);
  border-top: 1px solid var(--obs-border);
}
.ide-sidebar, .ide-inspector {
  background: var(--obs-bg-card);
  border-right: 1px solid var(--obs-border);
  padding: 12px 0;
}
.ide-inspector { border-right: none; border-left: 1px solid var(--obs-border); }
.ide-sidebar__title { padding: 8px 16px; font-size: var(--font-size-xs); color: var(--obs-neutral-500); font-weight: 600; }
.ide-widgets { list-style: none; font-size: var(--font-size-sm); }
.ide-widgets li { padding: 8px 16px; cursor: pointer; }
.ide-widgets li:hover { background: var(--obs-bg-page); }
.ide-canvas { background: var(--obs-bg-subtle); padding: 16px; }
.ide-canvas__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  min-height: 400px;
}
.ide-panel {
  background: var(--obs-bg-card);
  border: 1px solid var(--obs-border);
  border-radius: 2px;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-sm);
  color: var(--obs-neutral-500);
}
.ide-panel--wide { grid-column: 1 / -1; min-height: 160px; }

/* —— Phase 4：日志 / 接入向导 —— */
.log-raw {
  font-family: ui-monospace, monospace;
  font-size: var(--font-size-xs);
  line-height: 1.6;
  background: var(--obs-bg-table-header);
  border: 1px solid var(--obs-border);
  padding: 12px;
  border-radius: 2px;
  overflow: auto;
  max-height: 400px;
}
.wizard-steps {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--obs-bg-card);
  border-bottom: 1px solid var(--obs-border);
  flex-wrap: wrap;
}
.wizard-steps a {
  padding: 6px 12px;
  font-size: var(--font-size-sm);
  color: var(--obs-neutral-600);
  text-decoration: none;
  border-radius: 2px;
}
.wizard-steps a.active { background: var(--obs-surface-selected); color: var(--obs-brand); font-weight: 500; }
.main--fullscreen { margin: 0 !important; }
