:root {
  color-scheme: dark;
  --bg: #070b14;
  --panel: rgba(13, 19, 33, 0.92);
  --panel-strong: #101828;
  --text: #eef4ff;
  --muted: #8ea0bc;
  --line: rgba(116, 139, 176, 0.2);
  --blue: #5b8cff;
  --cyan: #31d7e5;
  --green: #35d49a;
  --red: #ff6b7a;
  --amber: #f6c65b;
  --purple: #b78cff;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 10%, rgba(91, 140, 255, 0.22), transparent 28%),
    radial-gradient(circle at 88% 0%, rgba(49, 215, 229, 0.14), transparent 30%),
    linear-gradient(180deg, #0b1020 0%, #070b14 58%, #05070d 100%),
    var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(1420px, calc(100% - 40px));
  margin: 0 auto;
  padding: 34px 0 44px;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(32px, 5vw, 58px);
  line-height: 1.02;
}

.subhead {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.config-pill,
.section-title span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
}

.main-panel,
.side-panel section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(17, 25, 43, 0.94), rgba(10, 15, 27, 0.94));
  box-shadow: var(--shadow);
}

.main-panel {
  overflow: hidden;
}

.query-bar {
  display: flex;
  align-items: end;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.field,
.search-box {
  display: grid;
  gap: 7px;
}

.field span,
.search-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.grow {
  flex: 1;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  background: rgba(6, 10, 20, 0.72);
  color: var(--text);
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}

input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(91, 140, 255, 0.16);
}

.key-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 8px;
}

.primary-button,
.ghost-button,
.icon-button {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 16px;
  border: 1px solid transparent;
  font-weight: 800;
  white-space: nowrap;
}

.primary-button {
  background: linear-gradient(135deg, var(--blue), #7c5cff);
  color: #fff;
  box-shadow: 0 12px 28px rgba(91, 140, 255, 0.28);
}

.ghost-button {
  background: rgba(15, 23, 42, 0.72);
  border-color: var(--line);
  color: var(--text);
}

.icon-button {
  background: rgba(91, 140, 255, 0.12);
  border-color: var(--line);
  color: var(--blue);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
}

.metric {
  min-height: 126px;
  padding: 18px;
  background: rgba(9, 14, 26, 0.86);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 12px;
  font-size: 28px;
  line-height: 1.1;
}

.metric small {
  display: block;
  margin-top: 9px;
  color: var(--muted);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, 72px);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 11, 20, 0.86);
}

.segment {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segment.active {
  background: rgba(91, 140, 255, 0.16);
  color: #dce7ff;
  box-shadow: inset 0 0 0 1px rgba(91, 140, 255, 0.28);
}

.search-box {
  width: min(360px, 45%);
}

.table-wrap {
  overflow: auto;
  max-height: 560px;
}

table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 12px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #101827;
  color: var(--muted);
  font-weight: 900;
}

td {
  background: rgba(10, 15, 27, 0.94);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.mono {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.number-cell,
.compact-cell {
  white-space: normal;
}

th:nth-child(1),
td:nth-child(1) {
  width: 72px;
}

th:nth-child(2),
td:nth-child(2) {
  width: 110px;
}

th:nth-child(3),
td:nth-child(3) {
  width: 92px;
}

th:nth-child(4),
td:nth-child(4) {
  width: 150px;
}

th:nth-child(5),
td:nth-child(5) {
  width: 64px;
}

th:nth-child(6),
td:nth-child(6) {
  width: 76px;
}

.token-cell {
  font-size: 12px;
}

.token-cell div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  line-height: 1.4;
}

.token-cell span {
  color: var(--muted);
}

.token-cell strong {
  font-weight: 800;
}

.cost-cell {
  color: var(--red);
  font-weight: 900;
}

.token-in {
  color: var(--blue);
}

.token-out {
  color: var(--green);
}

.token-total {
  color: var(--amber);
}

.duration-cell {
  color: var(--purple);
  font-weight: 800;
}

.cache-line {
  color: var(--cyan);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: rgba(8, 12, 23, 0.95);
  color: var(--muted);
  font-size: 13px;
}

.pagination[hidden] {
  display: none;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.small-button {
  min-height: 34px;
  padding: 0 12px;
}

.small-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.empty {
  height: 160px;
  text-align: center;
  color: var(--muted);
}

.side-panel {
  display: grid;
  align-content: start;
  gap: 18px;
}

.side-panel section {
  padding: 18px;
}

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

.section-title p {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
}

.renew-card form {
  display: grid;
  gap: 13px;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.renew-preview {
  margin-top: 14px;
  padding: 14px;
  border-radius: 8px;
  background: rgba(7, 11, 20, 0.72);
  border: 1px dashed var(--line);
  color: var(--muted);
  font-size: 13px;
}

.preview-grid {
  display: grid;
  gap: 10px;
}

.preview-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(49, 215, 229, 0.12);
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
}

.tag.muted {
  background: rgba(142, 160, 188, 0.12);
  color: var(--muted);
}

.status-ok {
  color: var(--green);
}

.status-bad {
  color: var(--red);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(430px, calc(100vw - 44px));
  padding: 13px 15px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 700;
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 24px, 1420px);
    padding-top: 22px;
  }

  .hero,
  .query-bar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .search-box {
    width: 100%;
  }

  .segmented {
    width: 100%;
    grid-template-columns: repeat(3, 1fr);
  }
}
