:root {
    --es-navy: #16324f;
    --es-navy-dark: #0f2438;
    --es-accent: #0f8f86;
    --es-accent-dark: #0b6e68;
    --es-bg: #f3f5f8;
    --es-text: #1c2b3a;
    --es-sidebar-width: 264px;
    --es-topbar-height: 56px;
}

html, body {
    background: var(--es-bg);
    color: var(--es-text);
    font-family: "Segoe UI", system-ui, sans-serif;
}

body.has-sidebar {
    min-height: 100vh;
}

body.sidebar-open {
    overflow: hidden;
}

.es-logo {
    display: block;
    width: 100%;
    height: auto;
    max-height: 48px;
    object-fit: contain;
    object-position: left center;
}

.es-logo-auth {
    max-width: 280px;
    max-height: none;
    margin: 0 auto .85rem;
    object-position: center;
}

.es-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--es-sidebar-width);
    display: flex;
    flex-direction: column;
    background: var(--es-navy);
    color: #fff;
    z-index: 1040;
}

.es-sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .9rem .85rem;
    background: #fff;
}

.es-sidebar-brand {
    display: flex;
    align-items: center;
    min-width: 0;
    flex: 1;
    text-decoration: none;
}

.es-sidebar-close {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--es-navy);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}

.es-sidebar-close:hover {
    background: rgba(22, 50, 79, .08);
    color: var(--es-navy);
}

.es-sidebar-cta {
    display: block;
    width: calc(100% - 2rem);
    margin: 1rem 1rem 1rem;
    font-weight: 600;
}

.es-sidebar-cta.is-current {
    box-shadow: 0 0 0 2px rgba(255,255,255,.25);
}

.es-sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding-bottom: .5rem;
}

.es-sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 2px .7rem;
    padding: .6rem .75rem;
    border-radius: 8px;
    color: rgba(255,255,255,.78);
    text-decoration: none;
}

.es-sidebar-link:hover {
    color: #fff;
    background: rgba(255,255,255,.08);
}

.es-sidebar-link.active {
    color: #fff;
    font-weight: 600;
    background: rgba(15, 143, 134, .32);
}

.es-sidebar-icon {
    display: inline-flex;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.es-sidebar-icon svg {
    width: 18px;
    height: 18px;
}

.es-sidebar-foot {
    padding: .75rem 0 1rem;
    border-top: 1px solid rgba(255,255,255,.08);
}

.es-sidebar-user {
    padding: .35rem .75rem .15rem;
    margin: 0 .7rem;
    color: rgba(255,255,255,.55);
    font-size: .82rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.es-sidebar-signout {
    display: block;
    width: calc(100% - 1.4rem);
    margin: .2rem .7rem 0;
    padding: .5rem .75rem;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: rgba(255,255,255,.6);
    text-align: left;
    cursor: pointer;
}

.es-sidebar-signout:hover {
    color: #fff;
    background: rgba(255,255,255,.08);
}

.es-sidebar-backdrop {
    display: none;
}

.es-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    gap: .75rem;
    height: var(--es-topbar-height);
    padding: 0 1rem;
    background: #fff;
    color: var(--es-navy);
    box-shadow: 0 1px 0 rgba(22, 50, 79, .08);
}

.es-sidebar-link:focus-visible,
.es-sidebar-signout:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.es-sidebar-brand:focus-visible,
.es-menu-toggle:focus-visible,
.es-sidebar-close:focus-visible,
.es-topbar-brand:focus-visible {
    outline: 2px solid var(--es-navy);
    outline-offset: 2px;
}

.es-topbar-brand {
    display: flex;
    align-items: center;
    min-width: 0;
    flex: 1;
}

.es-topbar .es-logo {
    max-height: 32px;
    width: auto;
    max-width: 190px;
}

.es-menu-toggle {
    width: 40px;
    height: 40px;
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    padding: 0 8px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
}

.es-menu-toggle span {
    display: block;
    height: 2px;
    background: var(--es-navy);
    border-radius: 2px;
}

.app-main {
    min-height: 100vh;
}

.page-wrap {
    max-width: 1120px;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
}

@media (min-width: 992px) {
    .app-main {
        margin-left: var(--es-sidebar-width);
    }
}

@media (max-width: 991.98px) {
    .es-topbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
    }

    .app-main {
        padding-top: var(--es-topbar-height);
        min-height: calc(100vh - var(--es-topbar-height));
    }

    .es-sidebar {
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: none;
    }

    .es-sidebar.is-open {
        transform: translateX(0);
        box-shadow: 8px 0 30px rgba(15, 36, 56, .28);
    }

    .es-sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 36, 56, .45);
        z-index: 1035;
    }

    .es-sidebar-backdrop[hidden] {
        display: none;
    }
}

.auth-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 1.5rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    background: #fff;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(22, 50, 79, .08);
}

.auth-brand {
    text-align: center;
    margin-bottom: .25rem;
}

.auth-brand p {
    color: #6b7c8d;
    margin: 0 0 1rem;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
}

.panel {
    background: #fff;
    border-radius: 14px;
    padding: 1.25rem 1.4rem;
    box-shadow: 0 8px 24px rgba(22, 50, 79, .05);
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.panel-head h2,
.panel h2 {
    font-size: 1.05rem;
    margin: 0 0 .75rem;
}

.stat-card {
    background: #fff;
    border-radius: 14px;
    padding: 1rem 1.1rem;
    box-shadow: 0 8px 24px rgba(22, 50, 79, .05);
}

.stat-label {
    color: #6b7c8d;
    font-size: .85rem;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
}

.screen-card,
.screen-row,
.media-card {
    display: block;
    background: #fff;
    border-radius: 14px;
    padding: 1.1rem 1.2rem;
    color: inherit;
    text-decoration: none;
    box-shadow: 0 8px 24px rgba(22, 50, 79, .05);
}

.screen-card h2 {
    font-size: 1.15rem;
}

.screen-card:hover,
.screen-row:hover {
    box-shadow: 0 10px 28px rgba(22, 50, 79, .1);
}

.screen-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.list-stack .screen-row:last-child {
    margin-bottom: 0;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #9aa8b5;
}

.status-dot.online { background: #16a34a; }
.status-dot.delayed { background: #d97706; }
.status-dot.offline { background: #dc2626; }

.badge-status {
    display: inline-block;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .03em;
    padding: .2rem .5rem;
    border-radius: 999px;
}

.badge-status.online { background: #dcfce7; color: #166534; }
.badge-status.delayed { background: #fef3c7; color: #92400e; }
.badge-status.offline { background: #fee2e2; color: #991b1b; }

.event-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.event-list li {
    padding: .55rem 0;
    border-bottom: 1px solid #eef2f6;
}

.event-list li:last-child {
    border-bottom: 0;
}

.details {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: .4rem 1rem;
    margin: 0;
}

.details dt {
    color: #6b7c8d;
    font-weight: 500;
}

.details dd {
    margin: 0;
}

.btn-primary {
    background: var(--es-accent);
    border-color: var(--es-accent);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--es-accent-dark);
    border-color: var(--es-accent-dark);
}

.btn-outline-primary {
    color: var(--es-accent-dark);
    border-color: var(--es-accent);
}

.btn-check:checked + .btn-outline-primary {
    background: var(--es-accent);
    border-color: var(--es-accent);
}

.screen-check {
    display: flex;
    gap: 10px;
    padding: .65rem 0;
    border-bottom: 1px solid #eef2f6;
}

.media-card {
    padding: 0;
    overflow: hidden;
}

.media-thumb {
    height: 140px;
    background: #0f2438;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-placeholder {
    color: #fff;
    letter-spacing: .1em;
    font-size: .8rem;
}

.back-link {
    color: #5b6b7a;
    text-decoration: none;
}

.recent-displays {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
    gap: 12px;
}

.recent-displays > form {
    min-width: 0;
    height: 100%;
}

.recent-display {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 1px solid #e6edf3;
    border-radius: 12px;
    background: #fff;
    text-align: left;
    overflow: hidden;
    color: inherit;
    cursor: pointer;
    appearance: none;
}

.recent-display:hover {
    border-color: var(--es-accent);
    box-shadow: 0 8px 20px rgba(15, 143, 134, .12);
}

.recent-display.is-current {
    border-color: var(--es-accent);
    box-shadow: 0 0 0 2px rgba(15, 143, 134, .2);
}

.recent-display.is-busy {
    cursor: wait;
    opacity: .7;
}

.recent-display.is-disabled {
    cursor: default;
    opacity: .65;
}

.recent-display.is-static {
    cursor: default;
}

.recent-display.is-static:hover {
    border-color: #e6edf3;
    box-shadow: none;
}

.recent-display:focus-visible {
    outline: 2px solid var(--es-accent);
    outline-offset: 2px;
}

.recent-display-preview {
    height: 92px;
    background: #0f2438;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: .85rem;
    text-align: center;
    overflow: hidden;
}

.recent-display-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.recent-display-preview.is-text,
.recent-display-preview.is-website {
    padding: .75rem;
}

.recent-display-preview.is-text {
    background: #16324f;
    align-items: flex-start;
    justify-content: flex-start;
    font-size: .8rem;
    line-height: 1.35;
}

.recent-display-preview.is-website {
    background: linear-gradient(160deg, #16324f 0%, #0f8f86 120%);
    font-weight: 600;
    word-break: break-word;
}

.recent-display-body {
    padding: .7rem .8rem .85rem;
}

.recent-display-type {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .04em;
    color: var(--es-accent-dark);
}

.recent-display-label {
    font-weight: 600;
    font-size: .92rem;
    line-height: 1.3;
    margin: .15rem 0 .2rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (max-width: 576px) {
    .details {
        grid-template-columns: 1fr;
        gap: .15rem;
    }
}
