/* Цвета берутся из темы Telegram: приложение само подстраивается под
   светлую и тёмную тему пользователя. Справа — запасные значения. */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f2f3f5);
  --text: var(--tg-theme-text-color, #111111);
  --muted: var(--tg-theme-hint-color, #8a8f98);
  --accent: var(--tg-theme-button-color, #e30613);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --link: var(--tg-theme-link-color, #2481cc);
  --danger: var(--tg-theme-destructive-text-color, #d93025);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg2); color: var(--text); }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.screen { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--bg);
  border-bottom: 1px solid color-mix(in srgb, var(--muted) 20%, transparent);
}
.brand { font-weight: 700; font-size: 17px; }
.lang-switch {
  border: 1px solid var(--accent); color: var(--accent); background: transparent;
  border-radius: 999px; padding: 4px 12px; font-weight: 600; font-size: 13px;
}
.content { flex: 1; padding: 16px 16px 96px; display: flex; flex-direction: column; gap: 14px; }
h2 { margin: 4px 0; font-size: 20px; }
h3 { margin: 0 0 6px; font-size: 16px; }
.subtitle { margin: 0; color: var(--muted); }

/* Нижнее меню */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 2;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--bg);
  border-top: 1px solid color-mix(in srgb, var(--muted) 20%, transparent);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 11px;
}
.tab.active { color: var(--accent); }
.tab-icon { font-size: 20px; }

/* Карточки программ */
.program-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.program-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  min-height: 128px; padding: 14px; text-align: left;
  background: var(--bg); color: var(--text);
  border: none; border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}
.program-card:active { transform: scale(.98); }
.program-icon { font-size: 28px; }
.program-title { font-weight: 700; font-size: 16px; }
.program-hint { color: var(--muted); font-size: 13px; }

.ad img { width: 100%; display: block; border-radius: var(--radius); }

/* Карточки и списки */
.card { background: var(--bg); border-radius: var(--radius); padding: 14px; }
.card p { margin: 0 0 10px; }
.list { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.excerpt { margin: 8px 0 4px; white-space: pre-wrap; word-break: break-word; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

.status { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.status-sent { background: color-mix(in srgb, var(--muted) 20%, transparent); }
.status-in_work { background: #fff3cd; color: #8a6100; }
.status-on_air { background: #d9f5e1; color: #17703a; }
.status-rejected { background: #fde2e1; color: #a52019; }

/* Форма */
.form { gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-weight: 600; font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; margin: -4px 0 0; }
.section-title { margin-top: 8px; }
input[type=text], input[type=tel], textarea, select {
  width: 100%; padding: 12px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid color-mix(in srgb, var(--muted) 35%, transparent);
  border-radius: 10px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check input { width: 22px; height: 22px; flex: none; margin: 0; accent-color: var(--accent); }

.file-list { display: flex; flex-direction: column; gap: 6px; }
.file-chip {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: var(--bg); padding: 8px 10px; border-radius: 10px; font-size: 13px;
  overflow: hidden; text-overflow: ellipsis;
}
.chip-remove { border: none; background: none; color: var(--danger); font-size: 16px; }

/* Кнопки */
.btn {
  width: 100%; padding: 14px; border: none; border-radius: 12px;
  font: inherit; font-weight: 600; cursor: pointer;
}
.btn:disabled { opacity: .6; }
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.secondary { background: color-mix(in srgb, var(--accent) 12%, var(--bg)); color: var(--accent); }
.btn.small { padding: 10px; font-size: 14px; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--bg); padding: 4px; border-radius: 12px; }
.seg { border: none; background: transparent; padding: 10px; border-radius: 9px; font: inherit; color: var(--text); }
.seg.active { background: var(--accent); color: var(--accent-text); font-weight: 600; }

/* Сообщения */
.error { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--bg)); padding: 10px 12px; border-radius: 10px; }
.warn { color: #8a6100; }
.success { text-align: center; padding: 24px 8px 8px; }
.success-icon { font-size: 56px; }
.success-text { margin: 0; }
.fatal { padding: 48px 24px; text-align: center; color: var(--muted); }

.loader {
  width: 32px; height: 32px; margin: 48px auto;
  border: 3px solid color-mix(in srgb, var(--muted) 30%, transparent);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Панель редакции ---------- */
.row .lang-switch + .lang-switch { margin-left: 6px; }
.lang-switch { text-decoration: none; display: inline-block; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip {
  flex: none; border: none; border-radius: 999px; padding: 7px 14px;
  background: var(--bg); color: var(--text); font: inherit; font-size: 14px;
}
.chip.active { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filters select { padding: 9px; font-size: 14px; }
.feed-card { display: block; color: inherit; text-decoration: none; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: middle; }
.assignee { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--bg2); white-space: nowrap; }
.assignee.me { background: #fff3cd; color: #8a6100; }
.full-text { white-space: pre-wrap; word-break: break-word; font-size: 16px; }
.fact { margin-top: 4px; word-break: break-word; }
.phone { font-weight: 700; font-size: 17px; }
.btn-row { display: flex; gap: 8px; margin-top: 10px; }
.btn-row .btn { flex: 1; text-align: center; text-decoration: none; }
.actions { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.btn.danger { background: color-mix(in srgb, var(--danger) 12%, var(--bg)); color: var(--danger); }
.btn.link { background: none; color: var(--muted); font-weight: 400; font-size: 14px; }
.btn.left { text-align: left; }
.btn.auto { width: auto; flex: none; }
.invite-link { font-family: ui-monospace, monospace; font-size: 12px; word-break: break-all; background: var(--bg2); padding: 8px; border-radius: 8px; }
.card.row { align-items: center; }
