.admin-shell {
    max-width: 1320px;
}

.admin-page {
    background: linear-gradient(180deg, #f1f5fb 0%, #f7f9fc 100%);
}

.admin-page.lock-scroll {
    overflow: hidden;
    overscroll-behavior: none;
}

.admin-header {
    align-items: center;
    gap: 12px;
}

.admin-header-right,
.admin-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-header-right {
    margin-inline-end: auto;
    justify-content: flex-start;
    text-align: right;
    gap: 14px;
}

.admin-header-right h1 {
    font-size: 1.25rem;
    margin: 0;
    line-height: 1.2;
}

.header-icon-btn {
    width: 40px;
    height: 40px;
    border: 1px solid #dde5ef;
    border-radius: 10px;
    background: #fff;
    color: #334155;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.header-icon-btn i {
    font-size: 1.1rem;
}

.admin-logout-btn {
    width: 36px;
    height: 36px;
    border: 1px solid #fecaca;
    border-radius: 10px;
    background: #fff5f5;
    color: #b91c1c;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.admin-logout-btn i {
    font-size: 1rem;
}

.admin-logout-btn:hover {
    background: #fee2e2;
    border-color: #fca5a5;
}

.admin-logout-btn:focus-visible,
.header-icon-btn:focus-visible {
    outline: 2px solid #0b79d0;
    outline-offset: 2px;
}

.admin-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 14px;
    position: relative;
}

.admin-layout.sidebar-collapsed {
    grid-template-columns: minmax(0, 1fr);
}

.admin-layout.sidebar-collapsed .admin-sidebar {
    display: none;
}

.admin-sidebar-overlay {
    display: none;
    border: 0;
    background: rgba(15, 23, 42, 0.4);
    padding: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}

.mobile-sheet-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    border: 0;
    padding: 0;
    background: rgba(15, 23, 42, 0.42);
    opacity: 0;
    pointer-events: none;
    z-index: 1285;
    transition: opacity 0.18s ease;
}

.mobile-sheet-backdrop.show {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

.admin-sidebar {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-self: start;
    position: sticky;
    top: 18px;
}

.admin-nav-btn {
    width: 100%;
    border: 1px solid #e2e8f0;
    background: #fff;
    border-radius: 12px;
    min-height: 46px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    font-size: 0.88rem;
    color: #334155;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.admin-nav-btn .admin-nav-main {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.admin-nav-btn.active {
    border-color: #0b79d0;
    background: #edf6ff;
    color: #0b79d0;
}

.nav-count {
    min-width: 36px;
    height: 24px;
    border-radius: 999px;
    background: #eef2f7;
    color: #334155;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.admin-nav-btn.active .nav-count {
    background: #d8ecff;
    color: #0b79d0;
}

.admin-main {
    min-width: 0;
}

.admin-section {
    display: none;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    padding: 16px;
    margin-bottom: 14px;
}

.admin-section.active {
    display: block;
    animation: section-fade 0.18s ease;
}

@keyframes section-fade {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.admin-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.admin-head-title {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 auto;
    min-width: 0;
}

.admin-head-title h2 {
    margin: 0;
    font-size: 1.05rem;
}

.admin-section-subtitle {
    margin: 0;
    margin-inline-start: auto;
    color: #64748b;
    font-size: 0.8rem;
    text-align: left;
}

.admin-filters {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-stack {
    display: grid;
    gap: 8px;
    width: min(520px, 100%);
}

.filter-select-row,
.filter-search-row {
    display: grid;
    gap: 8px;
    align-items: center;
}

.filter-select-row {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
}

.filter-search-row {
    grid-template-columns: minmax(0, 1fr) auto;
}

.filter-search-row .admin-input {
    min-width: 0;
}

.users-filters .filter-select-row {
    grid-template-columns: 94px;
}

.channels-filters .filter-select-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.channels-filters .filter-select-row .admin-select {
    min-width: 0;
    width: 100%;
}

.events-filters .filter-select-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-input {
    min-height: 38px;
    border: 1px solid #dbe3ee;
    border-radius: 9px;
    padding: 0 10px;
    font-size: 0.85rem;
    background: #fff;
    min-width: 180px;
}

.admin-input:focus {
    outline: none;
    border-color: #0b79d0;
}

.admin-select {
    cursor: pointer;
}

.admin-select-compact {
    min-width: 94px;
}

.events-filters {
    width: min(520px, 100%);
}

.table-wrap {
    width: 100%;
    overflow: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 780px;
}

.admin-table th,
.admin-table td {
    border-bottom: 1px solid #edf2f8;
    padding: 11px 8px;
    font-size: 0.84rem;
    vertical-align: middle;
}

.admin-table th {
    background: #f8fbff;
    color: #334155;
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
}

.admin-table td {
    color: #334155;
}

.loading-row,
.empty-row {
    text-align: center;
    color: #64748b;
    font-size: 0.82rem;
}

.empty-row {
    padding-top: 18px !important;
    padding-bottom: 18px !important;
    vertical-align: middle;
}

.table-spinner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid #dbe7f7;
    border-top-color: #0b79d0;
    display: inline-block;
    animation: admin-spin 0.8s linear infinite;
    vertical-align: middle;
    margin-left: 8px;
}

@keyframes admin-spin {
    to {
        transform: rotate(360deg);
    }
}

.table-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 0;
}

.btn-icon-only {
    width: 36px;
    min-width: 36px;
    min-height: 36px;
    padding: 0;
    gap: 0;
}

.pager-icon-btn {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    color: #64748b;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1;
}

.pager-icon-btn:hover {
    background: transparent !important;
    color: #0b79d0;
    transform: none;
}

.pager-icon-btn:disabled {
    color: #cbd5e1;
}

.id-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid #dbe3ee;
    border-radius: 999px;
    padding: 3px 10px;
    background: #f8fbff;
    font-size: 0.78rem;
    direction: ltr;
}

.badge-premium,
.badge-normal {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 62px;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.72rem;
    font-weight: 700;
    border: 1px solid transparent;
}

.badge-premium {
    background: #fff3c4;
    color: #8b5e00;
    border-color: #f4d57a;
}

.badge-normal {
    background: #f3f4f6;
    color: #4b5563;
    border-color: #e5e7eb;
}

.state-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

.state-active {
    background: #e0f2fe;
    color: #075985;
}

.state-removed {
    background: #fef3c7;
    color: #92400e;
}

.event-title-wrap {
    display: grid;
    gap: 3px;
}

.event-type-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 0.69rem;
    font-weight: 700;
    width: fit-content;
}

.event-type-positive {
    background: #dcfce7;
    color: #166534;
}

.event-type-warning {
    background: #fef3c7;
    color: #92400e;
}

.event-type-danger {
    background: #fee2e2;
    color: #991b1b;
}

.event-type-neutral {
    background: #e2e8f0;
    color: #334155;
}

.row-actions {
    position: relative;
}

.row-actions summary {
    list-style: none;
    width: 34px;
    height: 34px;
    border: 1px solid #dbe3ee;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #334155;
    background: #fff;
}

.row-actions summary span {
    display: none;
}

.row-actions summary::-webkit-details-marker {
    display: none;
}

.row-actions summary:focus-visible {
    outline: 2px solid #0b79d0;
    outline-offset: 2px;
}

.row-actions-menu {
    position: absolute;
    inset-inline-end: 0;
    top: calc(100% + 6px);
    min-width: 220px;
    border: 1px solid #dbe3ee;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.12);
    z-index: 50;
    padding: 6px;
    display: grid;
    gap: 5px;
}

.row-actions-menu button {
    width: 100%;
    border: none;
    background: #f8fbff;
    border-radius: 8px;
    min-height: 36px;
    padding: 8px 10px;
    text-align: right;
    font-size: 0.8rem;
    color: #334155;
}

.row-actions-menu button:hover {
    background: #ebf4ff;
}

.row-actions-menu button.action-danger {
    background: #fef2f2;
    color: #991b1b;
}

.row-actions-menu button.action-danger:hover {
    background: #fee2e2;
}

.row-actions-menu button.is-loading {
    opacity: 0.72;
    pointer-events: none;
    position: relative;
}

.row-actions-menu button.is-loading::after {
    content: "";
    width: 12px;
    height: 12px;
    border: 2px solid #dbe7f7;
    border-top-color: #0b79d0;
    border-radius: 50%;
    display: inline-block;
    animation: admin-spin 0.8s linear infinite;
    margin-inline-start: auto;
}

.modal-large {
    max-width: 960px;
    width: min(960px, 95vw);
    text-align: right;
    max-height: 88vh;
    overflow: auto;
}

.modal-filters {
    margin-bottom: 10px;
    display: grid;
    grid-template-columns: 94px minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.modal-table-footer {
    margin-top: 0;
}

.admin-toast-stack {
    position: fixed;
    bottom: calc(18px + env(safe-area-inset-bottom));
    left: 18px;
    right: auto;
    width: min(360px, calc(100vw - 24px));
    min-width: 240px;
    max-width: 360px;
    z-index: 1200;
}

.admin-toast-stack .toast {
    width: 100%;
}

.admin-toast-stack .toast + .toast {
    margin-top: 8px;
}

.admin-fab {
    position: fixed;
    right: 18px;
    bottom: calc(18px + env(safe-area-inset-bottom));
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #0b79d0;
    color: #fff;
    box-shadow: 0 10px 24px rgba(11, 121, 208, 0.28);
    z-index: 1100;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.admin-fab.active {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px rgba(11, 121, 208, 0.32);
}

.admin-fab-panel {
    position: fixed;
    right: 18px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    width: 260px;
    border: 1px solid #dbe3ee;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
    padding: 8px;
    display: grid;
    gap: 6px;
    z-index: 1100;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(12px) scaleY(0.96);
    transform-origin: bottom right;
    transition: transform 0.17s ease, opacity 0.17s ease, visibility 0s linear 0.17s;
}

.admin-fab-panel.show,
.admin-fab-panel.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scaleY(1);
    transition: transform 0.17s ease, opacity 0.17s ease, visibility 0s linear 0s;
}

.admin-fab-panel button {
    border: none;
    background: #f8fbff;
    border-radius: 10px;
    min-height: 40px;
    padding: 8px 10px;
    text-align: right;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #334155;
    font-size: 0.82rem;
}

.admin-fab-panel button:hover {
    background: #edf5ff;
}

@keyframes sheet-drop-in {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes sheet-drop-out {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(14px);
    }
}

@media (max-width: 1024px) {
    .admin-layout,
    .admin-layout.sidebar-collapsed {
        grid-template-columns: 1fr;
    }

    .admin-sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1140;
    }

    .admin-sidebar {
        position: fixed;
        top: calc(env(safe-area-inset-top, 0px) + 10px);
        right: 12px;
        left: 12px;
        z-index: 1150;
        max-height: calc(100vh - env(safe-area-inset-top, 0px) - 22px);
        overflow: auto;
        opacity: 0;
        pointer-events: none;
        transform: translateY(-14px);
        transition: transform 0.24s ease, opacity 0.24s ease;
    }

    .admin-layout.sidebar-open .admin-sidebar {
        opacity: 1;
        pointer-events: auto;
        transform: translateY(0);
    }

    .admin-layout.sidebar-open .admin-sidebar-overlay {
        opacity: 1;
        pointer-events: auto;
    }
}

@media (min-width: 768px) and (max-width: 1024px) {
    .admin-section-head {
        align-items: flex-start;
    }

    .admin-head-title {
        width: 100%;
    }
}

@media (max-width: 767px) {
    .admin-shell {
        max-width: 100%;
    }

    .admin-header {
        flex-wrap: nowrap;
        gap: 10px;
    }

    .admin-header-right,
    .admin-header-left {
        width: auto;
    }

    .admin-header-right {
        margin-inline-end: auto;
    }

    .admin-section {
        padding: 12px;
    }

    .admin-section-head {
        flex-direction: column;
        align-items: stretch;
        position: sticky;
        top: 8px;
        z-index: 10;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(6px);
        padding-bottom: 8px;
        margin-bottom: 12px;
        border-bottom: 1px solid #eef2f7;
        border-radius: 10px;
        padding-inline: 6px;
    }

    .admin-head-title {
        width: 100%;
        flex-wrap: nowrap;
        align-items: center;
    }

    .admin-section-subtitle {
        font-size: 0.76rem;
    }

    .admin-filters {
        width: 100%;
        gap: 6px;
    }

    .admin-section-head .admin-filters .admin-input,
    .admin-section-head .admin-filters .admin-select {
        min-width: 0;
    }

    .admin-section-head .admin-filters .btn {
        min-height: 38px;
        padding-inline: 12px;
        white-space: nowrap;
    }

    .filter-stack {
        width: 100%;
        gap: 6px;
        grid-template-columns: 1fr;
    }

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

    .filter-search-row {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .filter-select-row .admin-select-compact {
        min-width: 0;
    }

    .channels-filters .filter-select-row {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .users-filters .filter-select-row {
        grid-template-columns: 1fr;
    }

    .events-filters .filter-select-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .events-filters {
        width: 100%;
    }

    .modal-filters {
        grid-template-columns: 1fr 1fr;
    }

    .modal-filters .admin-input {
        min-width: 0;
    }

    .modal-filters #userChannelsSearch {
        grid-column: 1 / -1;
        order: -1;
    }

    .admin-table {
        min-width: 100%;
        border-collapse: separate;
        border-spacing: 0 10px;
    }

    .admin-table thead {
        display: none;
    }

    .admin-table tbody tr.row-data {
        display: block;
        background: #fbfdff;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        padding: 8px 10px;
        box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
        margin-bottom: 10px;
    }

    .admin-table tbody tr.row-data:last-child {
        margin-bottom: 0;
    }

    .admin-table tbody tr.row-data td[data-label] {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
        border: 0;
        padding: 6px 0;
        font-size: 0.8rem;
        text-align: left;
    }

    .admin-table tbody tr.row-data td[data-label]::before {
        content: attr(data-label);
        color: #64748b;
        font-size: 0.74rem;
        font-weight: 600;
        text-align: right;
    }

    .admin-table tbody tr.row-data td[data-label] .row-actions {
        margin-inline-start: auto;
    }

    .admin-table tbody tr.row-data td.hide-mobile-col {
        display: none !important;
    }

    .table-wrap {
        overflow: visible;
    }

    .row-actions-menu {
        min-width: 200px;
    }

    .row-actions summary {
        min-height: 42px;
        width: auto;
        min-width: 88px;
        padding: 0 10px;
        gap: 6px;
        border-radius: 10px;
    }

    .row-actions summary span {
        display: inline;
        font-size: 0.78rem;
        font-weight: 600;
    }

    .row-actions[open] {
        position: static;
    }

    .row-actions[open]::before {
        content: none;
    }

    .row-actions[open] .row-actions-menu {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: calc(10px + env(safe-area-inset-bottom));
        top: auto;
        max-height: min(60vh, 420px);
        overflow: auto;
        border-radius: 14px;
        padding: 8px;
        box-shadow: 0 20px 34px rgba(15, 23, 42, 0.22);
        z-index: 1300;
        animation: sheet-drop-in 0.24s ease;
    }

    .row-actions.is-closing .row-actions-menu {
        pointer-events: none;
        animation: sheet-drop-out 0.24s ease forwards;
    }

    .row-actions-menu button {
        min-height: 46px;
        font-size: 0.82rem;
        border: 1px solid #e2e8f0;
    }

    .nav-count {
        min-width: 30px;
        font-size: 0.7rem;
    }

    .table-footer {
        gap: 8px;
    }

    .table-footer .btn {
        min-height: 42px;
    }

    .table-footer .btn-icon-only {
        width: 36px;
        min-width: 36px;
        min-height: 36px;
        padding: 0;
    }

    .admin-toast-stack {
        left: 12px;
        right: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom));
        width: auto;
        min-width: 0;
        max-width: none;
    }

    .admin-fab {
        display: inline-flex;
        right: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom));
        z-index: 1295;
    }

    .admin-fab-panel {
        right: 12px;
        bottom: calc(72px + env(safe-area-inset-bottom));
        width: min(320px, calc(100vw - 20px));
        z-index: 1300;
    }

    .modal-large {
        width: min(96vw, 960px);
        max-height: 90vh;
    }

    .modal-table-footer {
        gap: 8px;
    }

    .modal-table-footer .btn {
        min-height: 42px;
    }
}

@media (max-width: 767px) and (orientation: landscape) {
    .admin-sidebar {
        top: calc(env(safe-area-inset-top, 0px) + 8px);
        max-height: calc(100vh - env(safe-area-inset-top, 0px) - 18px);
    }

    .row-actions[open] .row-actions-menu {
        max-height: min(78vh, 360px);
    }

    .admin-fab-panel {
        width: min(420px, calc(100vw - 20px));
    }

    .admin-section-head {
        top: 4px;
    }

    .modal-large {
        max-height: 86vh;
    }
}

@media (prefers-reduced-motion: reduce) {
    .admin-section.active,
    .row-actions[open] .row-actions-menu,
    .admin-fab,
    .admin-fab i,
    .admin-fab-panel,
    .admin-fab-panel button,
    .admin-nav-btn {
        animation: none !important;
        transition: none !important;
    }
}
