/* ==========================================================================
   Finance Module — KPI, Charts, Analytics Styles
   ========================================================================== */

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

.fin-kpi-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    background: #fff;
    border-radius: 10px;
    border-left: 4px solid var(--fin-kpi-color, #3b82f6);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: box-shadow 0.2s, transform 0.15s;
}
.fin-kpi-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}

.fin-kpi-card--green  { --fin-kpi-color: #16a34a; }
.fin-kpi-card--red    { --fin-kpi-color: #dc2626; }
.fin-kpi-card--blue   { --fin-kpi-color: #3b82f6; }
.fin-kpi-card--orange { --fin-kpi-color: #f59e0b; }
.fin-kpi-card--purple { --fin-kpi-color: #8b5cf6; }
.fin-kpi-card--teal   { --fin-kpi-color: #14b8a6; }

.fin-kpi-card--warning {
    --fin-kpi-color: #f59e0b;
    background: #fffbeb;
}
.fin-kpi-card--critical {
    --fin-kpi-color: #dc2626;
    background: #fef2f2;
}

.fin-kpi-icon {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: color-mix(in srgb, var(--fin-kpi-color) 12%, transparent);
    color: var(--fin-kpi-color);
    font-size: 18px;
    flex-shrink: 0;
}

.fin-kpi-body {
    flex: 1;
    min-width: 0;
}

.fin-kpi-value {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.2;
    color: #111827;
}

.fin-kpi-label {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 2px;
}

.fin-kpi-change {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 6px;
    vertical-align: middle;
}
.fin-kpi-change--up {
    color: #16a34a;
    background: rgba(22, 163, 74, 0.1);
}
.fin-kpi-change--down {
    color: #dc2626;
    background: rgba(220, 38, 38, 0.1);
}
.fin-kpi-change--neutral {
    color: #6b7280;
    background: rgba(107, 114, 128, 0.1);
}

/* ---------------------------------------------------------------------------
   Charts Grid
   --------------------------------------------------------------------------- */
.fin-charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.fin-chart-card {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.fin-chart-card__title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #374151;
    margin: 0 0 14px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.fin-chart-card__title i {
    color: #6b7280;
    font-size: 0.85rem;
}

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

.fin-chart-wrap--sm {
    height: 200px;
}

/* ---------------------------------------------------------------------------
   Attention Section
   --------------------------------------------------------------------------- */
.fin-attention {
    margin-bottom: 24px;
}

.fin-attention__title {
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
    margin: 0 0 12px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.fin-attention__title i {
    color: #f59e0b;
}

.fin-attention-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.fin-attention-card {
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    padding: 16px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.fin-attention-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.fin-attention-card__label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
}

.fin-attention-card__count {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    background: #fef3c7;
    color: #92400e;
}

.fin-attention-card__count--danger {
    background: #fee2e2;
    color: #991b1b;
}

.fin-attention-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.fin-attention-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.82rem;
    color: #374151;
}
.fin-attention-list li:last-child {
    border-bottom: none;
}

.fin-attention-list__amount {
    font-weight: 600;
    white-space: nowrap;
}

.fin-attention-list__amount--danger {
    color: #dc2626;
}

.fin-attention-list__amount--warning {
    color: #f59e0b;
}

/* ---------------------------------------------------------------------------
   Period Selector
   --------------------------------------------------------------------------- */
.fin-period-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 10px 14px;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.fin-period-bar label {
    font-size: 0.82rem;
    font-weight: 500;
    color: #374151;
}

.fin-period-bar select,
.fin-period-bar input[type="date"] {
    font-size: 0.82rem;
    padding: 5px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
}

/* ---------------------------------------------------------------------------
   Data Tables (finance-specific)
   --------------------------------------------------------------------------- */
.fin-table-wrap {
    overflow-x: auto;
    margin-top: 12px;
}

.fin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}

.fin-table th {
    background: #f9fafb;
    font-weight: 600;
    color: #374151;
    padding: 10px 12px;
    text-align: left;
    border-bottom: 2px solid #e5e7eb;
    white-space: nowrap;
}

.fin-table td {
    padding: 9px 12px;
    border-bottom: 1px solid #f3f4f6;
    color: #374151;
}

.fin-table tr:hover td {
    background: #f9fafb;
}

.fin-table .u-text-right {
    text-align: right;
}

.fin-table .u-fw-600 {
    font-weight: 600;
}

/* Profitability margin bar */
.fin-margin-bar {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.fin-margin-bar__track {
    width: 50px;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
}

.fin-margin-bar__fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

.fin-margin-bar__fill--green  { background: #16a34a; }
.fin-margin-bar__fill--orange { background: #f59e0b; }
.fin-margin-bar__fill--red    { background: #dc2626; }

/* ---------------------------------------------------------------------------
   Section Tabs (sub-tabs inside finance)
   --------------------------------------------------------------------------- */
.fin-section-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 0;
    overflow-x: auto;
}

.fin-section-tab {
    padding: 8px 16px;
    font-size: 0.84rem;
    font-weight: 500;
    color: #6b7280;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
}
.fin-section-tab:hover {
    color: #111827;
}
.fin-section-tab.active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
    font-weight: 600;
}

/* ---------------------------------------------------------------------------
   Empty State
   --------------------------------------------------------------------------- */
.fin-empty {
    text-align: center;
    padding: 32px 16px;
    color: #9ca3af;
    font-size: 0.88rem;
}
.fin-empty i {
    font-size: 2rem;
    display: block;
    margin-bottom: 8px;
}

/* ---------------------------------------------------------------------------
   Loading
   --------------------------------------------------------------------------- */
.fin-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px 16px;
    color: #6b7280;
    font-size: 0.88rem;
}

/* ---------------------------------------------------------------------------
   Coming Soon Panel
   --------------------------------------------------------------------------- */
.fin-coming-soon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 24px;
    text-align: center;
    color: #9ca3af;
}
.fin-coming-soon i {
    font-size: 2.5rem;
    margin-bottom: 16px;
    color: #d1d5db;
}
.fin-coming-soon h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #374151;
    margin: 0 0 8px 0;
}
.fin-coming-soon p {
    font-size: 0.875rem;
    margin: 0;
}

/* ---------------------------------------------------------------------------
   Overview Actions Row
   --------------------------------------------------------------------------- */
/* Tab navigation bottom spacing */
#finance-page .detail-tabs {
    margin-bottom: 24px;
}

.fin-overview-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

/* 4-column KPI grid variant */
.fin-kpi-grid--4 {
    grid-template-columns: repeat(4, 1fr);
}

.fin-kpi-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 500;
    color: #6b7280;
    margin-left: 4px;
}

/* ---------------------------------------------------------------------------
   Overview Mid Grid (project budget + upcoming payments)
   --------------------------------------------------------------------------- */
.fin-overview-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 20px;
    align-items: start;
    margin-bottom: 16px;
}

.fin-overview-left,
.fin-overview-right {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.fin-overview-mid-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    margin-bottom: 16px;
    align-items: start;
}

.fin-section-card {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    overflow: hidden;
}

.fin-section-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    background: #f9fafb;
}

.fin-section-card__title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

.fin-section-card__body {
    overflow-x: auto;
}

/* Budget table */
.fin-budget-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.fin-budget-table thead th {
    padding: 8px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid #f3f4f6;
    background: #f9fafb;
}

.fin-budget-row td {
    padding: 9px 12px;
    border-bottom: 1px solid #f9fafb;
    vertical-align: middle;
}

.fin-budget-row:last-child td { border-bottom: none; }

.fin-budget-row__name {
    font-weight: 500;
    color: #111827;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fin-budget-row__amount {
    white-space: nowrap;
    color: #374151;
}

.fin-budget-row__amount--positive {
    color: var(--success-color);
}

.fin-budget-row__amount--negative {
    color: var(--warning-color);
}

.fin-budget-row__bar {
    width: 120px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.fin-budget-bar {
    flex: 1;
    height: 6px;
    background: #f3f4f6;
    border-radius: 4px;
    overflow: hidden;
}

.fin-budget-bar__fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s ease;
}

.fin-budget-bar__fill--ok   { background: #16a34a; }
.fin-budget-bar__fill--warn { background: #f59e0b; }
.fin-budget-bar__fill--over { background: #dc2626; }

.fin-budget-bar__pct {
    font-size: 0.72rem;
    color: #6b7280;
    white-space: nowrap;
    min-width: 30px;
}

.fin-budget-empty {
    padding: 20px;
    text-align: center;
    color: #9ca3af;
    font-size: 0.82rem;
}

/* ---------------------------------------------------------------------------
   Accounts side panel (overview)
   --------------------------------------------------------------------------- */
.fin-acct-panel {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    overflow: hidden;
}

.fin-acct-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    background: #f9fafb;
}

.fin-acct-panel__title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

.fin-acct-panel__total {
    font-size: 0.85rem;
    font-weight: 700;
    color: #111827;
}

.fin-acct-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.fin-acct-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.83rem;
}

.fin-acct-row:last-child { border-bottom: none; }

.fin-acct-row__icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: #eff6ff;
    color: #3b82f6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.fin-acct-row__name {
    flex: 1;
    font-weight: 500;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fin-acct-row__balance {
    font-weight: 600;
    white-space: nowrap;
    color: #111827;
}

.fin-acct-row__balance--neg { color: #dc2626; }
.fin-acct-row--empty { color: #9ca3af; justify-content: center; }

/* ---------------------------------------------------------------------------
   Overview Main Grid (chart + accounts)
   --------------------------------------------------------------------------- */
.fin-main-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    margin-bottom: 16px;
    align-items: start;
}

.fin-side-panels {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.fin-side-panel {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    overflow: hidden;
}

.fin-side-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    background: #f9fafb;
}

.fin-side-panel__title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}
.fin-side-panel__title i {
    font-size: 0.8rem;
}

/* ---------------------------------------------------------------------------
   Upcoming Payments List
   --------------------------------------------------------------------------- */
.fin-upcoming-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.fin-upcoming-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 16px;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.82rem;
}
.fin-upcoming-item:last-child {
    border-bottom: none;
}

.fin-upcoming-item__left {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.fin-upcoming-item__name {
    font-weight: 500;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fin-upcoming-item__amount {
    font-weight: 600;
    white-space: nowrap;
    color: #374151;
}
.fin-upcoming-item__amount--in {
    color: #16a34a;
}

.fin-upcoming-empty {
    padding: 16px;
    text-align: center;
    font-size: 0.82rem;
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.fin-upcoming-empty i {
    color: #16a34a;
}

/* ---------------------------------------------------------------------------
   Kasa/Banka — Two-column master-detail layout
   --------------------------------------------------------------------------- */
.fin-ops-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 0;
    min-height: 500px;
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    overflow: hidden;
}

.fin-ops-sidebar {
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e5e7eb;
    background: #f9fafb;
}

.fin-ops-sidebar__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 12px;
    border-bottom: 1px solid #e5e7eb;
}

.fin-ops-sidebar__title {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #6b7280;
}

.fin-ops-account-list {
    flex: 1;
    overflow-y: auto;
}

.fin-account-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.12s;
}
.fin-account-item:hover {
    background: #eff6ff;
}
.fin-account-item--active {
    background: #eff6ff;
    border-left: 3px solid #2563eb;
}
.fin-account-item--active .fin-account-item__name {
    color: #1d4ed8;
}

.fin-account-item__icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}
.fin-account-item__icon--cash {
    background: rgba(20, 184, 166, 0.12);
    color: #0d9488;
}
.fin-account-item__icon--bank {
    background: rgba(37, 99, 235, 0.12);
    color: #1d4ed8;
}

.fin-account-item__body {
    flex: 1;
    min-width: 0;
}

.fin-account-item__name {
    font-size: 0.84rem;
    font-weight: 600;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.fin-account-item__type {
    font-size: 0.74rem;
    color: #9ca3af;
}

.fin-account-item__balance {
    font-size: 0.82rem;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
}
.fin-account-item__balance--negative {
    color: #dc2626;
}

.fin-account-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 16px;
    text-align: center;
    color: #9ca3af;
    font-size: 0.82rem;
}
.fin-account-empty i {
    font-size: 1.8rem;
    margin-bottom: 8px;
    color: #d1d5db;
}
.fin-account-empty p {
    margin: 0;
}

.fin-ops-sidebar__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-top: 1px solid #e5e7eb;
    font-size: 0.82rem;
    color: #6b7280;
    background: #fff;
}

.fin-ops-sidebar__footer-label {
    font-weight: 500;
}

.fin-ops-sidebar__footer-value {
    font-weight: 700;
    color: #111827;
}
.fin-ops-sidebar__footer-value--negative {
    color: #dc2626;
}

.fin-ops-main {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.fin-ops-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

/* Account detail header inside main panel */
.fin-ops-detail-head {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid #f3f4f6;
}

.fin-ops-detail-title {
    flex: 1;
    min-width: 0;
}
.fin-ops-detail-title h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---------------------------------------------------------------------------
   Kasa/Banka — Account card sparkline & delta
   --------------------------------------------------------------------------- */
.fin-account-item__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 1px;
}
.fin-account-item__delta {
    font-size: 0.72rem;
    font-weight: 600;
}
.fin-account-item__delta--pos { color: #16a34a; }
.fin-account-item__delta--neg { color: #dc2626; }

.fin-account-sparkline {
    display: block;
    margin-top: 5px;
    overflow: visible;
}

/* ---------------------------------------------------------------------------
   Kasa/Banka — Operations filter chip bar
   --------------------------------------------------------------------------- */
.fin-ops-filter-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    padding: 10px 14px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}
.fin-ops-filter-bar__group {
    display: flex;
    align-items: center;
    gap: 5px;
}
.fin-ops-filter-bar__group + .fin-ops-filter-bar__group {
    padding-left: 10px;
    border-left: 1px solid #e5e7eb;
}
.fin-ops-filter-bar__group--select {
    flex: 1;
    justify-content: flex-end;
}
.fin-ops-filter-bar__label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #9ca3af;
    text-transform: uppercase;
    white-space: nowrap;
}
.fin-ops-chip {
    padding: 3px 10px;
    border: 1px solid #d1d5db;
    border-radius: 16px;
    background: #fff;
    color: #374151;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.fin-ops-chip:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}
.fin-ops-chip--active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}
.fin-ops-chip--ghost {
    background: transparent;
    border-color: transparent;
    color: #9ca3af;
    padding: 3px 7px;
}
.fin-ops-chip--ghost:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #374151;
}
.fin-ops-select {
    padding: 4px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.8rem;
    color: #374151;
    background: #fff;
    cursor: pointer;
    max-width: 180px;
}

/* ---------------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------------- */
@media (max-width: 1024px) {
    .fin-overview-layout {
        grid-template-columns: 1fr;
    }
    .fin-main-grid {
        grid-template-columns: 1fr;
    }
    .fin-overview-mid-grid {
        grid-template-columns: 1fr;
    }
    .fin-side-panels {
        flex-direction: row;
    }
    .fin-side-panel {
        flex: 1;
    }
    .fin-kpi-grid--4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .fin-kpi-grid {
        grid-template-columns: 1fr 1fr;
    }
    .fin-kpi-grid--4 {
        grid-template-columns: 1fr 1fr;
    }
    .fin-charts-grid {
        grid-template-columns: 1fr;
    }
    .fin-attention-grid {
        grid-template-columns: 1fr;
    }
    .fin-chart-wrap {
        height: 220px;
    }
    .fin-main-grid {
        grid-template-columns: 1fr;
    }
    .fin-side-panels {
        flex-direction: column;
    }
    .fin-ops-layout {
        grid-template-columns: 1fr;
    }
    .fin-ops-sidebar {
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
    }
    .fin-ops-account-list {
        max-height: 240px;
    }
}

@media (max-width: 480px) {
    .fin-kpi-grid,
    .fin-kpi-grid--4 {
        grid-template-columns: 1fr;
    }
}

/* ---------------------------------------------------------------------------
   Nakit Akışı — Period Chips
   --------------------------------------------------------------------------- */
.fin-cf-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.fin-cf-period-chips {
    display: flex;
    gap: 6px;
}

.fin-period-chip {
    padding: 5px 16px;
    border-radius: 20px;
    border: 1px solid #e5e7eb;
    background: #fff;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    color: #6b7280;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    line-height: 1.4;
}
.fin-period-chip:hover {
    border-color: #3b82f6;
    color: #3b82f6;
}
.fin-period-chip--active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #fff;
}

/* ---------------------------------------------------------------------------
   Nakit Akışı — Monthly Table Row States
   --------------------------------------------------------------------------- */
.fin-cf-row--current > td {
    background: rgba(59, 130, 246, 0.06);
    font-weight: 600;
}
.fin-cf-row--projection > td {
    font-style: italic;
    color: #9ca3af;
}
.fin-cf-row--projection > td .badge {
    vertical-align: middle;
}

/* Mini bar in cashflow table */
.fin-cf-bar {
    height: 6px;
    background: #f3f4f6;
    border-radius: 3px;
    min-width: 64px;
    overflow: hidden;
}
.fin-cf-bar__fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
    border-radius: 3px;
}

/* ---------------------------------------------------------------------------
   Nakit Akışı — Waterfall (Şelale) View
   --------------------------------------------------------------------------- */
.fin-wf-container {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
}
.fin-wf-axis-label {
    display: none; /* decorative, skip in layout */
}
.fin-wf-row {
    display: grid;
    grid-template-columns: 100px 1fr 90px 90px;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}
.fin-wf-row__label {
    font-size: 0.8rem;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}
.fin-wf-row__bar-wrap {
    display: flex;
    align-items: center;
    height: 20px;
    background: #f3f4f6;
    border-radius: 4px;
    overflow: hidden;
}
.fin-wf-row__bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}
.fin-wf-row__spacer {
    height: 100%;
    flex-shrink: 0;
}
.fin-wf-row__value {
    font-size: 0.78rem;
    font-weight: 600;
    text-align: right;
    white-space: nowrap;
}
.fin-wf-row__closing {
    font-size: 0.75rem;
    color: #6b7280;
    text-align: right;
    white-space: nowrap;
}

/* ---------------------------------------------------------------------------
   Nakit Akışı — Category Breakdown
   --------------------------------------------------------------------------- */
.fin-cf-breakdown {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 20px;
}
.fin-cf-breakdown__panel {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
}
.fin-cf-breakdown__head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 0.86rem;
    font-weight: 600;
    border-bottom: 1px solid #e5e7eb;
}
.fin-cf-breakdown__head--income {
    background: #f0fdf4;
    color: #16a34a;
}
.fin-cf-breakdown__head--expense {
    background: #fef2f2;
    color: #dc2626;
}
.fin-cf-breakdown__body {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.fin-cat-row {
    display: grid;
    grid-template-columns: 120px 1fr 90px;
    align-items: center;
    gap: 8px;
}
.fin-cat-row__name {
    font-size: 0.78rem;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.fin-cat-row__bar-wrap {
    height: 6px;
    background: #f3f4f6;
    border-radius: 3px;
    overflow: hidden;
}
.fin-cat-row__bar {
    height: 100%;
    background: #3b82f6;
    border-radius: 3px;
}
.fin-cf-breakdown__head--income + .fin-cf-breakdown__body .fin-cat-row__bar {
    background: #16a34a;
}
.fin-cf-breakdown__head--expense + .fin-cf-breakdown__body .fin-cat-row__bar {
    background: #dc2626;
}
.fin-cat-row__val {
    font-size: 0.78rem;
    font-weight: 600;
    color: #111827;
    text-align: right;
    white-space: nowrap;
}
.fin-cat-empty {
    font-size: 0.8rem;
    color: #9ca3af;
    padding: 12px 0;
    text-align: center;
}

/* ---------------------------------------------------------------------------
   Ödemeler — Alert Strip
   --------------------------------------------------------------------------- */
.fin-payments-alert {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #dc2626;
    font-size: 0.875rem;
    margin-bottom: 20px;
}
.fin-payments-alert i {
    flex-shrink: 0;
}

/* ---------------------------------------------------------------------------
   Ödemeler — Layout (Calendar + List)
   --------------------------------------------------------------------------- */
.fin-payments-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
    align-items: start;
    margin-top: 20px;
}

/* ---------------------------------------------------------------------------
   Ödemeler — Mini Calendar
   --------------------------------------------------------------------------- */
.fin-cal {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    overflow: hidden;
}

.fin-cal__head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}
.fin-cal__month {
    flex: 1;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    color: #374151;
}
.fin-cal__nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    background: #fff;
    color: #6b7280;
    cursor: pointer;
    font-size: 0.7rem;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}
.fin-cal__nav-btn:hover {
    background: #e5e7eb;
    color: #111827;
}
.fin-cal__clear-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    background: #fee2e2;
    color: #dc2626;
    cursor: pointer;
    font-size: 0.65rem;
    flex-shrink: 0;
    transition: background 0.15s;
}
.fin-cal__clear-btn:hover {
    background: #fecaca;
}

.fin-cal__grid {
    width: 100%;
    border-collapse: collapse;
}
.fin-cal__grid th {
    padding: 8px 0;
    text-align: center;
    color: #9ca3af;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.fin-cal__cell,
.fin-cal__empty {
    padding: 5px 2px;
    text-align: center;
    vertical-align: top;
    width: 14.28%;
}
.fin-cal__cell {
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.12s;
}
.fin-cal__cell:hover {
    background: #f3f4f6;
}
.fin-cal__cell--today {
    background: rgba(59, 130, 246, 0.08);
    border-radius: 4px;
}
.fin-cal__cell--selected {
    background: #2563eb !important;
    border-radius: 4px;
}
.fin-cal__cell--selected .fin-cal__day-num {
    color: #fff;
}
.fin-cal__cell--has-overdue {
    outline: 1px solid #fca5a5;
    outline-offset: -1px;
}
.fin-cal__day-num {
    display: block;
    font-size: 0.8rem;
    color: #374151;
    line-height: 1.4;
}
.fin-cal__empty .fin-cal__day-num {
    visibility: hidden;
}

.fin-cal-dot {
    display: block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    margin: 2px auto 0;
}
.fin-cal-dot--overdue    { background: #dc2626; }
.fin-cal-dot--upcoming  { background: #f59e0b; }
.fin-cal-dot--today     { background: #3b82f6; }
.fin-cal-dot--completed { background: #16a34a; }

.fin-cal__legend {
    display: flex;
    gap: 12px;
    padding: 10px 14px;
    border-top: 1px solid #f3f4f6;
    font-size: 0.73rem;
    color: #6b7280;
    flex-wrap: wrap;
}
.fin-cal-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* ---------------------------------------------------------------------------
   Ödemeler — Payment Groups & Rows
   --------------------------------------------------------------------------- */
.fin-payment-group {
    margin-bottom: 14px;
}
.fin-payment-group__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 8px 14px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px 8px 0 0;
    font-size: 0.84rem;
    font-weight: 600;
    color: #374151;
}
.fin-payment-group__head--overdue {
    background: #fef2f2;
    border-color: #fecaca;
    color: #dc2626;
}
.fin-payment-group__head--today {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #2563eb;
}

.fin-payment-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-top: none;
}
.fin-payment-row:last-child {
    border-radius: 0 0 8px 8px;
}
.fin-payment-row:hover {
    background: #f9fafb;
}

.fin-payment-row__date {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 34px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 4px 6px;
    flex-shrink: 0;
}
.fin-payment-row__day {
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
    line-height: 1.1;
}
.fin-payment-row__mon {
    font-size: 0.7rem;
    color: #9ca3af;
    margin-top: 1px;
}

.fin-payment-row__info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.fin-payment-row__name {
    font-size: 0.86rem;
    font-weight: 500;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fin-payment-row__amount {
    font-size: 0.9rem;
    font-weight: 700;
    color: #dc2626;
    white-space: nowrap;
    flex-shrink: 0;
}

.fin-payment-empty {
    text-align: center;
    padding: 40px 20px;
    color: #9ca3af;
    font-size: 0.875rem;
}
.fin-payment-empty i {
    display: block;
    font-size: 1.8rem;
    color: #d1d5db;
    margin-bottom: 10px;
}
.fin-payment-empty p {
    margin: 0;
}

/* ---------------------------------------------------------------------------
   Ödemeler — Filter Chip Bar
   --------------------------------------------------------------------------- */
.fin-pay-filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.fin-pay-filter-bar__label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #9ca3af;
    text-transform: uppercase;
}
.fin-pay-chip {
    padding: 4px 12px;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    background: #fff;
    color: #374151;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.13s, border-color 0.13s, color 0.13s;
}
.fin-pay-chip:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}
.fin-pay-chip--active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

/* ---------------------------------------------------------------------------
   Ödemeler — Row Modifiers
   --------------------------------------------------------------------------- */
.fin-payment-row--overdue .fin-payment-row__date {
    background: #fef2f2;
    border-color: #fecaca;
}
.fin-payment-row--overdue .fin-payment-row__day {
    color: #dc2626;
}
.fin-payment-row--today .fin-payment-row__date {
    background: #eff6ff;
    border-color: #bfdbfe;
}
.fin-payment-row--today .fin-payment-row__day {
    color: #2563eb;
}

.fin-payment-row__tags {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}
.fin-payment-row__cat {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 10px;
    background: #f3f4f6;
    color: #6b7280;
    font-size: 0.72rem;
    font-weight: 500;
}

.fin-payment-row__actions {
    flex-shrink: 0;
    display: flex;
    gap: 6px;
}
.fin-payment-row__btn {
    padding: 4px 10px;
    border-radius: 5px;
    border: 1px solid #d1d5db;
    background: #fff;
    color: #374151;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s;
}
.fin-payment-row__btn:hover {
    background: #f3f4f6;
}
.fin-payment-row__btn--primary {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}
.fin-payment-row__btn--primary:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

/* ---------------------------------------------------------------------------
   Ödemeler — Gecikmiş uyarı kategorileri
   --------------------------------------------------------------------------- */
.fin-payments-alert {
    align-items: flex-start;
}
.fin-payments-alert__icon {
    margin-top: 2px;
    flex-shrink: 0;
}
.fin-payments-alert__body {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.fin-payments-alert__cats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    font-size: 0.82rem;
    opacity: 0.9;
}
.fin-payments-alert-cat {
    white-space: nowrap;
}

/* ---------------------------------------------------------------------------
   Ödemeler — Kategoriye göre gruplandırma (accordion)
   --------------------------------------------------------------------------- */
.fin-pay-cat-group {
    margin-bottom: 12px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}
.fin-pay-cat-group[open] > .fin-pay-cat-group__head .fin-pay-cat-group__chevron {
    transform: rotate(180deg);
}
.fin-pay-cat-group__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 14px;
    background: #f9fafb;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    list-style: none;
    user-select: none;
}
.fin-pay-cat-group__head::-webkit-details-marker { display: none; }
.fin-pay-cat-group__head--overdue {
    background: #fef2f2;
    border-color: #fecaca;
    color: #dc2626;
}
.fin-pay-cat-group__head--upcoming {
    background: #f0fdf4;
    border-bottom: 1px solid #d1fae5;
    color: #065f46;
}
.fin-pay-cat-group__title {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
}
.fin-pay-cat-group__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    font-size: 0.82rem;
    opacity: 0.85;
}
.fin-pay-cat-group__chevron {
    transition: transform 0.2s;
    font-size: 0.72rem;
}
.fin-pay-cat-group__body .fin-payment-row {
    border: none;
    border-top: 1px solid #e5e7eb;
    border-radius: 0;
}
.fin-pay-cat-group__body .fin-payment-row:last-child {
    border-radius: 0;
}

/* ---------------------------------------------------------------------------
   Phase 2 Responsive
   --------------------------------------------------------------------------- */
@media (max-width: 900px) {
    .fin-payments-layout {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 600px) {
    .fin-cf-header {
        justify-content: flex-start;
    }
}

/* ---------------------------------------------------------------------------
   Phase 3 — Bütçe Tab
   --------------------------------------------------------------------------- */
.fin-bud-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    align-items: start;
}
.fin-bud-side {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Progress bar */
.fin-bud-prog {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.fin-bud-prog__track {
    flex: 1;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}
.fin-bud-prog__fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}
.fin-bud-prog__fill--ok    { background: #10b981; }
.fin-bud-prog__fill--warn  { background: #f59e0b; }
.fin-bud-prog__fill--over  { background: #ef4444; }
.fin-bud-prog__pct {
    font-size: 0.78rem;
    font-weight: 600;
    color: #6b7280;
    white-space: nowrap;
    min-width: 38px;
    text-align: right;
}

/* Budget table status badge colors */
.fin-bud-status--ok   { color: #059669; font-weight: 600; }
.fin-bud-status--warn { color: #d97706; font-weight: 600; }
.fin-bud-status--over { color: #dc2626; font-weight: 600; }

/* ---------------------------------------------------------------------------
   Phase 3 — Raporlar Tab
   --------------------------------------------------------------------------- */
.fin-reports-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}
.fin-reports-toolbar .btn-secondary {
    font-size: 0.82rem;
}

.fin-reports-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

.fin-report-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    padding: 18px 20px;
    background: linear-gradient(135deg, #18324a 0%, #21516a 58%, #287267 100%);
    color: #fff;
    border-radius: 8px;
}

.fin-report-hero__title {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 750;
    letter-spacing: 0;
}

.fin-report-hero__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.fin-reports-grid--executive {
    align-items: stretch;
}

.fin-report-card {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr) auto;
    gap: 16px;
    align-items: center;
    min-height: 150px;
    padding: 18px;
    background: #fff;
    border: 1px solid #dbe4f0;
    border-radius: 8px;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
}

.fin-report-card__icon {
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    font-size: 1.35rem;
}

.fin-report-card__icon--people {
    color: #1d4ed8;
    background: #dbeafe;
}

.fin-report-card__icon--projects {
    color: #047857;
    background: #d1fae5;
}

.fin-report-card__body {
    min-width: 0;
}

.fin-report-card__body h3 {
    margin: 0 0 12px;
    color: #172033;
    font-size: 1.05rem;
    letter-spacing: 0;
}

.fin-report-card__controls,
.fin-report-card__chips,
.fin-report-card__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.fin-report-card__controls label {
    font-size: 0.82rem;
    font-weight: 700;
    color: #64748b;
}

.fin-report-card__controls select {
    min-width: 110px;
}

.fin-report-card__actions {
    justify-content: flex-end;
}

/* ---------------------------------------------------------------------------
   Phase 3 Responsive
   --------------------------------------------------------------------------- */
@media (max-width: 960px) {
    .fin-bud-grid {
        grid-template-columns: 1fr;
    }
    .fin-reports-grid {
        grid-template-columns: 1fr;
    }
    .fin-report-card {
        grid-template-columns: 48px minmax(0, 1fr);
    }
    .fin-report-card__actions {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }
    .fin-cf-breakdown {
        grid-template-columns: 1fr;
    }
    .fin-wf-row {
        grid-template-columns: 80px 1fr 70px 70px;
    }
}
