/* ==========================================================================
   客户中心（/portal）— 复用管理面板的设计令牌与基础组件，只补门户布局
   ========================================================================== */

.portal-body { background: var(--bg); }

.portal-brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--brand-grad);
  color: #fff;
}
.portal-brand-mark svg { width: 19px; height: 19px; }

.login-brand > div:last-child { display: flex; flex-direction: column; line-height: 1.25; }
.login-brand strong { font-size: 15px; letter-spacing: -.01em; }
.login-brand span { font-size: 11px; color: var(--fg-subtle); }

.portal-login-card { width: min(400px, calc(100vw - 32px)); }

/* 顶部栏 */
.portal-top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 64px;
  padding: 0 22px;
  background: rgba(255, 255, 255, .88);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}
.portal-top-brand { display: flex; align-items: center; gap: 10px; }
.portal-top-brand > div:last-child { display: flex; flex-direction: column; line-height: 1.2; }
.portal-top-brand strong { font-size: 14px; }
.portal-top-brand span { font-size: 10.5px; color: var(--fg-subtle); }
.portal-top-right { display: flex; align-items: center; gap: 10px; }
.portal-who {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--fg-muted);
}

/* 主区 */
.portal-main {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.portal-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.portal-hero h1 { font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
.portal-hero p { margin-top: 5px; color: var(--fg-muted); font-size: 12.5px; }
.portal-hero-actions { display: flex; gap: 8px; }

.portal-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 0; }

.portal-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(280px, 1fr);
  gap: 18px;
  align-items: start;
}

/* 公告 */
.announce {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12.5px;
  line-height: 1.65;
}
.announce.is-warn { border-color: rgba(234, 88, 12, .28); background: var(--warn-soft); color: #9a3d0a; }
.announce.is-bad { border-color: rgba(231, 0, 11, .25); background: var(--danger-soft); color: #a3070e; }
.announce.is-info { border-color: rgba(66, 192, 142, .28); background: var(--brand-soft); color: var(--brand-ink); }

/* Key 列表 */
.key-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px auto;
  gap: 14px;
  align-items: center;
  padding: 14px 18px;
  border-top: 1px solid var(--border-soft);
}
.key-item:first-child { border-top: 0; }
.key-item-main { min-width: 0; }
.key-item-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.key-item-title strong { font-size: 13px; font-weight: 600; }
.key-item-sub { margin-top: 4px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 11px; color: var(--fg-subtle); }
.key-item-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.quota-block { min-width: 0; }
.quota-line { display: flex; justify-content: space-between; font-size: 11px; color: var(--fg-muted); margin-bottom: 5px; }
.quota-bar {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.quota-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
  transition: width .35s ease;
}
.quota-bar.is-warn > span { background: var(--warn); }
.quota-bar.is-danger > span { background: var(--danger); }

/* 图表 */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 150px;
  padding-top: 8px;
}
.chart-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; min-width: 0; }
.chart-bar {
  position: relative;
  min-height: 2px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, #5ccfa2 0%, #42c08e 100%);
  transition: height .3s ease;
}
.chart-bar.is-empty { background: var(--surface-3); }
.chart-label {
  font-size: 9.5px;
  color: var(--fg-subtle);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chart-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--fg-subtle);
}

/* 侧栏提示 */
.portal-tip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
  font-size: 11.5px;
  color: var(--fg-subtle);
}
.portal-tip strong { font-size: 11.5px; color: var(--fg-muted); font-weight: 500; }

.portal-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 2px 0;
  font-size: 11px;
  color: var(--fg-subtle);
}

/* 会话 */
.session-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 18px;
  border-top: 1px solid var(--border-soft);
  font-size: 11.5px;
}
.session-row:first-child { border-top: 0; }
.session-row .ua { color: var(--fg-subtle); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Toast */
.portal-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 90;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 10px;
  background: #1f2430;
  color: #fff;
  font-size: 12.5px;
  box-shadow: var(--sh-pop);
  max-width: min(520px, calc(100vw - 32px));
}
.portal-toast.is-ok { background: #177a52; }
.portal-toast.is-warn { background: #a8480c; }
.portal-toast.is-bad { background: #a3070e; }

@media (max-width: 900px) {
  .portal-grid { grid-template-columns: 1fr; }
  .portal-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .key-item { grid-template-columns: 1fr; }
  .key-item-actions { justify-content: flex-start; }
}
@media (max-width: 560px) {
  .portal-top { padding: 0 14px; }
  .portal-who { display: none; }
  .portal-main { width: calc(100% - 20px); }
  .portal-stats { grid-template-columns: 1fr; }
}

/* 登录 / 注册切换 */
.login-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 14px;
  background: var(--bg-subtle, #f4f5f7);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.login-tab {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 8px 10px;
  border-radius: 7px;
  font: inherit;
  font-size: 12.5px;
  color: var(--fg-muted);
  cursor: pointer;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.login-tab:hover { color: var(--fg); }
.login-tab.is-active {
  background: var(--surface, #fff);
  color: var(--fg);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .08);
}
.login-tab:focus-visible { outline: 2px solid var(--brand, #4f46e5); outline-offset: 1px; }

/* 单 Key 用量弹窗 */
.key-usage-chart { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding: 8px 0 0; }
.key-usage-chart .bar {
  flex: 1;
  min-width: 6px;
  border-radius: 4px 4px 0 0;
  background: var(--brand-grad, linear-gradient(180deg, #6366f1, #4f46e5));
  position: relative;
}
.key-usage-chart .bar.is-empty { background: var(--border); }
.key-usage-chart .bar span {
  position: absolute;
  left: 50%;
  bottom: -18px;
  transform: translateX(-50%);
  font-size: 9.5px;
  color: var(--fg-subtle);
  white-space: nowrap;
}
.key-usage-meta { display: flex; justify-content: space-between; margin-top: 22px; font-size: 11.5px; color: var(--fg-muted); }
