.table-box {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

.table th {
    text-align: left;
    font-size: 13px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    padding: 10px;
    background: var(--surface-muted);
    white-space: nowrap;
}

.table td {
    padding: 10px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    color: var(--text-heading);
}

/* Form grid defaults */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-dark);
}

.table tr:hover td {
    background: var(--surface-muted);
}

.activity-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    color: var(--text-muted);
    font-size: 14px;
}

.activity-list li {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    line-height: 1.4;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 6px;
    background: var(--text-muted);
}

.dot.success { background: #16a34a; }
.dot.warning { background: #f59e0b; }
.dot.danger { background: #dc2626; }

@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .page-actions {
        width: 100%;
    }

    .page-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .input-search {
        width: 100%;
    }

    .tabs {
        gap: 6px;
    }

    .table {
        min-width: 620px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .page-actions {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .page-actions .btn {
        min-width: 0;
        width: 100%;
    }

    .table-box {
        padding: 12px;
    }

    .table th,
    .table td {
        font-size: 12px;
        padding: 8px;
    }
}

.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--text-light);
}

.badge.success { background: var(--success); }
.badge.warning { background: var(--warning); }
.badge.danger  { background: var(--danger); }
.badge.primary { background: var(--accent); }
.badge.info { background: var(--info); }

.muted {
    color: var(--text-muted);
}


.badge {
    text-decoration: none;
    cursor: pointer;
}

.badge:hover {
    opacity: 0.85;
}

.badge.accent {
    background: var(--accent);
}

.pagination-box {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 20px;
}

.pagination-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-right: 6px;
}

.page-item {
    padding: 6px 10px;
    border-radius: 6px;
    background: var(--surface-muted);
    color: var(--text-heading);
    text-decoration: none;
    font-size: 13px;
}

.page-item:hover {
    background: var(--border);
}

.page-item.active {
    background: var(--accent);
    color: var(--text-light);
}

.page-dots {
    padding: 0 4px;
    color: var(--text-muted);
}

.flash-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.flash {
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    border: 1px solid transparent;
}

.flash-success {
    background: var(--success-weak);
    color: var(--success);
    border-color: var(--success-border);
}

.flash-danger {
    background: var(--danger-weak);
    color: var(--danger);
    border-color: var(--danger-border);
}

.flash-warning {
    background: var(--warning-weak);
    color: var(--warning);
    border-color: var(--warning-border);
}

.modal {
    display: none;
    align-items: center;
    justify-content: center;
    position: fixed;
    inset: 0;
    background: var(--overlay);
    z-index: 50;
}

.modal[aria-hidden="false"] {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 16px;
    min-width: 320px;
    max-width: 520px;
    box-shadow: var(--shadow-md);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.modal-close {
    cursor: pointer;
}

.field-error {
    color: var(--danger);
    font-size: 12px;
    margin-top: 4px;
}


.filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 16px 0;
    gap: 12px;
}

.input-search {
    width: 280px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: var(--surface);
    color: var(--text-dark);
}

.input-search:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-weak);
}

.input-select {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: var(--surface);
    color: var(--text-dark);
}

.input-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-weak);
}

.btn {
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--accent);
    color: var(--text-light);
    box-shadow: 0 6px 16px var(--accent-weak);
}

.btn-primary:hover {
    filter: brightness(0.95);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
}

.btn-outline:hover {
    background: var(--accent-weak);
}

.btn-ghost {
    background: var(--surface-muted);
    color: var(--text-muted);
}

.btn-view {
    background: var(--accent);
    color: var(--text-light);
}

.btn-lock {
    background: var(--warning);
    color: var(--text-light);
}

.btn-unlock {
    background: var(--success);
    color: var(--text-light);
}

.btn-success {
    background: var(--success);
    color: var(--text-light);
}

.btn-danger {
    background: var(--danger);
    color: var(--text-light);
}

.btn-add {
    background: var(--accent);
    color: var(--text-light);
}

.btn-xs {
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 6px;
}

.btn + .btn {
    margin-left: 4px;
}


/* ===== MODAL CORE ===== */
.modal {
    position: fixed;
    inset: 0;
    background: var(--overlay);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
    backdrop-filter: blur(4px);
}

.modal.show {
    display: flex;
}

/* ===== MODAL CONTENT ===== */
.modal-content {
    background: var(--surface);
    width: 900px;
    max-width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

/* ===== MODAL HEADER ===== */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-close {
    cursor: pointer;
    font-size: 22px;
    color: var(--text-muted);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.page-title {
    margin: 0;
    font-size: 24px;
}

.page-subtitle {
    margin: 6px 0 0;
    color: var(--text-muted);
    font-size: 14px;
}

.page-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.page-actions .btn {
    min-width: 120px;
}

.tabs {
    display: flex;
    gap: 8px;
    margin: 12px 0 18px;
    flex-wrap: wrap;
}

.tab {
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--text-heading);
    text-decoration: none;
    font-size: 13px;
    transition: background 0.2s ease, color 0.2s ease;
}

.tab.active,
.tab:hover {
    background: var(--accent);
    color: var(--text-light);
}

/* ===== MODAL BODY ===== */
.modal-body {
    padding: 20px;
}

/* ===== AVATAR ===== */
.modal-avatar {
    text-align: center;
    margin-bottom: 16px;
}

.modal-avatar img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid var(--border);
}

/* ===== INFO GRID ===== */
.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px 20px;
    margin-bottom: 20px;
}

/* ===== CCCD BOX ===== */
.cccd-box {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.cccd-box img {
    width: 100%;
    max-height: 200px;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-muted);
}

/* ===== MODAL FOOTER ===== */
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}


.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}

.cccd-box {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.cccd-box img {
    width: 100%;
    border-radius: 8px;
    border: 1px solid var(--border);
}


/* ===== CAMERA GRID ===== */
.camera-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

/* Card */
.camera-card {
    background: var(--surface);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow-card);
    transition: transform .15s ease, box-shadow .15s ease;
}

.camera-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-card-hover);
}

/* Thumb giữ tỉ lệ 16:9 */
.camera-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;   /* 🔥 QUAN TRỌNG */
    background: var(--bg-dark);
    overflow: hidden;
}

/* Ảnh tự scale */
.camera-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;     /* 🔥 AUTO SCALE */
    display: block;
}

/* Info */
.camera-info {
    padding: 10px 12px;
    font-size: 14px;
}


/* =========================
   CAMERA IMAGE HANDLING
   ========================= */

/* Grid camera */
.camera-card {
    background: var(--surface);
    border-radius: 10px;
    overflow: hidden;              /* QUAN TRỌNG */
    box-shadow: var(--shadow-thumb);
}

.camera-card img {
    width: 100%;
    height: 180px;                 /* ép chiều cao đồng đều */
    object-fit: cover;             /* tự scale + crop */
    display: block;
}

/* Camera detail page */
.camera-detail {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    align-items: start;
}

.camera-preview {
    width: 100%;
    max-height: 520px;              /* KHÓA CHIỀU CAO */
    object-fit: contain;            /* KHÔNG bị cắt */
    background: var(--bg-dark);
    border-radius: 12px;
}

/* Mobile */
@media (max-width: 900px) {
    .camera-detail {
        grid-template-columns: 1fr;
    }

    .camera-preview {
        max-height: 320px;
    }
}
