#ledger-panel { min-width: 0; }
#ledger-panel .section-header { flex-wrap: wrap; }
#ledger-panel .section-header > div { min-width: 0; }
#ledger-panel .section-header .actions { flex-wrap: wrap; }
.page[data-section="calendar"] { min-width: 0; }
.page[data-section="calendar"] .page-header { flex-wrap: wrap; }
.ledger-scroll { overflow: auto; max-height: 68vh; border: 1px solid #cbd5e1; border-radius: 8px; }
.ledger-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; background: white; color: #172b4d; }
.ledger-table th, .ledger-table td { border-right: 1px solid #dbe3ed; border-bottom: 1px solid #dbe3ed; padding: 0; text-align: left; vertical-align: middle; }
.ledger-table thead th { position: sticky; top: 0; z-index: 3; padding: 10px; background: #153c5a; color: white; white-space: nowrap; }
.ledger-table tbody th { min-width: 145px; padding: 9px; position: sticky; left: 0; z-index: 2; background: #f1f5f9; }
.ledger-table small { display: block; font-size: 11px; font-weight: normal; color: #526579; margin-top: 4px; }
.ledger-table input, .ledger-table select { width: 100%; min-width: 130px; border: 0; border-radius: 0; background: transparent; color: inherit; box-shadow: none; margin: 0; padding: 10px 8px; font-size: 13px; min-height: 40px; }
.ledger-table input[data-field="provider_name"], .ledger-table input[data-field="notes"] { min-width: 210px; }
.ledger-table input[data-field="total"] { text-align: right; font-variant-numeric: tabular-nums; }
.ledger-table input[data-field="currency"] { min-width: 85px; max-width: 100px; }
.ledger-table input:focus, .ledger-table select:focus { outline: 2px solid #168a70; outline-offset: -2px; background: #fff; }
.ledger-table .ledger-invoice { background: #edf6fd; }
.ledger-table .ledger-invoice th { background: #dceefb; }
.ledger-table .ledger-child th { border-left: 4px solid #72afca; padding-left: 16px; }
.ledger-table .ledger-dirty { background: #fff3c4; box-shadow: inset 0 -2px #ca9400; }
.ledger-table .ledger-sum { padding: 10px; min-width: 140px; font-weight: 600; }
.ledger-table .ledger-empty { background: #f5f7f9; text-align: center; color: #8090a0; }
.ledger-table .ledger-files, .ledger-table .ledger-actions { padding: 5px; min-width: 150px; }
.ledger-table .ledger-actions { min-width: 240px; }
.ledger-table button { font-size: 12px; padding: 5px 8px; margin: 2px; white-space: nowrap; }
.ledger-drop td { background: #d6f5e9 !important; box-shadow: inset 0 2px #168a70, inset 0 -2px #168a70; }
.ledger-totals { background: #f1f5f9; color: #233b53; padding: 12px; border-radius: 8px; }
#ledger-dialog { width: min(720px, 94vw); max-height: 85vh; overflow: auto; border: 1px solid #cbd5e1; border-radius: 12px; padding: 24px; color: #172b4d; background: white; }
#ledger-dialog::backdrop { background: #10233799; }
.ledger-options { max-height: 320px; overflow-y: auto; margin: 15px 0; }
.ledger-options label { display: flex; align-items: center; gap: 10px; padding: 10px; border-bottom: 1px solid #e2e8f0; }
.ledger-options label[hidden] { display: none; }
.ledger-options input { width: auto; }
.ledger-attached { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
#ledger-panel[aria-busy="true"] .ledger-scroll { opacity: .7; pointer-events: none; }
#ledger-panel .list-pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 12px; }

.ledger-file-ribbon { margin: 16px 0 20px; padding: 14px; border: 1px solid #d4e2ee; border-radius: 12px; background: #f7fafc; }
.ledger-ribbon-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.ledger-ribbon-header h4 { margin: 0; color: #153c5a; }
.ledger-ribbon-header p { margin: 6px 0 10px; font-size: 13px; }
.ledger-count { display: inline-block; min-width: 24px; padding: 2px 7px; border-radius: 14px; background: #dceefb; font-size: 12px; text-align: center; }
.ledger-ribbon-header .actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.ledger-ribbon-header input[type="search"] { width: 180px; font-size: 13px; padding: 8px 10px; }
.ledger-upload-label { position: relative; overflow: hidden; display: inline-block; margin: 0; border-radius: 8px; padding: 9px 12px; background: #153c5a; color: white; cursor: pointer; font-size: 13px; }
.ledger-upload-label input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.ledger-upload-label:focus-within { outline: 3px solid #67b9ff; }
.ledger-ribbon-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; }
.ledger-ribbon-left { min-width: 0; }
.ledger-file-strip { display: flex; align-items: stretch; gap: 9px; overflow-x: auto; padding: 5px 2px 10px; min-height: 115px; }
.ledger-file-card { position: relative; flex: 0 0 142px; border: 1px solid #d5dfea; border-radius: 9px; background: white; cursor: grab; transition: border-color .15s, box-shadow .15s; }
.ledger-file-card.selected { border-color: #168a70; background: #edfbf4; box-shadow: inset 0 0 0 1px #168a70; }
.ledger-file-card.previewing { border-color: #2589dc; box-shadow: 0 0 0 2px #2589dc44; }
.ledger-file-check { position: absolute; top: 7px; right: 7px; z-index: 1; margin: 0; }
.ledger-file-check input { width: 17px; height: 17px; margin: 0; accent-color: #168a70; }
.ledger-file-open { display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 5px; width: 100%; min-height: 110px; padding: 10px; border: 0; border-radius: 9px; background: transparent; color: #203c55; cursor: grab; text-align: left; box-shadow: none; }
.ledger-file-open:hover { background: #e9f4fc; }
.ledger-file-badge { display: inline-block; font-weight: 700; font-size: 11px; padding: 4px 6px; border-radius: 5px; background: #e7edf4; color: #3d5b77; }
.ledger-file-badge.image { background: #e0f3e9; color: #157558; }
.ledger-file-name { width: 100%; font-size: 12px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ledger-file-preview-hint { font-size: 10px; color: #708297; }
.ledger-ribbon-empty { align-self: center; padding: 15px; color: #60758a; font-size: 13px; }
.ledger-ribbon-footer { display: flex; align-items: center; justify-content: space-between; font-size: 12px; gap: 8px; }
.ledger-ribbon-footer button { font-size: 12px; padding: 4px 8px; }
.ledger-new-expense-bar { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.ledger-new-expense-bar > label { width: 170px; flex-shrink: 0; font-size: 12px; margin: 0; }
.ledger-new-expense-bar input { padding: 7px; font-size: 12px; }
.ledger-new-expense-drop { display: flex; gap: 10px; align-items: center; justify-content: center; flex: 1; min-height: 60px; margin: 0; padding: 10px 16px; border: 1px dashed #65a6bb; border-radius: 9px; background: #edf7fb; color: #21566f; box-shadow: none; }
.ledger-new-expense-drop > span:first-child { font-size: 26px; line-height: 1; }
.ledger-new-expense-drop small { display: block; font-size: 11px; font-weight: normal; margin-top: 3px; }
.ledger-file-preview { overflow: hidden; border: 1px solid #d3dfe9; border-radius: 9px; background: white; min-width: 0; }
.ledger-preview-header { display: flex; align-items: center; gap: 8px; justify-content: space-between; padding: 8px 10px; border-bottom: 1px solid #e3eaf1; }
.ledger-preview-header strong { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; }
.ledger-preview-header button { font-size: 11px; padding: 4px 7px; flex-shrink: 0; }
#ledger-preview-content { height: 195px; overflow: auto; display: flex; align-items: center; justify-content: center; }
#ledger-preview-content p { padding: 16px; font-size: 12px; }
#ledger-preview-content img { width: 100%; height: 100%; object-fit: contain; }
#ledger-preview-content iframe { width: 100%; height: 100%; border: 0; }
#ledger-preview-content pre { align-self: flex-start; width: 100%; margin: 0; padding: 10px; font-size: 11px; white-space: pre-wrap; overflow-wrap: anywhere; color: #364b60; }
.ledger-drag-guide { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 12px; border-radius: 8px; background: #f1f7fa; color: #46627a; font-size: 12px; }
.ledger-drag-guide > span:first-child { font-size: 22px; }
.ledger-unlink-drop { display: flex; align-items: center; gap: 6px; border: 1px dashed #a6bacb; padding: 7px 10px; margin-left: auto; }
.ledger-unlink-drop small { font-size: 10px; color: #526579; font-weight: normal; }
#ledger-drag-status { flex-basis: 100%; font-weight: 600; color: #136b54; }
#ledger-drag-status:empty { display: none; }
.ledger-row-label { display: flex; align-items: center; gap: 7px; }
.ledger-table .ledger-row-handle { width: 24px; min-width: 24px; padding: 4px 1px; margin: 0; border: 0; background: transparent; color: #607f97; font-size: 23px; line-height: 1; cursor: grab; box-shadow: none; }
.ledger-row-handle:active, .ledger-file-card:active { cursor: grabbing; }
.ledger-row-handle:hover, .ledger-row-handle:focus { background: #cce7ed; color: #166e68; outline: 2px solid #228d83; border-radius: 4px; }
.ledger-row-selected > th { box-shadow: inset 3px 0 #168a70; }
.ledger-target > th { background: #e0f5ec !important; }
.ledger-row-dragging { opacity: .55; }
.ledger-drop { outline: 2px solid #168a70; outline-offset: -2px; background: #d6f5e9 !important; }
.ledger-drop > th { background: #b9ead5 !important; }
@media (max-width: 900px) {
    .ledger-ribbon-workspace { grid-template-columns: minmax(0, 1fr) 260px; }
    .ledger-ribbon-header .actions { width: 100%; }
}
@media (max-width: 650px) {
    .ledger-ribbon-workspace { grid-template-columns: minmax(0, 1fr); }
    #ledger-preview-content { height: 160px; }
    .ledger-new-expense-bar { flex-wrap: wrap; }
    .ledger-new-expense-bar > label { width: 100%; }
    .ledger-unlink-drop { margin-left: 0; }
}
/* Document review: keep the receipt next to the record being checked. */
#ledger-dialog { width: min(1180px, 96vw); max-height: 92vh; padding: 0; border: 0; border-radius: 18px; box-shadow: 0 24px 90px #10233755; }
#ledger-dialog > .section-header { position: sticky; top: 0; z-index: 4; margin: 0; padding: 18px 24px; background: #153c5a; color: white; }
#ledger-dialog-title { color: white; margin: 0; font-size: 20px; }
#ledger-dialog-body { padding: 20px; }
#ledger-dialog::backdrop { background: #102337aa; backdrop-filter: blur(4px); }
.ledger-review-layout { display: grid; grid-template-columns: minmax(290px, .85fr) minmax(420px, 1.4fr); gap: 20px; }
.ledger-review-list { min-width: 0; }
.ledger-record-summary { display: flex; flex-direction: column; gap: 8px; padding: 16px; border: 1px solid #d6e4ee; border-radius: 12px; background: #eef6fb; }
.ledger-record-summary strong { font-size: 18px; }
.ledger-record-summary span { font-size: 13px; color: #536b80; }
.ledger-option-card { border: 1px solid #dbe5ed; border-radius: 10px; margin-bottom: 9px; padding: 4px 9px 9px; background: white; }
.ledger-option-card:has(input:checked) { border-color: #168a70; background: #effaf5; box-shadow: inset 3px 0 #168a70; }
.ledger-option-card[hidden] { display: none; }
.ledger-option-card label { border: 0; padding: 10px 0; gap: 10px; cursor: pointer; }
.ledger-option-card label span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ledger-option-card small { display: block; color: #617589; margin-top: 5px; }
.ledger-option-card b { font-size: 13px; white-space: nowrap; }
.ledger-option-card input { flex: 0 0 auto; margin: 0; accent-color: #168a70; }
#ledger-dialog .ledger-options { max-height: 42vh; padding-right: 5px; }
.ledger-document { display: flex; align-items: center; gap: 8px; max-width: 100%; padding: 9px 12px; border: 1px solid #cbdce8; border-radius: 8px; background: #f3f8fc; color: #153c5a; font-size: 12px; text-align: left; overflow-wrap: anywhere; }
.ledger-document > span:first-child { font-size: 10px; font-weight: bold; background: #dceaf4; border-radius: 4px; padding: 5px; }
.ledger-dialog-footer { position: sticky; bottom: -20px; padding: 14px 0; background: white; border-top: 1px solid #dbe5ed; }
.ledger-review { min-width: 0; border: 1px solid #d5e1eb; border-radius: 12px; overflow: hidden; background: #edf1f5; align-self: start; position: sticky; top: 0; }
.ledger-review-toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 10px; background: white; border-bottom: 1px solid #d5e1eb; }
.ledger-review-toolbar strong { margin-right: auto; }
.ledger-review-toolbar button { padding: 6px 9px; font-size: 12px; }
#ledger-viewer-name { margin: 0; padding: 10px 14px; font-size: 12px; color: #536b80; overflow-wrap: anywhere; }
.ledger-viewer-content { height: 62vh; min-height: 320px; overflow: auto; text-align: center; padding: 16px; }
.ledger-viewer-content img { display: block; width: 100%; height: 100%; object-fit: contain; margin: auto; background: white; }
.ledger-viewer-content img.zoomed { max-width: none; height: auto; margin: 0; }
.ledger-viewer-content iframe { width: 100%; height: 100%; border: 0; background: white; }
.ledger-viewer-content pre { text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; background: white; padding: 16px; }
#ledger-preview-content { height: 310px; background: #edf1f5; padding: 10px; }
.ledger-file-open .ledger-thumbnail { width: 100%; height: 90px; object-fit: contain; background: #edf1f5; border-radius: 5px; }
@media (max-width: 850px) { .ledger-review-layout { grid-template-columns: 1fr; } .ledger-review { position: static; } .ledger-viewer-content { height: 55vh; } #ledger-dialog-body { padding: 12px; } #ledger-dialog > .section-header { padding: 14px; } }
