:root {
  --mg-red: #e30613;
  --mg-red-hot: #ff2a2a;
  --mg-coral: #f5a3a8;
  --mg-grad-a: #ff3b30;
  --mg-grad-b: #ff6a3d;
  --bg: #ffffff;
  --page: #f4f4f6;
  --field: #f2f2f4;
  --surface: #ffffff;
  --ink: #1c1c1e;
  --muted: #8e8e93;
  --line: #ebebef;
  --danger: #e30613;
  --ok: #1f8a4c;
  --wait: #c47a00;
  --font: "SF Pro Display", "Manrope", "Segoe UI", system-ui, sans-serif;
  --radius: 16px;
  --radius-lg: 20px;
  --shadow: 0 4px 18px rgba(0, 0, 0, 0.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
}
.bg { display: none; }

/* —— top bar —— */
.top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.85rem 1.25rem;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand {
  display: inline-flex; align-items: center; gap: 0.5rem;
  color: var(--ink); text-decoration: none; font-weight: 800; font-size: 1.05rem;
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--mg-red); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 0.95rem;
}
nav { display: flex; gap: 0.9rem; align-items: center; flex-wrap: wrap; }
nav a { color: var(--muted); text-decoration: none; font-size: 0.9rem; font-weight: 600; }
nav a:hover { color: var(--mg-red); }

.wrap { max-width: 920px; margin: 0 auto; padding: 1.5rem 1.15rem 3.5rem; }
h1, h2 { margin: 0 0 0.5rem; font-weight: 800; letter-spacing: -0.03em; }
h1 { font-size: clamp(1.75rem, 4.5vw, 2.15rem); line-height: 1.15; }
h2 { font-size: 1.15rem; }

/* —— Magnit-style auth (phone screen) —— */
.auth-page {
  max-width: 420px;
  margin: 0.5rem auto 0;
  background: #fff;
  border-radius: 24px;
  padding: 1.75rem 1.35rem 2rem;
  box-shadow: var(--shadow);
}
.auth-page.bare {
  box-shadow: none;
  border-radius: 0;
  padding: 1.25rem 0.25rem 2rem;
  background: transparent;
}
.auth-back {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; margin: 0 0 1.25rem;
  color: var(--ink); text-decoration: none; font-size: 1.4rem; line-height: 1;
}
.auth-title { margin-bottom: 0.35rem; }
.auth-sub {
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.35;
  margin: 0 0 1.5rem;
}
.field {
  background: var(--field);
  border-radius: 14px;
  padding: 0.55rem 0.95rem 0.7rem;
  margin-bottom: 0.85rem;
}
.field label {
  display: block;
  margin: 0 0 0.15rem;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
}
.field input {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0.15rem 0 0;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink);
  outline: none;
  font-family: inherit;
}
.field input::placeholder { color: #c5c5c9; font-weight: 500; }

.btn-mg {
  display: flex; align-items: center; justify-content: center;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.95rem 1rem;
  border: 0;
  border-radius: 14px;
  background: var(--mg-coral);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s ease, transform .08s ease;
}
.btn-mg:hover { background: #ef8f96; }
.btn-mg.is-ready,
.btn-mg.primary {
  background: var(--mg-red);
}
.btn-mg.is-ready:hover,
.btn-mg.primary:hover { background: #c90511; }
.btn-mg:active { transform: scale(0.99); }
.btn-mg.secondary {
  background: #fff;
  color: var(--ink);
  border: 1.5px solid var(--line);
}
.btn-mg.secondary:hover { background: #fafafa; }

.auth-foot {
  text-align: center;
  margin-top: 1.25rem;
  color: var(--muted);
  font-size: 0.92rem;
}
.auth-foot a { color: var(--mg-red); font-weight: 700; text-decoration: none; }

.err {
  background: #ffe8ea;
  color: var(--mg-red);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  margin: 0 0 1rem;
  font-size: 0.92rem;
  line-height: 1.35;
}

/* —— landing / cards —— */
.hero-mg {
  background: linear-gradient(165deg, var(--mg-grad-a) 0%, var(--mg-grad-b) 100%);
  border-radius: 24px;
  padding: 1.6rem 1.35rem 1.5rem;
  color: #fff;
  box-shadow: 0 12px 32px rgba(227, 6, 19, 0.22);
  margin-bottom: 1.1rem;
}
.hero-mg .chip {
  display: inline-block;
  background: rgba(255,255,255,0.2);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  margin-bottom: 0.75rem;
}
.hero-mg h1 { color: #fff; margin-bottom: 0.45rem; }
.hero-mg .lead { color: rgba(255,255,255,0.9); margin: 0; max-width: 34rem; line-height: 1.4; font-size: 1rem; }
.hero-mg .cta-row { margin-top: 1.2rem; display: flex; gap: 0.65rem; flex-wrap: wrap; }
.hero-mg .btn-mg { width: auto; min-width: 140px; padding: 0.8rem 1.2rem; }
.hero-mg .btn-mg.primary { background: #fff; color: var(--mg-red); }
.hero-mg .btn-mg.ghost {
  background: rgba(255,255,255,0.18);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.35);
}

.panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.15rem 1.2rem;
  margin: 0.85rem 0;
  box-shadow: var(--shadow);
}
.grid { display: grid; gap: 0.85rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.panel h2 { margin-bottom: 0.35rem; }
.muted { color: var(--muted); line-height: 1.4; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; font-size: 0.85rem; }

.plus-card {
  background: linear-gradient(165deg, var(--mg-grad-a), var(--mg-grad-b));
  border-radius: 22px;
  padding: 1.15rem;
  color: #fff;
  margin: 0.85rem 0 1rem;
}
.plus-card .plus-top {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.85rem; font-weight: 800;
}
.plus-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}
.plus-tile {
  background: #fff;
  color: var(--ink);
  border-radius: 16px;
  padding: 0.85rem;
}
.plus-tile .label { color: var(--muted); font-size: 0.78rem; font-weight: 600; }
.plus-tile .value { font-size: 1.45rem; font-weight: 800; margin-top: 0.2rem; }
.plus-tile.wide { grid-column: 1 / -1; }

/* legacy helpers used in other templates */
label { display: block; font-size: 0.82rem; color: var(--muted); margin: 0.75rem 0 0.3rem; font-weight: 600; }
input, select {
  width: 100%; padding: 0.8rem 0.9rem; border-radius: 12px;
  border: 1.5px solid var(--line); background: #fff; color: var(--ink); font: inherit;
}
input:focus, select:focus { outline: none; border-color: var(--mg-red); box-shadow: 0 0 0 3px rgba(227,6,19,.12); }
button, .btn {
  display: inline-flex; align-items: center; justify-content: center;
  margin-top: 0.85rem; padding: 0.8rem 1.15rem;
  border-radius: 14px; border: 0; background: var(--mg-red); color: #fff;
  font-weight: 700; cursor: pointer; text-decoration: none; font: inherit;
}
button.secondary, .btn.secondary { background: #fff; color: var(--ink); border: 1.5px solid var(--line); }
button.danger { background: var(--danger); }
button.full, .btn.full { width: 100%; }
.inline { display: inline; margin: 0; }
.inline button {
  margin: 0; padding: 0.35rem 0.7rem; font-size: 0.85rem;
  background: #fff; color: var(--muted); border: 1px solid var(--line);
}
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.55rem 0.35rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.badge {
  display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px;
  background: #eee; font-size: 0.75rem; font-weight: 700;
}
.badge.ok { background: #e3f5ea; color: var(--ok); }
.badge.wait { background: #fff3dc; color: var(--wait); }
.badge.bad { background: #ffe8ea; color: var(--mg-red); }
.qr { background: #fff; padding: 12px; border-radius: 12px; display: inline-block; border: 1px solid var(--line); }
.stat { font-size: 2rem; font-weight: 800; color: var(--mg-red); }
.cta-row { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1rem; }

@media (max-width: 640px) {
  .wrap { padding: 1rem 1rem 3rem; }
  .auth-page { padding: 1.25rem 1rem 1.75rem; border-radius: 18px; }
  .plus-grid { grid-template-columns: 1fr 1fr; }
}

/* —— email registration / login extras —— */
.note {
  background: #e6f6ec;
  color: var(--ok);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  margin: 0 0 1rem;
  font-size: 0.92rem;
  line-height: 1.35;
}
.auth-foot + .auth-foot { margin-top: 0.45rem; }
form.auth-foot { display: block; }
.link-btn {
  display: inline; margin: 0; padding: 0;
  background: none; border: 0;
  color: var(--mg-red); font: inherit; font-weight: 700; cursor: pointer;
}
