:root {
    --bg: #f4f7f6;
    --surface: #ffffff;
    --surface-2: #eef3f1;
    --text: #17211f;
    --muted: #64716d;
    --line: #dbe4e1;
    --brand: #117c6f;
    --brand-2: #174a7c;
    --danger: #b42318;
    --warning: #b76e00;
    --success: #147a3f;
    --shadow: 0 10px 28px rgba(23, 33, 31, 0.08);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    color: var(--text);
    background: var(--bg);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
}

a {
    color: var(--brand-2);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

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

.sidebar {
    background: #102522;
    color: #f4fffc;
    padding: 18px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 28px;
}

.brand-mark {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
    font-weight: 700;
}

.brand-logo {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    object-fit: contain;
    background: #fff;
}

.sidebar nav {
    display: grid;
    gap: 6px;
}

.sidebar a,
.sidebar button {
    width: 100%;
    border: 0;
    border-radius: 8px;
    color: #e4f4f0;
    background: transparent;
    text-align: left;
    padding: 10px 12px;
    cursor: pointer;
    font: inherit;
}

.sidebar a:hover,
.sidebar button:hover,
.sidebar .active {
    background: rgba(255, 255, 255, 0.1);
    text-decoration: none;
}

.main {
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 68px;
    padding: 14px 28px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-title {
    margin: 0;
    font-size: 22px;
}

.content {
    padding: 28px;
    max-width: 1480px;
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(135deg, #102522, #164e63);
}

.auth-box {
    width: min(440px, 100%);
    background: #fff;
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 30px;
}

.auth-box h1 {
    margin: 0 0 10px;
}

.grid {
    display: grid;
    gap: 18px;
}

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

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

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

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 18px;
}

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

.metric small {
    color: var(--muted);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0;
}

.metric strong {
    font-size: 28px;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin: 0 0 14px;
}

.section-title h2 {
    margin: 0;
    font-size: 20px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.table-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 10px;
}

.table-filter {
    max-width: 320px;
}

.table-pagination {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
}

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

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

th {
    background: var(--surface-2);
    font-size: 13px;
    color: #35413e;
}

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

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

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

.field.full {
    grid-column: 1 / -1;
}

label {
    font-weight: 700;
    font-size: 13px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

textarea {
    min-height: 92px;
    resize: vertical;
}

.checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
}

.checkboxes label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
}

.checkboxes input {
    width: auto;
}

.switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
}

.switch input {
    width: auto;
}

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

.btn {
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 9px 12px;
    background: var(--brand);
    color: #fff;
    cursor: pointer;
    font: inherit;
    display: inline-flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    min-height: 38px;
}

.btn:hover {
    text-decoration: none;
    filter: brightness(0.96);
}

.btn.secondary {
    color: var(--text);
    border-color: var(--line);
    background: #fff;
}

.btn.danger {
    background: var(--danger);
}

.btn.warning {
    background: var(--warning);
}

.btn.small {
    min-height: 32px;
    padding: 6px 9px;
    font-size: 13px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 12px;
    white-space: nowrap;
}

.badge.online,
.badge.active,
.badge.success {
    color: #fff;
    background: var(--success);
}

.badge.attention,
.badge.processing {
    color: #fff;
    background: var(--warning);
}

.badge.offline,
.badge.suspended,
.badge.inactive,
.badge.failed,
.badge.incompatible {
    color: #fff;
    background: var(--danger);
}

.alert {
    border-radius: 8px;
    border: 1px solid var(--line);
    padding: 12px 14px;
    margin-bottom: 16px;
    background: #fff;
}

.alert.success {
    border-color: #b7dec7;
    background: #eefaf2;
    color: var(--success);
}

.alert.error {
    border-color: #f1b9b4;
    background: #fff1f0;
    color: var(--danger);
}

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

.progress {
    width: 100%;
    height: 12px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--surface-2);
}

.progress > span {
    display: block;
    height: 100%;
    width: 0;
    background: var(--brand);
    transition: width 0.2s ease;
}

.upload-feedback {
    display: grid;
    gap: 6px;
}

.thumbnail-preview {
    display: flex;
    align-items: center;
    gap: 12px;
}

.thumbnail-preview img,
.video-thumb {
    width: 112px;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-2);
}

.video-thumb.empty {
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
    padding: 8px;
}

.drag-row {
    cursor: grab;
}

.drag-row.dragging {
    opacity: 0.55;
}

.qr {
    width: 110px;
    height: 110px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.player-page {
    margin: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: #000;
    color: #fff;
}

.player-root,
.player-video {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background: #000;
}

.player-video.cover {
    object-fit: cover;
}

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

.player-video.stretch {
    object-fit: fill;
}

.player-overlay {
    position: fixed;
    inset: 0;
    display: none;
    place-items: center;
    text-align: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.72);
    z-index: 10;
}

.player-overlay.show {
    display: grid;
}

.player-panel {
    max-width: 560px;
}

.player-panel h1 {
    font-size: 26px;
    margin: 0 0 10px;
}

.fullscreen-btn {
    position: fixed;
    right: 14px;
    bottom: 14px;
    z-index: 12;
    opacity: 0.5;
}

.fullscreen-btn:hover {
    opacity: 1;
}

.diag {
    position: fixed;
    left: 10px;
    bottom: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 12px;
    display: none;
    z-index: 11;
}

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

.timeline-item {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 10px;
    align-items: center;
}

.timeline-bar {
    height: 18px;
    border-radius: 6px;
    background: var(--brand);
}

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

    .sidebar {
        position: static;
        height: auto;
    }

    .sidebar nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .grid-4,
    .grid-3,
    .grid-2,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .topbar {
        padding: 14px 18px;
    }

    .content {
        padding: 18px;
    }

    .table-tools,
    .table-pagination {
        align-items: stretch;
        flex-direction: column;
    }

    .table-filter {
        max-width: none;
        width: 100%;
    }
}
