:root {
    color-scheme: dark;
    --bg: #111318;
    --surface: #191d24;
    --surface-2: #222833;
    --border: #303846;
    --text: #f3f6fb;
    --muted: #96a0af;
    --accent: #1fb7cf;
    --accent-contrast: #031c22;
    --success: #26c485;
    --accent-2: #5a8dee;
    --danger: #ff5f64;
}

* {
    box-sizing: border-box;
}

html {
    height: 100%;
    overflow: hidden;
}

body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    font-family: "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

button,
input,
select,
textarea {
    font: inherit;
}

.prefix-input {
    display: grid;
    grid-template-columns: 42px 1fr;
}

.prefix-input span {
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-right: 0;
    border-radius: 8px 0 0 8px;
    background: var(--surface-2);
    color: var(--text);
    font-weight: 700;
}

.prefix-input input {
    border-radius: 0 8px 8px 0;
}

.field-set {
    display: grid;
    gap: 9px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
}

.field-set legend {
    color: var(--muted);
    font-size: 13px;
    padding: 0 6px;
}

.field-error {
    color: var(--danger);
    font-size: 12px;
}

.app-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    border-right: 1px solid var(--border);
    background: #151922;
    padding: 24px;
    overflow: auto;
}

.topbar h2,
.topbar p {
    margin: 0;
}

.topbar p {
    color: var(--muted);
    font-size: 14px;
}

.account.sidebar-account {
    display: grid;
    gap: 10px;
    margin-bottom: 28px;
}

.sidebar-account #account-name {
    color: var(--text);
    font-size: 15px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-account .button {
    width: 100%;
}

.nav {
    display: grid;
    gap: 8px;
}

.nav-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    padding: 10px 12px;
    text-align: left;
}

.nav-icon {
    width: 19px;
    height: 19px;
    flex: 0 0 19px;
    object-fit: contain;
}

.nav-item.active,
.nav-item:hover {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
}

.main {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    padding: 28px;
    min-width: 0;
}

.topbar {
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
    min-height: 113px;
}

.topbar::after {
    content: "";
    position: absolute;
    right: 14px;
    bottom: 0;
    left: 14px;
    height: 1px;
    background: var(--border);
}

.status-strip {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.content-view {
    min-height: 0;
    overflow: auto;
    overflow-x: hidden;
}

.status-item {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    min-width: 0;
    padding: 12px 14px;
}

.status-item span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 5px;
    text-transform: uppercase;
}

.status-item strong {
    font-size: 15px;
}

.state-text.online {
    color: var(--success);
}

.state-text.offline {
    color: var(--danger);
}

.account {
    display: flex;
    align-items: center;
    gap: 10px;
}

.button {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    min-height: 38px;
    padding: 8px 13px;
}

.button.primary {
    border-color: transparent;
    background: var(--accent);
    color: var(--accent-contrast);
    font-weight: 700;
}

.button.ghost {
    background: transparent;
}

.button.danger {
    border-color: transparent;
    background: var(--danger);
    color: #150506;
    font-weight: 700;
}

.toolbar {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.field {
    display: grid;
    gap: 7px;
}

.field.compact {
    min-width: 260px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.field span,
.check-field {
    color: var(--muted);
    font-size: 13px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #10141b;
    color: var(--text);
    padding: 10px 11px;
}

textarea {
    resize: vertical;
}

.panel {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    overflow: auto;
    max-width: 100%;
}

.form-panel {
    padding: 16px;
    margin-bottom: 16px;
}

.test-form {
    display: grid;
    gap: 16px;
}

.test-result {
    display: grid;
    gap: 16px;
    padding: 16px;
}

.test-result h3 {
    margin: 10px 0 6px;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin: 0;
}

.result-grid div {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
}

.result-grid dt {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.result-grid dd {
    margin: 6px 0 0;
    overflow-wrap: anywhere;
}

.detail-list {
    margin: 0;
    padding-left: 18px;
    color: var(--muted);
}

table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
}

th,
td {
    border-bottom: 1px solid var(--border);
    padding: 12px 14px;
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

td {
    font-size: 14px;
    overflow-wrap: anywhere;
}

.table-controls {
    display: flex;
    align-items: end;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
}

.table-controls .field {
    min-width: 220px;
}

.control-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.row-actions {
    display: flex;
    justify-content: flex-end;
}

.folder-row td {
    background: #202632;
    color: var(--text);
    font-size: 13px;
    text-transform: uppercase;
}

.folder-button {
    border: 0;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    padding: 0;
}

.folder-row strong {
    color: var(--accent);
    margin-right: 8px;
}

.status-pill {
    display: inline-flex;
    justify-content: center;
    min-width: 78px;
    border-radius: 999px;
    padding: 3px 8px;
    background: rgba(31, 183, 207, 0.16);
    color: var(--accent);
    font-size: 12px;
}

.status-pill.off {
    background: rgba(150, 160, 175, 0.14);
    color: var(--muted);
}

.status-pill.enabled {
    background: rgba(38, 196, 133, 0.14);
    color: var(--success);
}

.status-pill.pending {
    background: rgba(255, 191, 71, 0.16);
    color: #ffbf47;
}

.status-pill.unknown,
.status-pill.error {
    background: rgba(255, 95, 100, 0.14);
    color: var(--danger);
}

.switch {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--muted);
    cursor: pointer;
    min-width: 0;
    user-select: none;
}

.switch span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.switch-track {
    flex: 0 0 44px;
    position: relative;
    width: 44px;
    height: 24px;
    border-radius: 999px;
    background: #3a4352;
    transition: background 160ms ease;
}

.switch-track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    transition: transform 160ms ease;
}

.switch input:checked + .switch-track {
    background: var(--accent);
}

.switch input:checked + .switch-track::after {
    transform: translateX(20px);
}

.muted-text {
    color: var(--muted);
    margin: 0;
}

.muted-small {
    color: var(--muted);
    font-size: 12px;
    margin-top: 4px;
}

.table-empty,
.empty-state {
    padding: 28px;
    color: var(--muted);
    text-align: center;
}

.empty-state {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.empty-state h3 {
    color: var(--text);
    margin-top: 0;
}

.channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(460px, 1fr));
    gap: 16px;
}

.notice {
    border: 1px solid rgba(255, 191, 71, 0.35);
    border-radius: 8px;
    background: rgba(255, 191, 71, 0.09);
    color: #ffd28a;
    margin-bottom: 16px;
    padding: 12px 14px;
}

.notice code {
    color: var(--text);
}

.channel-item {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    padding: 18px;
}

.channel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.channel-title {
    min-width: 0;
}

.channel-title p span,
.channel-summary span,
.feature-heading span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.channel-title h3,
.channel-title p {
    margin: 0;
}

.channel-title h3 {
    font-size: 22px;
}

.channel-title p {
    color: var(--muted);
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: baseline;
    gap: 8px;
    margin-top: 7px;
    overflow-wrap: anywhere;
}

.channel-title p strong {
    color: var(--muted);
    font-weight: 400;
}

.channel-power {
    flex: 0 0 auto;
    margin-top: 22px;
}

.channel-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.channel-settings {
    display: flex;
    gap: 12px;
    align-items: end;
    margin-top: 14px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #111720;
}

.channel-summary div {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #141922;
    padding: 10px 12px;
}

.channel-summary strong {
    display: block;
    margin-top: 5px;
}

.summary-online {
    color: var(--success);
}

.summary-offline {
    color: var(--danger);
}

.broadcaster-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #141922;
    margin-top: 14px;
    padding: 12px;
}

.broadcaster-box > div {
    display: grid;
    gap: 7px;
    min-width: 0;
}

.broadcaster-box strong {
    display: grid;
    gap: 3px;
    overflow-wrap: anywhere;
}

.broadcaster-box strong span,
.broadcaster-box p {
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
}

.broadcaster-box p {
    margin: 0;
}

.broadcaster-box .button {
    flex: 0 0 auto;
}

.feature-heading {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) 88px 190px;
    gap: 12px;
    margin-top: 18px;
    padding: 0 2px;
}

.feature-grid {
    display: grid;
    gap: 8px;
    margin-top: 8px;
}

.feature-row {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) 88px 190px;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #141922;
    padding: 10px;
}

.feature-name {
    color: var(--text);
    font-weight: 700;
}

.feature-toggle {
    justify-content: center;
}

.feature-row select {
    min-width: 0;
}

@media (max-width: 720px) {
    .channel-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .feature-row {
        grid-template-columns: minmax(0, 1fr);
    }

    .feature-heading {
        display: none;
    }

    .channel-header,
    .broadcaster-box,
    .channel-settings,
    .channel-summary {
        grid-template-columns: 1fr;
    }

    .channel-header,
    .broadcaster-box {
        display: grid;
    }

    .channel-power {
        margin-top: 0;
    }
}

dialog {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    width: min(560px, calc(100vw - 28px));
    padding: 0;
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.64);
}

.dialog-form {
    display: grid;
    gap: 16px;
    padding: 18px;
}

.dialog-form header,
.dialog-form footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.dialog-form h3 {
    margin: 0;
}

.dialog-actions {
    display: flex;
    gap: 8px;
}

.icon-button {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-family: "Segoe UI Symbol", "Segoe UI", Arial, sans-serif;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    padding: 0;
}

.icon-button:hover {
    border-color: var(--border);
    background: var(--surface-2);
    color: var(--text);
}

.check-field {
    display: flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    user-select: none;
}

.check-field input[type="checkbox"] {
    position: relative;
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    appearance: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #10141b;
    cursor: pointer;
    padding: 0;
    transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.check-field input[type="checkbox"]::after {
    content: "";
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid var(--accent-contrast);
    border-width: 0 2px 2px 0;
    opacity: 0;
    transform: rotate(45deg) scale(0.8);
    transition: opacity 120ms ease;
}

.check-field input[type="checkbox"]:checked {
    border-color: var(--accent);
    background: var(--accent);
}

.check-field input[type="checkbox"]:checked::after {
    opacity: 1;
}

.check-field input[type="checkbox"]:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 3px rgba(31, 183, 207, 0.2);
}

.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    padding: 12px 14px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.35);
}

.hidden {
    display: none !important;
}

@media (max-width: 760px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .topbar,
    .toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar {
        min-height: auto;
        padding-bottom: 16px;
    }

    .status-strip {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .account {
        justify-content: space-between;
    }

    th:nth-child(2),
    td:nth-child(2) {
        display: none;
    }
}
