html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.overlay-page {
    width: 100%;
    height: 100%;
    background: transparent;
    overflow: hidden;
}

.popup-image {
    position: fixed;
    left: var(--popup-x, 50%);
    top: var(--popup-y, 50%);
    max-width: 100vw;
    max-height: 100vh;
    opacity: 0;
    pointer-events: none;
    transform: var(--popup-transform, translate(-50%, -50%));
    transition: opacity 500ms ease;
    will-change: opacity, transform;
}

.popup-image.visible {
    opacity: 1;
}

.admin-page {
    min-height: 100vh;
    color: #e7edf4;
    background: #10151d;
    font-size: 14px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 16px;
    background: #151c27;
    border-bottom: 1px solid #273142;
}

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

.topbar h1,
.login-box h1 {
    margin: 0;
    font-size: 18px;
    line-height: 1.2;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.shown-mode {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 0 8px;
    color: #c9d5e4;
    font-size: 13px;
    background: #0d121a;
    border: 1px solid #344055;
    border-radius: 4px;
    white-space: nowrap;
}

.shown-mode input {
    width: 16px;
    height: 16px;
    padding: 0;
}

.admin-shell {
    padding: 16px;
}

.upload-panel {
    margin-bottom: 14px;
    padding: 12px;
    background: #151c27;
    border: 1px solid #273142;
    border-radius: 6px;
}

.upload-panel form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.category-form {
    margin-top: 8px;
}

.category-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.category-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 26px;
    padding: 0 8px;
    color: #d8e3f0;
    background: #222c3b;
    border: 1px solid #344055;
    border-radius: 4px;
    font-size: 12px;
}

.category-chip button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    color: #d8e3f0;
    background: #3b4658;
    border: 0;
    border-radius: 3px;
    cursor: pointer;
}

.category-chip button:hover {
    background: #596579;
}

.category-empty {
    color: #9fb0c3;
    font-size: 12px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid #273142;
    border-radius: 6px;
    background: #151c27;
}

table {
    width: 100%;
    min-width: 1180px;
    border-collapse: collapse;
}

th,
td {
    padding: 8px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid #273142;
}

th {
    color: #9fb0c3;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    background: #111823;
}

.actions-heading,
.actions-cell {
    text-align: right;
    width: 1%;
}

tr:last-child td {
    border-bottom: 0;
}

tbody tr {
    transition: opacity 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

tbody tr.was-shown:not(.is-active) {
    opacity: 0.5;
}

tbody tr.is-active {
    position: relative;
    background: #1c3454;
    box-shadow: inset 4px 0 0 #5aa2ff;
}

tbody tr.is-active td {
    border-bottom-color: #395d89;
}

.category-group-row td {
    padding: 7px 10px;
    color: #d8e3f0;
    background: #202938;
    border-top: 1px solid #344055;
    border-bottom: 1px solid #344055;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.category-group-row span {
    margin-left: 8px;
    color: #9fb0c3;
    font-weight: 700;
}

input,
select,
button {
    font: inherit;
}

input,
select {
    box-sizing: border-box;
    height: 32px;
    color: #e7edf4;
    background: #0d121a;
    border: 1px solid #344055;
    border-radius: 4px;
    padding: 0 8px;
}

input:focus,
select:focus {
    outline: 2px solid #4f8cff;
    outline-offset: 1px;
}

input[type="file"] {
    min-width: 260px;
    padding-top: 5px;
}

.title-input {
    width: 220px;
}

.number-input,
.seconds-input {
    width: 76px;
}

.anchor-input {
    width: 150px;
}

.category-input {
    width: 170px;
}

.thumb {
    display: block;
    width: 96px;
    height: 60px;
    object-fit: contain;
    background:
        linear-gradient(45deg, #222b38 25%, transparent 25%),
        linear-gradient(-45deg, #222b38 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #222b38 75%),
        linear-gradient(-45deg, transparent 75%, #222b38 75%);
    background-color: #151c27;
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    border: 1px solid #344055;
    border-radius: 4px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 0 10px;
    color: #f8fbff;
    text-decoration: none;
    border: 0;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}

.button.primary,
.button.show {
    background: #2374e1;
}

.button.timed {
    background: #15a36b;
}

.button.hide {
    background: #596579;
}

.button.danger {
    background: #c93f3f;
}

.button.neutral {
    background: #334056;
}

.button:hover {
    filter: brightness(1.1);
}

.row-actions {
    display: inline-flex;
    justify-content: flex-end;
    gap: 6px;
    white-space: nowrap;
}

.state-badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 700;
    border-radius: 999px;
}

.state-badge.visible {
    color: #dff9eb;
    background: #12764d;
}

.state-badge.hidden {
    color: #d6deea;
    background: #3a4558;
}

.status {
    position: fixed;
    left: 16px;
    bottom: 16px;
    z-index: 20;
    width: min(420px, calc(100vw - 32px));
    box-sizing: border-box;
    margin: 0;
    padding: 9px 10px;
    color: #dff9eb;
    background: #123f2d;
    border: 1px solid #1e7f55;
    border-radius: 5px;
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.35);
}

.status.error {
    color: #ffe5e5;
    background: #4c171b;
    border-color: #a13d45;
}

.login-page {
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-box {
    width: min(100%, 360px);
    padding: 20px;
    background: #151c27;
    border: 1px solid #273142;
    border-radius: 6px;
}

.login-box form {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.login-box label {
    color: #9fb0c3;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

@media (max-width: 680px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-brand {
        width: 100%;
        justify-content: space-between;
    }

    .topbar-actions {
        flex-wrap: wrap;
    }

    .admin-shell {
        padding: 10px;
    }
}
