/* Scoped ChatBI usage redesign — does not alter other admin tabs */
#usagePanel.module-panel.panel > .module-panel__inner#usagePanelRoot,
#usagePanelRoot {
  --usage-bg: #f5f7fb;
  --usage-panel: #ffffff;
  --usage-line: #e6eaf0;
  --usage-text: #172033;
  --usage-muted: #6b778c;
  --usage-primary: #4f6ef7;
  --usage-primary-weak: #eef2ff;
  --usage-success: #12a66a;
  --usage-success-weak: #eaf8f1;
  --usage-warning: #e39a16;
  --usage-warning-weak: #fff7e8;
  --usage-danger: #e45656;
  --usage-danger-weak: #fff0f0;
  --usage-shadow: 0 8px 28px rgba(27, 39, 65, 0.06);
  --usage-radius: 14px;

  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 0 0 24px !important;
  color: var(--usage-text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", Arial, sans-serif;
  min-width: 0;
}

body.admin-tab-usage .main-chrome .header,
body.admin-tab-usage .main-chrome .toolbar,
body.admin-tab-usage .main-chrome .validation-banner {
  display: none !important;
}

body.admin-tab-usage .main-chrome {
  padding-bottom: 0;
}

body.admin-tab-usage .user-bar {
  margin-bottom: 8px;
}

body.admin-tab-usage .workspace {
  padding-top: 0;
}

body.admin-tab-usage .main-footer {
  display: block;
}

#usagePanelRoot * {
  box-sizing: border-box;
}

#usagePanelRoot .usage-content {
  max-width: 1700px;
  margin: 0 auto;
  padding: 4px 2px 8px;
}

#usagePanelRoot .usage-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

#usagePanelRoot .usage-page-head h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.4px;
  color: var(--usage-text);
}

#usagePanelRoot .usage-page-head p {
  margin: 5px 0 0;
  color: var(--usage-muted);
  font-size: 13px;
}

#usagePanelRoot .usage-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

#usagePanelRoot .usage-btn {
  height: 38px;
  padding: 0 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--usage-line);
  border-radius: 10px;
  background: #fff !important;
  color: #435066 !important;
  font-weight: 600;
  font-size: 13px;
  min-width: 0 !important;
  width: auto !important;
  cursor: pointer;
  transition: 0.18s ease;
}

#usagePanelRoot .usage-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(30, 45, 75, 0.07);
}

#usagePanelRoot .usage-btn.primary {
  border-color: var(--usage-primary);
  background: var(--usage-primary) !important;
  color: #fff !important;
}

#usagePanelRoot .usage-btn.ghost {
  background: transparent;
}

#usagePanelRoot .usage-btn.small {
  height: 31px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 12px;
}

#usagePanelRoot .usage-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

#usagePanelRoot .usage-notice {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 50px;
  margin-bottom: 16px;
  padding: 10px 14px;
  border: 1px solid #dce7ff;
  border-radius: 12px;
  background: linear-gradient(90deg, #f6f9ff, #ffffff);
}

#usagePanelRoot .usage-notice-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--usage-success);
  box-shadow: 0 0 0 4px rgba(18, 166, 106, 0.12);
}

#usagePanelRoot .usage-notice-dot.warn {
  background: var(--usage-warning);
  box-shadow: 0 0 0 4px rgba(227, 154, 22, 0.15);
}

#usagePanelRoot .usage-notice-main {
  flex: 1;
  min-width: 0;
  color: #536178;
  font-size: 13px;
}

#usagePanelRoot .usage-notice-main strong {
  color: var(--usage-text);
}

#usagePanelRoot .usage-notice-main code {
  padding: 2px 6px;
  border-radius: 6px;
  background: #edf2ff;
  color: #4660cf;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

#usagePanelRoot .usage-card {
  background: var(--usage-panel);
  border: 1px solid var(--usage-line);
  border-radius: var(--usage-radius);
  box-shadow: var(--usage-shadow);
}

#usagePanelRoot .usage-filter-card {
  margin-bottom: 16px;
  padding: 16px;
}

#usagePanelRoot .usage-filter-row {
  display: grid;
  grid-template-columns: 1fr 1.35fr 1fr 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}

#usagePanelRoot .usage-field label {
  display: block;
  margin-bottom: 7px;
  color: #617087;
  font-size: 12px;
  font-weight: 600;
}

#usagePanelRoot .usage-control {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  border: 1px solid #dde3ec;
  border-radius: 9px;
  outline: none;
  background: #fff;
  color: var(--usage-text);
  font: inherit;
  transition: 0.18s ease;
}

#usagePanelRoot .usage-control:focus {
  border-color: #9eafff;
  box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.09);
}

#usagePanelRoot .usage-filter-buttons {
  display: flex;
  gap: 8px;
}

#usagePanelRoot .usage-kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

#usagePanelRoot .usage-kpi {
  position: relative;
  min-height: 124px;
  padding: 16px;
  overflow: hidden;
}

#usagePanelRoot .usage-kpi:after {
  content: "";
  position: absolute;
  right: -22px;
  bottom: -28px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: rgba(79, 110, 247, 0.05);
}

#usagePanelRoot .usage-kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--usage-muted);
  font-size: 12px;
}

#usagePanelRoot .usage-kpi-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--usage-primary-weak);
  color: var(--usage-primary);
  font-size: 12px;
  font-weight: 700;
}

#usagePanelRoot .usage-kpi-value {
  margin: 13px 0 5px;
  font-size: 26px;
  line-height: 1;
  font-weight: 750;
  letter-spacing: -0.8px;
}

#usagePanelRoot .usage-kpi-foot {
  color: var(--usage-muted);
  font-size: 11px;
}

#usagePanelRoot .usage-analytics-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(330px, 0.9fr);
  gap: 16px;
  margin-bottom: 16px;
}

#usagePanelRoot .usage-card-head {
  min-height: 58px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--usage-line);
}

#usagePanelRoot .usage-card-title h3 {
  margin: 0;
  font-size: 15px;
  color: var(--usage-text);
}

#usagePanelRoot .usage-card-title p {
  margin: 3px 0 0;
  color: var(--usage-muted);
  font-size: 11px;
}

#usagePanelRoot .usage-segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 9px;
  background: #f1f4f8;
}

#usagePanelRoot .usage-segmented button {
  height: 29px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent !important;
  color: #66748a !important;
  font-size: 12px;
  min-width: 0 !important;
  width: auto !important;
  font-weight: 600;
  cursor: pointer;
}

#usagePanelRoot .usage-segmented button.active {
  background: #fff !important;
  color: var(--usage-text) !important;
  box-shadow: 0 2px 8px rgba(30, 45, 75, 0.07);
}

#usagePanelRoot .usage-chart-wrap {
  padding: 10px 16px 14px;
}

#usagePanelRoot .usage-chart {
  width: 100%;
  height: 260px;
  display: block;
}

#usagePanelRoot .usage-chart-label {
  fill: #8a96a8;
  font-size: 11px;
}

#usagePanelRoot .usage-status-body {
  padding: 16px;
}

#usagePanelRoot .usage-donut-layout {
  display: grid;
  grid-template-columns: 144px 1fr;
  align-items: center;
  gap: 12px;
}

#usagePanelRoot .usage-donut {
  position: relative;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: conic-gradient(
    var(--usage-success) 0 100%,
    var(--usage-danger) 100% 100%,
    var(--usage-warning) 100% 100%
  );
}

#usagePanelRoot .usage-donut:after {
  content: "";
  position: absolute;
  inset: 17px;
  border-radius: 50%;
  background: #fff;
}

#usagePanelRoot .usage-donut-center {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  text-align: center;
}

#usagePanelRoot .usage-donut-center strong {
  display: block;
  font-size: 24px;
  line-height: 1;
}

#usagePanelRoot .usage-donut-center span {
  display: block;
  margin-top: 4px;
  color: var(--usage-muted);
  font-size: 11px;
}

#usagePanelRoot .usage-legend {
  display: grid;
  gap: 12px;
}

#usagePanelRoot .usage-legend-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  color: #56647a;
  font-size: 12px;
}

#usagePanelRoot .usage-legend-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

#usagePanelRoot .usage-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

#usagePanelRoot .usage-legend-row strong {
  color: var(--usage-text);
}

#usagePanelRoot .usage-exception-list {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--usage-line);
}

#usagePanelRoot .usage-exception-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 0;
  cursor: pointer;
}

#usagePanelRoot .usage-exception-item + .usage-exception-item {
  border-top: 1px dashed #e7ebf1;
}

#usagePanelRoot .usage-exception-icon {
  width: 27px;
  height: 27px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--usage-danger-weak);
  color: var(--usage-danger);
  font-weight: 700;
  font-size: 12px;
}

#usagePanelRoot .usage-exception-text {
  min-width: 0;
  flex: 1;
}

#usagePanelRoot .usage-exception-text strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--usage-text);
}

#usagePanelRoot .usage-exception-text span {
  color: var(--usage-muted);
  font-size: 11px;
}

#usagePanelRoot .usage-table-card {
  margin-bottom: 16px;
}

#usagePanelRoot .usage-tabs {
  display: flex;
  gap: 20px;
  height: 42px;
  align-items: center;
}

#usagePanelRoot .usage-tab {
  position: relative;
  color: var(--usage-muted);
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
  user-select: none;
}

#usagePanelRoot .usage-tab.active {
  color: var(--usage-text);
}

#usagePanelRoot .usage-tab.active:after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -18px;
  height: 2px;
  border-radius: 1px;
  background: var(--usage-primary);
}

#usagePanelRoot .usage-table-wrap {
  overflow: auto;
}

#usagePanelRoot table.usage-table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
  font-size: 12px;
}

#usagePanelRoot table.usage-table th {
  height: 42px;
  padding: 0 14px;
  background: #f8fafc;
  color: #69768b;
  font-size: 11px;
  font-weight: 650;
  text-align: left;
  border-bottom: 1px solid var(--usage-line);
  border-top: 0;
  border-left: 0;
  border-right: 0;
}

#usagePanelRoot table.usage-table td {
  height: 54px;
  padding: 0 14px;
  color: #3f4c61;
  border-bottom: 1px solid #edf0f4;
  border-top: 0;
  border-left: 0;
  border-right: 0;
  font-size: 12px;
  vertical-align: middle;
}

#usagePanelRoot table.usage-table tbody tr:hover {
  background: #fafbfe;
}

#usagePanelRoot table.usage-table tbody tr:last-child td {
  border-bottom: 0;
}

#usagePanelRoot .usage-account {
  display: flex;
  align-items: center;
  gap: 9px;
}

#usagePanelRoot .usage-mini-avatar {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: #eef2ff;
  color: #5269db;
  font-weight: 700;
  flex: 0 0 auto;
}

#usagePanelRoot .usage-account strong {
  display: block;
  color: var(--usage-text);
}

#usagePanelRoot .usage-account span {
  display: block;
  color: var(--usage-muted);
  font-size: 10px;
}

#usagePanelRoot .usage-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 650;
}

#usagePanelRoot .usage-tag.success {
  color: var(--usage-success);
  background: var(--usage-success-weak);
}

#usagePanelRoot .usage-tag.danger {
  color: var(--usage-danger);
  background: var(--usage-danger-weak);
}

#usagePanelRoot .usage-tag.warning {
  color: var(--usage-warning);
  background: var(--usage-warning-weak);
}

#usagePanelRoot .usage-tag.info {
  color: #5269db;
  background: var(--usage-primary-weak);
}

#usagePanelRoot .usage-progress {
  width: 84px;
  height: 6px;
  border-radius: 4px;
  background: #edf0f5;
  overflow: hidden;
}

#usagePanelRoot .usage-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #7a8eff, #4f6ef7);
}

#usagePanelRoot .usage-table-actions {
  display: flex;
  gap: 8px;
}

#usagePanelRoot .usage-link-btn {
  border: 0;
  background: transparent !important;
  color: var(--usage-primary) !important;
  padding: 0;
  font-weight: 650;
  font-size: 12px;
  min-width: 0 !important;
  width: auto !important;
  cursor: pointer;
}

#usagePanelRoot .usage-q-cell {
  max-width: 280px;
  white-space: normal;
  word-break: break-word;
}

#usagePanelRoot .usage-pagination {
  min-height: 58px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--usage-line);
  color: var(--usage-muted);
  font-size: 12px;
  gap: 12px;
  flex-wrap: wrap;
}

#usagePanelRoot .usage-pages {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

#usagePanelRoot .usage-page-btn {
  min-width: 32px !important;
  height: 32px;
  padding: 0 9px;
  border: 1px solid var(--usage-line);
  border-radius: 8px;
  background: #fff !important;
  color: #566176 !important;
  font-weight: 600;
  font-size: 12px;
  width: auto !important;
  cursor: pointer;
}

#usagePanelRoot .usage-page-btn.active {
  border-color: var(--usage-primary);
  background: var(--usage-primary) !important;
  color: #fff !important;
}

#usagePanelRoot .usage-page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#usagePanelRoot .usage-muted {
  color: var(--usage-muted);
}

#usagePanelRoot .usage-status-line {
  margin-top: 8px;
  color: var(--usage-muted);
  font-size: 12px;
  min-height: 18px;
}

.usage-drawer-mask {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: none;
  background: rgba(14, 22, 36, 0.36);
  backdrop-filter: blur(2px);
}

.usage-drawer-mask.show {
  display: block;
}

.usage-drawer-mask .usage-drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: 720px;
  max-width: 78vw;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #f7f9fc;
  box-shadow: -16px 0 42px rgba(20, 30, 50, 0.18);
  animation: usageSlideIn 0.22s ease;
  color: #172033;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", Arial, sans-serif;
}

@keyframes usageSlideIn {
  from {
    transform: translateX(32px);
    opacity: 0.6;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.usage-drawer-mask .usage-drawer-head {
  height: 68px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border-bottom: 1px solid #e6eaf0;
  flex-shrink: 0;
}

.usage-drawer-mask .usage-drawer-head h3 {
  margin: 0;
  font-size: 17px;
}

.usage-drawer-mask .usage-drawer-head p {
  margin: 3px 0 0;
  color: #6b778c;
  font-size: 11px;
}

.usage-drawer-mask .usage-icon-btn {
  width: 36px !important;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid #e6eaf0;
  border-radius: 10px;
  background: #fff !important;
  color: #566176 !important;
  min-width: 0 !important;
  padding: 0;
  cursor: pointer;
  font-size: 18px;
  font-weight: 600;
}

.usage-drawer-mask .usage-drawer-body {
  padding: 16px 18px 28px;
  overflow: auto;
  flex: 1;
  min-height: 0;
}

.usage-drawer-mask .usage-profile-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.usage-drawer-mask .usage-profile-item {
  padding: 12px;
  border: 1px solid #e6eaf0;
  border-radius: 11px;
  background: #fff;
}

.usage-drawer-mask .usage-profile-item span {
  display: block;
  color: #6b778c;
  font-size: 10px;
}

.usage-drawer-mask .usage-profile-item strong {
  display: block;
  margin-top: 5px;
  font-size: 14px;
}

.usage-drawer-mask .usage-message {
  margin-bottom: 12px;
  padding: 15px;
  border: 1px solid #e6eaf0;
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 5px 18px rgba(30, 45, 75, 0.04);
}

.usage-drawer-mask .usage-message-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  color: #6b778c;
  font-size: 11px;
}

.usage-drawer-mask .usage-question {
  padding: 10px 12px;
  border-radius: 10px;
  background: #f4f6fb;
  color: #2c3850;
  font-weight: 650;
  white-space: pre-wrap;
  word-break: break-word;
}

.usage-drawer-mask .usage-answer {
  margin-top: 10px;
  color: #526076;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.usage-drawer-mask .usage-message-foot {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed #e4e8ef;
}

.usage-drawer-mask .usage-meta-chip {
  padding: 3px 7px;
  border-radius: 6px;
  background: #f5f7fa;
  color: #748096;
  font-size: 10px;
}

.usage-drawer-mask .usage-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 650;
}

.usage-drawer-mask .usage-tag.success {
  color: #12a66a;
  background: #eaf8f1;
}

.usage-drawer-mask .usage-tag.danger {
  color: #e45656;
  background: #fff0f0;
}

.usage-drawer-mask .usage-tag.warning {
  color: #e39a16;
  background: #fff7e8;
}

.usage-api-dialog {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(14, 22, 36, 0.36);
}

.usage-api-dialog.show {
  display: flex;
}

.usage-api-dialog .usage-api-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 14px;
  border: 1px solid #e6eaf0;
  box-shadow: 0 16px 40px rgba(20, 30, 50, 0.18);
  padding: 20px;
  color: #172033;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", Arial, sans-serif;
}

.usage-api-dialog h3 {
  margin: 0 0 6px;
  font-size: 17px;
}

.usage-api-dialog p {
  margin: 0 0 14px;
  color: #6b778c;
  font-size: 12px;
}

.usage-api-dialog label {
  display: block;
  margin-bottom: 7px;
  color: #617087;
  font-size: 12px;
  font-weight: 600;
}

.usage-api-dialog input {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  border: 1px solid #dde3ec;
  border-radius: 9px;
  outline: none;
  font: inherit;
}

.usage-api-dialog .usage-api-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.usage-api-dialog .usage-btn {
  height: 36px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e6eaf0;
  border-radius: 10px;
  background: #fff !important;
  color: #435066 !important;
  font-weight: 600;
  font-size: 13px;
  min-width: 0 !important;
  width: auto !important;
  cursor: pointer;
}

.usage-api-dialog .usage-btn.primary {
  border-color: #4f6ef7;
  background: #4f6ef7 !important;
  color: #fff !important;
}

.usage-toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1400;
  display: none;
  min-width: 230px;
  padding: 12px 14px;
  border-radius: 11px;
  background: #172033;
  color: #fff;
  box-shadow: 0 12px 28px rgba(16, 24, 40, 0.22);
  font-size: 13px;
}

.usage-toast.show {
  display: block;
  animation: usageToastIn 0.18s ease;
}

@keyframes usageToastIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1360px) {
  #usagePanelRoot .usage-kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #usagePanelRoot .usage-filter-row {
    grid-template-columns: 1fr 1.2fr 1fr 1fr;
  }

  #usagePanelRoot .usage-filter-buttons {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }
}

@media (max-width: 1280px) {
  #usagePanelRoot .usage-analytics-grid {
    grid-template-columns: 1fr;
  }

  #usagePanelRoot .usage-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .usage-drawer-mask .usage-profile-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
