/* =========================================================
   SoftDesk admin theme (Bootstrap 5.3 + light/dark)
   ========================================================= */
:root {
    --sd-primary: #4f46e5;
    --sd-primary-rgb: 79, 70, 229;
    --sd-sidebar-bg: #ffffff;
    --sd-sidebar-fg: #374151;
    --sd-sidebar-active: #ffffff;
    --sd-sidebar-width: 230px;
    --sd-body-bg: #f4f6fb;
    --sd-card-bg: #ffffff;
    --sd-border: #e5e7eb;
    --sd-muted: #6b7280;
    --bs-primary: var(--sd-primary);
    --bs-primary-rgb: var(--sd-primary-rgb);
    --bs-link-color: var(--sd-primary);
    --bs-link-color-rgb: var(--sd-primary-rgb);
}
[data-bs-theme="dark"] {
    --sd-sidebar-bg: #161c2b;
    --sd-sidebar-fg: #cbd5e1;
    --sd-body-bg: #0f1420;
    --sd-card-bg: #161c2b;
    --sd-border: #273046;
    --sd-muted: #94a3b8;
    --bs-body-bg: #0f1420;
    --bs-tertiary-bg: #1b2234;
}

body { background: var(--sd-body-bg); font-size: 1rem; }
.btn-primary { --bs-btn-bg: var(--sd-primary); --bs-btn-border-color: var(--sd-primary); --bs-btn-hover-bg: #4338ca; --bs-btn-hover-border-color: #4338ca; --bs-btn-active-bg: #3730a3; }
.btn-outline-primary { --bs-btn-color: var(--sd-primary); --bs-btn-border-color: var(--sd-primary); --bs-btn-hover-bg: var(--sd-primary); --bs-btn-hover-border-color: var(--sd-primary); }
.text-primary { color: var(--sd-primary) !important; }
.form-control:focus, .form-select:focus { border-color: rgba(var(--sd-primary-rgb), .5); box-shadow: 0 0 0 .2rem rgba(var(--sd-primary-rgb), .15); }

/* ---------- Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sd-sidebar-width); z-index: 1040;
    background: var(--sd-sidebar-bg); color: var(--sd-sidebar-fg); border-right: 1px solid var(--sd-border);
    display: flex; flex-direction: column; transition: transform .25s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.25rem; color: var(--bs-body-color); text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.sidebar-brand:hover { color: var(--bs-body-color); }
.brand-mark { display: inline-flex; width: 34px; height: 34px; border-radius: 10px; align-items: center; justify-content: center; background: var(--sd-primary); color: #fff; }
.brand-logo { height: 30px; max-width: 185px; object-fit: contain; object-position: left center; }
[data-bs-theme="dark"] .brand-logo { background: #fff; padding: 3px 6px; border-radius: 6px; }
.brand-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem .65rem; }
.nav-heading { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; padding: .9rem .75rem .35rem; color: #6b7280; }
.nav-link-item { display: flex; align-items: center; gap: .75rem; padding: .65rem .85rem; margin-bottom: 4px; font-weight: 500; border-radius: 8px; color: var(--sd-sidebar-fg); text-decoration: none; }
.nav-link-item i { font-size: 1.05rem; width: 1.2rem; text-align: center; }
.nav-link-item:hover { color: var(--sd-primary); background: rgba(var(--sd-primary-rgb), .08); }
.nav-link-item.active { color: var(--sd-sidebar-active); background: var(--sd-primary); }
.sidebar-footer { padding: .75rem 1.25rem; color: var(--sd-muted); }
.nav-divider { height: 1px; background: var(--sd-border); margin: .6rem .5rem; }
.sidebar-backdrop { display: none; }

.main-area { flex: 1; margin-left: var(--sd-sidebar-width); min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .75rem;
    padding: .7rem 1.5rem; background: var(--sd-card-bg); border-bottom: 1px solid var(--sd-border);
}
.page-title { font-size: 1.15rem; font-weight: 600; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-icon { border: 0; background: transparent; color: inherit; width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; }
.btn-icon:hover { background: var(--bs-tertiary-bg); }
.user-chip { display: flex; align-items: center; gap: .5rem; border: 1px solid var(--sd-border); border-radius: 999px; padding: .2rem .7rem .2rem .25rem; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: rgba(var(--sd-primary-rgb), .15); color: var(--sd-primary); font-weight: 700; }
.content { padding: 1.5rem; flex: 1; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    body.sidebar-open .sidebar { transform: none; }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1035; }
    .main-area { margin-left: 0; }
    .content { padding: 1rem; }
    .topbar { padding: .6rem 1rem; }
}

/* ---------- Cards ---------- */
.card { background: var(--sd-card-bg); border: 1px solid var(--sd-border); border-radius: 14px; }
.card-header { background: transparent; border-bottom: 1px solid var(--sd-border); padding: .9rem 1.25rem; font-weight: 600; }
.stat-card { position: relative; overflow: hidden; }
.stat-card .card-body { padding: 1.1rem 1.25rem; }
.stat-label { color: var(--sd-muted); font-size: .95rem; font-weight: 500; }
.stat-value { font-size: 1.75rem; font-weight: 700; margin-top: .25rem; line-height: 1.2; word-break: break-word; }
.stat-sub { font-size: .85rem; color: var(--sd-muted); }
.stat-icon { position: absolute; right: 1rem; top: 1rem; width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; }
.bg-soft-primary { background: rgba(var(--sd-primary-rgb), .12); color: var(--sd-primary); }
.bg-soft-success { background: rgba(25,135,84,.12); color: #198754; }
.bg-soft-warning { background: rgba(255,193,7,.18); color: #b58100; }
.bg-soft-danger  { background: rgba(220,53,69,.12); color: #dc3545; }
.bg-soft-info    { background: rgba(13,202,240,.14); color: #0aa2c0; }
.chart-box { position: relative; height: 290px; }

/* ---------- Tables ---------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > thead th { font-size: .85rem; color: var(--sd-muted); font-weight: 600; white-space: nowrap; border-bottom-width: 1px; background: var(--bs-tertiary-bg); }
.table td { vertical-align: middle; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: rgba(var(--sd-primary-rgb), .04); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable::after { content: "\2195"; opacity: .35; margin-left: .3rem; font-size: .8em; }
th.sort-asc::after { content: "\2191"; opacity: 1; }
th.sort-desc::after { content: "\2193"; opacity: 1; }
.dt-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .9rem 1.25rem; border-bottom: 1px solid var(--sd-border); }
.dt-toolbar .dt-search { max-width: 280px; }
.dt-footer { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; padding: .75rem 1.25rem; border-top: 1px solid var(--sd-border); font-size: .85rem; color: var(--sd-muted); }
.dt-footer .pagination { margin: 0; }
.dt-loading { opacity: .5; pointer-events: none; }
.table .actions { white-space: nowrap; text-align: right; }
.table .actions .btn { padding: .2rem .45rem; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }

.badge-status { font-weight: 600; letter-spacing: .02em; padding: .38em .65em; border-radius: 999px; }
.text-bg-warning.badge-status { color: #6b4e00 !important; }

/* ---------- Forms / modals ---------- */
.modal-content { border-radius: 14px; border: 1px solid var(--sd-border); background: var(--sd-card-bg); }
.modal-header, .modal-footer { border-color: var(--sd-border); }
.form-label { font-weight: 500; font-size: .85rem; margin-bottom: .3rem; }
.required::after { content: " *"; color: #dc3545; }
.form-hint { font-size: .75rem; color: var(--sd-muted); }

/* ---------- Misc ---------- */
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--sd-muted); }
.empty-state i { font-size: 2rem; display: block; margin-bottom: .5rem; }
.detail-list dt { font-weight: 500; color: var(--sd-muted); font-size: .8rem; }
.detail-list dd { margin-bottom: .65rem; }
.nav-tabs .nav-link { color: var(--sd-muted); }
.nav-tabs .nav-link.active { color: var(--sd-primary); font-weight: 600; }
.placeholder-chip { cursor: pointer; font-family: monospace; }
.toast { border-radius: 12px; }

/* ---------- Auth ---------- */
.auth-body { min-height: 100vh; background: radial-gradient(circle at 20% 20%, rgba(var(--sd-primary-rgb), .25), transparent 40%), radial-gradient(circle at 80% 80%, rgba(14,165,233,.2), transparent 40%), var(--sd-body-bg); }
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1rem; }
.auth-card { width: 100%; max-width: 420px; border-radius: 18px; }
.auth-mark { display: inline-flex; width: 60px; height: 60px; border-radius: 16px; align-items: center; justify-content: center; background: var(--sd-primary); color: #fff; font-size: 1.8rem; }
.auth-logo { max-height: 70px; max-width: 200px; object-fit: contain; }

@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .main-area { margin: 0; }
}

/* ---------- Simple dashboard ---------- */
.welcome h2 { font-size: 1.5rem; font-weight: 700; margin: 0; }
.welcome p { color: var(--sd-muted); margin: .25rem 0 0; }
.quick-actions .btn { padding: .6rem 1rem; font-weight: 500; }
.owe-row td { padding-top: .85rem; padding-bottom: .85rem; }
.owe-amount { font-size: 1.05rem; font-weight: 700; }

/* ---------- Reports index ---------- */
.report-card { transition: border-color .15s ease, box-shadow .15s ease; }
.report-card:hover { border-color: rgba(var(--sd-primary-rgb), .45); box-shadow: 0 2px 10px rgba(var(--sd-primary-rgb), .08); }
.report-icon { flex: 0 0 38px; width: 38px; height: 38px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.1rem; }

/* ---------- Collect Payment ---------- */
.step-no { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; align-items: center; justify-content: center; background: var(--sd-primary); color: #fff; font-size: .75rem; font-weight: 700; margin-right: .5rem; }
.collect-clients { max-height: 560px; overflow-y: auto; }
.collect-clients .list-group-item.active { background: rgba(var(--sd-primary-rgb), .1); color: inherit; border-color: var(--sd-border); box-shadow: inset 3px 0 0 var(--sd-primary); }
.collect-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .5rem; background: var(--bs-tertiary-bg); border-radius: 10px; padding: .75rem 1rem; }
.collect-summary span { display: block; font-size: .8rem; color: var(--sd-muted); }
.collect-summary strong { font-size: 1.05rem; }
.done-icon { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 50%; background: rgba(25,135,84,.12); color: #198754; display: flex; align-items: center; justify-content: center; font-size: 2rem; }

/* Collect Payment: months in advance */
.advance-box { border-top: 1px solid var(--bs-border-color); background: rgba(var(--bs-success-rgb), .04); }
.advance-head { padding: .75rem 1rem .5rem; font-weight: 600; }
.advance-box .table { --bs-table-bg: transparent; }
.advance-box td:first-child { padding-left: 1rem; }
.advance-box td:last-child { padding-right: 1rem; }
