:root {
    --admin-primary: #277ea7;
    --admin-bg: #ededed;
    --admin-ink: #1d2830;
    --admin-muted: #6b7881;
    --admin-border: #d5dee4;
    --admin-card: #ffffff;
    --admin-danger: #dc3545;
    --admin-success: #198754;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--admin-ink);
    background: var(--admin-bg);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

.app-shell {
    min-height: 100vh;
}

.auth-page {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    background: var(--admin-bg);
}

.top-bar,
.mobile-top-bar {
    background: var(--admin-primary);
    color: #fff;
}

.auth-card,
.panel,
.list-item,
.device-card,
.modal-content {
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    background: var(--admin-card);
}

.auth-card {
    width: min(420px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 24px;
}

.auth-content {
    display: grid;
    align-items: center;
    padding-bottom: clamp(28px, 7vh, 54px);
}

.brand-logo {
    width: 72px;
    height: 72px;
    object-fit: contain;
}

.layout {
    display: grid;
    min-height: 100vh;
    grid-template-columns: 280px 1fr;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    color: #fff;
    background: #1e5e7d;
}

.sidebar-backdrop {
    display: none;
}

.sidebar-close {
    display: none;
}

.sidebar-header {
    padding: 22px;
    background: var(--admin-primary);
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    color: rgba(255, 255, 255, 0.9);
    border-radius: 6px;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.14);
}

.content {
    min-width: 0;
}

.page-wrap {
    width: min(1180px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 20px 0 36px;
}

.page-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.page-title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
}

.panel {
    padding: 16px;
}

.headline-marquee {
    overflow: hidden;
    padding: 8px 0;
    border-radius: 0;
    background: var(--admin-danger);
    color: #fff;
    white-space: nowrap;
}

.headline-marquee-text {
    display: inline-block;
    min-width: 100%;
    padding-left: 100%;
    font-size: 0.95rem;
    font-weight: 700;
    animation: headline-marquee 16s linear infinite;
}

@keyframes headline-marquee {
    from {
        transform: translateX(0);
    }

    to {
        transform: translateX(-100%);
    }
}

.home-summary {
    position: relative;
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(280px, auto);
    align-items: center;
    gap: 18px;
    padding: 18px 18px 18px 22px;
    border: 1px solid #c8dbe5;
    border-radius: 8px;
    background: linear-gradient(90deg, rgba(39, 126, 167, 0.1), rgba(255, 255, 255, 0) 42%),
    var(--admin-card);
    box-shadow: 0 10px 24px rgba(29, 40, 48, 0.07);
}

.home-summary::before {
    position: absolute;
    inset: 0 auto 0 0;
    width: 5px;
    content: "";
    background: #277ea7;
}

.home-project {
    position: relative;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.home-project-icon {
    width: 42px;
    height: 42px;
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    color: var(--admin-primary);
    border-radius: 8px;
    background: #e6f3f8;
    border: 1px solid #bfdae7;
    font-size: 1.2rem;
}

.home-eyebrow,
.home-count-label {
    color: var(--admin-muted);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.home-project-title {
    color: #152630;
    font-size: 1.12rem;
    font-weight: 700;
    line-height: 1.15;
}

.home-project-subtitle {
    max-width: 460px;
    color: var(--admin-muted);
    font-size: 0.9rem;
}

.home-counts {
    display: grid;
    grid-template-columns: repeat(3, 72px);
    justify-content: end;
    gap: 10px;
    min-width: 0;
}

.home-count {
    position: relative;
    overflow: hidden;
    width: 72px;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 12px 10px;
    border: 1px solid #d2e0e7;
    border-radius: 8px;
    background: #f8fbfc;
}

.home-count::before {
    position: absolute;
    inset: 0 0 auto;
    height: 5px;
    content: "";
    background: var(--admin-primary);
}

.home-count-total {
    background: #f6fbfd;
}

.home-count-online {
    border-color: #c7e4d4;
    background: #f4fbf7;
}

.home-count-online::before {
    background: var(--admin-success);
}

.home-count-offline {
    border-color: #eadba8;
    background: #fffaf0;
}

.home-count-offline::before {
    background: #ffc107;
}

.home-count-value {
    display: block;
    font-size: clamp(1.25rem, 2vw, 1.65rem);
    font-weight: 700;
    line-height: 1;
}

.home-count-label {
    display: block;
    font-weight: 600;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.stat-tile {
    padding: 14px;
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    background: #f8fbfc;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.toolbar .search-group {
    display: flex;
    flex: 1 1 320px;
    gap: 8px;
}

.list-stack {
    min-width: 0;
    display: grid;
    gap: 10px;
}

.list-item {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding: 14px;
}

.card-actions {
    display: inline-flex;
    flex: 0 0 auto;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.card-actions .btn {
    width: 32px;
    height: 32px;
    display: inline-grid;
    flex: 0 0 32px;
    place-items: center;
    padding: 0;
    line-height: 1;
}

.user-card-clickable {
    cursor: pointer;
    transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.user-card-clickable:hover,
.user-card-clickable:focus-visible {
    border-color: #8fbfd5;
    outline: none;
    box-shadow: 0 6px 16px rgba(29, 40, 48, 0.09);
    transform: translateY(-1px);
}

.user-card-header {
    width: 100%;
    min-width: 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.user-card-identity {
    min-width: 0;
    flex: 1 1 auto;
}

.user-card-details {
    width: 100%;
    min-width: 0;
    margin-top: 8px;
}

.list-item pre {
    white-space: pre-wrap;
    margin: 0;
    font-family: inherit;
}

.data-html {
    line-height: 1.45;
}

.muted {
    color: var(--admin-muted);
}

.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 6px;
    border-radius: 999px;
    background: var(--admin-muted);
}

.status-dot.online {
    background: var(--admin-success);
}

.status-dot.offline {
    background: #ffc107;
}

.status-dot.uninstalled {
    background: var(--admin-danger);
}

.user-status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 8px;
    border: 1px solid currentColor;
    border-radius: 5px;
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1;
    background: #fff;
}

.user-status-badge.online {
    color: #328634;
}

.user-status-badge.offline {
    color: #f44336;
}

.user-status-badge.uninstalled {
    color: #777;
}

.user-detail-row,
.user-sim-row {
    min-width: 0;
    overflow-wrap: anywhere;
    margin-top: 5px;
    padding: 5px 8px;
    font-size: 0.82rem;
    line-height: 1.25;
}

.user-detail-row {
    background: rgba(112, 112, 112, 0.1);
}

.user-last-seen {
    color: #d32f2f;
    background: rgba(244, 67, 54, 0.1);
}

.user-sim-row.sim-one {
    background: rgba(33, 150, 243, 0.1);
}

.user-sim-row.sim-two {
    background: rgba(244, 67, 54, 0.1);
}

.user-overview {
    overflow: hidden;
    border: 1px solid #cbdbe3;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 10px 24px rgba(29, 40, 48, 0.07);
}

.user-overview-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid #cbdbe3;
    background: #eef7fa;
}

.user-device-mark {
    width: 38px;
    height: 38px;
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    color: #fff;
    border-radius: 8px;
    background: var(--admin-primary);
    font-size: 1.1rem;
}

.user-device-identity {
    min-width: 0;
    flex: 1 1 auto;
}

.user-overview-eyebrow,
.user-meta-label {
    color: var(--admin-muted);
    font-size: 0.72rem;
    font-weight: 750;
    text-transform: uppercase;
}

.user-device-name {
    overflow: hidden;
    margin: 1px 0 0;
    font-size: 1.02rem;
    font-weight: 700;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-device-os {
    margin-top: 1px;
    color: var(--admin-muted);
    font-size: 0.82rem;
}

.user-presence {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    padding: 5px 8px;
    border: 1px solid currentColor;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 800;
    background: #fff;
}

.user-presence.online {
    color: var(--admin-success);
}

.user-presence.offline {
    color: #d97900;
}

.user-presence.uninstalled {
    color: #6c757d;
}

.user-overview-body {
    padding: 12px;
}

.user-meta-grid {
    display: grid;
    grid-template-columns: minmax(240px, 1.3fr) repeat(2, minmax(190px, 1fr));
    gap: 8px;
}

.user-meta-item,
.user-forward-item {
    min-width: 0;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 9px 10px;
    border: 1px solid #d9e3e8;
    border-radius: 7px;
    background: #f8fbfc;
}

.user-meta-icon,
.user-forward-icon,
.user-sim-icon {
    width: 28px;
    height: 28px;
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 7px;
}

.user-meta-icon {
    color: var(--admin-primary);
    background: #e2f0f6;
}

.user-meta-value {
    color: #17262e;
    font-size: 0.82rem;
    font-weight: 700;
}

.user-meta-note {
    margin-top: 1px;
    color: var(--admin-muted);
    font-size: 0.72rem;
}

.user-forward-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.user-forward-item.enabled {
    border-color: #bcdcca;
    background: #f3faf6;
}

.user-forward-item.disabled {
    background: #f8f9fa;
}

.user-forward-item.enabled .user-forward-icon {
    color: var(--admin-success);
    background: #dff1e7;
}

.user-forward-item.disabled .user-forward-icon {
    color: #7a858c;
    background: #e8ecef;
}

.user-forward-value {
    font-size: 0.82rem;
    font-weight: 700;
}

.user-forward-item.enabled .user-forward-value {
    color: #166b43;
}

.user-forward-item.disabled .user-forward-value {
    color: #6f7a81;
}

.user-numbers-section {
    margin-top: 12px;
}

.user-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 7px;
    font-size: 0.84rem;
    font-weight: 800;
}

.user-number-count {
    min-width: 19px;
    height: 19px;
    display: inline-grid;
    place-items: center;
    padding: 0 6px;
    color: #fff;
    border-radius: 999px;
    background: var(--admin-primary);
    font-size: 0.66rem;
}

.user-number-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.user-number-item {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    border: 1px solid #d6e1e6;
    border-radius: 7px;
    background: #fff;
}

.user-number-item.selected {
    border-color: #89bfd6;
    background: #f1f8fb;
    box-shadow: inset 3px 0 0 var(--admin-primary);
}

.user-sim-icon {
    color: var(--admin-primary);
    background: #e2f0f6;
    font-size: 1.05rem;
}

.user-number-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.user-sim-label {
    color: var(--admin-muted);
    font-size: 0.72rem;
    font-weight: 800;
}

.user-selected-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #166b43;
    font-size: 0.7rem;
    font-weight: 800;
}

.user-phone-number {
    overflow: hidden;
    margin-top: 1px;
    font-size: 0.86rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-carrier {
    color: var(--admin-muted);
    font-size: 0.77rem;
}

.user-empty-numbers {
    grid-column: 1 / -1;
    padding: 16px;
    color: var(--admin-muted);
    border: 1px dashed #cbd7dd;
    border-radius: 7px;
    text-align: center;
    background: #f8fafb;
}

.device-grid,
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.tabs-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
}

.tab-pill {
    white-space: nowrap;
}

.file-grid,
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.file-tile,
.image-tile {
    min-height: 132px;
    padding: 12px;
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    background: #fff;
}

.storage-status {
    min-height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px;
    color: var(--admin-muted);
    text-align: center;
}

.storage-path-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    padding: 10px 12px;
    border-bottom: 2px solid var(--admin-primary);
    background: #fff;
}

.storage-path {
    min-width: 0;
    flex: 1 1 auto;
    font-size: 0.86rem;
    font-weight: 700;
}

.storage-list {
    display: grid;
    gap: 10px;
    padding: 10px;
    background: var(--admin-bg);
}

.storage-row {
    width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 28px;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    color: var(--admin-text);
    text-align: left;
    background: #fff;
    box-shadow: 0 3px 10px rgba(29, 40, 48, 0.06);
}

button.storage-row {
    cursor: pointer;
}

.storage-row:hover,
.storage-row:focus-visible {
    border-color: #8fbfd5;
    outline: none;
}

.storage-file-icon {
    display: grid;
    place-items: center;
    color: var(--admin-primary);
    font-size: 1.55rem;
}

.storage-file-icon.folder {
    color: #e2a312;
}

.storage-file-icon.pdf {
    color: var(--admin-danger);
}

.storage-file-icon.audio {
    color: #6f42c1;
}

.storage-file-icon.video {
    color: #d63384;
}

.storage-file-copy {
    min-width: 0;
    display: block;
}

.storage-file-name,
.storage-file-info {
    overflow: hidden;
    display: block;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.storage-file-name {
    font-size: 0.9rem;
    font-weight: 700;
}

.storage-file-info {
    margin-top: 3px;
    color: var(--admin-muted);
    font-size: 0.78rem;
}

.storage-action-icon {
    justify-self: center;
    color: var(--admin-primary);
    font-size: 1rem;
}

.storage-empty {
    padding: 60px 20px;
    color: var(--admin-muted);
    text-align: center;
}

.image-tile {
    min-height: 190px;
}

.image-preview {
    width: 100%;
    aspect-ratio: 1 / 1;
    display: grid;
    place-items: center;
    border-radius: 6px;
    color: var(--admin-muted);
    background: #eef4f7;
}

.gallery-status {
    min-height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px;
    color: var(--admin-muted);
    text-align: center;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 8px;
    background: #111;
}

.gallery-tile {
    position: relative;
    overflow: hidden;
    width: 100%;
    padding: 0;
    border: 0;
    border-radius: 4px;
    aspect-ratio: 1 / 1;
    color: var(--admin-primary);
    background: #e6e6e6;
}

.gallery-tile:disabled {
    opacity: 1;
}

.gallery-tile:not(:disabled) {
    cursor: pointer;
}

.gallery-tile:not(:disabled):hover img {
    transform: scale(1.03);
}

.gallery-image-host {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
}

.gallery-image-host img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 160ms ease;
}

.gallery-error {
    color: var(--admin-danger);
    font-size: 1.8rem;
}

.gallery-load-more {
    display: flex;
    justify-content: center;
    padding: 18px;
}

.icon-xl {
    font-size: 2rem;
}

.hide {
    display: none !important;
}

@media (max-width: 900px) {
    .layout {
        display: block;
    }

    .sidebar {
        position: fixed;
        z-index: 1060;
        inset: 0 auto 0 0;
        width: min(300px, 82vw);
        transform: translateX(-102%);
        transition: transform 180ms ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 auto;
    }

    .sidebar-backdrop {
        position: fixed;
        z-index: 1055;
        inset: 0;
        display: block;
        pointer-events: none;
        opacity: 0;
        background: rgba(13, 24, 31, 0.45);
        transition: opacity 180ms ease;
    }

    .sidebar-backdrop.show {
        pointer-events: auto;
        opacity: 1;
    }

    .mobile-top-bar {
        display: flex !important;
    }

    .page-wrap {
        width: min(100% - 20px, 1180px);
        padding-top: 12px;
    }

    .home-counts {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .stats-grid,
    .device-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .user-meta-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .user-meta-id {
        grid-column: 1 / -1;
    }
}

@media (max-width: 640px) {
    .page-title-row {
        align-items: center;
    }

    .page-title-row > .d-flex {
        width: auto;
        justify-content: flex-end;
    }

    .page-title-row .btn {
        flex: 0 0 auto;
    }

    .toolbar,
    .toolbar .search-group {
        display: grid;
        grid-template-columns: 1fr auto auto;
        width: 100%;
    }

    .toolbar > .d-flex {
        width: 100%;
    }

    .toolbar > .d-flex .btn {
        flex: 1 1 0;
    }

    .file-grid,
    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
    }

    .auth-card {
        width: min(100% - 20px, 420px);
        margin: 0 auto;
        padding: 18px;
    }

    .auth-content {
        padding-bottom: clamp(18px, 4vh, 30px);
    }

    .user-overview-header {
        align-items: flex-start;
        padding: 10px 12px;
    }

    .user-overview-body {
        padding: 10px;
    }

    .user-device-mark {
        width: 36px;
        height: 36px;
    }

    .user-presence {
        padding: 4px 7px;
    }

    .user-meta-grid,
    .user-forward-grid,
    .user-number-list {
        grid-template-columns: 1fr;
    }

    .user-meta-id {
        grid-column: auto;
    }
}

@media (max-width: 560px) {
    .home-summary {
        grid-template-columns: minmax(128px, 0.85fr) minmax(0, 2fr);
        gap: 8px;
        padding: 12px 10px 12px 15px;
    }

    .home-project-icon {
        width: 34px;
        height: 34px;
    }

    .home-project {
        gap: 7px;
    }

    .home-project-title {
        font-size: 0.92rem;
    }

    .home-project-subtitle {
        font-size: 0.76rem;
    }

    .home-counts {
        grid-template-columns: repeat(3, 58px);
        gap: 5px;
    }

    .home-count {
        width: 58px;
        flex-direction: column;
        gap: 4px;
        padding: 12px 3px 7px;
    }

    .home-count-label {
        font-size: 0.62rem;
    }
}

@media (max-width: 420px) {
    .home-summary {
        grid-template-columns: minmax(88px, 0.75fr) minmax(0, 2.25fr);
        gap: 6px;
        padding-right: 7px;
    }

    .home-project-icon {
        display: none;
    }

    .home-counts {
        grid-template-columns: repeat(3, 54px);
        gap: 4px;
    }

    .home-count {
        width: 54px;
    }

    .home-count-value {
        font-size: 1.15rem;
    }

    .list-item {
        padding: 10px;
    }

    .user-card-header {
        gap: 6px;
    }

    .card-actions .btn {
        width: 28px;
        height: 28px;
        flex-basis: 28px;
    }

    .file-grid,
    .image-grid {
        grid-template-columns: 1fr;
    }
}
