/* 社交 BI v2 设计基座：与 finance v2 同一设计语言（深色海军侧栏 + 浅色内容区 + 蓝青渐变强调）。
   各视图自己的样式放在 databi/src/social/views/*.css，只允许使用这里定义的 token。 */

.sbi-shell {
  --sbi-sidebar-bg: #101b2d;
  --sbi-sidebar-hover: rgba(120, 165, 255, 0.12);
  --sbi-accent: #2557d6;
  --sbi-accent-2: #0e7490;
  --sbi-accent-grad: linear-gradient(135deg, #2557d6, #0e7490);
  --sbi-bg: #f6f8fb;
  --sbi-card: #ffffff;
  --sbi-border: #e3eaf3;
  --sbi-text: #14263c;
  --sbi-text-2: #5b7089;
  --sbi-text-3: #8aa0b8;
  --sbi-up: #0f9d58;
  --sbi-down: #d93025;
  --sbi-warn-bg: #fdf3e7;
  --sbi-warn-text: #9a5b13;
  --sbi-radius: 12px;
  --sbi-shadow: 0 1px 2px rgba(16, 34, 56, 0.06), 0 4px 16px rgba(16, 34, 56, 0.05);

  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
  min-height: 100vh;
  min-width: 1080px;
  background: var(--sbi-bg);
  color: var(--sbi-text);
  font-size: 14px;
}

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

.sbi-sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  gap: 20px;
  padding: 18px 12px;
  background: var(--sbi-sidebar-bg);
  color: #dbe7f7;
}

.sbi-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px;
}

.sbi-brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 10px;
  background: var(--sbi-accent-grad);
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
}

.sbi-brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.sbi-brand-copy strong {
  font-size: 15px;
  color: #ffffff;
}

.sbi-brand-copy small {
  color: #7e8db0;
  font-size: 11px;
  letter-spacing: 0.04em;
}

.sbi-nav {
  display: grid;
  gap: 4px;
}

.sbi-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #a9bcd8;
  font-size: 13.5px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.sbi-nav-item:hover {
  background: var(--sbi-sidebar-hover);
  color: #e9f2ff;
}

.sbi-nav-item.is-active {
  background: var(--sbi-accent-grad);
  color: #ffffff;
}

.sbi-scope-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 10px 12px;
  border: 1px solid rgba(126, 141, 176, 0.35);
  border-radius: 9px;
  color: #a9bcd8;
  font-size: 12px;
}

.sbi-scope-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #38bdf8;
}

/* ---------- 主区 / 顶栏 ---------- */

.sbi-main {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.sbi-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--sbi-border);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
}

.sbi-topbar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.sbi-date-presets {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--sbi-border);
  border-radius: 9px;
  background: #f1f5fa;
}

.sbi-date-presets > button {
  padding: 6px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--sbi-text-2);
  font-size: 13px;
  font-weight: 640;
  cursor: pointer;
}

.sbi-date-presets > button.is-active {
  background: #ffffff;
  color: var(--sbi-accent);
  box-shadow: 0 1px 3px rgba(16, 34, 56, 0.12);
}

/* 自定义区间触发按钮：复用全局 TimeRangeFilter（@/shared/ui），这里只做与预设条的对齐微调。 */
.sbi-custom-range {
  margin-left: 6px;
}

.sbi-granularity {
  display: flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--sbi-border);
  border-radius: 9px;
  background: #f1f5fa;
}

.sbi-granularity > button {
  padding: 6px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--sbi-text-2);
  font-size: 13px;
  font-weight: 640;
  cursor: pointer;
}

.sbi-granularity > button.is-active {
  background: #ffffff;
  color: var(--sbi-accent);
  box-shadow: 0 1px 3px rgba(16, 34, 56, 0.12);
}

.sbi-refresh {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  margin-left: auto;
  border: 1px solid var(--sbi-border);
  border-radius: 9px;
  background: #ffffff;
  color: var(--sbi-text-2);
  cursor: pointer;
}

.sbi-refresh:hover {
  color: var(--sbi-accent);
  border-color: var(--sbi-accent);
}

.sbi-app-chips {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sbi-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border: 1px solid var(--sbi-border);
  border-radius: 999px;
  background: #ffffff;
  color: var(--sbi-text-2);
  font-size: 13px;
  font-weight: 640;
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

.sbi-chip:hover {
  border-color: var(--sbi-accent);
}

.sbi-chip.is-active {
  border-color: var(--sbi-accent);
  color: var(--sbi-accent);
  box-shadow: 0 0 0 3px rgba(37, 87, 214, 0.1);
}

.sbi-region-select {
  position: relative;
}

.sbi-region-trigger {
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--sbi-border);
  border-radius: 999px;
  background: #ffffff;
  color: var(--sbi-text-2);
  font-size: 13px;
  font-weight: 640;
  cursor: pointer;
}

.sbi-region-trigger:hover {
  border-color: var(--sbi-accent);
}

.sbi-region-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 40;
  display: grid;
  gap: 2px;
  min-width: 260px;
  max-height: 360px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--sbi-border);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: var(--sbi-shadow);
}

.sbi-region-group {
  display: grid;
  gap: 2px;
  padding-top: 4px;
  border-top: 1px dashed var(--sbi-border);
}

.sbi-region-option {
  padding: 7px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--sbi-text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.sbi-region-option:hover {
  background: #f1f5fa;
}

.sbi-region-option.is-group {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--sbi-text-2);
  font-weight: 700;
}

.sbi-region-option.is-active {
  background: rgba(37, 87, 214, 0.08);
  color: var(--sbi-accent);
  font-weight: 700;
}

.sbi-region-empty {
  margin: 6px;
  color: var(--sbi-text-3);
  font-size: 12.5px;
}

.sbi-operator-filter {
  width: 210px;
}

.sbi-operator-option {
  display: grid !important;
  gap: 2px;
}

.sbi-operator-option strong {
  color: var(--sbi-text);
  font-size: 13px;
}

.sbi-operator-option small {
  color: var(--sbi-text-3);
  font-size: 11.5px;
}

.sbi-range-label {
  color: var(--sbi-text-3);
  font-size: 12.5px;
}

.sbi-loading-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--sbi-accent);
  animation: sbi-pulse 900ms ease-in-out infinite;
}

@keyframes sbi-pulse {
  0%,
  100% {
    opacity: 0.25;
  }
  50% {
    opacity: 1;
  }
}

.sbi-error-banner {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 12px 22px 0;
  padding: 10px 14px;
  border: 1px solid #f3ddc0;
  border-radius: 10px;
  background: var(--sbi-warn-bg);
  color: var(--sbi-warn-text);
  font-size: 12.5px;
}

.sbi-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 22px 40px;
}

/* ---------- 视图共用原语（卡片/表格/骨架/空态/徽标） ---------- */

.sbi-card {
  border: 1px solid var(--sbi-border);
  border-radius: var(--sbi-radius);
  background: var(--sbi-card);
  box-shadow: var(--sbi-shadow);
}

.sbi-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px 0;
}

.sbi-card-header strong {
  font-size: 14.5px;
}

.sbi-card-header small {
  color: var(--sbi-text-3);
  font-size: 12px;
}

.sbi-card-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.sbi-seg {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--sbi-border);
  border-radius: 8px;
  background: #f1f5fa;
}

.sbi-seg > button {
  padding: 4px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--sbi-text-2);
  font-size: 12px;
  font-weight: 640;
  cursor: pointer;
}

.sbi-seg > button.is-active {
  background: #ffffff;
  color: var(--sbi-accent);
  box-shadow: 0 1px 2px rgba(16, 34, 56, 0.12);
}

.sbi-delta {
  font-size: 12px;
  font-weight: 700;
}

.sbi-delta.is-up {
  color: var(--sbi-up);
}

.sbi-delta.is-down {
  color: var(--sbi-down);
}

.sbi-delta.is-flat {
  color: var(--sbi-text-3);
}

.sbi-table-scroll {
  overflow: auto;
}

.sbi-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.sbi-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 10px 12px;
  border-bottom: 1px solid var(--sbi-border);
  background: #f7fafd;
  color: var(--sbi-text-2);
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}

.sbi-table th.is-left,
.sbi-table td.is-left {
  text-align: left;
}

.sbi-table td {
  padding: 9px 12px;
  border-bottom: 1px solid #eef3f9;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.sbi-table tbody tr:hover td {
  background: #f4f8fd;
}

.sbi-table tr.is-total td {
  background: #f0f5fc;
  font-weight: 720;
}

.sbi-empty {
  display: grid;
  gap: 6px;
  place-items: center;
  padding: 46px 20px;
  color: var(--sbi-text-3);
  font-size: 13px;
  text-align: center;
}

.sbi-empty strong {
  color: var(--sbi-text-2);
  font-size: 14px;
}

.sbi-skeleton {
  display: inline-block;
  border-radius: 6px;
  background: linear-gradient(90deg, #edf2f8 25%, #f7fafd 50%, #edf2f8 75%);
  background-size: 200% 100%;
  animation: sbi-shimmer 1.1s linear infinite;
}

@keyframes sbi-shimmer {
  to {
    background-position: -200% 0;
  }
}

.sbi-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(37, 87, 214, 0.08);
  color: var(--sbi-accent);
  font-size: 11.5px;
  font-weight: 700;
}

.sbi-badge.is-warn {
  background: var(--sbi-warn-bg);
  color: var(--sbi-warn-text);
}

.sbi-metric-hint {
  cursor: help;
  border-bottom: 1px dotted var(--sbi-text-3);
}

@media (max-width: 1280px) {
  .sbi-shell {
    grid-template-columns: 68px minmax(0, 1fr);
  }

  .sbi-brand-copy,
  .sbi-nav-item span,
  .sbi-scope-badge {
    display: none;
  }

  .sbi-nav-item {
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sbi-shell *,
  .sbi-shell *::before,
  .sbi-shell *::after {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}
