/* ==========================================================================
   Hostel finance theme (Bootstrap 5.3 overrides)
   ========================================================================== */

:root {
    --app-sidebar-w: 260px;
    --app-sidebar-bg: #0f172a;
    --app-sidebar-fg: #cbd5e1;
    --app-sidebar-muted: #64748b;
    --app-sidebar-active: #1e293b;
    --app-bg: #f3f5f9;
    --app-surface: #ffffff;
    --app-border: #e5e8ef;
    --app-text: #1e293b;
    --app-muted: #64748b;
    --app-primary: #2563eb;
    --app-primary-soft: #e8efff;
    --app-success: #059669;
    --app-success-soft: #e6f6f0;
    --app-danger: #dc2626;
    --app-danger-soft: #fdecec;
    --app-warning: #d97706;
    --app-warning-soft: #fdf3e3;
    --app-info: #0891b2;
    --app-info-soft: #e3f5f9;
    --app-radius: 14px;
    --app-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 2px 8px rgba(15, 23, 42, .04);

    --bs-primary: var(--app-primary);
    --bs-primary-rgb: 37, 99, 235;
    --bs-body-bg: var(--app-bg);
    --bs-body-color: var(--app-text);
    --bs-border-color: var(--app-border);
    --bs-body-font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --bs-body-font-size: .925rem;
    --bs-link-color: var(--app-primary);
    --bs-link-color-rgb: 37, 99, 235;
}

body { background: var(--app-bg); color: var(--app-text); -webkit-font-smoothing: antialiased; }

.btn-primary {
    --bs-btn-bg: var(--app-primary); --bs-btn-border-color: var(--app-primary);
    --bs-btn-hover-bg: #1d4ed8; --bs-btn-hover-border-color: #1d4ed8;
    --bs-btn-active-bg: #1e40af; --bs-btn-active-border-color: #1e40af;
}
.btn { border-radius: 9px; font-weight: 500; }
.btn-sm { border-radius: 7px; }
.btn-soft { background: var(--app-primary-soft); color: var(--app-primary); border: 0; }
.btn-soft:hover { background: #d9e5ff; color: #1d4ed8; }
.btn-light { background: #fff; border-color: var(--app-border); }
.btn-light:hover { background: #f8fafc; border-color: #d6dbe5; }
.btn-icon { width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }

.form-control, .form-select { border-radius: 9px; border-color: #dbe0e8; }
.form-control:focus, .form-select:focus { border-color: #93b4f8; box-shadow: 0 0 0 .2rem rgba(37, 99, 235, .12); }
.form-label { font-weight: 500; font-size: .85rem; color: #334155; margin-bottom: .3rem; }
.input-group-text { background: #f8fafc; border-color: #dbe0e8; color: var(--app-muted); }
.form-text { color: var(--app-muted); }

/* --------------------------------------------------------------------------
   Shell
   -------------------------------------------------------------------------- */

.app-shell { min-height: 100vh; }

.app-sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--app-sidebar-w);
    background: var(--app-sidebar-bg); color: var(--app-sidebar-fg);
    display: flex; flex-direction: column; z-index: 1040;
}
.app-sidebar .brand {
    display: flex; align-items: center; gap: .7rem; padding: 1.15rem 1.25rem;
    color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.app-sidebar .brand-mark {
    width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
    background: linear-gradient(135deg, #3b82f6, #6366f1); color: #fff; font-size: 1.1rem;
}
.app-sidebar .brand-name { font-weight: 700; letter-spacing: .02em; line-height: 1.1; }
.app-sidebar .brand-sub { font-size: .72rem; color: var(--app-sidebar-muted); }

.app-nav { flex: 1; overflow-y: auto; padding: .5rem .75rem 1rem; }
.app-nav .nav-section {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .09em;
    color: var(--app-sidebar-muted); padding: .75rem .75rem .3rem; font-weight: 600;
}
.app-nav a {
    display: flex; align-items: center; gap: .7rem; padding: .4rem .75rem; border-radius: 9px;
    color: var(--app-sidebar-fg); text-decoration: none; font-size: .9rem; margin-bottom: 2px;
}
.app-nav a i { font-size: 1.05rem; opacity: .85; width: 1.2rem; text-align: center; }
.app-nav a:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.app-nav a.active { background: var(--app-sidebar-active); color: #fff; box-shadow: inset 3px 0 0 #3b82f6; }
.app-nav a .badge { margin-left: auto; }

.app-sidebar .sidebar-foot { padding: .9rem 1.25rem; border-top: 1px solid rgba(255, 255, 255, .06); font-size: .75rem; color: var(--app-sidebar-muted); }
.app-sidebar .sidebar-foot a { color: #93c5fd; text-decoration: none; }

.app-main { margin-left: var(--app-sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

.app-topbar {
    position: sticky; top: 0; z-index: 1030; height: 60px;
    display: flex; align-items: center; gap: .75rem; padding: 0 1.5rem;
    background: rgba(243, 245, 249, .85); backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--app-border);
}
.app-topbar .crumb { color: var(--app-muted); font-size: .85rem; }
.app-topbar .crumb strong { color: var(--app-text); font-weight: 600; }

.app-content { padding: 1.5rem; flex: 1; }
.app-footer { padding: 1rem 1.5rem; color: var(--app-muted); font-size: .78rem; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

.avatar {
    width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center;
    background: var(--app-primary-soft); color: var(--app-primary); font-weight: 600; font-size: .8rem; flex-shrink: 0;
}
.avatar-lg { width: 44px; height: 44px; font-size: .95rem; }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }

.sidebar-backdrop { display: none; }

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    .app-shell.sidebar-open .app-sidebar { transform: none; }
    .app-shell.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 1035; }
    .app-main { margin-left: 0; }
    .app-content { padding: 1rem; }
    .app-topbar { padding: 0 1rem; }
}

/* --------------------------------------------------------------------------
   Page header
   -------------------------------------------------------------------------- */

.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-header h1 { font-size: 1.45rem; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.page-header .subtitle { color: var(--app-muted); margin: .2rem 0 0; font-size: .9rem; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */

.card { border: 1px solid var(--app-border); border-radius: var(--app-radius); box-shadow: var(--app-shadow); background: var(--app-surface); }
.card-header {
    background: transparent; border-bottom: 1px solid var(--app-border); padding: .9rem 1.15rem;
    display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
}
.card-header:first-child { border-radius: var(--app-radius) var(--app-radius) 0 0; }
.card-title { font-size: .98rem; font-weight: 600; margin: 0; }
.card-subtitle { font-size: .8rem; color: var(--app-muted); }
.card-body { padding: 1.15rem; }
.card-footer { background: #fafbfd; border-top: 1px solid var(--app-border); }

/* KPI tiles */
.stat { display: flex; gap: .9rem; align-items: flex-start; height: 100%; }
.stat-icon { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; font-size: 1.2rem; flex-shrink: 0; }
.stat-label { font-size: .78rem; color: var(--app-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: .7rem; font-weight: 600; color: var(--app-muted); margin-right: .2rem; letter-spacing: 0; }
.stat-meta { font-size: .78rem; color: var(--app-muted); margin-top: .15rem; }

.tone-primary { background: var(--app-primary-soft); color: var(--app-primary); }
.tone-success { background: var(--app-success-soft); color: var(--app-success); }
.tone-danger { background: var(--app-danger-soft); color: var(--app-danger); }
.tone-warning { background: var(--app-warning-soft); color: var(--app-warning); }
.tone-info { background: var(--app-info-soft); color: var(--app-info); }
.tone-muted { background: #eef1f5; color: #475569; }

.trend { font-size: .75rem; font-weight: 600; padding: .1rem .4rem; border-radius: 6px; }
.trend-up { background: var(--app-success-soft); color: var(--app-success); }
.trend-down { background: var(--app-danger-soft); color: var(--app-danger); }
.trend-flat { background: #eef1f5; color: #64748b; }
.trend-up.inverse { background: var(--app-danger-soft); color: var(--app-danger); }
.trend-down.inverse { background: var(--app-success-soft); color: var(--app-success); }

.text-income { color: var(--app-success) !important; }
.text-expense { color: var(--app-danger) !important; }

/* --------------------------------------------------------------------------
   Filter bar
   -------------------------------------------------------------------------- */

.filter-bar { margin-bottom: 1.25rem; }
.filter-bar .card-body { padding: .9rem 1.15rem; }
.filter-bar .form-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--app-muted); }
.filter-bar .range-label { font-size: .82rem; color: var(--app-muted); }
.filter-bar .range-label strong { color: var(--app-text); }
.filter-chip { display: inline-flex; align-items: center; gap: .35rem; background: var(--app-primary-soft); color: var(--app-primary); border-radius: 999px; padding: .15rem .6rem; font-size: .78rem; font-weight: 500; }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */

.table { --bs-table-bg: transparent; margin-bottom: 0; font-size: .875rem; }
.table > :not(caption) > * > * { padding: .6rem .85rem; border-bottom-color: #eef0f4; }
.table thead th {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--app-muted);
    font-weight: 600; background: #f8fafc; border-bottom: 1px solid var(--app-border); white-space: nowrap;
}
.table tbody tr:hover > * { background: #f8fafd; }
.table tfoot th, .table tfoot td { background: #f8fafc; font-weight: 700; border-top: 1px solid var(--app-border); }
.table .num, .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; width: 1%; }
.table-card .card-body { padding: 0; }
.table-card .dt-container { padding: .75rem 1rem 1rem; }
.cell-sub { display: block; font-size: .76rem; color: var(--app-muted); }
.cell-clip { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* DataTables 2 */
div.dt-container .dt-search input { border-radius: 9px; border-color: #dbe0e8; min-width: 220px; }
div.dt-container .dt-length select { border-radius: 8px; }
div.dt-container div.dt-layout-row { margin: .5rem 0; }
div.dt-container .dt-paging .page-link { border-radius: 8px !important; margin: 0 2px; border: 0; color: var(--app-text); }
div.dt-container .dt-paging .page-item.active .page-link { background: var(--app-primary); color: #fff; }
div.dt-container .dt-info { color: var(--app-muted); font-size: .8rem; }
div.dt-buttons > .btn { border-radius: 8px !important; margin-right: .3rem; }
table.dataTable thead > tr > th.dt-orderable-asc, table.dataTable thead > tr > th.dt-orderable-desc { padding-right: 26px; }
table.dataTable > tbody > tr > td.num, table.dataTable > thead > tr > th.num, table.dataTable > tfoot > tr > th.num { text-align: right; }

/* --------------------------------------------------------------------------
   Misc
   -------------------------------------------------------------------------- */

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--app-muted); }
.empty-state i { font-size: 2.2rem; color: #c3cad6; display: block; margin-bottom: .5rem; }
.empty-state h6 { color: var(--app-text); font-weight: 600; }

.alert { border-radius: 11px; border: 0; }
.alert-success { background: var(--app-success-soft); color: #065f46; }
.alert-danger { background: var(--app-danger-soft); color: #991b1b; }
.alert-warning { background: var(--app-warning-soft); color: #92400e; }

.badge-soft { font-weight: 600; padding: .3em .6em; border-radius: 6px; }

.progress-thin { height: 6px; border-radius: 6px; background: #eef1f5; }
.progress-thin .progress-bar { border-radius: 6px; }

.list-tight .list-group-item { padding: .7rem 1.15rem; border-color: #eef0f4; }

.report-card { transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease; text-decoration: none; color: inherit; display: block; height: 100%; }
.report-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(15, 23, 42, .08); border-color: #c7d5f5; color: inherit; }
.report-card .stat-icon { margin-bottom: .75rem; }
.report-card h6 { font-weight: 600; margin-bottom: .3rem; }
.report-card p { color: var(--app-muted); font-size: .84rem; margin: 0; }

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

.client-photo { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: #eef1f5; }

.form-section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--app-muted); font-weight: 600; margin-bottom: .75rem; }

.amount-input { font-size: 1.15rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Guest pages (login, licence) */
.guest-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.guest-art {
    background: radial-gradient(1200px 600px at 10% 10%, #1e3a8a 0%, #0f172a 55%);
    color: #e2e8f0; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
}
.guest-art h2 { color: #fff; font-weight: 700; font-size: 2rem; line-height: 1.2; max-width: 420px; }
.guest-art .feature { display: flex; gap: .75rem; align-items: flex-start; margin-bottom: 1rem; color: #cbd5e1; }
.guest-art .feature i { color: #93c5fd; font-size: 1.15rem; }
.guest-form { display: grid; place-items: center; padding: 2rem; background: #fff; }
.guest-form .inner { width: 100%; max-width: 380px; }
@media (max-width: 991.98px) { .guest-wrap { grid-template-columns: 1fr; } .guest-art { display: none; } .guest-form { background: var(--app-bg); } }

/* --------------------------------------------------------------------------
   Print
   -------------------------------------------------------------------------- */

.print-only { display: none; }
@media print {
    body { background: #fff; font-size: 11px; }
    .app-sidebar, .app-topbar, .app-footer, .filter-bar, .page-actions, .no-print,
    .dt-layout-row:not(.dt-layout-table), .actions, .btn { display: none !important; }
    .app-main { margin: 0; }
    .app-content { padding: 0; }
    .card { box-shadow: none; border-color: #ddd; break-inside: avoid; }
    .print-only { display: block; }
    a { color: inherit; text-decoration: none; }
    .chart-box { height: 220px; }
}
