/* =====================================================================
   Integrated Management System: design system
   ===================================================================== */
:root {
    --ims-primary: #1E293B;
    --ims-secondary: #2563EB;
    --ims-bg: #F8FAFC;
    --ims-white: #FFFFFF;
    --ims-success: #16A34A;
    --ims-warning: #F59E0B;
    --ims-danger: #DC2626;
    --ims-purple: #7C3AED;
    --ims-info: #0891B2;
    --ims-muted: #64748B;
    --ims-border: #E2E8F0;
    --ims-text: #0F172A;
    --ims-radius: 14px;
    --ims-radius-sm: 10px;
    --ims-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
    --ims-shadow-lg: 0 10px 40px rgba(15, 23, 42, .12);
    --sidebar-w: 264px;
    --sidebar-w-collapsed: 78px;
    --topbar-h: 64px;

    --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-body-bg: var(--ims-bg);
    --bs-body-color: var(--ims-text);
    --bs-primary: #2563EB;
    --bs-primary-rgb: 37, 99, 235;
    --bs-link-color: #2563EB;
    --bs-link-color-rgb: 37, 99, 235;
    --bs-border-color: var(--ims-border);
    --bs-border-radius: var(--ims-radius-sm);
}

body { background: var(--ims-bg); color: var(--ims-text); font-size: .925rem; -webkit-font-smoothing: antialiased; }
a { text-decoration: none; }
.text-muted { color: var(--ims-muted) !important; }
.fw-semibold { font-weight: 600 !important; }
.small-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ims-muted); font-weight: 600; }

/* ---- Buttons ------------------------------------------------------ */
.btn { border-radius: var(--ims-radius-sm); font-weight: 500; padding: .5rem 1rem; }
.btn-sm { padding: .3rem .7rem; border-radius: 8px; }
.btn-primary { --bs-btn-bg: #2563EB; --bs-btn-border-color: #2563EB; --bs-btn-hover-bg: #1D4ED8; --bs-btn-hover-border-color: #1D4ED8; --bs-btn-active-bg: #1E40AF; }
.btn-dark { --bs-btn-bg: var(--ims-primary); --bs-btn-border-color: var(--ims-primary); }
.btn-purple { --bs-btn-color: #fff; --bs-btn-bg: var(--ims-purple); --bs-btn-border-color: var(--ims-purple); --bs-btn-hover-bg: #6D28D9; --bs-btn-hover-color: #fff; --bs-btn-hover-border-color: #6D28D9; }
.btn-light { --bs-btn-bg: #F1F5F9; --bs-btn-border-color: #F1F5F9; --bs-btn-hover-bg: #E2E8F0; }
.btn-icon { width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; }

/* ---- Forms -------------------------------------------------------- */
.form-control, .form-select { border-radius: var(--ims-radius-sm); border-color: var(--ims-border); padding: .55rem .8rem; font-size: .925rem; }
.form-control:focus, .form-select:focus { border-color: #93C5FD; box-shadow: 0 0 0 .2rem rgba(37, 99, 235, .15); }
.form-control[readonly] { background: #F1F5F9; }
.form-label { font-weight: 500; font-size: .85rem; margin-bottom: .35rem; color: #334155; }
.required::after { content: " *"; color: var(--ims-danger); }
.input-group-text { border-radius: var(--ims-radius-sm); background: #F1F5F9; border-color: var(--ims-border); }

/* ---- Cards -------------------------------------------------------- */
.card { border: 1px solid var(--ims-border); border-radius: var(--ims-radius); box-shadow: var(--ims-shadow); background: #fff; }
.card-header { background: transparent; border-bottom: 1px solid var(--ims-border); padding: 1rem 1.25rem; font-weight: 600; }
.card-body { padding: 1.25rem; }
.card-title { font-size: 1rem; font-weight: 600; margin: 0; }

.stat-card { position: relative; overflow: hidden; padding: 1.1rem 1.2rem; display: flex; gap: 1rem; align-items: center; height: 100%; }
.stat-card .stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; }
.stat-card .stat-value { font-size: 1.55rem; font-weight: 700; line-height: 1.1; }
.stat-card .stat-label { color: var(--ims-muted); font-size: .8rem; font-weight: 500; }

.soft-primary { background: #DBEAFE; color: #1D4ED8; }
.soft-success { background: #DCFCE7; color: #15803D; }
.soft-warning { background: #FEF3C7; color: #B45309; }
.soft-danger  { background: #FEE2E2; color: #B91C1C; }
.soft-purple  { background: #EDE9FE; color: #6D28D9; }
.soft-info    { background: #CFFAFE; color: #0E7490; }
.soft-dark    { background: #E2E8F0; color: #1E293B; }
.soft-secondary { background: #F1F5F9; color: #475569; }

/* ---- Badges ------------------------------------------------------- */
.badge-status { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .65rem; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.badge-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag-chip { display: inline-flex; align-items: center; padding: .15rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 600; color: #fff; margin: 0 .15rem .15rem 0; }

/* ---- Tables ------------------------------------------------------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; vertical-align: middle; }
.table > thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ims-muted); font-weight: 600; background: #F8FAFC; border-bottom: 1px solid var(--ims-border); padding: .8rem 1rem; white-space: nowrap; }
.table > tbody td { padding: .8rem 1rem; border-color: #F1F5F9; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #F8FAFC; }
.table a.sort { color: inherit; }
.table a.sort .fa-solid { opacity: .5; font-size: .65rem; }
.table-card .card-body { padding: 0; }
.table-responsive { border-radius: 0 0 var(--ims-radius) var(--ims-radius); }
.cell-truncate { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--ims-muted); }
.empty-state i { font-size: 2.2rem; opacity: .35; margin-bottom: .75rem; display: block; }

.pagination { margin: 0; gap: .25rem; }
.page-link { border-radius: 8px !important; border: 1px solid var(--ims-border); color: #334155; font-size: .85rem; }
.page-item.active .page-link { background: var(--ims-secondary); border-color: var(--ims-secondary); }

/* ---- Layout: sidebar --------------------------------------------- */
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--ims-primary); color: #CBD5E1; z-index: 1040; display: flex; flex-direction: column; transition: width .2s ease, transform .25s ease; }
.sidebar-brand { height: var(--topbar-h); display: flex; align-items: center; gap: .75rem; padding: 0 1.25rem; color: #fff; font-weight: 700; border-bottom: 1px solid rgba(255, 255, 255, .06); overflow: hidden; white-space: nowrap; }
.sidebar-brand .brand-logo { width: 36px; height: 36px; border-radius: 10px; background: var(--ims-secondary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; }
.sidebar-brand .brand-logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.sidebar-brand small { display: block; font-weight: 400; color: #94A3B8; font-size: .72rem; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 1rem .75rem; }
.sidebar-nav .nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #64748B; padding: .9rem .75rem .4rem; white-space: nowrap; }
.sidebar-nav .nav-link { display: flex; align-items: center; gap: .8rem; color: #CBD5E1; padding: .62rem .8rem; border-radius: 10px; font-weight: 500; margin-bottom: 2px; white-space: nowrap; overflow: hidden; }
.sidebar-nav .nav-link i.nav-icon { width: 20px; text-align: center; font-size: 1rem; flex-shrink: 0; }
.sidebar-nav .nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--ims-secondary); color: #fff; box-shadow: 0 6px 16px rgba(37, 99, 235, .35); }
.sidebar-nav .nav-link .chevron { margin-left: auto; font-size: .7rem; transition: transform .2s; }
.sidebar-nav .nav-link[aria-expanded="true"] .chevron { transform: rotate(90deg); }
.sidebar-nav .nav-link.parent-active { color: #fff; }
.sidebar-nav .submenu { padding-left: 1.85rem; }
.sidebar-nav .submenu .nav-link { padding: .45rem .8rem; font-size: .88rem; }
.sidebar-nav .submenu .nav-link.active { background: rgba(37, 99, 235, .25); box-shadow: none; color: #fff; }
.sidebar-footer { padding: .9rem 1.25rem; border-top: 1px solid rgba(255, 255, 255, .06); font-size: .75rem; color: #64748B; white-space: nowrap; overflow: hidden; }

.main { margin-left: var(--sidebar-w); min-height: 100vh; transition: margin-left .2s ease; display: flex; flex-direction: column; }
.topbar { height: var(--topbar-h); background: rgba(255, 255, 255, .9); backdrop-filter: blur(8px); border-bottom: 1px solid var(--ims-border); display: flex; align-items: center; gap: 1rem; padding: 0 1.5rem; position: sticky; top: 0; z-index: 1030; }
.topbar .page-title { font-weight: 600; font-size: 1.05rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, #2563EB, #7C3AED); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: .8rem; flex-shrink: 0; }
.content { padding: 1.5rem; flex: 1; }
.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.page-header h1 { font-size: 1.4rem; font-weight: 700; margin: 0; }
.page-header p { margin: .15rem 0 0; color: var(--ims-muted); }
.app-footer { padding: 1rem 1.5rem; color: var(--ims-muted); font-size: .78rem; }

/* collapsed (desktop) */
@media (min-width: 992px) {
    body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
    body.sidebar-collapsed .main { margin-left: var(--sidebar-w-collapsed); }
    body.sidebar-collapsed .sidebar .nav-text,
    body.sidebar-collapsed .sidebar .nav-section,
    body.sidebar-collapsed .sidebar .chevron,
    body.sidebar-collapsed .sidebar .brand-text,
    body.sidebar-collapsed .sidebar .sidebar-footer { display: none; }
    body.sidebar-collapsed .sidebar .submenu { padding-left: 0; }
    body.sidebar-collapsed .sidebar-nav .nav-link { justify-content: center; }
}
/* mobile / tablet */
.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--ims-shadow-lg); }
    .main { margin-left: 0; }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 1035; }
    .content { padding: 1rem; }
    .topbar { padding: 0 1rem; }
}
@media (max-width: 575.98px) {
    .page-header h1 { font-size: 1.2rem; }
    .stat-card .stat-value { font-size: 1.25rem; }
    .card-body { padding: 1rem; }
}

/* ---- Filters bar -------------------------------------------------- */
.filter-bar { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; align-items: end; }
.filter-bar .filter-actions { display: flex; gap: .5rem; }

/* ---- Modals ------------------------------------------------------- */
.modal-content { border: 0; border-radius: 18px; box-shadow: var(--ims-shadow-lg); }
.modal-header { border-bottom: 1px solid var(--ims-border); padding: 1rem 1.5rem; }
.modal-body { padding: 1.5rem; }
.modal-footer { border-top: 1px solid var(--ims-border); padding: .9rem 1.5rem; }

/* ---- Timeline (history) ------------------------------------------ */
.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 15px; top: 4px; bottom: 4px; width: 2px; background: var(--ims-border); }
.timeline li { position: relative; padding: 0 0 1.1rem 44px; }
.timeline .dot { position: absolute; left: 4px; top: 0; width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .65rem; border: 3px solid #fff; }
.timeline .change { font-size: .82rem; background: #F8FAFC; border: 1px solid var(--ims-border); border-radius: 8px; padding: .45rem .65rem; margin-top: .3rem; word-break: break-word; }
.timeline .change del { color: var(--ims-danger); }
.timeline .change ins { color: var(--ims-success); text-decoration: none; }

/* ---- Detail lists ------------------------------------------------- */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem 1.5rem; }
.detail-grid dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ims-muted); font-weight: 600; margin-bottom: .2rem; }
.detail-grid dd { margin: 0; font-weight: 500; word-break: break-word; }
.prewrap { white-space: pre-wrap; }

/* ---- Claim items table ------------------------------------------- */
.items-table td { padding: .5rem !important; vertical-align: top; }
.items-table .form-control, .items-table .form-select { padding: .45rem .6rem; font-size: .875rem; }
.total-box { background: var(--ims-primary); color: #fff; border-radius: var(--ims-radius); padding: 1rem 1.25rem; }
.total-box .amount { font-size: 1.6rem; font-weight: 700; }
@media (max-width: 767.98px) {
    .items-table thead { display: none; }
    .items-table, .items-table tbody, .items-table tr, .items-table td { display: block; width: 100%; }
    .items-table tr { border: 1px solid var(--ims-border); border-radius: 12px; padding: .5rem; margin-bottom: .75rem; }
    .items-table td { border: 0 !important; }
    .items-table td[data-label]::before { content: attr(data-label); display: block; font-size: .72rem; font-weight: 600; color: var(--ims-muted); margin-bottom: .2rem; }
}

/* ---- Calendar ----------------------------------------------------- */
.fc { --fc-border-color: var(--ims-border); --fc-today-bg-color: #EFF6FF; --fc-button-bg-color: #fff; --fc-button-border-color: var(--ims-border); --fc-button-text-color: #334155; --fc-button-hover-bg-color: #F1F5F9; --fc-button-hover-border-color: var(--ims-border); --fc-button-active-bg-color: #2563EB; --fc-button-active-border-color: #2563EB; font-size: .85rem; }
.fc .fc-button { border-radius: 8px !important; font-weight: 500; text-transform: capitalize; box-shadow: none !important; }
.fc .fc-button-primary:not(:disabled).fc-button-active { color: #fff; }
.fc .fc-toolbar-title { font-size: 1.15rem; font-weight: 700; }
.fc-event { cursor: pointer; border-radius: 6px; padding: 1px 3px; }
.fc .fc-daygrid-day:hover { background: #F8FAFC; cursor: pointer; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: .35rem; }
@media (max-width: 767.98px) {
    .fc .fc-toolbar { flex-direction: column; gap: .5rem; }
    .fc .fc-toolbar-title { font-size: 1rem; }
}

/* ---- Auth / public pages ----------------------------------------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { background: radial-gradient(circle at 20% 20%, #334155 0, var(--ims-primary) 60%); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-side::after { content: ""; position: absolute; width: 420px; height: 420px; border-radius: 50%; background: rgba(37, 99, 235, .25); filter: blur(60px); right: -120px; bottom: -120px; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 420px; }
@media (max-width: 991.98px) { .auth-wrap { grid-template-columns: 1fr; } .auth-side { display: none; } }

.public-header { background: #fff; border-bottom: 1px solid var(--ims-border); }
.public-hero { background: radial-gradient(1200px 400px at 50% -10%, #DBEAFE 0, transparent 60%), var(--ims-bg); padding: 4rem 1rem 3rem; }
.track-card { max-width: 640px; margin: 0 auto; }
.track-input { font-size: 1.05rem; padding: .85rem 1rem; text-transform: uppercase; letter-spacing: .04em; }

/* ---- Print -------------------------------------------------------- */
@media print {
    .sidebar, .topbar, .no-print, .app-footer { display: none !important; }
    .main { margin: 0 !important; }
    .card { box-shadow: none; border-color: #ccc; }
    body { background: #fff; }
}
