:root {
  --bg-a: #f3f7ff;
  --bg-b: #fef7ee;
  --card: #ffffff;
  --line: #dce6f5;
  --text: #1b2a42;
  --muted: #5f6f86;
  --primary: #0f62fe;
  --danger: #c5283d;
  --ok: #1f8a4c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background: linear-gradient(145deg, var(--bg-a), var(--bg-b));
}

.background {
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle at 15% 20%, rgba(15, 98, 254, 0.08), transparent 30%),
    radial-gradient(circle at 85% 80%, rgba(241, 136, 29, 0.09), transparent 30%);
  pointer-events: none;
}

.container {
  position: relative;
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 16px 56px;
}

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

h1,
h2,
h3 {
  margin: 0;
}

h2 {
  margin-bottom: 10px;
}

.pill {
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 6px 12px;
  font-size: 12px;
  color: var(--muted);
  background: #fff;
}

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
}

.card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  padding: 16px;
  box-shadow: 0 7px 30px rgba(20, 39, 72, 0.06);
}

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

.row + .row {
  margin-top: 8px;
}

form {
  margin: 0;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

input,
button,
select,
textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  font-size: 14px;
  background: #fff;
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  margin-right: 6px;
}

input:focus,
textarea:focus {
  outline: 2px solid rgba(15, 98, 254, 0.22);
  outline-offset: 0;
}

button {
  cursor: pointer;
  border: 0;
  background: var(--primary);
  color: white;
  font-weight: 600;
}

button.secondary {
  background: #eef3ff;
  color: #204386;
  border: 1px solid #d4e3ff;
}

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

button.slim {
  width: auto;
  padding: 8px 12px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.flash {
  border-radius: 10px;
  margin-bottom: 12px;
  padding: 10px 12px;
  font-weight: 600;
}

.flash.success {
  color: #0f5f34;
  background: #e8f8ef;
  border: 1px solid #b6e7c7;
}

.flash.error {
  color: #7e1a28;
  background: #fdecef;
  border: 1px solid #f5b7c0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

.inline-form {
  display: inline;
}

.auth-box {
  max-width: 420px;
  margin: 80px auto 0;
}

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

.auth-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.link-btn {
  display: inline-block;
  text-decoration: none;
  border-radius: 10px;
  border: 1px solid #d4e3ff;
  background: #eef3ff;
  color: #204386;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
}

.status-ok {
  color: var(--ok);
  font-weight: 700;
}

.status-off {
  color: var(--danger);
  font-weight: 700;
}

.telegram-collapse {
  padding: 0;
}

.telegram-collapse summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
  font-weight: 700;
}

.telegram-collapse summary::-webkit-details-marker {
  display: none;
}

.telegram-collapse summary::after {
  content: "▾";
  margin-left: auto;
  color: var(--muted);
}

.telegram-collapse:not([open]) summary {
  border-radius: 14px;
}

.telegram-collapse[open] summary {
  border-bottom: 1px solid var(--line);
}

.telegram-collapse[open] summary::after {
  content: "▴";
}

.telegram-collapse-body {
  padding: 16px;
}

.instruction-block {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fbff;
  padding: 12px;
}

.instruction-list {
  margin: 0;
  padding-left: 20px;
  line-height: 1.5;
}

.instruction-list li + li {
  margin-top: 6px;
}

.instruction-video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.instruction-video-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 10px;
}

.instruction-video-card video {
  display: block;
  width: 100%;
  max-height: 360px;
  border-radius: 8px;
  background: #000;
}

.instruction-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.instruction-image-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 10px;
}

.instruction-image-card img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid #e6eef9;
}

.max-link-step-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid #f0dcc0;
  border-radius: 8px;
  background: #fffef9;
  padding: 9px 10px;
  margin-bottom: 8px;
}

.max-link-action-row {
  margin: 2px 0 8px;
}

.step-badge-ok {
  border-radius: 999px;
  background: #e8f8ef;
  border: 1px solid #b6e7c7;
  color: #0f5f34;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  white-space: nowrap;
}

.step-badge-wait {
  border-radius: 999px;
  background: #fff;
  border: 1px solid #f1b84b;
  color: #8a5a0a;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  white-space: nowrap;
}

.max-link-command-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.max-link-highlight {
  border-color: #f1b84b;
  background: #fff7e5;
}

.max-link-code {
  color: #8b1e2d;
  font-size: 18px;
  font-weight: 800;
  background: #fff;
  border: 1px dashed #f1b84b;
  padding: 2px 8px;
  border-radius: 8px;
}

.max-link-command {
  color: #0f3f88;
  font-size: 15px;
  font-weight: 700;
  background: #eef3ff;
  border: 1px solid #cddcff;
  padding: 2px 8px;
  border-radius: 8px;
}

.instruction-details {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.instruction-details summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--text);
  list-style: none;
}

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

.instruction-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.instruction-toggle-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 112px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #d7dce8;
  background: #f4f6fb;
  color: #2a3c59;
  font-size: 12px;
  font-weight: 700;
}

.instruction-details[open] .instruction-toggle-label::before {
  content: "Свернуть";
}

.instruction-details:not([open]) .instruction-toggle-label::before {
  content: "Развернуть";
}

.instruction-details summary::marker {
  color: var(--muted);
}

.bot-highlight {
  border: 2px solid #d12d3f;
  border-radius: 12px;
  background: #fff1f3;
  padding: 10px 12px;
  color: #7e1a28;
  font-size: 16px;
  line-height: 1.4;
}

.bot-name {
  color: #b3122a;
}

.bot-handle {
  color: #b3122a;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

@media (max-width: 720px) {
  .container {
    padding: 16px 12px 40px;
  }

  th,
  td {
    padding: 8px 4px;
    font-size: 12px;
  }
}
