/* ─── RESET & BASE ─────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', sans-serif; background: #0f172a; color: #e2e8f0; min-height: 100vh; display: flex; }

/* ─── SIDEBAR ──────────────────────────────────────── */
.sidebar { width: 220px; min-height: 100vh; background: #1e293b; display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; }
.sidebar-brand { padding: 20px 16px; font-size: 1rem; font-weight: 700; color: #f8fafc; border-bottom: 1px solid #334155; }
.sidebar-menu { list-style: none; flex: 1; padding: 12px 0; }
.sidebar-menu li a { display: block; padding: 10px 20px; color: #94a3b8; text-decoration: none; border-radius: 6px; margin: 2px 8px; transition: all .2s; font-size: .9rem; }
.sidebar-menu li.active a, .sidebar-menu li a:hover { background: #3b82f6; color: #fff; }
.sidebar-footer { padding: 16px; border-top: 1px solid #334155; font-size: .8rem; color: #64748b; display: flex; justify-content: space-between; align-items: center; }
.btn-logout { color: #f87171; text-decoration: none; font-size: .8rem; }
.btn-logout:hover { color: #ef4444; }

/* ─── MAIN CONTENT ─────────────────────────────────── */
.main-content { margin-left: 220px; flex: 1; padding: 24px; overflow-x: auto; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-header h1 { font-size: 1.4rem; color: #f8fafc; }

/* ─── BUTTONS ──────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 4px; padding: 8px 16px; border-radius: 6px; border: none; cursor: pointer; font-size: .875rem; font-weight: 500; text-decoration: none; transition: all .2s; }
.btn-primary { background: #3b82f6; color: #fff; }
.btn-primary:hover { background: #2563eb; }
.btn-secondary { background: #334155; color: #cbd5e1; }
.btn-secondary:hover { background: #475569; color: #f1f5f9; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 4px 10px; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }

/* ─── STATS GRID ───────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card { background: #1e293b; border-radius: 10px; padding: 20px; display: flex; align-items: center; gap: 16px; }
.stat-icon { font-size: 1.8rem; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: #f8fafc; }
.stat-label { font-size: .8rem; color: #64748b; }

/* ─── VPS GRID ─────────────────────────────────────── */
.vps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.vps-card { background: #1e293b; border-radius: 10px; overflow: hidden; border: 1px solid #334155; }
.vps-card.offline { opacity: .6; border-color: #dc2626; }
.vps-card-header { padding: 12px 16px; display: flex; align-items: center; gap: 8px; background: #0f172a; }
.vps-status-dot { width: 8px; height: 8px; border-radius: 50%; }
.vps-status-dot.online { background: #22c55e; box-shadow: 0 0 6px #22c55e; }
.vps-status-dot.offline { background: #ef4444; }
.vps-status-dot.loading { background: #94a3b8; animation: pulse-dot 1.2s ease-in-out infinite; }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.vps-name { font-weight: 600; flex: 1; }
.vps-host { font-size: .75rem; color: #64748b; }
.vps-card-body { padding: 12px 16px; }
.vps-stat-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: .875rem; border-bottom: 1px solid #1e293b; }
.vps-card-footer { padding: 10px 16px; display: flex; gap: 6px; flex-wrap: wrap; background: #0f172a; }
.text-offline { color: #ef4444; font-size: .875rem; text-align: center; padding: 12px; }
.section-title { font-size: .75rem; font-weight: 600; color: #64748b; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 12px; }

/* ─── BADGES ───────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .75rem; font-weight: 600; }
.badge-green { background: #166534; color: #86efac; }
.badge-red { background: #7f1d1d; color: #fca5a5; }
.badge-blue { background: #1e3a5f; color: #93c5fd; }
.badge-gray { background: #334155; color: #94a3b8; }

/* ─── TABLE ────────────────────────────────────────── */
.table-container { background: #1e293b; border-radius: 10px; overflow: hidden; }

/* User management — scrollable table card + sticky header */
.user-table-card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .15);
}
.user-table-scroll {
    max-height: min(68vh, calc(100vh - 300px));
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}
.user-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #0f172a;
    box-shadow: 0 1px 0 #334155;
}
.user-table tbody tr:last-child td {
    border-bottom: none;
}

.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table thead th { padding: 12px 16px; text-align: left; background: #0f172a; color: #64748b; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }
.table tbody td { padding: 12px 16px; border-bottom: 1px solid #0f172a; vertical-align: middle; }
.table tbody tr:hover { background: #263348; }
.table-sm td, .table-sm th { padding: 8px 12px; }
.actions { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.row-expired { background: rgba(127,29,29,.2); }

/* ─── FORM ─────────────────────────────────────────── */
.form-card { background: #1e293b; border-radius: 10px; padding: 24px; max-width: 700px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: .875rem; color: #94a3b8; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 9px 12px; background: #0f172a; border: 1px solid #334155;
    border-radius: 6px; color: #f1f5f9; font-size: .9rem; outline: none;
}
.form-group input:focus, .form-group select:focus { border-color: #3b82f6; }
.password-field { position: relative; }
.password-field input { padding-right: 44px; width: 100%; }
.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px;
    line-height: 1;
}
.password-toggle:hover { color: #e2e8f0; }
.form-group small { font-size: .75rem; color: #64748b; margin-top: 4px; display: block; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }

/* ─── FILTER BAR ───────────────────────────────────── */
.filter-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.vps-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.vps-tab { padding: 6px 14px; background: #1e293b; border-radius: 6px; color: #94a3b8; text-decoration: none; font-size: .875rem; }
.vps-tab.active { background: #3b82f6; color: #fff; }

/* ─── ALERTS ───────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: .875rem; }
.alert-error { background: rgba(220,38,38,.2); border: 1px solid #dc2626; color: #fca5a5; }
.alert-success { background: rgba(34,197,94,.2); border: 1px solid #22c55e; color: #86efac; }
.alert-warning { background: rgba(245,158,11,.15); border: 1px solid #f59e0b; color: #fcd34d; }
.maintenance-panel-banner p { margin: 8px 0 12px; font-size: .875rem; }
.maintenance-card { margin-bottom: 24px; }
.maintenance-card h2 { font-size: 1.125rem; margin-bottom: 8px; }
.maintenance-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.maintenance-status { font-size: .875rem; color: #94a3b8; }
.maintenance-log {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 12px;
    max-height: 220px;
    overflow: auto;
    font-size: .75rem;
    color: #cbd5e1;
    white-space: pre-wrap;
}

/* ─── MONITORING ───────────────────────────────────── */
.monitor-vps-block { background: #1e293b; border-radius: 10px; padding: 16px 20px; margin-bottom: 20px; }
.monitor-vps-title { font-size: 1rem; font-weight: 600; color: #f8fafc; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.vps-host-small { font-size: .8rem; color: #64748b; }
.disk-badge { font-size: .78rem; background: #0f172a; padding: 3px 10px; border-radius: 99px; color: #94a3b8; }
.storage-bar-wrap { width: 80px; height: 6px; background: #334155; border-radius: 3px; margin-bottom: 2px; overflow: hidden; }
.storage-bar { height: 100%; background: #3b82f6; border-radius: 3px; }
.text-center { text-align: center; }

/* ─── MISC ─────────────────────────────────────────── */
.text-green { color: #4ade80; }
.text-blue  { color: #60a5fa; }
.text-red   { color: #f87171; }
.text-muted { color: #64748b; font-size: .875rem; }
.select-sm { background: #0f172a; border: 1px solid #334155; color: #cbd5e1; border-radius: 4px; padding: 3px 6px; font-size: .8rem; cursor: pointer; }
.user-filter-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }
.user-filter-group label { display: block; margin-bottom: 6px; font-size: .78rem; color: #94a3b8; font-weight: 700; }
.user-filter-group input, .user-filter-group select {
    width: 100%; padding: 9px 12px; background: #0f172a; border: 1px solid #334155;
    border-radius: 6px; color: #f1f5f9; font-size: .9rem; outline: none;
}
.user-filter-meta { margin-top: 10px; color: #94a3b8; font-size: .85rem; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.user-management-filter-row { grid-template-columns: minmax(160px, .9fr) minmax(240px, 1.4fr) minmax(145px, .8fr) minmax(145px, .8fr) minmax(165px, .9fr); }
.user-summary-grid { margin-bottom: 18px; }
.finance-filter-row { grid-template-columns: minmax(180px, 1.1fr) minmax(170px, 1fr) minmax(170px, 1fr) auto; }
.finance-filter-actions .btn-sm { padding: 9px 12px; }
@media (max-width: 1100px) {
    .user-filter-row, .finance-filter-row, .user-management-filter-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
    .user-filter-row, .finance-filter-row, .user-management-filter-row { grid-template-columns: 1fr; }
}
.empty-state { text-align: center; padding: 48px 24px; color: #64748b; }
.empty-state p { margin-bottom: 16px; }
.auto-refresh-badge { font-size: .75rem; background: #0f172a; padding: 4px 10px; border-radius: 99px; color: #64748b; }
code { background: #0f172a; padding: 2px 6px; border-radius: 4px; font-size: .85rem; color: #7dd3fc; }

/* ─── CONFIRM MODAL ────────────────────────────────── */
.confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
}
.confirm-modal.show { display: flex; }
.confirm-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, .72);
    backdrop-filter: blur(5px);
}
.confirm-modal-card {
    position: relative;
    width: min(420px, 100%);
    background: linear-gradient(180deg, #1e293b 0%, #111827 100%);
    border: 1px solid #334155;
    border-radius: 18px;
    padding: 28px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .45);
    text-align: center;
    animation: modalPop .18s ease-out;
}
.confirm-modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 999px;
    background: #0f172a;
    color: #94a3b8;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
}
.confirm-modal-close:hover { color: #f8fafc; background: #334155; }
.confirm-modal-icon {
    width: 58px;
    height: 58px;
    margin: 0 auto 14px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: rgba(59, 130, 246, .14);
    border: 1px solid rgba(96, 165, 250, .35);
    font-size: 1.8rem;
}
.confirm-modal-card h2 {
    color: #f8fafc;
    font-size: 1.15rem;
    margin-bottom: 8px;
}
.confirm-modal-card p {
    color: #cbd5e1;
    font-size: .92rem;
    line-height: 1.55;
    margin-bottom: 22px;
}
.confirm-modal-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}
@keyframes modalPop {
    from { opacity: 0; transform: translateY(10px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── LOGIN PAGE ───────────────────────────────────── */
body.login-page { display: flex; align-items: center; justify-content: center; background: #0f172a; }
.login-container { width: 100%; max-width: 380px; }
.login-box { background: #1e293b; border-radius: 12px; padding: 36px; }
.login-logo { font-size: 2.5rem; text-align: center; margin-bottom: 8px; }
.login-logo img { display: block; margin: 0 auto; border-radius: 16px; object-fit: contain; }
.login-box h2 { text-align: center; color: #f8fafc; margin-bottom: 4px; }
.login-subtitle { text-align: center; color: #64748b; font-size: .875rem; margin-bottom: 24px; }
.forgot-form { margin-top: 12px; }
.forgot-link {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: .8125rem;
    text-decoration: underline;
    cursor: pointer;
    padding: 8px 0;
}
.forgot-link:hover { color: #cbd5e1; }

/* ─── RESPONSIVE / MOBILE ──────────────────────────── */
@media (max-width: 900px) {
    body {
        display: block;
        min-height: 100vh;
        overflow-x: hidden;
    }

    .sidebar {
        position: sticky;
        top: 0;
        z-index: 50;
        width: 100%;
        min-height: auto;
        bottom: auto;
        border-bottom: 1px solid #334155;
    }

    .sidebar-brand {
        padding: 12px 14px 8px;
        font-size: .95rem;
        border-bottom: none;
    }

    .sidebar-menu {
        flex: none;
        display: flex;
        gap: 6px;
        padding: 8px 10px 12px;
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .sidebar-menu::-webkit-scrollbar { display: none; }

    .sidebar-menu li {
        flex: 0 0 auto;
    }

    .sidebar-menu li a {
        white-space: nowrap;
        margin: 0;
        padding: 9px 12px;
        font-size: .82rem;
        border-radius: 8px;
        background: #0f172a;
    }

    .sidebar-menu li.active a,
    .sidebar-menu li a:hover {
        background: #3b82f6;
        color: #fff;
    }

    .sidebar-footer {
        display: none;
    }

    .main-content {
        margin-left: 0;
        padding: 14px 12px 24px;
        overflow-x: hidden;
    }

    .page-header {
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 16px;
        flex-wrap: wrap;
    }

    .page-header h1 {
        font-size: 1.25rem;
    }

    .auto-refresh-badge {
        font-size: .68rem;
        padding: 3px 8px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        margin-bottom: 18px;
    }

    .stat-card {
        padding: 14px 12px;
        gap: 10px;
        min-width: 0;
    }

    .stat-icon {
        font-size: 1.35rem;
    }

    .stat-value {
        font-size: 1.45rem;
    }

    .stat-label {
        font-size: .72rem;
    }

    .vps-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .vps-card-header {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .vps-name {
        min-width: 0;
        word-break: break-word;
    }

    .vps-host {
        width: 100%;
        margin-left: 16px;
        word-break: break-all;
    }

    .vps-card-footer,
    .actions,
    .form-actions,
    .page-actions {
        gap: 8px;
    }

    .vps-card-footer .btn,
    .actions .btn,
    .form-actions .btn,
    .page-actions .btn {
        flex: 1 1 auto;
        justify-content: center;
    }

    .form-card {
        max-width: none;
        padding: 16px;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .filter-bar {
        align-items: stretch;
        flex-direction: column;
    }

    .vps-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 4px;
    }

    .table-container,
    .user-table-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .user-table-scroll {
        max-height: min(58vh, calc(100vh - 260px));
    }

    .table,
    .user-table {
        min-width: 720px;
    }

    .monitor-vps-title {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 12px 10px 22px;
    }

    .sidebar-brand {
        font-size: .9rem;
    }

    .sidebar-menu li a {
        padding: 8px 10px;
        font-size: .78rem;
    }

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

    .stat-card {
        align-items: flex-start;
        flex-direction: column;
        padding: 12px;
    }

    .stat-value {
        font-size: 1.35rem;
    }

    .section-title {
        margin-top: 4px;
    }

    .btn {
        padding: 8px 10px;
        font-size: .8rem;
    }

    .btn-sm {
        padding: 7px 9px;
        font-size: .76rem;
    }

    .login-container {
        max-width: none;
        padding: 16px;
    }

    .login-box {
        padding: 24px 18px;
    }
}
