:root {
  --ink: #111318;
  --ink-soft: #3a3d46;
  --mute: #6f7380;
  --line: #e6e4df;
  --page: #f3f1ec;
  --card: #ffffff;
  --rausch: #e11d48;
  --rausch-deep: #be123c;
  --good: #0f9f6e;
  --warn: #c2410c;
  --side: #111318;
  --side-text: #c9cdd6;
  --side-dim: #8b909c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(17, 19, 24, .06), 0 12px 32px rgba(17, 19, 24, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--page);
  color: var(--ink);
  font-family: "DM Sans", "Avenir Next", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}
[hidden] { display: none !important; }
body[data-screen="login"] { overflow: hidden; }
body[data-screen="login"] #shell {
  display: none !important;
  visibility: hidden;
  pointer-events: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.03em; }
h1 { font-size: 26px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 650; }

body[data-screen="login"] #shell { display: none !important; }
body[data-screen="app"] #gate { display: none !important; }
body[data-screen="app"] #shell {
  display: grid !important;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

#gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(225, 29, 72, .18), transparent 55%),
    linear-gradient(180deg, #17181d 0%, #111318 100%);
}

.login {
  width: min(420px, 100%);
  background: var(--card);
  border-radius: 28px;
  padding: 32px;
  display: grid;
  gap: 14px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .28);
}
.login .brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--rausch), var(--rausch-deep));
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 20px;
}
.kicker {
  margin: 0 0 6px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--rausch);
  font-size: 11px;
  font-weight: 700;
}
.lede { color: var(--mute); margin: 0 0 8px; }
.enroll {
  display: grid;
  gap: 8px;
  justify-items: center;
  background: var(--page);
  border-radius: 16px;
  padding: 16px;
  text-align: center;
  color: var(--mute);
  font-size: 13px;
}
.enroll img { background: #fff; border-radius: 12px; }
.enroll code {
  font-size: 13px;
  background: #fff;
  padding: 6px 10px;
  border-radius: 8px;
  word-break: break-all;
}
label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; }
input, select, textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  font-weight: 400;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(225, 29, 72, .25);
  border-color: var(--rausch);
}
textarea { min-height: 88px; resize: vertical; }
button {
  background: var(--ink);
  color: #fff;
  border: 0;
  border-radius: 12px;
  padding: 11px 14px;
  cursor: pointer;
  font-weight: 650;
}
button:hover { filter: brightness(1.06); }
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.warn { background: var(--warn); }
button:disabled { opacity: .5; cursor: default; }
.error { color: #b42318; margin: 0; }

aside {
  background: var(--side);
  color: #f4f4f4;
  padding: 22px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  color: #fff;
  text-decoration: none;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
}
.brand span {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--rausch), var(--rausch-deep));
  font-size: 15px;
}
.aside-live {
  margin: 0;
  color: var(--side-dim);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; display: inline-block; }
.nav-label {
  margin: 10px 8px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #6d7380;
}
aside nav { display: grid; gap: 2px; flex: 1; overflow: auto; }
aside nav button {
  text-align: left;
  background: transparent;
  color: var(--side-text);
  font-weight: 500;
  border-radius: 10px;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
aside nav button svg {
  width: 16px;
  height: 16px;
  flex: none;
  opacity: .8;
}
aside nav button.on {
  background: #fff;
  color: var(--ink);
}
aside nav button.on svg { opacity: 1; }
aside #logout {
  background: transparent;
  color: var(--side-text);
  border: 1px solid #2a2d36;
}
.aside-user {
  margin: 0;
  padding: 0 8px;
  color: var(--side-dim);
  font-size: 12px;
  word-break: break-all;
}
main {
  padding: 28px 32px 56px;
  min-width: 0;
  overflow-x: hidden;
}
.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 22px;
}
.live-pill {
  background: #ecfdf3;
  color: var(--good);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}
.kpi {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.card, .table-wrap, .editor {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
  box-shadow: var(--shadow);
}
.card strong { display: block; font-size: 28px; letter-spacing: -0.04em; }
.card span { color: var(--mute); font-size: 13px; }
.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, .8fr);
  gap: 14px;
  align-items: start;
}
.bars { display: grid; gap: 10px; }
.bar { display: grid; grid-template-columns: 1fr auto; gap: 8px; font-size: 13px; }
.bar i {
  display: block;
  height: 8px;
  border-radius: 99px;
  background: linear-gradient(90deg, #e11d48, #111318);
  margin-top: 6px;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--mute); font-weight: 600; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #faf9f6; }
.table-wrap { overflow-x: auto; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}
.row > label input[type="checkbox"] { width: auto; }
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 16px;
  align-items: start;
}
.checks {
  max-height: 180px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  display: grid;
  gap: 4px;
  background: #fff;
}
.checks label { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.phone {
  background: #111318;
  border-radius: 36px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.screen { background: #f6f5f3; border-radius: 26px; min-height: 280px; padding: 14px; overflow: hidden; }
.ad-card { background: #fff; border-radius: 16px; overflow: hidden; }
.ad-card img { width: 100%; display: block; object-fit: cover; }
.ad-copy { padding: 12px; }
.tag { color: var(--mute); font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.muted { color: var(--mute); }
.size-hint {
  font-size: 12px;
  color: var(--mute);
  background: var(--page);
  border-radius: 10px;
  padding: 10px 12px;
}
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  background: var(--page);
  color: var(--ink-soft);
}
.badge.on { background: #ecfdf3; color: var(--good); }
.badge.off { background: #fff1f2; color: var(--rausch); }
#toast {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: var(--ink);
  color: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  z-index: 20;
}
#toast.bad { background: #b42318; }
.range { display: flex; gap: 6px; }
.range button { background: #fff; color: var(--ink); border: 1px solid var(--line); padding: 8px 12px; }
.range button.on { background: var(--ink); color: #fff; }
canvas { width: 100%; height: 180px; display: block; }
@media (max-width: 980px) {
  body[data-screen="app"] #shell { grid-template-columns: 1fr; }
  aside { height: auto; position: static; }
  aside nav { grid-auto-flow: column; overflow: auto; }
  .nav-label { display: none; }
  .grid-2, .layout { grid-template-columns: 1fr; }
  main { padding: 18px; }
}
