/* Lists, forms and detail pages. Builds on the tokens in site.css. */

.page-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.page-bar .spacer { flex: 1; }
.page-bar p { margin: 0; color: var(--muted); font-size: .9rem; }

.back-link { display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; font-weight: 700; font-size: .85rem; text-decoration: none; color: var(--ink-2); }
.back-link:hover { color: var(--emerald-700); }

.search { position: relative; flex: 1 1 240px; max-width: 360px; }
.search .icon { position: absolute; left: .85rem; top: 50%; translate: 0 -50%; color: var(--muted); pointer-events: none; }
.search .form-control { padding-left: 2.6rem; background: #fff; }

.filter-tabs { display: flex; gap: .35rem; padding: .25rem; background: #e9eeea; border-radius: 12px; overflow-x: auto; }
.filter-tabs a { padding: .45rem .85rem; border-radius: 9px; font-size: .82rem; font-weight: 700; color: var(--ink-2); text-decoration: none; white-space: nowrap; }
.filter-tabs a.active { background: #fff; color: var(--forest-900); box-shadow: var(--shadow-sm); }

.pill { display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .6rem; border-radius: 99px; font-size: .74rem; font-weight: 700; white-space: nowrap; background: var(--grey-50); color: #55655d; }
.pill-on { background: var(--emerald-50); color: var(--emerald-700); }
.pill-warn { background: var(--amber-50); color: var(--amber); }
.pill-off { background: var(--red-50); color: var(--red); }
.pill-gold { background: var(--gold-50); color: var(--gold-700); }
.pill-dark { background: var(--forest-900); color: var(--gold-200); letter-spacing: .04em; }
.pills { display: flex; flex-wrap: wrap; gap: .3rem; }

.person { display: flex; align-items: center; gap: .75rem; min-width: 180px; }
.person .avatar { width: 36px; height: 36px; font-size: .74rem; background: var(--emerald-50); color: var(--emerald-700); }
.person-name { font-weight: 700; line-height: 1.2; color: var(--ink); text-decoration: none; }
a.person-name:hover, a.biz-name:hover { color: var(--emerald-700); text-decoration: underline; }
a.biz-name { color: var(--ink); text-decoration: none; }
.is-off .person-name, .is-off .biz-name { color: var(--muted); }
.is-off .avatar { filter: grayscale(1); opacity: .7; }

.row-menu > button { width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--ink-2); display: grid; place-items: center; }
.row-menu > button:hover, .row-menu > button[aria-expanded="true"] { background: var(--emerald-50); color: var(--emerald-700); }
.row-menu form { margin: 0; }
.dropdown-item.danger { color: var(--red); }
.dropdown-item.danger:hover { background: var(--red-50); color: var(--red); }

.pager { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .85rem 1.25rem; border-top: 1px solid var(--line-soft); font-size: .85rem; color: var(--muted); }
.pager .spacer { flex: 1; }
.pager a, .pager span.cur { min-width: 40px; height: 40px; display: inline-grid; place-items: center; padding: 0 .6rem; border-radius: 10px; font-weight: 700; text-decoration: none; color: var(--ink-2); }
.pager a:hover { background: var(--emerald-50); }
.pager span.cur { background: var(--forest-900); color: #fff; }

/* Forms */
.form-card { max-width: 720px; }
.form-card .panel-body { padding-top: 1.25rem; }
.form-section { padding: 1.25rem 0; border-top: 1px solid var(--line-soft); }
.form-section:first-of-type { border-top: 0; padding-top: 0; }
.form-section h3 { font-size: .95rem; margin: 0 0 .2rem; }
.form-section > p { font-size: .85rem; color: var(--muted); margin: 0 0 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.form-grid .full { grid-column: 1 / -1; }
.hint { font-size: .8rem; color: var(--muted); margin-top: .35rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: .6rem; padding-top: 1.25rem; border-top: 1px solid var(--line-soft); }
.form-control:disabled { background: var(--grey-50); color: var(--muted); }
.input-suffix, .input-prefix { position: relative; }
.input-suffix .form-control { padding-right: 2.4rem; }
.input-suffix > span { position: absolute; right: .9rem; top: 23px; translate: 0 -50%; color: var(--muted); font-weight: 700; pointer-events: none; }
.input-prefix .form-control { padding-left: 2rem; }
.input-prefix > span { position: absolute; left: .9rem; top: 23px; translate: 0 -50%; color: var(--muted); font-weight: 600; pointer-events: none; }

@media (max-width: 575.98px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: .5rem; }
.seg label { position: relative; display: block; padding: .85rem 1rem; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; }
.seg input { position: absolute; opacity: 0; }
.seg label strong { display: block; font-size: .92rem; }
.seg label span { font-size: .78rem; color: var(--muted); }
.seg label:has(input:checked) { border-color: var(--emerald-600); background: var(--emerald-50); box-shadow: 0 0 0 3px rgba(23, 153, 111, .12); }
.seg label:has(input:focus-visible) { outline: 3px solid rgba(201, 162, 74, .6); outline-offset: 2px; }

.check-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .6rem; }
.check-card { display: flex; align-items: center; gap: .7rem; min-height: 52px; padding: .6rem .85rem; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; font-weight: 600; }
.check-card input { width: 1.2em; height: 1.2em; flex: none; margin: 0; }
.check-card:has(input:checked) { border-color: var(--emerald-600); background: var(--emerald-50); }

.toggle-row { display: flex; align-items: center; gap: .85rem; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.toggle-row .form-check-input { width: 2.8em; height: 1.5em; margin: 0; flex: none; cursor: pointer; }
.toggle-row strong { display: block; font-size: .92rem; }
.toggle-row small { font-size: .8rem; color: var(--muted); }

/* One-time secrets and notes */
.callout { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; padding: 1rem 1.25rem; margin-bottom: 1rem; border-radius: var(--radius-lg); background: linear-gradient(135deg, var(--gold-50), #fff); border: 1px solid var(--gold-200); }
.callout-icon { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 14px; background: var(--gold-200); color: var(--gold-700); }
.callout-body { flex: 1 1 260px; min-width: 0; }
.callout-body strong { display: block; }
.callout-body p { margin: .15rem 0 0; font-size: .85rem; color: var(--ink-2); }
.secret { display: inline-flex; align-items: center; padding: .5rem .9rem; border-radius: 10px; background: var(--forest-900); color: var(--gold-200); font-family: ui-monospace, Consolas, monospace; font-size: 1.15rem; font-weight: 700; letter-spacing: .08em; user-select: all; }
.note { display: flex; gap: .6rem; padding: .75rem .9rem; border-radius: 10px; background: var(--emerald-50); color: var(--forest-800); font-size: .85rem; }
.note.gold { background: var(--gold-50); color: var(--gold-700); }

/* Detail pages */
.detail-head { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; padding: 1.25rem; }
.detail-head .avatar { width: 56px; height: 56px; font-size: 1.1rem; }
.detail-head .biz-code { font-size: .9rem; padding: .6rem .8rem; border-radius: 12px; }
.detail-head h2 { font-size: 1.35rem; margin: 0; }
.detail-head .meta { display: flex; flex-wrap: wrap; gap: .35rem 1rem; font-size: .85rem; color: var(--muted); margin-top: .2rem; }
.detail-head .meta span { display: inline-flex; align-items: center; gap: .35rem; }
.detail-head .actions { margin-left: auto; display: flex; gap: .5rem; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; margin: 0; background: var(--line-soft); border-top: 1px solid var(--line-soft); border-radius: 0 0 var(--radius-lg) var(--radius-lg); overflow: hidden; }
.fact { background: #fff; padding: .9rem 1.25rem; }
.fact dt { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.fact dd { margin: .2rem 0 0; font-size: 1.1rem; font-weight: 800; }

.share-meter { display: flex; height: 14px; border-radius: 99px; overflow: hidden; gap: 3px; background: var(--grey-50); }
.share-meter i { display: block; min-width: 4px; border-radius: 99px; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; margin-top: .75rem; font-size: .88rem; }
.legend span { display: inline-flex; align-items: center; gap: .4rem; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
.c-owner { background: var(--emerald-500); }
.c-p0 { background: var(--gold-500); }
.c-p1 { background: #2f6f9f; }
.c-p2 { background: #8e5ea8; }
.c-p3 { background: #c8553d; }

.link-card { padding: 1.25rem; scroll-margin-top: calc(var(--topbar-h) + 1rem); }
.link-card + .link-card { margin-top: 1rem; }
.link-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }
.link-card-head .ratio-now { margin-left: auto; text-align: right; }
.ratio-big { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.ratio-big small { font-size: .9rem; color: var(--muted); font-weight: 700; }
.sub-block { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line-soft); }
.sub-head { display: flex; align-items: center; gap: .75rem; margin-bottom: .5rem; }
.sub-head h4 { font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0; }
.sub-head .btn { margin-left: auto; }
.inline-form { margin-top: .75rem; padding: 1rem; border-radius: 12px; background: #f8faf8; border: 1px solid var(--line); }
.inline-form[hidden] { display: none; }
.mini-table { width: 100%; font-size: .87rem; }
.mini-table td { padding: .45rem .75rem .45rem 0; border-top: 1px solid var(--line-soft); vertical-align: top; }
.mini-table tr:first-child td { border-top: 0; }
.kv { display: flex; flex-wrap: wrap; gap: .5rem 2rem; font-size: .9rem; }
.kv div span { display: block; font-size: .75rem; color: var(--muted); font-weight: 600; }
.kv div strong { font-weight: 800; }

/* Masters */
.master-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; align-items: start; }
.master-list { list-style: none; margin: 0; padding: 0; }
.master-list > li { padding: .4rem 1.25rem; border-top: 1px solid var(--line-soft); }
.master-row { display: flex; align-items: center; gap: .25rem; min-height: 44px; }
.master-row .name { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.master-list li.is-off .name { color: var(--muted); text-decoration: line-through; }
.master-list form.rename { display: flex; gap: .5rem; padding: .25rem 0 .5rem; }
.master-list form.rename[hidden] { display: none; }
.master-add { display: flex; gap: .5rem; padding: .85rem 1.25rem 1.1rem; border-top: 1px solid var(--line-soft); }
.btn-ghost { --bs-btn-color: var(--ink-2); --bs-btn-hover-bg: var(--emerald-50); --bs-btn-hover-color: var(--emerald-700); --bs-btn-border-color: transparent; --bs-btn-hover-border-color: transparent; --bs-btn-active-bg: var(--emerald-100); --bs-btn-active-border-color: transparent; }

/* Modal */
.modal-content { border: 0; border-radius: var(--radius-lg); box-shadow: 0 30px 60px -20px rgba(5, 36, 28, .5); }
.modal-body { padding: 1.5rem 1.5rem .5rem; }
.modal-body h2 { font-size: 1.15rem; margin: 0 0 .4rem; }
.modal-body p { color: var(--ink-2); margin: 0; }
.modal-footer { border: 0; padding: 1rem 1.5rem 1.5rem; }
.btn-danger { --bs-btn-bg: var(--red); --bs-btn-border-color: var(--red); --bs-btn-hover-bg: #a5332d; --bs-btn-hover-border-color: #a5332d; }

/* Two-step login + setup wizard */
.bare-wide { max-width: 760px; }
.bare-brand { display: flex; align-items: center; justify-content: center; gap: .7rem; margin-bottom: 1.25rem; font-weight: 800; font-size: 1.25rem; color: var(--forest-900); }
.bare-brand img { width: 42px; height: 42px; }
.bare-brand span { color: var(--gold-600); }
.bare-card.left { text-align: left; }
.bare-card.left h1 { margin-top: 0; }
.otp-input { text-align: center; font-size: 1.6rem; font-weight: 800; letter-spacing: .35em; padding-left: .35em; min-height: 60px; }
.qr-wrap { display: grid; grid-template-columns: auto 1fr; gap: 1.5rem; align-items: center; }
.qr { width: 190px; padding: .5rem; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.qr svg { display: block; width: 100%; height: auto; }
.steps { counter-reset: step; list-style: none; margin: 0; padding: 0; }
.steps li { counter-increment: step; position: relative; padding: 0 0 .9rem 2.5rem; font-size: .92rem; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: -.1rem; width: 1.75rem; height: 1.75rem; display: grid; place-items: center; border-radius: 50%; background: var(--forest-900); color: var(--gold-200); font-weight: 800; font-size: .8rem; }
.key-text { font-family: ui-monospace, Consolas, monospace; font-weight: 700; word-break: break-all; }
.code-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; padding: 1rem; border-radius: 12px; background: var(--forest-900); color: var(--gold-200); font-family: ui-monospace, Consolas, monospace; font-weight: 700; font-size: 1rem; text-align: center; }

@media (max-width: 575.98px) { .qr-wrap { grid-template-columns: 1fr; justify-items: center; } }

/* ══ Entries, works, proof ═══════════════════════════════════════ */

.top-search { position: relative; flex: 0 1 300px; }
.top-search .icon { position: absolute; left: .8rem; top: 50%; translate: 0 -50%; color: var(--muted); pointer-events: none; }
.top-search .form-control { min-height: 44px; padding-left: 2.5rem; border-radius: 12px; background: #fff; font-size: .9rem; }
.top-search-link { display: none; text-decoration: none; }

@media (max-width: 991.98px) {
    .top-search { display: none; }
    .top-search-link { display: grid; }
}

a.ref { color: var(--forest-800); text-decoration: none; }
a.ref:hover { color: var(--emerald-600); text-decoration: underline; }
a.sort { color: inherit; text-decoration: none; }
a.sort:hover { color: var(--forest-800); }

.filters > summary { display: flex; align-items: center; gap: .5rem; min-height: 48px; padding: 0 1.25rem; font-weight: 700; font-size: .9rem; cursor: pointer; list-style: none; }
.filters > summary::-webkit-details-marker { display: none; }
.filters > summary::after { content: ''; margin-left: auto; width: .55rem; height: .55rem; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); rotate: 45deg; transition: rotate .15s; }
.filters[open] > summary::after { rotate: 225deg; }
.filters-body { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .85rem 1rem; padding: .25rem 1.25rem 1.25rem; align-items: end; }
.filters-actions { display: flex; gap: .5rem; }

.facts.totals { border-radius: 0; }

/* Entry form */
.entry-form { max-width: 640px; }
.type-seg label strong { display: flex; align-items: center; gap: .4rem; }
.type-seg .seg-income:has(input:checked) { border-color: var(--emerald-600); background: var(--emerald-50); }
.type-seg .seg-income:has(input:checked) strong { color: var(--emerald-700); }
.type-seg .seg-expense:has(input:checked) { border-color: var(--red); background: var(--red-50); box-shadow: 0 0 0 3px rgba(194, 65, 58, .1); }
.type-seg .seg-expense:has(input:checked) strong { color: var(--red); }

.amount-field .form-control { min-height: 64px; padding-left: 2.6rem; font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; }
.amount-field > span { top: 32px; left: 1rem; font-size: 1.5rem; }
body[data-entry-type="1"] .amount-field .form-control { color: var(--emerald-700); }
body[data-entry-type="2"] .amount-field .form-control { color: var(--red); }

.more { border: 1px solid var(--line); border-radius: 12px; padding: 0 1rem; }
.more[open] { padding-bottom: 1rem; }
.more > summary { min-height: 48px; display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: .9rem; cursor: pointer; list-style: none; }
.more > summary::-webkit-details-marker { display: none; }
.more > summary::before { content: '+'; width: 1.4rem; height: 1.4rem; display: grid; place-items: center; border-radius: 50%; background: var(--emerald-50); color: var(--emerald-700); font-weight: 800; }
.more[open] > summary::before { content: '−'; }

.btn-lg { --bs-btn-padding-x: 1.6rem; min-height: 52px; font-size: 1rem; }

@media (max-width: 575.98px) {
    /* Submit stays in reach of the thumb. */
    .sticky-actions { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); margin-inline: -1.25rem; padding: .75rem 1.25rem; background: #fff; box-shadow: 0 -10px 20px -16px rgba(16, 35, 28, .4); z-index: 5; }
    .sticky-actions { flex-wrap: nowrap; }
    .sticky-actions .btn-lg { flex: 2 1 0; --bs-btn-padding-x: .75rem; }
    .sticky-actions .btn-light { flex: 1 1 0; white-space: nowrap; }
    .sticky-actions .btn-ghost { display: none; } /* Back at the top already cancels */
}

/* Proof input */
.proof-zone { display: flex; flex-wrap: wrap; align-items: center; gap: .85rem 1rem; padding: 1rem; border: 2px dashed #c9d6cd; border-radius: 14px; background: #fafcfa; transition: border-color .15s, background .15s; }
.proof-zone.is-over { border-color: var(--gold-500); background: var(--gold-50); }
.proof-zone-icon { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--emerald-50); color: var(--emerald-700); }
.proof-zone-text { flex: 1 1 200px; min-width: 0; }
.proof-zone-text strong { display: block; font-size: .92rem; }
.proof-zone-text span { font-size: .8rem; color: var(--muted); }
.proof-buttons { display: flex; flex-wrap: wrap; gap: .5rem; }
.proof-buttons label { cursor: pointer; margin: 0; }
kbd { padding: .1rem .4rem; border-radius: 6px; border: 1px solid var(--line); border-bottom-width: 2px; background: #fff; color: var(--ink-2); font-size: .75rem; font-family: inherit; font-weight: 700; }

/* Camera and "paste here" wording only make sense on their device type. */
.proof-camera { display: none; }
@media (hover: none) and (pointer: coarse) {
    .proof-camera { display: inline-flex; }
    .proof-zone-text strong kbd { display: none; }
}

.proof-list { display: flex; flex-wrap: wrap; gap: .6rem; list-style: none; margin: .75rem 0 0; padding: 0; }
.proof-list:empty { margin: 0; }
.proof-list li { position: relative; width: 92px; }
.proof-thumb { display: grid; place-items: center; width: 92px; height: 92px; border-radius: 12px; border: 1px solid var(--line); background: var(--grey-50); overflow: hidden; position: relative; }
.proof-thumb img { width: 100%; height: 100%; object-fit: cover; }
.proof-pdf { padding: .25rem .5rem; border-radius: 6px; background: var(--red); color: #fff; font-size: .7rem; font-weight: 800; letter-spacing: .05em; }
.proof-name { display: block; margin-top: .25rem; font-size: .7rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proof-bar { position: absolute; inset: auto 6px 6px 6px; height: 5px; border-radius: 99px; background: rgba(255, 255, 255, .7); overflow: hidden; }
.proof-bar i { display: block; height: 100%; width: 5%; background: var(--emerald-600); transition: width .15s; }
.is-uploading .proof-thumb img { opacity: .45; }
.proof-remove { position: absolute; top: -8px; right: -8px; width: 28px; height: 28px; border: 2px solid #fff; border-radius: 50%; background: var(--forest-900); color: #fff; font-size: 1rem; line-height: 1; display: grid; place-items: center; cursor: pointer; }
.proof-remove:hover { background: var(--red); }
.proof-dup { display: block; margin-top: .2rem; padding: .15rem .35rem; border-radius: 6px; background: var(--amber-50); color: var(--amber); font-size: .66rem; font-weight: 700; line-height: 1.25; }
.proof-list li.is-failed { width: auto; max-width: 260px; display: flex; align-items: center; gap: .5rem; padding: .5rem 2rem .5rem .6rem; border-radius: 10px; background: var(--red-50); }
.proof-list li.is-failed .proof-thumb { display: none; }
.proof-list li.is-failed .proof-name { margin: 0; color: var(--red); white-space: normal; font-weight: 600; font-size: .78rem; }
.proof-list li.is-failed .proof-remove { top: 50%; right: 4px; translate: 0 -50%; border: 0; }

.proof-compact { display: flex; align-items: center; gap: .4rem; }
.proof-compact .proof-attach { cursor: pointer; margin: 0; min-width: 44px; }
.proof-compact.has-files .proof-attach { border-color: var(--emerald-500); color: var(--emerald-700); background: var(--emerald-50); }
.proof-compact .proof-list { margin: 0; flex-wrap: nowrap; gap: .3rem; }
.proof-compact .proof-list li { width: 36px; }
.proof-compact .proof-thumb { width: 36px; height: 36px; border-radius: 8px; }
.proof-compact .proof-name, .proof-compact .proof-dup { display: none; }
.proof-compact .proof-remove { width: 18px; height: 18px; font-size: .7rem; top: -6px; right: -6px; border-width: 1px; }
.proof-compact .proof-pdf { font-size: .5rem; padding: .1rem .25rem; }
.proof-compact .proof-message { position: absolute; }

/* Proof gallery on detail pages */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .75rem; list-style: none; margin: 0; padding: 0; }
.gallery a { display: block; aspect-ratio: 1; border-radius: 14px; border: 1px solid var(--line); overflow: hidden; background: var(--grey-50); }
.gallery a:hover { border-color: var(--emerald-500); }
.gallery img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.gallery .gallery-file { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem; padding: .5rem; text-align: center; text-decoration: none; word-break: break-all; }

.timeline { list-style: none; margin: 0 0 0 6px; padding: 0; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 1rem 1.25rem; font-size: .9rem; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ''; position: absolute; left: -7px; top: .3rem; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--muted); }
.timeline li.ok::before { border-color: var(--emerald-600); }
.timeline li.bad::before { border-color: var(--red); }
.timeline li.wait::before { border-color: var(--gold-500); }
.timeline li span { display: block; font-size: .78rem; color: var(--muted); }

/* Viewer */
.viewer { position: fixed; inset: 0; z-index: 2000; display: none; grid-template-columns: auto 1fr auto; grid-template-rows: auto 1fr; background: rgba(5, 20, 15, .94); color: #fff; }
.viewer.is-open { display: grid; }
.viewer-open { overflow: hidden; }
.viewer-bar { grid-column: 1 / -1; display: flex; align-items: center; gap: .4rem; padding: .6rem .8rem; }
.viewer-caption { flex: 1; min-width: 0; font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-bar button, .viewer-bar a, .viewer-nav { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border: 0; border-radius: 12px; background: rgba(255, 255, 255, .1); color: #fff; font-size: 1.25rem; text-decoration: none; cursor: pointer; }
.viewer-bar button:hover, .viewer-bar a:hover, .viewer-nav:hover { background: rgba(255, 255, 255, .22); color: #fff; }
.viewer-stage { grid-column: 2; position: relative; overflow: hidden; min-height: 0; touch-action: none; }
.viewer-stage img { position: absolute; inset: 0; margin: auto; max-width: 100%; max-height: 100%; user-select: none; transition: transform .12s; }
.viewer-nav { align-self: center; margin: 0 .6rem; font-size: 1.8rem; }
.viewer-nav.prev { grid-column: 1; grid-row: 2; }
.viewer-nav.next { grid-column: 3; grid-row: 2; }
.viewer-nav[hidden] { display: none; }

/* Quick multi-entry */
.quick-head { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.quick-line { display: grid; grid-template-columns: 1.75rem 8.5rem minmax(9rem, 1.1fr) 9.5rem minmax(8rem, 1.6fr) auto 2.5rem; gap: .5rem; align-items: start; padding: .7rem 1.25rem; border-bottom: 1px solid var(--line-soft); }
.quick-no { align-self: center; font-size: .78rem; font-weight: 800; color: var(--muted); text-align: center; }
.quick-line .form-control, .quick-line .form-select { min-height: 44px; }
.quick-line .field-error:empty { display: none; }
.quick-proof { align-self: center; position: relative; }
.quick-remove { align-self: center; font-size: 1.2rem; }
.quick-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; padding: 1rem 1.25rem; }
.quick-totals { display: flex; gap: 1.75rem; margin: 0 0 0 auto; }
.quick-totals dt { font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.quick-totals dd { margin: 0; font-size: 1.1rem; font-weight: 800; }

@media (max-width: 991.98px) {
    .quick-head { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .quick-line { grid-template-columns: 1.5rem 1fr 1fr 2.5rem; }
    .quick-line .quick-no { grid-row: 1; }
    .quick-line .quick-type { grid-column: 2; }
    .quick-line .quick-amount { grid-column: 3; grid-row: 1; }
    .quick-line .quick-remove { grid-column: 4; grid-row: 1; }
    .quick-line .quick-cat { grid-column: 2 / 4; }
    .quick-line .quick-desc { grid-column: 2 / 4; }
    .quick-line .quick-proof { grid-column: 2 / 4; }
    .quick-totals { margin-left: 0; gap: 1.1rem; }
}

@media (max-width: 575.98px) { .quick-head { grid-template-columns: minmax(0, 1fr); } }

.truncate-sm { max-width: 170px; }

@media (max-width: 575.98px) {
    .biz-switch select { max-width: 38vw; }
    .detail-head .actions { margin-left: 0; flex-wrap: wrap; width: 100%; }
}

/* ══ Milestone 3: approvals, ledger, periods, notifications ═══════ */

/* Notification bell */
.bell-menu { position: relative; }
.bell-menu .icon-btn { position: relative; }
.bell-count { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 99px; background: var(--red); color: #fff; font-size: .62rem; font-weight: 800; display: grid; place-items: center; border: 2px solid #fff; }
.bell-dropdown { width: 360px; max-width: calc(100vw - 2rem); padding: 0; overflow: hidden; }
.bell-head { display: flex; align-items: center; justify-content: space-between; padding: .85rem 1rem; font-weight: 800; font-size: .85rem; border-bottom: 1px solid var(--line-soft); }
.btn-link-sm { border: 0; background: none; padding: 0; color: var(--emerald-700); font-weight: 700; font-size: .78rem; cursor: pointer; }
.btn-link-sm:hover { text-decoration: underline; }
.bell-empty { padding: 1.5rem 1rem; text-align: center; color: var(--muted); font-size: .85rem; }
.bell-item-form { margin: 0; }
.bell-item { display: flex; align-items: flex-start; gap: .6rem; width: 100%; padding: .7rem 1rem; border: 0; background: none; text-align: left; cursor: pointer; border-bottom: 1px solid var(--line-soft); }
.bell-item:hover { background: var(--emerald-50); }
.bell-dot { flex: none; width: 8px; height: 8px; margin-top: .4rem; border-radius: 50%; background: transparent; }
.bell-item.is-unread .bell-dot { background: var(--gold-500); }
.bell-item-body { min-width: 0; }
.bell-item-title { display: block; font-weight: 700; font-size: .85rem; }
.bell-item.is-unread .bell-item-title { color: var(--forest-900); }
.bell-item-msg { display: block; font-size: .8rem; color: var(--ink-2); white-space: normal; }
.bell-item-time { display: block; font-size: .7rem; color: var(--muted); margin-top: .15rem; }
.bell-foot { display: block; padding: .7rem; text-align: center; font-weight: 700; font-size: .82rem; color: var(--emerald-700); text-decoration: none; }
.bell-foot:hover { background: var(--emerald-50); }

@media (max-width: 575.98px) { .bell-dropdown { width: calc(100vw - 1.5rem); } }

/* Approval inbox */
.bulk-bar { display: flex; align-items: center; gap: .75rem; padding: .7rem 1.25rem; background: var(--gold-50); border-bottom: 1px solid var(--gold-200); font-size: .85rem; font-weight: 700; }
.bulk-bar[hidden] { display: none; }
.select-col { width: 2.5rem; }
.form-check-lg { width: 1.2em; height: 1.2em; cursor: pointer; }
.proof-thumb-sm { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; overflow: hidden; background: var(--grey-50); border: 1px solid var(--line); vertical-align: middle; }
.proof-thumb-sm img { width: 100%; height: 100%; object-fit: cover; }

/* Ledger */
/* A text action that sits inside a hint line (e.g. "Pending balance: ₹5,44,525  Pay all"). */
.link-button { border: 0; background: none; padding: 0; font: inherit; font-weight: 700; color: var(--emerald-700); text-decoration: underline; cursor: pointer; }
.link-button:hover { color: var(--forest-800); }

.ledger-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.ledger-total { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 1rem 1.25rem; }
.ledger-total-label { display: flex; align-items: center; gap: .45rem; font-size: .8rem; font-weight: 700; color: var(--muted); }
.ledger-total-value { display: block; margin-top: .35rem; font-size: 1.45rem; font-weight: 800; }
.ledger-total-note { display: block; font-size: .75rem; color: var(--muted); }

.ledger-head { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; align-items: end; margin-bottom: 1rem; }
.ledger-section-title { display: flex; align-items: center; gap: .6rem; padding: 1rem 1.25rem .5rem; }
.ledger-section-title h2 { font-size: .95rem; margin: 0; }
.table-ps tfoot.opening td { background: var(--grey-50); font-style: italic; color: var(--ink-2); font-weight: 700; }

/* Period grid */
.period-grid-wrap { overflow-x: auto; }
.period-grid { border-collapse: collapse; width: 100%; font-size: .85rem; }
.period-grid th, .period-grid td { padding: .6rem .9rem; border: 1px solid var(--line-soft); text-align: center; white-space: nowrap; }
.period-grid thead th { background: #f8faf8; font-weight: 700; position: sticky; top: 0; }
.period-grid tbody th { text-align: left; font-weight: 700; background: #f8faf8; position: sticky; left: 0; }
.period-cell { display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .6rem; border-radius: 99px; font-weight: 700; font-size: .78rem; cursor: pointer; border: 0; }
.period-cell.is-closed { background: var(--forest-900); color: var(--gold-200); }
.period-cell.is-open { background: var(--emerald-50); color: var(--emerald-700); }
.period-cell:hover { filter: brightness(1.08); }

/* Share breakdown */
.share-breakdown td.num { font-variant-numeric: tabular-nums; }
.share-breakdown tfoot td { font-weight: 800; border-top: 2px solid var(--line); }

/* Overdraw / reversal callouts reuse .callout; a couple of tone variants */
.callout.warn { background: linear-gradient(135deg, var(--amber-50), #fff); border-color: #f0dca3; }
.callout.warn .callout-icon { background: #f0dca3; color: var(--amber); }

/* Reason textarea inside modals */
.modal-body textarea, .modal-body input.form-control { margin-top: .75rem; }
.modal-body label { font-weight: 700; font-size: .85rem; display: block; margin-top: 1rem; margin-bottom: .3rem; }

.tab-badge { margin-left: .4rem; }

/* Notifications list page */
.notif-row { display: flex; align-items: flex-start; gap: .75rem; padding: .5rem 0; cursor: pointer; }
.bell-dot.is-unread { background: var(--gold-500); }
.master-list li.is-unread-row { background: var(--emerald-50); }
