:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #65738a;
  --line: #dbe3ef;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #0f766e;
  --danger: #dc2626;
  --warning: #b45309;
  --shadow: 0 12px 30px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Microsoft YaHei", sans-serif;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

.topbar {
  align-items: center;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
}

.nav {
  align-items: center;
  display: flex;
  gap: 18px;
}

.inline-form {
  display: inline;
}

.link-button {
  background: transparent;
  border: 0;
  color: var(--primary);
  cursor: pointer;
  padding: 0;
}

.page {
  margin: 0 auto;
  max-width: 1120px;
  padding: 32px 24px 56px;
}

.notice,
.flash {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 16px;
  padding: 12px 14px;
}

.notice {
  background: #eef6ff;
  color: #17406f;
}

.flash-list {
  margin-bottom: 18px;
}

.flash-success {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: var(--success);
}

.flash-error {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--danger);
}

.auth-layout {
  align-items: center;
  display: grid;
  gap: 36px;
  grid-template-columns: minmax(0, 1fr) 420px;
  min-height: calc(100vh - 180px);
}

.auth-copy h1,
.header-row h1 {
  font-size: 36px;
  line-height: 1.2;
  margin: 8px 0 12px;
}

.auth-copy p {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
  max-width: 560px;
}

.eyebrow {
  color: var(--success);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0;
}

.panel,
.service-card,
.stat-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-form {
  display: grid;
  gap: 18px;
  padding: 28px;
}

label {
  color: var(--text);
  display: grid;
  gap: 8px;
  font-weight: 700;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 44px;
  padding: 10px 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  outline: 3px solid rgba(37, 99, 235, 0.16);
}

.primary-button,
.secondary-button,
.danger-button {
  align-items: center;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
}

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

.primary-button:hover {
  background: var(--primary-dark);
  text-decoration: none;
}

.secondary-button {
  background: #e8eef7;
  color: var(--text);
}

.danger-button {
  background: #fee2e2;
  color: var(--danger);
}

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

.full-width {
  width: 100%;
}

.muted,
.empty-text {
  color: var(--muted);
}

.header-row {
  align-items: center;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  margin-bottom: 24px;
}

.balance-chip {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 8px;
  color: var(--success);
  font-weight: 700;
  padding: 12px 14px;
}

.danger-chip {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--danger);
}

.danger-notice {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--danger);
}

.stats-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 24px;
}

.stat-panel {
  display: grid;
  gap: 8px;
  min-height: 120px;
  padding: 22px;
}

.stat-panel span,
.label {
  color: var(--muted);
  font-size: 14px;
}

.stat-panel strong {
  font-size: 30px;
}

.stat-panel small {
  color: var(--muted);
  line-height: 1.4;
}

.danger-text {
  color: var(--danger);
}

.panel {
  padding: 24px;
}

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

.panel-title h2 {
  font-size: 20px;
  margin: 0;
}

.table-wrap {
  overflow-x: auto;
}

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

tr[id^="country-"] {
  scroll-margin-top: 96px;
}

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

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.service-card {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.service-card h2 {
  font-size: 20px;
  margin: 0 0 8px;
}

.service-card p {
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
}

.purchase-shell {
  display: grid;
  gap: 18px 24px;
  grid-template-areas:
    "top top"
    "service summary"
    "country summary";
  grid-template-columns: minmax(0, 1fr) 360px;
  margin: 0 auto;
  max-width: 1080px;
}

.purchase-top {
  align-items: center;
  display: flex;
  grid-area: top;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.purchase-top h1 {
  font-size: 36px;
  line-height: 1.2;
  margin: 8px 0 0;
}

.purchase-step {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}

.purchase-shell > .purchase-step:nth-of-type(1) {
  grid-area: service;
}

.purchase-shell > .purchase-step:nth-of-type(2) {
  grid-area: country;
}

.step-title {
  align-items: center;
  display: flex;
  font-size: 18px;
  font-weight: 800;
  justify-content: space-between;
  margin-bottom: 12px;
}

.step-title small {
  background: #eef2ff;
  border-radius: 999px;
  color: #4f46e5;
  font-size: 13px;
  padding: 7px 12px;
}

.selection-list {
  display: grid;
  gap: 10px;
}

.selection-row {
  align-items: center;
  background: #f5f6f8;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  display: grid;
  gap: 12px;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  min-height: 64px;
  padding: 10px 14px;
  text-align: left;
  width: 100%;
}

.country-list {
  max-height: min(620px, calc(100vh - 280px));
  overflow-y: auto;
  padding-right: 4px;
}

.selection-row.is-selected {
  background: #eef2ff;
  border-color: #c7d2fe;
}

.service-mark,
.country-mark {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 50%;
  display: inline-flex;
  font-weight: 800;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.service-mark {
  color: #111827;
}

.country-mark {
  color: var(--primary);
}

.selection-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.selection-main strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selection-main small {
  color: var(--muted);
}

.selection-check {
  color: var(--muted);
  font-size: 30px;
  line-height: 1;
}

.price-tag {
  color: var(--text);
  font-weight: 800;
  white-space: nowrap;
}

.is-hidden {
  display: none;
}

.purchase-summary {
  border-bottom: 0;
  grid-area: summary;
  position: sticky;
  top: 88px;
}

.summary-list {
  gap: 8px;
  margin-bottom: 18px;
}

.summary-list div {
  display: flex;
  justify-content: space-between;
}

.summary-list dt,
.summary-list dd {
  font-size: 15px;
}

.summary-list dd {
  font-weight: 800;
}

.summary-note {
  color: var(--muted);
  line-height: 1.7;
  margin: 0 0 18px;
}

.purchase-actions {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) 52px;
}

.buy-button {
  background: #7457e8;
  border-radius: 999px;
  font-size: 16px;
  min-height: 52px;
}

.buy-button:hover {
  background: #6548db;
}

.favorite-button {
  align-items: center;
  background: #f5f6f8;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  font-size: 30px;
  height: 52px;
  justify-content: center;
  line-height: 1;
  width: 52px;
}

dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

dt {
  color: var(--muted);
}

dd {
  font-weight: 700;
  margin: 0;
  text-align: right;
  word-break: break-word;
}

.order-panel {
  display: grid;
  gap: 24px;
}

.order-main {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.phone-number,
.sms-code {
  display: block;
  font-size: 32px;
  margin-top: 8px;
  word-break: break-word;
}

.sms-code {
  color: var(--success);
}

.status-row,
.actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.status-pill {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
}

.status-WAITING,
.status-UNKNOWN {
  background: #fff7ed;
  color: var(--warning);
}

.status-CODE_RECEIVED,
.status-FINISHED {
  background: #ecfdf5;
  color: var(--success);
}

.status-CANCELLED,
.status-ERROR {
  background: #fef2f2;
  color: var(--danger);
}

.admin-split {
  align-items: center;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 24px;
}

.admin-shortcuts {
  align-items: center;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 24px;
}

.import-callout {
  align-items: center;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 24px;
}

.admin-shortcuts h2 {
  font-size: 22px;
  margin: 6px 0 0;
}

.import-callout h2 {
  font-size: 22px;
  margin: 6px 0;
}

.big-number {
  color: var(--success);
  font-size: 32px;
  font-weight: 700;
  margin: 8px 0;
}

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

.wide-field {
  grid-column: 1 / -1;
}

.checkbox-row {
  align-items: center;
  display: flex;
  flex-direction: row;
  gap: 10px;
}

.checkbox-row input {
  min-height: auto;
  width: auto;
}

.compact-form,
.admin-table-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.compact-form select {
  min-height: 38px;
  width: 120px;
}

.compact-form .secondary-button,
.admin-table-actions .secondary-button,
.admin-table-actions .danger-button {
  min-height: 38px;
  padding: 0 12px;
}

.service-group-list {
  display: grid;
  gap: 14px;
}

.service-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.service-group summary {
  align-items: center;
  background: #f8fafc;
  cursor: pointer;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  list-style: none;
  padding: 16px 18px;
}

.service-group summary::-webkit-details-marker {
  display: none;
}

.service-group summary strong {
  display: block;
  font-size: 18px;
}

.service-group summary small,
.group-meta {
  color: var(--muted);
  font-size: 14px;
}

.service-group .table-wrap {
  border-top: 1px solid var(--line);
}

.service-group-toolbar {
  align-items: center;
  background: #ffffff;
  border-top: 1px solid var(--line);
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  justify-content: space-between;
  padding: 12px 18px;
}

.service-group-toolbar form {
  margin: 0;
}

.service-group-name-form {
  align-items: end;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(180px, 260px) auto;
}

.service-group-name-form label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  gap: 6px;
}

.service-group-name-form input {
  min-height: 38px;
}

.service-group-name-form .secondary-button {
  min-height: 38px;
  padding: 0 12px;
}

.service-group-toolbar .danger-button {
  min-height: 38px;
  padding: 0 12px;
}

.service-group table {
  min-width: 640px;
}

.service-group tbody tr:last-child td {
  border-bottom: 0;
}

.catalog-create-form {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(180px, 1fr) 92px auto;
  min-width: 380px;
}

.catalog-create-form input {
  min-height: 38px;
}

code {
  background: #eef2f7;
  border-radius: 6px;
  padding: 2px 6px;
}

.badge {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
}

.badge-pending {
  background: #fff7ed;
  color: var(--warning);
}

.badge-approved {
  background: #ecfdf5;
  color: var(--success);
}

.badge-disabled {
  background: #fef2f2;
  color: var(--danger);
}

.readiness-list {
  display: grid;
  gap: 12px;
}

.readiness-item {
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  grid-template-columns: 72px 1fr;
  padding: 16px;
}

.readiness-item h3 {
  font-size: 16px;
  margin: 0 0 4px;
}

.readiness-item p {
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

.readiness-ok {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.readiness-warn {
  background: #fffbeb;
  border-color: #fde68a;
}

.readiness-fail {
  background: #fef2f2;
  border-color: #fecaca;
}

.status-badge {
  border-radius: 999px;
  display: inline-flex;
  font-size: 13px;
  font-weight: 700;
  justify-content: center;
  padding: 6px 10px;
}

.status-ok {
  background: #dcfce7;
  color: #166534;
}

.status-warn {
  background: #fef3c7;
  color: #92400e;
}

.status-fail {
  background: #fee2e2;
  color: #991b1b;
}

.readiness-actions {
  display: grid;
  gap: 10px;
}

.readiness-actions code {
  background: #111827;
  border-radius: 8px;
  color: #e5e7eb;
  display: block;
  overflow-x: auto;
  padding: 12px;
}

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

  .auth-layout,
  .stats-grid,
  .service-grid,
  .order-main,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .header-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-split {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-shortcuts {
    align-items: flex-start;
    flex-direction: column;
  }

  .service-group-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .import-callout {
    align-items: flex-start;
    flex-direction: column;
  }

  .readiness-item {
    grid-template-columns: 1fr;
  }

  .purchase-shell {
    grid-template-areas:
      "top"
      "service"
      "country"
      "summary";
    grid-template-columns: 1fr;
    max-width: 680px;
  }

  .purchase-summary {
    position: static;
  }

  .country-list {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .purchase-top {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 540px) {
  .page {
    padding: 24px 14px 40px;
  }

  .auth-copy h1,
  .header-row h1 {
    font-size: 28px;
  }

  .phone-number,
  .sms-code {
    font-size: 26px;
  }
}
