:root {
    --jw-orange: #ed7000;
    --jw-dark: #2b2b31;
    --jw-surface: #f2f3f5;
    --jw-line: #d9dde3;
    --jw-blue: #325f9f;
    --jw-text: #21252c;
    --jw-muted: #5f6875;
    --mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
    --mobile-nav-row-height: 3.2rem;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Source Sans 3", "Segoe UI", sans-serif;
    color: var(--jw-text);
    background: linear-gradient(180deg, #f7f8fa 0%, #eef1f5 100%);
}

a {
    text-decoration: none;
}

.auth-shell {
    min-height: calc(100vh - 70px);
    display: grid;
    place-items: center;
    background: #f3f3f3;
    padding: 1.5rem 1rem;
}

.auth-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.auth-footer {
    margin-top: auto;
    padding: 1rem;
    background: #ededed;
    border-top: 1px solid #d8d8d8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.auth-footer__copyright {
    margin: 0;
    font-size: 0.9rem;
    color: #555d68;
}

.auth-footer__links {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.auth-footer__links a {
    color: var(--jw-blue);
    font-size: 0.9rem;
    font-weight: 600;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: 48px;
    background: var(--jw-dark);
    color: #f0f0ef;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.9rem 0 0;
}

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

.topbar-logo-link {
    width: 48px;
    height: 48px;
    background: var(--jw-orange);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.topbar-logo-image {
    width: 48px;
    height: auto;
    display: block;
}

.topbar-page-title {
    margin-left: 1rem;
    font-size: 1.2rem;
    font-weight: 500;
    color: #fff;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.topbar-actions a,
.topbar-actions button {
    color: #fff;
    font-weight: 600;
}

.app-layout {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    min-height: calc(100vh - 60px);
}

.sidebar {
    background: #f5f6f8;
    border-right: 1px solid var(--jw-line);
    padding: 1rem 0.75rem;
}

.menu {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.menu a {
    color: var(--jw-blue);
    font-weight: 600;
    border-radius: 8px;
    padding: 0.65rem 0.75rem;
}

.menu a.active,
.menu a:hover {
    color: #0f2e57;
    background: #dfe8f6;
}

.content {
    padding: 1.25rem;
    padding-bottom: 4.8rem;
}

.page-title {
    margin-bottom: 1rem;
    font-weight: 700;
}

.app-card {
    background: #fff;
    border: 1px solid var(--jw-line);
    border-radius: 12px;
    box-shadow: 0 6px 14px rgba(24, 35, 53, 0.06);
    padding: 1rem;
}

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

.stat-item {
    background: linear-gradient(135deg, #ffffff, #f4f7fc);
    border: 1px solid var(--jw-line);
    border-radius: 12px;
    padding: 0.95rem;
}

.stat-label {
    color: var(--jw-muted);
    font-size: 0.92rem;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    margin-top: 0.2rem;
}

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

.table thead th {
    background: #f1f4f8;
    font-size: 0.88rem;
    text-transform: uppercase;
    color: #4f5868;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.search-list {
    border: 1px solid var(--jw-line);
    border-radius: 10px;
    background: #fff;
    max-height: 240px;
    overflow-y: auto;
}

.search-item {
    width: 100%;
    text-align: left;
    border: 0;
    background: #fff;
    padding: 0.65rem;
    border-bottom: 1px solid #edf1f5;
}

.search-item:hover {
    background: #edf4ff;
}

.search-item-content {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.search-item-thumb {
    height: 30px;
    width: 30px;
    object-fit: cover;
    border: 2px solid #e4e8ef;
    border-radius: 4px;
    flex-shrink: 0;
}

.form-control,
.form-select {
    border-color: #c9d1dc;
    min-height: 44px;
}

.users-toolbar {
    align-items: stretch;
}

.users-toolbar-btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.users-search-form {
    margin: 0;
    align-items: stretch;
}

.users-search-form .form-control {
    min-width: 190px;
}

.publications-toolbar {
    align-items: stretch;
}

.publications-toolbar-btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.publications-search-form {
    margin: 0;
    align-items: stretch;
}

.publications-search-form .form-control {
    min-width: 220px;
}

.btn-primary {
    background: var(--jw-orange);
    border-color: var(--jw-orange);
}

.btn-primary:hover,
.btn-primary:focus {
    background: #e36600;
    border-color: #e36600;
}

.mobile-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ffffff;
    border-top: 1px solid var(--jw-line);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    z-index: 30;
    padding-bottom: var(--mobile-safe-bottom);
    min-height: calc(var(--mobile-nav-row-height) + var(--mobile-safe-bottom));
}

.mobile-nav a {
    padding: 0.8rem 0.35rem;
    min-height: var(--mobile-nav-row-height);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--jw-muted);
    font-weight: 600;
    font-size: 0.9rem;
}

.mobile-nav a.active {
    color: var(--jw-blue);
}

.login-layout {
    width: 100%;
    display: flex;
    justify-content: center;
}

.login-layout__main-container {
    width: 100%;
    max-width: 530px;
}

.login-layout__main-content {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 4px;
    padding: 1.05rem;
}

.login-layout__main-footer {
    margin-top: 1.2rem;
    text-align: center;
}

.login-page-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.9rem;
}

.login-page-logo {
    width: 48px;
    height: 48px;
    display: block;
}

.login-page-title {
    margin: 0;
    font-size: 2rem;
    font-weight: 400;
    color: #222;
}

.jw-login-form .form-label {
    margin-bottom: 0.35rem;
    font-weight: 600;
    color: #1f252d;
}

.jw-login-link-wrap {
    margin: 0 0 1rem;
    font-size: 0.95rem;
}

.jw-login-link-wrap a {
    color: var(--jw-blue);
}

.btn-outline-primary {
    color: var(--jw-orange);
    border-color: var(--jw-orange);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
    color: #fff;
    background: var(--jw-orange);
    border-color: var(--jw-orange);
}

.login-hint {
    color: #475160;
    margin-bottom: 1.15rem;
}

.my-work-entity {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.my-work-avatar,
.my-work-thumb {
    width: 30px;
    height: 30px;
    object-fit: cover;
    border: 2px solid #e4e8ef;
    border-radius: 6px;
    flex-shrink: 0;
    background: #f2f3f5;
}

.my-work-avatar-fallback {
    width: 30px;
    height: 30px;
    border-radius: 999px;
    border: 2px solid #e4e8ef;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--jw-blue);
    background: #f1f4f8;
    flex-shrink: 0;
}

@media (max-width: 992px) {
    .app-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .content {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .app-card,
    .table-wrap {
        width: 100%;
    }

    .count-header {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.75rem;
    }

    .count-header .btn {
        width: 100%;
    }

    .count-form-actions {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
    }

    .count-form-actions .btn {
        width: 100%;
    }

    .content {
        padding: 1rem;
        padding-bottom: calc(5.2rem + var(--mobile-safe-bottom));
    }

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

    .auth-shell {
        min-height: calc(100vh - 120px);
    }

    .auth-footer {
        padding: 0.9rem;
    }
}

@media (max-width: 576px) {
    .users-toolbar {
        width: 100%;
    }

    .users-search-form {
        flex: 1 1 auto;
    }

    .users-search-form .form-control {
        min-width: 0;
    }

    .publications-toolbar {
        width: 100%;
    }

    .publications-search-form {
        flex: 1 1 auto;
    }

    .publications-search-form .form-control {
        min-width: 0;
    }

    .topbar {
        padding: 0 0.6rem 0 0;
    }

    .topbar-logo-link {
        width: 52px;
    }

    .topbar-logo-image {
        width: 38px;
    }

    .topbar-page-title {
        margin-left: 0.75rem;
        font-size: 1.2rem;
    }

    .topbar-actions {
        gap: 0.75rem;
    }

    .count-form-actions {
        grid-template-columns: 1fr;
    }

    .login-layout__main-content {
        padding: 0.9rem;
    }

    .login-page-title {
        font-size: 1.8rem;
    }

    .login-page-logo {
        width: 44px;
        height: 44px;
    }

    .auth-footer {
        justify-content: center;
    }

    .auth-footer__copyright {
        width: 100%;
        text-align: center;
    }

    .auth-footer__links {
        justify-content: center;
    }
}
