:root {
  --bg: #0f141b;
  --bg-soft: #121922;
  --surface: #171f2a;
  --surface-2: #111820;
  --surface-3: #1d2733;
  --border: #2b3746;
  --border-soft: #243140;
  --text: #eef3f8;
  --muted: #9aa8b8;
  --muted-2: #6f7f91;
  --accent: #23c4ad;
  --accent-dark: #18a28f;
  --blue: #5b8def;
  --good: #22c55e;
  --warn: #f59e0b;
  --danger: #f97316;
  --critical: #ef4444;
  --none: #8b99ad;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(35, 196, 173, 0.07), transparent 260px),
    var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei UI", "PingFang SC", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 24px;
  background: rgba(16, 22, 30, 0.95);
  border-bottom: 1px solid var(--border);
}

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

.brand-mark {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #061413;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(35, 196, 173, 0.22);
}

.brand-copy {
  min-width: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: #f7fbff;
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: 0;
}

.brand-sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.clock {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

main {
  width: min(1260px, 100%);
  margin: 0 auto;
  padding: 22px 22px 36px;
}

.usage-shell {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.usage-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 2px solid var(--accent);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.eyebrow,
.card-kicker {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}

.usage-heading h2 {
  margin-top: 4px;
  color: #f7fbff;
  font-size: 24px;
  line-height: 1.2;
}

.usage-heading p {
  margin-top: 6px;
  color: var(--muted);
}

.heading-badge {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 13px;
  color: #bffaf1;
  background: rgba(35, 196, 173, 0.12);
  border: 1px solid rgba(35, 196, 173, 0.35);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.usage-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  padding: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.field {
  min-width: 150px;
}

.key-field {
  flex: 1 1 420px;
}

.range-field {
  flex: 0 0 150px;
}

.field label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  color: var(--text);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
}

input::placeholder {
  color: #66778a;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(35, 196, 173, 0.16);
}

button {
  min-height: 38px;
  padding: 0 15px;
  color: var(--text);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

button:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent);
}

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

.primary {
  min-width: 96px;
  color: #06201d;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 800;
}

.primary:hover:not(:disabled) {
  color: #03110f;
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.toolbar-status {
  min-height: 38px;
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.error-banner {
  padding: 11px 13px;
  color: #ffd1d1;
  background: rgba(239, 68, 68, 0.13);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 8px;
}

.error-banner[hidden] {
  display: none;
}

.usage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.info-card,
.logs-panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.info-card {
  padding: 16px;
}

.quota-card {
  grid-column: 1 / -1;
  border-top: 2px solid var(--accent);
}

.key-card {
  border-top: 2px solid var(--blue);
}

.usage-card {
  border-top: 2px solid #38bdf8;
}

.card-head,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-head {
  margin-bottom: 14px;
}

.card-title,
.section-head h2 {
  margin-top: 3px;
  color: #f7fbff;
  font-size: 16px;
  font-weight: 800;
}

.quota-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-3);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.level-good {
  color: #9cf2bd;
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.36);
}

.level-warn {
  color: #ffe08a;
  background: rgba(245, 158, 11, 0.13);
  border-color: rgba(245, 158, 11, 0.4);
}

.level-danger {
  color: #fed7aa;
  background: rgba(249, 115, 22, 0.14);
  border-color: rgba(249, 115, 22, 0.42);
}

.level-critical {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.42);
}

.level-none {
  color: var(--muted);
  background: rgba(139, 153, 173, 0.12);
  border-color: rgba(139, 153, 173, 0.25);
}

.quota-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.8fr);
  gap: 14px;
  align-items: stretch;
}

.quota-numbers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.quota-stat,
.quota-progress,
.key-tile,
.usage-group,
.usage-tile {
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 7px;
}

.quota-stat {
  padding: 13px;
}

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

.quota-stat strong {
  display: block;
  margin-top: 7px;
  color: #f7fbff;
  font-size: 24px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.quota-stat.is-used strong {
  color: #ffe08a;
}

.quota-stat.is-remaining strong {
  color: #9cf2bd;
}

.quota-progress {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 9px;
  padding: 13px;
}

.progress-meta,
.progress-scale {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.progress-meta {
  color: var(--muted);
  font-size: 12px;
}

.progress-meta strong {
  color: #f7fbff;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 13px;
  overflow: hidden;
  background: #0b1016;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #22c55e, #23c4ad);
  transition: width 0.35s ease;
}

.progress-fill.level-warn {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.progress-fill.level-danger {
  background: linear-gradient(90deg, #f97316, #fbbf24);
}

.progress-fill.level-critical {
  background: linear-gradient(90deg, #ef4444, #f87171);
}

.progress-fill.is-empty {
  background: #334155;
}

.progress-scale {
  color: var(--muted-2);
  font-size: 11px;
}

.quota-foot {
  min-height: 18px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.key-tile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.key-tile,
.usage-tile {
  padding: 11px;
}

.key-tile .value,
.usage-tile .value {
  display: block;
  margin-top: 5px;
  color: var(--text);
  font-weight: 800;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.usage-groups {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.usage-group {
  padding: 12px;
}

.usage-group-title {
  margin-bottom: 9px;
  color: #dbe5ef;
  font-size: 13px;
  font-weight: 800;
}

.usage-tile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.usage-tile .value {
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logs-panel {
  padding: 16px;
}

.section-head {
  margin-bottom: 12px;
}

.result-count {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.table-wrap {
  overflow: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.data-table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
  white-space: nowrap;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #b8c5d4;
  background: #1b2531;
  font-size: 12px;
  font-weight: 800;
}

.data-table tbody tr:hover {
  background: rgba(35, 196, 173, 0.055);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.empty-state {
  padding: 36px 16px;
  color: var(--muted);
  text-align: center;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 12px;
  color: var(--muted);
}

.pager span {
  min-width: 62px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.pager button {
  min-width: 76px;
}

@media (max-width: 1040px) {
  .quota-main,
  .usage-grid {
    grid-template-columns: 1fr;
  }

  .usage-groups {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .topbar,
  .usage-heading,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar {
    padding: 14px;
  }

  main {
    padding: 14px 14px 26px;
  }

  .usage-heading {
    padding: 16px;
  }

  .usage-heading h2 {
    font-size: 22px;
  }

  .usage-toolbar {
    align-items: stretch;
  }

  .field,
  .key-field,
  .range-field {
    min-width: 100%;
    flex: 1 1 100%;
  }

  .toolbar-status {
    min-height: 0;
  }

  .quota-numbers,
  .key-tile-grid,
  .usage-tile-grid {
    grid-template-columns: 1fr;
  }

  .quota-stat strong {
    font-size: 21px;
  }

  .logs-panel,
  .info-card {
    padding: 14px;
  }
}
