:root {
  color-scheme: light;
  --page: #f4f7f8;
  --surface: #ffffff;
  --surface-muted: #eef3f4;
  --line: #d5dfe2;
  --line-strong: #aebfc4;
  --text: #162126;
  --muted: #617078;
  --accent: #155e75;
  --accent-dark: #0e4759;
  --accent-soft: #e2f1f5;
  --success: #167252;
  --success-soft: #e4f4ed;
  --warning: #9a5d0b;
  --warning-soft: #fff4df;
  --danger: #b0333e;
  --danger-soft: #fff0f1;
  --shadow: 0 10px 28px rgba(22, 33, 38, 0.07);
  --radius: 8px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: Inter, "Avenir Next", "Helvetica Neue", "PingFang SC", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--page);
  color: var(--text);
  font-family: var(--sans);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
input,
select,
textarea {
  outline-color: var(--accent);
}

button {
  border: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-header {
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.header-inner,
.app-main {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 82px;
  gap: 24px;
}

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

.eyebrow,
.section-kicker {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.12em;
}

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

h1 {
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  line-height: 1.08;
}

h2 {
  font-size: 1.12rem;
  line-height: 1.25;
}

.app-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.app-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}

.app-nav a:hover,
.app-nav a.is-active {
  background: var(--surface);
  color: var(--accent-dark);
  box-shadow: 0 4px 12px rgba(22, 33, 38, 0.07);
}

.app-main {
  padding: 22px 0 36px;
}

.import-band,
.results-section {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.import-band {
  padding: 18px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.section-heading,
.results-topbar,
.results-toolbar,
.progress-head,
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-heading {
  margin-bottom: 14px;
}

.import-settings {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.import-settings input {
  width: 64px;
  min-height: 36px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  text-align: center;
}

.import-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.42fr) minmax(0, 1fr) 150px;
  gap: 12px;
  align-items: stretch;
}

.drop-zone {
  display: grid;
  min-height: 168px;
  place-content: center;
  gap: 6px;
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-muted);
  color: var(--text);
  cursor: pointer;
  text-align: center;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-zone span:last-child {
  color: var(--muted);
  font-size: 0.82rem;
}

.drop-icon {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 1.55rem;
  font-weight: 800;
}

.input-shell {
  display: block;
  min-width: 0;
}

textarea {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 168px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfc;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(21, 94, 117, 0.12);
}

.import-actions {
  display: grid;
  grid-auto-rows: minmax(42px, auto);
  gap: 8px;
  align-content: start;
}

.button,
.icon-button,
.filter-tab,
.stat-button {
  cursor: pointer;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 13px;
  border-radius: 6px;
  font-size: 0.84rem;
  font-weight: 780;
}

.button-primary {
  background: var(--accent);
  color: #ffffff;
}

.button-primary:hover {
  background: var(--accent-dark);
}

.button-secondary {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.button-secondary:hover {
  border-color: var(--line-strong);
  background: var(--surface-muted);
}

.button:disabled,
.icon-button:disabled,
.filter-tab:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.security-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 12px;
  padding: 9px 11px;
  border-left: 3px solid var(--warning);
  background: var(--warning-soft);
  color: #71460c;
  font-size: 0.79rem;
  line-height: 1.5;
}

.security-notice strong {
  flex: 0 0 auto;
}

.status-line {
  min-height: 20px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.status-line.is-success {
  color: var(--success);
}

.status-line.is-error {
  color: var(--danger);
}

.progress-wrap {
  margin-top: 10px;
}

.progress-head {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

.progress-track {
  height: 7px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--surface-muted);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 160ms ease;
}

.stats-band {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border-right: 1px solid var(--line);
  border-left: 1px solid var(--line);
  background: var(--surface);
}

.stat-button {
  display: grid;
  min-width: 0;
  min-height: 72px;
  align-content: center;
  gap: 5px;
  padding: 10px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  text-align: left;
}

.stat-button:last-child {
  border-right: 0;
}

.stat-button:hover,
.stat-button.is-active {
  background: var(--surface-muted);
  color: var(--text);
}

.stat-button.is-active {
  box-shadow: inset 0 -3px 0 var(--accent);
}

.stat-button span {
  overflow: hidden;
  font-size: 0.76rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-button strong {
  color: var(--text);
  font-family: var(--mono);
  font-size: 1.2rem;
}

.results-section {
  border-radius: 0 0 var(--radius) var(--radius);
}

.results-topbar {
  min-height: 70px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.json-export-bar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  border-bottom: 1px solid var(--line);
  background: var(--line);
}

.json-export-group {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: #fbfcfc;
}

.json-export-label {
  display: grid;
  min-width: 92px;
  gap: 2px;
}

.json-export-label strong {
  color: var(--text);
  font-size: 0.8rem;
}

.json-export-label span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
}

.threshold-control {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.77rem;
  font-weight: 700;
}

.threshold-control input {
  width: 62px;
  min-height: 36px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  text-align: center;
}

.json-export-group .button {
  margin-left: auto;
  white-space: nowrap;
}

.command-bar,
.list-controls,
.pagination-buttons {
  display: flex;
  align-items: center;
  gap: 7px;
}

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  font-weight: 800;
}

.icon-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-muted);
}

.icon-button.danger {
  border-color: #e8b8bd;
  color: var(--danger);
}

.icon-button.danger:hover {
  background: var(--danger-soft);
}

.results-toolbar {
  align-items: flex-start;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfc;
}

.filter-tabs {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 5px;
}

.filter-tab {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.77rem;
  font-weight: 760;
  white-space: nowrap;
}

.filter-tab:hover,
.filter-tab.is-active {
  border-color: var(--line);
  background: var(--surface);
  color: var(--accent-dark);
}

.search-control input,
.page-size-control select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.search-control input {
  width: min(260px, 28vw);
  padding: 7px 10px;
}

.page-size-control {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.77rem;
  font-weight: 700;
}

.page-size-control select {
  padding: 6px 8px;
}

.table-shell {
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}

.accounts-table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.8rem;
}

.accounts-table th,
.accounts-table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  text-align: left;
}

.accounts-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.accounts-table th:nth-child(1) {
  width: 44px;
}

.accounts-table th:nth-child(2) {
  width: 23%;
}

.accounts-table th:nth-child(3),
.accounts-table th:nth-child(4) {
  width: 9%;
}

.accounts-table th:nth-child(5) {
  width: 12%;
}

.accounts-table th:nth-child(6),
.accounts-table th:nth-child(7) {
  width: 18%;
}

.accounts-table th:nth-child(8) {
  width: 126px;
}

.select-column,
.row-select {
  text-align: center !important;
}

.account-cell {
  min-width: 0;
}

.account-email,
.account-id {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-email {
  color: var(--text);
  font-weight: 780;
}

.account-id {
  margin-top: 3px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.7rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 5px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 820;
  white-space: nowrap;
}

.badge.alive {
  background: var(--success-soft);
  color: var(--success);
}

.badge.failed,
.badge.invalid,
.badge.http402,
.badge.expired {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.loading,
.badge.pending {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.badge.rate_limited,
.badge.unsupported {
  background: var(--warning-soft);
  color: var(--warning);
}

.quota-cell {
  min-width: 0;
}

.quota-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}

.quota-top strong {
  font-family: var(--mono);
  font-size: 0.8rem;
}

.quota-top span {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.67rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quota-track {
  height: 5px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--surface-muted);
}

.quota-track span {
  display: block;
  height: 100%;
  background: var(--success);
}

.quota-track span.medium {
  background: var(--warning);
}

.quota-track span.low {
  background: var(--danger);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.row-actions .icon-button {
  width: 32px;
  height: 32px;
  flex-basis: 32px;
  font-size: 0.85rem;
}

.detail-row td {
  padding: 0;
  background: #fbfcfc;
}

.account-detail {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 12px 54px;
  border-bottom: 1px solid var(--line);
}

.detail-item {
  min-width: 0;
}

.detail-item span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 750;
}

.detail-item strong,
.detail-item code {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-row {
  height: 190px;
  color: var(--muted);
  text-align: center !important;
}

.pagination {
  min-height: 54px;
  padding: 8px 18px;
  color: var(--muted);
  font-size: 0.78rem;
}

.pagination-buttons strong {
  min-width: 64px;
  color: var(--text);
  font-family: var(--mono);
  text-align: center;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1040px) {
  .header-inner {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    padding: 14px 0;
  }

  .app-nav {
    width: 100%;
  }

  .app-nav a {
    min-width: 0;
    flex: 1 1 0;
    padding: 0 8px;
  }

  .import-grid {
    grid-template-columns: minmax(200px, 0.45fr) minmax(0, 1fr);
  }

  .import-actions {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stats-band {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .stat-button:nth-child(4) {
    border-right: 0;
  }

  .stat-button:nth-child(-n + 4) {
    border-bottom: 1px solid var(--line);
  }

  .results-topbar,
  .results-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .command-bar {
    flex-wrap: wrap;
  }

  .json-export-bar {
    grid-template-columns: 1fr;
  }

  .list-controls {
    justify-content: space-between;
  }

  .search-control {
    flex: 1 1 auto;
  }

  .search-control input {
    width: 100%;
  }
}

@media (max-width: 700px) {
  .header-inner,
  .app-main {
    width: min(100% - 20px, 1440px);
  }

  .app-header {
    position: static;
  }

  .app-nav {
    overflow-x: auto;
  }

  .app-nav a {
    flex: 0 0 auto;
  }

  .app-main {
    padding-top: 10px;
  }

  .import-band {
    padding: 14px;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .drop-zone {
    min-height: 116px;
  }

  textarea {
    min-height: 160px;
  }

  .import-actions {
    grid-column: auto;
    grid-template-columns: 1fr;
  }

  .security-notice {
    display: block;
  }

  .security-notice strong {
    display: block;
    margin-bottom: 4px;
  }

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

  .stat-button,
  .stat-button:nth-child(4) {
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  .stat-button:nth-child(even) {
    border-right: 0;
  }

  .stat-button:last-child {
    border-bottom: 0;
  }

  .command-bar .button {
    flex: 1 1 calc(50% - 7px);
  }

  .json-export-group {
    flex-wrap: wrap;
    padding: 10px 14px;
  }

  .json-export-label {
    flex: 1 1 auto;
  }

  .json-export-group .button {
    width: 100%;
    margin-left: 0;
  }

  .filter-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .list-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .page-size-control {
    justify-content: space-between;
  }

  .account-detail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 12px 44px;
  }
}
