:root {
  color-scheme: light;
  --page: #f4f7f8;
  --panel: #ffffff;
  --line: #dfe7e4;
  --text: #17211f;
  --muted: #66736f;
  --green: #0b8d68;
  --green-dark: #056047;
  --blue: #2e66d4;
  --red: #c84a3f;
  --amber: #b87412;
  --shadow: 0 18px 46px rgba(22, 35, 38, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  background: var(--page);
  color: var(--text);
  margin: 0;
}

button {
  border: 0;
  cursor: pointer;
  font: inherit;
}

input,
textarea,
select {
  background: #fff;
  border: 1px solid #cfdad6;
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  min-height: 48px;
  outline: none;
  padding: 11px 13px;
  width: 100%;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(11, 141, 104, 0.14);
}

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

button svg {
  height: 18px;
  width: 18px;
}

.app-shell {
  min-height: 100vh;
  padding: 18px;
}

.app-shell--centered {
  align-items: center;
  display: flex;
  justify-content: center;
  padding: 28px 18px 72px;
}

.app-shell--centered .tool {
  width: min(100%, 1160px);
}

.tool {
  display: grid;
  gap: 16px;
  margin: 0 auto;
  max-width: 1160px;
}

.support-link {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 999px;
  bottom: 18px;
  box-shadow: 0 10px 24px rgba(22, 35, 38, 0.1);
  color: #52615d;
  font-size: 13px;
  font-weight: 800;
  padding: 8px 12px;
  position: fixed;
  right: 18px;
  text-decoration: none;
  z-index: 20;
}

.support-link:hover,
.support-link:focus-visible {
  color: var(--blue);
}

.toast-message {
  background: rgba(23, 33, 31, 0.94);
  border-radius: 999px;
  bottom: 68px;
  box-shadow: 0 14px 32px rgba(22, 35, 38, 0.18);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  left: 50%;
  max-width: min(520px, calc(100vw - 28px));
  opacity: 0;
  padding: 10px 14px;
  pointer-events: none;
  position: fixed;
  text-align: center;
  transform: translate(-50%, 8px);
  transition: opacity 0.16s ease, transform 0.16s ease;
  z-index: 40;
}

.toast-message.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-height: 620px) {
  .app-shell--centered {
    align-items: flex-start;
  }
}

.topbar,
.panel,
.hero-panel,
.log-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  background: #edf7f2;
  border: 1px solid var(--line);
  border-radius: 8px;
  height: 48px;
  object-fit: contain;
  padding: 7px;
  width: 48px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.18;
}

h2 {
  font-size: 26px;
  line-height: 1.2;
}

.brand p,
.hero-panel p {
  color: var(--muted);
  font-size: 14px;
  margin-top: 5px;
}

.status-pill,
.small-badge {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  font-size: 13px;
  font-weight: 800;
  gap: 7px;
  min-height: 32px;
  padding: 6px 11px;
  white-space: nowrap;
}

.status-pill,
.small-badge.idle {
  background: #edf2f4;
  color: #46535a;
}

.status-pill.ok,
.small-badge.ok {
  background: #e8f8f1;
  color: var(--green-dark);
}

.status-pill.error {
  background: #fff0ee;
  color: var(--red);
}

.small-badge.error {
  background: #fff0ee;
  color: var(--red);
}

.small-badge.wait {
  background: #fff5e4;
  color: var(--amber);
}

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

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

.summary-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 26px rgba(22, 35, 38, 0.06);
  min-height: 86px;
  padding: 14px;
}

.summary-card span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 800;
}

.summary-card strong {
  display: block;
  font-size: 24px;
  line-height: 1.2;
  margin-top: 8px;
}

.hero-panel {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.key-row {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) 150px;
}

.step-label {
  background: #eef8f3;
  border-radius: 999px;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 900;
  justify-self: start;
  padding: 6px 11px;
}

.big-button {
  align-items: center;
  background: var(--green);
  border-radius: 8px;
  color: #fff;
  display: inline-flex;
  font-size: 22px;
  font-weight: 900;
  gap: 10px;
  justify-content: center;
  min-height: 68px;
  padding: 16px 20px;
  width: 100%;
}

.big-button.compact {
  font-size: 17px;
  min-height: 48px;
}

.big-button:hover,
.secondary-button:hover,
.success-button:hover,
.danger-button:hover,
.icon-text-button:hover,
.circle-action:hover,
.sms-help-button:hover {
  transform: translateY(-1px);
}

.order-strip {
  align-items: center;
  background: #eef3fb;
  border: 1px solid #dfe7f1;
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 96px;
  padding: 12px;
}

.phone-capsule {
  align-items: center;
  background: #fff;
  border-radius: 8px;
  display: flex;
  flex: 1 1 285px;
  gap: 10px;
  min-height: 68px;
  min-width: 0;
  padding: 10px 12px;
}

.order-service-mark {
  background: #f8fbfa;
  border: 1px solid var(--line);
  border-radius: 8px;
  height: 38px;
  object-fit: contain;
  padding: 5px;
  width: 38px;
}

.country-chip {
  align-items: center;
  background: #0b5cc9;
  border-radius: 6px;
  color: #fff;
  display: inline-flex;
  font-size: 12px;
  font-weight: 950;
  height: 28px;
  justify-content: center;
  width: 38px;
}

.phone-capsule strong {
  display: block;
  flex: 1 1 auto;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 26px;
  line-height: 1.2;
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: nowrap;
}

.order-timer {
  color: #07131f;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 22px;
  font-weight: 900;
  flex: 0 0 58px;
  text-align: center;
}

.sms-status {
  align-items: center;
  background: #fff;
  border: 1px solid rgba(23, 33, 31, 0.48);
  border-radius: 8px;
  color: #1f2927;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 15px;
  font-weight: 850;
  gap: 8px;
  justify-content: center;
  min-height: 46px;
  padding: 8px 12px;
  white-space: nowrap;
}

.sms-status.has-code {
  border-color: #bfe8d5;
  color: var(--green-dark);
}

.status-dot {
  background: #5d6569;
  border-radius: 999px;
  height: 12px;
  width: 12px;
}

.sms-status.has-code .status-dot {
  background: var(--green);
}

.sms-code {
  align-items: center;
  color: #07131f;
  display: flex;
  flex: 1 1 205px;
  font-size: 16px;
  font-weight: 850;
  gap: 8px;
  min-height: 50px;
  min-width: 0;
  white-space: nowrap;
}

.sms-code span {
  flex: 0 0 auto;
  line-height: 1;
}

.sms-code strong {
  align-items: center;
  color: var(--green-dark);
  display: inline-flex;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 19px;
  line-height: 1;
  min-height: 44px;
  overflow-wrap: anywhere;
}

.sms-code strong:empty {
  display: none;
}

.sms-code .code-copy-action {
  flex: 0 0 44px;
  margin-left: 0;
}

.phone-hint {
  color: var(--green-dark);
  display: block;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
  margin-top: -4px;
}

.circle-action {
  align-items: center;
  background: #e2e9f6;
  border-radius: 999px;
  color: #8fa0c2;
  display: inline-flex;
  flex: 0 0 50px;
  height: 50px;
  justify-content: center;
  position: relative;
  transition: transform 0.14s ease, background 0.14s ease, color 0.14s ease;
  width: 50px;
}

.circle-action svg {
  height: 26px;
  width: 26px;
}

.circle-action:not(:disabled):not(.is-locked) {
  background: #edf3ff;
  color: var(--blue);
}

.circle-action.copy-action {
  background: #eef3ff;
  color: #7257d9;
  height: 44px;
  margin-left: auto;
  width: 44px;
}

.circle-action.copy-action svg {
  height: 22px;
  width: 22px;
}

.circle-action.is-locked {
  cursor: help;
}

.circle-action.is-locked:hover::after,
.circle-action.is-locked:focus-visible::after,
.sms-help-button[data-tooltip]:hover::after,
.sms-help-button[data-tooltip]:focus-visible::after {
  background: #fff;
  border: 1px solid #d5dce7;
  border-radius: 7px;
  box-shadow: 0 2px 7px rgba(22, 35, 38, 0.16);
  color: #1f2927;
  content: attr(data-tooltip);
  font-size: 14px;
  font-weight: 500;
  left: 50%;
  line-height: 1.2;
  padding: 8px 10px;
  position: absolute;
  top: -52px;
  transform: translateX(-50%);
  white-space: nowrap;
  z-index: 10;
}

.sms-help-button {
  align-items: center;
  background: #e1e8f5;
  border-radius: 999px;
  color: #93a2bf;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 14px;
  font-weight: 950;
  justify-content: center;
  min-height: 46px;
  padding: 10px 15px;
  position: relative;
  white-space: nowrap;
}

.sms-help-button[data-tooltip]:hover::after,
.sms-help-button[data-tooltip]:focus-visible::after {
  left: auto;
  right: 0;
  transform: none;
}

.sms-help-button:not(:disabled) {
  background: #edf3ff;
  color: var(--blue);
}

.cancel-hint {
  display: none;
}

.order-complete-button {
  justify-self: end;
  min-width: 150px;
}

.notice-hint {
  background: #fff9e8;
  border: 1px solid #efdcae;
  border-radius: 8px;
  color: #8b681c;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
  margin: -4px 0 0;
  padding: 10px 12px;
}

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

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

.action-row.admin-actions {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.secondary-button,
.success-button,
.danger-button,
.icon-text-button {
  align-items: center;
  border-radius: 8px;
  display: inline-flex;
  font-weight: 900;
  gap: 8px;
  justify-content: center;
  min-height: 46px;
  padding: 10px 13px;
}

.secondary-button {
  background: #edf3ff;
  color: var(--blue);
}

.success-button {
  background: #e8f8f1;
  color: var(--green-dark);
}

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

.icon-text-button {
  background: #edf3ff;
  color: var(--blue);
  min-width: 96px;
}

.panel-heading {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-heading h2 {
  font-size: 16px;
}

.panel-note {
  color: var(--muted);
  font-size: 13px;
  margin-top: 5px;
}

.admin-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.plain-link {
  color: var(--blue);
  font-weight: 900;
  text-decoration: none;
}

.admin-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(190px, 1.2fr) 150px minmax(170px, 1fr) 120px 150px;
  margin-bottom: 14px;
}

.admin-filter-row {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(180px, 1fr) repeat(5, minmax(130px, 160px));
  margin-bottom: 12px;
}

.admin-pagination {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  font-weight: 800;
  gap: 8px;
  justify-content: flex-end;
  margin: -2px 0 12px;
}

.page-button {
  min-height: 34px;
  padding: 8px 12px;
}

.page-button svg {
  height: 16px;
  width: 16px;
}

.admin-card-list-panel {
  order: 2;
}

.stock-admin-panel {
  display: grid;
  gap: 10px;
  order: 3;
  padding: 14px;
}

.api-compact-bar {
  align-items: end;
  background: #f8fbfa;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px 10px;
  grid-template-columns: 170px minmax(240px, 340px) minmax(220px, 1fr) auto;
  margin-top: 12px;
  padding: 9px 10px;
}

.api-compact-bar[hidden] {
  display: none;
}

.api-compact-title span {
  color: var(--ink);
  display: block;
  font-size: 13px;
  font-weight: 900;
}

.api-compact-title small,
.api-compact-status small {
  color: var(--muted);
  display: block;
  font-size: 12px;
  line-height: 1.35;
  margin-top: 3px;
}

.api-mode-field {
  margin: 0;
}

.api-compact-status {
  align-self: center;
  min-width: 0;
}

.api-compact-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.api-compact-actions button {
  min-height: 34px;
  padding: 7px 10px;
}

.stock-admin-panel .panel-heading {
  margin-bottom: 0;
}

.stock-admin-panel .panel-note {
  display: none;
}

.stock-summary-grid,
.stock-rule-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stock-metric {
  background: #f8fbfa;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 74px;
  padding: 10px 11px;
}

.stock-metric span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 900;
}

.stock-metric strong {
  display: block;
  font-size: 18px;
  line-height: 1.2;
  margin-top: 5px;
  overflow-wrap: anywhere;
}

.stock-metric small,
.stock-status-line {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.stock-metric small {
  display: block;
  margin-top: 4px;
}

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

.stock-actions button {
  min-height: 38px;
  padding: 8px 11px;
}

.stock-status-line {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.stock-notice {
  background: #fff9e8;
  border: 1px solid #efdcae;
  border-radius: 8px;
  color: #8b681c;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
  padding: 10px 12px;
}

.stock-notice.ok {
  background: #e8f8f1;
  border-color: #bfe8d5;
  color: var(--green-dark);
}

.stock-notice.error {
  background: #fff0ee;
  border-color: #ffd0ca;
  color: var(--red);
}

.stock-log-details {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.stock-log-details summary {
  color: var(--blue);
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
  list-style-position: inside;
}

.stock-log {
  background: #111918;
  border: 0;
  border-radius: 8px;
  color: #d9f4eb;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
  margin: 8px 0 0;
  max-height: 150px;
  min-height: 72px;
  overflow: auto;
  padding: 12px;
  white-space: pre-wrap;
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}

.empty-table {
  align-items: center;
  color: var(--muted);
  display: flex;
  justify-content: center;
  min-height: 160px;
  padding: 18px;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
}

th {
  background: #f5f8f7;
  color: var(--muted);
  font-size: 12px;
}

.select-cell {
  text-align: center;
  width: 42px;
}

.select-cell input {
  height: 18px;
  width: 18px;
}

td code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-weight: 800;
}

.table-type {
  background: #edf3ff;
  border-radius: 999px;
  color: var(--blue);
  display: inline-flex;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  padding: 7px 9px;
}

.table-status {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  padding: 7px 9px;
}

.table-status.ok {
  background: #e8f8f1;
  color: var(--green-dark);
}

.table-status.wait {
  background: #fff5e4;
  color: var(--amber);
}

.table-status.error {
  background: #fff0ee;
  color: var(--red);
}

.table-status.idle {
  background: #edf2f4;
  color: #46535a;
}

.table-delete-button {
  background: #fff0ee;
  border-radius: 8px;
  color: var(--red);
  font-size: 12px;
  font-weight: 900;
  min-height: 32px;
  padding: 7px 10px;
  white-space: nowrap;
}

.activity-log {
  background: #111918;
  border-radius: 8px;
  color: #d9f4eb;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
  max-height: 220px;
  min-height: 150px;
  overflow: auto;
  padding: 12px;
}

.log-entry {
  border-bottom: 1px solid rgba(217, 244, 235, 0.12);
  padding: 7px 0;
  white-space: pre-wrap;
}

.log-entry:first-child {
  padding-top: 0;
}

.log-entry:last-child {
  border-bottom: 0;
}

@media (max-width: 760px) {
  .app-shell {
    padding: 10px;
  }

  .app-shell--centered {
    padding: 14px 10px 62px;
  }

  .support-link {
    bottom: 10px;
    left: 10px;
    right: 10px;
    text-align: center;
  }

  .toast-message {
    bottom: 56px;
  }

  .topbar {
    align-items: stretch;
    display: grid;
  }

  .panel-heading {
    align-items: stretch;
    display: grid;
  }

  .admin-stats {
    justify-content: flex-start;
  }

  h1 {
    font-size: 21px;
  }

  h2 {
    font-size: 23px;
  }

  .summary-grid,
  .summary-grid.three,
  .action-row,
  .action-row.two,
  .action-row.admin-actions,
  .api-compact-bar,
  .stock-summary-grid,
  .stock-rule-grid,
  .stock-actions,
  .admin-grid,
  .admin-filter-row,
  .key-row {
    grid-template-columns: 1fr;
  }

  .summary-card {
    min-height: 74px;
  }

  .order-strip {
    min-height: 0;
  }

  .phone-capsule {
    flex-basis: 100%;
  }

  .phone-capsule strong {
    font-size: 22px;
    white-space: normal;
  }

  .sms-code,
  .sms-help-button {
    flex-basis: 100%;
  }

  .circle-action {
    justify-self: center;
  }

  .admin-pagination {
    justify-content: flex-start;
  }

  .icon-text-button {
    width: 100%;
  }
}
