:root, html[data-theme="dark"] {
  --bg: #000000;
  --bg-elevated: #1c1c1e;
  --surface: #1c1c1e;
  --surface-2: #2c2c2e;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .14);
  --text: #f5f5f7;
  --muted: #a1a1a6;
  --accent: #0a84ff;
  --accent-dark: #003166;
  --danger: #ff453a;
  --success: #30d158;
  --warning: #ffd60a;
  --shadow: 0 8px 30px rgba(0, 0, 0, .35);
  --desc: #ebebf5;
  --placeholder: #636366;
  --table-cell: #141416;
  --radius: 28px;
  --radius-sm: 20px;
  --radius-xs: 14px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Helvetica, Arial, sans-serif;
}

html[data-theme="light"] {
  --bg: #f5f5f7;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-2: #f2f2f7;
  --line: rgba(0, 0, 0, .08);
  --line-strong: rgba(0, 0, 0, .12);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --accent: #007aff;
  --accent-dark: #e8f1ff;
  --danger: #ff3b30;
  --success: #34c759;
  --warning: #ff9f0a;
  --shadow: 0 8px 24px rgba(0, 0, 0, .06);
  --desc: #1d1d1f;
  --placeholder: #8e8e93;
  --table-cell: #fafafa;
}

:root {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
*, *::before, *::after { box-sizing: border-box; }
html {
  min-width: 320px;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--bg);
  transition: background-color .45s var(--ease), color .45s var(--ease);
}
body {
  margin: 0;
  min-height: 100vh;
  min-height: var(--tg-vh, 100dvh);
  max-width: 100vw;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  transition: background-color .45s var(--ease), color .45s var(--ease);
}
body:not(.desktop-only) {
  padding-left: max(0px, var(--tg-safe-left, 0px));
  padding-right: max(0px, var(--tg-safe-right, 0px));
}
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.app-shell, .admin-shell {
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
  max-width: 100%;
  overflow-x: hidden;
}
body:not(.desktop-only) .app-shell {
  width: min(1120px, calc(100% - clamp(16px, 4vw, 48px)));
  min-height: var(--tg-vh, 100dvh);
  padding-top: max(0px, var(--tg-safe-top, env(safe-area-inset-top, 0px)));
  padding-bottom: max(12px, var(--tg-safe-bottom, env(safe-area-inset-bottom, 0px)));
}
body.desktop-only .admin-shell {
  width: min(1860px, calc(100% - 48px));
  max-width: 1920px;
  min-width: 1280px;
  padding: 8px 0 48px;
}
body.desktop-only {
  min-width: 1280px;
  overflow-x: auto;
}
body.desktop-only .panel-card,
body.desktop-only .stat-cell,
body.desktop-only .table-wrap,
body.desktop-only .panel-tabs,
body.desktop-only .alert-item,
body.desktop-only .event-row,
body.desktop-only .notice,
body.desktop-only .login-panel,
body.desktop-only .setup-card {
  border-radius: var(--radius) !important;
}
body.desktop-only input:not([type="checkbox"]):not([type="radio"]),
body.desktop-only select,
body.desktop-only .source-title-input {
  border-radius: 999px !important;
}
body.desktop-only .panel-tab {
  border-radius: 999px !important;
}
body.desktop-only .button,
body.desktop-only .button-compact,
body.desktop-only .bots-add-form .button-compact,
body.desktop-only .table-button {
  border-radius: 999px !important;
}
body.desktop-only .scrape-mini,
body.desktop-only .icon-button {
  border-radius: 50% !important;
}
body.desktop-only table {
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border-radius: var(--radius);
}
body.desktop-only th:first-child { border-top-left-radius: var(--radius); }
body.desktop-only th:last-child { border-top-right-radius: var(--radius); }
body.desktop-only tr:last-child td:first-child { border-bottom-left-radius: var(--radius); }
body.desktop-only tr:last-child td:last-child { border-bottom-right-radius: var(--radius); }
.topbar, .admin-header {
  min-height: 82px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  transition: border-color .45s var(--ease);
  min-width: 0;
}
.miniapp .topbar-sticky {
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: 56px;
  padding: 8px 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.fullscreen-toggle .fs-exit { display: none; }
.fullscreen-toggle.is-active .fs-enter { display: none; }
.fullscreen-toggle.is-active .fs-exit { display: inline; }
.feed-layout {
  display: grid;
  gap: 14px;
  margin-top: 8px;
}
.feed-main { min-width: 0; }
.brand-lockup {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
  flex: 1 1 auto;
}
.brand-lockup > div { min-width: 0; overflow: hidden; }
.brand-lockup strong {
  display: block;
  font-size: 16px;
  letter-spacing: .02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-lockup span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color .45s var(--ease);
}
.brand-logo {
  width: 40px; height: 40px; object-fit: cover;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  transition: border-color .45s var(--ease), transform .35s cubic-bezier(.34, 1.56, .64, 1);
}
.brand-home {
  cursor: pointer;
  user-select: none;
}
.brand-home:hover .brand-logo {
  transform: translateY(-5px) scale(1.06);
}
.brand-home:active .brand-logo {
  transform: translateY(-1px) scale(1.02);
}
/* Mini App logos/avatars are decorative — no hover jump, no click preview */
body:not(.desktop-only) .brand-logo,
body:not(.desktop-only) .offer-avatar {
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 0 0 auto;
  min-width: 0;
}
.last-updated {
  color: var(--muted);
  font-size: 12px;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.intro-row, .admin-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  min-width: 0;
}
.intro-row > div:first-child { min-width: 0; flex: 1 1 auto; }
h1 {
  font-size: clamp(22px, 6vw, 42px);
  letter-spacing: 0;
  line-height: 1.1;
  margin-bottom: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.user-chip {
  color: var(--accent);
  border: 1px solid var(--line-strong);
  padding: 8px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  max-width: min(160px, 42vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 0 0 auto;
}
.content { padding: 52px 0 80px; }
.eyebrow {
  color: var(--accent);
  font-size: 10px;
  letter-spacing: .18em;
  font-weight: 700;
  margin: 0 0 10px;
  transition: color .45s var(--ease);
}
h1, h2, p { margin-top: 0; }
h2 { font-size: 18px; line-height: 1.25; letter-spacing: 0; }
.muted, .field-note { color: var(--muted); line-height: 1.6; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 28px 0 18px;
  background: transparent;
  border: 0;
}
.stat-cell {
  background: var(--surface);
  padding: 18px 20px;
  min-height: 85px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: background-color .45s var(--ease), border-color .45s var(--ease), transform .25s var(--ease), box-shadow .45s var(--ease);
}
.stat-cell:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.stat-cell span { color: var(--muted); display: block; font-size: 12px; transition: color .45s var(--ease); }
.stat-cell strong { display: block; font-size: 25px; margin-top: 8px; }

.filters {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) 110px 110px 170px 150px auto;
  gap: 8px;
  padding: 12px 0 26px;
  border-bottom: 1px solid var(--line);
}

input:not([type="checkbox"]):not([type="radio"]),
select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  min-height: 44px;
  padding: 0 14px;
  outline: none;
  border-radius: var(--radius-sm);
  transition: background-color .45s var(--ease), border-color .25s var(--ease), color .45s var(--ease), box-shadow .25s var(--ease);
}
input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
input::placeholder, textarea::placeholder {
  color: var(--placeholder);
  opacity: 1;
}

.button, .icon-button {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  background: var(--surface-2);
  min-height: 44px;
  padding: 0 18px;
  text-decoration: none;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  font-weight: 650;
  font-size: 13px;
  transition:
    background-color .45s var(--ease),
    border-color .45s var(--ease),
    color .45s var(--ease),
    transform .28s cubic-bezier(.22, 1, .36, 1),
    box-shadow .45s var(--ease),
    filter .35s var(--ease);
}
.button:hover, .icon-button:hover {
  border-color: var(--accent);
  transform: translateY(-1px) scale(1.01);
  box-shadow: 0 10px 24px rgba(10,132,255,.10);
}
.button:active, .icon-button:active { transform: translateY(0); }
.button-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
html[data-theme="light"] .button-primary { color: #fff; }
.button-primary:hover { filter: brightness(1.08); }
.button-quiet { background: transparent; color: var(--muted); }
.button-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.button-primary .btn-icon,
.button-with-icon .btn-icon {
  filter: brightness(0) invert(1);
  opacity: .95;
}
.icon-button { width: 44px; padding: 0; font-size: 20px; border-radius: 50%; position: relative; }

.theme-toggle .theme-icon {
  position: absolute;
  inset: 10px;
  display: block;
  background-color: var(--text);
  transition: opacity .35s var(--ease), transform .35s var(--ease), background-color .45s var(--ease);
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  mask-size: contain;
}
.theme-icon-moon {
  -webkit-mask-image: url("/static/icons/moon.png");
  mask-image: url("/static/icons/moon.png");
}
.theme-icon-sun {
  -webkit-mask-image: url("/static/icons/sun.png");
  mask-image: url("/static/icons/sun.png");
}
html[data-theme="dark"] .theme-icon-moon { opacity: 1; transform: scale(1) rotate(0deg); }
html[data-theme="dark"] .theme-icon-sun { opacity: 0; transform: scale(.6) rotate(-40deg); }
html[data-theme="light"] .theme-icon-moon { opacity: 0; transform: scale(.6) rotate(40deg); }
html[data-theme="light"] .theme-icon-sun { opacity: 1; transform: scale(1) rotate(0deg); }

.field-hint {
  margin: -6px 0 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  transition: color .3s var(--ease);
}
.field-hint.ok { color: var(--success); }
.field-hint.bad { color: var(--danger); }

.strength-meter {
  display: grid;
  gap: 8px;
  margin-top: -4px;
}
.strength-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  overflow: hidden;
}
.strength-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--danger);
  transition: width .35s var(--ease), background-color .35s var(--ease);
}
.strength-fill[data-score="1"] { background: #e35d5d; }
.strength-fill[data-score="2"] { background: var(--warning); }
.strength-fill[data-score="3"] { background: #7bc96f; }
.strength-fill[data-score="4"] { background: var(--success); }
.strength-label {
  font-size: 12px;
  color: var(--muted);
  transition: color .3s var(--ease);
}
.strength-label[data-score="3"],
.strength-label[data-score="4"] { color: var(--success); }
.strength-label[data-score="1"] { color: var(--danger); }

.anim-rise {
  animation: panel-in .5s var(--ease) both;
}

#dashboard-view .panel-card {
  animation: panel-in .55s var(--ease) both;
}
#dashboard-view .panel-card:nth-child(1) { animation-delay: .02s; }
#dashboard-view .panel-card:nth-child(2) { animation-delay: .06s; }
#dashboard-view .panel-card:nth-child(3) { animation-delay: .1s; }
#dashboard-view .stat-cell {
  animation: panel-in .45s var(--ease) both;
}
#dashboard-view .stat-cell:nth-child(1) { animation-delay: .04s; }
#dashboard-view .stat-cell:nth-child(2) { animation-delay: .08s; }
#dashboard-view .stat-cell:nth-child(3) { animation-delay: .12s; }
#dashboard-view .stat-cell:nth-child(4) { animation-delay: .16s; }

.button, .icon-button, .stat-cell, .panel-card, .alert-item, .offer-card {
  will-change: transform;
}

input:not([type="checkbox"]):not([type="radio"]):invalid:not(:placeholder-shown) {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--line));
}


.notice {
  border-left: 3px solid var(--accent);
  background: var(--accent-dark);
  color: var(--text);
  padding: 13px 16px;
  margin: 18px 0;
  font-size: 13px;
  border-radius: var(--radius-sm);
  transition: background-color .45s var(--ease), color .45s var(--ease);
}
.notice.error {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 16%, transparent);
}

.offers-list { display: grid; gap: 10px; padding-top: 18px; }
.offer-card {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 22px;
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  transition: background-color .45s var(--ease), border-color .3s var(--ease), box-shadow .45s var(--ease);
}
.offer-card:hover { border-color: var(--line-strong); }
.offer-source { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.offer-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: var(--surface-2); border: 1px solid var(--line); }
.source-type, .offer-category { color: var(--accent); border-left: 1px solid var(--line-strong); padding-left: 9px; }
.offer-age { margin-left: auto; white-space: nowrap; }
.offer-main { padding: 18px 0 14px; max-width: 920px; min-width: 0; }
.offer-title {
  margin-bottom: 9px;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.offer-description, .description-full {
  color: var(--desc);
  line-height: 1.55;
  font-size: 14px;
  margin-bottom: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  transition: color .45s var(--ease);
}
.offer-description { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.offer-description.is-full {
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
}
.offer-card:has(.description-details[open]) .offer-description { display: none; }
.description-details { margin-top: 10px; color: var(--muted); font-size: 12px; }
.description-details[hidden] { display: none !important; }
.description-details summary { cursor: pointer; color: var(--accent); list-style: none; }
.description-details summary::-webkit-details-marker { display: none; }
.description-full { margin-top: 10px; white-space: pre-wrap; }
.offer-footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; border-top: 1px solid var(--line); padding-top: 15px; }
.offer-price { color: var(--success); font-size: 15px; }
.empty-state { text-align: center; padding: 80px 20px; color: var(--muted); }
.empty-state h2 { color: var(--text); }
.empty-icon { color: var(--accent); font-size: 34px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.setup-page { display: grid; place-items: center; padding: 30px 20px; }
.setup-shell, .login-panel, .setup-card { width: min(520px, 100%); }
.setup-mark { margin-bottom: 28px; }
.setup-mark img { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; border: 1px solid var(--line-strong); }
.form-stack { display: grid; gap: 14px; margin-top: 28px; }
.form-stack label { display: grid; gap: 7px; color: var(--text); font-size: 13px; font-weight: 600; }
.form-message { min-height: 20px; color: var(--muted); font-size: 13px; margin: 0; }
.form-message.error { color: var(--danger); }
.form-message.success { color: var(--success); }

.admin-shell { padding-bottom: 70px; }
.admin-header { margin-bottom: 40px; }
.admin-toolbar { align-items: center; }
.admin-section { margin-top: 28px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: 15px; gap: 12px; }
.section-heading h2 { margin-bottom: 0; }
.inline-form { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 160px; }
.source-form .checkbox-inline {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  color: #8e8e93;
  font-size: 13px;
  font-weight: 400;
  line-height: 1;
  white-space: nowrap;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  height: auto !important;
  min-height: 0 !important;
  width: auto !important;
  background: transparent !important;
  cursor: pointer;
  user-select: none;
  flex: 0 0 auto !important;
}
.source-form .checkbox-inline:hover {
  color: var(--text);
}
.source-form .checkbox-inline:has(input:checked) {
  color: var(--text);
}
.source-form .checkbox-inline span {
  color: inherit;
}
.source-form .checkbox-inline input[type="checkbox"] {
  appearance: none !important;
  -webkit-appearance: none !important;
  box-sizing: border-box !important;
  width: 16px !important;
  height: 16px !important;
  min-width: 16px !important;
  max-width: 16px !important;
  min-height: 16px !important;
  max-height: 16px !important;
  margin: 0 !important;
  padding: 0 !important;
  flex: 0 0 16px !important;
  border: 1.5px solid #636366 !important;
  border-radius: 6px !important;
  background: #1c1c1e !important;
  display: grid !important;
  place-content: center !important;
  cursor: pointer;
  box-shadow: none !important;
  transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
.source-form .checkbox-inline input[type="checkbox"]::before {
  content: "" !important;
  width: 9px !important;
  height: 9px !important;
  transform: scale(0);
  transition: transform .12s var(--ease);
  transform-origin: center;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0, 43% 62%);
  background-color: #fff !important;
}
html[data-theme="light"] .source-form .checkbox-inline input[type="checkbox"] {
  background: #fff !important;
  border-color: #c7c7cc !important;
}
html[data-theme="light"] .source-form .checkbox-inline input[type="checkbox"]::before {
  background-color: #fff !important;
}
.source-form .checkbox-inline input[type="checkbox"]:checked {
  background: #2c2c2e !important;
  border-color: #2c2c2e !important;
}
html[data-theme="light"] .source-form .checkbox-inline input[type="checkbox"]:checked {
  background: #1d1d1f !important;
  border-color: #1d1d1f !important;
}
.source-form .checkbox-inline input[type="checkbox"]:checked::before {
  transform: scale(1);
}
.source-form .checkbox-inline input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent) !important;
}

.bots-add-form {
  display: grid;
  grid-template-columns: 1fr 1.4fr 1.4fr auto;
  gap: 12px 14px;
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  align-items: end;
}
.bots-add-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.bots-add-form .button-compact {
  align-self: end;
  margin-bottom: 1px;
  min-height: 40px !important;
  height: 40px;
  padding: 0 16px !important;
  font-size: 13px !important;
  border-radius: 10px !important;
  color: #fff !important;
}
.button-compact {
  min-height: 32px !important;
  height: 32px;
  padding: 0 14px !important;
  font-size: 13px !important;
  border-radius: 980px !important;
}

.scrape-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.scrape-mini {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.scrape-mini img {
  width: 15px;
  height: 15px;
  filter: brightness(0) invert(1);
  opacity: .9;
}
html[data-theme="light"] .scrape-mini img {
  filter: none;
  opacity: .75;
}

.site-auth-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 24px;
}
.site-auth-modal[hidden] { display: none !important; }
.site-auth-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(8px);
}
.site-auth-window {
  position: relative;
  width: min(560px, 100%);
  max-height: min(86vh, 760px);
  overflow: auto;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .35);
  padding: 18px 18px 20px;
}
.site-auth-window-wide {
  width: min(720px, 100%);
}
.site-auth-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}
.site-auth-field {
  display: grid;
  gap: 6px;
  font-size: .82rem;
  color: var(--muted);
}
.site-auth-field span { font-weight: 600; }
.site-auth-field input,
.site-auth-field select {
  min-height: 40px;
  width: 100%;
}
.site-auth-field.is-required {
  color: var(--text);
}
.site-auth-field.is-required input,
.site-auth-field.is-required select {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(10, 132, 255, .25);
}
.site-auth-field.is-missing input,
.site-auth-field.is-missing select {
  border-color: #ff453a;
}
.site-auth-req {
  margin: 0 0 6px;
  font-size: .92rem;
  line-height: 1.4;
}
@media (max-width: 720px) {
  .site-auth-grid { grid-template-columns: 1fr; }
}
.site-auth-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.site-auth-header h2 {
  margin: 0;
  font-size: 1.15rem;
}
.site-auth-sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.35;
}
.site-auth-block {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 12px;
}
.site-auth-block h3 {
  margin: 0 0 10px;
  font-size: .95rem;
}
.site-auth-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.site-auth-row input,
.site-auth-row select {
  flex: 1 1 140px;
  min-height: 40px;
}
.site-auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.site-auth-hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: .85rem;
}
.site-auth-current {
  margin: 0 0 8px;
  font-size: .92rem;
}
.site-auth-queue {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.site-auth-queue li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid transparent;
  font-size: .9rem;
  cursor: pointer;
  transition: border-color .2s var(--ease), transform .2s var(--ease);
}
.site-auth-queue li:hover {
  border-color: rgba(10, 132, 255, .35);
}
.site-auth-queue li.is-current {
  border-color: var(--accent);
}
.site-auth-queue .ok { color: #34c759; }
.site-auth-queue .wait { color: var(--muted); }
.site-auth-log {
  margin: 10px 0 0;
  padding: 10px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .78rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 160px;
  overflow: auto;
}

.stat-icon {
  display: inline-block;
  vertical-align: -2px;
  margin-right: 4px;
  opacity: .7;
  filter: brightness(0) invert(1);
}
html[data-theme="light"] .stat-icon {
  filter: none;
  opacity: .55;
}

/* Apple-like Mini App filters */
.filter-sheet {
  margin: 0;
  padding: 14px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  display: grid;
  gap: 12px;
  box-shadow: var(--shadow);
  align-self: start;
}
.filter-header {
  display: flex;
  gap: 8px;
  align-items: center;
}
.filter-header .filter-search { flex: 1; min-width: 0; }
.filter-toggle-btn {
  width: 40px;
  min-height: 40px;
  flex: 0 0 40px;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.filter-toggle-icon {
  display: inline-block;
  transition: transform .3s var(--ease);
}
.filter-sheet.is-collapsed .filter-toggle-icon {
  transform: rotate(-90deg);
}
.filter-body {
  display: grid;
  gap: 12px;
  overflow: hidden;
  max-height: 600px;
  opacity: 1;
  transform-origin: top center;
  transform: translateY(0) scaleY(1);
  transition:
    max-height .48s cubic-bezier(.22, 1, .36, 1),
    opacity .32s var(--ease),
    margin .32s var(--ease),
    transform .42s cubic-bezier(.22, 1, .36, 1);
}
.filter-sheet.is-collapsed .filter-body {
  max-height: 0;
  opacity: 0;
  margin: 0;
  transform: translateY(-6px) scaleY(.96);
  pointer-events: none;
}
.seg-flag { font-size: 16px; vertical-align: -1px; margin-right: 2px; }
.filter-search input,
.filter-row input {
  width: 100%;
  border: 0;
  background: var(--surface-2);
  border-radius: 12px;
  min-height: 40px;
  padding: 0 14px;
  color: var(--text);
}
.filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.segmented {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-2);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  max-width: 100%;
}
.segmented::-webkit-scrollbar { display: none; }
.seg {
  border: 0;
  background: transparent;
  color: var(--muted);
  min-height: 32px;
  padding: 0 12px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  flex: 0 0 auto;
  white-space: nowrap;
  transition:
    background-color .45s var(--ease),
    color .45s var(--ease),
    transform .28s cubic-bezier(.22, 1, .36, 1),
    box-shadow .45s var(--ease),
    opacity .35s var(--ease);
}
.seg:hover { color: var(--text); }
.seg.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 6px 18px rgba(0,0,0,.10), inset 0 1px 0 rgba(255,255,255,.04);
}
.seg-region {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.seg-flag {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border-radius: 50%;
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.12),
    0 1px 3px rgba(0,0,0,.16);
}
.seg-flag-ru {
  background:
    linear-gradient(to bottom,
      #ffffff 0 33.333%,
      #1f6fff 33.333% 66.666%,
      #ef3d3d 66.666% 100%);
}
.seg-flag-eu {
  background:
    radial-gradient(circle at 50% 18%, #f6d34f 0 7%, transparent 8%),
    radial-gradient(circle at 68% 24%, #f6d34f 0 6%, transparent 7%),
    radial-gradient(circle at 78% 40%, #f6d34f 0 6%, transparent 7%),
    radial-gradient(circle at 78% 60%, #f6d34f 0 6%, transparent 7%),
    radial-gradient(circle at 68% 76%, #f6d34f 0 6%, transparent 7%),
    radial-gradient(circle at 50% 82%, #f6d34f 0 7%, transparent 8%),
    radial-gradient(circle at 32% 76%, #f6d34f 0 6%, transparent 7%),
    radial-gradient(circle at 22% 60%, #f6d34f 0 6%, transparent 7%),
    radial-gradient(circle at 22% 40%, #f6d34f 0 6%, transparent 7%),
    radial-gradient(circle at 32% 24%, #f6d34f 0 6%, transparent 7%),
    #1d4ed8;
}
.filter-reset { justify-self: start; }
.intro-sub { margin: 8px 0 0; font-size: 15px; }
.offer-card {
  border-radius: 18px !important;
  transition:
    transform .42s cubic-bezier(.22, 1, .36, 1),
    box-shadow .45s var(--ease),
    border-color .45s var(--ease),
    background-color .45s var(--ease);
}
.offer-card:hover {
  transform: translateY(-3px) scale(1.003);
  box-shadow: 0 18px 42px rgba(0,0,0,.22);
}
.section-heading .eyebrow { display: none; }
.section-heading h2 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
#tab-title {
  font-size: 28px !important;
  font-weight: 650 !important;
  letter-spacing: -0.03em !important;
}
.panel-tabs {
  background: var(--surface-2);
  border-radius: 14px;
  padding: 4px;
  gap: 2px;
}
.panel-tab {
  border-radius: 10px !important;
  font-weight: 550;
}
.settings-form { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.settings-form-wide { grid-template-columns: 1fr 1fr 1fr; }
.settings-form label { display: grid; gap: 6px; color: var(--text); font-size: 12px; font-weight: 600; }
.settings-session { grid-column: 1 / -1; }
.settings-block-words {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
  margin-top: 4px;
  padding-top: 4px;
}
.block-words-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.block-words-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.settings-save {
  min-height: 32px !important;
  padding: 0 14px !important;
  font-size: 12px !important;
  font-weight: 600;
}
.block-words-add {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.block-words-add input {
  width: 100%;
  min-height: 40px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 14px;
}
.block-word-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 36px;
}
.block-word-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0;
  max-width: 100%;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  transition: border-color .2s var(--ease), background-color .2s var(--ease), padding .2s var(--ease);
}
.block-word-chip.is-custom {
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
  background: color-mix(in srgb, var(--accent) 10%, var(--surface-2));
}
.block-word-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}
.block-word-remove {
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%) scale(.85);
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--danger) 18%, transparent);
  color: var(--danger);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s var(--ease), transform .18s var(--ease), background-color .18s var(--ease);
}
.block-word-chip.is-custom:hover {
  padding-left: 28px;
}
.block-word-chip.is-custom:hover .block-word-remove {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) scale(1);
}
.block-word-remove:hover {
  background: color-mix(in srgb, var(--danger) 32%, transparent);
}

.panel-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  transition: background-color .45s var(--ease), border-color .45s var(--ease), box-shadow .45s var(--ease);
  animation: panel-in .45s var(--ease) both;
}
.panel-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 8px;
}
.panel-grid-2 .admin-section { margin-top: 0; }

.stats-detail { display: grid; gap: 10px; }
.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--table-cell);
  transition: background-color .45s var(--ease), border-color .45s var(--ease);
}
.stat-row span { color: var(--muted); font-size: 13px; }
.stat-row strong { font-size: 14px; }

.alerts-list, .alerts-stack { display: grid; gap: 10px; }
.alert-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--table-cell);
  font-size: 13px;
  line-height: 1.45;
  transition: background-color .45s var(--ease), border-color .45s var(--ease), transform .25s var(--ease);
}
.alert-item:hover { transform: translateY(-1px); }
.alert-item.warn { border-color: color-mix(in srgb, var(--warning) 45%, var(--line)); }
.alert-item.danger { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.alert-item .alert-meta { color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.alert-empty { color: var(--muted); font-size: 13px; padding: 8px 0; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color .45s var(--ease);
}
.sources-table-wrap {
  max-height: min(62vh, 640px);
  overflow: auto;
}
table { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 720px; }
th, td { text-align: left; padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: top; transition: background-color .45s var(--ease), color .45s var(--ease), border-color .45s var(--ease); }
th { color: var(--text); font-weight: 650; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td { color: var(--desc); background: var(--table-cell); }
td small, td small a { color: var(--muted); }
.source-title-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.source-title-input {
  flex: 1;
  min-width: 160px;
  min-height: 36px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.sources-count {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.85em;
}
.table-button { min-height: 30px; padding: 0 12px; font-size: 11px; border-radius: 999px; }
.status-ok { color: var(--success); }
.status-error { color: var(--danger); max-width: 280px; }

.events-list, .log-journal {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  max-height: 420px;
  overflow: auto;
  transition: border-color .45s var(--ease);
}
.event-row {
  display: grid;
  grid-template-columns: 160px 130px 1fr;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  transition: background-color .25s var(--ease);
}
.event-row:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.event-row:last-child { border-bottom: 0; }
.event-time, .event-type { color: var(--muted); }
.event-user {
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}
.event-row.is-error .event-type { color: var(--danger); }

.login-panel { margin: 10vh auto 0; }
.setup-card { margin: 6vh auto 0; }
[hidden] { display: none !important; }

.panel-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 18px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
}
.panel-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  min-height: 40px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 650;
  font-size: 13px;
  transition: background-color .3s var(--ease), color .3s var(--ease), border-color .3s var(--ease), transform .2s var(--ease);
}
.panel-tab img {
  width: 18px;
  height: 18px;
  opacity: .85;
  filter: none;
}
html[data-theme="dark"] .panel-tab img { filter: invert(1) brightness(1.15); }
.panel-tab:hover {
  color: var(--text);
  border-color: var(--line);
  background: var(--surface-2);
}
.panel-tab.is-active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}
html[data-theme="light"] .panel-tab.is-active { color: #fff; }
.panel-tab.is-active img { opacity: 1; filter: brightness(0) invert(1); }
html[data-theme="dark"] .panel-tab.is-active img { filter: brightness(0) invert(1); }
html[data-theme="light"] .panel-tab.is-active img { filter: brightness(0) invert(1); }

.tab-panels { position: relative; }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }
.tab-panel-in { animation: tab-fade .35s var(--ease) both; }
.btn-icon {
  width: 16px;
  height: 16px;
  filter: none;
}
html[data-theme="dark"] .button-primary .btn-icon { filter: brightness(0) invert(1); }
html[data-theme="light"] .button-primary .btn-icon { filter: brightness(0) invert(1); }

@keyframes tab-fade {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.split-parent {
  overflow: hidden;
  display: inline-block;
  will-change: transform, opacity;
}
.split-char {
  display: inline-block;
  will-change: transform, opacity;
}
.shuffle-parent {
  display: inline-block;
  white-space: nowrap;
  will-change: transform;
  line-height: 1.15;
  visibility: hidden;
}
.shuffle-parent.is-ready { visibility: visible; }
.shuffle-char-wrapper {
  display: inline-block;
  overflow: hidden;
  vertical-align: baseline;
  position: relative;
}
.shuffle-char {
  line-height: 1.15;
  display: inline-block;
  text-align: center;
}
.lang-toggle {
  min-width: 48px;
  font-weight: 700;
  letter-spacing: .04em;
}
#tab-title {
  font-size: inherit;
  font-family: inherit;
  font-weight: inherit;
  text-transform: none;
  letter-spacing: inherit;
}

@media (max-width: 900px) {
  body:not(.desktop-only) .filters { grid-template-columns: 1fr 1fr; }
  body:not(.desktop-only) .search-field { grid-column: 1 / -1; }
  body:not(.desktop-only) .panel-grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 959px) {
  .miniapp .app-shell {
    width: min(100% - 16px, 720px);
  }
  .miniapp .content {
    padding-top: 12px;
    padding-bottom: max(28px, var(--tg-safe-bottom, 12px));
  }
  .miniapp .intro-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }
  .miniapp h1 { font-size: clamp(22px, 6.5vw, 30px); }
  .miniapp .brand-tagline,
  .miniapp .last-updated { display: none; }
  .miniapp .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 14px;
  }
  .miniapp .stat-cell { padding: 12px 14px; min-height: 68px; }
  .miniapp .stat-cell strong { font-size: 20px; }
  .miniapp .feed-layout { grid-template-columns: 1fr; gap: 12px; }
  .miniapp .filter-sheet { border-radius: 16px; padding: 10px; }
  .miniapp .segmented {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .miniapp .segmented::-webkit-scrollbar { display: none; }
  .miniapp .offers-list { grid-template-columns: 1fr; gap: 10px; padding-top: 4px; }
  .miniapp .offer-card { padding: 14px; border-radius: 20px; }
  .miniapp .offer-footer {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }
  .miniapp .offer-link {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }
  .miniapp .offer-age { margin-left: 0; width: 100%; }
  .miniapp .icon-button { width: 40px; min-height: 40px; }
  .miniapp .lang-toggle { min-width: 44px; min-height: 40px; padding: 0 10px; }
  .miniapp .filter-toggle-btn { display: inline-flex; }
}
@media (max-width: 420px) {
  .miniapp .app-shell { width: calc(100% - 12px); }
  .miniapp .stats-grid { gap: 6px; }
  .miniapp .stat-cell { padding: 12px; min-height: 64px; border-radius: 18px; }
  .miniapp .stat-cell strong { font-size: 18px; }
  .miniapp .brand-logo { width: 34px; height: 34px; }
  .miniapp .top-actions { gap: 6px; }
  .miniapp .filter-row { grid-template-columns: 1fr; }
}
@media (min-width: 960px) {
  .miniapp .app-shell {
    width: min(1280px, calc(100% - 48px));
  }
  .miniapp.is-fullscreen .app-shell {
    width: min(1600px, calc(100% - 32px));
  }
  .miniapp .content {
    padding-top: 28px;
    padding-bottom: 64px;
  }
  .miniapp .feed-layout {
    grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
  }
  .miniapp .filter-sheet {
    position: sticky;
    top: calc(64px + var(--tg-safe-top, 0px));
    max-height: calc(var(--tg-vh, 100dvh) - 88px);
    overflow: auto;
    padding: 16px;
  }
  .miniapp .filter-toggle-btn { display: none; }
  .miniapp .filter-sheet.is-collapsed .filter-body { display: grid; }
  .miniapp .offers-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    padding-top: 0;
  }
  .miniapp .offer-card { padding: 20px 22px; }
  .miniapp .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
  }
  .miniapp .fullscreen-toggle { display: inline-flex; }
}
@media (min-width: 1400px) {
  .miniapp .app-shell { width: min(1440px, calc(100% - 64px)); }
  .miniapp.is-fullscreen .app-shell { width: min(1720px, calc(100% - 40px)); }
}
