/**
 * START.AI Property Finance Management Stylesheet (finance.css)
 * Version: 01.00.00
 * Performance-First, Responsive & High-Contrast Financial Interface
 */

/* Container & Typography */
.finance-app-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #2c3e50;
    background-color: #f8fafc;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    padding: 20px;
    margin: 10px 0;
}

/* Header & Roles */
.finance-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: #ffffff;
    padding: 18px 24px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.header-branding {
    display: flex;
    align-items: center;
    gap: 15px;
}

.branding-badge {
    background: #3b82f6;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    padding: 4px 8px;
    border-radius: 4px;
}

.branding-text h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #ffffff;
}

.branding-text .subtitle {
    margin: 3px 0 0;
    font-size: 13px;
    color: #94a3b8;
}

.header-user-status {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-chip {
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 12px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.badge {
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
}

.badge-admin { background: #8b5cf6; color: #fff; }
.badge-checker { background: #f59e0b; color: #fff; }
.badge-maker { background: #3b82f6; color: #fff; }

/* Navigation Tabs */
.finance-nav-tabs {
    display: flex;
    gap: 6px;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 20px;
}

.nav-tab-item {
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.nav-tab-item:hover {
    color: #1e293b;
    background: #f1f5f9;
    border-radius: 6px 6px 0 0;
}

.nav-tab-item.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
    background: #ffffff;
}

/* Tab Panels */
.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    animation: fadeIn 0.25s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* KPI Cards Grid */
.finance-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: transform 0.15s, box-shadow 0.15s;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.kpi-revenue .kpi-icon { background: #ecfdf5; color: #10b981; }
.kpi-disbursement .kpi-icon { background: #fef2f2; color: #ef4444; }
.kpi-balance .kpi-icon { background: #eff6ff; color: #3b82f6; }
.kpi-receivables .kpi-icon { background: #fffbeb; color: #f59e0b; }
.kpi-pending .kpi-icon { background: #fdf2f8; color: #ec4899; }

.kpi-info {
    flex: 1;
}

.kpi-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 4px;
}

.kpi-value {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
}

.kpi-subtext {
    display: block;
    font-size: 11px;
    color: #94a3b8;
    margin-top: 3px;
}

/* Skeleton loader */
.skeleton-text {
    display: inline-block;
    position: relative;
    overflow: hidden;
    background-color: #e2e8f0;
    color: transparent !important;
    border-radius: 4px;
    min-width: 120px;
}

.skeleton-text::after {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    transform: translateX(-100%);
    background-image: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0,
        rgba(255, 255, 255, 0.5) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    animation: shimmer 1.5s infinite;
    content: '';
}

@keyframes shimmer {
    100% { transform: translateX(100%); }
}

/* Analytics Grid */
.dashboard-analytics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 900px) {
    .dashboard-analytics-grid {
        grid-template-columns: 1fr;
    }
}

.analytics-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 18px;
}

.analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.analytics-header h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
}

/* Cashflow Visual Bars */
.cashflow-bars {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.cashflow-bar-group .bar-title {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 4px;
}

.bar-track {
    background: #f1f5f9;
    border-radius: 6px;
    height: 14px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.bar-inflow { background: #10b981; }
.bar-outflow { background: #ef4444; }
.bar-net { background: #3b82f6; }

.bar-val {
    font-size: 12px;
    font-weight: 700;
    color: #1e293b;
    text-align: right;
    margin-top: 3px;
}

/* Debt Aging Grid */
.debt-aging-box {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.aging-item {
    padding: 12px;
    border-radius: 6px;
    border-left: 4px solid transparent;
}

.aging-current { background: #f0fdf4; border-color: #22c55e; }
.aging-warning { background: #fefce8; border-color: #eab308; }
.aging-danger { background: #fff7ed; border-color: #f97316; }
.aging-critical { background: #fef2f2; border-color: #ef4444; }

.aging-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
}

.aging-value {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
    margin-top: 4px;
}

/* Toolbars */
.panel-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.toolbar-search {
    position: relative;
    flex: 1;
    min-width: 250px;
}

.toolbar-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
}

.toolbar-search input {
    padding-left: 34px !important;
}

.toolbar-filters {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Dual Control Banner */
.dual-control-banner {
    display: flex;
    gap: 14px;
    align-items: center;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 16px;
}

.dual-control-banner .banner-icon {
    color: #d97706;
}

.dual-control-banner h5 {
    margin: 0 0 3px 0;
    font-size: 14px;
    font-weight: 700;
    color: #92400e;
}

.dual-control-banner p {
    margin: 0;
    font-size: 12px;
    color: #78350f;
}

/* Tables */
.table-responsive-wrapper {
    overflow-x: auto;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.finance-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}

.finance-table th {
    background: #f8fafc;
    color: #475569;
    font-weight: 600;
    padding: 10px 14px;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}

.finance-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
    color: #1e293b;
    vertical-align: middle;
}

.finance-table tr:hover td {
    background: #f8fafc;
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 12px;
    text-align: center;
}

.status-draft { background: #f1f5f9; color: #475569; }
.status-pendingapproval { background: #fef3c7; color: #b45309; }
.status-approved { background: #dbeafe; color: #1d4ed8; }
.status-posted { background: #d1fae5; color: #047857; }
.status-voided { background: #fee2e2; color: #b91c1c; }
.status-stornoreversed { background: #f3e8ff; color: #7e22ce; }
.status-active { background: #dbeafe; color: #1d4ed8; }
.status-paid { background: #d1fae5; color: #047857; }
.status-cancelled { background: #f1f5f9; color: #64748b; }

/* Pagination */
.pagination-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 6px;
    font-size: 13px;
    color: #64748b;
}

.pagination-buttons {
    display: flex;
    gap: 8px;
}

/* Ledger Summary */
.ledger-balance-summary-card {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
}

.balance-metric .metric-title {
    display: block;
    font-size: 12px;
    color: #64748b;
    margin-bottom: 4px;
}

.balance-metric strong {
    font-size: 18px;
    font-weight: 700;
}

.metric-debit { color: #10b981; }
.metric-credit { color: #ef4444; }
.metric-balance { color: #2563eb; }

/* CashBook & Bank layout */
.cash-bank-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 900px) {
    .cash-bank-layout {
        grid-template-columns: 1fr;
    }
}

.cash-register-panel, .bank-accounts-panel {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 18px;
}

.panel-box-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 12px;
    margin-bottom: 15px;
}

.panel-box-header h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
}

.cashbook-date-selector {
    display: flex;
    gap: 8px;
    align-items: center;
}

.cashbook-metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.cb-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 12px;
}

.cb-card.cb-inflow strong { color: #10b981; }
.cb-card.cb-outflow strong { color: #ef4444; }
.cb-card.cb-closing strong { color: #2563eb; }

.cb-title {
    display: block;
    font-size: 11px;
    color: #64748b;
}

.cb-val {
    display: block;
    font-size: 16px;
    font-weight: 700;
    margin-top: 4px;
}

/* Modals */
.finance-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1050;
    overflow-y: auto;
}

.finance-modal.show {
    display: block;
}

.modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    z-index: 1040;
}

.modal-dialog {
    position: relative;
    z-index: 1050;
    max-width: 600px;
    margin: 40px auto;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.modal-dialog.modal-lg {
    max-width: 850px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.modal-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
}

.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    color: #94a3b8;
    cursor: pointer;
}

.modal-close:hover {
    color: #0f172a;
}

.modal-body {
    padding: 20px;
    max-height: 75vh;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 20px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

/* Forms */
.form-row {
    display: flex;
    gap: 14px;
    margin-bottom: 12px;
}

.form-group {
    margin-bottom: 12px;
    flex: 1;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 4px;
}

.form-group label.required::after {
    content: " *";
    color: #ef4444;
}

.form-control {
    width: 100%;
    padding: 7px 10px;
    font-size: 13px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    box-sizing: border-box;
}

.form-control:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
}

.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: #64748b; color: #fff; }
.btn-secondary:hover { background: #475569; }
.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline-primary { border-color: #2563eb; color: #2563eb; background: transparent; }
.btn-outline-primary:hover { background: #2563eb; color: #fff; }
.btn-outline-secondary { border-color: #cbd5e1; color: #475569; background: transparent; }
.btn-outline-secondary:hover { background: #f1f5f9; }
.btn-outline-light { border-color: rgba(255, 255, 255, 0.3); color: #fff; background: transparent; }
.btn-outline-light:hover { background: rgba(255, 255, 255, 0.15); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-xs { padding: 2px 6px; font-size: 11px; }

/* Accounting line rows */
.section-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.section-title-row h6 {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
}

.idempotency-badge {
    margin-top: 10px;
    padding: 6px 10px;
    background: #f1f5f9;
    border-radius: 4px;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.finance-toast {
    min-width: 280px;
    padding: 12px 16px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.25s ease-out;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast-success { background: #10b981; }
.toast-error { background: #ef4444; }
.toast-warning { background: #f59e0b; }
.toast-info { background: #3b82f6; }
