:root {
  --bg: #f6f7f4;
  --panel: #ffffff;
  --text: #202124;
  --muted: #68706a;
  --line: #dfe4dc;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --orange: #f97316;
  --red: #c2410c;
  --ink: #17201c;
  --shadow: 0 12px 28px rgba(25, 31, 28, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
  padding: 0 28px;
  background: rgba(246, 247, 244, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.brand img {
  width: 36px;
  height: 36px;
}

.nav a {
  color: var(--teal-dark);
  font-weight: 700;
  text-decoration: none;
}

.shell {
  width: min(1180px, calc(100% - 36px));
  margin: 28px auto 56px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.panel + .panel,
.workspace {
  margin-top: 20px;
}

.panel-head,
.panel-title,
.quote-row,
.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.currency-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(60px, 1fr));
  gap: 4px;
  padding: 4px;
  background: #e8f3ef;
  border: 1px solid #c8ddd5;
  border-radius: 8px;
}

.currency-switch button {
  min-height: 34px;
  padding: 0 12px;
  color: var(--teal-dark);
  background: transparent;
}

.currency-switch button.active {
  color: #ffffff;
  background: var(--teal);
}

.panel-head.compact {
  align-items: flex-start;
}

.kicker {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

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

h1 {
  font-size: 28px;
  line-height: 1.25;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 16px;
  line-height: 1.3;
}

.balance-box,
.metric {
  display: grid;
  gap: 6px;
  min-width: 150px;
  padding: 14px 16px;
  background: #f9fbf8;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.balance-box span,
.metric span,
label span,
.muted,
dt {
  color: var(--muted);
  font-size: 13px;
}

.balance-box strong,
.metric strong {
  font-size: 24px;
  color: var(--teal-dark);
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  margin-top: 22px;
}

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

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 8px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  color: var(--text);
  background: #fbfcfa;
  border: 1px solid #cfd8cf;
  border-radius: 6px;
  padding: 10px 12px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  font-weight: 800;
  cursor: pointer;
}

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

.primary {
  color: #fff;
  background: var(--teal);
}

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

.secondary {
  color: #fff;
  background: var(--orange);
}

.ghost {
  color: var(--teal-dark);
  background: #e8f3ef;
}

.danger {
  color: #fff;
  background: var(--red);
}

.wide {
  width: 100%;
}

.message {
  margin-top: 16px;
  min-height: 24px;
}

.message.error {
  color: var(--red);
}

.message.success {
  color: var(--teal-dark);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
  gap: 20px;
  align-items: start;
}

.selection-steps {
  margin-top: 18px;
  border-top: 1px solid var(--line);
}

.selection-step {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.step-heading {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  color: #fff;
  background: var(--teal);
  border-radius: 50%;
  font-size: 14px;
  font-weight: 900;
}

.step-controls {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

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

.native-select {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.service-choice-grid {
  grid-template-columns: repeat(auto-fill, minmax(164px, 1fr));
}

.choice-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 62px;
  padding: 10px;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
}

.choice-card:hover,
.choice-card.active {
  border-color: var(--teal);
  background: #e7f4ef;
}

.choice-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  overflow: hidden;
  color: var(--teal-dark);
  background: #eef4ef;
  border: 1px solid #d7e5dc;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 900;
}

.choice-icon img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #ffffff;
}

.service-icon {
  border-radius: 10px;
}

.country-icon img {
  object-fit: cover;
}

.choice-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.choice-main strong,
.choice-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.choice-main strong {
  font-size: 14px;
}

.choice-main span,
.choice-empty {
  color: var(--muted);
  font-size: 12px;
}

.choice-empty {
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.quote-row {
  margin-top: 18px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.quote-row strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
}

.quote-levels {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.quote-level {
  display: grid;
  gap: 2px;
  min-height: 66px;
  min-width: 148px;
  padding: 10px 13px;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
}

.quote-level:hover,
.quote-level.active {
  border-color: var(--teal);
  background: #e7f4ef;
}

.quote-level strong {
  margin: 0;
  color: var(--orange);
  font-size: 18px;
}

.quote-level span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.rank-filter {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 16px;
  padding: 6px;
  background: #e8f3ef;
  border: 1px solid #c8ddd5;
  border-radius: 8px;
}

.rank-filter button {
  min-height: 38px;
  color: var(--teal-dark);
  background: transparent;
}

.rank-filter button.active {
  color: #fff;
  background: var(--teal);
}

.rank-rules {
  overflow: hidden;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.rank-rule-row {
  display: grid;
  grid-template-columns: minmax(86px, 0.8fr) minmax(90px, 0.9fr) minmax(130px, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.rank-rule-row:first-child {
  border-top: 0;
}

.rank-rule-head {
  color: var(--muted);
  background: #eef4ef;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.rank-rule-name {
  font-size: 14px;
}

.rank-rule-name.gold {
  color: #9a6a00;
}

.rank-rule-name.silver {
  color: #60666d;
}

.rank-rule-name.bronze {
  color: #9a5424;
}

.provider-prices {
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.provider-empty {
  padding: 16px;
  color: var(--muted);
}

.country-service-card {
  margin: 0;
  padding: 12px;
  color: #ffffff;
  background: #3fa978;
  border: 1px solid #2d916f;
  border-radius: 8px;
}

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

.country-service-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.country-service-icons {
  display: flex;
  align-items: center;
  width: 58px;
  flex: 0 0 auto;
}

.country-service-icons .choice-icon {
  width: 38px;
  height: 38px;
  color: var(--teal-dark);
  background: #ffffff;
  border: 0;
  box-shadow: 0 3px 10px rgba(25, 31, 28, 0.18);
}

.country-service-icons .choice-icon + .choice-icon {
  margin-left: -16px;
}

.country-service-title strong,
.country-service-title small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.country-service-title strong {
  font-size: 17px;
  line-height: 1.15;
}

.country-service-title small {
  margin-top: 3px;
  color: #d7f4e5;
  font-size: 12px;
  font-weight: 800;
}

.country-service-buy,
.position-cost {
  color: #ffffff;
  background: var(--orange);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.12);
}

.country-service-buy {
  min-width: 80px;
  min-height: 34px;
}

.position-toggle {
  width: 100%;
  min-height: 34px;
  margin-top: 12px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.16);
}

.country-service-card.collapsed .position-table {
  display: none;
}

.position-table {
  margin-top: 10px;
}

.position-head,
.price-position-row {
  display: grid;
  grid-template-columns: minmax(88px, 0.8fr) minmax(118px, 1fr) minmax(132px, 1fr);
  align-items: center;
  gap: 14px;
}

.position-head {
  padding: 2px 4px 10px;
  color: #d7f4e5;
  font-size: 14px;
  font-weight: 800;
}

.price-position-row {
  min-height: 48px;
  padding: 5px 0;
  color: #ffffff;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
}

.price-position-row.active {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
}

.position-count {
  white-space: nowrap;
}

.position-cost {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 900;
}

.level-list.compact {
  display: none;
}

.activation-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
  gap: 12px;
  padding: 14px;
}

.activation-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "icons body"
    "icons price";
  gap: 10px 12px;
  align-items: center;
  width: 100%;
  min-height: 132px;
  padding: 12px;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
}

.activation-card:hover,
.activation-card.active {
  border-color: var(--teal);
  background: #e7f4ef;
}

.activation-icons {
  grid-area: icons;
  display: flex;
  align-items: center;
  width: 70px;
  min-height: 52px;
}

.activation-icons .choice-icon {
  width: 42px;
  height: 42px;
  box-shadow: 0 4px 12px rgba(25, 31, 28, 0.10);
}

.activation-icons .choice-icon + .choice-icon {
  margin-left: -14px;
}

.activation-body {
  grid-area: body;
  display: grid;
  gap: 6px;
  min-width: 0;
}

.activation-title,
.activation-provider {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activation-title {
  font-size: 14px;
  font-weight: 900;
}

.activation-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.activation-provider {
  color: var(--muted);
  font-size: 12px;
}

.activation-price {
  grid-area: price;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.activation-price span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.activation-price strong {
  color: var(--orange);
  font-size: 20px;
}

.provider-head,
.provider-row {
  display: grid;
  grid-template-columns: 54px minmax(78px, 0.8fr) minmax(90px, 1fr) minmax(100px, 1fr) minmax(90px, 0.9fr);
  align-items: center;
  gap: 10px;
}

.price-summary {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.price-summary strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.level-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
}

.level-row {
  display: grid;
  gap: 3px;
  padding: 10px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.level-row strong {
  margin: 0;
  color: var(--orange);
  font-size: 17px;
}

.level-row span {
  color: var(--muted);
  font-size: 12px;
}

.provider-head {
  padding: 10px 14px;
  color: var(--muted);
  background: #eef4ef;
  font-size: 12px;
  font-weight: 800;
}

.provider-list {
  overflow: visible;
}

.provider-row {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  color: var(--text);
  background: transparent;
  border-top: 1px solid var(--line);
  border-radius: 0;
  text-align: left;
}

.provider-row:hover,
.provider-row.active {
  background: #e7f4ef;
}

.provider-row strong {
  color: var(--orange);
  font-size: 17px;
}

.provider-id,
.rank {
  font-family: Consolas, "SFMono-Regular", monospace;
  font-weight: 800;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  width: fit-content;
  min-width: 70px;
  padding: 0 10px;
  color: #fff;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
}

.rank-badge.gold {
  background: linear-gradient(#d9b84b, #ad7c18);
}

.rank-badge.silver {
  background: linear-gradient(#d9dce0, #8f969d);
}

.rank-badge.bronze {
  background: linear-gradient(#cd8a55, #9a5424);
}

.rank-badge.unknown {
  color: var(--muted);
  background: #e5e7eb;
}

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

.order-details div {
  min-height: 86px;
  padding: 14px;
  background: #fbfcfa;
  border: 1px solid var(--line);
  border-radius: 8px;
}

dt {
  margin-bottom: 8px;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 20px;
  font-weight: 800;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--teal-dark);
  background: #e8f3ef;
  font-size: 13px;
  font-weight: 800;
}

.admin-shell {
  display: grid;
  gap: 20px;
}

.admin-content {
  display: grid;
  gap: 20px;
}

.hidden {
  display: none !important;
}

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

.output {
  margin-top: 14px;
  min-height: 90px;
  resize: vertical;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  margin-top: 16px;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.table-actions {
  display: flex;
  gap: 8px;
}

.table-actions button {
  min-height: 34px;
  padding: 0 10px;
}

.code-text {
  font-family: Consolas, "SFMono-Regular", monospace;
  font-weight: 800;
}

@media (max-width: 860px) {
  .topbar {
    padding: 0 16px;
  }

  .shell {
    width: min(100% - 24px, 1180px);
    margin-top: 18px;
  }

  .panel {
    padding: 18px;
  }

  .panel-head,
  .panel-title,
  .quote-row,
  .action-row {
    align-items: stretch;
    flex-direction: column;
  }

  .form-grid,
  .form-grid.two,
  .form-grid.three,
  .step-controls.two,
  .workspace,
  .order-details,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 22px;
  }

  .choice-grid,
  .service-choice-grid,
  .activation-card-grid {
    grid-template-columns: 1fr;
  }

  .activation-card {
    min-height: 116px;
  }

  .country-service-card {
    padding: 10px;
  }

  .position-head,
  .price-position-row {
    grid-template-columns: minmax(68px, 0.8fr) minmax(76px, 0.9fr) minmax(108px, 1fr);
    gap: 8px;
  }

  .price-position-row {
    font-size: 14px;
  }

  .position-cost {
    min-height: 36px;
    padding: 0 10px;
  }

  .price-position-row .rank-badge {
    min-width: 64px;
    padding: 0 6px;
    font-size: 13px;
  }
}
