:root {
  --ink: #10212b;
  --muted: #667780;
  --line: #dbe5e7;
  --paper: #f4f7f6;
  --white: #fff;
  --teal: #0d7770;
  --teal-dark: #075b57;
  --amber: #a45f1e;
  --red: #a9433d;
  --shadow: 0 12px 30px rgba(16, 33, 43, .07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

body.notice-open { overflow: hidden; }
a { color: var(--teal-dark); text-decoration: none; }
button, input, textarea, select { font: inherit; }

.eyebrow,
.section-kicker {
  font-size: 10px;
  letter-spacing: .12em;
  font-weight: 800;
  color: var(--teal);
  text-transform: uppercase;
}

.shell {
  max-width: 1380px;
  margin: 0 auto;
  padding: 26px 24px 60px;
}

.access-strip {
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  box-shadow: var(--shadow);
}

.access-strip .section-kicker { color: #8ed5ca; }
.access-strip .muted { color: #aebfc3; margin-left: 10px; }

.token-row { display: flex; gap: 8px; min-width: min(560px, 100%); }

input,
textarea,
select {
  border: 1px solid var(--line);
  background: #fbfdfc;
  color: var(--ink);
  border-radius: 6px;
  padding: 10px 12px;
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(13, 119, 112, .12);
}

.token-row input {
  flex: 1;
  background: #21343d;
  border-color: #3d5961;
  color: #fff;
}

.token-row input::placeholder { color: #9eb0b5; }

.button {
  border: 0;
  border-radius: 6px;
  padding: 10px 15px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.button:disabled { cursor: not-allowed; opacity: .62; }
.button.primary { background: var(--teal); color: #fff; }
.button.primary:hover { background: var(--teal-dark); }
.button.secondary { background: #e7f2ef; color: var(--teal-dark); }
.button.danger { background: #f9e5e1; color: var(--red); }
.button.ghost { background: transparent; color: #c4d2d4; border: 1px solid #526a71; }

.hero-row {
  display: flex;
  align-items: end;
  gap: 36px;
  padding: 38px 2px 26px;
}

.hero-row h2 {
  font-size: 30px;
  line-height: 1.1;
  margin: 7px 0;
}

.hero-row p { margin: 0; max-width: 610px; }
.muted { color: var(--muted); }

.metric {
  margin-left: auto;
  min-width: 86px;
  border-left: 1px solid var(--line);
  padding-left: 22px;
}

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

.work-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.panel,
.table-section {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.panel { padding: 20px; }

.panel-head,
.table-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.panel h3,
.table-head h3 {
  margin: 4px 0 16px;
  font-size: 17px;
}

.format-chip {
  font-size: 11px;
  background: #eef6f3;
  color: var(--teal-dark);
  padding: 5px 8px;
  border-radius: 4px;
}

.import-panel textarea {
  width: 100%;
  min-height: 146px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0;
  color: var(--muted);
  font-size: 13px;
}

.check-row input { accent-color: var(--teal); }
.import-options { align-items: flex-start; flex-wrap: wrap; }
.import-options[hidden] { display: none !important; }

.domain-controls {
  display: grid;
  grid-template-columns: minmax(180px, .8fr) minmax(240px, 1.2fr);
  gap: 12px;
  flex: 1 0 100%;
  width: 100%;
}

.domain-controls label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.domain-controls select { width: 100%; }
.import-panel .domain-batch-input { min-height: 68px; max-height: 150px; line-height: 1.45; }
.domain-summary { min-height: 17px; color: var(--teal-dark); font-size: 11px; }
.domain-summary.bad { color: var(--red); }

.popular-domain-panel {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex: 1 0 100%;
  width: 100%;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.popular-domain-title {
  flex: 0 0 auto;
  padding-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.popular-domain-ranking {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 24px;
}

.popular-domain-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  border-radius: 4px;
  background: #eef6f3;
  color: var(--teal-dark);
  padding: 3px 7px;
  font-size: 11px;
}

.popular-domain-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.popular-domain-item strong { font-variant-numeric: tabular-nums; }

.inline-actions,
.split-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.split-panel { margin-top: 16px; }
.split-panel p { margin: 0 0 16px; }
.split-actions { flex-wrap: wrap; }
.split-actions input { flex: 1; min-width: 220px; }
.split-actions select { min-width: 82px; }

.result-block {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

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

.result-block textarea {
  width: 100%;
  min-height: 92px;
  background: #f7fbfa;
  color: var(--teal-dark);
  font: 12px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace;
  resize: vertical;
}

.table-section { margin-top: 16px; padding: 20px; }
.table-head { align-items: center; }
.table-head h3 { margin-bottom: 0; }

.table-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  min-width: 0;
}

.table-tools .muted {
  max-width: 520px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-toolbar {
  margin-top: 14px;
  padding: 12px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.batch-toolbar label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.batch-toolbar select {
  min-width: 170px;
  padding: 9px 10px;
}

.batch-operation-status {
  min-width: 170px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.routes-layout {
  --routes-panel-height: 760px;
  display: grid;
  grid-template-columns: minmax(400px, 480px) minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
  align-items: stretch;
}

.primary-account-panel,
.route-detail-panel {
  min-width: 0;
  height: var(--routes-panel-height);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  overflow: hidden;
}

.routes-panel-head {
  min-height: 52px;
  padding: 15px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.routes-panel-head .muted {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.account-filter-group {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.account-filter-group .filter {
  border: 0;
  border-radius: 4px;
  padding: 6px 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.account-filter-group .filter.active {
  background: #e0f2ec;
  color: var(--teal-dark);
}

.primary-account-list {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow: auto;
}

.primary-account-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.primary-account-table th,
.primary-account-table td {
  padding: 12px 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.primary-account-table th:nth-child(1),
.primary-account-table td:nth-child(1) { width: 44px; text-align: center; }

.primary-account-table th:nth-child(2),
.primary-account-table td:nth-child(2) { width: 43%; }

.primary-account-table th:nth-child(3),
.primary-account-table td:nth-child(3) { width: 27%; }

.primary-account-table th:nth-child(4),
.primary-account-table td:nth-child(4) { width: 30%; }

.primary-account-table th:nth-child(5),
.primary-account-table td:nth-child(5) { width: 88px; }

.select-cell input,
#select-all-accounts {
  width: 16px;
  height: 16px;
  margin: 0;
}

.primary-account-row {
  cursor: pointer;
  outline: none;
}

.primary-account-row:hover,
.primary-account-row:focus-visible {
  background: #eef6f3;
}

.primary-account-row.selected {
  background: #e0f2ec;
  color: var(--teal-dark);
  box-shadow: inset 4px 0 0 var(--teal);
}

.account-action-cell {
  overflow: visible !important;
  text-align: center;
}

.account-verify {
  border: 0;
  border-radius: 4px;
  padding: 5px 8px;
  background: #e7f2ef;
  color: var(--teal-dark);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.account-verify:disabled {
  cursor: wait;
  opacity: .62;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow: auto;
}

.route-detail-panel .table-wrap {
  flex: 1;
  min-height: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 850px;
}

.route-detail-table {
  min-width: 680px;
  table-layout: fixed;
}

.route-detail-table th:first-child,
.route-detail-table td:first-child {
  width: 34%;
  max-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-detail-table th:nth-child(2),
.route-detail-table td:nth-child(2) { width: 56%; }

.route-detail-table th:nth-child(3),
.route-detail-table td:nth-child(3) { width: 10%; }

th,
td {
  text-align: left;
  border-top: 1px solid var(--line);
  padding: 13px 10px;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 800;
}

.table-group-row th {
  border-top: 0;
  color: var(--teal);
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
  padding-bottom: 18px;
}

td:first-child { font-weight: 700; }

.route-detail-table th,
.route-detail-table td {
  background: #fff;
}

.status {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  background: #eef1f1;
  color: var(--muted);
}

.status.ready { background: #e0f2ec; color: var(--teal-dark); }
.status.bad { background: #f9e5e1; color: var(--red); }

.route {
  display: block;
  max-width: 560px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--teal-dark);
  font-family: ui-monospace, monospace;
  font-size: 12px;
}

.copy {
  border: 0;
  background: transparent;
  color: var(--teal);
  cursor: pointer;
  font-weight: 700;
}

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

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  background: var(--ink);
  color: #fff;
  padding: 11px 14px;
  border-radius: 6px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: .2s;
  pointer-events: none;
}

.toast.show { opacity: 1; transform: translateY(0); }

.notice-dialog {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16, 33, 43, .58);
  backdrop-filter: blur(3px);
}

.notice-dialog[hidden] { display: none; }

.notice-card {
  width: min(560px, 100%);
  max-height: min(90vh, 640px);
  overflow: auto;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(16, 33, 43, .24);
  padding: 24px;
}

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

.notice-dismiss {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 27px;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
}

.notice-dismiss:hover,
.notice-dismiss:focus-visible {
  background: #eef6f3;
  color: var(--teal-dark);
}

.notice-card h2 { margin: 10px 0 12px; font-size: 24px; }
.notice-card p { margin: 0 0 12px; color: var(--muted); }

.notice-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 22px;
}

.notice-links a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 8px 11px;
  border: 1px solid #b9cdca;
  border-radius: 6px;
  background: #f7fbfa;
  color: var(--teal-dark);
  font-weight: 700;
  font-size: 13px;
}

.notice-links a:hover,
.notice-links a:focus-visible {
  border-color: var(--teal);
  background: #e7f2ef;
}

.notice-actions { display: flex; justify-content: flex-end; }
.notice-actions .button { min-width: 150px; }

@media (max-width: 760px) {
  .resource-bar-inner {
    justify-content: center;
    min-height: 42px;
    padding: 0 8px;
  }

  .resource-bar a {
    flex: 1;
    text-align: center;
    padding: 3px 8px;
    font-size: 11px;
  }

  .topbar { padding: 0 16px; }
  .top-actions a { display: none; }
  .shell { padding: 16px; }

  .access-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .access-strip > div { min-width: 0; }
  .access-strip .muted { display: block; margin: 4px 0 0; }

  .token-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    width: 100%;
    min-width: 0;
  }

  .token-row input {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .token-row .primary { width: 100%; }

  .hero-row {
    gap: 15px;
    flex-wrap: wrap;
    padding-top: 28px;
  }

  .hero-row h2 { font-size: 26px; }
  .metric { margin-left: 0; }
  .metric:nth-last-child(1) { margin-left: auto; }
  .panel-head { min-width: 0; }

  .inline-actions,
  .split-actions {
    flex-wrap: wrap;
  }

  .split-actions input {
    min-width: 0;
    width: 100%;
    flex-basis: 100%;
  }

  .import-options {
    align-items: stretch;
    flex-direction: column;
  }

  .import-options label {
    display: flex;
    flex-wrap: wrap;
    min-width: 0;
  }

  .import-options select,
  .import-options .domain-batch-input {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .domain-controls { grid-template-columns: minmax(0, 1fr); }
  .popular-domain-panel { flex-direction: column; gap: 6px; }

  .table-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .table-tools {
    width: 100%;
    justify-content: space-between;
    align-items: stretch;
    flex-wrap: wrap;
  }

  .table-tools .muted {
    flex: 1 1 100%;
    max-width: none;
    white-space: normal;
  }

  .table-tools .button { width: 100%; }
  .batch-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .batch-toolbar label,
  .batch-toolbar select,
  .batch-toolbar .button {
    width: 100%;
  }

  .routes-panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .account-filter-group {
    width: 100%;
  }

  .account-filter-group .filter {
    flex: 1;
  }

  .routes-layout { grid-template-columns: minmax(0, 1fr); }
  .primary-account-panel,
  .route-detail-panel { height: auto; }
  .primary-account-list { flex: none; max-height: 240px; }
  .route-detail-panel .table-wrap { flex: none; }
  .table-wrap { overscroll-behavior-inline: contain; }
}
