:root {
    --bg: #0f1115;
    --surface: #14171c;
    --panel: #181c22;
    --panel-2: #202631;
    --panel-3: #111419;
    --text: #edf2f7;
    --muted: #9aa6b2;
    --line: #2a313b;
    --line-soft: #222832;
    --accent: #22c55e;
    --accent-2: #38bdf8;
    --danger: #ef4444;
    --warning: #f59e0b;
    --shadow: 0 18px 44px rgba(0, 0, 0, .24);
}

* {
    box-sizing: border-box;
}

html {
    background: var(--bg);
}

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", Arial, sans-serif;
    font-size: 15px;
    letter-spacing: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #10141a;
    color: var(--text);
    outline: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .03);
    transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease;
}

input,
select {
    min-height: 44px;
    padding: 0 12px;
}

select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 18px) 19px, calc(100% - 12px) 19px;
    background-repeat: no-repeat;
    background-size: 6px 6px, 6px 6px;
    padding-right: 36px;
}

textarea {
    min-height: 92px;
    padding: 12px;
    resize: vertical;
    line-height: 1.5;
}

input:hover,
select:hover,
textarea:hover {
    border-color: #3b4656;
    background-color: #121821;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent-2);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, .16), inset 0 1px 0 rgba(255, 255, 255, .04);
}

input::placeholder,
textarea::placeholder {
    color: #66717f;
}

label {
    display: grid;
    gap: 7px;
    color: #bac4cf;
    font-size: 13px;
    font-weight: 700;
}

label small {
    color: var(--muted);
    font-weight: 600;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th,
td {
    padding: 15px 14px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
    text-align: left;
}

th {
    background: #151a21;
    color: #a8b4c1;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

tbody tr {
    transition: background-color .14s ease;
}

tbody tr:hover {
    background: rgba(56, 189, 248, .045);
}

td strong {
    color: #f8fafc;
}

td small {
    display: block;
    max-width: 430px;
    margin-top: 6px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 66px;
    border-bottom: 1px solid var(--line);
    background: rgba(15, 17, 21, .92);
    padding: 0 24px;
    backdrop-filter: blur(14px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: #f8fafc;
    font-weight: 850;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 34px;
    border: 1px solid rgba(34, 197, 94, .45);
    border-radius: 7px;
    background: #12301f;
    color: #86efac;
    font-size: 12px;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, .08);
}

.nav {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-weight: 750;
}

.nav a {
    min-height: 36px;
    border: 1px solid transparent;
    border-radius: 7px;
    padding: 8px 12px;
    transition: border-color .15s ease, background-color .15s ease, color .15s ease;
}

.nav a:hover {
    border-color: var(--line);
    background: #171c23;
    color: #f8fafc;
}

.shell {
    width: min(1220px, calc(100% - 36px));
    margin: 28px auto 60px;
}

.install-body .shell {
    width: min(820px, calc(100% - 36px));
}

.hero-band {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin: 0 0 18px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 18px;
}

.hero-band h1,
.panel-heading h1,
.panel-heading h2 {
    margin: 0;
    color: #f8fafc;
    line-height: 1.18;
}

.hero-band h1 {
    font-size: 28px;
}

.panel-heading h1,
.panel-heading h2 {
    font-size: 21px;
}

.eyebrow {
    margin: 0 0 7px;
    color: var(--accent-2);
    font-size: 11px;
    font-weight: 850;
    letter-spacing: 0;
    text-transform: uppercase;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat,
.panel,
.auth-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.stat {
    position: relative;
    min-height: 112px;
    overflow: hidden;
    padding: 18px;
}

.stat::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--accent);
}

.stat:nth-child(2)::before {
    background: var(--accent-2);
}

.stat:nth-child(3)::before {
    background: var(--warning);
}

.stat:nth-child(4)::before {
    background: #f472b6;
}

.stat span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.stat strong {
    display: block;
    margin-top: 12px;
    color: #fff;
    font-size: 30px;
    line-height: 1;
}

.panel,
.auth-panel {
    margin-bottom: 18px;
    padding: 18px;
}

.auth-panel,
.edit-panel {
    width: min(540px, 100%);
    margin: 64px auto;
}

.install-panel {
    width: min(780px, 100%);
}

.panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.auth-panel .panel-heading,
.edit-panel .panel-heading,
.install-panel .panel-heading {
    display: block;
}

.panel-heading .muted {
    max-width: 650px;
    margin: 10px 0 0;
    line-height: 1.55;
}

.stack {
    display: grid;
    gap: 15px;
}

.grid-form {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) minmax(220px, 1.45fr) minmax(160px, 1fr) minmax(150px, 180px) auto;
    gap: 13px;
    align-items: end;
}

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

.install-form {
    gap: 16px;
}

.sqlite-fields {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #10141a;
    padding: 13px 14px;
    line-height: 1.5;
}

.sqlite-fields[hidden],
.mysql-fields[hidden] {
    display: none;
}

.wide-field {
    grid-column: 1 / -2;
}

.btn,
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel-2);
    color: var(--text);
    padding: 0 14px;
    cursor: pointer;
    font-weight: 850;
    white-space: nowrap;
    box-shadow: 0 1px 0 rgba(255, 255, 255, .04) inset;
    transition: border-color .15s ease, background-color .15s ease, color .15s ease, transform .15s ease, box-shadow .15s ease;
}

.btn:hover,
.icon-btn:hover {
    border-color: #445064;
    background: #283140;
    transform: translateY(-1px);
}

.btn.primary {
    border-color: rgba(34, 197, 94, .7);
    background: #15803d;
    color: #fff;
}

.btn.primary:hover {
    border-color: rgba(74, 222, 128, .9);
    background: #16a34a;
    box-shadow: 0 12px 26px rgba(22, 163, 74, .22);
}

.btn:active,
.icon-btn:active {
    transform: translateY(0);
}

.btn:disabled,
.icon-btn:disabled {
    cursor: wait;
    opacity: .72;
    transform: none;
}

.btn.is-working {
    box-shadow: 0 0 0 3px rgba(56, 189, 248, .12);
}

.icon-btn.is-copied {
    border-color: rgba(34, 197, 94, .62);
    background: rgba(34, 197, 94, .18);
    color: #bbf7d0;
}

.btn.ghost {
    background: transparent;
}

.btn.danger {
    border-color: rgba(239, 68, 68, .42);
    color: #fecaca;
}

.btn.danger:hover {
    border-color: rgba(239, 68, 68, .7);
    background: rgba(239, 68, 68, .12);
}

.btn.mini {
    min-height: 33px;
    padding: 0 10px;
    font-size: 12px;
}

.button-row,
.actions,
.copy-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.actions {
    justify-content: flex-end;
    flex-wrap: wrap;
}

.actions form {
    margin: 0;
}

.copy-stack {
    display: grid;
    gap: 8px;
}

.copy-row input {
    min-width: 290px;
    min-height: 36px;
    background: #101318;
    color: #cbd5e1;
    font-size: 13px;
}

.icon-btn {
    min-width: 66px;
    min-height: 36px;
    color: #dbeafe;
}

.pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 74px;
    min-height: 29px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 850;
}

.pill.ok {
    border-color: rgba(34, 197, 94, .32);
    background: rgba(34, 197, 94, .14);
    color: #86efac;
}

.pill.off {
    border-color: rgba(245, 158, 11, .32);
    background: rgba(245, 158, 11, .14);
    color: #fde68a;
}

.alert {
    margin-bottom: 18px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 13px 15px;
    font-weight: 760;
    line-height: 1.45;
}

.alert-success {
    border-color: rgba(34, 197, 94, .28);
    background: rgba(34, 197, 94, .12);
    color: #bbf7d0;
}

.alert-danger {
    border-color: rgba(239, 68, 68, .28);
    background: rgba(239, 68, 68, .12);
    color: #fecaca;
}

.notice {
    display: grid;
    gap: 6px;
    margin-bottom: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px 16px;
    line-height: 1.45;
}

.notice.warning {
    border-color: rgba(245, 158, 11, .42);
    background: rgba(245, 158, 11, .1);
    color: #fde68a;
}

.notice code {
    border-radius: 5px;
    background: rgba(0, 0, 0, .24);
    padding: 2px 5px;
    color: #fff7c2;
}

.muted {
    color: var(--muted);
}

.table-panel {
    padding: 0;
    overflow: hidden;
}

.table-panel .panel-heading {
    margin: 0;
    border-bottom: 1px solid var(--line);
    padding: 18px;
}

.table-wrap {
    overflow-x: auto;
}

.table-wrap table {
    min-width: 920px;
}

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

.check-row input {
    width: 18px;
    min-height: 18px;
    accent-color: var(--accent);
}

.player-body {
    background: #000;
    overflow: hidden;
}

.player-screen {
    position: fixed;
    inset: 0;
    background: #000;
}

.video-frame,
.jw-frame,
.player-screen .jwplayer {
    width: 100%;
    height: 100%;
    background: #000;
}

.video-frame {
    object-fit: contain;
}

.jw-frame {
    position: absolute;
    inset: 0;
}

.player-error {
    position: fixed;
    inset: 0;
    z-index: 5;
    background: #000;
}

.player-message {
    display: grid;
    place-items: center;
    min-height: 100vh;
    color: #fff;
}

@media (max-width: 1080px) {
    .grid-form,
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .wide-field,
    .grid-form .btn {
        grid-column: 1 / -1;
    }
}

@media (max-width: 720px) {
    body {
        font-size: 14px;
    }

    .topbar,
    .hero-band {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar {
        gap: 12px;
        padding: 14px 16px;
    }

    .nav {
        flex-wrap: wrap;
    }

    .shell,
    .install-body .shell {
        width: min(100% - 24px, 1220px);
        margin-top: 20px;
    }

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

    .copy-row {
        align-items: stretch;
        flex-direction: column;
    }

    .copy-row input {
        min-width: 0;
    }

    .auth-panel,
    .edit-panel {
        margin: 32px auto;
    }
}
