:root {
    color-scheme: dark;
    --bg: #11131a;
    --panel: #1b1f2a;
    --panel-soft: #232938;
    --text: #f3f5f8;
    --muted: #aab2c0;
    --line: #303848;
    --accent: #f5b942;
    --good: #43c47a;
    --bad: #ff6474;
    --info: #63a6ff;
}

* { box-sizing: border-box; }
html, body {
    max-width: 100%;
    overflow-x: hidden;
}
body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    display: grid;
    grid-template-columns: 260px 1fr;
}

a { color: inherit; text-decoration: none; }
.sidebar {
    min-height: 100vh;
    border-right: 1px solid var(--line);
    background: linear-gradient(180deg, #161a24 0%, #121620 100%);
    padding: 18px 14px;
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 18px;
    margin-bottom: 24px;
    padding: 6px 8px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; background: var(--accent); color: #171717; border-radius: 8px; font-size: 13px; }
.brand-logo {
    width: 42px;
    height: 42px;
    object-fit: contain;
    border-radius: 8px;
    background: var(--panel-soft);
    border: 1px solid rgba(255, 255, 255, .08);
}
.side-nav {
    display: grid;
    gap: 6px;
}
.side-nav a, .logout {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 42px;
    padding: 11px 12px 11px 16px;
    border-radius: 8px;
    color: var(--muted);
    background: transparent;
    font-weight: 700;
    letter-spacing: 0;
    transition: background .16s ease, color .16s ease, border-color .16s ease;
}
.side-nav a::before {
    content: "";
    width: 4px;
    height: 18px;
    border-radius: 999px;
    background: transparent;
    position: absolute;
    left: 6px;
}
.side-nav a:hover, .logout:hover {
    background: rgba(255, 255, 255, .055);
    color: var(--text);
}
.side-nav a.active {
    background: rgba(245, 185, 66, .14);
    color: #ffe2a3;
}
.side-nav a.active::before {
    background: var(--accent);
}
.logout {
    margin-top: 18px;
    color: #ff8793;
    border: 1px solid rgba(255, 100, 116, .18);
    background: rgba(255, 100, 116, .06);
}
.menu-toggle, .menu-scrim { display: none; }
.main { padding: 28px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; gap: 18px; align-items: center; margin-bottom: 22px; }
h1, h2, p { margin-top: 0; }
h1 { font-size: 30px; margin-bottom: 6px; }
h2 { font-size: 18px; margin-bottom: 16px; }
p, small { color: var(--muted); }
.section-head { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; margin-bottom: 16px; }
.section-head h2 { margin-bottom: 4px; }
.button, button {
    border: 0;
    border-radius: 8px;
    padding: 11px 15px;
    background: var(--accent);
    color: #171717;
    font-weight: 800;
    cursor: pointer;
}
.button.muted { background: var(--panel-soft); color: var(--text); }
.button.danger { background: var(--bad); color: #fff; }
.panel, .auth-panel, .stats article {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    min-width: 0;
}
.auth-panel { max-width: 420px; margin: 10vh auto; }
.alert {
    background: rgba(245, 185, 66, .14);
    border: 1px solid rgba(245, 185, 66, .35);
    color: #ffe2a3;
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 18px;
}
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.stats strong { display: block; font-size: 32px; }
.stats span { color: var(--muted); }
.dashboard-stats .stat-card {
    position: relative;
    overflow: hidden;
    min-height: 118px;
    display: grid;
    align-content: space-between;
    border-color: rgba(255, 255, 255, .09);
}
.dashboard-stats .stat-card::after {
    content: "";
    position: absolute;
    inset: auto -40px -54px auto;
    width: 135px;
    height: 135px;
    border-radius: 50%;
    opacity: .18;
    background: currentColor;
}
.stat-card span,
.stat-card small {
    position: relative;
    z-index: 1;
}
.stat-card strong {
    position: relative;
    z-index: 1;
    line-height: 1;
}
.stat-card.clients { color: #f5b942; background: linear-gradient(135deg, rgba(245, 185, 66, .18), var(--panel) 62%); }
.stat-card.active { color: #43c47a; background: linear-gradient(135deg, rgba(67, 196, 122, .17), var(--panel) 62%); }
.stat-card.playlists { color: #63a6ff; background: linear-gradient(135deg, rgba(99, 166, 255, .18), var(--panel) 62%); }
.stat-card.logs { color: #ff8793; background: linear-gradient(135deg, rgba(255, 100, 116, .15), var(--panel) 62%); }
.stat-card span { color: #d8deea; font-weight: 800; }
.stat-card small { color: var(--muted); }
.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, .6fr);
    gap: 14px;
    margin-bottom: 22px;
}
.growth-panel,
.quick-panel {
    min-height: 220px;
}
.growth-chart {
    height: 128px;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 10px;
    align-items: end;
    padding-top: 6px;
}
.growth-day {
    height: 100%;
    display: grid;
    grid-template-rows: 22px 1fr 20px;
    gap: 6px;
    align-items: end;
    min-width: 0;
}
.growth-day span {
    color: var(--text);
    font-weight: 800;
    text-align: center;
    font-size: 13px;
}
.growth-day i {
    display: block;
    width: 100%;
    min-height: 6px;
    align-self: end;
    border-radius: 8px 8px 3px 3px;
    background: linear-gradient(180deg, #f5b942, #63a6ff);
    box-shadow: 0 8px 24px rgba(99, 166, 255, .18);
}
.growth-day small {
    text-align: center;
    font-size: 12px;
    white-space: nowrap;
}
.quick-list {
    display: grid;
    gap: 10px;
}
.quick-list div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #151923;
}
.quick-list span {
    color: var(--muted);
}
.quick-list strong {
    font-size: 18px;
    color: var(--text);
}
.server-panel { margin-bottom: 22px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric {
    background: #151923;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}
.metric span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.metric strong { display: block; font-size: 26px; margin-bottom: 8px; }
.bar { height: 8px; background: #10141d; border-radius: 999px; overflow: hidden; margin-bottom: 8px; }
.bar i { display: block; height: 100%; min-width: 2px; max-width: 100%; background: var(--accent); }
.upload-progress {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid rgba(99, 166, 255, .35);
    border-radius: 8px;
    background: rgba(99, 166, 255, .1);
}
.upload-progress[hidden] { display: none; }
.upload-progress-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.upload-progress-head strong,
.upload-progress-head span {
    color: #dbe7ff;
}
.busy-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(7, 10, 16, .78);
    backdrop-filter: blur(4px);
}
.busy-box {
    width: min(420px, 100%);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: 18px;
    box-shadow: 0 20px 70px rgba(0, 0, 0, .35);
}
.busy-spinner {
    width: 38px;
    height: 38px;
    border: 4px solid rgba(245, 185, 66, .2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .9s linear infinite;
    margin-bottom: 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.server-meta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; color: var(--muted); font-size: 13px; }
.server-meta span { background: var(--panel-soft); border-radius: 999px; padding: 6px 9px; }
.grid.two { display: grid; grid-template-columns: minmax(320px, 420px) 1fr; gap: 18px; align-items: start; }
.template-workspace {
    display: grid;
    grid-template-columns: minmax(340px, 500px) minmax(420px, 1fr);
    gap: 12px;
    align-items: start;
}
.template-workspace.is-editing {
    grid-template-columns: minmax(320px, .9fr) minmax(360px, 1fr) minmax(340px, .95fr);
}
.template-edit-panel,
.add-channel-panel,
.templates-saved-panel {
    align-self: stretch;
}
.template-edit-panel,
.add-channel-panel {
    gap: 9px;
    padding: 14px;
}
.template-edit-panel h2,
.add-channel-panel h2,
.templates-saved-panel h2 {
    margin-bottom: 8px;
}
.template-edit-panel label,
.add-channel-panel label {
    gap: 5px;
}
.template-edit-panel input,
.template-edit-panel select,
.template-edit-panel textarea,
.add-channel-panel input,
.add-channel-panel select,
.add-channel-panel textarea {
    padding: 9px 10px;
    min-height: 38px;
}
.template-edit-panel textarea {
    min-height: 82px;
    max-height: 118px;
}
.add-channel-panel p {
    margin-bottom: 2px;
    line-height: 1.35;
}
.add-channel-panel small {
    font-size: 12px;
}
.add-channel-panel button[type="submit"],
.template-edit-panel button[type="submit"] {
    min-height: 40px;
    padding: 9px 12px;
}
.templates-saved-panel {
    padding: 14px;
    overflow: visible;
}
.template-workspace.is-editing .templates-saved-panel {
    max-height: 604px;
    overflow: auto;
}
.template-workspace.is-creating .templates-saved-panel .template-list {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.templates-saved-panel .template-list {
    gap: 7px;
}
.templates-saved-panel .template-card {
    padding: 9px 10px;
}
.templates-saved-panel .template-main {
    grid-template-columns: 1fr;
    gap: 6px;
}
.templates-saved-panel .template-badges {
    justify-content: flex-start;
}
.templates-saved-panel .template-footer {
    grid-template-columns: 1fr auto;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
}
.templates-saved-panel .actions {
    display: flex;
    gap: 12px;
}
.tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.tabs a {
    padding: 10px 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    background: var(--panel);
}
.tabs a.active { color: #171717; background: var(--accent); border-color: var(--accent); font-weight: 800; }
.form { display: grid; gap: 14px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 14px; }
input, select, textarea {
    width: 100%;
    background: #11151e;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px 12px;
    font: inherit;
}
textarea { min-height: 86px; resize: vertical; }
input[type="file"] { padding: 9px 10px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.form-actions.compact button {
    width: auto;
    inline-size: 190px;
    min-inline-size: 190px;
    block-size: 42px;
    padding: 0 14px;
}
.access-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #11151e;
}
.access-switch label {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 40px;
    border-radius: 6px;
    color: var(--muted);
    cursor: pointer;
    font-weight: 800;
}
.access-switch label.active {
    background: var(--accent);
    color: #171717;
}
.access-switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.access-fields {
    display: grid;
    gap: 14px;
}
.access-fields[hidden] { display: none; }
.list-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 14px;
}
.list-head h2 { margin-bottom: 3px; }
.per-page-form {
    display: flex;
    align-items: end;
    gap: 8px;
}
.per-page-form label {
    min-width: 92px;
}
.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}
.pagination a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    min-height: 36px;
    padding: 8px 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
    color: var(--text);
    font-weight: 800;
}
.pagination a.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #171717;
}
.filter-bar { display: grid; grid-template-columns: minmax(180px, 260px) minmax(220px, 1fr) auto; gap: 12px; align-items: end; }
.search-field {
    position: relative;
    display: block;
}
.search-field::before {
    content: "";
    position: absolute;
    left: 13px;
    top: 50%;
    width: 11px;
    height: 11px;
    border: 2px solid var(--muted);
    border-radius: 999px;
    transform: translateY(-55%);
    opacity: .8;
    pointer-events: none;
}
.search-field::after {
    content: "";
    position: absolute;
    left: 25px;
    top: 50%;
    width: 8px;
    height: 2px;
    border-radius: 999px;
    background: var(--muted);
    transform: translateY(5px) rotate(45deg);
    opacity: .8;
    pointer-events: none;
}
.search-field input {
    padding-left: 42px;
}
.transcoder-pagination {
    justify-content: flex-end;
}
.truncate-url { max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-wrap { width: 100%; overflow-x: auto; }
.add-device-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.add-device-btn span {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    background: rgba(245, 185, 66, .18);
    color: var(--accent);
    font-size: 17px;
    line-height: 1;
}
.device-group {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #151923;
}
.device-group[hidden] { display: none; }
.device-group h3 {
    margin: 0;
    color: var(--text);
    font-size: 15px;
}
.device-group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.device-group-head .icon-btn {
    margin-right: 0;
    width: 30px;
    height: 30px;
    color: var(--muted);
}
.expiry-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: end; }
.check { display: flex; align-items: center; gap: 9px; }
.check input { width: auto; }
.switch-row {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
    gap: 10px;
    align-items: center;
    min-height: 43px;
    padding-bottom: 0;
    white-space: nowrap;
}
.switch-row span { color: var(--muted); }
.switch-row input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.switch-row i {
    display: block;
    flex: 0 0 auto;
    width: 54px;
    height: 30px;
    border-radius: 999px;
    background: #10141d;
    border: 1px solid var(--line);
    position: relative;
}
.switch-row i::before {
    content: "";
    position: absolute;
    width: 24px;
    height: 24px;
    top: 2px;
    left: 3px;
    border-radius: 50%;
    background: #f3f5f8;
    transition: transform .18s ease, background .18s ease;
}
.switch-row input:checked + i {
    background: rgba(67, 196, 122, .18);
    border-color: rgba(67, 196, 122, .5);
}
.switch-row input:checked + i::before {
    transform: translateX(23px);
    background: var(--good);
}
input:disabled { opacity: .55; cursor: not-allowed; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 12px 10px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 13px; font-weight: 700; }
td small { display: block; margin-top: 4px; word-break: break-all; }
.pill { display: inline-block; padding: 5px 9px; border-radius: 999px; background: var(--panel-soft); color: var(--muted); font-size: 12px; }
.pill.active { background: rgba(67, 196, 122, .16); color: var(--good); }
.pill.blocked { background: rgba(255, 100, 116, .16); color: var(--bad); }
.pill.paused { background: rgba(99, 166, 255, .16); color: var(--info); }
.actions { white-space: nowrap; }
.actions a { color: var(--accent); margin-right: 10px; }
.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    color: var(--accent);
    margin-right: 7px;
    vertical-align: middle;
}
.icon-btn span { line-height: 1; font-size: 16px; }
.icon-btn:hover { border-color: var(--accent); }
.icon-btn.danger { color: var(--bad); }
.icon-btn.danger:hover { border-color: var(--bad); }
.icon-btn.warn { color: var(--info); }
.icon-btn.warn:hover { border-color: var(--info); }
.icon-btn.ok { color: var(--good); }
.icon-btn.ok:hover { border-color: var(--good); }
.mini-link {
    display: inline-block;
    margin: 0 6px 6px 0;
    padding: 5px 8px;
    border-radius: 999px;
    background: var(--panel-soft);
    color: var(--accent);
    font-size: 12px;
}
.template-list { display: grid; gap: 12px; }
.form-stack { display: grid; gap: 18px; }
.assign-playlist-panel {
    gap: 12px;
    padding: 16px;
}
.assign-playlist-panel p {
    margin-bottom: 2px;
    line-height: 1.35;
}
.assigned-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.assigned-head h2 {
    margin-bottom: 3px;
}
.assigned-head > span {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(99, 166, 255, .12);
    color: #bcd8ff;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}
.assigned-list {
    display: grid;
    gap: 8px;
}
.assigned-row {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #151923;
    padding: 10px 12px;
}
.assigned-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
}
.assigned-client {
    min-width: 0;
}
.assigned-client small {
    max-width: 360px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.assigned-count-btn {
    min-height: 38px;
    padding: 8px 12px;
}
.assigned-pagination {
    margin-top: 14px;
}
.template-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(99, 166, 255, .08), rgba(245, 185, 66, .05)),
        #151923;
    padding: 12px;
}
.assigned-card .template-main { align-items: center; }
.template-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
}
.template-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 4px; }
.template-title strong { font-size: 16px; }
.template-card small { word-break: break-word; overflow-wrap: anywhere; }
.template-badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.template-footer {
    border-top: 1px solid var(--line);
    margin-top: 10px;
    padding-top: 10px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
}
.vod-grid { display: grid; gap: 12px; }
.vod-card {
    display: grid;
    grid-template-columns: 100px minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #151923;
}
.vod-poster {
    width: 100px;
    height: 200px;
    border-radius: 8px;
    background: var(--panel-soft);
    overflow: hidden;
    display: grid;
    place-items: center;
    color: var(--muted);
    font-weight: 800;
}
.vod-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.vod-info { min-width: 0; }
.vod-info small { word-break: break-word; overflow-wrap: anywhere; }
.vod-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.vod-actions { margin-top: 10px; white-space: normal; }
.vod-actions a { display: inline-block; margin-bottom: 6px; }
.assign-list { min-width: 0; }
.client-count-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.client-count-btn span {
    display: inline-grid;
    place-items: center;
    min-width: 24px;
    height: 24px;
    border-radius: 999px;
    background: rgba(245, 185, 66, .18);
    color: var(--accent);
    font-size: 12px;
}
.compact-btn {
    min-width: 0;
    padding: 8px 10px;
    white-space: nowrap;
}
.api-docs { margin-bottom: 18px; }
.api-docs code {
    display: block;
    margin-top: 10px;
    padding: 12px;
    border-radius: 8px;
    background: #10141d;
    color: #dbe7ff;
    word-break: break-all;
}
.channel-panel {
    grid-column: 1 / -1;
}
.channel-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 12px;
}
.channel-panel-head h2 {
    margin-bottom: 4px;
}
.channel-panel-head p {
    margin-bottom: 0;
}
.channel-panel-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}
.channel-group-list {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}
.channel-group {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #141923;
    overflow: hidden;
}
.channel-group summary {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    color: var(--text);
    background: rgba(255, 255, 255, .025);
}
.channel-group summary span {
    color: var(--accent);
    font-weight: 800;
}
.channel-list {
    display: grid;
    gap: 6px;
    padding: 0 10px 10px;
}
.channel-row {
    border-top: 1px solid var(--line);
    padding-top: 8px;
}
.channel-edit-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, .72fr) auto;
    gap: 10px;
    align-items: stretch;
}
.channel-main-fields {
    display: grid;
    grid-template-columns: minmax(180px, .7fr) minmax(260px, 1.3fr);
    gap: 8px;
    align-content: start;
}
.channel-logo-editor {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, .06);
    border-radius: 8px;
    background: rgba(255, 255, 255, .025);
}
.channel-logo-preview {
    position: relative;
    width: 54px;
    height: 54px;
}
.channel-logo-editor img,
.channel-logo-preview > span {
    width: 54px;
    height: 54px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #10141d;
}
.channel-logo-editor img {
    object-fit: contain;
}
.channel-logo-preview > span {
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
}
.logo-remove-btn {
    position: absolute;
    top: -7px;
    right: -7px;
    width: 24px;
    min-width: 24px;
    max-width: 24px;
    height: 24px;
    min-height: 24px;
    max-height: 24px;
    padding: 0;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 76, 112, .55);
    border-radius: 999px;
    background: #241722;
    color: var(--bad);
    font: inherit;
    font-size: 14px;
    font-weight: 900;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 6px 14px rgba(0, 0, 0, .25);
    aspect-ratio: 1;
    z-index: 2;
}
.logo-remove-btn:hover {
    border-color: var(--bad);
    background: rgba(255, 76, 112, .16);
}
.logo-remove-btn span {
    transform: translateY(-1px);
}
.channel-logo-editor > div {
    display: grid;
    gap: 7px;
}
.channel-edit-form label {
    margin: 0;
}
.channel-edit-form input {
    min-height: 36px;
    padding: 8px 9px;
}
.channel-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    padding-bottom: 1px;
}
.channel-actions .compact-btn {
    min-height: 32px;
    padding: 7px 9px;
}
.channel-pagination {
    margin-top: 12px;
}
.empty-state {
    color: var(--muted);
    padding: 12px;
    border: 1px dashed var(--line);
    border-radius: 8px;
}
.system-preview {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border-radius: 8px;
    background: #151923;
    border: 1px solid var(--line);
}
.system-preview img { width: 72px; height: 72px; object-fit: contain; border-radius: 8px; background: var(--panel-soft); }
.system-preview strong { display: block; font-size: 20px; margin-bottom: 5px; }
.system-preview small { display: block; }
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 22px;
    background: rgba(0, 0, 0, .62);
    backdrop-filter: blur(4px);
}
.modal-backdrop[hidden] { display: none; }
.confirm-modal {
    width: min(440px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
    box-shadow: 0 22px 70px rgba(0, 0, 0, .45);
}
.confirm-modal h2 { margin-bottom: 8px; }
.confirm-modal p { margin-bottom: 20px; line-height: 1.45; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.list-modal { width: min(560px, 100%); }
.modal-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 18px;
}
.modal-head h2 { margin-bottom: 5px; }
.modal-head p { margin-bottom: 0; }
.modal-head .icon-btn {
    margin-right: 0;
    flex: 0 0 auto;
    color: var(--muted);
}
.client-modal-list {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
    max-height: min(420px, 58vh);
    overflow: auto;
}
.client-modal-list article {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #151923;
}
.client-modal-list small {
    display: block;
    margin-top: 4px;
    word-break: break-all;
}
.playlist-list-modal { width: min(720px, 100%); }
.playlist-modal-list article {
    grid-template-columns: minmax(0, 1fr) auto;
}
.playlist-modal-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}
.playlist-modal-actions .icon-btn { margin-right: 0; }
.device-edit-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 18px;
}
.device-edit-grid .xtream-access-card {
    grid-column: 1 / -1;
    gap: 16px;
    background:
        linear-gradient(135deg, rgba(245, 185, 66, .12), rgba(99, 166, 255, .08)),
        #151923;
}
.device-edit-grid .mac-access-card {
    grid-column: 1 / -1;
    gap: 16px;
    background:
        linear-gradient(135deg, rgba(67, 196, 122, .12), rgba(99, 166, 255, .08)),
        #151923;
}
.device-edit-grid section,
.link-list article {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #151923;
}
.device-edit-grid h3 {
    margin: 0;
    font-size: 15px;
}
.access-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}
.access-card-head small {
    display: block;
    margin-top: 4px;
}
.access-card-head span {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(245, 185, 66, .16);
    color: #ffd984;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}
.credential-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.xtream-access-card .credential-grid label:last-child {
    grid-column: 1 / -1;
    max-width: 220px;
}
.links-modal { width: min(760px, 100%); }
.link-list {
    display: grid;
    gap: 12px;
    margin-bottom: 18px;
    max-height: min(500px, 62vh);
    overflow: auto;
}
.link-list small {
    display: block;
    word-break: break-all;
}
.link-list input {
    font-size: 13px;
}
.empty-state {
    padding: 16px;
    margin-bottom: 18px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    color: var(--muted);
    background: #151923;
}

@media (max-width: 900px) {
    body {
        display: block;
        width: 100%;
        grid-template-columns: none;
    }
    body.menu-open { overflow: hidden; }
    .menu-toggle {
        position: fixed;
        top: 14px;
        right: 14px;
        z-index: 1200;
        display: grid;
        gap: 5px;
        place-content: center;
        width: 44px;
        height: 44px;
        padding: 0;
        background: var(--accent);
        border: 1px solid rgba(0, 0, 0, .18);
        box-shadow: 0 10px 28px rgba(0, 0, 0, .32);
    }
    .menu-toggle span {
        display: block;
        width: 20px;
        height: 2px;
        border-radius: 999px;
        background: #171717;
    }
    .menu-scrim {
        position: fixed;
        inset: 0;
        z-index: 1000;
        display: block;
        background: rgba(0, 0, 0, .58);
        backdrop-filter: blur(2px);
    }
    .menu-scrim[hidden] { display: none; }
    .sidebar {
        position: fixed;
        inset: 0 0 0 auto;
        z-index: 1100;
        width: min(78vw, 280px);
        min-height: 100vh;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity .16s ease, visibility .16s ease;
        box-shadow: -18px 0 50px rgba(0, 0, 0, .36);
        overflow-y: auto;
    }
    body.menu-open .sidebar {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }
    .main {
        width: 100%;
        max-width: 100vw;
        margin: 0;
        overflow-x: hidden;
        padding: 68px 8px 18px;
    }
    .main > * { max-width: 100%; }
    .panel,
    .form,
    .template-card,
    .device-group,
    .clients-table tr {
        max-width: 100%;
        overflow-x: hidden;
    }
    .grid.two > *,
    .stats > *,
    .metric-grid > * {
        min-width: 0;
        width: 100%;
    }
    .grid.two, .stats, .metric-grid, .dashboard-grid, .template-workspace { grid-template-columns: minmax(0, 1fr); }
    .grid.two { gap: 12px; }
    .panel { padding: 12px; }
    .page-head { margin-bottom: 14px; }
    h1 { font-size: 26px; margin-bottom: 4px; }
    h2 { font-size: 17px; margin-bottom: 12px; }
    p { margin-bottom: 12px; }
    .form { gap: 10px; }
    label { gap: 5px; font-size: 13px; }
    input, select, textarea { padding: 9px 10px; border-radius: 7px; }
    .form-actions.compact button {
        width: 100%;
        inline-size: auto;
        min-width: 0;
        min-inline-size: 0;
        block-size: 40px;
    }
    .access-switch { gap: 5px; }
    .access-switch label { min-height: 36px; }
    .list-head {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .per-page-form,
    .per-page-form label {
        width: 100%;
    }
    textarea { min-height: 62px; }
    .button, button { padding: 9px 12px; border-radius: 7px; }
    .add-device-btn { min-height: 38px; }
    .stats, .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
    .stats article { padding: 10px; }
    .stats strong { font-size: 24px; line-height: 1; }
    .stats span { font-size: 12px; }
    .dashboard-stats .stat-card {
        min-height: 96px;
    }
    .dashboard-grid {
        gap: 10px;
        margin-bottom: 12px;
    }
    .growth-panel,
    .quick-panel {
        min-height: 0;
    }
    .growth-chart {
        height: 116px;
        gap: 6px;
    }
    .growth-day {
        grid-template-rows: 18px 1fr 18px;
        gap: 4px;
    }
    .growth-day span,
    .growth-day small {
        font-size: 11px;
    }
    .quick-list {
        gap: 8px;
    }
    .quick-list div {
        padding: 10px;
    }
    .server-panel { margin-bottom: 12px; }
    .section-head { gap: 8px; margin-bottom: 10px; }
    .section-head p { margin-bottom: 0; }
    .filter-bar { grid-template-columns: 1fr; gap: 8px; }
    .truncate-url { max-width: 240px; }
    .metric { padding: 10px; }
    .metric span { font-size: 11px; margin-bottom: 5px; }
    .metric strong { font-size: 20px; margin-bottom: 5px; }
    .metric small { font-size: 11px; }
    .bar { height: 6px; margin-bottom: 5px; }
    .server-meta { gap: 6px; margin-top: 10px; font-size: 11px; }
    .server-meta span { padding: 5px 7px; }
    table:not(.clients-table) {
        display: block;
        overflow-x: auto;
        font-size: 12px;
        white-space: nowrap;
    }
    table:not(.clients-table) th,
    table:not(.clients-table) td {
        padding: 8px 7px;
    }
    .template-list { gap: 8px; }
    .form-stack { gap: 12px; }
    .template-card { padding: 10px; }
    .template-workspace {
        gap: 10px;
    }
    .template-edit-panel,
    .add-channel-panel {
        gap: 9px;
    }
    .template-edit-panel textarea {
        min-height: 78px;
        max-height: 120px;
    }
    .templates-saved-panel {
        max-height: none;
        overflow: visible;
    }
    .assign-playlist-panel {
        gap: 9px;
        padding: 12px;
    }
    .assigned-head {
        align-items: stretch;
        flex-direction: column;
        gap: 8px;
        margin-bottom: 10px;
    }
    .assigned-head > span {
        justify-content: center;
        width: 100%;
    }
    .assigned-list {
        gap: 7px;
    }
    .assigned-row {
        padding: 9px;
    }
    .assigned-main {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .assigned-client small {
        max-width: 100%;
        white-space: normal;
    }
    .assigned-count-btn {
        width: 100%;
        justify-content: center;
        min-height: 36px;
    }
    .vod-grid { gap: 8px; }
    .vod-card {
        grid-template-columns: 74px minmax(0, 1fr);
        gap: 10px;
        padding: 10px;
    }
    .vod-poster {
        width: 74px;
        height: 148px;
    }
    .template-main { gap: 8px; }
    .template-title { gap: 6px; margin-bottom: 3px; }
    .template-title strong { font-size: 15px; }
    .template-badges { gap: 5px; }
    .template-footer { margin-top: 8px; padding-top: 8px; gap: 8px; }
    .channel-panel-head {
        flex-direction: column;
        gap: 8px;
    }
    .channel-panel-badges {
        justify-content: flex-start;
    }
    .channel-group-list {
        gap: 7px;
    }
    .channel-group summary {
        padding: 9px 10px;
    }
    .channel-list {
        padding: 0 8px 8px;
    }
    .pill { padding: 4px 7px; font-size: 11px; }
    .compact-btn { padding: 7px 9px; }
    .api-docs { margin-bottom: 10px; }
    .api-docs code {
        margin-top: 7px;
        padding: 9px;
        font-size: 12px;
        line-height: 1.35;
    }
    .system-preview {
        gap: 10px;
        padding: 10px;
    }
    .system-preview img,
    .system-preview .brand-mark {
        width: 54px;
        height: 54px;
    }
    .system-preview strong { font-size: 17px; margin-bottom: 3px; }
    .alert { padding: 9px 10px; margin-bottom: 10px; }
    .clients-table,
    .clients-table tbody,
    .clients-table tr,
    .clients-table td {
        display: block;
        width: 100%;
    }
    .clients-table thead { display: none; }
    .clients-table tr {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        padding: 12px;
        margin-bottom: 10px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #151923;
    }
    .clients-table tr:last-child { margin-bottom: 0; }
    .clients-table td {
        width: auto;
        border-bottom: 0;
        padding: 0;
        min-width: 0;
    }
    .clients-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 4px;
        color: var(--muted);
        font-size: 11px;
        font-weight: 800;
    }
    .clients-table td:first-child {
        grid-column: 1 / -1;
        padding-top: 0;
        font-size: 16px;
    }
    .clients-table td:first-child::before { display: none; }
    .clients-table .actions {
        display: flex;
        gap: 8px;
        white-space: normal;
    }
    .clients-table .actions a { margin-right: 0; }
    .clients-table .compact-btn,
    .clients-table .client-count-btn {
        width: 100%;
        justify-content: center;
    }
    .clients-table .icon-btn {
        width: 32px;
        height: 32px;
    }
    .expiry-row { grid-template-columns: 1fr; gap: 8px; }
    .expiry-row .switch-row { justify-content: flex-start; }
    .switch-row { min-height: 38px; }
    .tabs { gap: 6px; margin-bottom: 12px; }
    .tabs a { padding: 8px 10px; }
    .pagination {
        justify-content: center;
        gap: 6px;
    }
    .pagination a {
        min-width: 34px;
        min-height: 34px;
        padding: 7px 9px;
    }
    .template-main, .template-footer { grid-template-columns: 1fr; }
    .template-badges { justify-content: flex-start; }
    .page-head { align-items: flex-start; flex-direction: column; }
    .client-modal-list article, .playlist-modal-list article { grid-template-columns: 1fr; }
    .playlist-modal-actions { justify-content: flex-start; }
    .device-edit-grid { grid-template-columns: 1fr; }
    .access-card-head {
        flex-direction: column;
        align-items: flex-start;
    }
    .credential-grid { grid-template-columns: 1fr; }
    .credential-grid label:last-child { max-width: none; }
    .channel-edit-form {
        grid-template-columns: 1fr;
        gap: 7px;
    }
    .channel-main-fields {
        grid-template-columns: 1fr;
    }
    .channel-logo-editor {
        grid-template-columns: 46px minmax(0, 1fr);
        gap: 8px;
    }
    .channel-logo-preview,
    .channel-logo-editor img,
    .channel-logo-preview > span {
        width: 46px;
        height: 46px;
    }
    .logo-remove-btn {
        top: -6px;
        right: -6px;
        width: 22px;
        min-width: 22px;
        max-width: 22px;
        height: 22px;
        min-height: 22px;
        max-height: 22px;
    }
    .channel-actions {
        justify-content: flex-start;
        flex-wrap: wrap;
    }
}
