:root {
  color-scheme: light;
  --bg: #eef2f6;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-2: rgba(244, 247, 250, 0.92);
  --line: rgba(30, 43, 58, 0.1);
  --text: #111827;
  --muted: #6b7280;
  --danger: #dc4c42;
  --warning: #c79222;
  --success: #178761;
  --blue: #2563eb;
  --shadow: 0 18px 50px rgba(34, 48, 66, 0.12);
  --soft-shadow: 0 8px 26px rgba(34, 48, 66, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #f8fafc 0%, var(--bg) 100%);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

select {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.title-block {
  text-align: center;
}

.top-spacer,
.settings-btn {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
}

.settings-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  box-shadow: var(--soft-shadow);
  position: relative;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.settings-btn::before,
.settings-btn::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  height: 2px;
  border-radius: 999px;
  background: #4b5563;
  box-shadow: 0 7px 0 #4b5563;
}

.settings-btn::before {
  top: 13px;
}

.settings-btn::after {
  display: none;
}

.settings-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(37, 99, 235, 0.22);
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.13);
}

.eyebrow {
  margin: 0 0 5px;
  color: #2563eb;
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 24px;
  font-weight: 820;
}

button {
  height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  color: #ffffff;
  background: var(--blue);
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.18);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.auth-panel,
.account-card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(18px);
}

.settings-dialog {
  width: min(390px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.settings-dialog::backdrop {
  background: rgba(12, 18, 14, 0.35);
}

.settings-card {
  display: grid;
  gap: 11px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.settings-head h2 {
  font-size: 18px;
}

.settings-card label {
  color: var(--muted);
  font-size: 12px;
}

.settings-card input,
.settings-card select {
  height: 42px;
  width: 100%;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  outline: none;
}

.settings-card input:focus,
.settings-card select:focus {
  border-color: rgba(37, 99, 235, 0.42);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.close-btn {
  color: #5f6962;
  font-size: 22px;
}

.auth-panel {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.auth-panel label,
#statusText {
  color: var(--muted);
  font-size: 12px;
}

.token-row {
  display: flex;
  gap: 10px;
}

#adminApiKey {
  height: 38px;
  min-width: 0;
  flex: 1;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 10px;
  outline: none;
}

.cards-head {
  display: flex;
  justify-content: flex-end;
  min-height: 20px;
  margin: 4px 0 12px;
}

.card-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.account-card {
  padding: 16px;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.account-card:hover {
  transform: translateY(-2px);
  border-color: rgba(37, 99, 235, 0.18);
  box-shadow: var(--shadow);
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.identity {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  color: #ffffff;
  background: linear-gradient(145deg, #111827, #334155);
  font-size: 11px;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.identity h2 {
  max-width: min(420px, calc(100vw - 140px));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 15px;
  line-height: 1.2;
}

.identity p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  max-width: min(420px, calc(100vw - 140px));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 128px;
}

.badges span {
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 999px;
  padding: 0 8px;
  color: #475569;
  background: rgba(248, 250, 252, 0.82);
  font-size: 10px;
  font-weight: 720;
}

.badges .status.ok {
  color: #0f6f50;
  background: rgba(23, 135, 97, 0.12);
  border-color: rgba(23, 135, 97, 0.18);
}

.badges .status.warn {
  color: #916813;
  background: rgba(199, 146, 34, 0.13);
  border-color: rgba(199, 146, 34, 0.18);
}

.badges .status.muted {
  color: #64748b;
  background: rgba(100, 116, 139, 0.12);
  border-color: rgba(100, 116, 139, 0.16);
}

.icon-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #647069;
  font-size: 17px;
  line-height: 1;
}

.usage-row + .usage-row {
  margin-top: 12px;
}

.usage-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.usage-meta strong {
  color: #1f2937;
  font-weight: 760;
  white-space: nowrap;
}

.progress-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(226, 232, 240, 0.92);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.06);
}

.progress-fill {
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
  background: #c7d1ca;
  transition: width 220ms ease;
}

.progress-fill.red {
  background: linear-gradient(90deg, #f87171, var(--danger));
}

.progress-fill.yellow {
  background: linear-gradient(90deg, #facc15, var(--warning));
}

.progress-fill.green {
  background: linear-gradient(90deg, #34d399, var(--success));
}

.usage-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
  color: #8a94a3;
  font-size: 10px;
}

.usage-foot span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 42px 0;
}

@media (max-width: 520px) {
  .shell {
    width: calc(100vw - 24px);
    padding-top: 18px;
  }

  .card-list {
    grid-template-columns: 1fr;
  }

  .topbar {
    margin-bottom: 14px;
  }

  h1 {
    font-size: 21px;
  }

  .token-row {
    flex-direction: column;
  }

  button {
    width: 100%;
  }

  .topbar button,
  .icon-btn {
    width: auto;
  }

  .identity h2 {
    max-width: calc(100vw - 132px);
  }

  .identity p {
    max-width: calc(100vw - 132px);
  }

  .badges {
    max-width: 96px;
  }
}

@media (min-width: 900px) {
  .topbar {
    margin-bottom: 20px;
  }

  .card-list {
    gap: 16px;
  }

  .account-card {
    padding: 16px;
  }
}

@media (min-width: 1180px) {
  .card-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
