/* X5 Adapt Admin — youth editorial / digital ecology (кв_молодежный direction) */

:root {
  --font-display: "Unbounded", system-ui, sans-serif;
  --font-body: "Manrope", system-ui, sans-serif;

  --bg: #f3efe6;
  --bg-accent: #e8f9d4;
  --surface: #ffffff;
  --surface-2: #faf8f4;
  --text: #0f1412;
  --text-muted: #5a6560;
  --brand: #00a046;
  --brand-dark: #007a35;
  --brand-soft: #e6f7ec;
  --lime: #c8f55a;
  --lime-dark: #9bc42a;
  --border: #ddd6c8;
  --border-strong: #c4baa8;
  --danger: #c62828;
  --danger-soft: #fdecea;
  --success-soft: #e6f7ec;
  --shadow: 0 12px 40px rgba(15, 20, 18, 0.08);
  --shadow-sm: 0 4px 14px rgba(15, 20, 18, 0.06);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-w: 260px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 120% 80% at 100% 0%, rgba(200, 245, 90, 0.35), transparent 55%),
    radial-gradient(ellipse 90% 60% at 0% 100%, rgba(0, 160, 70, 0.08), transparent 50%);
}

a {
  color: var(--brand-dark);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.2s var(--ease);
}

a:hover {
  color: var(--brand);
}

/* ——— App shell ——— */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1.25rem;
  background: var(--text);
  color: #f4f6f5;
  border-right: 3px solid var(--lime);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
  text-decoration: none;
  color: inherit;
}

.brand:hover {
  color: var(--lime);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--lime-dark) 100%);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.75rem;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 6px 20px rgba(0, 160, 70, 0.35);
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.brand-sub {
  font-size: 0.7rem;
  opacity: 0.65;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
  font-weight: 500;
  transition:
    background 0.2s var(--ease),
    color 0.2s var(--ease),
    transform 0.2s var(--ease);
}

.nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav a.is-active {
  background: rgba(200, 245, 90, 0.18);
  color: var(--lime);
  font-weight: 600;
}

.nav-icon {
  width: 1.25rem;
  text-align: center;
  opacity: 0.9;
  font-size: 0.85rem;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-footer a {
  display: block;
  padding: 0.5rem 0.85rem;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.55);
  text-decoration: none;
}

.sidebar-footer a:hover {
  color: #fff;
}

.main {
  padding: 2rem 2.5rem 3rem;
  max-width: 1100px;
  width: 100%;
}

.page-header {
  margin-bottom: 1.75rem;
  animation: rise 0.5s var(--ease) both;
}

.page-header h1 {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.page-header .subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 42rem;
}

.page-content {
  animation: rise 0.55s var(--ease) 0.05s both;
}

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

/* ——— Cards & stats ——— */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin: 0 0 2rem;
  padding: 0;
  list-style: none;
}

.stat-card {
  display: flex;
  flex-direction: column;
  min-height: 6.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow-sm);
  transition:
    border-color 0.2s var(--ease),
    box-shadow 0.2s var(--ease);
}

.stat-card--link {
  cursor: pointer;
}

.stat-card--link:hover,
.stat-card--link:focus-within {
  border-color: rgba(0, 160, 70, 0.35);
  box-shadow: var(--shadow);
}

@media (prefers-reduced-motion: no-preference) {
  .stat-card--link:hover {
    transform: translateY(-2px);
  }

  .stat-card--link {
    transition:
      transform 0.25s var(--ease),
      border-color 0.2s var(--ease),
      box-shadow 0.25s var(--ease);
  }
}

.stat-card__link {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 100%;
  text-decoration: none;
  color: inherit;
  margin: -1.25rem -1.35rem;
  padding: 1.25rem 1.35rem;
  border-radius: inherit;
}

.stat-card__link:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.stat-card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.65rem;
  min-width: 0;
}

.stat-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  line-height: 1.35;
}

.stat-value {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4vw, 1.85rem);
  font-weight: 600;
  color: var(--text);
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.stat-value--text {
  font-family: var(--font-body);
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.stat-card--accent {
  border-left: 4px solid var(--brand);
  padding-left: calc(1.35rem - 4px);
}

.stat-card--accent .stat-card__link {
  margin-left: calc(-1.35rem + 4px);
  padding-left: calc(1.35rem - 4px);
}

.stat-card--warn {
  border-left: 4px solid var(--danger);
  padding-left: calc(1.35rem - 4px);
}

.stat-card--warn .stat-card__link {
  margin-left: calc(-1.35rem + 4px);
  padding-left: calc(1.35rem - 4px);
}

.stat-card--warn .stat-value {
  color: var(--danger);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.panel h2,
.page-content h2 {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.panel h2:not(:first-child),
.page-content h2:not(:first-child) {
  margin-top: 2rem;
}

/* ——— Tables ——— */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead {
  background: var(--surface-2);
}

th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: rgba(200, 245, 90, 0.12);
}

td a {
  font-weight: 600;
}

/* ——— Forms ——— */

form.stack {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  max-width: 520px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="datetime-local"],
input[type="email"],
textarea,
select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font: inherit;
  font-weight: 400;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition:
    border-color 0.2s var(--ease),
    box-shadow 0.2s var(--ease);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0, 160, 70, 0.15);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

label.checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 0.65rem;
  font-weight: 500;
  cursor: pointer;
}

label.checkbox-row input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
  accent-color: var(--brand);
  cursor: pointer;
}

.test-target {
  padding: 0.85rem 1rem;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
}

.broadcast-form textarea {
  min-height: 160px;
}

/* ——— Broadcast rich editor (Telegram HTML) ——— */

.broadcast-editor {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.broadcast-editor__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.broadcast-editor__title {
  font-weight: 700;
  font-size: 0.92rem;
}

.broadcast-editor__tabs {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.2rem;
  background: var(--surface-2);
  border-radius: 999px;
  border: 1px solid var(--border);
}

.broadcast-editor__tab {
  padding: 0.35rem 0.85rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  box-shadow: none;
}

.broadcast-editor__tab:hover {
  color: var(--text);
  background: var(--surface);
  transform: none;
}

.broadcast-editor__tab.is-active {
  background: var(--brand);
  color: #fff;
}

.broadcast-editor__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.broadcast-editor__btn {
  min-width: 2.25rem;
  padding: 0.4rem 0.55rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  box-shadow: none;
}

.broadcast-editor__btn:hover {
  border-color: var(--brand);
  color: var(--brand-dark);
  background: var(--brand-soft);
  transform: none;
}

.broadcast-editor__textarea {
  width: 100%;
  min-height: 200px;
  margin: 0;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.88rem;
  line-height: 1.55;
}

.broadcast-editor__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0.35rem 0 0;
}

.broadcast-editor__counter {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.broadcast-editor__counter.is-over {
  color: var(--danger);
}

.telegram-preview {
  min-height: 200px;
  padding: 0.85rem 1rem;
  background: #17212b;
  color: #f5f5f5;
  border-radius: 12px 12px 12px 4px;
  font-size: 0.95rem;
  line-height: 1.5;
  white-space: normal;
  word-break: break-word;
}

.telegram-preview b,
.telegram-preview strong {
  font-weight: 700;
}

.telegram-preview i,
.telegram-preview em {
  font-style: italic;
}

.telegram-preview u,
.telegram-preview ins {
  text-decoration: underline;
}

.telegram-preview s,
.telegram-preview strike,
.telegram-preview del {
  text-decoration: line-through;
  opacity: 0.85;
}

.telegram-preview code {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.88em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
}

.telegram-preview pre {
  margin: 0.5rem 0;
  padding: 0.65rem 0.75rem;
  overflow-x: auto;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.85em;
  white-space: pre-wrap;
}

.telegram-preview a {
  color: #6ab3f3;
  text-decoration: none;
}

.telegram-preview a:hover {
  text-decoration: underline;
}

.telegram-preview blockquote {
  margin: 0.35rem 0;
  padding: 0.35rem 0 0.35rem 0.75rem;
  border-left: 3px solid #6ab3f3;
  color: #c8d6e5;
}

.telegram-preview blockquote.tg-expandable {
  cursor: pointer;
  position: relative;
}

.telegram-preview blockquote.tg-expandable::after {
  content: "▾ развернуть";
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: #6ab3f3;
}

.telegram-preview .tg-spoiler,
.telegram-preview tg-spoiler {
  background: #3a4550;
  color: #3a4550;
  border-radius: 4px;
  padding: 0 0.15em;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.telegram-preview .tg-spoiler:hover,
.telegram-preview .tg-spoiler.is-revealed,
.telegram-preview tg-spoiler.is-revealed {
  color: inherit;
  background: rgba(255, 255, 255, 0.08);
}

.telegram-preview__empty {
  margin: 0;
  color: #8b9bab;
  font-style: italic;
}

fieldset.attachment-mode {
  margin: 0;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

fieldset.attachment-mode legend {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0 0.35rem;
}

label.radio-row {
  flex-direction: row;
  align-items: flex-start;
  gap: 0.55rem;
  font-weight: 500;
  cursor: pointer;
  margin-top: 0.45rem;
}

label.radio-row:first-of-type {
  margin-top: 0.25rem;
}

label.radio-row input[type="radio"] {
  width: 1rem;
  height: 1rem;
  margin-top: 0.15rem;
  accent-color: var(--brand);
  cursor: pointer;
}

input[type="file"] {
  font-family: var(--font-body);
  font-size: 0.92rem;
  padding: 0.35rem 0;
}

/* ——— Buttons ——— */

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.15rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition:
    transform 0.15s var(--ease),
    box-shadow 0.2s var(--ease),
    background 0.2s var(--ease);
}

button,
.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 160, 70, 0.25);
}

button:hover,
.btn-primary:hover {
  background: var(--brand-dark);
  transform: translateY(-1px);
  color: #fff;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: none;
}

.btn-secondary:hover {
  border-color: var(--brand);
  color: var(--brand-dark);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  margin: 1rem 0;
}

.form-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.plain-list,
ul.clean {
  margin: 0;
  padding-left: 1.2rem;
}

.plain-list li,
ul.clean li {
  margin-bottom: 0.35rem;
}

.hint {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ——— Alerts ——— */

.msg,
.err {
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  border: 1px solid transparent;
}

.msg {
  background: var(--success-soft);
  border-color: rgba(0, 160, 70, 0.25);
  color: var(--brand-dark);
}

.err {
  background: var(--danger-soft);
  border-color: rgba(198, 40, 40, 0.2);
  color: var(--danger);
}

/* ——— Misc ——— */

.page-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1.25rem;
}

.page-toolbar .spacer {
  flex: 1;
  min-width: 0.5rem;
}

.page-toolbar .hint {
  flex: 1 1 100%;
  margin: 0;
}

@media (min-width: 640px) {
  .page-toolbar .hint {
    flex: 1 1 auto;
    text-align: right;
  }
}

.meta-list {
  display: grid;
  gap: 0.5rem;
  margin: 1rem 0;
}

.meta-list p {
  margin: 0;
}

.meta-list b {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 0.5rem;
}

ul.clean {
  margin: 0;
  padding-left: 1.2rem;
}

ul.clean li {
  margin-bottom: 0.35rem;
}

.screenshot-preview {
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.qr-stage {
  text-align: center;
  padding: 2rem 1.5rem;
}

.qr-stage img {
  image-rendering: pixelated;
  border: 8px solid var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.code-block {
  display: block;
  word-break: break-all;
  padding: 0.85rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  line-height: 1.45;
}

.quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}

.quick-link {
  display: block;
  padding: 1rem 1.15rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  transition:
    border-color 0.2s var(--ease),
    background 0.2s var(--ease);
}

.quick-link:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.quick-link:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.quick-link span {
  display: block;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.badge--pending {
  background: #fff3e0;
  color: #e65100;
}

/* ——— Login ——— */

body.login-page {
  display: grid;
  place-items: center;
  padding: 2rem;
  min-height: 100vh;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  padding: 2.25rem 2rem;
  box-shadow: var(--shadow);
  animation: rise 0.6s var(--ease) both;
}

.login-card .brand {
  margin-bottom: 1.75rem;
  color: var(--text);
}

.login-card .brand:hover {
  color: var(--brand-dark);
}

.login-card h1 {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
}

.login-card .login-lead {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.login-error {
  margin-bottom: 1rem;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
  }

  .brand {
    margin-bottom: 0;
  }

  .nav {
    flex-direction: row;
    flex-wrap: wrap;
    flex: 1;
  }

  .sidebar-footer {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
  }

  .main {
    padding: 1.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
