:root {
    --bg-color: #0d1117;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --accent-color: #58a6ff;
    --accent-hover: #3182ce;
    --glass-bg: rgba(22, 27, 34, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);

    --status-running: #2ea043;
    --status-stopped: #da3633;
    --status-unknown: #d29922;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-color);
    background-image:
        radial-gradient(circle at 15% 50%, rgba(31, 111, 235, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 85% 30%, rgba(137, 87, 229, 0.08) 0%, transparent 50%);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 2rem;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInDown 0.8s ease;
}

header h1 {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(90deg, #58a6ff, #a371f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-secondary);
    font-size: 1.2rem;
}

/* Stats */
.stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 3rem;
    animation: fadeIn 1s ease;
    flex-wrap: wrap;
}

.stat-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem 2rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--glass-shadow);
    text-align: center;
    flex: 1;
    min-width: 200px;
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-card h3 {
    color: var(--text-secondary);
    font-weight: 400;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.stat-card p {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent-color);
}

/* Grid */
.servers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
    gap: 2rem;
    animation: fadeInUp 1s ease;
}

.server-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--glass-shadow);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.server-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background-color: var(--status-unknown);
    transition: background-color 0.3s ease;
}

.server-card[data-status="RUNNING"]::before {
    background-color: var(--status-running);
}

.server-card[data-status="SHUTOFF"]::before {
    background-color: var(--status-stopped);
}

.server-card:hover {
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.4);
}

.server-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.server-name {
    font-size: 1.25rem;
    font-weight: 600;
    word-break: break-all;
}

.server-status {
    font-size: 0.8rem;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.1);
    font-weight: 600;
    letter-spacing: 0.5px;
}

.status-running {
    color: var(--status-running);
    background: rgba(46, 160, 67, 0.15);
}

.status-stopped {
    color: var(--status-stopped);
    background: rgba(218, 54, 51, 0.15);
}

.server-info {
    flex-grow: 1;
    margin-bottom: 1.5rem;
}

.info-label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.info-value {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.analyst-assigned {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.8rem;
    background: rgba(88, 166, 255, 0.1);
    border: 1px solid rgba(88, 166, 255, 0.2);
    border-radius: 8px;
    color: var(--accent-color);
    font-weight: 600;
}

.btn {
    width: 100%;
    padding: 0.75rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn.primary {
    background: var(--accent-color);
    color: #fff;
    box-shadow: 0 4px 14px 0 rgba(88, 166, 255, 0.39);
}

.btn.primary:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px 0 rgba(88, 166, 255, 0.45);
}

.btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.btn.secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Users page */
.users-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    text-align: left;
}

.users-header-meta {
    text-align: right;
}

.welcome-message {
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.users-home-btn,
.users-create-btn {
    width: auto;
    font-size: 0.9rem;
}

.users-home-btn {
    padding: 0.5rem 1rem;
}

.users-create-btn {
    padding: 0.6rem 1.1rem;
    border: 1px solid rgba(149, 204, 255, 0.28);
    background: linear-gradient(135deg, rgba(88, 166, 255, 0.95), rgba(127, 92, 242, 0.92));
}

.users-card {
    margin-bottom: 1rem;
    padding: 1.1rem 1.1rem 0.9rem;
}

.users-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.85rem;
}

.users-table-wrap {
    overflow-x: auto;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.01));
}

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

.users-table thead tr {
    background: rgba(255, 255, 255, 0.05);
}

.users-table th {
    text-align: left;
    padding: 0.78rem 0.72rem;
    color: #b7c1cc;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    font-size: 0.74rem;
}

.users-table td {
    padding: 0.75rem 0.72rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.users-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.users-actions-column,
.users-table .users-actions-cell {
    text-align: right;
}

.users-table-empty {
    color: var(--text-secondary);
    text-align: center;
    padding: 1.2rem;
}

.users-role-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.6rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.07);
}

.users-role-pill.admin {
    color: #9dd2ff;
    background: rgba(88, 166, 255, 0.14);
    border-color: rgba(88, 166, 255, 0.33);
}

.users-role-pill.analyst {
    color: #c8b2ff;
    background: rgba(163, 113, 247, 0.14);
    border-color: rgba(163, 113, 247, 0.33);
}

.success-message {
    color: #7ee787;
    background: rgba(46, 160, 67, 0.13);
    border: 1px solid rgba(46, 160, 67, 0.3);
    border-radius: 10px;
    padding: 0.55rem 0.75rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    text-align: center;
}

.user-actions-menu {
    position: relative;
    display: inline-block;
}

.users-action-trigger {
    width: auto;
    min-width: 78px;
    padding: 0.35rem 0.95rem;
    font-size: 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
}

.user-actions-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 0.4rem);
    min-width: 180px;
    display: grid;
    gap: 0.3rem;
    padding: 0.35rem;
    background: rgba(18, 23, 31, 0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    box-shadow: 0 18px 38px rgba(0, 0, 0, 0.45);
    z-index: 30;
}

.user-actions-dropdown .btn {
    width: 100%;
    padding: 0.45rem 0.6rem;
    font-size: 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.09);
    background: rgba(255, 255, 255, 0.04);
}

.user-actions-dropdown .btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

.user-actions-dropdown .users-delete-btn {
    color: #ff8e86;
    border-color: rgba(218, 54, 51, 0.28);
    background: rgba(218, 54, 51, 0.11);
}

.user-actions-dropdown .users-delete-btn:hover {
    background: rgba(218, 54, 51, 0.18);
}

.user-actions-dropdown .btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.users-modal-content {
    max-width: 520px;
}

.users-modal-title {
    margin-bottom: 1rem;
}

.users-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.users-admin-group {
    display: flex;
    align-items: end;
}

.users-admin-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

.users-submit-btn {
    max-width: 240px;
}

/* Routing page */
.routing-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.85rem;
}

.routing-rules {
    display: grid;
    gap: 0.65rem;
}

.routing-rule {
    font-family: monospace;
    font-size: 0.9rem;
    color: #dce7f5;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 0.6rem 0.75rem;
    word-break: break-word;
}

/* Audit logs page */
.audit-details {
    margin: 0;
    font-family: monospace;
    font-size: 0.8rem;
    color: #dce7f5;
    max-width: 420px;
    max-height: 140px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Utility */
.hidden {
    display: none !important;
}

.loading {
    text-align: center;
    font-size: 1.5rem;
    color: var(--text-secondary);
    margin-top: 4rem;
    animation: pulse 1.5s infinite ease-in-out;
}

.error-message {
    background: rgba(218, 54, 51, 0.1);
    border: 1px solid var(--status-stopped);
    color: #ff7b72;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    margin-bottom: 2rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

.modal-content.glass-panel {
    background: rgba(22, 27, 34, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 500px;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal:not(.hidden) .modal-content {
    transform: scale(1);
}

.close-button {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s;
}

.close-button:hover {
    color: var(--text-primary);
}

.modal-content h2 {
    margin-bottom: 1rem;
}

.modal-content p {
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-group input {
    width: 100%;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus {
    border-color: var(--accent-color);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.6;
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    body {
        padding: 1rem;
    }

    header h1 {
        font-size: 2rem;
    }

    .stats {
        gap: 1rem;
        flex-direction: column;
    }

    .stat-card {
        min-width: 100%;
        padding: 1rem;
    }

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

    .modal-content.glass-panel {
        padding: 1.5rem;
    }

    .users-header {
        flex-direction: column;
        align-items: stretch;
    }

    .users-header-meta {
        text-align: left;
    }

    .users-toolbar {
        justify-content: flex-start;
    }

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