:root {
  color-scheme: light;
  --page: #f5f7f6;
  --surface: #ffffff;
  --ink: #17212b;
  --muted: #66727c;
  --line: #d9e0dd;
  --line-strong: #c7d2cd;
  --teal: #0f766e;
  --teal-dark: #0a5c55;
  --teal-soft: #e5f4f1;
  --amber: #a15c07;
  --amber-soft: #fff5df;
  --red: #b42318;
  --red-soft: #fff0ee;
  --focus: #1d8a80;
  --shadow: 0 10px 24px rgb(22 33 43 / 7%);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page);
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

button,
input,
textarea {
  font: inherit;
}

button,
input,
textarea {
  border-radius: 6px;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

:focus-visible {
  outline: 3px solid rgb(29 138 128 / 34%);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 10;
  transform: translateY(-180%);
  padding: 8px 12px;
  background: var(--ink);
  color: #fff;
  text-decoration: none;
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.topbar-inner,
.console-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 86px;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.eyebrow,
.section-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 19px;
  line-height: 1.2;
}

h2 {
  margin: 3px 0 0;
  font-size: 18px;
  line-height: 1.25;
}

.connection-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.state-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9aa6ad;
}

.connection-state.is-connected {
  color: var(--teal-dark);
}

.connection-state.is-connected .state-dot {
  background: var(--teal);
}

.console-shell {
  padding: 36px 0 64px;
}

.connection-panel,
.overview-section,
.accounts-section,
.import-section {
  border-top: 1px solid var(--line-strong);
}

.connection-panel {
  display: grid;
  grid-template-columns: minmax(180px, 0.65fr) minmax(360px, 1.35fr);
  align-items: end;
  gap: 32px;
  padding: 24px 0 28px;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.connection-form {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  padding: 9px 10px;
  font-size: 14px;
  font-weight: 500;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--teal);
  outline: none;
}

.api-key-field {
  width: min(100%, 390px);
}

.field textarea {
  min-height: 176px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.45;
}

.connection-actions,
.overview-actions,
.import-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.button {
  min-height: 38px;
  border: 1px solid transparent;
  padding: 8px 13px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.button.primary {
  background: var(--teal);
  color: #fff;
}

.button.primary:hover:not(:disabled) {
  background: var(--teal-dark);
}

.button.secondary {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

.button.secondary:hover:not(:disabled) {
  border-color: var(--teal);
  color: var(--teal-dark);
}

.notice {
  margin: 0 0 24px;
  border-left: 3px solid var(--teal);
  padding: 10px 12px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-size: 14px;
  font-weight: 600;
}

.notice.is-error {
  border-left-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
}

.overview-section,
.accounts-section,
.import-section {
  padding: 28px 0 32px;
}

.overview-heading {
  align-items: center;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.stat-card {
  min-height: 110px;
  padding: 15px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--ink);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.stat-card strong {
  display: block;
  margin-top: 15px;
  font-size: 30px;
  line-height: 1;
}

.stat-active {
  border-top-color: var(--teal);
}

.stat-limited {
  border-top-color: var(--amber);
}

.stat-error {
  border-top-color: var(--red);
}

.runtime-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin: 18px 0 0;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.runtime-details div {
  min-width: 0;
}

.runtime-details dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.runtime-details dd {
  overflow: hidden;
  margin: 3px 0 0;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.table-frame {
  overflow-x: auto;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: #f9fbfa;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

td {
  font-size: 14px;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr.is-selected {
  background: #f1fbf8;
}

.account-identity {
  display: grid;
  gap: 2px;
  min-width: 220px;
}

.account-identity strong {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-identity span,
.last-used {
  color: var(--muted);
  font-size: 12px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  border-radius: 5px;
  padding: 3px 7px;
  background: #eef1f0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.status-badge.active {
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.status-badge.rate-limited {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-badge.error {
  background: var(--red-soft);
  color: var(--red);
}

.row-action {
  min-width: 86px;
}

.compact-action {
  min-width: 52px;
  margin-left: 6px;
}

.destructive-action:hover:not(:disabled) {
  border-color: var(--red);
  color: var(--red);
}

.proxy-editor {
  display: grid;
  grid-template-columns: auto minmax(170px, 220px) auto;
  align-items: center;
  gap: 7px;
  min-width: 350px;
}

.proxy-state {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.proxy-input {
  min-height: 34px;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  padding: 6px 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
}

.proxy-input:focus {
  border-color: var(--teal);
  outline: 3px solid rgb(29 138 128 / 18%);
}

.proxy-save {
  min-height: 34px;
  padding: 6px 9px;
  font-size: 12px;
}

.account-dialog {
  width: min(560px, calc(100% - 28px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 20px 64px rgb(22 33 43 / 24%);
}

.account-dialog::backdrop {
  background: rgb(14 26 37 / 48%);
}

.account-dialog-form {
  display: grid;
  gap: 16px;
  padding: 24px;
}

.dialog-heading,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-heading h2 {
  margin: 2px 0 0;
  font-size: 20px;
}

.icon-button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
}

.icon-button:hover {
  border-color: var(--teal);
  color: var(--teal-dark);
}

.check-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.check-control input {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 4px;
}

.row-action[aria-current="true"] {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.empty-state {
  margin: 0;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.import-form {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.import-payload-field {
  max-width: 100%;
}

.import-controls {
  flex-wrap: wrap;
}

.file-picker {
  display: inline-flex;
  align-items: center;
}

.file-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.file-name {
  min-width: 0;
  max-width: 320px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shard-field {
  width: 96px;
}

.shard-field input {
  text-align: center;
}

.toggle-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
}

.toggle-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.toggle-track {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 20px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #e9eeeb;
  transition: background 150ms ease, border-color 150ms ease;
}

.toggle-track::after {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgb(22 33 43 / 25%);
  content: "";
  transition: transform 150ms ease;
}

.toggle-control input:checked + .toggle-track {
  border-color: var(--teal);
  background: var(--teal);
}

.toggle-control input:checked + .toggle-track::after {
  transform: translateX(14px);
}

.toggle-control input:focus-visible + .toggle-track {
  outline: 3px solid rgb(29 138 128 / 34%);
  outline-offset: 2px;
}

@media (max-width: 840px) {
  .connection-panel {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .connection-form {
    justify-content: flex-start;
  }

  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .topbar-inner,
  .console-shell {
    width: min(100% - 28px, 1180px);
  }

  .topbar-inner {
    min-height: 78px;
    gap: 14px;
  }

  .connection-state {
    font-size: 12px;
  }

  .console-shell {
    padding-top: 24px;
  }

  .connection-form,
  .overview-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .api-key-field {
    width: 100%;
  }

  .connection-actions,
  .overview-actions {
    justify-content: space-between;
  }

  .connection-actions .button {
    flex: 1;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat-card {
    min-height: 98px;
  }

  .runtime-details {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .section-heading {
    align-items: flex-start;
  }

  .import-controls {
    align-items: flex-end;
  }

  .file-name {
    flex-basis: 100%;
    max-width: 100%;
    order: 3;
  }

  .shard-field {
    width: 78px;
  }

  .import-controls > .button.primary {
    flex: 1;
  }
}
