/* =========================
   RESET & BASE
========================= */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    background: #f3f4f6;
    color: #111827;
    line-height: 1.4;
}

a {
    color: #2563eb;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* =========================
   TOP BAR
========================= */
.topbar {
    background: #111827;
    color: #ffffff;
    box-shadow: 0 2px 10px rgba(0,0,0,.25);
}

.topbar-inner {
    max-width: 1200px;
    margin: auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-weight: 700;
    font-size: 16px;
    color: #d1d5db;
    text-decoration: none;
}

.topbar nav a {
    color: #d1d5db;
    margin-left: 20px;
    font-weight: 500;
}

.topbar nav a:hover {
    color: #ffffff;
}

/* =========================
   LAYOUT
========================= */
.container {
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 20px;
}

/* =========================
   CARD
========================= */
.card {
    background: #ffffff;
    border-radius: 12px;
    padding: 22px;
    box-shadow: 0 10px 30px rgba(0,0,0,.08);
    margin-bottom: 30px;
}

.card h2 {
    margin: 0 0 20px;
    font-size: 22px;
    font-weight: 700;
}

/* =========================
   TABLE
========================= */
table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    background: #f9fafb;
    font-weight: 600;
    text-align: left;
    font-size: 13px;
    color: #374151;
}

th, td {
    padding: 12px 14px;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: middle;
}

tbody tr:hover {
    background: #f9fafb;
}

/* =========================
   STATUS
========================= */
.status {
    color: #16a34a;
    font-weight: 600;
}

/* =========================
   BUTTONS
========================= */
button {
    background: #4f46e5;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s ease;
}

button:hover {
    background: #4338ca;
}

button.danger {
    background: #dc2626;
}

button.danger:hover {
    background: #b91c1c;
}

/* =========================
   BUTTON LOADING
========================= */
button[disabled] {
    opacity: 0.7;
    cursor: not-allowed;
}

#uploadBtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

#uploadBtn .btn-spinner {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,.35);
    border-top-color: rgba(255,255,255,1);
    display: none;
    animation: btnSpin 0.8s linear infinite;
}

#uploadBtn.is-loading .btn-spinner {
    display: inline-block;
}

@keyframes btnSpin {
    to { transform: rotate(360deg); }
}

/* =========================
   FORMS
========================= */
form {
    max-width: 520px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

input[type="text"],
input[type="password"],
select,
input[type="file"] {
    border-radius: 8px;
    border: 1px solid #d1d5db;
    padding: 10px 12px;
    font-size: 14px;
    width: 100%;
}

input[type="file"] {
    padding: 7px;
    background: #ffffff;
    cursor: pointer;
}

input:focus,
select:focus {
    outline: none;
    border-color: #6366f1;
}

/* =========================
   HELPERS
========================= */
.muted {
    color: #6b7280;
    font-size: 13px;
}

/* =========================
   UPLOAD PAGE FIXES
========================= */
.card form {
    max-width: 520px;
}

#deviceGroup select {
    max-width: 100%;
}

.card button[type="submit"] {
    margin-top: 10px;
    padding: 10px 18px;
    font-size: 14px;
    border-radius: 10px;
}

#deviceGroup {
    transition: opacity .15s ease;
}

.filters {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filters input,
.filters select {
    max-width: 220px;
}

.btn {
    display: inline-block;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    text-decoration: none;
    margin-right: 6px;
}

.btn-primary {
    background: #4f46e5;
    color: #ffffff;
}

.btn-primary:hover {
    background: #4338ca;
}

.btn-secondary {
    background: #e5e7eb;
    color: #111827;
}

.btn-secondary:hover {
    background: #d1d5db;
}

/* =========================
   MOBILE
========================= */
@media (max-width: 768px) {
    .topbar-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    table {
        font-size: 13px;
    }

    form {
        max-width: 100%;
    }
}

.status {
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 12px;
    font-weight: 600;
}

.status.online {
    background: #d4edda;
    color: #155724;
}

.status.offline {
    background: #f8d7da;
    color: #721c24;
}

.status.never {
    background: #fff3cd;
    color: #856404;
}

/* =========================
   MODAL
========================= */
#videoModal {
    display: none;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0,0,0,0.85) !important;
    z-index: 999999 !important;
    justify-content: center !important;
    align-items: center !important;
}

#videoModal.show {
    display: flex !important;
}

#videoModal .modal-content {
    background: #111;
    padding: 20px;
    width: 80%;
    max-width: 1000px;
    border-radius: 12px;
    position: relative;
}

#videoModal video {
    width: 100%;
    max-height: 80vh;
    border-radius: 8px;
    display: block;
}

#videoModal .close {
    position: absolute;
    top: -15px;
    right: -15px;
    color: white;
    font-size: 20px;
    cursor: pointer;
    background: #333;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    z-index: 10;
    transition: background 0.15s ease;
}

#videoModal .close:hover {
    background: #555;
}

#videoModal .modal-title {
    color: white;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}
