body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f7fb;
    color: #1f2933;
}

.layout-body {
    display: flex;
    min-height: 100vh;
}

a {
    color: #2f5ed6;
    text-decoration: none;
}

.muted {
    color: #52606d;
    font-size: 0.9rem;
}

.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #f5f7fb;
}

.auth-container {
    width: min(360px, 90vw);
    background: #ffffff;
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: 0 20px 45px rgba(31, 41, 51, 0.12);
    box-sizing: border-box;
}

.auth-logo {
    display: block;
    width: 48px;
    height: 48px;
    margin: 0 auto 1.25rem;
    border-radius: 12px;
}

.auth-container h1 {
    margin: 0;
    font-size: 1.8rem;
    text-align: center;
}

.subtitle {
    text-align: center;
    color: #52606d;
    margin-bottom: 1.5rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-form label {
    font-weight: 500;
}

.auth-form input {
    padding: 0.75rem;
    border: 1px solid #d2d6dc;
    border-radius: 8px;
    font-size: 1rem;
}

.auth-form button {
    padding: 0.85rem;
    background: linear-gradient(135deg, #3f8efc 0%, #1b61f2 100%);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s ease-in, box-shadow 0.1s ease-in;
}

.auth-form button:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(31, 97, 242, 0.25);
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.alert-error {
    background: #fde8e8;
    color: #c52f2f;
}

.hint {
    text-align: center;
    font-size: 0.85rem;
    color: #52606d;
    margin-top: 1.5rem;
}

.sidebar {
    width: 240px;
    background: #10182b;
    color: #e0e7ff;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    box-shadow: 10px 0 24px rgba(10, 14, 28, 0.4);
    transition: transform 0.25s ease-in-out;
}

.sidebar-brand {
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-logo {
    width: 32px;
    height: 32px;
    border-radius: 8px;
}

.brand-title {
    font-size: 1.4rem;
    font-weight: 700;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-link {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    color: inherit;
    background: rgba(255, 255, 255, 0.04);
    transition: background 0.2s ease-out, transform 0.2s ease-out;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateX(4px);
}

.nav-link.active {
    background: linear-gradient(135deg, #2563eb 0%, #60a5fa 100%);
    color: #ffffff;
}

.layout-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: #f5f7fb;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2.5rem;
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(31, 41, 51, 0.07);
}

.topbar h1 {
    margin: 0;
    font-size: 1.5rem;
    letter-spacing: -0.02em;
}

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

.sidebar-toggle {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #1f2933;
    font-size: 1.6rem;
}

.topbar nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    font-size: 0.95rem;
}

.user-info {
    color: #52606d;
}

.logout-link {
    padding: 0.45rem 1.1rem;
    border-radius: 999px;
    border: 1px solid #d2d6dc;
    transition: background 0.2s ease-in;
}

.logout-link:hover {
    background: #eff6ff;
}

.layout-content {
    padding: 2.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    box-sizing: border-box;
}

.card {
    background: #ffffff;
    padding: 1.75rem;
    border-radius: 16px;
    box-shadow: 0 12px 30px rgba(31, 41, 51, 0.08);
    box-sizing: border-box;
}

.card h2 {
    margin-top: 0;
}

.logs-card {
    grid-column: 1 / -1;
}

.logs-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.logs-actions {
    display: flex;
    gap: 0.75rem;
}

.insights-button {
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    border: 1px solid #f59e0b;
    background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
    color: #ffffff;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.08s ease, box-shadow 0.12s ease;
    text-decoration: none;
    display: inline-block;
}

.insights-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(245, 158, 11, 0.25);
}

.stats-button {
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    border: 1px solid #8b5cf6;
    background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%);
    color: #ffffff;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.08s ease, box-shadow 0.12s ease;
    text-decoration: none;
    display: inline-block;
}

.stats-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(139, 92, 246, 0.25);
}

.refresh-button {
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    border: 1px solid #2563eb;
    background: linear-gradient(135deg, #2563eb 0%, #60a5fa 100%);
    color: #ffffff;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.08s ease, box-shadow 0.12s ease;
}

.refresh-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(37, 99, 235, 0.25);
}

.table-wrapper {
    overflow-x: auto;
    border-radius: 12px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.93rem;
}

.table thead {
    background: #f1f5ff;
}

.table th,
.table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.table tbody tr:hover {
    background: rgba(37, 99, 235, 0.05);
}

.table th {
    font-weight: 600;
    color: #334155;
}

.table td {
    color: #1f2937;
}

.ua-cell {
    max-width: 240px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: #52606d;
}

@media (max-width: 720px) {
    .table {
        border-collapse: separate;
    }

    .table thead {
        display: none;
    }

    .table tbody {
        display: block;
    }

    .table tbody tr {
        display: block;
        margin-bottom: 1rem;
        padding: 1rem;
        border-radius: 14px;
        border: 1px solid rgba(15, 23, 42, 0.08);
        background: #ffffff;
        box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
    }

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

    .table tbody tr td {
        display: block;
        padding: 0.35rem 0;
        border-bottom: none;
    }

    .table tbody tr td::before {
        content: attr(data-label);
        display: block;
        font-size: 0.75rem;
        font-weight: 600;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: #475569;
        margin-bottom: 0.1rem;
    }

    .table tbody tr td.empty-state {
        padding: 1.25rem;
    }

    .table tbody tr td.empty-state::before {
        content: none;
    }

    .users-table-wrapper {
        border: none;
        padding: 0;
    }

    .users-actions {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        gap: 0.35rem;
    }

    .ua-cell {
        white-space: normal;
        word-break: break-word;
    }
}

.alert-success {
    background: #ecfdf3;
    color: #166534;
}

.users-grid {
    display: grid;
    grid-template-columns: minmax(280px, 340px) 1fr;
    gap: 1.5rem;
    align-items: flex-start;
}

.user-form-card {
    position: sticky;
    top: 2rem;
}

.user-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.user-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.user-form input[type="text"],
.user-form input[type="email"],
.user-form input[type="password"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d2d6dc;
    border-radius: 10px;
    font-size: 0.95rem;
    box-sizing: border-box;
}

.user-form small {
    font-size: 0.75rem;
    color: #697586;
    margin-left: 0.25rem;
}

.form-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.form-switch input {
    width: 1.25rem;
    height: 1.25rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
}

.primary-button {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #3f8efc 0%, #1b61f2 100%);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s ease-in, box-shadow 0.1s ease-in;
}

.primary-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(31, 97, 242, 0.2);
}

.ghost-button {
    padding: 0.75rem 1.3rem;
    border-radius: 10px;
    border: 1px solid #d2d6dc;
    background: #ffffff;
    font-size: 0.95rem;
    font-weight: 500;
    color: #1f2933;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.ghost-button:hover {
    background: #f4f6fa;
}

.users-list-card {
    grid-column: span 1;
}

.users-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.user-filter {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.filter-row {
    display: flex;
    gap: 0.75rem;
}

.filter-row input[type="search"] {
    flex: 1;
    padding: 0.7rem 0.9rem;
    border: 1px solid #d2d6dc;
    border-radius: 10px;
}

.switch {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.switch input {
    width: 1.15rem;
    height: 1.15rem;
}

.users-table-wrapper {
    border: 1px solid rgba(15, 23, 42, 0.06);
    border-radius: 16px;
}

.users-table tbody tr.inactive {
    opacity: 0.65;
}

.user-cell {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.user-email {
    font-size: 0.85rem;
    color: #64748b;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-muted {
    background: #e2e8f0;
    color: #475569;
}

.users-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.link-button {
    background: none;
    border: none;
    padding: 0.25rem 0.6rem;
    font-size: 0.9rem;
    color: #2563eb;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.15s ease;
}

.link-button:hover {
    background: rgba(37, 99, 235, 0.1);
}

.link-button.warning {
    color: #c2410c;
}

.link-button.warning:hover {
    background: rgba(194, 65, 12, 0.12);
}

.link-button.success {
    color: #047857;
}

.link-button.success:hover {
    background: rgba(4, 120, 87, 0.12);
}

@media (max-width: 960px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 240px;
        padding: 2rem 1.5rem;
        transform: translateX(-100%);
        box-shadow: 20px 0 45px rgba(10, 14, 28, 0.45);
        z-index: 1000;
        justify-content: flex-start;
    }

    .sidebar.sidebar-open {
        transform: translateX(0);
    }

    .layout-body {
        display: block;
        overflow-x: hidden;
    }

    .sidebar-nav {
        width: 100%;
        flex-direction: column;
        gap: 0.75rem;
    }

    .layout-main {
        width: 100%;
        margin-left: 0;
        min-height: 100vh;
    }

    .sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 2.5rem;
        height: 2.5rem;
        border-radius: 999px;
        background: #e5edff;
    }

    .topbar {
        position: sticky;
        top: 0;
        z-index: 900;
        padding: 1rem 1.5rem;
    }

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

    .layout-content {
        padding: 2rem 1.5rem;
        display: block;
    }

    .users-grid {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
    }

    .user-form-card {
        position: static;
    }
}

@media (max-width: 600px) {
    .topbar-left h1 {
        font-size: 1.25rem;
    }

    .topbar-right {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .layout-content {
        padding: 1.5rem 1rem;
    }

    .card {
        margin-bottom: 1rem;
    }

    .filter-row {
        flex-direction: column;
    }

    .filter-row input[type="search"] {
        width: 100%;
    }
}
