:root {
    --primary: #1a56db;
    --primary-dark: #1e40af;
    --primary-light: #dbeafe;
    --success: #059669;
    --success-light: #d1fae5;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --info: #0891b2;
    --info-light: #cffafe;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --sidebar-width: 260px;
    --header-height: 64px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--gray-100); color: var(--gray-800); font-size: 14px; line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Restore original heading proportions (Bootstrap 5 enables responsive vw font sizing) */
h1, h2, h3, h4, h5, h6 { font-weight: 700; line-height: 1.25; }
h1 { font-size: 2em; }
h2 { font-size: 1.5em; }
h3 { font-size: 1.17em; }
h4 { font-size: 1em; }
h5 { font-size: 0.83em; }
h6 { font-size: 0.67em; }

/* Login */
.login-page { display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: 24px; background: linear-gradient(135deg, #1a56db 0%, #1e3a8a 100%); }
.login-card { background: #fff; border-radius: 12px; padding: 40px; width: 420px; max-width: 90vw; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.login-card h1 { font-size: 24px; color: var(--gray-900); margin-bottom: 4px; text-align: center; }
.login-card .subtitle { color: var(--gray-500); margin-bottom: 24px; font-size: 13px; text-align: center; }

/* Animated SHIMS logo */
.login-logo-wrap { width: 210px; height: 210px; margin: 0 auto 12px; position: relative; }
.login-logo { position: absolute; top: 0; left: 0; width: 420px; height: 420px; transform: scale(0.5); transform-origin: top left; }
.login-logo .ring { position: absolute; inset: 0; border: 10px solid #009966; border-radius: 50%; box-shadow: 0 0 20px rgba(0,153,102,.35), inset 0 0 20px rgba(0,153,102,.20); }
.login-logo .orbit { position: absolute; inset: 0; animation: login-spin 18s linear infinite; }
.login-logo .letters { position: absolute; inset: 0; animation: login-spin-rev 18s linear infinite; }
.login-logo .center { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); width: 150px; height: 150px; border-radius: 50%; background: #005a9c; display: flex; justify-content: center; align-items: center; box-shadow: 0 12px 30px rgba(0,0,0,.25); z-index: 2; }
.login-logo .cross { position: relative; width: 28px; height: 90px; background: #ffffff; border-radius: 8px; }
.login-logo .cross::before { content: ""; position: absolute; left: -31px; top: 31px; width: 90px; height: 28px; background: #ffffff; border-radius: 8px; }
.login-logo .ball { position: absolute; width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 30% 30%, #ffffff, #e7e7e7, #b8b8b8, #7c7c7c); box-shadow: inset -2px -2px 5px rgba(0,0,0,.35), 0 3px 8px rgba(0,0,0,.25); }
.login-logo .ball:nth-child(1) { top: -11px; left: 50%; transform: translateX(-50%); }
.login-logo .ball:nth-child(2) { top: 85px; right: 18px; }
.login-logo .ball:nth-child(3) { bottom: 85px; right: 18px; }
.login-logo .ball:nth-child(4) { bottom: -11px; left: 50%; transform: translateX(-50%); }
.login-logo .ball:nth-child(5) { top: 50%; left: -11px; transform: translateY(-50%); }
.login-logo .letter { position: absolute; width: 40px; height: 40px; border-radius: 50%; background: #005a9c; color: #fff; display: flex; justify-content: center; align-items: center; font-weight: bold; font-size: 22px; box-shadow: 0 5px 15px rgba(0,0,0,.20); }
.login-logo .letter:nth-child(1) { top: 18px; left: 50%; transform: translateX(-50%); }
.login-logo .letter:nth-child(2) { top: 92px; right: 55px; }
.login-logo .letter:nth-child(3) { bottom: 92px; right: 55px; }
.login-logo .letter:nth-child(4) { bottom: 18px; left: 50%; transform: translateX(-50%); }
.login-logo .letter:nth-child(5) { top: 50%; left: 18px; transform: translateY(-50%); }
@keyframes login-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes login-spin-rev { from { transform: rotate(360deg); } to { transform: rotate(0deg); } }
@media (prefers-reduced-motion: reduce) {
    .login-logo .orbit, .login-logo .letters { animation: none; }
}
@media (max-width: 480px) {
    .login-page { padding: 16px; }
    .login-card { padding: 24px; }
    .login-logo-wrap { width: 168px; height: 168px; }
    .login-logo { transform: scale(0.4); }
}
@media (max-width: 380px) {
    .login-card { padding: 20px; }
    .login-logo-wrap { width: 126px; height: 126px; }
    .login-logo { transform: scale(0.3); }
}

/* Layout */
.app-layout { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-width); background: var(--gray-900); color: #fff; position: fixed; top: 0; left: 0; bottom: 0; overflow-y: auto; z-index: 100; }
.sidebar-brand { padding: 20px; border-bottom: 1px solid var(--gray-700); }
.sidebar-brand h2 { font-size: 16px; font-weight: 700; }
.sidebar-brand span { font-size: 11px; color: var(--gray-400); display: block; margin-top: 2px; }
.sidebar-nav { padding: 12px 0; }
.sidebar-nav .nav-section { padding: 8px 20px 4px; font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--gray-500); }
.sidebar-nav a { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: var(--gray-300); font-size: 13px; transition: all 0.15s; }
.sidebar-nav a:hover { background: var(--gray-700); color: #fff; text-decoration: none; }
.sidebar-nav a.active { background: var(--primary); color: #fff; }
.sidebar-nav a .icon { width: 20px; text-align: center; font-size: 16px; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--gray-700); margin-top: auto; }
.sidebar-footer .user-info { font-size: 13px; }
.sidebar-footer .user-name { font-weight: 600; }
.sidebar-footer .user-role { font-size: 11px; color: var(--gray-400); }
.sidebar-footer a { display: block; margin-top: 8px; font-size: 12px; color: var(--danger); }

.main-content { margin-left: var(--sidebar-width); flex: 1; min-width: 0; }
.top-header { height: var(--header-height); background: #fff; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 50; }
.top-header h1 { font-size: 18px; font-weight: 600; color: var(--gray-900); }
.top-header-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.top-header-left h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content-area { padding: 24px; }

/* Mobile sidebar toggle (hamburger) */
.sidebar-toggle { display: none; flex-direction: column; justify-content: center; gap: 5px; width: 40px; height: 40px; padding: 0 9px; background: none; border: 1px solid var(--gray-200); border-radius: 6px; cursor: pointer; flex-shrink: 0; }
.sidebar-toggle span { display: block; height: 2px; width: 20px; background: var(--gray-700); border-radius: 2px; transition: background 0.15s; }
.sidebar-toggle:hover span { background: var(--primary); }

/* Backdrop shown behind off-canvas sidebar on small screens */
.sidebar-backdrop { display: none; }

/* Cards & Stats */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { position: relative; background: #fff; border-radius: 8px; padding: 20px; border: 1px solid var(--gray-200); }
.stat-card .stat-label { font-size: 12px; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: var(--gray-900); margin-top: 4px; }
.stat-card .stat-sub { font-size: 12px; color: var(--gray-400); margin-top: 2px; }
.stat-card.primary { border-left: 4px solid var(--primary); }
.stat-card.success { border-left: 4px solid var(--success); }
.stat-card.warning { border-left: 4px solid var(--warning); }
.stat-card.danger { border-left: 4px solid var(--danger); }

/* Blue orbit ring on stat/dashboard cards */
.stat-card::before {
    content: "";
    position: absolute;
    inset: -10px;
    border: 2px dashed rgba(26, 86, 219, 0.45);
    border-radius: 14px;
    pointer-events: none;
    z-index: 0;
}
.stat-card .stat-label, .stat-card .stat-value, .stat-card .stat-sub { position: relative; z-index: 1; }

/* Single dot circulating along the ring path (CSS motion path). */
/* Static fallback (top-center) for browsers without offset-path support. */
.stat-card::after {
    content: "";
    position: absolute;
    top: -15px;
    left: 50%;
    width: 10px;
    height: 10px;
    margin-left: -5px;
    border-radius: 50%;
    background: rgba(26, 86, 219, 0.9);
    box-shadow: 0 0 10px rgba(26, 86, 219, 0.7);
    pointer-events: none;
    z-index: 1;
}
@supports (offset-path: rect(0 0 100% 100% round 14px)) {
    .stat-card::after {
        top: 0;
        left: 0;
        margin-left: 0;
        offset-path: rect(-10px calc(100% + 10px) calc(100% + 10px) -10px round 14px);
        animation: stat-dot-orbit 8s linear infinite;
    }
}
@keyframes stat-dot-orbit {
    from { offset-distance: 0%; }
    to { offset-distance: 100%; }
}
@media (prefers-reduced-motion: reduce) {
    .stat-card::after, .login-logo .orbit, .login-logo .letters { animation: none; }
}

.card { background: #fff; border-radius: 8px; border: 1px solid var(--gray-200); margin-bottom: 24px; }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--gray-200); display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; background: #fff; }
.card-header h2 { font-size: 16px; font-weight: 600; }
.card-body { padding: 20px; }
.card-header .flex { flex-wrap: wrap; }

/* Tables */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
table th { text-align: left; padding: 10px 12px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--gray-500); background: var(--gray-50); border-bottom: 2px solid var(--gray-200); font-weight: 600; white-space: nowrap; }

table th a.sortable { color: var(--gray-500); text-decoration: none; }
table th a.sortable:hover { color: var(--primary-color); }
table th a.sortable.active { color: var(--primary-color); font-weight: 700; }
table td { padding: 10px 12px; border-bottom: 1px solid var(--gray-100); font-size: 13px; vertical-align: middle; }
table tbody tr:hover { background: var(--gray-50); }
table .actions { white-space: nowrap; }
table .actions a, table .actions button { margin-right: 6px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 6px; font-size: 13px; font-weight: 500; border: 1px solid transparent; cursor: pointer; transition: all 0.15s; text-decoration: none; }
.btn:hover { text-decoration: none; opacity: 0.9; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { background: #fff; color: var(--gray-600); border-color: var(--gray-300); }
.btn-outline:hover { background: var(--gray-50); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-xs { padding: 2px 8px; font-size: 11px; }

/* Badges */
.badge { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-success { background: var(--success-light); color: #065f46; }
.badge-danger { background: var(--danger-light); color: #991b1b; }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-info { background: var(--info-light); color: #155e75; }
.badge-gray { background: var(--gray-200); color: var(--gray-600); }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--gray-700); margin-bottom: 4px; }
.form-group .hint { font-size: 12px; color: var(--gray-400); margin-top: 2px; }
.form-control { width: 100%; padding: 8px 12px; border: 1px solid var(--gray-300); border-radius: 6px; font-size: 13px; font-family: inherit; transition: border-color 0.15s; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,0.1); }
select.form-control { appearance: auto; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; gap: 8px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--gray-200); }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 13px; }
.alert-success { background: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }

/* Modal */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 1000; justify-content: center; align-items: center; }
.modal-overlay.show { display: flex; }
.modal { position: relative; display: block; background: #fff; border-radius: 8px; width: 500px; max-width: 92vw; max-height: 85vh; overflow-y: auto; }
@media (max-width: 575.98px) {
    .modal { width: 100%; max-width: 100%; border-radius: 8px; max-height: 92vh; }
    .modal-overlay { padding: 12px; }
}
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--gray-200); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { font-size: 16px; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--gray-400); }
.modal-body { padding: 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 8px; }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; flex-wrap: wrap; }
.pagination-info { font-size: 13px; color: var(--gray-500); }
.pagination-links { display: flex; gap: 4px; flex-wrap: wrap; }
.pagination-links a, .pagination-links span { padding: 6px 12px; border: 1px solid var(--gray-300); border-radius: 4px; font-size: 13px; }
.pagination-links a:hover { background: var(--gray-50); text-decoration: none; }
.pagination-links span.current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Record counter */
.record-counter { font-size: 13px; color: var(--gray-500); padding: 12px 0 0; }

/* Filters */
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters .form-control { width: auto; min-width: 160px; }
.filters input[type="text"] { min-width: 220px; }

/* Responsive
   Mobile-first off-canvas sidebar below lg (992px), matching Bootstrap 5 breakpoints. */
@media (min-width: 992px) {
    .sidebar { transform: none; }
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        width: 280px;
        box-shadow: none;
    }
    body.sidebar-open { overflow: hidden; }
    body.sidebar-open .sidebar { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,0.35); }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 90; }
    .sidebar-toggle { display: flex; }
    .main-content { margin-left: 0; }
    .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 767.98px) {
    .top-header { padding: 0 16px; }
    .content-area { padding: 16px; }
    .card-body, .card-header { padding: 14px 16px; }
    .modal-body, .modal-header, .modal-footer { padding: 16px; }
    table th, table td { padding: 8px 10px; font-size: 12px; }
    .btn { padding: 7px 12px; }
}

@media (max-width: 575.98px) {
    .content-area { padding: 12px; }
    .filters { flex-direction: column; align-items: stretch; }
    .filters .form-control, .filters input[type="text"] { width: 100%; min-width: 0; }
    .filters .btn { justify-content: center; }
    .stat-grid { grid-template-columns: 1fr; }
    .stat-card .stat-value { font-size: 24px; }
    .form-actions { flex-wrap: wrap; }
    .form-actions .btn { flex: 1; justify-content: center; }
    .card-header h2 { font-size: 15px; }
    .empty-state { padding: 24px 12px; }
}

/* Empty state */
.empty-state { text-align: center; padding: 40px 20px; color: var(--gray-400); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* Misc */
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--gray-400); }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
