/* The assistant is one continuous workspace, including receipt review. */
body:has(#adviser.active) .top,body:has(#adviser.active) .app-header{display:none}
body:has(#adviser.active) .main{padding:24px 32px;max-width:none}
#adviser{max-width:1080px;margin-inline:auto}
#assistantChat{display:flex;flex-direction:column;height:calc(100dvh - 48px);min-height:260px;padding:0;overflow:hidden;border-radius:24px;background:var(--panel);box-shadow:var(--shadow)}
.chat-header{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:20px 26px;border-bottom:1px solid var(--line);flex-shrink:0}
.chat-identity{display:flex;gap:12px;align-items:center}.chat-avatar{display:grid;place-items:center;width:38px;height:38px;border-radius:13px;background:var(--accent-soft);color:var(--accent);font-size:22px;font-weight:700}
.chat-header h2{font-size:17px;margin:0}.chat-header p{font-size:12px;color:var(--muted);margin:2px 0 0}.chat-header .btn{padding:8px;font-size:12px}
#adviserAnswer.chat-log{display:flex;flex-direction:column;gap:24px;flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;padding:32px max(26px,calc((100% - 760px)/2));margin:0;scroll-padding-block:24px;scrollbar-width:thin}
.chat-message{flex-shrink:0;max-width:100%;font-size:15px;line-height:1.65;overflow-wrap:anywhere}.chat-speaker{display:block;font-size:11px;font-weight:650;color:var(--muted);margin:0 0 7px}.chat-text{white-space:pre-wrap;margin:0}
.chat-user{align-self:flex-end;max-width:85%;padding:12px 18px;background:var(--accent-soft);color:var(--ink);border-radius:20px 20px 6px 20px}.chat-user .chat-speaker{display:none}.chat-assistant{align-self:flex-start;width:100%}.chat-message h3{font-size:16px;margin:16px 0 8px}.chat-message h4{font-size:14px;margin:0 0 4px}
.chat-fact{padding:14px 0;border-bottom:1px solid var(--line)}.chat-fact p{white-space:pre-line;margin:0;font-size:14px;color:var(--muted)}.chat-message>.muted{font-size:12px;margin:12px 0 0}
.chat-suggestions{display:flex;gap:8px;flex-wrap:wrap;margin-top:14px}.chat-suggestions:empty{display:none}.chat-suggestions button{font:inherit;font-size:13px;color:var(--ink);background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:10px 14px;min-height:44px;text-align:left}.chat-suggestions button:hover{border-color:var(--accent);background:var(--accent-soft)}
.chat-change{margin-top:14px;padding:16px;border:1px solid var(--line);border-radius:16px}.chat-result{display:inline-block;font-size:11px;font-weight:650;letter-spacing:.02em;padding:4px 8px;border-radius:7px;color:var(--accent);background:var(--accent-soft)}.chat-result.saved{color:var(--green);background:var(--bg)}.chat-change>.adviser-card{border:0;padding:0;margin:12px 0}.chat-change table{font-size:12px}.chat-change details{font-size:12px}.chat-change pre{white-space:pre-wrap;max-height:200px;overflow:auto}
.chat-receipt{border:1px solid var(--line);background:var(--bg);border-radius:18px;padding:20px;margin-top:16px}.receipt-heading{display:flex;gap:20px;align-items:flex-start;justify-content:space-between}.receipt-heading>strong:first-child{max-width:65%}.receipt-amount{font-size:20px;line-height:1.3;text-align:right;white-space:nowrap;font-variant-numeric:tabular-nums}.receipt-amount small{font-size:11px;color:var(--muted)}.chat-receipt dl{margin:16px 0 0;display:grid;gap:7px;font-size:13px}.chat-receipt dl div{display:flex;gap:20px;justify-content:space-between}.chat-receipt dt{color:var(--muted)}.chat-receipt dd{margin:0;text-align:right}.chat-receipt ul{font-size:13px;padding-left:20px}.chat-receipt .muted{font-size:12px;margin:12px 0 0}.chat-review-actions{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin-top:12px}
.chat-review-actions.chat-actions-pinned{position:sticky;bottom:0;z-index:3;margin:12px -8px 0;padding:10px 8px calc(10px + env(safe-area-inset-bottom,0px));background:var(--panel);border-top:1px solid var(--line);border-radius:0 0 10px 10px}
@supports not (position:sticky){.chat-review-actions.chat-actions-pinned{position:static}}
.chat-ticket-details,.chat-budget-help{margin-top:10px}.chat-ticket-details>summary,.chat-budget-help>summary{cursor:pointer;font-size:13px;color:var(--muted);padding:6px 0}.chat-ticket-details[open]>summary,.chat-budget-help[open]>summary{color:var(--ink)}
.chat-composer{flex-shrink:0;padding:8px max(26px,calc((100% - 760px)/2)) 16px;background:var(--panel)}
#adviserAskForm.adviser-question{display:flex;align-items:flex-end;gap:6px;margin:0;padding:8px;border:1px solid var(--line);border-radius:24px;background:var(--bg);box-shadow:0 3px 12px #00000004}
#adviserAskForm:focus-within{border-color:var(--accent)}#adviserQuestion{display:block;flex:1;min-width:0;width:auto;min-height:44px;max-height:120px;height:44px;resize:none;margin:0!important;padding:11px 4px;border:0!important;border-radius:0;background:transparent;box-shadow:none;outline:none;font-size:16px!important;line-height:22px}
#adviserAskForm .chat-attach,#adviserAskForm .chat-send{display:grid;place-items:center;flex-shrink:0;width:44px;height:44px;min-height:44px;padding:0;border-radius:16px}.chat-attach{border:0;background:transparent;color:var(--muted)}#chatPhoto[hidden]{display:none!important}
#chatStatus{font-size:12px;color:var(--muted);margin:0 10px 8px;line-height:1.4}#chatStatus:empty{display:none}#chatStatus.error{color:var(--red)}.chat-caption{font-size:10px;color:var(--muted);text-align:center;margin:10px 0 0;line-height:1.5}.chat-history-note{font-size:12px;color:var(--muted);text-align:center}
.chat-photo{display:block;max-width:180px;max-height:210px;object-fit:contain;border-radius:12px;margin-bottom:8px}.chat-photo-label{display:block;font-size:12px;margin-bottom:8px}.chat-attachment{display:flex;align-items:center;gap:12px;font-size:12px;color:var(--muted);padding:10px}.chat-attachment:empty{display:none}.chat-attachment .chat-photo{width:40px;height:48px;object-fit:cover;margin:0;border-radius:6px}.chat-attachment button{margin-left:auto}
.assistant-details[hidden],#adviserGuide{display:none!important}#assistantDialog input[type=file][hidden]{display:none!important}
@media(max-width:800px),(max-width:1000px) and (pointer:coarse){body:has(#adviser.active){overflow:hidden}body:has(#adviser.active) .main{padding:0}body:has(#adviser.active) .app-header{display:none}#adviser{position:fixed;inset:0;z-index:15}#assistantChat{position:absolute;inset:var(--chat-offset,0px) 0 auto;height:calc(var(--chat-viewport,100dvh) - 78px - env(safe-area-inset-bottom));min-height:180px;border:0;border-radius:0;box-shadow:none}.chat-header{padding:calc(12px + env(safe-area-inset-top)) 18px 12px}.chat-header .btn span{display:none}.chat-header h2{font-size:16px}#adviserAnswer.chat-log{padding:24px 20px;gap:24px}.chat-composer{padding:6px 12px 12px}.chat-caption{font-size:10px;margin:8px 8px 0}.chat-user{max-width:88%}.chat-message{font-size:15px}.chat-receipt{padding:16px}.chat-review-actions .primary{flex:1 1 100%}.chat-change{padding:12px}.chat-change .adviser-guide-actions{display:flex;flex-wrap:wrap;gap:8px}#assistantChat.keyboard-open{height:var(--chat-viewport,100dvh)}body:has(#assistantChat.keyboard-open) #bottomNav{display:none}#assistantChat.keyboard-open .chat-caption{display:none}}
@media(prefers-reduced-motion:reduce){#assistantChat *{scroll-behavior:auto!important;animation:none!important}}

/* Grouped documents remain in the conversation and can be removed individually. */
.chat-photo-grid{display:flex;flex-wrap:wrap;gap:8px;max-width:420px}.chat-photo-grid .chat-photo{max-width:120px;max-height:160px;margin:0 0 8px;object-fit:contain}.chat-attachment{flex-wrap:wrap;padding:8px 4px;gap:10px}.chat-attachment>span{font-size:12px;flex:1;min-width:100px}.attachment-item{position:relative;flex:0 0 64px}.chat-attachment .attachment-item .chat-photo{width:64px;height:72px;object-fit:cover;border:1px solid var(--line);border-radius:10px}.chat-attachment .attachment-item button{position:absolute;right:-8px;top:-9px;margin:0;width:30px;height:30px;min-width:30px;min-height:30px;background:var(--surface,var(--bg));border:1px solid var(--line);font-size:20px;line-height:1}.chat-user:has(.chat-photo-grid){min-width:160px}

.chat-batch{min-width:0}.chat-batch>h3{font-size:1rem;margin:1rem 0}.chat-batch-entry{margin:1rem 0;padding-bottom:.75rem;border-bottom:1px solid var(--line,#d9dfdb)}.chat-batch-entry .chat-receipt{margin:.35rem 0}.chat-batch-entry>p{font-size:.82rem;margin:.35rem 0}.chat-batch-totals{background:var(--soft,#f2f6f3);border-radius:12px;padding:1rem;margin:.65rem 0}.chat-batch-totals p{margin:.4rem 0}.chat-change details{margin-top:.75rem}.chat-change summary{cursor:pointer;font-size:.85rem}.chat-batch .receipt-heading{flex-wrap:wrap;gap:.4rem}.chat-batch .receipt-heading>strong:first-child{overflow-wrap:anywhere}

.chat-header-actions{display:flex;gap:4px;flex-shrink:0}.chat-entry-controls{display:flex;justify-content:flex-end;padding:0 6px 6px}.chat-clear-confirm{padding:14px 20px;background:var(--panel);border-bottom:1px solid var(--line);font-size:14px;flex-shrink:0}.chat-clear-confirm p{margin:0 0 10px}.chat-clear-confirm>div{display:flex;justify-content:flex-end;gap:8px;flex-wrap:wrap}#chatEntryControls[hidden],#chatClearConfirm[hidden]{display:none!important}


/* Keep image paste within reach on mobile, alongside the batch stop control. */
.chat-composer-actions{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:4px}.chat-composer-actions .chat-entry-controls{margin-left:auto;padding:0}.chat-composer-actions .text-button{min-height:44px;padding:8px 10px;font-size:13px}#chatPasteImage[hidden]{display:none!important}

.chat-text{white-space:normal}.chat-text p{white-space:pre-wrap;margin:0 0 .8em}.chat-text>:last-child{margin-bottom:0}.chat-text h3{font-size:1.05em;margin:1.2em 0 .5em}.chat-text h3:first-child{margin-top:0}.chat-text ul,.chat-text ol{margin:.4em 0 1em;padding-left:1.4em}.chat-text li{margin:.25em 0}.chat-text pre{overflow-x:auto;white-space:pre;padding:12px;border-radius:10px;background:var(--bg)}.chat-table-wrap{max-width:100%;overflow-x:auto;margin:.75em 0 1em}.chat-table-wrap table{width:100%;border-collapse:collapse;font-size:.94em}.chat-table-wrap th,.chat-table-wrap td{text-align:left;vertical-align:top;padding:8px;border-bottom:1px solid var(--line)}.chat-table-wrap th{font-weight:650}.chat-text hr{border:0;border-top:1px solid var(--line);margin:1em 0}
@media(max-width:640px){.chat-table-wrap thead{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}.chat-table-wrap table,.chat-table-wrap tbody,.chat-table-wrap tr,.chat-table-wrap td{display:block}.chat-table-wrap tr{border:1px solid var(--line);border-radius:10px;margin-bottom:10px;padding:6px 10px}.chat-table-wrap td{display:flex;gap:12px;justify-content:space-between;padding:5px 0;border:0}.chat-table-wrap td:before{content:attr(data-label);color:var(--muted);flex:0 0 34%;font-weight:500}}

/* iOS keyboard resize: only the log scrolls; no stale smooth-scroll target. */
#adviserAnswer.chat-log{overflow-anchor:none;scroll-behavior:auto}
#assistantChat .chat-header,#assistantChat .chat-composer{position:relative;z-index:1}

.attachment-item>span{display:block;max-width:64px;max-height:3.6em;overflow:hidden;overflow-wrap:anywhere;font-size:.65rem;line-height:1.2;color:var(--muted)}
