:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e2e4e9;
  --text: #16181d;
  --text-muted: #6b7280;
  --text-faint: #9aa0ab;

  --primary: #4338ca;
  --primary-hover: #372da8;
  --primary-soft: #eef0fd;

  --danger: #b91c1c;
  --danger-soft: #fdecec;

  --success: #15803d;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- Навигация ---------- */

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.nav .brand {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--text);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}

.nav-links a:hover { background: var(--bg); color: var(--text); }
.nav-links a.active { color: var(--primary); background: var(--primary-soft); }

.nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: 16px;
  padding-left: 16px;
  border-left: 1px solid var(--border);
}

.nav-user .email {
  font-size: 13px;
  color: var(--text-muted);
}

.nav-user form { margin: 0; }

.link-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
}
.link-btn:hover { background: var(--bg); color: var(--text); }

/* ---------- Каркас страницы ---------- */

.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 24px 72px;
}

h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 24px;
}

h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 16px;
  color: var(--text);
}

/* ---------- Карточки ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  margin-bottom: 22px;
}

/* ---------- Формы ---------- */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 18px;
}

.form-grid label,
.auth-form label {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  gap: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

fieldset {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin: 0;
}
fieldset legend {
  font-size: 12px;
  color: var(--text-faint);
  padding: 0 6px;
}

.btn-primary, .btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  grid-column: 1 / -1;
  justify-self: start;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg); }

/* ---------- Таблицы ---------- */

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table th {
  color: var(--text-faint);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.table tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
}
.badge-on { background: #ecfdf3; color: var(--success); }
.badge-off { background: var(--bg); color: var(--text-faint); }

.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions form { display: inline; margin: 0; }
.actions button {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text);
}
.actions button:hover { background: var(--border); }
.actions button.danger { color: var(--danger); }
.actions button.danger:hover { background: var(--danger-soft); }

/* ---------- Фильтры архива ---------- */

.filters {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.filters label {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---------- Список материалов ---------- */

.items { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }

.item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  transition: border-color 0.15s;
}
.item:hover { border-color: #c7cad4; }
.item.is-read { opacity: 0.5; }

.item-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  line-height: 1.4;
}
.item-title:hover { color: var(--primary); }

.item .meta { font-size: 12px; color: var(--text-faint); margin-top: 4px; }
.item .summary { font-size: 13.5px; color: var(--text-muted); margin: 8px 0 0; line-height: 1.5; }
.item .actions { flex-direction: column; align-items: flex-end; flex-shrink: 0; }

.empty {
  color: var(--text-muted);
  padding: 40px 20px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  font-size: 14px;
}

/* ---------- Статистика ---------- */

.stats-cards { display: flex; gap: 16px; margin-bottom: 24px; }
.stat-card {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.stat-number { font-size: 30px; font-weight: 700; color: var(--primary); letter-spacing: -0.02em; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 6px; }

/* ---------- Авторизация ---------- */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 32px;
}

.auth-card .brand {
  display: block;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--text);
  margin-bottom: 4px;
}

.auth-card h1 {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-muted);
  margin: 0 0 24px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-form .btn-primary { width: 100%; }

.auth-error {
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.auth-switch {
  margin-top: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}
.auth-switch a { color: var(--primary); font-weight: 600; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

/* ---------- Сообщения и статус проверки ---------- */

.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 20px;
  border: 1px solid transparent;
}
.flash-success { background: #ecfdf3; color: var(--success); border-color: #c6f0d6; }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: #f6caca; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 4px;
}
.page-head form { margin: 0; }
.page-head .btn-secondary { font-size: 13px; padding: 8px 14px; }

.check-status { max-width: 260px; font-size: 13px; line-height: 1.4; }
.check-status span { display: block; }
.status-ok { color: var(--success); }
.status-error { color: var(--danger); }
.status-time { color: var(--text-faint); font-size: 12px; margin-top: 2px; }
