/* ─── Reset & Base ─────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

button {
    background: none;
    border: none;
    cursor: pointer;
    outline: none;
    line-height: 1;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    background: #0a0a14;
    color: #c8c8e0;
    min-height: 100vh;
}

.dashboard {
    max-width: 1440px;
    margin: 0 auto;
    padding: 20px 28px;
}

/* ─── Header ────────────────────────────────────────────── */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding: 18px 28px;
    background: linear-gradient(135deg, #141428 0%, #1a1a32 100%);
    border-radius: 16px;
    border: 1px solid rgba(88,101,242,0.12);
    box-shadow: 0 4px 24px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.03);
}

.header-left { display: flex; align-items: center; gap: 14px; }

.logo {
    font-size: 32px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(88,101,242,0.2), rgba(88,101,242,0.05));
    border-radius: 12px;
    border: 1px solid rgba(88,101,242,0.2);
}

h1 { font-size: 22px; font-weight: 800; color: white; letter-spacing: -0.3px; }
.subtitle { font-size: 12px; color: #5a5a8a; margin-top: 2px; font-weight: 500; }

.header-right { display: flex; align-items: center; gap: 16px; }
.header-stats { display: flex; gap: 8px; }

.stat-card {
    background: rgba(255,255,255,0.03);
    border-radius: 10px;
    padding: 10px 18px;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.06);
    min-width: 80px;
    transition: all 0.2s ease;
}
.stat-card:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.stat-card.ok { border-color: rgba(87,242,135,0.25); background: rgba(87,242,135,0.05); }
.stat-card.warn { border-color: rgba(255,180,50,0.25); background: rgba(255,180,50,0.05); }
.stat-card.error { border-color: rgba(237,66,69,0.25); background: rgba(237,66,69,0.05); }

.stat-num { display: block; font-size: 26px; font-weight: 800; color: white; line-height: 1.1; }
.stat-card.ok .stat-num { color: #57f287; }
.stat-card.warn .stat-num { color: #ffb432; }
.stat-card.error .stat-num { color: #ed4245; }
.stat-label { font-size: 10px; color: #5a5a8a; text-transform: uppercase; letter-spacing: 0.8px; font-weight: 600; }

.header-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-left: 20px;
    margin-left: 4px;
    border-left: 1px solid rgba(255,255,255,0.06);
}

.user-label {
    font-size: 12px;
    color: #8888b0;
    font-weight: 600;
    background: rgba(255,255,255,0.04);
    padding: 5px 12px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.06);
}

.btn-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(237,66,69,0.12), rgba(237,66,69,0.06));
    color: #ff6b6e;
    border: 1px solid rgba(237,66,69,0.2);
    border-radius: 10px;
    padding: 8px 18px;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.3px;
    text-transform: none;
    line-height: 1.4;
}
.btn-logout:hover {
    background: linear-gradient(135deg, #ed4245, #d63031);
    color: white;
    border-color: #ed4245;
    box-shadow: 0 4px 24px rgba(237,66,69,0.4), 0 0 0 3px rgba(237,66,69,0.1);
    transform: translateY(-1px);
}
.btn-logout:active { transform: translateY(0); }

.btn-grafana-signups {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #f59e0b, #f97316);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 9px 18px;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 12px;
    font-weight: 800;
    text-decoration: none;
    margin-right: 10px;
    letter-spacing: 0.4px;
    box-shadow: 0 2px 12px rgba(249,115,22,0.45);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}
.btn-grafana-signups:hover {
    background: linear-gradient(135deg, #fbbf24, #fb923c);
    box-shadow: 0 4px 20px rgba(249,115,22,0.65);
    transform: translateY(-2px);
    color: #fff;
}
.btn-grafana-signups:active { transform: translateY(0); }

/* ─── Filters ────────────────────────────────────────────── */
.filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
}

.search-input {
    flex: 1;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    color: white;
    padding: 11px 16px;
    font-size: 13px;
    font-weight: 500;
    outline: none;
    transition: all 0.2s ease;
}
.search-input::placeholder { color: #4a4a6a; }
.search-input:focus { border-color: rgba(88,101,242,0.5); box-shadow: 0 0 0 3px rgba(88,101,242,0.1); }

.filter-select {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    color: white;
    padding: 11px 16px;
    font-size: 13px;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    transition: all 0.2s ease;
}
.filter-select:focus { border-color: rgba(88,101,242,0.5); }
.filter-select option { background: #1a1a2e; color: white; }

.btn-refresh {
    background: linear-gradient(135deg, #5865f2, #4752c4);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    padding: 11px 22px;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 13px;
    cursor: pointer;
    font-weight: 700;
    white-space: nowrap;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 3px 12px rgba(88,101,242,0.3);
    line-height: 1.4;
    letter-spacing: 0.2px;
}
.btn-refresh:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(88,101,242,0.4), 0 0 0 3px rgba(88,101,242,0.1);
    background: linear-gradient(135deg, #6a75ff, #5260d8);
}
.btn-refresh:active { transform: translateY(0); }

/* ─── Table ──────────────────────────────────────────────── */
.table-container {
    background: linear-gradient(180deg, #12122a 0%, #0e0e1e 100%);
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.06);
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0,0,0,0.2);
}

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

.devices-table thead tr {
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.devices-table th {
    padding: 14px 18px;
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #5a5a8a;
    font-weight: 700;
}

.device-row {
    border-bottom: 1px solid rgba(255,255,255,0.03);
    transition: all 0.15s ease;
}
.device-row:hover { background: rgba(88,101,242,0.04); }
.device-row.selected { background: rgba(88,101,242,0.08); }

.devices-table td {
    padding: 14px 18px;
    font-size: 13px;
    vertical-align: middle;
}

.hostname { font-weight: 600; color: #ebebff; }
.mono { font-family: 'JetBrains Mono', 'Consolas', 'Courier New', monospace; font-size: 12px; }
.mac { color: #7878a8; }
.version { color: #5a5a8a; font-size: 11px; font-weight: 500; }
.date { color: #5a5a8a; font-size: 11px; white-space: nowrap; font-weight: 500; }

.ip-link {
    color: #7b86f6;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s;
}
.ip-link:hover { color: #a0a8ff; }

/* ─── Badges ─────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: 0.2px;
}
.badge-ok { background: rgba(87,242,135,0.1); color: #57f287; border: 1px solid rgba(87,242,135,0.15); }
.badge-warn { background: rgba(255,180,50,0.1); color: #ffb432; border: 1px solid rgba(255,180,50,0.15); }
.badge-error { background: rgba(237,66,69,0.1); color: #ed4245; border: 1px solid rgba(237,66,69,0.15); }
.badge-pending { background: rgba(88,101,242,0.1); color: #7b86f6; border: 1px solid rgba(88,101,242,0.15); }

/* ─── Buttons ────────────────────────────────────────────── */
.btn-detail {
    display: inline-flex;
    align-items: center;
    background: rgba(88,101,242,0.08);
    color: #7b86f6;
    border: 1px solid rgba(88,101,242,0.15);
    border-radius: 8px;
    padding: 7px 16px;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    line-height: 1.4;
}
.btn-detail:hover {
    background: linear-gradient(135deg, #5865f2, #4752c4);
    color: white;
    border-color: #5865f2;
    box-shadow: 0 4px 16px rgba(88,101,242,0.35);
    transform: translateY(-1px);
}

/* ─── Loading / Empty ────────────────────────────────────── */
.loading, .empty-state {
    text-align: center;
    padding: 80px 40px;
    color: #5a5a8a;
}
.loading span, .empty-state span { font-size: 48px; display: block; margin-bottom: 16px; }
.empty-state p { font-size: 15px; font-weight: 500; }

.spinner {
    width: 36px; height: 36px;
    border: 3px solid rgba(88,101,242,0.15);
    border-top-color: #5865f2;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Modal ──────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(8px);
    animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
    background: linear-gradient(180deg, #161630 0%, #111124 100%);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 20px;
    width: 640px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 80px rgba(0,0,0,0.6), 0 0 40px rgba(88,101,242,0.05);
    animation: modalSlide 0.25s ease;
}
@keyframes modalSlide { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 22px 28px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.modal-header h2 { font-size: 17px; color: white; font-weight: 700; }

.modal-close {
    background: rgba(255,255,255,0.05);
    border: none;
    color: #7070a0;
    font-size: 16px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    transition: all 0.15s;
}
.modal-close:hover { background: rgba(237,66,69,0.15); color: #ed4245; }

.modal-body { padding: 28px; }

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 28px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
    background: rgba(255,255,255,0.02);
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.04);
}
.detail-item.full-width { grid-column: 1 / -1; }
.detail-item label { font-size: 10px; color: #5a5a8a; text-transform: uppercase; letter-spacing: 0.8px; font-weight: 700; }
.detail-item span, .detail-item a { font-size: 13px; color: #d0d0ee; font-weight: 500; }
.detail-item a { color: #7b86f6; text-decoration: none; }
.detail-item a:hover { color: #a0a8ff; }

.password-row { display: flex; align-items: center; gap: 8px; }
.password-field { letter-spacing: 2px; }

.btn-show-pass {
    background: rgba(88,101,242,0.1);
    color: #7b86f6;
    border: 1px solid rgba(88,101,242,0.15);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}
.btn-show-pass:hover { background: #5865f2; color: white; }

.modal-links {
    display: flex;
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.btn-link {
    flex: 1;
    text-align: center;
    padding: 12px;
    border-radius: 10px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    background: rgba(88,101,242,0.08);
    color: #7b86f6;
    border: 1px solid rgba(88,101,242,0.12);
    transition: all 0.2s ease;
}
.btn-link:hover { background: #5865f2; color: white; border-color: #5865f2; box-shadow: 0 4px 20px rgba(88,101,242,0.3); }
.btn-link.admin { background: rgba(237,66,69,0.06); color: #e06668; border-color: rgba(237,66,69,0.15); }
.btn-link.admin:hover { background: #ed4245; color: white; box-shadow: 0 4px 20px rgba(237,66,69,0.3); }

/* ─── Login ─────────────────────────────────────────────── */
.login-overlay {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0a0a14;
    position: relative;
    overflow: hidden;
}

.login-glow {
    position: absolute;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(88,101,242,0.08) 0%, transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.login-card {
    background: linear-gradient(180deg, #141428 0%, #0f0f20 100%);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 24px;
    padding: 44px 40px;
    width: 420px;
    max-width: 95vw;
    box-shadow: 0 25px 80px rgba(0,0,0,0.5), 0 0 60px rgba(88,101,242,0.04);
    position: relative;
    z-index: 1;
    animation: modalSlide 0.4s ease;
}

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

.login-icon {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(88,101,242,0.15), rgba(88,101,242,0.05));
    border: 1px solid rgba(88,101,242,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.login-header h1 {
    font-size: 24px;
    font-weight: 800;
    color: white;
    margin-bottom: 6px;
    letter-spacing: -0.3px;
}

.login-subtitle {
    font-size: 13px;
    color: #5a5a8a;
    font-weight: 500;
}

.login-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent);
    margin-bottom: 28px;
}

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

.form-group label {
    display: block;
    font-size: 11px;
    color: #6a6a9a;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 8px;
    font-weight: 700;
}

.input-wrapper {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #4a4a7a;
    pointer-events: none;
    transition: color 0.2s;
}

.login-input {
    width: 100%;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    color: white;
    padding: 13px 16px;
    font-size: 14px;
    font-weight: 500;
    outline: none;
    transition: all 0.2s ease;
}
.login-input.has-icon { padding-left: 42px; }
.login-input::placeholder { color: #3a3a5a; font-weight: 400; }
.login-input:focus { border-color: rgba(88,101,242,0.5); box-shadow: 0 0 0 3px rgba(88,101,242,0.1); }
.login-input:focus + .input-icon,
.input-wrapper:focus-within .input-icon { color: #5865f2; }
.login-input:disabled { opacity: 0.5; }

.login-error {
    background: rgba(237,66,69,0.08);
    color: #ed6668;
    padding: 11px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid rgba(237,66,69,0.12);
}

.login-button {
    width: 100%;
    background: linear-gradient(135deg, #5865f2 0%, #4752c4 100%);
    color: #ffffff;
    border: none;
    border-radius: 12px;
    padding: 15px 24px;
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 6px 24px rgba(88,101,242,0.35), 0 0 0 0 rgba(88,101,242,0);
    letter-spacing: 0.3px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    position: relative;
    overflow: hidden;
    line-height: 1.4;
    margin-top: 6px;
}
.login-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    transition: left 0.5s ease;
}
.login-button:hover:not(:disabled)::before { left: 100%; }
.login-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 32px rgba(88,101,242,0.45), 0 0 0 4px rgba(88,101,242,0.12);
    background: linear-gradient(135deg, #6a75ff 0%, #5260d8 100%);
}
.login-button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 4px 16px rgba(88,101,242,0.3);
}
.login-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 11px;
    color: #3a3a5a;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.spinner-small {
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* ─── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 900px) {
    .header { flex-direction: column; gap: 16px; }
    .header-right { flex-direction: column; }
    .header-stats { flex-wrap: wrap; justify-content: center; }
    .filters { flex-direction: column; }
    .detail-grid { grid-template-columns: 1fr; }
    .devices-table { font-size: 12px; }
}
