:root {
  --ink: #162034;
  --muted: #667085;
  --line: #e7eaf0;
  --surface: #ffffff;
  --soft: #f6f8fb;
  --green: #53ad68;
  --green-dark: #31894a;
  --blue: #3996ea;
  --vk: #2787f5;
  --danger: #d74848;
  --warning: #b66a12;
  --shadow: 0 18px 55px rgba(24, 39, 75, .09);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(83, 173, 104, .13), transparent 30%),
    radial-gradient(circle at 100% 10%, rgba(57, 150, 234, .11), transparent 25%),
    #f7f8fb;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.5;
}

a { color: inherit; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
code { overflow-wrap: anywhere; }

.page-shell, .admin-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 64px;
}
.narrow-shell { width: min(720px, calc(100% - 28px)); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 58px;
  margin-bottom: 34px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}
.brand-mark {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(145deg, #7fbc47, #54af69);
  font-size: 14px;
  letter-spacing: .04em;
}
.brand-mark.large { width: 64px; height: 64px; font-size: 18px; }
.test-badge, .eyebrow {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.test-badge {
  padding: 7px 11px;
  border: 1px solid rgba(49, 137, 74, .2);
  border-radius: 999px;
  background: rgba(83, 173, 104, .1);
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 14px; font-size: clamp(32px, 5vw, 54px); line-height: 1.06; letter-spacing: -.04em; }
h2 { margin-bottom: 6px; font-size: 22px; line-height: 1.15; }
.lead { color: var(--muted); font-size: 18px; }

.welcome-card, .center-card, .admin-card {
  border: 1px solid rgba(222, 226, 235, .9);
  border-radius: 28px;
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow);
}
.welcome-card { padding: clamp(28px, 7vw, 58px); text-align: center; }
.welcome-card .eyebrow { margin: 0 auto 10px; }
.welcome-card .lead { max-width: 580px; margin: 0 auto 30px; }
.welcome-icon, .success-mark {
  display: grid;
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(145deg, #7fbc47, #4fac63);
  box-shadow: 0 14px 30px rgba(83, 173, 104, .24);
  font-size: 29px;
  font-weight: 800;
}

.email-form, .login-form, .settings-form {
  display: grid;
  gap: 14px;
}
.email-form { max-width: 480px; margin: 0 auto; text-align: left; }
label { color: #404b61; font-size: 14px; font-weight: 700; }
input, select {
  display: block;
  width: 100%;
  height: 52px;
  margin-top: 7px;
  padding: 0 15px;
  border: 1px solid #d6dae3;
  border-radius: 13px;
  outline: none;
  background: #fff;
  color: var(--ink);
}
select { padding: 0 40px 0 15px; }
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(83, 173, 104, .12); }

.primary-button, .secondary-button, .warning-button, .danger-button, .network-button, .quiet-button {
  min-height: 48px;
  padding: 12px 18px;
  border: 0;
  border-radius: 13px;
  cursor: pointer;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}
.primary-button { color: #fff; background: linear-gradient(135deg, #63b870, #409e58); box-shadow: 0 10px 24px rgba(64, 158, 88, .2); }
.secondary-button { color: var(--ink); background: #edf0f5; }
.warning-button { color: #8f4e08; background: #fff0d8; }
.danger-button { color: #b42323; background: #fee7e7; }
.quiet-button { min-height: 40px; padding: 8px 13px; color: var(--muted); background: #eef1f5; }
.inline { display: inline-flex; align-items: center; justify-content: center; width: auto; }
button:disabled { cursor: not-allowed; opacity: .5; }

.test-note, .personal-box, .alert {
  margin-top: 22px;
  padding: 16px 18px;
  border-radius: 15px;
}
.test-note { display: grid; gap: 3px; color: #536073; background: var(--soft); text-align: left; font-size: 14px; }
.test-note strong { color: var(--ink); }
.quiet-link { display: block; width: fit-content; margin: 20px auto 0; color: var(--muted); font-size: 14px; text-underline-offset: 3px; }
.alert { border: 1px solid; }
.alert-error { color: #912929; border-color: #f4c1c1; background: #fff0f0; }
.alert-success { color: #26743a; border-color: #bfe5c8; background: #eefaf1; }

.center-state {
  display: flex;
  min-height: 100vh;
  padding: 36px 22px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
}
.center-state h1 { max-width: 720px; }
.center-state p { max-width: 620px; color: var(--muted); font-size: 17px; }
.state-icon {
  display: grid;
  width: 70px;
  height: 70px;
  margin-bottom: 18px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--vk);
  font-weight: 900;
  font-size: 22px;
}
.state-icon.error { background: var(--danger); }
.state-icon.success { background: var(--green); }
.login-form { width: min(390px, 100%); }

.activation-head { max-width: 760px; margin: 20px auto 30px; text-align: center; }
.activation-head .eyebrow { margin: 0 auto 10px; }
.activation-head h1 { font-size: clamp(34px, 5vw, 52px); }
.activation-head .lead { margin-bottom: 0; }
.order-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 12px 35px rgba(24, 39, 75, .05);
}
.order-strip > div { display: grid; gap: 4px; padding: 18px; border-right: 1px solid var(--line); }
.order-strip > div:last-child { border-right: 0; }
small { color: var(--muted); font-size: 12px; font-weight: 700; }
.order-strip strong { font-size: 14px; }
.countdown-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
  padding: 15px 20px;
  border-radius: 15px;
  color: #285f38;
  background: #eaf8ee;
}
.countdown-card strong { font-size: 22px; font-variant-numeric: tabular-nums; }
.countdown-card.waiting { color: #765514; background: #fff6df; }

.channel-grid, .setup-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.channel-card {
  display: flex;
  min-height: 300px;
  padding: 24px;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 16px 44px rgba(24, 39, 75, .06);
}
.channel-card.connected { border-color: rgba(83, 173, 104, .45); background: #fbfffc; }
.network-heading { display: flex; gap: 13px; align-items: flex-start; }
.network-heading p { margin: 0; color: var(--muted); font-size: 14px; }
.network-icon {
  display: inline-grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  font-weight: 900;
}
.network-icon.telegram { background: linear-gradient(145deg, #54b9f0, #268ed5); }
.network-icon.vk { background: var(--vk); }
.network-button { display: flex; align-items: center; justify-content: center; width: 100%; color: #fff; }
.network-button.telegram { background: linear-gradient(135deg, #45aff0, #278fd3); }
.network-button.vk { background: var(--vk); }
.network-button.disabled { color: #8791a2; background: #e9edf2; }
.connected-box { display: flex; gap: 13px; align-items: center; padding: 16px; border-radius: 15px; background: #eaf8ee; }
.connected-box > span { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; color: #fff; background: var(--green); font-weight: 800; }
.connected-box div { display: grid; }
.connected-box p { margin: 0; color: var(--muted); font-size: 14px; }
.setup-hint, .setup-warning { color: var(--muted); font-size: 13px; }
.setup-warning { color: #8c5a16; }
.personal-box { border: 1px dashed #ccd2dc; background: rgba(255,255,255,.7); }
.personal-box small, .personal-box code, .personal-box p { display: block; }
.personal-box code { margin: 6px 0; color: #40526c; font-size: 12px; }
.personal-box p { margin: 0; color: var(--muted); font-size: 13px; }

.admin-nav { display: flex; gap: 18px; }
.admin-nav a { color: var(--muted); font-size: 14px; }
.admin-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 20px 0 28px; }
.admin-heading h1 { margin-bottom: 8px; }
.admin-heading p { max-width: 720px; margin-bottom: 0; color: var(--muted); }
.admin-heading-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.status-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.status-grid article { display: grid; gap: 5px; min-height: 116px; padding: 18px; border: 1px solid var(--line); border-radius: 17px; background: #fff; }
.status-grid strong { font-size: 17px; }
.status-grid span { color: var(--muted); font-size: 12px; }
.status-active { color: var(--green-dark); }
.status-expired { color: var(--danger); }
.admin-card { margin-bottom: 20px; padding: 24px; border-radius: 22px; }
.admin-card-head { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 20px; }
.admin-card-head h2 { margin: 2px 0 0; }
.status-pill { display: inline-flex; padding: 6px 10px; border-radius: 999px; color: #6a7280; background: #eef1f5; font-size: 12px; font-weight: 800; }
.status-pill.done { color: #28733a; background: #e6f6ea; }
.details-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.details-grid > div { display: grid; gap: 5px; padding: 14px; border-radius: 13px; background: var(--soft); }
.details-grid strong { font-size: 13px; overflow-wrap: anywhere; }
.account-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-top: 16px; }
.account-grid article { display: flex; gap: 13px; padding: 16px; border: 1px solid var(--line); border-radius: 15px; }
.account-grid article > div { display: grid; }
.account-grid p, .account-grid em { margin: 0; color: var(--muted); font-size: 12px; font-style: normal; }
.account-grid em { color: var(--danger); }
.account-note { color: var(--green-dark); font-size: 12px; }
.account-link { width: fit-content; margin-top: 5px; color: #2877c7; font-size: 12px; text-underline-offset: 3px; }
.account-form { margin-top: 9px; }
.account-form .quiet-button { min-height: 36px; padding: 7px 11px; font-size: 12px; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.standalone-actions { margin: 0 0 20px; }
.access-tabs { display: flex; gap: 8px; margin: 0 0 20px; padding: 6px; overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.76); }
.access-tabs a { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 9px 14px; border-radius: 11px; color: var(--muted); font-size: 14px; font-weight: 800; text-decoration: none; white-space: nowrap; }
.access-tabs a.active { color: #26743a; background: #e9f7ed; }
.access-tabs span { display: inline-grid; min-width: 22px; height: 22px; padding: 0 6px; place-items: center; border-radius: 999px; background: rgba(255,255,255,.9); font-size: 11px; }
.compact-card { box-shadow: 0 10px 34px rgba(24, 39, 75, .05); }
.empty-card { padding: 42px 24px; color: var(--muted); text-align: center; }
.empty-card h2 { color: var(--ink); }
.wide-code { display: block; margin-top: 12px; padding: 13px 15px; border-radius: 11px; background: var(--soft); color: #40526c; font-size: 12px; overflow-wrap: anywhere; }
.test-order-form { grid-template-columns: repeat(3, minmax(0, 1fr)) auto; align-items: end; }
.test-order-form .primary-button { min-width: 120px; }
.event-list { display: grid; gap: 8px; }
.event-list > div { display: grid; grid-template-columns: 150px 180px 1fr; gap: 12px; padding: 10px 12px; border-radius: 10px; background: var(--soft); font-size: 12px; }
.event-list code { color: var(--muted); }
.muted { color: var(--muted); }
.setup-shell { max-width: 1080px; }
.setup-grid .admin-card { margin: 0; }
.setup-divider { height: 1px; margin: 22px 0; background: var(--line); }
.settings-form { margin-top: 16px; }
.safety-card { margin-top: 20px; }
.checkbox-label { display: flex; align-items: flex-start; gap: 10px; padding: 13px 14px; border-radius: 13px; background: var(--soft); font-weight: 600; }
.checkbox-label input { width: 18px; height: 18px; margin: 2px 0 0; flex: 0 0 18px; box-shadow: none; }
.safety-results { display: grid; gap: 10px; }
.safety-result { display: flex; align-items: center; gap: 12px; padding: 13px 15px; border-radius: 13px; background: var(--soft); }
.safety-result span { display: inline-grid; width: 28px; height: 28px; flex: 0 0 28px; place-items: center; border-radius: 50%; color: #fff; font-weight: 900; }
.safety-result.ok span { background: var(--green); }
.safety-result.fail span { background: var(--danger); }
.resource-list { display: grid; gap: 9px; }
.resource-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border-radius: 12px; background: var(--soft); }
.resource-row > div:first-child { display: grid; }
.resource-row small { overflow-wrap: anywhere; }
.resource-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.resource-actions form { margin: 0; }
.resource-actions .quiet-button { min-height: 34px; padding: 6px 10px; font-size: 11px; }

@media (max-width: 820px) {
  .page-shell, .admin-shell { width: min(100% - 20px, 680px); padding-top: 12px; }
  .topbar { margin-bottom: 20px; }
  .order-strip, .status-grid, .details-grid { grid-template-columns: repeat(2, 1fr); }
  .order-strip > div:nth-child(2) { border-right: 0; }
  .order-strip > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .channel-grid, .setup-grid, .account-grid { grid-template-columns: 1fr; }
  .test-order-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-heading { align-items: flex-start; flex-direction: column; }
  .admin-heading-actions { justify-content: flex-start; }
}

@media (max-width: 520px) {
  .test-badge { font-size: 10px; }
  .welcome-card { padding: 28px 20px; border-radius: 22px; }
  h1 { font-size: 34px; }
  .lead { font-size: 16px; }
  .order-strip, .status-grid, .details-grid { grid-template-columns: 1fr; }
  .order-strip > div { border-right: 0; border-bottom: 1px solid var(--line); }
  .order-strip > div:last-child { border-bottom: 0; }
  .channel-card, .admin-card { padding: 19px; }
  .countdown-card { align-items: flex-start; flex-direction: column; gap: 3px; }
  .admin-nav { gap: 10px; }
  .admin-nav a { font-size: 12px; }
  .admin-actions { display: grid; }
  .admin-actions form, .admin-actions button { width: 100%; }
  .admin-heading-actions { display: grid; width: 100%; }
  .admin-heading-actions a { width: 100%; }
  .event-list > div { grid-template-columns: 1fr; gap: 2px; }
  .test-order-form { grid-template-columns: 1fr; }
  .access-tabs { margin-left: -2px; margin-right: -2px; }
  .resource-row { align-items: stretch; flex-direction: column; }
  .resource-actions { justify-content: stretch; }
  .resource-actions form, .resource-actions button { width: 100%; }
}
