/* Ledger reconcile (bookkeeping vs statement) — styled to match the ledger pages. */

.ledger-reconcile-page {
    display: block;
}

/* ── Filters ─────────────────────────────────────────────────────────────── */
.ledger-reconcile-filters {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.ledger-reconcile-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.ledger-reconcile-field-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #64748b;
}

.ledger-reconcile-field-label i {
    color: var(--accent-color, #6366f1);
    font-size: 0.82rem;
}

.ledger-reconcile-select-wrap {
    position: relative;
    width: 100%;
}

.ledger-reconcile-select {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    padding: 9px 30px 9px 12px;
    border-radius: 12px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    color: #1f2937;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ledger-reconcile-select:focus {
    outline: none;
    border-color: var(--accent-color, #6366f1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}

.ledger-reconcile-select-caret {
    position: absolute;
    right: 11px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #94a3b8;
    font-size: 0.75rem;
}

/* ── Status pills ────────────────────────────────────────────────────────── */
.ledger-reconcile-status-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

/* ── Summary hero ────────────────────────────────────────────────────────── */
.ledger-reconcile-summary {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 6px;
    padding: 14px 16px;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(99, 102, 241, 0.02) 100%);
    border: 1px solid rgba(99, 102, 241, 0.16);
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.06);
}

.ledger-reconcile-summary-item {
    flex: 1 1 0;
    min-width: 0;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 3px;
    justify-content: center;
}

.ledger-reconcile-summary-value {
    font-size: 1.02rem;
    font-weight: 800;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ledger-reconcile-summary-item.is-matched .ledger-reconcile-summary-value {
    color: #059669;
}

.ledger-reconcile-summary-item.is-diff .ledger-reconcile-summary-value {
    color: #dc2626;
}

.ledger-reconcile-summary-item.is-ok .ledger-reconcile-summary-value {
    color: #059669;
}

.ledger-reconcile-summary-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: #64748b;
}

.ledger-reconcile-summary-divider {
    width: 1px;
    align-self: stretch;
    background: rgba(15, 23, 42, 0.1);
    flex: 0 0 auto;
}

/* ── Board ───────────────────────────────────────────────────────────────── */
.ledger-reconcile-board {
    border-radius: 18px;
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.05);
    overflow: hidden;
}

.ledger-reconcile-col-head,
.ledger-reconcile-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 36px minmax(0, 1fr);
    align-items: stretch;
}

.ledger-reconcile-col-head {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    position: sticky;
    top: 0;
    z-index: 1;
}

.ledger-reconcile-col-head-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    font-size: 0.82rem;
    font-weight: 700;
    color: #475569;
}

.ledger-reconcile-col-head-cell.is-simple i {
    color: #10b981;
}

.ledger-reconcile-col-head-cell.is-bill i {
    color: var(--accent-color, #6366f1);
}

.ledger-reconcile-col-head-gutter {
    border-left: 1px solid rgba(15, 23, 42, 0.06);
    border-right: 1px solid rgba(15, 23, 42, 0.06);
}

.ledger-reconcile-rows {
    display: block;
}

.ledger-reconcile-row {
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
    transition: background 0.15s ease, transform 0.15s ease;
}

.ledger-reconcile-row:last-child {
    border-bottom: none;
}

.ledger-reconcile-row:hover {
    background: rgba(99, 102, 241, 0.03);
}

.ledger-reconcile-cell {
    padding: 11px 14px;
    min-width: 0;
    display: flex;
    align-items: center;
}

.ledger-reconcile-cell.is-simple {
    border-left: 3px solid transparent;
}

.ledger-reconcile-cell.is-bill {
    justify-content: flex-end;
    text-align: right;
}

/* Status accent per row */
.ledger-reconcile-row.is-matched .ledger-reconcile-cell.is-simple {
    border-left-color: #10b981;
}

.ledger-reconcile-row.is-bill-only .ledger-reconcile-cell.is-bill {
    background: rgba(245, 158, 11, 0.06);
}

.ledger-reconcile-row.is-simple-only .ledger-reconcile-cell.is-simple {
    background: rgba(239, 68, 68, 0.05);
    border-left-color: #ef4444;
}

/* Cell content: desktop = name+amount row, date below */
.lrc-cell-inner {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        "name amount"
        "date date";
    gap: 2px 10px;
    width: 100%;
    min-width: 0;
    align-items: baseline;
}

.is-bill .lrc-cell-inner {
    grid-template-areas:
        "amount name"
        "date date";
    grid-template-columns: auto 1fr;
    text-align: right;
}

.lrc-name {
    grid-area: name;
    font-size: 0.88rem;
    font-weight: 600;
    color: #1f2937;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lrc-amount {
    grid-area: amount;
    font-size: 0.92rem;
    font-weight: 800;
    color: #0f172a;
    white-space: nowrap;
}

.lrc-date {
    grid-area: date;
    font-size: 0.72rem;
    font-weight: 600;
    color: #94a3b8;
}

.lrc-empty {
    color: #cbd5e1;
    font-size: 0.82rem;
    font-weight: 600;
    width: 100%;
}

.is-bill .lrc-empty {
    text-align: right;
}

/* Middle gutter with status icon */
.ledger-reconcile-mid {
    display: flex;
    align-items: center;
    justify-content: center;
    border-left: 1px solid rgba(15, 23, 42, 0.06);
    border-right: 1px solid rgba(15, 23, 42, 0.06);
}

.ledger-reconcile-mid-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    font-size: 0.68rem;
    color: #fff;
}

.is-matched .ledger-reconcile-mid-icon {
    background: #10b981;
}

.is-bill-only .ledger-reconcile-mid-icon {
    background: #f59e0b;
}

.is-simple-only .ledger-reconcile-mid-icon {
    background: #ef4444;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */
.ledger-reconcile-empty {
    margin-top: 8px;
}

.ledger-reconcile-empty-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 40px 20px;
    text-align: center;
    color: #94a3b8;
}

.ledger-reconcile-empty-inner > i {
    font-size: 2rem;
    color: #cbd5e1;
}

.ledger-reconcile-empty-title {
    font-size: 0.98rem;
    font-weight: 700;
    color: #475569;
}

.ledger-reconcile-empty-body {
    font-size: 0.84rem;
    line-height: 1.6;
    max-width: 30rem;
}

/* ── Dark theme ──────────────────────────────────────────────────────────── */
body.dark-theme .ledger-reconcile-field-label {
    color: #94a3b8;
}

body.dark-theme .ledger-reconcile-select {
    border-color: rgba(255, 255, 255, 0.12);
    background: linear-gradient(180deg, rgba(43, 48, 76, 0.92) 0%, rgba(35, 39, 62, 0.88) 100%);
    color: #e2e8f0;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
}

body.dark-theme .ledger-reconcile-summary {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.18) 0%, rgba(43, 48, 76, 0.55) 100%);
    border-color: rgba(129, 140, 248, 0.28);
}

body.dark-theme .ledger-reconcile-summary-value {
    color: #e2e8f0;
}

body.dark-theme .ledger-reconcile-summary-label {
    color: #94a3b8;
}

body.dark-theme .ledger-reconcile-summary-divider {
    background: rgba(255, 255, 255, 0.1);
}

body.dark-theme .ledger-reconcile-board {
    background: rgba(30, 34, 54, 0.9);
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark-theme .ledger-reconcile-col-head {
    background: linear-gradient(180deg, rgba(43, 48, 76, 0.9) 0%, rgba(35, 39, 62, 0.85) 100%);
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

body.dark-theme .ledger-reconcile-col-head-cell {
    color: #cbd5e1;
}

body.dark-theme .ledger-reconcile-row {
    border-bottom-color: rgba(255, 255, 255, 0.07);
}

body.dark-theme .ledger-reconcile-row:hover {
    background: rgba(129, 140, 248, 0.08);
}

body.dark-theme .lrc-name {
    color: #e2e8f0;
}

body.dark-theme .lrc-amount {
    color: #f1f5f9;
}

body.dark-theme .lrc-date {
    color: #94a3b8;
}

body.dark-theme .lrc-empty {
    color: #475569;
}

body.dark-theme .ledger-reconcile-mid,
body.dark-theme .ledger-reconcile-col-head-gutter {
    border-color: rgba(255, 255, 255, 0.08);
}

body.dark-theme .ledger-reconcile-empty-title {
    color: #cbd5e1;
}

/* ── Mobile: keep left/right columns; stack date -> name -> amount ─────────── */
@media (max-width: 768px) {
    .ledger-reconcile-filters {
        grid-template-columns: 1fr;
    }

    .ledger-reconcile-col-head,
    .ledger-reconcile-row {
        grid-template-columns: minmax(0, 1fr) 26px minmax(0, 1fr);
    }

    .ledger-reconcile-cell {
        padding: 10px 10px;
        align-items: stretch;
    }

    .lrc-cell-inner,
    .is-bill .lrc-cell-inner {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 3px;
        text-align: left;
    }

    .is-bill .lrc-cell-inner {
        align-items: flex-end;
        text-align: right;
    }

    .lrc-date {
        order: 1;
    }

    .lrc-name {
        order: 2;
        white-space: normal;
        word-break: break-word;
    }

    .lrc-amount {
        order: 3;
    }

    .ledger-reconcile-mid-icon {
        width: 18px;
        height: 18px;
        font-size: 0.6rem;
    }

    .ledger-reconcile-summary {
        flex-wrap: wrap;
        gap: 10px;
    }

    .ledger-reconcile-summary-item {
        flex: 1 1 40%;
    }

    .ledger-reconcile-summary-divider {
        display: none;
    }
}
