:root {
  --bg: #0f172a;
  --sidebar: #1e293b;
  --card: #ffffff;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --error: #dc2626;
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #f1f5f9;
  color: var(--text);
  min-height: 100vh;
  display: flex;
}

.sidebar {
  width: 240px;
  background: var(--sidebar);
  color: #e2e8f0;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-height: 100vh;
  position: fixed;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1rem;
  padding: 0.5rem 0.75rem 1.5rem;
  border-bottom: 1px solid #334155;
  margin-bottom: 0.5rem;
}

.brand-icon { font-size: 1.5rem; }

.nav-link {
  color: #94a3b8;
  text-decoration: none;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
  transition: all 0.15s;
}

.nav-link:hover, .nav-link.active {
  background: #334155;
  color: #fff;
}

.nav-link.logout { margin-top: auto; color: #f87171; }

.content {
  margin-left: 240px;
  padding: 2rem;
  flex: 1;
  max-width: 1100px;
}

h1 { font-size: 1.75rem; margin-bottom: 0.25rem; }
h2 { font-size: 1.1rem; margin-bottom: 1rem; color: #334155; }

.muted { color: var(--muted); margin-bottom: 1.5rem; }
.small { font-size: 0.85rem; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border: 1px solid var(--border);
}

.card-highlight {
  border-left: 4px solid var(--primary);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label { color: var(--muted); font-size: 0.85rem; margin-top: 0.25rem; }
.stat-max .stat-value { color: #7c3aed; }
.stat-tg .stat-value { color: #0891b2; }
.stat-email .stat-value { color: #ea580c; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 0.65rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
th { font-weight: 600; color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }

label { display: block; font-size: 0.85rem; font-weight: 500; margin-bottom: 0.35rem; color: #475569; }

input[type=text], input[type=password], input[type=email], input[type=tel], input[type=date],
select, textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  margin-bottom: 1rem;
  background: #fff;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1.1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  background: #e2e8f0;
  color: var(--text);
  text-decoration: none;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: #fee2e2; color: var(--error); }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }

.form-inline { display: flex; gap: 0.5rem; align-items: center; }
.form-inline input { margin-bottom: 0; flex: 1; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0 1rem;
}

.form-grid .full-width { grid-column: 1 / -1; }
.form-actions { grid-column: 1 / -1; margin-top: 0.5rem; }

.inline-form { display: inline; }
.actions { white-space: nowrap; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-max { background: #ede9fe; color: #6d28d9; }
.badge-telegram { background: #cffafe; color: #0e7490; }
.badge-email { background: #ffedd5; color: #c2410c; }

.alert {
  padding: 0.85rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }

.login-card, .public-card {
  max-width: 420px;
  margin: 4rem auto;
  background: var(--card);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(0,0,0,0.1);
  border: 1px solid var(--border);
}

.public-page { margin-left: 0; max-width: 100%; padding: 2rem; }

.brand-center { text-align: center; margin-bottom: 1.5rem; }
.brand-icon-lg { font-size: 3rem; display: block; margin-bottom: 0.5rem; }

/* Public pages (login, email subscribe) — full-width without sidebar offset */
body.layout-public {
  display: block;
  background: linear-gradient(160deg, #e2e8f0 0%, #f8fafc 45%, #f1f5f9 100%);
}

body.layout-public .content {
  margin-left: 0;
  max-width: none;
  padding: 0;
  min-height: 100vh;
}

/* Email subscribe page */
.subscribe-page {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
}

.subscribe-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.subscribe-header h1 {
  font-size: 1.5rem;
  margin-bottom: 0.35rem;
  letter-spacing: 0.02em;
}

.subscribe-lead {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0;
}

.subscribe-intro {
  font-size: 0.9rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 0.75rem;
}

.subscribe-channels {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.channel-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.25rem;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.channel-card-email {
  border-left: 4px solid #ea580c;
}

.channel-card-telegram {
  border-left: 4px solid #0891b2;
}

.channel-card-max {
  border-left: 4px solid #7c3aed;
}

.channel-card-head {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.channel-icon {
  font-size: 1.75rem;
  line-height: 1;
  flex-shrink: 0;
}

.channel-card h2 {
  font-size: 1.05rem;
  margin-bottom: 0.15rem;
  color: var(--text);
}

.channel-desc {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.4;
}

.subscribe-form label {
  margin-bottom: 0.35rem;
}

.subscribe-form input,
.subscribe-form select {
  margin-bottom: 0.85rem;
  font-size: 16px; /* prevents iOS zoom on focus */
}

.optional {
  font-weight: 400;
  color: var(--muted);
}

.channel-unavailable {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.45;
}

.channel-unavailable code {
  font-size: 0.8rem;
  background: #f1f5f9;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.btn-telegram {
  background: #0891b2;
  color: #fff;
}

.btn-telegram:hover {
  background: #0e7490;
}

.btn-max {
  background: #7c3aed;
  color: #fff;
}

.btn-max:hover {
  background: #6d28d9;
}

.subscribe-footer {
  text-align: center;
  margin-top: 1.75rem;
  font-size: 0.85rem;
}

.subscribe-footer a {
  color: var(--muted);
  text-decoration: none;
}

.subscribe-footer a:hover {
  color: var(--primary);
  text-decoration: underline;
}

body.layout-public .login-card {
  margin: 2rem auto;
  max-width: min(420px, calc(100% - 2rem));
}

@media (min-width: 640px) {
  .subscribe-page {
    padding: 2.5rem 1.5rem 3rem;
  }

  .subscribe-header h1 {
    font-size: 1.75rem;
  }
}

@media (max-width: 768px) {
  .sidebar { width: 100%; position: relative; min-height: auto; flex-direction: row; flex-wrap: wrap; }
  .content { margin-left: 0; padding: 1rem; }
  body { flex-direction: column; }
}
