/* ТихOn — личный кабинет закрытого теста и минимальная админка.
   Светлая бумага, мята, чернила; только локальные стили и системные шрифты. */

:root {
  --ink: #163842;
  --ink-soft: #203c48;
  --blue: #245edb;
  --blue-dark: #1b49ad;
  --paper: #f6faf8;
  --mint: #e4f1ec;
  --mint-deep: #cfe6dd;
  --line: #d3e4dd;
  --muted: #526c75;
  --white: #ffffff;
  --orange: #b4551f;
  --red: #a63a2a;
  --red-soft: #fbeae6;
  --amber-soft: #fdf1dd;
  --amber-ink: #8a4b12;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(22, 56, 66, 0.08);
  --wrap: 1080px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-width: 0;
  background:
    radial-gradient(900px 480px at 88% -10%, rgba(207, 230, 221, 0.75), transparent 70%),
    var(--paper);
  color: var(--ink);
  font-family: Manrope, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; }
a { color: var(--blue); }
p { margin: 0 0 12px; }

a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 3px;
  border-radius: 6px;
}

.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 20;
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 700;
}
.skip:focus { top: 12px; }

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 24px;
}

/* Шапка */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 0 6px;
  flex-wrap: wrap;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  font-size: 24px;
  letter-spacing: -0.03em;
}
.brand img { width: 38px; height: 44px; object-fit: contain; flex: none; }
.brand small {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-left: 2px;
}
.top-badge {
  border: 1px solid var(--mint-deep);
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}
.top-link,
.linkish {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  padding: 9px 12px;
  border-radius: 10px;
  cursor: pointer;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
}
.top-link:hover,
.linkish:hover { background: var(--mint); }
.linkish[disabled] { opacity: 0.6; cursor: default; }

main { padding: 22px 0 40px; }

/* Первый экран входа */
.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 34px;
  align-items: start;
  padding: 18px 0 10px;
}
.eyebrow {
  margin: 0 0 12px;
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #2f6f61;
}
h1 {
  margin: 0 0 16px;
  font-size: clamp(32px, 4.6vw, 52px);
  line-height: 1.06;
  letter-spacing: -0.04em;
  font-weight: 800;
  overflow-wrap: anywhere;
}
h2 {
  margin: 0 0 10px;
  font-size: clamp(22px, 2.6vw, 28px);
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 800;
}
h3 {
  margin: 0 0 6px;
  font-size: 17px;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.lead {
  color: var(--muted);
  font-size: clamp(16px, 1.6vw, 18px);
  max-width: 56ch;
}
.chips {
  list-style: none;
  margin: 20px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chips li {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}
.steps {
  list-style: none;
  counter-reset: step;
  margin: 26px 0 0;
  padding: 0;
  display: grid;
  gap: 12px;
}
.steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.55;
}
.steps li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--mint);
  border: 1px solid var(--mint-deep);
  color: var(--ink);
  font-weight: 800;
  font-size: 14px;
}
.steps b { color: var(--ink); display: block; }

.intro-side { display: grid; gap: 14px; justify-items: center; }
.intro-art {
  width: min(190px, 60%);
  filter: drop-shadow(0 18px 24px rgba(22, 56, 66, 0.12));
}
.intro-art img { display: block; width: 100%; }

/* Карточки */
.card {
  width: 100%;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 6px);
  box-shadow: var(--shadow);
  padding: clamp(20px, 4vw, 32px);
}
.card + .card { margin-top: 16px; }
.card-title { margin-bottom: 6px; }
.sub { margin: 0 0 16px; color: var(--muted); font-size: 15px; }

/* Кнопки */
.btn {
  appearance: none;
  border: 1.5px solid transparent;
  border-radius: 13px;
  min-height: 50px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 800;
  font-size: 15.5px;
  line-height: 1.25;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  text-decoration: none;
  max-width: 100%;
  overflow-wrap: anywhere;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.btn:active:not([disabled]) { transform: translateY(1px); }
.btn[disabled] { opacity: 0.65; cursor: default; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not([disabled]) { background: var(--blue-dark); }
.btn-secondary {
  background: var(--white);
  color: var(--ink);
  border-color: #b9d2c9;
}
.btn-secondary:hover:not([disabled]) { border-color: var(--blue); background: #f7faff; }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: transparent; }
.btn-ghost:hover:not([disabled]) { background: var(--mint); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not([disabled]) { background: #8c2f22; }
.btn-danger-outline {
  background: var(--white);
  color: var(--red);
  border-color: #e2b8ae;
}
.btn-danger-outline:hover:not([disabled]) { background: var(--red-soft); }
.btn-small { min-height: 40px; padding: 8px 13px; font-size: 13.5px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }

/* Ожидание Telegram */
.pending {
  border: 1px solid var(--mint-deep);
  background: var(--mint);
  border-radius: 14px;
  padding: 16px;
  margin-top: 16px;
}
.pending[hidden] { display: none; }
.code-label {
  display: block;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.code {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(21px, 6vw, 30px);
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--ink);
  overflow-wrap: anywhere;
  margin-bottom: 12px;
}
.tg-link {
  display: inline-block;
  font-weight: 800;
  overflow-wrap: anywhere;
  margin-bottom: 8px;
}
.poll-line {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  color: var(--ink-soft);
  margin: 4px 0 0;
  flex-wrap: wrap;
}
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #2f6f61;
  flex: none;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) {
  .dot { animation: none; }
  .btn { transition: none; }
}

/* Сообщения */
.alert {
  border-radius: 13px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.55;
  margin: 14px 0 0;
  border: 1px solid transparent;
}
.alert-error { background: var(--red-soft); border-color: #ecc7be; color: #7c2e22; }
.alert-info { background: var(--mint); border-color: var(--mint-deep); color: var(--ink-soft); }
.alert-warn { background: var(--amber-soft); border-color: #efd7b0; color: var(--amber-ink); }
.muted { color: var(--muted); font-size: 13.5px; }
.small-note { color: var(--muted); font-size: 12.5px; line-height: 1.55; margin: 12px 0 0; }

/* Кабинет */
.account-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.account-head h1 { font-size: clamp(28px, 4vw, 40px); margin-bottom: 6px; }
.account-head .btn-row { margin-top: 0; gap: 8px; }
.account-head .btn-row .btn { min-height: 44px; padding: 9px 14px; font-size: 14px; }
.identity { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.status-card { margin-top: 4px; }
.status-top {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12.5px;
  font-weight: 800;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-mint { background: var(--mint); border-color: var(--mint-deep); color: #245c4f; }
.badge-blue { background: #e8f0ff; border-color: #c9dbfb; color: #1b49ad; }
.badge-warn { background: var(--amber-soft); border-color: #efd7b0; color: var(--amber-ink); }
.badge-red { background: var(--red-soft); border-color: #ecc7be; color: #7c2e22; }
.badge-grey { background: #eef2f1; border-color: #dbe5e2; color: #4b6169; }
.status-desc { color: var(--ink-soft); font-size: 15px; margin: 0 0 4px; max-width: 70ch; }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 18px 0 0;
}
.detail {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 13px;
  background: #fbfdfc;
  min-width: 0;
}
.detail dt {
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 2px;
}
.detail dd {
  margin: 0;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.access-box { margin-top: 18px; }
.access-box .btn { margin-top: 2px; }

.loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 26px 0;
  color: var(--muted);
  font-weight: 700;
}
.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid var(--mint-deep);
  border-top-color: var(--blue);
  animation: spin 0.9s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

.page-title { margin: 8px 0 4px; }
.page-sub { color: var(--muted); font-size: 15px; margin: 0 0 18px; max-width: 75ch; }

/* Счётчики админки */
.counts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 10px;
  margin: 0 0 18px;
}
.count {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 12px 14px;
  min-width: 0;
}
.count b { display: block; font-size: 26px; line-height: 1.1; letter-spacing: -0.03em; }
.count span { display: block; font-size: 12px; color: var(--muted); font-weight: 700; margin-top: 2px; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.toolbar h2 { margin: 0; font-size: 21px; }
.updated { color: var(--muted); font-size: 12.5px; }

/* Таблица */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 720px;
}
table.data th,
table.data td {
  text-align: left;
  padding: 11px 10px;
  border-bottom: 1px solid #e4eeea;
  vertical-align: top;
  overflow-wrap: anywhere;
}
table.data th {
  font-size: 11.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
  border-bottom-color: var(--line);
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr.is-updated { background: #f1f8f4; }
.cell-name { font-weight: 800; color: var(--ink); }
.cell-sub { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.cell-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
}
.cell-actions { min-width: 148px; }
.cell-actions .btn + .btn { margin-top: 6px; }
.cell-actions .btn { width: 100%; }
.row-empty { color: var(--muted); font-size: 14px; padding: 18px 10px; }

.audit-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.audit-list li {
  display: grid;
  grid-template-columns: minmax(130px, auto) minmax(0, 1fr);
  gap: 4px 14px;
  padding: 9px 0;
  border-bottom: 1px solid #e4eeea;
  font-size: 13px;
}
.audit-list li:last-child { border-bottom: 0; }
.audit-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.audit-main { min-width: 0; overflow-wrap: anywhere; }
.audit-main b { font-weight: 800; }

/* Модальное подтверждение */
dialog.confirm {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0;
  width: min(440px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  box-shadow: 0 30px 80px rgba(22, 56, 66, 0.24);
  color: var(--ink);
  background: var(--white);
}
dialog.confirm::backdrop { background: rgba(22, 56, 66, 0.42); }
.confirm-inner { padding: 24px; }
.confirm-inner h2 { font-size: 21px; }
.confirm-inner p { color: var(--muted); font-size: 14.5px; }
.confirm-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.confirm-actions .btn { flex: 1 1 140px; }

.toast {
  margin: 0 0 14px;
  font-size: 13.5px;
  color: #245c4f;
  font-weight: 700;
}

/* Подвал */
footer {
  border-top: 1px solid var(--line);
  margin-top: 26px;
  padding: 20px 0 34px;
  color: var(--muted);
  font-size: 12.5px;
}
footer p { margin: 0 0 6px; }
footer a { color: var(--muted); }
.foot-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--ink-soft);
  font-size: 13px;
  margin-bottom: 6px;
}

/* Адаптив */
@media (max-width: 820px) {
  .intro { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .intro-side { justify-items: stretch; }
  .intro-art { justify-self: center; width: min(150px, 45%); }
  .top-badge { display: none; }
}

@media (max-width: 760px) {
  .wrap { padding: 0 16px; }
  body { font-size: 16px; }
  main { padding-top: 14px; }
  .brand { font-size: 22px; }
  .brand img { width: 33px; height: 38px; }
  .top { padding-top: 14px; }
  .account-head .btn-row { width: 100%; justify-content: flex-start; }
  .top-actions { gap: 2px; }
  .top-link, .linkish { padding: 8px 9px; font-size: 13px; }

  table.data { min-width: 0; display: block; }
  table.data thead { display: none; }
  table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data tr {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 10px 12px;
    margin-bottom: 10px;
    background: #fbfdfc;
  }
  table.data tbody tr:last-child { margin-bottom: 0; }
  table.data td {
    border: 0;
    padding: 5px 0;
    display: grid;
    grid-template-columns: minmax(96px, 38%) minmax(0, 1fr);
    gap: 10px;
    align-items: baseline;
  }
  table.data td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }
  table.data td.cell-actions { display: block; padding-top: 8px; }
  table.data td.cell-actions::before { display: block; margin-bottom: 6px; }
  .cell-actions .btn { width: auto; min-width: 132px; }
  .cell-actions .btn + .btn { margin-top: 0; margin-left: 6px; }
  .row-empty { display: block !important; }
  .row-empty::before { display: none !important; }
  .audit-list li { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 390px) {
  .wrap { padding: 0 13px; }
  .card { padding: 18px 15px; border-radius: 18px; }
  h1 { font-size: 29px; }
  .btn { font-size: 14.5px; padding-left: 12px; padding-right: 12px; }
  .card .btn-row .btn { width: 100%; }
  .account-head .btn-row .btn { width: auto; }
  .counts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .top-actions .top-link:first-child { display: none; }
  table.data td { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .cell-actions .btn { width: 100%; min-width: 0; }
  .cell-actions .btn + .btn { margin-left: 0; margin-top: 6px; }
}
