:root {
  --bg: #0f1115; --panel: #171a21; --panel2: #1e222b; --line: #2a2f3a;
  --text: #e8eaf0; --muted: #8b93a5; --accent: #ff6a3d; --accent2: #e5385a;
  --ok: #3ccf8e; --warn: #f5b84b; --bad: #ff5d6c; --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--bad); min-height: 1.2em; margin: 4px 0; font-size: 14px; }
h1, h2 { margin: 0 0 6px; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 24px; } h2 { font-size: 18px; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.brand img { width: 30px; height: 30px; }

label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
input { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font: inherit; font-size: 15px; outline: none; }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,106,61,.18); }
input[type=file] { padding: 8px; }

.btn { border: 0; border-radius: 8px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer; color: var(--text); background: var(--panel2); white-space: nowrap; }
.btn:hover { filter: brightness(1.15); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid rgba(255,93,108,.35); }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.auth-card .brand { margin-bottom: 8px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; padding: 14px 28px; background: rgba(15,17,21,.9); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top-actions { display: flex; gap: 8px; }
main { max-width: 1180px; margin: 0 auto; padding: 24px 28px 80px; display: flex; flex-direction: column; gap: 28px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.add-panel { display: grid; grid-template-columns: 1fr 1.6fr; gap: 24px; align-items: end; }
.add-form { display: grid; grid-template-columns: 1.3fr 1fr 1fr auto; gap: 10px; align-items: end; }
@media (max-width: 900px) { .add-panel, .add-form { grid-template-columns: 1fr; } }

.section-title { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.count { background: var(--panel2); color: var(--muted); border-radius: 20px; padding: 0 9px; font-size: 13px; }
.cards { display: flex; flex-direction: column; gap: 14px; }
.empty { color: var(--muted); padding: 30px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }

.device { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.device.pending { border-color: rgba(245,184,75,.45); }
.device-head { display: flex; gap: 16px; align-items: center; padding: 16px 20px; flex-wrap: wrap; }
.device-title { flex: 1; min-width: 220px; }
.device-name { font-size: 17px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.device-name button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px; font-size: 14px; }
.device-meta { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin-top: 2px; }
.device-meta code { color: var(--text); font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.device-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.badge { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 20px; }
.badge.ok { background: rgba(60,207,142,.14); color: var(--ok); }
.badge.warn { background: rgba(245,184,75,.14); color: var(--warn); }
.badge.off { background: rgba(139,147,165,.16); color: var(--muted); }
.notice { margin: 0 20px 14px; padding: 10px 14px; border-radius: 8px; background: rgba(245,184,75,.1); color: var(--warn); font-size: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.playlists { border-top: 1px solid var(--line); background: var(--panel2); padding: 10px 20px 16px; }
.pl-head { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 8px; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.pl { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.pl:last-child { border-bottom: 0; }
.pl-info { flex: 1; min-width: 220px; }
.pl-name { font-weight: 600; }
.pl-sub { color: var(--muted); font-size: 13px; word-break: break-all; }
.pl-type { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 2px 7px; border-radius: 5px; background: var(--bg); color: var(--accent); margin-right: 6px; }
.pl-actions { display: flex; gap: 6px; }
.pl-test { font-size: 13px; width: 100%; }
.pl-test.ok { color: var(--ok); } .pl-test.bad { color: var(--bad); }
.pl.disabled .pl-name { color: var(--muted); text-decoration: line-through; }
.no-pl { color: var(--muted); font-size: 14px; padding: 6px 0; }

dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); padding: 0; width: min(560px, 94vw); }
dialog::backdrop { background: rgba(0,0,0,.6); }
.dialog { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.span2 { grid-column: span 2; }
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 3px; }
.seg button { flex: 1; border: 0; background: none; color: var(--muted); padding: 8px; border-radius: 6px; font: inherit; font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--panel2); color: var(--text); }

.bill-panel h3 { font-size: 15px; margin: 22px 0 10px; }
.bill-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.bill-grid.two { grid-template-columns: 1fr 1fr; }
.bill-grid.three { grid-template-columns: 1.4fr 1.4fr 1fr; }
@media (max-width: 800px) { .bill-grid, .bill-grid.two, .bill-grid.three { grid-template-columns: 1fr; } }
select { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font: inherit; }
.bill-actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
code { background: var(--bg); padding: 1px 6px; border-radius: 5px; font-size: 13px; }
.lic { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 20px; }
.lic.trial { background: rgba(245,184,75,.14); color: var(--warn); }
.lic.active { background: rgba(60,207,142,.14); color: var(--ok); }
.lic.expired { background: rgba(255,93,108,.14); color: var(--bad); }
.lic-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 0 20px 14px; color: var(--muted); font-size: 13px; }
.radio-panel h3 { font-size: 15px; margin: 22px 0 10px; }
.radio-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.radio-actions { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.switch { flex-direction: row; align-items: center; gap: 10px; color: var(--text); font-size: 14px; cursor: pointer; }
.switch input { display: none; }
.switch span { width: 42px; height: 24px; border-radius: 12px; background: var(--line); position: relative; transition: .2s; }
.switch span:after { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span:after { left: 21px; }
.radio-form { display: grid; grid-template-columns: 1fr 2fr 90px 1fr; gap: 10px; align-items: end; }
.radio-form .span2 { grid-column: span 2; }
.radio-form-btns { grid-column: span 2; display: flex; gap: 8px; }
@media (max-width: 800px) { .radio-form { grid-template-columns: 1fr; } .radio-form .span2, .radio-form-btns { grid-column: auto; } }
.radio-search { display: flex; gap: 8px; }
.radio-search #radioQ { flex: 1; }
.radio-search #radioCc { width: 120px; }
.radio-list { margin-top: 8px; }
.rs { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.rs:last-child { border-bottom: 0; }
.rs img, .rs .nologo { width: 36px; height: 36px; border-radius: 8px; object-fit: contain; background: var(--panel2); flex: none; }
.rs-info { flex: 1; min-width: 0; }
.rs-name { font-weight: 600; }
.rs-sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rs.is-hidden .rs-name { color: var(--muted); text-decoration: line-through; }

.msg { align-items: flex-start; }
.msg.unread .rs-name { color: var(--accent); }
.msg-text { white-space: pre-wrap; margin-top: 6px; font-size: 14px; color: #cfd3de; }
.legal-panel h3 { font-size: 15px; margin: 22px 0 10px; }
.legal-panel a, .site-foot a { color: var(--muted); }
.site-foot { text-align: center; color: var(--muted); font-size: 13px; padding: 24px 16px 40px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--panel2); border: 1px solid var(--line); padding: 10px 18px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translateX(-50%); }
