:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1d2330;
  --muted: #6b7280;
  --line: #e2e5ea;
  --accent: #1f6feb;
  --ok-bg: #e7f6ec;
  --ok-text: #14532d;
  --err-bg: #fdecec;
  --err-text: #8a1c1c;
  --wa: #118241;  /* білий текст на ньому — контраст 4.9:1 (норма від 4.5) */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }

.wrap { max-width: 1000px; margin: 0 auto; padding: 0 16px; }

.top { background: var(--card); border-bottom: 1px solid var(--line); }
.top-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; min-height: 56px; }
.brand { font-weight: 700; }
.menu { display: flex; flex-wrap: wrap; gap: 4px 16px; flex: 1; }
.menu a { text-decoration: none; }
.me { color: var(--muted); font-size: 14px; }

main.wrap { padding-top: 8px; padding-bottom: 48px; }
h1 { font-size: 24px; margin: 20px 0 8px; }
h2 { font-size: 18px; margin: 28px 0 8px; }
.headline { font-size: 18px; font-weight: 600; margin: 0 0 16px; }
.hint, .small { color: var(--muted); font-size: 14px; }

.flash { margin: 12px 0 0; padding: 10px 14px; border-radius: 8px; background: var(--ok-bg); color: var(--ok-text); }
.flash-error { background: var(--err-bg); color: var(--err-text); }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tfoot th { color: var(--text); border-top: 1px solid var(--line); border-bottom: none; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

/* Канал і його посилання — один tbody: рядок чисел, під ним посилання на всю ширину */
table.grouped td { border-bottom: none; }
table.grouped tbody { border-top: 1px solid var(--line); }
.link-row td { padding-top: 0; }

/* Посилання для копіювання: видно повністю, переноситься, клік виділяє його цілком */
code.link { display: inline-block; max-width: 100%; padding: 2px 6px; border-radius: 4px; background: var(--bg);
  font: 14px/1.5 ui-monospace, Consolas, monospace; word-break: break-all; user-select: all; }

/* Картки замість таблиць каналів — лише на телефоні (див. @media нижче) */
.cards { display: none; list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.cards li { display: grid; justify-items: start; gap: 6px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.cards li:last-child { border-bottom: none; }
.card-name { font-weight: 600; }
.nums span { white-space: nowrap; }

.form { display: flex; flex-direction: column; gap: 12px; max-width: 560px; }
.form.narrow { max-width: 360px; }
.form h2 { margin: 16px 0 0; }
.form p { margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: end; }
.form.row, .row { flex-direction: row; flex-wrap: wrap; align-items: flex-end; display: flex; gap: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
input, select, textarea, button { font: inherit; }
input, select, textarea { padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--text); }
textarea { resize: vertical; }

button { padding: 9px 16px; border: none; border-radius: 6px; background: var(--accent); color: #fff; cursor: pointer; align-self: flex-start; }
button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); padding: 6px 12px; }
form.inline { display: flex; gap: 8px; align-items: center; margin: 0; }

/* Преленд — єдина публічна сторінка, насамперед для телефона */
body.preland { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 16px; }
.preland-box { width: 100%; max-width: 480px; background: var(--card); border-radius: 16px; padding: 28px 22px; text-align: center; box-shadow: 0 6px 24px rgba(0, 0, 0, .06); }
.preland-box h1 { font-size: 26px; line-height: 1.25; margin: 0 0 14px; }
.preland-box p { margin: 0 0 12px; font-size: 17px; }
.wa-button { display: block; margin-top: 22px; padding: 16px; border-radius: 12px; background: var(--wa); color: #fff; font-size: 18px; font-weight: 700; text-decoration: none; }
.wa-button:active { opacity: .85; }

@media (max-width: 600px) {
  h1 { font-size: 21px; }
  .headline { font-size: 16px; }
  .top-row { padding-top: 10px; padding-bottom: 10px; }
  .brand { flex: 1; }
  .menu { order: 3; flex-basis: 100%; }
  .form.row, .row { flex-direction: column; align-items: stretch; }
  .desktop { display: none; }
  .cards { display: block; }
}
