:root {
  --navy: #0b1220;
  --navy-2: #111827;
  --blue: #2563eb;
  --bg: #eef2f7;
  --card: #fff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  background: #f8fafc;
}
.gate__bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(900px 420px at 80% -10%, rgba(37, 99, 235, 0.16), transparent 60%),
    radial-gradient(700px 380px at 0% 100%, rgba(14, 165, 233, 0.1), transparent 55%);
}
.gate__card {
  position: relative;
  width: min(400px, 100%);
  padding: 36px 32px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.08);
  text-align: left;
}
.gate__logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: block;
  margin-bottom: 18px;
}
.gate__card h1 {
  margin: 0 0 6px;
  font-size: 1.7rem;
  letter-spacing: -0.03em;
}
.gate__card > p {
  margin: 0 0 22px;
  color: var(--muted);
}
.gate__card label {
  display: block;
  margin: 14px 0 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
}
.gate__card input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
  font: inherit;
}
.gate__card input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
  background: #fff;
}
.gate__card button {
  width: 100%;
  margin-top: 22px;
  height: 46px;
  border: 0;
  border-radius: 12px;
  background: var(--blue);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.gate__error { margin-top: 12px; color: #dc2626; font-size: 0.9rem; }

.app { display: flex; min-height: 100dvh; }
.side {
  width: 250px;
  flex-shrink: 0;
  background: var(--navy);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  max-height: 100dvh;
  overflow: auto;
}
.side__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  font-weight: 800;
  letter-spacing: 0.04em;
  margin-bottom: 22px;
  padding: 0 8px;
}
.side__brand img { width: 32px; height: 32px; border-radius: 8px; }
.side__label {
  margin: 16px 8px 6px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
}
.side__link {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #cbd5e1;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.side__link svg { width: 18px; height: 18px; flex-shrink: 0; }
.side__link.is-active, .side__link:hover {
  background: rgba(37, 99, 235, 0.22);
  color: #fff;
}
.side__badge {
  margin-left: auto;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #22c55e;
  color: #052e16;
  font-size: 0.7rem;
  font-weight: 700;
  text-align: center;
}
.side__copy { margin-top: auto; padding: 12px 8px 0; font-size: 0.75rem; color: #64748b; }

.main { flex: 1; min-width: 0; }
.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.icon-btn, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.icon-btn { width: 40px; height: 40px; padding: 0; }
.icon-btn svg { width: 20px; height: 20px; }
.top__search {
  flex: 1;
  max-width: 360px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  background: #f8fafc;
  font: inherit;
}
.top__right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.top__lang { font-weight: 700; color: var(--muted); }
.top__user { display: flex; align-items: center; gap: 8px; }
.top__user small { display: block; color: var(--muted); font-size: 0.75rem; }
.top__avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: #dbeafe; color: var(--blue); font-weight: 800;
}
.btn--ghost { background: transparent; }
.btn--primary { background: var(--blue); border-color: var(--blue); color: #fff; }

.page-head { padding: 22px 22px 8px; }
.page-head h2 { margin: 0; font-size: 1.4rem; }
.crumb { margin: 4px 0 0; color: var(--muted); font-size: 0.85rem; }
.page { padding: 8px 22px 32px; }

.stats {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.stat {
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}
.stat span { color: var(--muted); font-size: 0.8rem; }
.stat strong { display: block; margin-top: 6px; font-size: 1.45rem; }
.stat.c1 { border-top: 3px solid #2563eb; }
.stat.c2 { border-top: 3px solid #22c55e; }
.stat.c3 { border-top: 3px solid #f59e0b; }
.stat.c4 { border-top: 3px solid #8b5cf6; }
.stat.c5 { border-top: 3px solid #06b6d4; }
.stat.c6 { border-top: 3px solid #ef4444; }

.grid-2 { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 12px; }
.card {
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}
.card__head, .toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.card h3 { margin: 0 0 12px; }
.field, .mail-form input, .mail-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
}
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  cursor: pointer;
}
.chip.is-active { background: #eff6ff; border-color: #bfdbfe; color: var(--blue); }
.select-all { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.9rem; }
.count { margin-left: auto; }
.list { margin-top: 10px; }
.hint { color: var(--muted); margin: 0; }

.admin-user-row, .admin-lead, .dash-row {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.admin-lead { display: block; }
.admin-user-row--banned { opacity: 0.65; }
.admin-user-row__avatar, .admin-user-row__photo {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: #eff6ff; color: var(--blue); font-weight: 700;
  object-fit: cover;
}
.admin-user-row__info span, .admin-user-row__info small, .admin-lead__meta { color: var(--muted); font-size: 0.8rem; }
.admin-user-row__actions, .admin-lead__actions { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-user-row__actions button {
  width: 32px; height: 32px; padding: 0;
  display: grid; place-items: center;
}
.admin-user-row__actions svg { width: 15px; height: 15px; }
.admin-user-row__badge { color: #dc2626; font-size: 0.72rem; }
.admin-empty { padding: 20px; text-align: center; color: var(--muted); }
.admin-lead--new { background: #eff6ff; border-radius: 12px; padding: 12px; }
.admin-lead__top { display: flex; justify-content: space-between; gap: 10px; }
.admin-lead__msg { white-space: pre-wrap; }
.mail-form label { display: block; margin: 12px 0 6px; font-weight: 600; font-size: 0.85rem; }
.sys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 12px; }
.log { margin: 0; color: var(--muted); white-space: pre-wrap; font-size: 0.85rem; }
.flash { margin: 0 22px 10px; }
.flash--error { color: #dc2626; }
.flash--ok { color: #15803d; }

.app.side-closed .side { display: none; }

.stat small { display: block; margin-top: 4px; color: #16a34a; font-size: 0.75rem; }
.grid-3 { display: grid; grid-template-columns: 1.3fr 0.85fr 0.85fr; gap: 12px; margin: 12px 0; }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.quick__btn {
  border: 0; border-radius: 14px; padding: 16px 10px; color: #fff;
  font: inherit; font-weight: 700; cursor: pointer;
}
.q1 { background: #2563eb; } .q2 { background: #7c3aed; } .q3 { background: #0ea5e9; }
.q4 { background: #16a34a; } .q5 { background: #f59e0b; } .q6 { background: #64748b; }
.q7 { background: #db2777; } .q8 { background: #0f766e; }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th, .table td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.table__act { white-space: nowrap; }
.st { font-weight: 700; }
.st--confirmed, .st--published, .st--active { color: #15803d; }
.st--sent { color: #2563eb; }
.st--pending { color: #d97706; }
.st--rejected, .st--disabled, .st--hidden { color: #dc2626; }
.st--draft { color: #64748b; }
.timeline__item { padding: 8px 0 8px 14px; border-left: 2px solid #bfdbfe; margin-left: 6px; }
.timeline__item small { color: var(--muted); margin-left: 6px; }
.chart-svg { width: 100%; height: 220px; }
.chart-legend { display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: 0.85rem; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.d1 { background: #2563eb; } .d2 { background: #22c55e; }
.donut-wrap { display: flex; gap: 12px; align-items: center; }
.donut { width: 140px; height: 140px; }
.donut-wrap ul { list-style: none; margin: 0; padding: 0; font-size: 0.85rem; }
.donut-wrap li { display: flex; align-items: center; gap: 6px; margin: 6px 0; }
.donut-wrap i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.bar { height: 8px; background: #e2e8f0; border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; background: #2563eb; }
.sys-mini p { display: flex; justify-content: space-between; margin: 8px 0; }
.modal {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45);
  display: grid; place-items: center; z-index: 40; padding: 20px;
}
.modal[hidden] { display: none !important; }
.modal__card {
  width: min(560px, 100%); background: #fff; border-radius: 18px;
  padding: 20px; max-height: 90dvh; overflow: auto;
}
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.media-card { background: #f8fafc; border-radius: 12px; padding: 10px; }
.media-card img { width: 100%; height: 110px; object-fit: cover; border-radius: 8px; }
.settings-form { max-width: 640px; }
.mail-box { padding: 0; overflow: hidden; border: 0; box-shadow: 0 16px 40px rgba(15, 23, 42, 0.08); }
.mail-top {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 16px 18px;
  background: linear-gradient(135deg, #0b1220, #1d4ed8);
  color: #fff;
}
.mail-brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.mail-brand__icon {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: rgba(255,255,255,0.14); font-size: 1.1rem;
}
.mail-brand b { display: block; font-size: 0.95rem; }
.mail-brand small { color: #bfdbfe; }
.mail-tabs { display: flex; gap: 6px; background: rgba(255,255,255,0.1); padding: 4px; border-radius: 999px; }
.mail-tab {
  border: 0; background: transparent; color: #dbeafe;
  border-radius: 999px; padding: 8px 16px; font: inherit; font-weight: 700; cursor: pointer;
}
.mail-tab.is-active { background: #fff; color: #1d4ed8; }
.mail-refresh { background: rgba(255,255,255,0.12); color: #fff; border-color: transparent; }
.mail-refresh:hover { background: rgba(255,255,255,0.22); }
.mail-split { display: grid; grid-template-columns: 340px 1fr; min-height: 560px; background: #f8fafc; }
.mail-list { background: #fff; border-right: 1px solid var(--line); overflow: auto; max-height: 72vh; }
.mail-item {
  display: grid; grid-template-columns: 42px 1fr; gap: 10px; align-items: start;
  width: 100%; text-align: left; border: 0; border-bottom: 1px solid #eef2f7;
  background: #fff; padding: 13px 14px; cursor: pointer; font: inherit;
}
.mail-item:hover { background: #f8fafc; }
.mail-item.is-on { background: #eff6ff; box-shadow: inset 3px 0 0 #2563eb; }
.mail-ava {
  width: 42px; height: 42px; border-radius: 14px;
  display: grid; place-items: center; color: #fff; font-weight: 800;
}
.mail-item strong, .mail-item span, .mail-item small { display: block; }
.mail-item strong { font-size: 0.92rem; }
.mail-item span { color: #334155; margin-top: 3px; font-size: 0.86rem; }
.mail-item small { color: var(--muted); margin-top: 5px; font-size: 0.72rem; }
.mail-read { padding: 28px 32px; overflow: auto; max-height: 72vh; background: #fff; margin: 12px; border-radius: 18px; }
.mail-read h4 { margin: 0 0 8px; font-size: 1.25rem; }
.mail-read .meta { color: var(--muted); font-size: 0.88rem; margin: 0 0 18px; }
.mail-read pre { white-space: pre-wrap; font: inherit; margin: 0 0 18px; line-height: 1.6; color: #1e293b; }
.mail-empty { height: 100%; min-height: 320px; display: grid; place-items: center; text-align: center; color: var(--muted); }
.mail-empty span { font-size: 2.4rem; display: block; margin-bottom: 8px; }
#mailWriteView { padding: 28px 32px 32px; max-width: 720px; background: #fff; margin: 12px; border-radius: 18px; }
#mailWriteView .mail-form input, #mailWriteView .mail-form textarea {
  background: #f8fafc; border-radius: 12px;
}
#mailError, #mailOk { margin: 0 0 10px; }
.check { display: flex; align-items: center; gap: 8px; }

@media (max-width: 1100px) {
  .grid-3, .quick { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 800px) {
  .quick { grid-template-columns: 1fr; }
  .mail-split { grid-template-columns: 1fr; min-height: 0; }
  .mail-list, .mail-read { max-height: 40vh; }
}

@media (max-width: 1100px) {
  .stats, .sys { grid-template-columns: repeat(3, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .side { position: fixed; inset: 0 auto 0 0; z-index: 20; }
  .stats, .sys { grid-template-columns: 1fr 1fr; }
  .admin-user-row { grid-template-columns: auto 1fr; }
  .admin-user-row__actions { grid-column: 1 / -1; }
}
