:root {
    --bg: #f3efe7;
    --bg-soft: #fbf8f2;
    --panel: rgba(255, 255, 255, 0.82);
    --line: rgba(78, 60, 35, 0.12);
    --text: #221b12;
    --muted: #665746;
    --accent: #c65d2f;
    --accent-dark: #934121;
    --success: #2f7a45;
    --error: #9a2f2f;
    --shadow: 0 24px 60px rgba(101, 74, 40, 0.14);
    --radius: 22px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(198, 93, 47, 0.18), transparent 30%),
        radial-gradient(circle at top right, rgba(55, 116, 92, 0.18), transparent 24%),
        linear-gradient(180deg, #f8f4ed 0%, #efe7da 100%);
    min-height: 100vh;
}

a {
    color: inherit;
}

.hero {
    padding: 48px 24px 20px;
}

.hero__content,
.page {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
}

.brand {
    display: inline-grid;
    justify-items: start;
    gap: 6px;
    color: var(--text);
    text-decoration: none;
    font-size: 1.72rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1;
}

.brand__logo {
    width: 92px;
    max-width: 100%;
    height: 44px;
    object-fit: contain;
    border-radius: 10px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.nav-links a {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    border-radius: 12px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.42);
    border: 1px solid rgba(78, 60, 35, 0.08);
}

.user-menu {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.48);
    border: 1px solid rgba(78, 60, 35, 0.08);
}

.user-menu span {
    padding-left: 8px;
    color: var(--muted);
    font-weight: 800;
    font-size: 0.86rem;
    white-space: nowrap;
}

.user-menu button {
    min-height: 34px;
    border-radius: 12px;
}

.nav-links a:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.72);
}

.hero__subtitle {
    max-width: 720px;
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 1rem;
}

.page {
    padding-bottom: 48px;
}

.stats-grid,
.grid-layout {
    display: grid;
    gap: 18px;
    margin-bottom: 18px;
}

.stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.grid-layout {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.panel {
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(16px);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}

.auth-shell {
    min-height: 42vh;
    display: grid;
    align-items: center;
    justify-items: center;
}

.auth-panel {
    width: min(460px, 100%);
}

.auth-logo {
    display: block;
    width: min(260px, 78%);
    max-height: 140px;
    object-fit: contain;
    margin: 0 auto 18px;
    border-radius: 18px;
}

.panel--device-summary {
    display: flex;
    flex-direction: column;
}

.panel--wide {
    grid-column: span 2;
}

.panel__header h2,
.detail-header h1 {
    margin: 0;
    font-size: 1.5rem;
}

.panel__header p,
.device-card p,
.video-row p,
.hint,
.detail-header p,
.meta-grid dt {
    color: var(--muted);
}

.panel__header {
    margin-bottom: 18px;
}

.panel__header--compact {
    margin-bottom: 12px;
}

.panel__header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.stat-card {
    display: block;
    padding: 22px;
    border-radius: 20px;
    color: #fff;
    text-decoration: none;
    background:
        linear-gradient(135deg, rgba(24, 24, 24, 0.1), rgba(255, 255, 255, 0.02)),
        linear-gradient(135deg, #b34e2b, #db8d38);
    box-shadow: var(--shadow);
}

.stat-card--link {
    position: relative;
    overflow: hidden;
    transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease;
}

.stat-card--link::after {
    content: "";
    position: absolute;
    inset: auto 18px 16px auto;
    width: 22px;
    height: 22px;
    border-right: 2px solid rgba(255, 255, 255, 0.8);
    border-top: 2px solid rgba(255, 255, 255, 0.8);
    transform: rotate(45deg) translateX(-3px);
    opacity: 0;
    transition: transform 140ms ease, opacity 140ms ease;
}

.stat-card--link:hover,
.stat-card--link:focus-visible {
    transform: translateY(-2px);
    filter: saturate(1.04);
    box-shadow: 0 28px 68px rgba(101, 74, 40, 0.2);
}

.stat-card--link:hover::after,
.stat-card--link:focus-visible::after {
    opacity: 1;
    transform: rotate(45deg) translateX(2px);
}

.stat-card:nth-child(2) {
    background:
        linear-gradient(135deg, rgba(24, 24, 24, 0.08), rgba(255, 255, 255, 0.03)),
        linear-gradient(135deg, #275f72, #4da3a1);
}

.stat-card:nth-child(3) {
    background:
        linear-gradient(135deg, rgba(24, 24, 24, 0.08), rgba(255, 255, 255, 0.03)),
        linear-gradient(135deg, #4d5640, #93a45f);
}

.stat-card:nth-child(4) {
    background:
        linear-gradient(135deg, rgba(24, 24, 24, 0.08), rgba(255, 255, 255, 0.03)),
        linear-gradient(135deg, #2e5f4f, #51a56d);
}

.stat-card--offline {
    background:
        linear-gradient(135deg, rgba(24, 24, 24, 0.1), rgba(255, 255, 255, 0.02)),
        linear-gradient(135deg, #7a2d2d, #c25143);
}

.stat-card__label {
    display: block;
    font-size: 0.85rem;
    opacity: 0.86;
}

.stat-card__value {
    display: block;
    margin-top: 10px;
    font-size: 2rem;
}

.form-stack {
    display: grid;
    gap: 14px;
}

.form-stack label {
    display: grid;
    gap: 8px;
    font-weight: 600;
}

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

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.8);
    color: var(--text);
}

textarea {
    resize: vertical;
}

button,
.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 0 16px;
    border: none;
    border-radius: 16px;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    font-weight: 700;
    transition: transform 140ms ease, background 140ms ease;
}

button:hover,
.button-link:hover {
    transform: translateY(-1px);
    background: var(--accent-dark);
}

.button-secondary {
    background: rgba(34, 27, 18, 0.08);
    color: var(--text);
}

.button-secondary:hover {
    background: rgba(34, 27, 18, 0.14);
}

.button-danger {
    background: var(--error);
}

.button-danger:hover {
    background: #7f2424;
}

.danger-zone {
    display: grid;
    gap: 12px;
    margin-top: 18px;
    padding: 16px;
    border: 1px solid rgba(154, 47, 47, 0.22);
    border-radius: 18px;
    background: rgba(154, 47, 47, 0.06);
}

.danger-zone h3 {
    margin: 0;
    color: var(--error);
}

.danger-zone p {
    margin: 0;
    color: var(--muted);
}

.device-list,
.video-list,
.compact-device-list,
.assignment-list,
.device-directory {
    display: grid;
    gap: 14px;
}

.compact-device-list--scroll {
    max-height: 282px;
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-color: rgba(195, 88, 43, 0.62) rgba(255, 255, 255, 0.36);
    scrollbar-width: thin;
}

.compact-device-list--scroll::-webkit-scrollbar {
    width: 8px;
}

.compact-device-list--scroll::-webkit-scrollbar-track {
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.42);
}

.compact-device-list--scroll::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(195, 88, 43, 0.62);
}

.dashboard-search {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
    font-weight: 700;
}

.dashboard-search span {
    color: var(--muted);
    font-size: 0.88rem;
}

.compact-device-empty {
    margin-top: 14px;
}

.device-card,
.video-row,
.assignment-row,
.compact-device-row {
    display: grid;
    gap: 14px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--bg-soft);
}

.device-card__top,
.video-row,
.assignment-row {
    grid-template-columns: 1fr auto;
    align-items: center;
}

.compact-device-row {
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
}

.device-card h3,
.compact-device-row h3,
.assignment-row strong,
.video-row strong {
    margin: 0;
}

.assignment-row {
    color: var(--text);
    text-decoration: none;
    transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.assignment-row:hover,
.assignment-row:focus-visible {
    transform: translateY(-1px);
    border-color: rgba(195, 88, 43, 0.36);
    background: rgba(255, 250, 241, 0.9);
}

.assignment-row p {
    margin: 6px 0 0;
    color: var(--muted);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    background: rgba(34, 27, 18, 0.08);
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
    white-space: nowrap;
}

.status-pill--playing {
    background: rgba(47, 122, 69, 0.12);
    color: #2f7a45;
}

.device-card h3,
.compact-device-row h3 {
    display: flex;
    gap: 8px;
    align-items: center;
}

.compact-device-row p {
    margin: 6px 0 0;
    color: var(--muted);
}

.compact-device-network {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 0.88rem;
    text-align: right;
    white-space: nowrap;
}

.compact-device-network strong {
    color: var(--text);
    font-weight: 800;
}

.button-link--block {
    margin-top: 14px;
    width: 100%;
}

.device-directory {
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #9a2f2f;
    box-shadow: 0 0 0 4px rgba(154, 47, 47, 0.08);
    flex: 0 0 auto;
    position: relative;
}

.status-dot--online {
    background: #2f7a45;
    box-shadow: 0 0 0 4px rgba(47, 122, 69, 0.12);
}

.status-dot::after {
    content: "";
    position: absolute;
    inset: -5px;
    border-radius: inherit;
    border: 1px solid currentColor;
    opacity: 0;
    animation: status-pulse 1.8s ease-out infinite;
}

.status-dot--online {
    color: #2f7a45;
}

.status-dot--offline {
    color: #9a2f2f;
}

.status-dot--offline::after {
    animation-duration: 2.4s;
}

@keyframes status-pulse {
    0% {
        transform: scale(0.72);
        opacity: 0.5;
    }
    70% {
        transform: scale(1.7);
        opacity: 0;
    }
    100% {
        transform: scale(1.7);
        opacity: 0;
    }
}

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

.meta-grid dt,
.meta-grid dd {
    margin: 0;
}

.meta-grid dd code,
.code-block code {
    word-break: break-all;
}

.meta-grid__full {
    grid-column: 1 / -1;
}

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

.detail-header {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: end;
    margin-bottom: 18px;
}

.detail-meta {
    display: grid;
    gap: 6px;
    justify-items: end;
}

.filter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.back-link {
    color: var(--accent-dark);
    text-decoration: none;
    font-weight: 700;
}

.playlist-table {
    display: grid;
    gap: 10px;
}

.playlist-table__head,
.playlist-table__row {
    display: grid;
    grid-template-columns: 90px 1fr 140px 120px;
    gap: 12px;
    align-items: center;
}

.playlist-table__head {
    padding: 0 12px;
    font-size: 0.85rem;
    color: var(--muted);
}

.playlist-table__row {
    padding: 14px 12px;
    border-radius: 16px;
    background: var(--bg-soft);
    border: 1px solid var(--line);
}

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

.command-grid form,
.command-grid button {
    width: 100%;
}

.mini-list,
.event-list,
.media-file-list {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.mini-list__row,
.event-row,
.media-file-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: start;
    padding: 12px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: var(--bg-soft);
}

.media-files {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.media-file-row {
    align-items: center;
}

.media-file-row--locked {
    background: rgba(47, 122, 69, 0.06);
}

.media-file-row p {
    margin: 4px 0 0;
    color: var(--muted);
}

.media-file-row form {
    margin: 0;
}

.mini-list__row span,
.event-row span,
.event-row p {
    color: var(--muted);
}

.mini-list__result {
    margin: 8px 0 0;
    color: var(--muted);
}

.event-row p {
    margin: 4px 0 0;
}

.event-row--error {
    border-color: rgba(154, 47, 47, 0.28);
}

.data-table {
    display: grid;
    gap: 10px;
}

.data-table__head,
.data-table__row {
    display: grid;
    gap: 12px;
    align-items: center;
}

.data-table__head {
    padding: 0 12px;
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 800;
}

.data-table__row {
    padding: 14px 12px;
    border-radius: 16px;
    background: var(--bg-soft);
    border: 1px solid var(--line);
}

.data-table__row form {
    margin: 0;
}

.data-table__row--users {
    grid-template-columns: 1fr 120px 180px 110px;
}

.data-table__row--audit {
    grid-template-columns: 150px 130px 170px minmax(240px, 1fr) 130px;
}

.flash-stack {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.flash {
    padding: 14px 16px;
    border-radius: 16px;
    font-weight: 600;
}

.flash--success {
    background: rgba(47, 122, 69, 0.12);
    color: var(--success);
}

.flash--error {
    background: rgba(154, 47, 47, 0.12);
    color: var(--error);
}

.code-block {
    padding: 18px;
    border-radius: 18px;
    background: #201a14;
    color: #f6efe3;
    overflow-x: auto;
}

.empty-state {
    margin: 0;
    padding: 18px;
    border: 1px dashed var(--line);
    border-radius: 18px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.46);
}

.site-footer {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 0 0 28px;
    color: var(--muted);
    text-align: center;
    font-size: 0.92rem;
}

.site-footer a {
    color: var(--accent-dark);
    font-weight: 800;
    text-decoration: none;
}

.site-footer a:hover {
    text-decoration: underline;
}

@media (max-width: 880px) {
    .panel--wide {
        grid-column: auto;
    }

    .detail-header,
    .device-card__top,
    .video-row,
    .assignment-row,
        .compact-device-row,
        .mini-list__row,
        .event-row,
        .media-file-row,
        .playlist-table__head,
        .playlist-table__row {
        grid-template-columns: 1fr;
    }

    .detail-header {
        align-items: start;
    }

    .compact-device-network {
        text-align: left;
        white-space: normal;
    }

    .detail-meta {
        justify-items: start;
    }

    .filter-actions {
        justify-content: flex-start;
    }

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

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

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

    .user-menu {
        width: 100%;
        justify-content: space-between;
    }

    .data-table__head {
        display: none;
    }

    .data-table__row--users,
    .data-table__row--audit {
        grid-template-columns: 1fr;
    }
}
