* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg-dark: #1a1a2e;
    --bg-card: #16213e;
    --bg-sidebar: #0f3460;
    --accent: #e94560;
    --accent-hover: #ff6b81;
    --text: #eee;
    --text-muted: #999;
    --border: #2a2a4a;
    --success: #2ed573;
    --warning: #ffa502;
}

body {
    font-family: 'Segoe UI', -apple-system, sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
}

/* Login Page */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.login-container {
    width: 400px;
    padding: 40px;
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 28px;
    color: var(--accent);
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-muted);
    font-size: 14px;
}

.auth-form h2 {
    font-size: 20px;
    margin-bottom: 20px;
    text-align: center;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

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

.btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-sidebar);
    color: var(--text);
}

.btn-secondary:hover {
    background: #1a5276;
}

.btn-sm {
    width: auto;
    padding: 6px 14px;
    font-size: 13px;
}

.btn-danger {
    background: #c0392b;
    color: white;
}

.btn-success {
    background: var(--success);
    color: #1a1a2e;
}

.form-footer {
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-muted);
}

.form-footer a {
    color: var(--accent);
    text-decoration: none;
}

.error-msg {
    color: var(--accent);
    font-size: 13px;
    text-align: center;
    margin-top: 12px;
    min-height: 20px;
}

.success-msg {
    color: var(--success);
    font-size: 13px;
    text-align: center;
    margin-top: 12px;
}

/* Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--bg-sidebar);
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 0 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 10px;
}

.sidebar-header h2 {
    font-size: 18px;
    color: var(--accent);
}

.sidebar-header small {
    color: var(--text-muted);
    font-size: 12px;
}

.sidebar-menu {
    flex: 1;
    list-style: none;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    transition: background 0.2s;
}

.sidebar-menu li a:hover,
.sidebar-menu li a.active {
    background: rgba(233, 69, 96, 0.2);
    border-right: 3px solid var(--accent);
}

.sidebar-menu li a .icon {
    font-size: 18px;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-footer .user-info {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.sidebar-footer .user-info strong {
    color: var(--text);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 24px;
    margin-bottom: 4px;
}

.page-header p {
    color: var(--text-muted);
    font-size: 14px;
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.card h3 {
    margin-bottom: 16px;
    font-size: 16px;
}

/* Table */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
}

/* Badge */
.badge {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge-superadmin { background: var(--accent); color: white; }
.badge-member { background: var(--success); color: #1a1a2e; }
.badge-pending { background: var(--warning); color: #1a1a2e; }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 30px;
    width: 420px;
    max-width: 90vw;
    border: 1px solid var(--border);
}

.modal h3 {
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.modal-actions .btn {
    width: auto;
    padding: 8px 20px;
}

/* Server list */
.server-list {
    list-style: none;
}

.server-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background: rgba(26, 26, 46, 0.7);
}

.server-item:hover {
    border-color: var(--accent);
    background: rgba(233, 69, 96, 0.15);
}

.server-item.connected {
    border-color: var(--success);
    background: rgba(46, 213, 115, 0.15);
}

.server-item .server-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.server-item .status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
}

.server-item.connected .status-dot {
    background: var(--success);
}

/* Terminal */
.terminal-container {
    display: flex;
    height: calc(100vh - 48px);
    gap: 0;
}

.terminal-sidebar {
    width: 280px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 16px;
    overflow-y: auto;
    flex-shrink: 0;
}

.terminal-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.terminal-main #terminal {
    flex: 1;
}

.terminal-status {
    padding: 8px 16px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-muted);
}

/* Checkbox toggle */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}

.toggle-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

/* Password input wrapper */
.pw-wrapper {
    position: relative;
}

.pw-wrapper input {
    width: 100%;
    padding-right: 44px;
}

.pw-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0;
    color: var(--text-muted);
    width: auto;
}

.pw-toggle:hover {
    color: var(--text);
}

/* Profile dropdown */
.profile-section {
    padding: 0 20px;
}

.profile-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 10px 0;
    user-select: none;
}

.profile-toggle:hover {
    color: var(--accent);
}

.profile-toggle .arrow {
    transition: transform 0.2s;
    font-size: 12px;
}

.profile-toggle.open .arrow {
    transform: rotate(180deg);
}

.profile-detail {
    display: none;
    padding: 8px 0 12px;
    font-size: 13px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.profile-detail.open {
    display: block;
}

.profile-detail .info-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    color: var(--text-muted);
}

.profile-detail .info-row span:last-child {
    color: var(--text);
}

.profile-actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}

.profile-actions .btn {
    flex: 1;
    font-size: 12px;
    padding: 6px 0;
}

/* Password strength indicator */
.pw-strength {
    height: 3px;
    border-radius: 2px;
    margin-top: 6px;
    background: var(--border);
    overflow: hidden;
}

.pw-strength-bar {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s, background 0.3s;
    width: 0;
}

.pw-rules {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
    line-height: 1.6;
}

.pw-rules .pass { color: var(--success); }
.pw-rules .fail { color: var(--accent); }

/* Server action buttons */
.srv-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 2px 4px;
    line-height: 1;
    opacity: 0.5;
    transition: opacity 0.2s, transform 0.15s;
}

.srv-action-btn:hover {
    opacity: 1;
    transform: scale(1.2);
}

/* Sidebar toggle */
.sidebar-toggle {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1100;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 20px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    line-height: 1;
    padding: 0;
}

.sidebar-toggle:hover {
    background: var(--accent);
}

.sidebar {
    transition: transform 0.25s, width 0.25s;
}

.sidebar.collapsed {
    transform: translateX(-100%);
    overflow: hidden;
}

.sidebar.collapsed + .main-content {
    margin-left: 0;
}

.sidebar-header {
    padding-left: 50px;
}

/* Responsive - Mobile Optimized */
@media (max-width: 768px) {
    .login-container {
        width: 95%;
        padding: 24px 20px;
        border-radius: 12px;
    }
    .login-header h1 { font-size: 22px; }
    .login-header p { font-size: 12px; }

    /* Sidebar: slide-out on mobile */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 240px;
        z-index: 1050;
        transform: translateX(-100%);
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    .sidebar.collapsed {
        transform: translateX(-100%);
    }

    /* Sidebar overlay */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1040;
    }
    .sidebar-overlay.active {
        display: block;
    }

    .sidebar-header { padding-left: 20px; }
    .sidebar-menu li a { padding: 14px 20px; font-size: 15px; }
    .sidebar-menu li a span { display: inline; }

    /* Main content full width */
    .main-content {
        padding: 16px 12px;
        margin-left: 0 !important;
    }

    .page-header h1 { font-size: 18px; }
    .page-header p { font-size: 12px; }

    /* Cards compact */
    .card { padding: 16px; border-radius: 10px; margin-bottom: 12px; }
    .card h3 { font-size: 14px; margin-bottom: 12px; }

    /* Table mobile scroll */
    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -12px;
        padding: 0 12px;
    }
    th, td {
        padding: 8px 10px;
        font-size: 12px;
        white-space: nowrap;
    }
    th { font-size: 10px; }

    /* Buttons touch-friendly */
    .btn { padding: 14px; font-size: 15px; border-radius: 10px; }
    .btn-sm { padding: 8px 14px; font-size: 13px; }

    /* Modal full-width on mobile */
    .modal {
        width: 100%;
        max-width: 100vw;
        border-radius: 16px 16px 0 0;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 80vh;
        overflow-y: auto;
        padding: 24px 20px;
    }
    .modal-overlay {
        align-items: flex-end;
    }

    /* Form inputs larger touch targets */
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 14px 16px;
        font-size: 16px; /* prevents iOS zoom */
        border-radius: 10px;
    }

    /* Terminal mobile */
    .terminal-container {
        flex-direction: column;
        height: calc(100vh - 48px);
    }
    .terminal-sidebar {
        width: 100%;
        height: auto;
        max-height: 35vh;
        border-right: none;
        border-bottom: 1px solid var(--border);
        overflow-y: auto;
        padding: 12px;
    }
    .terminal-main { flex: 1; min-height: 0; }
    .terminal-status { font-size: 11px; padding: 6px 12px; }

    /* Server list compact */
    .server-item { padding: 10px 12px; }
    .server-item .server-info { gap: 8px; }

    /* Sidebar toggle always visible on mobile */
    .sidebar-toggle {
        display: flex;
        top: 8px;
        left: 8px;
        width: 40px;
        height: 40px;
        font-size: 22px;
    }

    /* Badge */
    .badge { font-size: 10px; padding: 2px 8px; }

    /* Profile section */
    .profile-detail .info-row { font-size: 12px; }
    .profile-actions .btn { font-size: 11px; padding: 8px 0; }

    /* Fix overflow */
    body { overflow-x: hidden; }
}

/* Small phones */
@media (max-width: 380px) {
    .login-container { padding: 20px 16px; }
    .main-content { padding: 12px 8px; }
    .card { padding: 12px; }
    .form-group input { padding: 12px 14px; }
}
