:root {
  --bg: #fff8f5;
  --surface: #ffffff;
  --text: #4a3f3f;
  --muted: #a88f8f;
  --border: #f3ddd8;
  --primary: #ff8fa3;
  --primary-hover: #ff7192;
  --primary-soft: #ffe3e9;
  --accent: #b8b3ff;
  --accent-soft: #eceaff;
  --success: #7bc9a0;
  --success-soft: #e3f6ec;
  --danger: #ff8f8f;
  --danger-soft: #ffe9e9;
  --radius: 18px;
  --radius-sm: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #221b22;
    --surface: #2c2329;
    --text: #f5e9e9;
    --muted: #baa0a0;
    --border: #3f3138;
    --primary: #ff9fb3;
    --primary-hover: #ffb1c2;
    --primary-soft: #3a2830;
    --accent: #c7c3ff;
    --accent-soft: #332f4a;
    --success: #8fd6ae;
    --success-soft: #234034;
    --danger: #ff9f9f;
    --danger-soft: #402727;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
}

a { color: var(--primary); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }

.guest-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
  background: radial-gradient(circle at 20% 20%, var(--primary-soft), transparent 40%),
              radial-gradient(circle at 80% 80%, var(--accent-soft), transparent 40%),
              var(--bg);
}

.guest-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 17px;
  color: var(--muted);
}
.guest-brand .dot { color: var(--primary); margin-right: 2px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 30px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 30px -12px rgba(255, 143, 163, 0.25);
}

.card h1 {
  font-size: 19px;
  margin: 0 0 18px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 5px;
  color: var(--muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="date"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 10px 13px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  margin-bottom: 16px;
  font-family: inherit;
  transition: border-color .15s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
}

button, .btn {
  display: inline-block;
  padding: 10px 18px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .1s ease, background .15s ease;
}

button:hover, .btn:hover { background: var(--primary-hover); text-decoration: none; transform: translateY(-1px); }
button:active, .btn:active { transform: translateY(0); }

.btn-secondary { background: var(--accent-soft); color: var(--text); border: 2px solid transparent; }
.btn-secondary:hover { background: var(--accent); color: #fff; }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #ff7a7a; }

.error { color: var(--danger); font-size: 13px; margin: -10px 0 14px; font-weight: 600; }
.help { color: var(--muted); font-size: 13px; }
.status { padding: 11px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; font-weight: 600; }
.status-success { background: var(--success-soft); color: var(--success); }
.status-error { background: var(--danger-soft); color: var(--danger); }

/* App shell */
.app-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  height: 60px;
  overflow-x: auto;
}

.app-nav .brand { display: flex; align-items: center; height: 60px; gap: 10px; font-weight: 800; font-size: 15px; color: var(--muted); flex-shrink: 0; white-space: nowrap; }
.app-nav .brand:hover { text-decoration: none; color: var(--muted); }
.app-nav .brand .dot { color: var(--primary); margin-right: 2px; }

.logo-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  background: linear-gradient(135deg, var(--primary-soft), var(--accent-soft));
  border: 2px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 3px 10px -4px rgba(255, 143, 163, 0.4);
}
.app-nav nav { display: flex; align-items: center; gap: 18px; flex: 1; }
.app-nav nav a { display: flex; align-items: center; height: 60px; color: var(--muted); font-size: 14px; font-weight: 700; white-space: nowrap; }
.app-nav nav a.active, .app-nav nav a:hover { color: var(--primary); text-decoration: none; }
.app-nav form { margin: 0; }
.app-nav button.link {
  background: none; border: none; color: var(--muted); font-weight: 700; font-size: 14px; padding: 0; cursor: pointer;
}
.app-nav button.link:hover { color: var(--primary); text-decoration: underline; }

.container { max-width: 1100px; margin: 0 auto; padding: 30px 24px; }

table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { background: var(--primary-soft); font-weight: 800; color: var(--text); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

.toolbar { display: flex; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; align-items: flex-end; }
.toolbar .field { display: flex; flex-direction: column; }
.toolbar label { margin-bottom: 5px; }
.toolbar input, .toolbar select { margin-bottom: 0; min-width: 170px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-subscribed { background: var(--success-soft); color: var(--success); }
.badge-unsubscribed { background: var(--accent-soft); color: var(--muted); }
.badge-bounced { background: var(--danger-soft); color: var(--danger); }

.tag { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--accent-soft); color: var(--accent); margin: 0 4px 4px 0; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 30px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat-card .value { font-size: 28px; font-weight: 800; color: var(--primary); }
.stat-card .label { color: var(--muted); font-size: 13px; margin-top: 4px; font-weight: 600; }

.pagination { margin-top: 20px; display: flex; gap: 10px; }

h2.page-title { margin: 0 0 22px; font-size: 21px; font-weight: 800; }

.qr-box { background: #fff; padding: 18px; border-radius: var(--radius-sm); display: inline-block; }

.poster-preview { max-width: 240px; border-radius: var(--radius-sm); border: 2px solid var(--border); margin-bottom: 14px; display: block; }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--muted);
  margin-bottom: 16px;
  background: var(--bg);
}

/* Публичные страницы (отписка) */
.card-wide { max-width: 480px; }
.card-wide h1 { font-size: 21px; margin: 0 0 14px; }
.card-wide p { margin: 0 0 12px; }

.reason-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  text-transform: none;
  letter-spacing: normal;
}
.reason-option:hover { border-color: var(--primary); }
.reason-option input { width: auto; margin: 3px 0 0; }
.reason-option span { flex: 1; }

/* Выбор способа отправки */
.method-choice { margin-bottom: 16px; }
.method-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
  font-size: 14px;
  color: var(--text);
}
.method-option:hover { border-color: var(--primary); }
.method-option:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.method-option input { width: auto; margin: 4px 0 0; }
.method-option > span { display: block; }
.method-option .help { display: block; margin-top: 2px; font-weight: 600; }

.send-progress-bar { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; margin: 10px 0; }
.send-progress-bar > span { display: block; height: 100%; width: 0; background: var(--primary); transition: width .25s ease; }

/* Тестовая отправка */
.test-send { margin: 18px 0; padding: 14px 16px; border: 2px dashed var(--border); border-radius: var(--radius-sm); }
.test-send-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.test-send-row input { margin-bottom: 0; flex: 1; min-width: 200px; }
.test-send .help { margin: 8px 0 0; }

/* Карточка причины, по которой адрес не в рассылке */
.status-card { border-left: 4px solid var(--accent); }
.status-card h3 { margin: 0 0 10px; font-size: 16px; }
.status-card p { margin: 0 0 8px; }
.status-card p:last-child { margin-bottom: 0; }
