:root {
  --accent: #d13f35;
  --accent-strong: #9f2f28;
  --accent-soft: #fff1ef;
  --text: #162033;
  --muted: #64748b;
  --line: #d8e0ee;
  --surface: #ffffff;
  --bg: #f4f6fb;
  --ok: #16a34a;
  --ok-soft: #e8f7ee;
  --warn: #b45309;
  --warn-soft: #fff6e5;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #e5554b;
    --accent-strong: #c4473e;
    --accent-soft: #3a1d1b;
    --text: #e8ecf4;
    --muted: #98a3b8;
    --line: #2a3346;
    --surface: #161c28;
    --bg: #0d121b;
    --ok: #34d399;
    --ok-soft: #12291f;
    --warn: #fbbf24;
    --warn-soft: #2d2410;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, Consolas, "Courier New", monospace; font-size: 15px; letter-spacing: .3px; }
.center { text-align: center; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  max-width: 560px; width: 100%; margin: 0 auto;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.logo { font-weight: 800; font-size: 24px; color: var(--accent); letter-spacing: 1px; }
.sub { color: var(--muted); font-size: 14px; }

main { flex: 1; width: 100%; max-width: 560px; margin: 0 auto; padding: 0 16px 24px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 14px;
}
h1 { font-size: 22px; margin: 0 0 6px; }
h2 { font-size: 18px; margin: 0; }
.card > p { margin: 8px 0 14px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.device { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; }
.device .right { text-align: right; }

label { display: block; font-size: 14px; font-weight: 600; margin: 12px 0 0; }
input {
  display: block; width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.btn {
  display: block; width: 100%;
  margin-top: 14px;
  padding: 13px 16px;
  font-size: 16px; font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn:disabled { opacity: .6; cursor: default; }
.link { background: none; border: 0; color: var(--accent); font-size: 15px; font-weight: 600; cursor: pointer; padding: 6px; }

.err { color: var(--accent); font-size: 14px; margin: 10px 0 0; }
.help { margin-top: 14px; font-size: 14px; }
.help summary { cursor: pointer; color: var(--muted); }
.help p { margin: 8px 0 0; }
.tip { margin: 10px 0 0; text-align: center; }

.badge {
  font-size: 13px; font-weight: 700;
  padding: 4px 10px; border-radius: 999px;
  background: var(--line); color: var(--muted);
  white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.off { background: var(--accent-soft); color: var(--accent); }

.lists { list-style: none; margin: 12px 0 0; padding: 0; }
.lists li {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.lists li:first-child { border-top: 0; }
.lists .info { flex: 1; min-width: 0; }
.lists .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lists .meta { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lists .icon-btn {
  flex: none;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 10px; font-size: 14px; cursor: pointer;
}
.lists .icon-btn.danger { color: var(--accent); }

dialog {
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  border: 0; border-radius: var(--radius-lg);
  padding: 20px 18px;
  background: var(--surface); color: var(--text);
  overflow: auto;
}
dialog::backdrop { background: rgba(10, 14, 22, .55); }
.actions { display: flex; gap: 10px; }
.actions .btn { flex: 1; }

.tabs { display: flex; gap: 6px; margin-top: 14px; background: var(--bg); padding: 4px; border-radius: var(--radius-md); }
.tab {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  padding: 10px; border-radius: var(--radius-sm); font-size: 15px; font-weight: 600; cursor: pointer;
}
.tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.plans { display: grid; gap: 10px; margin-top: 14px; }
.plan {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px;
  border: 2px solid var(--line); border-radius: var(--radius-md);
  background: var(--surface); color: var(--text);
  font-size: 16px; cursor: pointer; text-align: left;
}
.plan.active { border-color: var(--accent); background: var(--accent-soft); }
.plan .p-name { font-weight: 700; }
.plan .p-days { font-size: 13px; color: var(--muted); }
.plan .p-price { font-weight: 800; font-size: 18px; }

#pay-qr { display: block; margin: 14px auto; background: #fff; padding: 8px; border-radius: var(--radius-md); }
.waiting { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 14px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--warn); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.ok-icon {
  width: 64px; height: 64px; margin: 4px auto 12px;
  border-radius: 50%; background: var(--ok-soft); color: var(--ok);
  font-size: 34px; font-weight: 800; line-height: 64px;
}

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--text); color: var(--surface);
  padding: 10px 16px; border-radius: 999px; font-size: 14px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
  z-index: 10;
}

.foot { text-align: center; padding: 16px; }
.foot a { color: var(--muted); }

.btn:focus-visible, .icon-btn:focus-visible, .plan:focus-visible, .tab:focus-visible, .link:focus-visible {
  outline: 3px solid var(--accent-soft);
  outline-offset: 2px;
}

.check { display: flex; align-items: center; gap: 10px; margin-top: 16px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--accent); }
.check-hint { margin: 4px 0 0 30px; }
.lock-tag { color: var(--muted); font-size: 13px; }

.top-actions { display: flex; align-items: center; gap: 6px; }
.lang-btn {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 10px; font-size: 13px; font-weight: 700; cursor: pointer;
}
.lang-btn .flag { width: 24px; height: 16px; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0,0,0,.12); display: block; }
.lang-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.lang-opt {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px;
  border: 2px solid var(--line); border-radius: var(--radius-md);
  background: var(--surface); color: var(--text);
  font-size: 15px; cursor: pointer; text-align: left;
}
.lang-opt .flag { width: 30px; height: 20px; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0,0,0,.12); flex: none; }
.lang-opt.active { border-color: var(--accent); background: var(--accent-soft); font-weight: 700; }
#pix-note:empty { display: none; }
