/* ============================================================
   Asset Manager — Main Stylesheet
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --sidebar-bg:     #0f172a;
    --sidebar-hover:  rgba(255,255,255,0.05);
    --sidebar-active: rgba(59,130,246,0.15);
    --accent:         #3b82f6;
    --accent-dark:    #1d4ed8;
    --body-bg:        #f1f5f9;
    --card-bg:        #ffffff;
    --border:         #e2e8f0;
    --text-primary:   #1e293b;
    --text-secondary: #64748b;
    --text-muted:     #94a3b8;
    --success:        #059669;
    --danger:         #dc2626;
    --warning:        #d97706;
    --info:           #0891b2;
    --sidebar-width:  260px;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--body-bg);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    min-width: 320px;
    overflow-x: hidden;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

/* ================================================================
   LAYOUT
   ================================================================ */
.wrapper { display: flex; min-height: 100vh; width: 100%; }

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    transition: transform .3s ease;
    overflow: hidden;
}

.sidebar-brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}
.sidebar-brand .brand-icon {
    width: 40px; height: 40px;
    background: var(--accent);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; color: #fff;
    flex-shrink: 0;
}
.sidebar-brand .brand-name {
    font-size: 16px; font-weight: 700; color: #fff; line-height: 1.2;
}
.sidebar-brand .brand-sub {
    font-size: 10px; color: #64748b; text-transform: uppercase; letter-spacing: .06em;
}

.sidebar-nav {
    list-style: none;
    padding: 12px 0;
    flex: 1;
    overflow-y: auto;
}
.nav-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: #475569;
    padding: 12px 20px 4px;
}
.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 20px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: all .18s;
    border-left: 3px solid transparent;
    position: relative;
}
.sidebar-nav li a .nav-icon {
    width: 18px;
    text-align: center;
    font-size: 15px;
    flex-shrink: 0;
}
.sidebar-nav li a:hover {
    color: #e2e8f0;
    background: var(--sidebar-hover);
}
.sidebar-nav li.active > a {
    color: #93c5fd;
    background: var(--sidebar-active);
    border-left-color: var(--accent);
}

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid rgba(255,255,255,.06);
    display: flex;
    align-items: center;
    gap: 10px;
}
.user-avatar {
    width: 34px; height: 34px;
    background: var(--accent);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; color: #fff; font-size: 13px;
    flex-shrink: 0;
}
.user-meta { flex: 1; min-width: 0; }
.user-meta .u-name { font-size: 13px; font-weight: 600; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta .u-role { font-size: 11px; color: #64748b; }
.btn-logout {
    color: #64748b; font-size: 16px; text-decoration: none;
    transition: color .2s; flex-shrink: 0;
}
.btn-logout:hover { color: #ef4444; }

/* ── Main Content ── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: #fff;
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.sidebar-toggle {
    background: none; border: none;
    color: var(--text-secondary); font-size: 18px;
    cursor: pointer; padding: 4px; display: none;
}
.page-heading { font-size: 18px; font-weight: 700; color: var(--text-primary); flex: 1; }
.topbar-meta { font-size: 12px; color: var(--text-muted); }

.content-area { padding: 24px; }

/* ── Overlay ── */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 199;
}

/* ================================================================
   CARDS
   ================================================================ */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.card-header h5, .card-header h6 { margin: 0; font-weight: 700; font-size: 14px; color: var(--text-primary); }
.card-body { padding: 20px; }

/* ── Stat Cards ── */
.stat-card {
    border-radius: 14px;
    padding: 22px 20px;
    color: #fff;
    position: relative;
    overflow: hidden;
}
.stat-card::after {
    content: '';
    position: absolute;
    right: -20px; top: -20px;
    width: 100px; height: 100px;
    border-radius: 50%;
    background: rgba(255,255,255,.08);
}
.stat-card .sc-icon {
    font-size: 30px; opacity: .35;
    position: absolute; right: 20px; top: 50%;
    transform: translateY(-50%);
}
.stat-card .sc-label { font-size: 12px; font-weight: 600; opacity: .85; text-transform: uppercase; letter-spacing: .04em; }
.stat-card .sc-value { font-size: 26px; font-weight: 800; margin-top: 6px; }
.stat-card .sc-sub { font-size: 11px; opacity: .7; margin-top: 4px; }
.sc-blue   { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.sc-green  { background: linear-gradient(135deg, #059669, #047857); }
.sc-purple { background: linear-gradient(135deg, #7c3aed, #6d28d9); }
.sc-amber  { background: linear-gradient(135deg, #d97706, #b45309); }
.sc-red    { background: linear-gradient(135deg, #dc2626, #b91c1c); }
.sc-teal   { background: linear-gradient(135deg, #0891b2, #0e7490); }

/* ── Account Cards ── */
.account-card {
    transition: transform .2s, box-shadow .2s;
    cursor: default;
}
.account-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,.1);
}
.acct-icon {
    width: 42px; height: 42px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.acct-icon.bank           { background: #eff6ff; color: #2563eb; }
.acct-icon.cash           { background: #f0fdf4; color: #16a34a; }
.acct-icon.mobile_banking { background: #faf5ff; color: #7c3aed; }
.acct-icon.crypto         { background: #fff7ed; color: #d97706; }
.acct-icon.receivable     { background: #ecfdf5; color: #0891b2; }
.acct-icon.other          { background: #f8fafc; color: #64748b; }
.acct-balance { font-size: 22px; font-weight: 800; color: var(--text-primary); }
.acct-name    { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.acct-type    { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }

/* ================================================================
   TABLES
   ================================================================ */
.table-responsive { border-radius: 0 0 12px 12px; }
.table { margin: 0; }
.table thead th {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-secondary);
    background: #f8fafc;
    border-bottom: 2px solid var(--border);
    padding: 12px 16px;
    white-space: nowrap;
}
.table tbody td {
    padding: 13px 16px;
    vertical-align: middle;
    font-size: 13.5px;
    border-bottom: 1px solid #f8fafc;
    color: var(--text-primary);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #fafbff; }

/* ================================================================
   BADGES
   ================================================================ */
.badge {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    text-transform: capitalize;
    letter-spacing: .02em;
}

/* ── Status badges ── */
.status-active    { background: #dcfce7; color: #15803d; }
.status-matured   { background: #fef3c7; color: #92400e; }
.status-renewed   { background: #dbeafe; color: #1d4ed8; }
.status-withdrawn { background: #f1f5f9; color: #475569; }

/* ── Transaction type badges ── */
.tx-deposit     { background: #dcfce7; color: #15803d; }
.tx-withdrawal  { background: #fee2e2; color: #b91c1c; }
.tx-investment  { background: #dbeafe; color: #1d4ed8; }
.tx-profit      { background: #ecfdf5; color: #059669; }
.tx-transfer_in  { background: #e0f2fe; color: #0369a1; }
.tx-transfer_out { background: #fef3c7; color: #92400e; }
.tx-renewal     { background: #f0f9ff; color: #0284c7; }

/* ================================================================
   ACTION BUTTONS
   ================================================================ */
.btn-act {
    width: 30px; height: 30px;
    border: none; border-radius: 7px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px; cursor: pointer;
    transition: all .18s;
    text-decoration: none;
}
.btn-act:hover { filter: brightness(.88); transform: scale(1.08); }
.btn-view     { background: #eff6ff; color: #2563eb; }
.btn-edit     { background: #f0fdf4; color: #16a34a; }
.btn-delete   { background: #fef2f2; color: #dc2626; }
.btn-renew    { background: #fefce8; color: #ca8a04; }
.btn-withdraw { background: #fff7ed; color: #c2410c; }
.btn-addmoney { background: #f0fdf4; color: #16a34a; }


.report-chart {
    position: relative;
    height: 260px;
    width: 100%;
}
.report-table-wrap {
    overflow-x: visible;
}
.report-table {
    min-width: 0;
    table-layout: fixed;
}
.report-table th,
.report-table td {
    white-space: normal;
    overflow-wrap: anywhere;
    padding: 8px 7px;
    font-size: 12px;
    line-height: 1.25;
}
.report-table thead th {
    font-size: 9.5px;
    padding: 8px 7px;
}
.report-table .amount-neutral,
.report-table .amount-pos,
.report-table .amount-neg {
    font-size: 11.5px;
    font-weight: 700;
}
.report-table .badge {
    font-size: 10px;
    padding: 4px 6px;
}

.report-account-table th:nth-child(1),
.report-account-table td:nth-child(1) { width: 34%; }
.report-account-table th:nth-child(2),
.report-account-table td:nth-child(2),
.report-account-table th:nth-child(3),
.report-account-table td:nth-child(3),
.report-account-table th:nth-child(4),
.report-account-table td:nth-child(4) { width: 22%; }

.report-category-table th:nth-child(1),
.report-category-table td:nth-child(1) { width: 34%; }
.report-category-table th:nth-child(2),
.report-category-table td:nth-child(2) { width: 14%; text-align: center; }
.report-category-table th:nth-child(3),
.report-category-table td:nth-child(3),
.report-category-table th:nth-child(4),
.report-category-table td:nth-child(4) { width: 26%; }

.report-profit-table th:nth-child(1),
.report-profit-table td:nth-child(1) { width: 48%; }
.report-profit-table th:nth-child(2),
.report-profit-table td:nth-child(2) { width: 52%; }

.maintenance-action {
    width: 100%;
    max-width: 260px;
}

@media (max-width: 767.98px) {
    .maintenance-action {
        max-width: none;
    }
}

/* ================================================================
   FORMS & MODALS
   ================================================================ */
.form-label { font-size: 12px; font-weight: 700; color: #374151; margin-bottom: 5px; text-transform: uppercase; letter-spacing: .04em; }
.form-control, .form-select {
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13.5px;
    padding: 9px 12px;
    transition: border-color .2s, box-shadow .2s;
    background: #fff;
}
.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,.12);
    outline: none;
}
.form-control::placeholder { color: #c0c8d4; }

.modal-header {
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
}
.modal-title { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); background: #fafbff; }
.modal-content { border-radius: 14px; border: 1px solid var(--border); box-shadow: 0 20px 60px rgba(0,0,0,.15); }

/* ================================================================
   AMOUNTS & NUMBERS
   ================================================================ */
.amount-pos { color: #16a34a; font-weight: 700; }
.amount-neg { color: #dc2626; font-weight: 700; }
.amount-neutral { color: var(--text-primary); font-weight: 600; }
.fw-700 { font-weight: 700; }
.fw-600 { font-weight: 600; }
.fs-13  { font-size: 13px; }

/* ================================================================
   MATURITY BADGES
   ================================================================ */
.maturity-badge {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11px; font-weight: 600; padding: 3px 9px;
    border-radius: 12px;
}
.maturity-badge.overdue { background: #fee2e2; color: #b91c1c; }
.maturity-badge.soon    { background: #fef3c7; color: #92400e; }
.maturity-badge.ok      { background: #dcfce7; color: #15803d; }

/* ================================================================
   MISCELLANEOUS
   ================================================================ */
.empty-state {
    text-align: center;
    padding: 56px 20px;
    color: var(--text-muted);
}
.empty-state .es-icon { font-size: 52px; margin-bottom: 14px; opacity: .4; }
.empty-state p { font-size: 14px; }

.page-actions { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; justify-content: space-between; }
.page-actions h2 { font-size: 20px; font-weight: 800; margin: 0; }
.page-actions .sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.section-divider { border-top: 1px solid var(--border); margin: 20px 0; }

/* Alert toast area */
.toast-area { position: fixed; top: 20px; right: 20px; z-index: 9999; min-width: 280px; }

/* ── Investment detail rows ── */
.detail-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #f1f5f9; font-size: 13.5px; }
.detail-row:last-child { border-bottom: none; }
.detail-row .label { color: var(--text-muted); }
.detail-row .value { font-weight: 600; color: var(--text-primary); }

/* ── Filter bar ── */
.filter-bar {
    display: flex; gap: 10px; flex-wrap: wrap;
    padding: 14px 16px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}
.filter-bar .form-control,
.filter-bar .form-select { font-size: 13px; padding: 7px 11px; max-width: 180px; }

/* ================================================================
   LOGIN PAGE
   ================================================================ */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.login-card {
    width: 100%; max-width: 400px;
    background: rgba(255,255,255,.97);
    border-radius: 20px;
    box-shadow: 0 25px 80px rgba(0,0,0,.4);
    overflow: hidden;
}
.login-card-top {
    background: linear-gradient(135deg, #1d4ed8, #3b82f6);
    padding: 32px 32px 28px;
    text-align: center;
    color: #fff;
}
.login-logo-icon {
    width: 60px; height: 60px;
    background: rgba(255,255,255,.18);
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px;
    margin: 0 auto 14px;
}
.login-card-top h1 { font-size: 22px; font-weight: 800; margin: 0 0 4px; }
.login-card-top p  { font-size: 13px; opacity: .8; margin: 0; }
.login-card-body { padding: 32px; }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .sidebar-toggle { display: block !important; }
    .sidebar-overlay.show { display: block; }
    .content-area { padding: 16px; }
}
@media (max-width: 576px) {
    .stat-card .sc-value { font-size: 20px; }
    .page-actions { flex-direction: column; align-items: flex-start; }
}


/* Mobile stability overrides */
.main-content { min-width: 0; }
.content-area { width: 100%; min-width: 0; }
.card { min-width: 0; }
.stat-card .sc-value { line-height: 1.15; overflow-wrap: anywhere; padding-right: 42px; }
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { min-width: 760px; }
.report-table-wrap {
    overflow-x: visible;
}
.report-table-wrap .report-table {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    table-layout: fixed;
}
.report-table-wrap .report-table th,
.report-table-wrap .report-table td {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

@media (max-width: 992px) {
    .sidebar { width: min(var(--sidebar-width), 86vw); }
}

@media (max-width: 768px) {
    .topbar { height: 56px; padding: 0 14px; }
    .sidebar-toggle {
        width: 38px; height: 38px; border-radius: 8px;
        background: #f8fafc; border: 1px solid var(--border); flex-shrink: 0;
    }
    .page-heading {
        font-size: 16px; min-width: 0; overflow: hidden;
        text-overflow: ellipsis; white-space: nowrap;
    }
    .content-area { padding: 14px; }
    .card { border-radius: 10px; }
    .card-header { padding: 14px; align-items: flex-start; flex-direction: column; }
    .card-header > .btn, .card-header > a.btn { width: 100%; }
    .card-header > .btn-card-action { width: auto; align-self: flex-start; }
    .card-body { padding: 14px; }
    .stat-card { border-radius: 10px; padding: 16px 14px; min-height: 118px; }
    .stat-card::after { width: 78px; height: 78px; right: -26px; top: -20px; }
    .stat-card .sc-icon { right: 12px; font-size: 22px; opacity: .22; }
    .stat-card .sc-label { font-size: 10px; line-height: 1.25; }
    .stat-card .sc-value { font-size: 18px; padding-right: 28px; }
    .acct-balance { font-size: 19px; overflow-wrap: anywhere; }
    .account-card:hover { transform: none; }
    .page-actions { margin-bottom: 14px; gap: 12px; }
    .page-actions > div, .page-actions > .btn, .page-actions > button { width: 100%; }
    .page-actions .btn, .page-actions button { justify-content: center; }
    .filter-bar { padding: 12px; }
    .filter-bar form, .card-header form { gap: 8px !important; }
    .filter-bar .form-control,
    .filter-bar .form-select,
    .filter-bar select,
    .card-header .form-select,
    .card-header form,
    .card-header form select,
    .card-header form .btn {
        width: 100% !important; max-width: none !important; min-width: 0 !important;
    }
    .filter-bar .btn, .card-header .btn { min-height: 36px; }
    .filter-bar .ms-auto, .card-header .ms-auto { margin-left: 0 !important; }
    .table-responsive { border-radius: 0 0 10px 10px; }
    .report-chart { height: 220px; }
    .report-table th, .report-table td { padding: 7px 5px; font-size: 11px; }
    .report-table thead th { font-size: 9px; padding: 7px 5px; }
    .report-table .amount-neutral, .report-table .amount-pos, .report-table .amount-neg { font-size: 10.5px; }
    .report-table .badge { white-space: normal; }
    .table thead th { padding: 10px 12px; font-size: 10px; }
    .table tbody td { padding: 11px 12px; font-size: 13px; }
    .btn-act { width: 34px; height: 34px; }
    .modal-dialog { margin: 10px; }
    .modal-content { max-height: calc(100vh - 20px); }
    .modal-body { padding: 16px; overflow-y: auto; }
    .modal-footer { padding: 12px 16px; flex-wrap: nowrap; }
    .toast-area { left: 12px; right: 12px; top: 12px; min-width: 0; }
    .toast-area .alert { min-width: 0 !important; width: 100%; }
}

@media (max-width: 576px) {
    .content-area { padding: 12px; }
    .report-chart { height: 200px; }
    .report-optional-sm { display: none; }
    .row.g-3 { --bs-gutter-x: .75rem; --bs-gutter-y: .75rem; }
    .stat-card { padding: 14px 12px; min-height: 112px; }
    .stat-card .sc-value { font-size: 16px; }
    .stat-card .sc-sub { font-size: 10px; }
    .page-actions h2 { font-size: 18px; }
    .empty-state { padding: 34px 14px; }
    .empty-state .es-icon { font-size: 40px; }
    .login-card-body { padding: 24px; }
    .login-card-top { padding: 26px 24px 22px; }
}

@media (max-width: 400px) {
    .stat-card .sc-value { font-size: 14px; padding-right: 18px; }
    .stat-card .sc-icon { display: none; }
    .modal-footer { flex-direction: column-reverse; align-items: stretch; }
    .modal-footer .btn { width: 100%; }
}
