:root {
    --fin-primary: #0f766e;
    --fin-primary-soft: #0d9488;
    --fin-ink: #1e293b;
    --fin-muted: #64748b;
    --fin-line: #e8edf3;
    --fin-surface: #ffffff;
    --fin-radius: 10px;
}

html {
    font-size: 15.5px;
}

body.finance-app {
    background: #f6f8fb;
    color: var(--fin-ink);
    font-family: Tahoma, "Segoe UI", sans-serif;
    font-size: 0.95rem;
    line-height: 1.9;
}

main > .container {
    padding: 76px 15px 24px;
    max-width: 1180px;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: #0f172a;
}

h1 { font-size: 1.35rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1.08rem; }
h5 { font-size: 1.02rem; }
h6 { font-size: 0.96rem; }

.small, small {
    font-size: 0.85rem;
}

a {
    text-decoration: none;
    color: var(--fin-primary);
    transition: color 0.15s ease-in-out;
}

a:hover,
a:focus {
    text-decoration: none;
    color: var(--fin-primary-soft);
}

/* ---------- navbar ---------- */

.finance-nav {
    background: var(--fin-primary) !important;
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.06);
}

.finance-nav .navbar-brand {
    font-weight: 600;
    font-size: 1.02rem;
    letter-spacing: -0.01em;
}

.finance-nav .nav-link,
.finance-nav .navbar-brand {
    color: rgba(255, 255, 255, 0.82);
}

.finance-nav .nav-link {
    font-size: 0.9rem;
    padding: 0.35rem 0.6rem;
    border-radius: 8px;
}

.finance-nav .nav-link:hover,
.finance-nav .navbar-brand:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.finance-nav .nav-item.active > .nav-link,
.finance-nav .nav-link.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.16);
}

.logout {
    padding: 0.35rem 0.6rem;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.82);
}

.logout:hover {
    color: #fff;
}

.finance-footer {
    background: transparent;
    border-top: 1px solid var(--fin-line);
    font-size: 0.85rem;
}

.breadcrumb {
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

/* ---------- surfaces ---------- */

.stat-card,
.account-card,
.panel-card {
    background: var(--fin-surface);
    border: 1px solid var(--fin-line);
    border-radius: var(--fin-radius);
    padding: 0.9rem 1.05rem;
    box-shadow: none;
    height: 100%;
}

.panel-card {
    padding: 1.05rem 1.2rem;
}

.card {
    border: 1px solid var(--fin-line);
    border-radius: var(--fin-radius);
    box-shadow: none;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--fin-line);
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.7rem 1rem;
}

.card-body {
    padding: 1rem;
}

.stat-card .label {
    color: var(--fin-muted);
    font-size: 0.85rem;
    margin-bottom: 0.2rem;
}

.stat-card .value {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.stat-card.income .value { color: #15803d; }
.stat-card.expense .value { color: #b91c1c; }
.stat-card.balance .value { color: var(--fin-primary); }
.stat-card.receivable .value { color: #1d4ed8; }
.stat-card.payable .value { color: #c2410c; }
.stat-card.asset .value { color: #b45309; }
.stat-card.custody .value { color: #0f766e; }

.account-card {
    border-right: 3px solid var(--fin-primary);
}

.account-card .balance {
    font-size: 1.2rem;
    font-weight: 600;
    color: #0f172a;
    margin-top: 0.35rem;
}

.account-card .meta {
    color: var(--fin-muted);
    font-size: 0.85rem;
}

.page-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* ---------- assets ---------- */

.asset-type-card {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    height: 100%;
    padding: 0.75rem 0.9rem;
    background: var(--fin-surface);
    border: 1px solid var(--fin-line);
    border-radius: var(--fin-radius);
}

.asset-type-icon {
    color: #b45309;
    font-size: 1.15rem;
}

.asset-dashboard-card {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    height: 100%;
    padding: 0.75rem 0.9rem;
    color: var(--fin-ink);
    background: #fbfcfe;
    border: 1px solid var(--fin-line);
    border-right: 3px solid #d97706;
    border-radius: var(--fin-radius);
    transition: background 0.15s ease-in-out;
}

.asset-dashboard-card:hover {
    color: var(--fin-ink);
    background: #f2f6fa;
}

.asset-chart-wrap {
    position: relative;
    height: 260px;
}

.asset-history {
    max-height: 280px;
    overflow-y: auto;
}

/* ---------- forms ---------- */

.form-label,
.control-label {
    font-size: 0.88rem;
    font-weight: 500;
    color: #475569;
    margin-bottom: 0.25rem;
}

.form-control,
.form-select {
    font-size: 0.92rem;
    padding: 0.38rem 0.65rem;
    border-color: #dbe3ec;
    border-radius: 8px;
    color: var(--fin-ink);
    text-align: right;
}

/* Custom dropdown: the native option list renders blank in Chrome/Edge here,
   so the menu is drawn by the page while the select keeps the value. */
.select-ui {
    position: relative;
}

.select-ui-native {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: 0;
    opacity: 0;
    pointer-events: none;
}

.select-ui-toggle {
    width: 100%;
    padding-left: 2rem;
    text-align: right;
    background-color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.select-ui-toggle.is-placeholder {
    color: #94a3b8;
}

.select-ui-menu {
    display: none;
    /* Fixed so the menu is not clipped by the scrolling table wrapper. */
    position: fixed;
    z-index: 1080;
    top: 0;
    left: 0;
    min-width: 190px;
    padding: 0.3rem;
    background: #fff;
    border: 1px solid #dbe3ec;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.select-ui.is-open .select-ui-menu {
    display: block;
}

.select-ui-list {
    max-height: 260px;
    overflow-y: auto;
}

.select-ui-search {
    width: 100%;
    margin-bottom: 0.3rem;
    padding: 0.3rem 0.5rem;
    font-size: 0.85rem;
    border: 1px solid #dbe3ec;
    border-radius: 6px;
}

.select-ui-option {
    display: block;
    width: 100%;
    padding: 0.35rem 0.55rem;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--fin-ink);
    font-size: 0.9rem;
    text-align: right;
}

.select-ui-option:hover {
    background: #f1f5f9;
}

.select-ui-option.is-selected {
    background: var(--fin-primary);
    color: #fff;
}

.select-ui-option.is-disabled {
    color: #cbd5e1;
}

.form-control:focus,
.form-select:focus {
    border-color: #99d6cf;
    box-shadow: 0 0 0 0.15rem rgba(15, 118, 110, 0.12);
}

.form-text,
.hint-block {
    font-size: 0.82rem;
    color: var(--fin-muted);
}

.invalid-feedback,
.help-block {
    font-size: 0.82rem;
}

.input-group-text {
    font-size: 0.85rem;
    color: var(--fin-muted);
    background: #f4f7fa;
    border-color: #dbe3ec;
}

.money-input,
.jalali-date {
    font-variant-numeric: tabular-nums;
    text-align: right;
    direction: ltr;
    unicode-bidi: plaintext;
}

.form-group,
.mb-3 {
    margin-bottom: 0.9rem !important;
}

textarea.form-control {
    min-height: 72px;
    line-height: 1.8;
}

/* Single column forms read better as a narrow centered column on desktop.
   Forms carrying their own layout classes (grids, filter bars) are untouched. */
@media (min-width: 768px) {
    .panel-card > form:not([class]) {
        max-width: 460px;
        margin-inline: auto;
    }

    .auth-wrap .panel-card > form:not([class]) {
        max-width: none;
    }
}

.form-check-input {
    margin-left: -1.5em;
    margin-right: 0;
}

/* ---------- buttons ---------- */

.btn {
    font-size: 0.9rem;
    border-radius: 8px;
    padding: 0.38rem 0.8rem;
}

.btn-sm {
    font-size: 0.85rem;
    padding: 0.26rem 0.6rem;
}

.btn-primary {
    background-color: var(--fin-primary);
    border-color: var(--fin-primary);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--fin-primary-soft);
    border-color: var(--fin-primary-soft);
}

.btn-outline-primary {
    color: var(--fin-primary);
    border-color: #b9dbd7;
}

.btn-outline-primary:hover {
    background-color: var(--fin-primary);
    border-color: var(--fin-primary);
}

.btn-link {
    text-decoration: none;
}

.badge {
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.3em 0.6em;
    border-radius: 6px;
}

/* ---------- tables ---------- */

.table {
    font-size: 0.9rem;
    color: var(--fin-ink);
    margin-bottom: 0;
}

.table thead th {
    white-space: nowrap;
    color: var(--fin-muted);
    font-weight: 500;
    font-size: 0.85rem;
    background: #fafbfd;
    border-bottom: 1px solid var(--fin-line);
}

.table > :not(caption) > * > * {
    padding: 0.55rem 0.7rem;
    border-bottom-color: #f1f4f8;
}

.table > :not(caption) > * > *:not(:last-child) {
    border-inline-end: 1px solid #eef2f7;
}

.table thead th:not(:last-child) {
    border-inline-end-color: #e2e8f0;
}

.table-hover > tbody > tr:hover > * {
    background-color: #f8fafc;
}

.grid-view .filters .form-control,
.grid-view .filters .form-select {
    font-size: 0.85rem;
    padding: 0.22rem 0.45rem;
}

.grid-view .filters td {
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
}

.grid-view .filters .select-ui {
    min-width: 118px;
}

.grid-view .filters .select-ui-toggle {
    padding: 0.22rem 0.45rem 0.22rem 1.7rem;
    background-position: left 0.4rem center;
    background-size: 12px 9px;
}

.grid-view .filters .form-control::placeholder {
    color: #b6c1cf;
    font-size: 0.78rem;
}

.action-buttons a {
    margin-inline-start: 0.2rem;
}

.action-buttons a:first-child {
    margin-inline-start: 0;
}

.action-buttons .btn {
    line-height: 1;
    padding: 0.25rem 0.45rem;
}

.grid-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 0.9rem;
}

.grid-summary {
    color: var(--fin-muted);
    font-size: 0.85rem;
}

.pagination {
    font-size: 0.88rem;
    margin-bottom: 0;
}

.page-link {
    color: var(--fin-primary);
    border-color: var(--fin-line);
    padding: 0.25rem 0.6rem;
}

.page-item.active .page-link {
    background-color: var(--fin-primary);
    border-color: var(--fin-primary);
    color: #fff;
}

.detail-view {
    font-size: 0.9rem;
}

.detail-view th {
    width: 200px;
    color: var(--fin-muted);
    font-weight: 500;
    text-align: right;
    border-inline-end: 1px solid #eef2f7;
}

.badge-type-deposit { background: #dcfce7; color: #166534; }
.badge-type-withdraw { background: #fee2e2; color: #991b1b; }
.badge-type-transfer { background: #e0e7ff; color: #3730a3; }

/* ---------- misc ---------- */

.auth-wrap {
    max-width: 400px;
    margin: 2rem auto;
}

.auth-wrap .panel-card {
    padding: 1.5rem;
}

.chart-wrap {
    position: relative;
    height: 250px;
}

.month-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

.month-nav strong {
    min-width: 130px;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.3rem 0.9rem;
    max-height: 145px;
    overflow-y: auto;
    padding: 0.5rem 0.7rem;
    margin-bottom: 0.9rem;
    border: 1px solid var(--fin-line);
    border-radius: var(--fin-radius);
}

.chart-legend::-webkit-scrollbar {
    width: 6px;
}

.chart-legend::-webkit-scrollbar-track {
    background: #f4f7fa;
    border-radius: 999px;
}

.chart-legend::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.1rem 0.15rem;
    border: 0;
    background: none;
    color: #475569;
    font-size: 0.85rem;
    line-height: 1.6;
}

.legend-item:hover {
    color: #0f172a;
}

.legend-item.is-hidden {
    opacity: 0.4;
    text-decoration: line-through;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.alert {
    font-size: 0.9rem;
    border-radius: var(--fin-radius);
    padding: 0.65rem 0.9rem;
}

.alert-panel .alert:last-child {
    margin-bottom: 0 !important;
}

.progress {
    height: 7px;
    background-color: #eef2f7;
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar {
    font-size: 0.72rem;
}

.text-muted {
    color: var(--fin-muted) !important;
}

/* ---------- persian datepicker ---------- */

.datepicker-plot-area {
    font-family: Tahoma, sans-serif;
    font-size: 0.85rem;
    direction: rtl;
}

@media (max-width: 767.98px) {
    main > .container {
        padding-top: 70px;
    }

    .finance-nav .nav-link {
        padding: 0.4rem 0.5rem;
    }
}
