:root {
    --brand-900: #0d2747;
    --brand-800: #123461;
    --brand-700: #1a4a8a;
    --brand-600: #1f5fbf;
    --brand-100: #e4edf9;
    --ink: #1c2733;
    --muted: #63707f;
    --line: #dde3ea;
    --surface: #ffffff;
    --canvas: #f2f5f8;
    --sidebar-width: 256px;
    --bs-primary: #1f5fbf;
    --bs-primary-rgb: 31, 95, 191;
    --bs-link-color: #1a4a8a;
    --bs-link-color-rgb: 26, 74, 138;
    --bs-body-color: #1c2733;
    --bs-font-sans-serif: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

body { background: var(--canvas); color: var(--ink); font-size: .925rem; }

.btn-primary {
    --bs-btn-bg: var(--brand-600); --bs-btn-border-color: var(--brand-600);
    --bs-btn-hover-bg: var(--brand-700); --bs-btn-hover-border-color: var(--brand-700);
    --bs-btn-active-bg: var(--brand-800); --bs-btn-active-border-color: var(--brand-800);
    --bs-btn-disabled-bg: var(--brand-600); --bs-btn-disabled-border-color: var(--brand-600);
}
.btn-outline-primary {
    --bs-btn-color: var(--brand-600); --bs-btn-border-color: var(--brand-600);
    --bs-btn-hover-bg: var(--brand-600); --bs-btn-hover-border-color: var(--brand-600);
    --bs-btn-active-bg: var(--brand-700); --bs-btn-active-border-color: var(--brand-700);
}
.text-bg-primary { background-color: var(--brand-600) !important; }

/* Sidebar */
.app-sidebar {
    --bs-offcanvas-width: var(--sidebar-width);
    --bs-offcanvas-bg: var(--brand-900);
    width: var(--sidebar-width);
    /* Bootstrap menjadikan offcanvas-lg lutsinar dengan !important pada skrin besar. */
    background-color: var(--brand-900) !important;
    color: #cfdbeb;
}
@media (min-width: 992px) {
    .app-sidebar { position: fixed; inset: 0 auto 0 0; z-index: 1030; visibility: visible !important; transform: none !important; overflow-y: auto; }
    .app-main { margin-left: var(--sidebar-width); }
}
.app-sidebar .offcanvas-body { display: flex; flex-direction: column; padding: 0; overflow-y: auto; }
.app-sidebar .offcanvas-body > * { flex-shrink: 0; }
.app-brand { display: flex; gap: .65rem; align-items: center; padding: 1rem 1.1rem; border-bottom: 1px solid rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.app-brand img { width: 38px; height: 38px; object-fit: contain; background: #fff; border-radius: 6px; padding: 2px; }
.app-brand .brand-mark { width: 38px; height: 38px; flex: none; border-radius: 6px; background: var(--brand-600); display: grid; place-items: center; font-size: 1.15rem; color: #fff; }
.app-brand strong { display: block; font-size: .95rem; line-height: 1.2; }
.app-brand small { color: #9fb2cb; font-size: .72rem; line-height: 1.2; display: block; }

.nav-section { padding: .95rem 1.1rem .3rem; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: #8197b4; }
.side-link { display: flex; align-items: center; gap: .65rem; padding: .5rem 1.1rem; color: #cfdbeb; text-decoration: none; border-left: 3px solid transparent; }
.side-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.side-link.active { background: rgba(31,95,191,.32); border-left-color: #6ea4ee; color: #fff; font-weight: 600; }
.side-link .badge { margin-left: auto; }

/* Topbar */
.app-topbar { background: var(--surface); border-bottom: 1px solid var(--line); padding: .55rem 1rem; position: sticky; top: 0; z-index: 1020; }
.topbar-icon { position: relative; color: var(--ink); font-size: 1.2rem; padding: .25rem .45rem; }
.topbar-icon .count { position: absolute; top: -2px; right: -3px; font-size: .62rem; padding: .15em .4em; }
.notification-menu { width: min(340px, 92vw); max-height: 420px; overflow-y: auto; }
.notification-menu .dropdown-item { white-space: normal; border-bottom: 1px solid var(--line); padding: .55rem .85rem; }
.notification-menu .unread { background: var(--brand-100); }

.app-content { padding: 1.1rem 1rem 2rem; }
@media (min-width: 768px) { .app-content { padding: 1.4rem 1.6rem 2.5rem; } }

.page-title { font-size: 1.3rem; font-weight: 600; margin: 0; }
.breadcrumb { font-size: .8rem; margin-bottom: .2rem; --bs-breadcrumb-divider-color: var(--muted); }
.breadcrumb a { text-decoration: none; }

/* Kad */
.card { border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 1px 2px rgba(13,39,71,.04); }
.card-header { background: var(--surface); border-bottom: 1px solid var(--line); font-weight: 600; padding: .7rem 1rem; }

.stat-card { display: flex; align-items: center; gap: .85rem; padding: .95rem 1rem; height: 100%; color: inherit; text-decoration: none; }
a.stat-card:hover { background: #f8fafc; }
.stat-icon { width: 42px; height: 42px; flex: none; border-radius: 8px; display: grid; place-items: center; font-size: 1.2rem; background: var(--brand-100); color: var(--brand-700); }
.stat-icon.good { background: #e3f4ea; color: #1f7a45; }
.stat-icon.info { background: #dff3f7; color: #0d7c92; }
.stat-icon.warn { background: #fdf3d8; color: #9a7000; }
.stat-icon.danger { background: #fbe6e3; color: #b3321f; }
.stat-value { font-size: 1.45rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: .78rem; color: var(--muted); }

/* Jadual */
.table { --bs-table-border-color: var(--line); margin-bottom: 0; }
.table thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: #f8fafc; white-space: nowrap; }
.table td { vertical-align: middle; }
.table-empty { text-align: center; color: var(--muted); padding: 2.2rem 1rem !important; }
.filter-bar { padding: .75rem 1rem; border-bottom: 1px solid var(--line); }
.pagination-wrap { padding: .75rem 1rem; border-top: 1px solid var(--line); }
.pagination-wrap nav > div:first-child { display: none !important; }
.pagination-wrap .pagination { margin: 0; flex-wrap: wrap; }
.pagination-wrap p { margin-bottom: .4rem; font-size: .8rem; color: var(--muted); }

.detail-list { display: grid; grid-template-columns: minmax(110px, 34%) 1fr; gap: .45rem .9rem; margin: 0; }
.detail-list dt { font-weight: 500; color: var(--muted); font-size: .84rem; }
.detail-list dd { margin: 0; overflow-wrap: anywhere; }

.form-label { font-weight: 500; font-size: .86rem; margin-bottom: .25rem; }
.form-label .req { color: #b3321f; }
.form-text { font-size: .78rem; }
.flatpickr-input[readonly] { background: #fff; }

.asset-thumb { width: 100%; max-height: 240px; object-fit: contain; background: #f8fafc; border-radius: 6px; }
.availability-note { font-size: .78rem; margin-top: .2rem; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 .9rem 1.1rem; border-left: 2px solid var(--line); margin-left: .35rem; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand-600); }
.timeline small { color: var(--muted); }

.chart-box { position: relative; height: 280px; }

/* Log masuk */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: linear-gradient(160deg, var(--brand-900), var(--brand-700)); }
.auth-card { width: min(410px, 100%); background: #fff; border-radius: 10px; padding: 1.8rem; box-shadow: 0 12px 34px rgba(0,0,0,.25); }
.auth-card img { max-height: 64px; max-width: 160px; }
.auth-mark { width: 54px; height: 54px; border-radius: 10px; background: var(--brand-600); color: #fff; display: inline-grid; place-items: center; font-size: 1.6rem; }

/* Senarai pilihan boleh dicari */
.search-select { position: relative; }
.search-select-native { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.search-select-toggle { display: block; width: 100%; text-align: left; }
.search-select-menu { position: fixed; z-index: 1090; padding: .5rem; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.15); }
.search-select-list { max-height: 260px; margin: .4rem 0 0; padding: 0; overflow-y: auto; list-style: none; font-size: .875rem; }
.search-select-option { padding: .35rem .5rem; border-radius: 4px; cursor: pointer; }
.search-select-option.is-selected { font-weight: 600; }
.search-select-option.is-active { background: var(--brand-100); }
.search-select-group { padding: .5rem .5rem .15rem; color: var(--muted); font-size: .75rem; font-weight: 600; }
.search-select-empty { padding: .35rem .5rem; color: var(--muted); }

/* Kalendar */
.fc { --fc-border-color: var(--line); --fc-button-bg-color: var(--brand-700); --fc-button-border-color: var(--brand-700); --fc-button-hover-bg-color: var(--brand-800); --fc-button-hover-border-color: var(--brand-800); --fc-button-active-bg-color: var(--brand-900); --fc-button-active-border-color: var(--brand-900); --fc-today-bg-color: var(--brand-100); }
.fc .fc-toolbar-title { font-size: 1.1rem; font-weight: 600; }
.fc a { text-decoration: none; color: inherit; }
.fc .fc-button { font-size: .82rem; }
.fc-event { cursor: pointer; }
@media (max-width: 575.98px) { .fc .fc-toolbar { flex-direction: column; gap: .5rem; } }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .3rem; }

/* Halaman cetak */
.print-page { background: #fff; font-size: 12px; padding: 16px; }
.print-page table { width: 100%; border-collapse: collapse; }
.print-page th, .print-page td { border: 1px solid #999; padding: 4px 5px; text-align: left; vertical-align: top; }
.print-page th { background: #eef2f7; }
@media print {
    .no-print { display: none !important; }
    @page { size: A4 landscape; margin: 10mm; }
}
