:root {
  --ccms-primary: #315b88;
  --ccms-primary-hover: #254a72;
  --ccms-secondary: #64748b;
  --ccms-success: #2b8a86;
  --ccms-danger: #b74a55;
  --ccms-warning: #c28a2c;
  --ccms-info: #397fcf;
  --ccms-ink: #243f61;
  --ccms-muted: #718096;
  --ccms-border: #dfe7f0;
  --ccms-surface: #ffffff;
  --ccms-canvas: #f5f7fb;
  --ccms-radius: .75rem;
  --ccms-shadow: 0 5px 18px rgba(37, 66, 103, .065);
  --bs-font-sans-serif: "Aptos", "Segoe UI", Arial, sans-serif;
  --bs-body-font-family: var(--bs-font-sans-serif);
  --bs-body-font-size: .9rem;
  --bs-body-color: var(--ccms-ink);
  --bs-primary: var(--ccms-primary);
  --bs-primary-rgb: 49, 91, 136;
}

html { font-size: 16px; }
body { color: var(--ccms-ink); font-family: var(--bs-font-sans-serif); font-size: .9rem; line-height: 1.5; background-color: var(--ccms-canvas); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, h5, h6 { color: #1d3554; font-family: inherit; font-weight: 700; line-height: 1.25; }
h1, .h1 { font-size: clamp(1.5rem, 2.5vw, 2rem); }
h2, .h2 { font-size: clamp(1.3rem, 2vw, 1.7rem); }
h3, .h3 { font-size: clamp(1.15rem, 1.7vw, 1.45rem); }
h4, .h4 { font-size: 1.15rem; }
h5, .h5 { font-size: 1rem; }
h6, .h6 { font-size: .9rem; }
a { color: #2f70b7; text-underline-offset: 2px; }
a:hover { color: #245991; }
.text-secondary, .text-muted { color: var(--ccms-muted) !important; }
.small, small { font-size: .79rem; }

.breadcrumb { --bs-breadcrumb-divider-color: #9aa8b8; margin-bottom: .75rem; padding: .45rem .7rem !important; color: var(--ccms-muted); background: transparent !important; border-radius: .5rem; font-size: .78rem; }
.breadcrumb-item.active { color: #52677f; font-weight: 600; }
.ccms-global-breadcrumb { margin:0; padding:.72rem clamp(.75rem,2vw,1.5rem) 0; }
.ccms-global-breadcrumb nav { max-width:1320px; margin:0 auto; }
.ccms-global-breadcrumb .breadcrumb { align-items:center; min-height:38px; padding:.42rem .75rem !important; background:#fff !important; border:1px solid var(--ccms-border); box-shadow:0 2px 8px rgba(37,66,103,.04); }
.ccms-global-breadcrumb a { color:#397fcf; text-decoration:none; font-weight:650; }
.ccms-global-breadcrumb a:hover { color:#2465ad; }

.card, .modal-content, .list-group { border-color: var(--ccms-border); border-radius: var(--ccms-radius); }
.card { box-shadow: var(--ccms-shadow); }
.card-header { padding: .85rem 1rem; color: #294c73; background: #f8fafc; border-bottom-color: var(--ccms-border); font-weight: 700; }
.card-body { padding: 1rem; }
.modal-content { box-shadow: 0 18px 50px rgba(27, 51, 79, .18); }
.modal-header { background: #f7f9fc; border-bottom-color: var(--ccms-border); }
.modal-title { color: #294c73; font-weight: 700; }
.modal-footer { border-top-color: var(--ccms-border); }

.btn { --bs-btn-font-size: .82rem; --bs-btn-font-weight: 650; display: inline-flex; align-items: center; justify-content: center; gap: .42rem; min-height: 38px; padding: .46rem .78rem; border-radius: .55rem; line-height: 1.2; box-shadow: none !important; transition: color .15s ease, background-color .15s ease, border-color .15s ease, transform .15s ease; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-sm { min-height: 31px; padding: .33rem .58rem; font-size: .75rem; border-radius: .45rem; }
.btn-lg { min-height: 46px; padding: .62rem 1rem; font-size: .92rem; }
.btn-primary { --bs-btn-bg: var(--ccms-primary); --bs-btn-border-color: var(--ccms-primary); --bs-btn-hover-bg: var(--ccms-primary-hover); --bs-btn-hover-border-color: var(--ccms-primary-hover); }
.btn-success { --bs-btn-bg: var(--ccms-success); --bs-btn-border-color: var(--ccms-success); --bs-btn-hover-bg: #21736f; --bs-btn-hover-border-color: #21736f; }
.btn-danger { --bs-btn-bg: var(--ccms-danger); --bs-btn-border-color: var(--ccms-danger); --bs-btn-hover-bg: #9e3e48; --bs-btn-hover-border-color: #9e3e48; }
.btn-warning { --bs-btn-bg: var(--ccms-warning); --bs-btn-border-color: var(--ccms-warning); --bs-btn-color: #fff; --bs-btn-hover-bg: #a97622; --bs-btn-hover-border-color: #a97622; --bs-btn-hover-color: #fff; }
.btn-info { --bs-btn-bg: var(--ccms-info); --bs-btn-border-color: var(--ccms-info); --bs-btn-color: #fff; --bs-btn-hover-bg: #2e6db4; --bs-btn-hover-border-color: #2e6db4; --bs-btn-hover-color: #fff; }
.btn-secondary { --bs-btn-bg: var(--ccms-secondary); --bs-btn-border-color: var(--ccms-secondary); }
.btn-outline-primary { --bs-btn-color: var(--ccms-primary); --bs-btn-border-color: #7b9dc2; --bs-btn-hover-bg: var(--ccms-primary); --bs-btn-hover-border-color: var(--ccms-primary); }
.btn-outline-secondary { --bs-btn-color: #5d6d80; --bs-btn-border-color: #aeb9c5; --bs-btn-hover-bg: #64748b; }
.btn-link { color: #2f70b7; text-decoration: none; }
.btn i, .btn .bi { font-size: 1em; line-height: 1; }

.form-label, label { color: #4d627b; font-size: .8rem; font-weight: 650; }
.form-control, .form-select { min-height: 41px; color: #304a68; background-color: #fff; border-color: #d5dfea; border-radius: .55rem; font-size: .86rem; }
.form-control:focus, .form-select:focus { border-color: #71a4db; box-shadow: 0 0 0 .2rem rgba(57, 127, 207, .12); }
.form-control::placeholder { color: #9aa7b5; }
.input-group-text { color: #64758a; background: #f7f9fc; border-color: #d5dfea; }
.form-check-input:checked { background-color: var(--ccms-primary); border-color: var(--ccms-primary); }
.form-text { color: #8491a2 !important; font-size: .74rem; }

.table-responsive { border-radius: .7rem; }
.table { --bs-table-color: #344b66; --bs-table-striped-bg: #f8fafc; --bs-table-hover-bg: #eef5fc; margin-bottom: 0; border-color: #e5ebf2; font-size: .8rem; vertical-align: middle; }
.table > :not(caption) > * > * { padding: .62rem .68rem; }
.table thead th { color: #fff; background: var(--ccms-primary); border-color: rgba(255, 255, 255, .16); font-size: .72rem; font-weight: 700; letter-spacing: .025em; text-transform: uppercase; white-space: nowrap; }
.table-light, .table-light > th, .table-light > td, thead.table-light th { color: #fff !important; background-color: var(--ccms-primary) !important; }
.table-bordered > :not(caption) > * { border-width: 0; }
.table-bordered > :not(caption) > * > * { border-width: 0 0 1px; }
.table caption { color: var(--ccms-muted); font-size: .78rem; }

.badge { padding: .38em .58em; border-radius: .4rem; font-size: .7rem; font-weight: 650; letter-spacing: .015em; }
.bg-primary { background-color: var(--ccms-primary) !important; }
.bg-success { background-color: var(--ccms-success) !important; }
.bg-danger { background-color: var(--ccms-danger) !important; }
.bg-info { background-color: var(--ccms-info) !important; }
.alert { border: 0; border-left: 4px solid currentColor; border-radius: .65rem; font-size: .83rem; }
.pagination { --bs-pagination-color: var(--ccms-primary); --bs-pagination-active-bg: var(--ccms-primary); --bs-pagination-active-border-color: var(--ccms-primary); --bs-pagination-border-color: #dce4ed; gap: .2rem; }
.page-link { border-radius: .4rem !important; font-size: .78rem; }
.dropdown-menu { padding: .45rem; border-color: var(--ccms-border); border-radius: .65rem; box-shadow: 0 12px 30px rgba(31, 57, 87, .14); font-size: .82rem; }
.dropdown-item { padding: .5rem .65rem; border-radius: .42rem; color: #40566f; }
.dropdown-item:hover, .dropdown-item:focus { color: #294c73; background: #edf4fb; }
.tooltip { --bs-tooltip-max-width: 320px; --bs-tooltip-bg: #203b5b; --bs-tooltip-opacity: .97; font-family: var(--bs-font-sans-serif); }
.tooltip .tooltip-inner { padding: .5rem .7rem; border-radius: .45rem; font-size: .74rem; line-height: 1.35; box-shadow: 0 6px 18px rgba(26, 49, 75, .2); }
.ccms-tooltip-box { position: fixed; z-index: 1090; max-width: 320px; padding: .5rem .7rem; color: #fff; background: #203b5b; border-radius: .45rem; box-shadow: 0 6px 18px rgba(26,49,75,.2); font-size: .74rem; line-height: 1.35; text-align: center; pointer-events: none; opacity: 0; visibility: hidden; transform: translateY(3px); transition: opacity .14s ease, transform .14s ease; }
.ccms-tooltip-box.is-visible { opacity: .97; visibility: visible; transform: translateY(0); }

.container.bg-light, .container-md.bg-light, .container-lg.bg-light, .container-xl.bg-light, .container-fluid.bg-light { background: var(--ccms-surface) !important; border-color: var(--ccms-border) !important; border-radius: var(--ccms-radius); box-shadow: var(--ccms-shadow); }
footer { color: #7d8b9c; }

/* Matriks kehadiran: kepala/lajur beku, sorotan silang dan seret untuk tatal. */
.attendance-matrix-toolbar { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:.65rem 1rem; margin-bottom:.8rem; }
.attendance-legend { display:flex; flex-wrap:wrap; gap:.45rem .85rem; color:#5d7087; font-size:.73rem; }
.attendance-legend span { display:inline-flex; align-items:center; gap:.35rem; }
.attendance-legend i { width:.72rem; height:.72rem; border:1px solid; border-radius:.2rem; }
.attendance-legend .complete { background:#e5f5eb; border-color:#72bd8d; }
.attendance-legend .partial { background:#fff4d6; border-color:#e2b84f; }
.attendance-legend .empty { background:#fde8e8; border-color:#dc7b7b; }
.attendance-legend .na { background:#f4f6f8; border-color:#cbd3dc; }
.attendance-drag-hint { color:#718298; font-size:.72rem; white-space:nowrap; }
.attendance-matrix-scroll { position:relative; max-height:70vh; overflow:auto; border:1px solid #dbe4ed; border-radius:.7rem; cursor:grab; overscroll-behavior:contain; scrollbar-color:#9fb4c9 #edf2f7; }
.attendance-matrix-scroll.is-dragging { cursor:grabbing; user-select:none; }
.attendance-matrix { width:max-content; min-width:100%; border-collapse:separate; border-spacing:0; }
.attendance-matrix thead th { position:sticky; top:0; z-index:4; height:58px; max-width:150px; overflow:hidden; text-overflow:ellipsis; }
.attendance-matrix .attendance-row-head { position:sticky; left:0; z-index:3; min-width:190px; max-width:240px; color:#294c73; background:#f8fafc !important; border-right:2px solid #cbd9e7 !important; font-weight:700; }
.attendance-matrix thead .attendance-row-head { z-index:6; color:#fff; background:var(--ccms-primary) !important; }
.attendance-matrix tbody tr.is-row-highlight > td { box-shadow:inset 0 2px rgba(57,127,207,.32), inset 0 -2px rgba(57,127,207,.32); }
.attendance-matrix th.is-column-highlight { background:#225f9f !important; }
.attendance-matrix td.is-cell-highlight { outline:3px solid #397fcf; outline-offset:-3px; }

/* Bantuan automatik untuk jadual umum yang panjang atau lebar. */
.ccms-large-table-wrap { position:relative; max-height:72vh; overflow:auto; border:1px solid #dbe4ed; border-radius:.7rem; cursor:grab; overscroll-behavior:contain; scrollbar-color:#8fa9c1 #edf2f7; }
.ccms-large-table-wrap.is-dragging { cursor:grabbing; user-select:none; }
.ccms-large-table { border-collapse:separate; border-spacing:0; }
.ccms-large-table thead th { position:sticky; top:0; z-index:5; box-shadow:0 2px 0 rgba(29,70,112,.18); }
.ccms-large-table.is-wide th:nth-child(1), .ccms-large-table.is-wide td:nth-child(1) { position:sticky; left:0; z-index:3; min-width:58px; background:#f8fafc; }
.ccms-large-table.is-wide th:nth-child(2), .ccms-large-table.is-wide td:nth-child(2) { position:sticky; left:var(--ccms-first-col-width, 58px); z-index:3; min-width:180px; background:#fff; border-right:2px solid #ccdae8; }
.ccms-large-table.is-wide thead th:nth-child(1), .ccms-large-table.is-wide thead th:nth-child(2) { z-index:7; color:#fff; background:var(--ccms-primary); }
.ccms-large-table tbody tr:hover td:nth-child(1), .ccms-large-table tbody tr:hover td:nth-child(2) { background:#eef5fc; }
.ccms-table-top-scroll { height:14px; margin-bottom:.35rem; overflow-x:auto; overflow-y:hidden; border-radius:.35rem; background:#edf2f7; }
.ccms-table-top-scroll > div { height:1px; }
.ccms-table-scroll-hint { display:flex; justify-content:flex-end; margin:0 0 .35rem; color:#718298; font-size:.7rem; }
.ccms-large-table-wrap::after { content:''; position:sticky; right:0; float:right; width:10px; height:100%; margin-top:-100%; pointer-events:none; background:linear-gradient(90deg,transparent,rgba(31,65,99,.12)); }
@media (max-width:767.98px) {
  .attendance-matrix-scroll { max-height:68vh; }
  .attendance-matrix .attendance-row-head { min-width:145px; max-width:170px; }
  .attendance-drag-hint { white-space:normal; }
  .ccms-large-table-wrap { max-height:68vh; }
  .ccms-large-table.is-wide th:nth-child(2), .ccms-large-table.is-wide td:nth-child(2) { min-width:145px; }
}

.ccms-auto-icon { margin-right: .05rem; }
@media (max-width: 767.98px) {
  body { font-size: .87rem; }
  .btn { min-height: 40px; }
  .table { font-size: .77rem; }
  .table > :not(caption) > * > * { padding: .58rem .6rem; }
  .container, .container-fluid, .container-md, .container-lg, .container-xl { --bs-gutter-x: 1.25rem; }
}
@media print {
  body { color: #000; background: #fff; }
  .btn, .no-print { display: none !important; }
  .card, .container.bg-light, .container-md.bg-light, .container-lg.bg-light, .container-xl.bg-light { box-shadow: none !important; }
}
