:root {
  --bg: #f6f6f8;
  --surface: #ffffff;
  --text: #1c1c22;
  --muted: #6b6b76;
  --border: #dcdce3;
  --accent: #4b3f8f;
  --accent-text: #ffffff;
  --warn-bg: #fff4d6;
  --warn-text: #6b4e00;
  --error-bg: #fde4e4;
  --error-text: #8a1c1c;
  --ok: #1d7a43;
  --notif: rgba(245, 245, 248, 0.92);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15151a;
    --surface: #1f1f26;
    --text: #ececf1;
    --muted: #a0a0ad;
    --border: #34343f;
    --accent: #8f82e0;
    --accent-text: #15151a;
    --warn-bg: #3a3014;
    --warn-text: #f2d98b;
    --error-bg: #3d1d1d;
    --error-text: #f4b0b0;
    --ok: #5ccf8c;
    --notif: rgba(60, 60, 70, 0.92);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
main { max-width: 1100px; margin: 0 auto; padding: 16px 16px 48px; }
h1 { font-size: 1.6rem; margin: 0.6em 0 0.5em; }
h2 { font-size: 1.15rem; margin: 1.6em 0 0.5em; }
a { color: var(--accent); }
.muted, .hint { color: var(--muted); }
.hint { font-size: 0.9rem; margin: 0.3em 0 0.8em; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85rem; }

.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.top .brand { font-weight: 700; color: var(--text); text-decoration: none; }
.top nav { display: flex; flex-wrap: wrap; gap: 4px 16px; flex: 1; }
.top nav a { text-decoration: none; color: var(--muted); padding: 2px 0; }
.top nav a[aria-current="page"] { color: var(--text); border-bottom: 2px solid var(--accent); }

.banner { padding: 10px 14px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); }
.banner.warn { background: var(--warn-bg); color: var(--warn-text); border-color: transparent; }
.banner.error { background: var(--error-bg); color: var(--error-text); border-color: transparent; }
.banner ul { margin: 0; padding-left: 1.2em; }
header + .banner { max-width: 1100px; margin: 12px auto 0; border-radius: 0; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 12px 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; }
.card span:last-child { color: var(--muted); font-size: 0.9rem; }
.num { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }

table { border-collapse: collapse; width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
caption { text-align: left; font-weight: 600; padding: 0 0 6px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
.tables { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.tables table { border-radius: 10px; }
.scroll { overflow-x: auto; }
.list td { font-size: 0.93rem; }
.devices input:not([type]) , .devices input[name="label"] { width: 9em; }
tr.invalid td { opacity: 0.6; }

.tag { display: inline-block; font-size: 0.75rem; padding: 0 6px; border-radius: 4px; background: var(--border); color: var(--text); vertical-align: 1px; }
.tag.promo { background: var(--accent); color: var(--accent-text); }
.tag.bad { background: var(--error-bg); color: var(--error-text); }
.status { font-weight: 600; text-transform: capitalize; }
.status.done { color: var(--ok); }
.status.failed { color: var(--error-text); }
.status.cancelled { color: var(--muted); }

form { margin: 0; }
fieldset { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); padding: 12px 14px 4px; margin: 0 0 16px; min-width: 0; }
legend { font-weight: 600; padding: 0 4px; }
label { display: block; margin: 0 0 12px; font-size: 0.9rem; color: var(--muted); }
label.check { display: inline-flex; align-items: center; gap: 6px; color: var(--text); margin-right: 16px; }
input, select, textarea, button {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 7px; padding: 7px 9px;
}
label > input:not([type="checkbox"]), label > select, label > textarea { display: block; width: 100%; margin-top: 4px; }
textarea { resize: vertical; }
input[type="checkbox"] { width: 1.05em; height: 1.05em; accent-color: var(--accent); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 12px; }
.checks { margin: 4px 0 12px; }

button, .button {
  display: inline-block; cursor: pointer; text-decoration: none;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 7px; padding: 8px 14px; font-weight: 600;
}
button.primary, .button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.danger { color: var(--error-text); }
button.link { background: none; border: none; color: var(--muted); padding: 0; font-weight: normal; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }

.cols { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
@media (max-width: 800px) { .cols { grid-template-columns: minmax(0, 1fr); } }
aside { position: sticky; top: 12px; }
@media (max-width: 800px) { aside { position: static; } }

.phone {
  border-radius: 22px; padding: 28px 12px; margin-bottom: 12px;
  background: linear-gradient(160deg, #3d3470, #16142b);
}
.notif { background: var(--notif); border-radius: 14px; padding: 10px 12px; font-size: 0.9rem; color: var(--text); overflow-wrap: anywhere; }
.notif > div:last-child { white-space: pre-line; }
.notif-app { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--muted); margin-bottom: 2px; letter-spacing: 0.04em; }
.notif [hidden] { display: none; }
.audience { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; }
.audience ul { margin: 4px 0 0; padding-left: 1.2em; }
details { margin: 10px 0; }
pre { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px; overflow-x: auto; font-size: 0.8rem; }
progress { width: 100%; height: 10px; accent-color: var(--accent); }
.details { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }
.crumbs { margin: 8px 0 0; font-size: 0.9rem; }

.search { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-bottom: 4px; }
.search input[type="search"] { flex: 1; min-width: 220px; }

.login { max-width: 340px; margin: 12vh auto 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px 22px; }
.login h1 { font-size: 1.3rem; margin-top: 0; }
.login button { width: 100%; }
