.sidb-bpkal-wrapper,
.sidb-bpkal-kegiatan-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    max-width: 100%;
    margin: 20px 0;
    box-sizing: border-box;
}

.sidb-bpkal-wrapper *,
.sidb-bpkal-kegiatan-wrapper * {
    box-sizing: border-box;
}

.sidb-bpkal-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.sidb-bpkal-search,
.sidb-bpkal-filter-jabatan,
.sidb-bpkal-filter-wilayah {
    padding: 8px 12px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    font-size: 14px;
}

.sidb-bpkal-search {
    flex: 1;
    min-width: 200px;
}

.sidb-bpkal-loading {
    padding: 20px;
    text-align: center;
    color: #667085;
}

.sidb-bpkal-error {
    padding: 12px 16px;
    background: #fef3f2;
    border: 1px solid #fda29b;
    border-radius: 6px;
    color: #b42318;
    margin-bottom: 16px;
}

.sidb-bpkal-chart-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
    background: #fff;
    padding: 16px;
    border: 1px solid #eaecf0;
    border-radius: 8px;
    max-width: 100%;
    /* Safety net: even if something upstream misbehaves, never let a
       chart bleed into a theme sidebar or off the edge of the page. */
    overflow: hidden;
}

/* Every grid item defaults to min-width:auto, which means the track
   can't shrink smaller than its content's intrinsic size. A <canvas>
   is a replaced element whose intrinsic size is its width/height
   attribute (which Chart.js sets in real pixels), so without this the
   grid track refuses to shrink when the available width changes
   (e.g. a theme sidebar appearing at a wider breakpoint), and the
   chart overflows into whatever sits next to it. */
.sidb-bpkal-chart-container > * {
    min-width: 0;
}

.sidb-bpkal-chart-box {
    position: relative;
    width: 100%;
    min-width: 0;
    /* Fixed, explicit height gives Chart.js's responsive resize logic
       a stable box to measure against instead of a canvas measuring
       itself, which is what causes runaway/oversized canvases. */
    height: 280px;
}

.sidb-bpkal-chart-box canvas {
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
    display: block;
}

.sidb-bpkal-table-container {
    overflow-x: auto;
    border: 1px solid #eaecf0;
    border-radius: 8px;
}

.sidb-bpkal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.sidb-bpkal-table thead th {
    background: #f9fafb;
    text-align: left;
    padding: 12px 16px;
    font-weight: 600;
    color: #344054;
    border-bottom: 1px solid #eaecf0;
}

.sidb-bpkal-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid #eaecf0;
    color: #475467;
    vertical-align: middle;
}

.sidb-bpkal-table tbody tr:last-child td {
    border-bottom: none;
}

.sidb-bpkal-table tbody tr:hover {
    background: #f9fafb;
}

.sidb-bpkal-photo-thumb {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    cursor: pointer;
}

.sidb-bpkal-photo-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #eaecf0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #98a2b3;
    font-size: 12px;
}

.sidb-bpkal-kegiatan-count {
    display: inline-block;
    padding: 2px 10px;
    background: #eef4ff;
    color: #3538cd;
    border-radius: 12px;
    font-size: 12px;
    cursor: pointer;
}

.sidb-bpkal-file-link,
.sidb-bpkal-foto-link {
    display: inline-block;
    margin-right: 6px;
    margin-bottom: 4px;
    padding: 2px 8px;
    background: #f2f4f7;
    border-radius: 4px;
    font-size: 12px;
    color: #344054;
    text-decoration: none;
}

.sidb-bpkal-file-link:hover,
.sidb-bpkal-foto-link:hover {
    background: #e4e7ec;
}

.sidb-bpkal-pagination {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 16px;
    flex-wrap: wrap;
}

.sidb-bpkal-pagination button {
    padding: 6px 12px;
    border: 1px solid #d0d5dd;
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}

.sidb-bpkal-pagination button.active {
    background: #3538cd;
    color: #fff;
    border-color: #3538cd;
}

.sidb-bpkal-pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sidb-bpkal-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(16, 24, 40, 0.6);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidb-bpkal-modal-content {
    background: #fff;
    border-radius: 8px;
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 24px;
    position: relative;
}

.sidb-bpkal-modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 24px;
    cursor: pointer;
    color: #667085;
    line-height: 1;
}

.sidb-bpkal-modal-body img {
    max-width: 100%;
    border-radius: 6px;
    margin-bottom: 10px;
}

.sidb-bpkal-modal-body h3 {
    margin-top: 0;
}

.sidb-bpkal-modal-kegiatan-item {
    padding: 12px 0;
    border-bottom: 1px solid #eaecf0;
}

.sidb-bpkal-modal-kegiatan-item:last-child {
    border-bottom: none;
}

.sidb-bpkal-export-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.sidb-bpkal-export-btn {
    padding: 8px 14px;
    background: #3538cd;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

.sidb-bpkal-export-btn:hover {
    background: #2c2fa3;
}

.sidb-bpkal-export-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Print Styles */
@media print {
    .sidb-bpkal-wrapper * {
        display: none !important;
    }
    .sidb-bpkal-wrapper .sidb-bpkal-table-container,
    .sidb-bpkal-wrapper .sidb-bpkal-table-container * {
        display: block !important;
    }
    .sidb-bpkal-controls,
    .sidb-bpkal-chart-container,
    .sidb-bpkal-pagination,
    .sidb-bpkal-modal {
        display: none !important;
    }
    .sidb-bpkal-table th,
    .sidb-bpkal-table td {
        border: 1px solid #333 !important;
        padding: 8px !important;
    }
}