* { box-sizing: border-box; }
html { height: 100%; }
body { min-height: 100%; margin: 0; color: var(--text); background: var(--canvas); font: 15px/1.55 var(--font); letter-spacing: 0; }
.public-beta-notice { position: relative; z-index: 20; padding: 10px 18px; border-bottom: 1px solid #91bdb6; background: #e8f6f3; color: #123f3a; font-size: .82rem; line-height: 1.4; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { min-width: 0; }
button { touch-action: manipulation; }
a { color: var(--signal); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.skip-link { position: fixed; z-index: 1000; top: -60px; left: 16px; padding: 10px 14px; color: #fff; background: var(--sidebar); }
.skip-link:focus { top: 12px; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.staging-banner { max-width: 100vw; min-height: 34px; padding: 7px 16px; color: #71440b; background: #fff5df; border-bottom: 1px solid #ebd3a2; overflow-wrap: anywhere; text-align: center; font-size: 13px; font-weight: 700; }
.app-shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: calc(100vh - 34px); }
.sidebar { position: sticky; top: 0; display: flex; flex-direction: column; min-width: 0; height: calc(100vh - 34px); padding: 20px 12px 16px; color: #fff; background: var(--sidebar); }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 10px 18px; }
.brand img { width: 40px; height: 40px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 20px; }
.brand small { color: #b7c6c0; }
#primary-navigation { display: grid; gap: 4px; overflow-y: auto; padding: 4px 0 16px; scrollbar-color: #51665e transparent; }
.nav-section { border-bottom: 1px solid rgb(255 255 255 / 8%); }
.nav-group-button { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 11px 12px; color: #e7efec; background: transparent; border: 0; border-radius: 6px; cursor: pointer; text-align: left; font-weight: 750; }
.nav-group-button:hover { background: var(--sidebar-hover); }
.nav-group-button::after { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform 160ms ease; }
.nav-group-button[aria-expanded="true"]::after { transform: rotate(225deg); }
.nav-items { display: grid; gap: 2px; padding: 0 0 8px; }
.nav-items[hidden] { display: none; }
.nav-button { width: 100%; padding: 8px 12px 8px 24px; color: #bdcbc6; background: transparent; border: 0; border-radius: 6px; text-align: left; cursor: pointer; }
.nav-button:hover { color: #fff; background: var(--sidebar-hover); }
.nav-button[aria-current="page"] { color: var(--ink); background: var(--sidebar-active); box-shadow: inset 3px 0 var(--accent); font-weight: 750; }
.task-count-badge { display: inline-grid; place-items: center; min-width: 22px; height: 22px; margin-left: auto; padding: 0 6px; color: #fff; background: #a85d00; border: 1px solid #d99b43; border-radius: 999px; font-size: 12px; font-weight: 800; line-height: 1; }
.task-count-badge[hidden] { display: none; }
.sidebar-footer { display: grid; gap: 3px; margin-top: auto; padding: 14px 10px 0; color: #b7c6c0; border-top: 1px solid #40534b; font-size: 12px; }
.workspace { min-width: 0; width: 100%; max-width: calc(var(--content-max) + 68px); margin: 0 auto; padding: 28px 34px 44px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.topbar > div:first-of-type { min-width: 0; }
.topbar > .mobile-menu { order: 1; }
.topbar > div:not(.topbar-actions) { order: 2; min-width: 0; }
.topbar > .topbar-actions { order: 3; margin-left: auto; }
.eyebrow { margin: 0 0 4px; color: var(--accent); font-size: 12px; font-weight: 800; text-transform: uppercase; }
h1, h2, h3, p { letter-spacing: 0; overflow-wrap: anywhere; }
h1 { margin: 0; color: var(--ink); font-size: 30px; line-height: 1.2; }
h2 { margin: 0 0 14px; color: var(--ink); font-size: 22px; line-height: 1.3; }
h3 { margin: 0 0 8px; color: var(--ink); font-size: 16px; }
.topbar-actions, .button-row, .dialog-actions, .inline-actions { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.icon-button { display: inline-grid; place-items: center; width: 44px; min-width: 44px; height: 44px; min-height: 44px; padding: 0; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 50%; cursor: pointer; transition: background 140ms ease, border-color 140ms ease, transform 140ms ease; }
.icon-button:hover { background: var(--surface-subtle); border-color: var(--line-strong); transform: translateY(-1px); }
.icon-button svg, .chat-send svg, .copy-message svg, .conversation-menu summary svg, .lunar-reminder-menu summary svg, .answer-menu summary svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tasks-shortcut { color: var(--accent-dark); }
.profile-menu { position: relative; }
.profile-menu > summary { display: grid; place-items: center; width: 44px; min-width: 44px; height: 44px; min-height: 44px; list-style: none; cursor: pointer; }
.profile-menu > summary::-webkit-details-marker { display: none; }
.profile-initial { display: grid; place-items: center; width: 38px; height: 38px; color: var(--accent-dark); background: linear-gradient(135deg, var(--accent-soft), #d7e9ff); border: 1px solid #9dcfc1; border-radius: 50%; font-weight: 850; }
.profile-menu-popover { position: absolute; z-index: 12; top: calc(100% + 8px); right: 0; display: grid; min-width: 230px; gap: 12px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-md); }
.profile-menu:not([open]) > .profile-menu-popover { display: none; }
.profile-menu-popover p { display: grid; gap: 2px; margin: 0; }
.profile-menu-popover p span { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.profile-menu-popover .button { width: 100%; }
.profile-menu-links { display: grid; gap: 3px; padding: 8px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.profile-menu-label { padding: 0 9px 4px; color: var(--muted); font-size: 12px; font-weight: 760; text-transform: uppercase; }
.profile-route { min-height: 38px; padding: 7px 9px; color: var(--text); background: transparent; border: 0; border-radius: 5px; cursor: pointer; text-align: left; }
.profile-route:hover, .profile-route:focus-visible { background: var(--surface-subtle); }
.mobile-menu { display: none; }
.button { min-height: 42px; padding: 9px 15px; border: 1px solid transparent; border-radius: 999px; cursor: pointer; font-weight: 720; transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease; }
.button:hover:not([disabled]) { transform: translateY(-1px); }
.button.primary { color: #fff; background: var(--accent); box-shadow: var(--shadow-sm); }
.button.primary:hover { background: var(--accent-dark); box-shadow: 0 7px 16px rgb(8 127 104 / 20%); }
.button.secondary { color: var(--text); background: var(--surface); border-color: var(--line-strong); }
.button.secondary:hover { background: var(--surface-subtle); }
.button.quiet, .button.text-button { color: var(--accent-dark); background: transparent; border-color: transparent; }
.button.quiet:hover, .button.text-button:hover { background: var(--accent-soft); }
.button.danger { color: var(--danger); background: var(--surface); border-color: #dca4a2; }
.button[disabled] { opacity: .55; cursor: not-allowed; }
.live-status { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
#main-content { min-width: 0; }
#main-content:focus-visible { outline: none; }
.page-grid, .metric-grid, .split-grid, .action-grid, .insight-grid { display: grid; gap: 16px; }
.page-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }
.split-grid { grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); }
.split-grid > :only-child { grid-column: 1 / -1; }
.action-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.insight-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.panel, .metric-card, .action-card { min-width: 0; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.panel.wide { grid-column: 1 / -1; }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.billing-onboarding #billing-onboarding-load-error:focus-visible { outline: none; box-shadow: inset 3px 0 var(--focus); padding-left: 10px; }
.metric-card { position: relative; overflow: hidden; }
.metric-button { width: 100%; border: 1px solid var(--line); cursor: pointer; text-align: left; }
.metric-button:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.metric-card::before { position: absolute; top: 0; left: 0; width: 100%; height: 3px; content: ""; background: var(--accent); }
.metric-card .value { margin: 6px 0 2px; color: var(--ink); font-size: 27px; font-weight: 800; font-variant-numeric: tabular-nums; }
.metric-card .meta { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.action-card { display: grid; gap: 8px; text-align: left; }
.action-card .button { justify-self: start; margin-top: 4px; }
.muted, .helper { color: var(--muted); }
.helper { font-size: 13px; }
.notice, .error, .success-message { padding: 12px 14px; border-left: 4px solid var(--info); border-radius: 4px; background: var(--info-bg); }
.error { color: var(--danger); border-color: var(--danger); background: var(--danger-bg); }
.success-message { color: var(--success); border-color: var(--success); background: var(--success-bg); }
.tax-profile-save-toast { position: fixed; right: 18px; bottom: 18px; z-index: 80; display: grid; gap: 3px; width: min(360px, calc(100vw - 36px)); padding: 13px 15px; color: var(--success); background: var(--success-bg); border: 1px solid var(--success); border-radius: 8px; box-shadow: var(--shadow); }
.tax-profile-save-toast span { color: var(--text); font-size: 13px; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border: 1px solid currentColor; border-radius: 4px; font-size: 12px; font-weight: 750; }
.status.success { color: var(--success); background: var(--success-bg); }
.status.warning { color: var(--warning); background: var(--warning-bg); }
.status.danger { color: var(--danger); background: var(--danger-bg); }
.status.info, .status.neutral { color: var(--info); background: var(--info-bg); }
.connections-page { display: grid; gap: 28px; }
.unified-import-shortcut { min-height: 44px; white-space: nowrap; }
.unified-import-shortcut[hidden] { display: none !important; }
.marketplace-import-review[hidden] { display: none !important; }
.unified-import-short-label { display: none; }
.unified-import-dialog-content { width: min(620px, calc(100vw - 48px)); }
.connection-import-choices { display: grid; gap: 10px; margin: 18px 0; }
.connection-import-choice { display: grid; gap: 4px; width: 100%; min-height: 64px; padding: 12px 14px; color: var(--text); text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.connection-import-choice:hover { border-color: var(--accent); }
.connection-import-choice:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.connection-import-choice span { color: var(--muted); font-size: 13px; }
.connection-section { display: grid; gap: 14px; padding: 0 0 28px; border-bottom: 1px solid var(--line); }
.connection-section:last-of-type { padding-bottom: 0; border-bottom: 0; }
.connection-section-heading,
.connection-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.connection-section-heading h2,
.connection-card-heading h3,
.connection-card-heading p { margin-bottom: 0; }
.connection-section-heading > .muted { margin: 4px 0 0; }
.connection-card-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.connection-card { min-width: 0; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-sm); }
.tiktok-catalog-upload { min-width: 0; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.tiktok-catalog-upload .summary-list dd,
.tiktok-catalog-upload code { overflow-wrap: anywhere; word-break: break-word; }
.tiktok-catalog-preview,
.tiktok-catalog-readback { min-width: 0; }
.tiktok-catalog-evidence { margin-top: 14px; }
.connection-identity { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.connection-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 14px 0; }
.connection-facts > div { min-width: 0; }
.connection-facts dt { color: var(--muted); font-size: 12px; }
.connection-facts dd { margin: 3px 0 0; overflow-wrap: anywhere; }
.connection-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 14px 0; }
.connection-summary dt { color: var(--muted); font-size: 12px; }
.connection-summary dd { margin: 3px 0 0; }
.mailbox-details { margin-top: 14px; }
.mailbox-details > summary { width: max-content; color: var(--text-secondary); cursor: pointer; font-weight: 650; }
.mailbox-unresolved-failure { margin: 0 0 12px; overflow-wrap: anywhere; }
.mail-automation-setting { display: grid; gap: 12px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.mail-switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; }
.mail-switch span { display: grid; gap: 3px; }
.mail-switch small { color: var(--muted); font-weight: 400; }
.mail-switch-control { position: relative; display: inline-flex !important; align-items: center; gap: 9px; min-width: 72px; min-height: 44px; }
.mail-switch-control b { min-width: 22px; color: var(--text-secondary); font-size: .84rem; font-weight: 720; }
.mail-switch input { position: absolute; opacity: 0; pointer-events: none; }
.mail-switch i { position: relative; flex: 0 0 42px; width: 42px; height: 24px; border-radius: 999px; background: #303834; border: 1px solid #7b8983; transition: background 180ms ease, border-color 180ms ease; }
.mail-switch i::after { content: ''; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px; border-radius: 50%; background: #dce7e2; transition: transform 180ms ease, background 180ms ease; }
.mail-switch input:checked + i { background: var(--accent); border-color: var(--accent); }
.mail-switch input:checked + i::after { transform: translateX(18px); background: #06120e; }
.mail-switch input:checked ~ b { color: var(--accent); }
.mail-switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 3px; }
.connection-action-menu { position: relative; }
.connection-action-menu > summary { display: grid; place-items: center; width: 40px; height: 40px; color: var(--text-secondary); cursor: pointer; list-style: none; }
.connection-action-menu > summary::-webkit-details-marker { display: none; }
.connection-action-menu > summary svg { width: 20px; height: 20px; }
.connection-action-menu[open] > .button { position: absolute; z-index: 5; top: 44px; right: 0; min-width: 190px; background: var(--surface-strong); border: 1px solid var(--line-strong); }
.connection-empty { margin: 0; padding: 14px 0; color: var(--muted); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.connection-settings { position: relative; }
.connection-settings > summary { min-height: 42px; padding: 9px 15px; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 999px; cursor: pointer; font-weight: 720; list-style: none; }
.connection-settings > summary::-webkit-details-marker { display: none; }
.connection-settings[open] { flex-basis: 100%; padding: 12px; background: var(--surface-subtle); border-radius: 8px; }
.connection-settings[open] > summary { width: max-content; margin-bottom: 12px; }
.connection-state { font-weight: 800; }
.connection-state.connected { color: var(--success); }
.connection-state.disconnected { color: var(--danger); }
.table-wrap { max-width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.table-wrap:focus-within { outline: none; }
.table-wrap > table:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
table { width: 100%; min-width: 100%; table-layout: fixed; border-collapse: collapse; background: var(--surface); }
caption { padding: 12px; color: var(--muted); text-align: left; }
th, td { min-width: 0; padding: 11px 13px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; word-break: normal; text-align: left; vertical-align: top; }
th { color: var(--ink); background: var(--surface-subtle); }
tr:last-child td, tr:last-child th { border-bottom: 0; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label, fieldset legend { color: var(--ink); font-weight: 720; }
.field input, .field select, .field textarea { width: 100%; min-height: 44px; padding: 9px 11px; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 6px; }
.field textarea { min-height: 108px; resize: vertical; }
fieldset { min-width: 0; margin: 0 0 16px; padding: 14px; border: 1px solid var(--line); border-radius: 6px; }
.choice { display: flex; gap: 9px; align-items: flex-start; padding: 8px 0; }
.choice input { flex: 0 0 auto; margin-top: 4px; }
.choice-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.choice-card { position: relative; display: grid; gap: 5px; min-height: 112px; padding: 15px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.choice-card:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.choice-card input { position: absolute; top: 14px; right: 14px; }
.choice-card strong { padding-right: 28px; }
.progress-track { height: 7px; overflow: hidden; background: var(--surface-strong); border-radius: 4px; }
.progress-track > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--signal), var(--accent)); background-size: 180% 100%; transition: width 180ms ease; animation: lunar-gradient-shift 5s ease-in-out infinite; }
.progress-0 > span { width: 0; }
.progress-10 > span { width: 10%; }
.progress-20 > span { width: 20%; }
.progress-30 > span { width: 30%; }
.progress-40 > span { width: 40%; }
.progress-50 > span { width: 50%; }
.progress-60 > span { width: 60%; }
.progress-70 > span { width: 70%; }
.progress-80 > span { width: 80%; }
.progress-90 > span { width: 90%; }
.progress-100 > span { width: 100%; }
.step-meta { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; color: var(--muted); font-size: 13px; }
.empty { display: grid; justify-items: start; gap: 8px; min-height: 150px; padding: 24px; border: 1px dashed var(--line-strong); border-radius: 6px; background: var(--surface-subtle); }
.empty h3, .empty p { margin: 0; }
.loading-state { display: flex; align-items: center; gap: 12px; min-height: 84px; padding: 18px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.loading-state::before { width: 18px; height: 18px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; content: ""; animation: spin 850ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.drop-zone { display: grid; place-items: center; min-height: 170px; padding: 24px; border: 2px dashed var(--line-strong); border-radius: 8px; text-align: center; transition: background 150ms ease, border-color 150ms ease, transform 150ms ease; }
.drop-zone.dragging { border-color: var(--accent); background: var(--accent-soft); }
.drop-zone span { display: block; }
.drop-zone:focus-within, .drop-zone:hover { border-color: var(--accent); background: var(--accent-soft); }
.upload-action { display: flex; align-items: center; justify-content: center; gap: 14px; width: min(440px, 100%); min-height: 82px; padding: 14px 18px; color: var(--ink); background: transparent; border: 0; border-radius: 8px; cursor: pointer; text-align: left; }
.upload-action strong, .upload-action small { display: block; }
.upload-action strong { font-size: 18px; }
.upload-action small { margin-top: 3px; color: var(--muted); }
.upload-symbol { display: grid !important; place-items: center; flex: 0 0 44px; width: 44px; height: 44px; color: #fff; background: var(--accent); border-radius: 8px; font-size: 28px; font-weight: 400; line-height: 1; }
.upload-progress { display: grid; grid-template-columns: minmax(140px, 1fr) auto; gap: 12px; align-items: center; margin-top: 14px; }
.upload-progress progress { width: 100%; accent-color: var(--accent); }
.capture-entry-actions { display: flex; justify-content: center; margin-top: 12px; }
.capture-entry-actions .button { min-height: 44px; }
.document-capture-dialog { width: min(980px, calc(100vw - 24px)); height: min(820px, calc(100dvh - 24px)); max-height: calc(100dvh - 24px); overflow: hidden; }
.document-capture-dialog::backdrop { background: rgb(10 16 14 / 72%); }
.document-capture-shell { display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100%; min-height: 0; }
.document-capture-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.document-capture-header h2, .document-capture-header p { margin: 0; }
.document-capture-header .capture-close { flex: 0 0 44px; width: 44px; height: 44px; }
.document-capture-body { min-width: 0; min-height: 0; padding: 20px; overflow-y: auto; overscroll-behavior: contain; }
.capture-mode-step { max-width: 720px; margin: 0 auto; }
.capture-mode-step > h3, .capture-mode-step > p { text-align: center; }
.capture-mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 22px; }
.capture-mode-card { display: grid; gap: 6px; min-height: 132px; padding: 22px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; cursor: pointer; text-align: left; }
.capture-mode-card:hover { border-color: var(--accent); }
.capture-mode-card:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.capture-mode-card strong { font-size: 19px; }
.capture-mode-card span { color: var(--muted); }
.capture-camera-step { display: grid; gap: 12px; width: min(760px, 100%); margin: 0 auto; }
.capture-mode-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.camera-stage { position: relative; display: grid; place-items: center; min-height: 420px; overflow: hidden; background: #111714; border: 1px solid var(--line-strong); border-radius: 8px; }
.camera-preview { display: block; width: 100%; height: 100%; min-height: 420px; max-height: 580px; object-fit: contain; }
.document-frame { position: absolute; inset: 8% 12%; pointer-events: none; border: 2px solid rgb(255 255 255 / 82%); border-radius: 4px; }
.document-frame.detected { border-color: #d9f2e8; }
.receipt-guide .document-frame { inset: 5% 27%; }
.document-frame span { position: absolute; width: 30px; height: 30px; border-color: #d9f2e8; }
.document-frame span:nth-child(1) { top: -3px; left: -3px; border-top: 4px solid; border-left: 4px solid; }
.document-frame span:nth-child(2) { top: -3px; right: -3px; border-top: 4px solid; border-right: 4px solid; }
.document-frame span:nth-child(3) { right: -3px; bottom: -3px; border-right: 4px solid; border-bottom: 4px solid; }
.document-frame span:nth-child(4) { bottom: -3px; left: -3px; border-bottom: 4px solid; border-left: 4px solid; }
.camera-quality-state { position: absolute; right: 12px; bottom: 12px; left: 12px; margin: 0; padding: 9px 12px; color: #10231c; background: #e8f5ef; border-radius: 6px; font-weight: 700; text-align: center; }
.camera-quality-state.warning { color: #41250b; background: #fff1d7; }
.capture-guidance { min-height: 24px; color: var(--muted); text-align: center; }
.capture-actions, .capture-override-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.capture-actions .button, .capture-override-actions .button { min-height: 48px; }
.capture-review-step { width: min(760px, 100%); margin: 0 auto; }
.capture-page-list { display: grid; gap: 10px; margin: 18px 0; padding: 0; list-style: none; }
.capture-page-list li { display: grid; grid-template-columns: 54px minmax(0, 1fr) auto; gap: 12px; align-items: center; min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
.capture-page-list small { display: block; margin-top: 3px; color: var(--muted); overflow-wrap: anywhere; }
.capture-page-preview { display: grid; place-items: center; width: 48px; height: 58px; color: var(--muted); background: var(--surface-subtle); border: 1px solid var(--line-strong); border-radius: 4px; font-weight: 800; }
.capture-page-controls { display: flex; align-items: center; gap: 6px; }
.capture-page-controls .icon-button { width: 44px; height: 44px; }
.capture-review-actions { position: sticky; bottom: -20px; margin: 18px -20px -20px; padding: 12px 20px max(12px, env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
.capture-processing, .capture-complete { display: grid; place-items: center; align-content: center; min-height: 360px; text-align: center; }

@media (max-width: 680px) {
  .document-capture-dialog { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; border: 0; border-radius: 0; }
  .document-capture-header { padding: max(12px, env(safe-area-inset-top)) 14px 10px; }
  .document-capture-body { padding: 14px 14px max(16px, env(safe-area-inset-bottom)); }
  .capture-mode-grid { grid-template-columns: 1fr; }
  .capture-mode-card { min-height: 104px; }
  .camera-stage, .camera-preview { min-height: min(58dvh, 480px); }
  .receipt-guide .document-frame { inset: 4% 21%; }
  .capture-page-list li { grid-template-columns: 48px minmax(0, 1fr); }
  .capture-page-controls { grid-column: 1 / -1; justify-content: flex-end; }
  .capture-actions, .capture-override-actions, .capture-review-actions { display: grid; grid-template-columns: 1fr; }
  .capture-actions .button, .capture-override-actions .button { width: 100%; }
  .capture-review-actions { bottom: -14px; margin: 16px -14px -14px; padding-inline: 14px; }
}
.document-hero, .cost-hero { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 28px; min-height: 176px; margin-bottom: 18px; padding: 28px 30px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; box-shadow: var(--shadow-sm); }
.document-hero > div, .cost-hero > div { max-width: 790px; }
.document-hero h2, .cost-hero h2 { max-width: 760px; margin-bottom: 8px; font-size: 28px; }
.document-hero p:last-child, .cost-hero p:last-child { margin: 0; color: var(--muted); font-size: 16px; }
.brand-signal { position: relative; display: inline-flex; align-items: center; justify-content: space-between; width: 84px; height: 34px; }
.brand-signal::before { position: absolute; right: 8px; left: 8px; height: 2px; background: var(--line-strong); content: ""; transform: rotate(-12deg); }
.brand-signal i { position: relative; width: 12px; height: 12px; background: var(--surface); border: 3px solid var(--accent); border-radius: 50%; box-shadow: 0 0 0 5px var(--accent-soft); }
.brand-signal i:nth-child(2) { transform: translateY(-9px); }
.brand-signal.large { flex: 0 0 118px; width: 118px; height: 60px; }
.brand-signal.large i { width: 16px; height: 16px; }
.section-heading { display: flex; align-items: flex-start; gap: 13px; margin-bottom: 18px; }
.section-heading h2, .section-heading p { margin-bottom: 4px; }
.section-heading p { color: var(--muted); }
.section-number { display: grid; place-items: center; flex: 0 0 32px; width: 32px; height: 32px; color: var(--accent-dark); background: var(--accent-soft); border: 1px solid #b8ddd2; border-radius: 8px; font-weight: 800; }
.upload-panel, .document-list, .cost-builder, .saved-rules { margin-bottom: 18px; padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-sm); }
.document-direction { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; border: 0; }
.document-direction legend { flex: 0 0 100%; margin-bottom: 3px; }
.document-direction label { position: relative; min-width: 0; cursor: pointer; }
.document-direction input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.document-direction span { display: flex; min-height: 44px; align-items: center; padding: 8px 13px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); font-weight: 700; }
.document-direction input:checked + span { border-color: var(--accent); box-shadow: inset 0 -3px var(--accent); }
.document-direction input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.historical-mail-search .inline-form { align-items: end; }
.historical-mail-search label { display: grid; gap: 5px; color: var(--ink); font-weight: 720; }
.historical-mail-search input { min-height: 44px; }
.upload-status { margin: 12px 0 0; }
.receipt-cards { display: grid; gap: 12px; }
.receipt-card { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-sm); }
.receipt-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.receipt-card-top .eyebrow { margin-bottom: 3px; }
.receipt-card dl { margin: 14px 0; }
.receipt-card dl > div { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.receipt-card dt { color: var(--muted); }
.receipt-card dd { margin: 0; color: var(--ink); font-weight: 750; text-align: right; }
.receipt-card details summary { min-height: 42px; padding: 9px 0; color: var(--accent-dark); cursor: pointer; font-weight: 750; }
.review-queue-summary { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-bottom: 14px; }
.review-queue-summary p { margin: 0; }
.review-queue-summary > div { display: grid; gap: 2px; min-width: 180px; }
.review-queue-summary > div span { color: var(--muted); font-size: .9rem; }
.review-queue-summary > div strong { font-size: 1.35rem; }
.inventory-setup-task { border-left: 3px solid #c47a17; }
.review-card-date,
.review-card-secondary { margin: 3px 0 0; color: var(--muted); }
.review-card-task { display: grid; gap: 3px; margin: 14px 0; padding: 11px 13px; background: var(--surface-subtle); border-left: 3px solid var(--accent); border-radius: 4px; }
.review-card-task strong { color: var(--ink); }
.product-mapping-page { max-width: 800px; }
.product-mapping-focus-panel { width: min(900px, 100%); }
.product-mapping-focus-panel .mapping-review-list { margin-top: 8px; }
.review-case h3,
.mapping-review-card h3 { overflow-wrap: anywhere; }
.document-timeline-region { flex-basis: 100%; width: 100%; margin-top: 8px; }
.document-timeline { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.document-timeline li { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 12px; min-height: 48px; padding: 10px 0 10px 22px; border-bottom: 1px solid var(--line); }
.document-timeline li::before { position: absolute; top: 16px; left: 3px; width: 8px; height: 8px; content: ""; background: var(--accent); border-radius: 50%; }
.document-timeline span { color: var(--muted); font-size: 13px; }
.document-timeline small { grid-column: 1 / -1; color: var(--muted); }
#document-review-dialog { width: min(760px, calc(100vw - 32px)); height: min(760px, calc(100dvh - 32px)); max-height: calc(100dvh - 32px); overflow: hidden; overscroll-behavior: contain; }
#document-area-correction-dialog { width: min(600px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; }
#document-area-correction-form { display: grid; gap: 12px; min-width: 0; padding: 22px; }
#document-area-correction-form > h2, #document-area-correction-form > p { margin: 0; }
.document-area-correction-details { display: grid; gap: 2px; overflow-wrap: anywhere; }
.document-area-correction-details span { color: var(--muted); }
.document-area-correction-preview { padding: 12px; background: var(--surface-subtle); border: 1px solid var(--line); border-radius: 6px; }
.document-area-correction-preview h3 { margin: 0 0 8px; }
.document-area-correction-preview code { overflow-wrap: anywhere; word-break: break-all; }
.document-area-correction-preview[hidden], #document-area-correction-confirm[hidden] { display: none !important; }
#document-area-correction-form .dialog-actions { position: sticky; bottom: -22px; margin: 0 -22px -22px; padding: 12px 22px max(12px, env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
@media (max-width: 680px) {
  #document-area-correction-dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  #document-area-correction-form { padding: 16px; }
  #document-area-correction-form .dialog-actions { display: grid; grid-template-columns: 1fr; bottom: -16px; margin: 0 -16px -16px; padding: 12px 16px max(12px, env(safe-area-inset-bottom)); }
  #document-area-correction-form .dialog-actions .button { width: 100%; min-height: 44px; }
}
#document-review-dialog:has(.canonical-receipt-review) { width: min(1040px, calc(100vw - 32px)); }
#document-review-dialog > form { display: grid; min-height: 0; height: 100%; padding: 0; }
#document-review-content { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-height: 0; height: 100%; overflow: hidden; }
#document-review-content:has(.canonical-receipt-review) { display: block; overflow-y: auto; overscroll-behavior: contain; }
.document-review-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.document-review-header h2, .document-review-header p { margin: 0; }
.document-review-body { min-height: 0; padding: 18px 20px max(18px, env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; }
.document-review-body > :first-child { margin-top: 0; }
.document-review-actions { margin: 0; padding: 12px 20px max(12px, env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
.document-review-unresolved-fields { margin-top: 18px; }
.canonical-receipt-review { display: grid; gap: 0; }
.canonical-review-header { position: sticky; top: 0; z-index: 2; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 22px 24px 18px; background: color-mix(in srgb, var(--surface) 96%, transparent); border-bottom: 1px solid var(--line); }
.canonical-review-header h2 { margin: 2px 0 5px; }
.canonical-review-header p { margin: 0; color: var(--muted); }
.canonical-review-statuses { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.canonical-review-section { padding: 20px 24px; border-bottom: 1px solid var(--line); }
.canonical-review-section > h3,
.canonical-review-section .section-heading h3 { margin: 0 0 10px; }
.original-document-status,
.tax-profile-status,
.automatic-repair-notice { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.original-document-status h3,
.tax-profile-status h3,
.automatic-repair-notice h3 { margin: 0 0 4px; }
.original-document-status p,
.tax-profile-status p,
.automatic-repair-notice p { margin: 0; }
.original-document-status.complete,
.tax-profile-status.complete { background: color-mix(in srgb, var(--success) 7%, transparent); }
.original-document-status.needs-review,
.tax-profile-status.needs-review { background: color-mix(in srgb, var(--warning) 7%, transparent); }
.automatic-repair-notice { background: color-mix(in srgb, var(--lunar-accent) 8%, transparent); }
.tax-profile-workspace { display: grid; gap: 16px; width: min(100%, 960px); margin-inline: auto; }
.tax-profile-workspace > .page-intro { margin-bottom: 0; }
.tax-profile-form { display: grid; gap: 18px; }
.tax-profile-form > section { display: grid; gap: 8px; }
.tax-profile-form h3, .tax-profile-status h3, .tax-profile-error h3 { margin: 0; }
.tax-profile-status .button-row { align-items: center; justify-content: flex-end; }
.tax-profile-saved-summary { margin: 9px 0 0; }
.tax-profile-form .dialog-actions { margin: 0; }
.tax-profile-advanced { border-top: 1px solid var(--line); }
.tax-profile-advanced > summary { min-height: 44px; padding: 11px 0; cursor: pointer; font-weight: 700; }
.tax-profile-advanced .form-grid { padding-top: 10px; }
.tax-profile-company-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: var(--line); }
.tax-profile-company-summary > div { min-width: 0; padding: 12px 14px; background: var(--surface-subtle); }
.tax-profile-company-summary dt { margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.tax-profile-company-summary dd { margin: 0; color: var(--ink); font-weight: 750; overflow-wrap: anywhere; }
.tax-profile-company-missing { display: grid; gap: 7px; padding: 13px 14px; border-left: 3px solid var(--warning); background: var(--surface-subtle); border-radius: 4px; }
.tax-profile-company-missing p { margin: 0; color: var(--muted); }
.help-icon { display: inline-grid; width: 24px; min-width: 24px; height: 24px; place-items: center; padding: 0; color: var(--accent-dark); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 50%; cursor: pointer; font: inherit; font-size: 13px; font-weight: 800; line-height: 1; }
.help-icon:focus-visible { outline: 3px solid var(--focus-ring, var(--accent)); outline-offset: 2px; }
.tax-profile-form .choice { align-items: center; min-height: 48px; min-width: 0; padding: 10px 0; overflow-wrap: anywhere; }
.tax-profile-form .choice input[type="checkbox"] { box-sizing: border-box; width: 22px; min-width: 22px; height: 22px; margin: 0; accent-color: var(--accent); }
.profile-help-panel, .tax-profile-support-note { margin-top: 8px; padding: 13px 14px; background: var(--surface-subtle); border-left: 3px solid var(--accent); border-radius: 4px; }
.profile-help-panel p, .tax-profile-support-note p { margin: 5px 0 0; color: var(--muted); }
.tax-profile-support-note { border-left-color: var(--line-strong); }
.tax-profile-support-note .button { margin-top: 8px; }
.canonical-document-overview { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--line); }
.canonical-document-overview > div { min-width: 0; padding: 12px 14px; background: var(--surface-subtle); }
.canonical-document-overview dt { margin-bottom: 5px; color: var(--muted); font-size: 12px; }
.canonical-document-overview dd { margin: 0; color: var(--text); font-weight: 750; }
.canonical-tax-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.canonical-tax-rate { padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-subtle); }
.canonical-tax-rate > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.canonical-tax-rate > div strong { color: var(--lunar-accent); font-size: 20px; }
.canonical-tax-rate > div span { color: var(--muted); font-size: 12px; }
.canonical-tax-rate dl { display: grid; gap: 5px; margin: 0; }
.canonical-tax-rate dl div { display: flex; justify-content: space-between; gap: 10px; }
.canonical-tax-rate dt { color: var(--muted); }
.canonical-tax-rate dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 700; }
.canonical-receipt-lines { display: grid; gap: 9px; }
.receipt-line-mobile { display: none; }
.receipt-position-card { min-width: 0; padding: 13px 0; border-top: 1px solid var(--line); }
.receipt-position-card:first-child { border-top: 0; }
.receipt-position-card h4, .receipt-position-card p { margin: 0; overflow-wrap: break-word; word-break: normal; }
.receipt-position-card dl { display: grid; gap: 7px; margin: 11px 0 0; }
.receipt-position-card dl > div { display: grid; grid-template-columns: minmax(92px, .8fr) minmax(0, 1.2fr); gap: 10px; }
.receipt-position-card dt { color: var(--muted); }
.receipt-position-card dd { min-width: 0; margin: 0; overflow-wrap: break-word; word-break: normal; }
.canonical-receipt-line { padding: 14px 15px; border: 1px solid var(--line); border-radius: 8px; background: transparent; }
.canonical-receipt-line.needs-review { border-color: color-mix(in srgb, var(--warning) 55%, var(--line)); }
.canonical-line-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.canonical-line-heading h4 { margin: 2px 0 0; font-size: 15px; }
.canonical-line-heading .line-number { color: var(--muted); font-size: 12px; }
.canonical-line-facts { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 9px; color: var(--muted); font-size: 13px; }
.canonical-line-facts span { min-width: 0; }
.canonical-line-correction,
.canonical-document-correction { margin-top: 12px; border-top: 1px solid var(--line); }
.canonical-line-correction summary,
.canonical-document-correction summary,
.canonical-technical-details > summary { min-height: 44px; padding: 11px 0; cursor: pointer; font-weight: 700; }
#document-review-dialog .canonical-line-tax-form,
#document-review-dialog #canonical-document-tax-form { padding: 10px 0 2px; }
.action-required ul { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.action-required li { display: grid; gap: 3px; padding: 12px 14px; border-left: 3px solid var(--warning); background: var(--surface-subtle); }
.action-required li span { color: var(--muted); font-size: 13px; }
.canonical-technical-details { margin: 0 24px; padding: 8px 0; }
.canonical-technical-details dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.canonical-technical-details dt { color: var(--muted); font-size: 12px; }
.canonical-technical-details dd { margin: 4px 0 0; overflow-wrap: anywhere; }
.canonical-receipt-review > .dialog-actions { position: sticky; bottom: 0; z-index: 2; margin: 0; padding: 14px 24px; background: color-mix(in srgb, var(--surface) 96%, transparent); border-top: 1px solid var(--line); }
@media (max-width: 680px) {
  .document-direction { display: grid; grid-template-columns: 1fr; }
  .document-direction legend { grid-column: 1; }
  .document-direction label, .document-direction span,
  .historical-mail-search .inline-form .button { width: 100%; }
  #document-review-dialog,
  #document-review-dialog:has(.canonical-receipt-review) { width: calc(100vw - 16px); height: calc(100dvh - 16px - env(safe-area-inset-top)); max-height: calc(100dvh - 16px - env(safe-area-inset-top)); margin: max(8px, env(safe-area-inset-top)) auto 8px; }
  .document-review-header { padding: 14px 16px 12px; }
  .document-review-body { padding: 14px 16px max(18px, env(safe-area-inset-bottom)); }
  .document-review-actions { display: grid; grid-template-columns: 1fr; padding: 10px 16px max(12px, env(safe-area-inset-bottom)); }
  .document-review-actions .button { width: 100%; min-height: 48px; }
  .canonical-review-header { position: static; display: grid; gap: 10px; padding: 16px; }
  .canonical-review-statuses { justify-content: flex-start; }
  .canonical-review-section { padding: 15px 16px; }
  .original-document-status,
  .tax-profile-status,
  .automatic-repair-notice { display: grid; gap: 12px; }
  .original-document-status .button,
  .tax-profile-status .button,
  .automatic-repair-notice .button { width: 100%; min-height: 48px; }
  .tax-profile-workspace { width: 100%; }
  .tax-profile-form { padding: 16px; }
  .tax-profile-company-summary { grid-template-columns: 1fr; }
  .tax-profile-form .dialog-actions { display: grid; grid-template-columns: 1fr; }
  .tax-profile-form .dialog-actions .button { width: 100%; min-height: 48px; }
  .canonical-document-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .canonical-document-overview > div { padding: 10px; }
  .canonical-tax-grid { grid-template-columns: 1fr; }
  .canonical-tax-rate { padding: 12px; }
  .canonical-line-heading { display: grid; gap: 8px; }
  .canonical-line-heading .status-badge { justify-self: start; }
  .canonical-line-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 10px; }
  .receipt-line-desktop { display: none; }
  .receipt-line-mobile { display: grid; }
  .receipt-position-card { padding: 14px 0; }
  .canonical-technical-details { margin: 0 16px; }
  .canonical-technical-details dl { grid-template-columns: 1fr; }
  .canonical-receipt-review > .dialog-actions { padding: 12px 16px max(12px, env(safe-area-inset-bottom)); }
}
.order-tax-intro { max-width: 1280px; margin-inline: auto; }
.order-tax-review { display: grid; gap: 24px; width: min(1280px, 100%); margin-inline: auto; }
.order-tax-overview { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--line); }
.order-tax-overview > div { display: grid; gap: 6px; min-width: 0; padding: 15px 17px; background: var(--surface); }
.order-tax-overview span { color: var(--muted); font-size: 12px; }
.order-tax-overview strong { overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.order-tax-section { display: grid; gap: 13px; }
.order-tax-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; }
.order-tax-summary-item { padding: 15px; border: 1px solid var(--line); border-radius: 8px; background: transparent; }
.order-tax-summary-item > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.order-tax-summary-item > div span { color: var(--muted); }
.order-tax-summary-item > div strong { color: var(--accent-dark); font-size: 20px; }
.order-tax-summary-item dl,
.order-tax-line dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 14px 0 0; }
.order-tax-summary-item dl div,
.order-tax-line dl div { min-width: 0; }
.order-tax-summary-item dt,
.order-tax-line dt { color: var(--muted); font-size: 12px; }
.order-tax-summary-item dd,
.order-tax-line dd { margin: 4px 0 0; font-variant-numeric: tabular-nums; font-weight: 700; overflow-wrap: anywhere; }
.order-tax-lines { display: grid; gap: 10px; }
.order-tax-line { padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: transparent; }
.order-tax-line.needs-review { border-color: color-mix(in srgb, var(--warning) 55%, var(--line)); }
.order-tax-line > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.order-tax-line h3 { margin: 3px 0 0; font-size: 16px; }
.order-tax-audit { min-width: 0; margin-top: 14px; border-top: 1px solid var(--line); }
.order-tax-audit > summary, .order-tax-audit-technical > summary { min-height: 44px; padding: 11px 0; color: var(--accent-dark); cursor: pointer; font-weight: 700; }
.order-tax-audit > .helper { margin: 4px 0 0; }
.order-tax-line .order-tax-audit-provenance { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.order-tax-audit-components { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 10px; margin-top: 12px; }
.order-tax-audit-component { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-subtle); }
.order-tax-audit-component h4 { margin: 0; }
.order-tax-line .order-tax-audit-component dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.order-tax-audit-open { color: var(--warning); font-weight: 750; }
.order-tax-audit-technical { min-width: 0; margin-top: 10px; }
.order-tax-line .order-tax-audit-technical dl { grid-template-columns: minmax(0, 1fr); }
.order-tax-audit-technical dd { overflow-wrap: anywhere; }
.order-tax-line-action { display: grid; gap: 6px; margin-top: 14px; padding: 12px 14px; border-left: 3px solid var(--warning); background: var(--surface-subtle); }
.order-tax-line-action ul { margin: 0; padding-left: 18px; }
.order-tax-action { padding: 18px; border: 1px solid color-mix(in srgb, var(--warning) 55%, var(--line)); border-radius: 8px; }
.order-tax-action.complete { border-color: color-mix(in srgb, var(--success) 45%, var(--line)); }
.order-tax-action h2 { margin: 0 0 10px; font-size: 18px; }
.order-tax-action ul { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.order-tax-action li { display: grid; gap: 3px; }
.order-tax-action li span { color: var(--muted); font-size: 13px; }
@media (max-width: 680px) {
  .order-tax-review { gap: 18px; }
  .order-tax-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .order-tax-overview > div { padding: 12px; }
  .order-tax-summary { grid-template-columns: 1fr; }
  .order-tax-summary-item dl,
  .order-tax-line dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .order-tax-line { padding: 13px; }
  .order-tax-line > header { display: grid; gap: 8px; }
  .order-tax-line > header .status-badge { justify-self: start; }
  .order-tax-line .order-tax-audit-provenance { grid-template-columns: minmax(0, 1fr); }
}
.receipt-details { margin: 0 !important; }
.structured-receipt { overflow: hidden; }
.receipt-structured-details { margin-top: 12px; border-top: 1px solid var(--line); }
.receipt-structured-details h4 { margin: 16px 0 8px; }
.receipt-tax-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
.receipt-tax-summary > div { display: grid; gap: 3px; padding: 10px 12px; background: var(--surface-subtle); border: 1px solid var(--line); border-radius: 7px; }
.receipt-tax-summary span { color: var(--muted); font-size: .9rem; }
.compact-vat-summary .input-vat-total dd { display: grid; gap: 6px; }
.input-vat-breakdown-label { margin-top: 4px; font-weight: 600; }
.input-vat-breakdown { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.input-vat-breakdown li { display: flex; flex-wrap: wrap; gap: 6px; font-size: .9rem; }
.input-vat-breakdown li strong { min-width: 38px; }
.product-relevance-actions { display: grid; gap: 8px; width: 100%; }
.receipt-line-table table { min-width: 760px; }
.receipt-line-table td:first-child { max-width: 360px; }
.receipt-line-table td:first-child small { display: block; margin-top: 3px; color: var(--muted); }

@media (max-width: 680px) {
  .receipt-line-table { overflow: visible; }
  .receipt-line-table table,
  .receipt-line-table tbody { display: block; min-width: 0; width: 100%; }
  .receipt-line-table thead,
  .receipt-line-table caption { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .receipt-line-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
  }
  .receipt-line-table td {
    display: grid;
    grid-template-columns: minmax(104px, 0.7fr) minmax(0, 1fr);
    gap: 8px;
    min-width: 0;
    padding: 0;
    border: 0;
    overflow-wrap: anywhere;
  }
  .receipt-line-table td:first-child { grid-column: 1 / -1; display: block; max-width: none; }
  .receipt-line-table td:not(:first-child)::before { color: var(--muted); font-size: 12px; font-weight: 700; }
  .receipt-line-table td:nth-child(2)::before { content: "Art"; }
  .receipt-line-table td:nth-child(3)::before { content: "Menge"; }
  .receipt-line-table td:nth-child(4)::before { content: "Netto"; }
  .receipt-line-table td:nth-child(5)::before { content: "Steuer"; }
  .receipt-line-table td:nth-child(6)::before { content: "Produkt"; }
}
.chat-layout { position: relative; display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: 590px; overflow: hidden; isolation: isolate; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.lunar-surface::after { position: absolute; z-index: -1; top: 0; right: 0; width: min(48%, 520px); height: 160px; pointer-events: none; background: linear-gradient(135deg, rgb(15 137 111 / 13%), rgb(67 135 203 / 9%), transparent 70%); clip-path: polygon(32% 0, 100% 0, 100% 100%, 0 58%); content: ""; }
.lunar-surface::before { position: absolute; z-index: -1; right: 92px; bottom: -86px; width: 270px; height: 270px; pointer-events: none; opacity: .42; border: 1px solid rgb(15 137 111 / 23%); border-radius: 56% 44% 61% 39%; box-shadow: 0 0 0 18px rgb(67 135 203 / 3%), 0 0 0 36px rgb(15 137 111 / 2%); content: ""; transform: rotate(-17deg); }
.chat-history { padding: 18px; background: var(--surface-subtle); border-right: 1px solid var(--line); }
.chat-history-list { display: grid; gap: 5px; margin: 14px 0 0; padding: 0; list-style: none; }
.chat-history button { width: 100%; padding: 9px; color: var(--text); background: transparent; border: 0; border-radius: 5px; text-align: left; }
.chat-history button:hover { background: var(--surface); }
.chat-main { position: relative; display: grid; grid-template-rows: auto minmax(260px, 1fr) auto; min-width: 0; }
.chat-main::before { position: absolute; z-index: -1; top: 28px; right: 34px; width: 230px; height: 82px; pointer-events: none; opacity: .7; background: repeating-linear-gradient(126deg, transparent 0 12px, rgb(15 137 111 / 17%) 13px 14px, transparent 15px 28px); content: ""; }
.chat-main-header { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.chat-header-actions { display: flex; align-items: center; gap: 7px; }
.conversation-heading { display: flex; align-items: center; min-width: 0; gap: 13px; }
.conversation-heading > div { min-width: 0; }
.conversation-heading h2 { max-width: 58ch; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lunar-orbit { position: relative; display: grid; place-items: center; flex: 0 0 42px; width: 42px; height: 42px; overflow: hidden; background: linear-gradient(135deg, var(--accent-soft), #d9eaff); border: 1px solid #b8ddd2; border-radius: 14px 8px 14px 8px; box-shadow: inset 0 1px 0 rgb(255 255 255 / 80%); }
.lunar-orbit::before { width: 18px; height: 18px; border: 2px solid var(--accent); border-radius: 50%; content: ""; }
.lunar-orbit::after { position: absolute; width: 32px; height: 32px; border: 1px dashed rgb(15 137 111 / 58%); border-radius: 50%; content: ""; }
.lunar-orbit i { position: absolute; width: 5px; height: 5px; background: var(--signal); border-radius: 50%; }
.lunar-orbit i:nth-child(1) { top: 7px; right: 9px; }
.lunar-orbit i:nth-child(2) { right: 6px; bottom: 10px; }
.lunar-orbit i:nth-child(3) { bottom: 6px; left: 11px; }
.lunar-orbit-large { flex-basis: 64px; width: 64px; height: 64px; border-radius: 22px 12px 22px 12px; }
.lunar-orbit-large::before { width: 27px; height: 27px; }
.lunar-orbit-large::after { width: 48px; height: 48px; }
.lunar-orbit-thinking { flex-basis: 28px; width: 28px; height: 28px; border-radius: 9px 6px 9px 6px; }
.lunar-orbit-thinking::before { width: 12px; height: 12px; border-width: 1px; }
.lunar-orbit-thinking::after { width: 21px; height: 21px; animation: lunar-orbit-rotate 3s linear infinite; }
.lunar-orbit-thinking i { width: 3px; height: 3px; }
.conversation-menu, .lunar-reminder-menu { position: relative; flex: 0 0 auto; }
.conversation-menu > summary, .lunar-reminder-menu > summary { display: grid; place-items: center; width: 42px; height: 42px; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; list-style: none; font-size: 18px; letter-spacing: 2px; }
.conversation-menu > summary::-webkit-details-marker, .lunar-reminder-menu > summary::-webkit-details-marker { display: none; }
.conversation-menu-popover, .lunar-reminder-popover { position: absolute; z-index: 6; top: calc(100% + 7px); right: 0; display: grid; min-width: 190px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-md); }
.lunar-reminder-popover { min-width: min(340px, calc(100vw - 36px)); padding: 14px; }
.lunar-reminder-popover h3 { margin: 0 0 8px; }
.conversation-menu-popover button { min-height: 42px; padding: 8px 10px; color: var(--text); background: transparent; border: 0; border-radius: 6px; cursor: pointer; text-align: left; }
.conversation-menu-popover button:hover, .conversation-menu-popover button:focus-visible { background: var(--surface-subtle); }
.conversation-menu-popover .danger-action { color: var(--danger); }
.conversation-menu-popover .danger-action:hover, .conversation-menu-popover .danger-action:focus-visible { color: var(--danger); background: var(--danger-bg); }
.chat-log { min-height: 0; padding: 22px; overflow-y: auto; user-select: text; }
.chat-message { position: relative; max-width: 78ch; margin: 0 0 18px; padding: 13px 15px; white-space: pre-wrap; }
.chat-message.user { margin-left: auto; background: var(--surface-subtle); border-radius: 8px 8px 2px 8px; }
.chat-message.assistant { padding-left: 18px; border-left: 3px solid var(--accent); }
.chat-message.failed { border-left-color: var(--danger); background: var(--danger-bg); }
.chat-message.stopped { border-left-color: var(--info); background: var(--info-bg); }
.message-author { display: flex; align-items: center; gap: 8px; }
.lunar-mark { display: inline-grid; place-items: center; width: 27px; height: 27px; color: var(--accent-dark); background: var(--accent-soft); border-radius: 7px; font-size: 11px; font-weight: 850; }
.chat-message.user .lunar-mark { color: var(--muted); background: var(--surface-strong); }
.message-sources { margin-top: 10px; color: var(--muted); font-size: 13px; }
.message-sources summary { display: flex; align-items: center; min-height: 36px; padding: 7px 0; cursor: pointer; font-weight: 720; }
.message-sources summary::before { width: 20px; height: 4px; margin-right: 8px; background: linear-gradient(90deg, var(--accent), var(--signal), var(--accent)); background-size: 180% 100%; border-radius: 999px; content: ""; }
.message-sources[open] summary::before { animation: lunar-gradient-shift 2s ease-in-out 2; }
.message-sources p { margin: 4px 0 0; padding: 9px 11px; background: var(--surface-subtle); border-radius: 6px; }
.message-sources small { display: block; margin-top: 8px; color: var(--muted); line-height: 1.45; }
.message-tools { display: flex; align-items: center; gap: 4px; margin-top: 8px; opacity: 0; transition: opacity 130ms ease; }
.chat-message:hover .message-tools, .chat-message:focus-within .message-tools { opacity: 1; }
.message-tools > button { min-height: 32px; padding: 4px 8px; color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 4px; }
.message-tools .copy-message { display: grid; place-items: center; width: 34px; padding: 4px; font-size: 16px; }
.answer-menu { position: relative; }
.answer-menu > summary { display: grid; place-items: center; width: 34px; min-height: 32px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; cursor: pointer; list-style: none; letter-spacing: 2px; }
.answer-menu > summary::-webkit-details-marker { display: none; }
.answer-menu-popover { position: absolute; z-index: 5; right: 0; bottom: calc(100% + 5px); display: grid; min-width: 150px; padding: 5px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow-md); }
.answer-menu-popover button { min-height: 36px; padding: 7px 9px; color: var(--text); background: transparent; border: 0; border-radius: 4px; text-align: left; }
.answer-menu-popover button:hover, .answer-menu-popover button:focus-visible { background: var(--surface-subtle); }
.message-tools button[aria-pressed="true"] { color: var(--accent-dark); background: var(--accent-soft); border-color: var(--accent); }
.preference-suggestion { display: grid; gap: 8px; margin-top: 12px; padding: 12px; background: var(--accent-soft); border: 1px solid #b8ddd2; border-radius: 6px; }
.preference-suggestion p { margin: 0; color: var(--ink); font-weight: 720; }
.preference-suggestion button { min-height: 34px; padding: 5px 9px; color: var(--accent-dark); background: var(--surface); border: 1px solid #9dcfc1; border-radius: 5px; }
.preference-list { display: grid; gap: 12px; }
.preference-card { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 15px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-subtle); }
.preference-card h3, .preference-card p { margin: 0; }
.preference-card > div:first-child { display: grid; gap: 4px; }
.message-tools[data-recovery-state="error"], .message-tools[data-recovery-state="stopped"] { opacity: 1; }
.message-tools[data-recovery-state="stopped"] > button { color: var(--info); border-color: currentColor; }
.lunar-thinking { color: var(--muted); }
.thinking-dots { display: inline-flex; gap: 4px; margin-right: 9px; }
.thinking-dots i { width: 6px; height: 6px; background: var(--accent); border-radius: 50%; animation: lunar-pulse 900ms ease-in-out infinite; }
.thinking-dots i:nth-child(2) { animation-delay: 120ms; }
.thinking-dots i:nth-child(3) { animation-delay: 240ms; }
@keyframes lunar-pulse { 0%, 100% { opacity: .35; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }
@keyframes lunar-gradient-shift { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
@keyframes page-enter { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.page-enter { animation: page-enter 180ms ease-out both; }
.lunar-empty { display: grid; align-content: center; justify-items: start; min-height: 100%; padding: clamp(26px, 7vw, 72px); background: radial-gradient(circle at 75% 18%, rgb(67 135 203 / 7%), transparent 28%); }
.lunar-empty-brand { width: min(64px, 25%); height: 64px; margin: 0 0 12px; object-fit: contain; }
.lunar-empty h3 { margin: 8px 0 4px; font-size: 24px; }
.lunar-empty p { margin: 0; color: var(--muted); }
.lunar-samples { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.lunar-sample { min-height: 40px; padding: 8px 12px; color: var(--accent-dark); background: var(--surface); border: 1px solid #b8ddd2; border-radius: 999px; cursor: pointer; text-align: left; transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease; }
.lunar-sample:hover, .lunar-sample:focus-visible { border-color: var(--accent); box-shadow: 0 5px 14px rgb(15 137 111 / 12%); transform: translateY(-1px); }
.chat-composer { position: relative; z-index: 4; padding: 14px 20px 20px; background: var(--surface); border-top: 1px solid var(--line); }
.chat-composer .field { margin: 0; }
.chat-composer-row { display: grid; grid-template-columns: minmax(0, 1fr) 48px; align-items: end; gap: 8px; }
.chat-composer textarea { min-height: 48px; max-height: 144px; resize: none; border-color: var(--line-strong); box-shadow: inset 0 1px 2px rgb(21 32 28 / 4%); }
.chat-send { display: grid; place-items: center; width: 48px; min-width: 48px; height: 48px; min-height: 48px; padding: 0; border-radius: 50%; }
.chat-send .composer-icon { font-size: 22px; font-weight: 850; line-height: 1; }
.chat-send.is-stopping { background: var(--danger); box-shadow: none; }
.chat-send.is-stopping:hover { background: #a93632; }
@keyframes lunar-orbit-rotate { to { transform: rotate(360deg); } }
.summary-list { display: grid; gap: 0; margin: 0; }
.summary-list div { display: grid; grid-template-columns: minmax(150px, .8fr) minmax(0, 1.2fr); gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.summary-list dt { color: var(--muted); }
.summary-list dd { margin: 0; font-weight: 700; }
.formula { display: grid; gap: 8px; margin: 16px 0; padding: 16px; background: var(--surface-subtle); border-radius: 6px; font-variant-numeric: tabular-nums; }
.formula-row { display: flex; justify-content: space-between; gap: 16px; }
.formula-row.total { padding-top: 9px; border-top: 2px solid var(--line-strong); font-weight: 800; }
.action-list { display: grid; gap: 9px; padding: 0; list-style: none; }
.action-list li { padding: 12px; border: 1px solid var(--line); border-radius: 6px; }
dialog { width: min(560px, calc(100vw - 32px)); padding: 0; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-md); }
dialog::backdrop { background: rgb(21 32 28 / 55%); }
dialog form { padding: 22px; }
html:has(#tax-v2-package-dialog[open]),
body:has(#tax-v2-package-dialog[open]) { overflow: hidden; }
#tax-v2-package-dialog { max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain; }
#tax-v2-package-tasks[hidden] { display: none !important; }
.voice-state { display: flex; align-items: center; gap: 9px; }
.voice-indicator { width: 12px; height: 12px; background: var(--muted); border-radius: 50%; }
.voice-indicator.listening { background: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); }
.page-intro { max-width: 760px; margin-bottom: 22px; }
.page-intro > p:last-child { color: var(--muted); font-size: 16px; }
.july-final-confirmation { display: grid; gap: 20px; max-width: 1120px; }
.july-final-status { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.july-final-status h3, .july-final-auto h3 { margin-top: 0; }
.july-final-status p, .july-final-auto p, .july-final-gate > .section-heading p { margin-bottom: 0; }
.july-final-gate { display: grid; gap: 14px; }
.july-final-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.july-final-fact-card { min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.july-final-fact-card > header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.july-final-fact-card h3 { margin: 0; font-size: 17px; }
.july-final-amount { margin: 7px 0 0; color: var(--muted); font-weight: 650; }
.july-final-fact-card dl { display: grid; gap: 10px; margin: 0; }
.july-final-fact-card dl > div { display: grid; gap: 3px; }
.july-final-fact-card dt { color: var(--muted); font-size: 13px; font-weight: 700; }
.july-final-fact-card dd { margin: 0; }
.july-final-fact-card .helper { margin: 14px 0 0; overflow-wrap: anywhere; }
.july-final-cash form { display: grid; gap: 12px; margin-top: 16px; }
.july-final-source-confirmation { margin-top: 14px; }
.july-final-source-confirmation h3 { margin-top: 0; }
@media (max-width: 720px) {
  .july-final-status { display: grid; }
  .july-final-card-grid { grid-template-columns: minmax(0, 1fr); }
  .july-final-fact-card { padding: 16px; }
  .july-final-fact-card > header { display: grid; }
}
.cost-rule-layout { align-items: start; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
#tax-v2-source-amounts[hidden] { display: none; }
#tax-v2-source-dialog .field[hidden] { display: none; }
#tax-v2-source-form > .helper[hidden] { display: none; }
.form-span { grid-column: 1 / -1; }
.invoice-intro { margin-bottom: 14px; }
.invoice-steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 0; margin: 0 0 16px; list-style: none; }
.invoice-steps li { display: flex; align-items: center; gap: 9px; min-height: 48px; padding: 8px 10px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; font-weight: 720; }
.invoice-steps li span { display: grid; place-items: center; flex: 0 0 24px; width: 24px; height: 24px; background: var(--surface-strong); border-radius: 50%; font-size: 12px; }
.invoice-steps li.active { color: var(--accent-dark); background: var(--accent-soft); border-color: var(--accent); }
.invoice-steps li.complete { color: var(--success); border-color: #b4d8c2; }
.invoice-wizard { max-width: 1040px; }
.invoice-wizard-content { min-height: 330px; }
.invoice-line-list { display: grid; gap: 12px; margin-bottom: 14px; }
.invoice-line { margin: 0; background: var(--surface-subtle); }
.invoice-line legend { padding: 0 6px; color: var(--accent-dark); font-weight: 800; }
.invoice-line output { display: grid; align-items: center; min-height: 44px; padding: 9px 11px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 6px; font-weight: 750; }
.issuer-summary { display: flex; justify-content: space-between; gap: 18px; margin-top: 16px; padding: 16px; background: var(--surface-subtle); border: 1px solid var(--line); border-radius: 8px; }
.issuer-summary h3, .issuer-summary p { margin: 0; }
.issuer-summary p:last-child { margin-top: 4px; color: var(--muted); }
.invoice-review { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.invoice-review .panel { padding: 16px; box-shadow: none; }
.invoice-totals { display: grid; gap: 7px; margin-top: 14px; }
.invoice-totals > div { display: flex; justify-content: space-between; gap: 16px; }
.invoice-totals .total { padding-top: 8px; border-top: 2px solid var(--line-strong); font-size: 17px; }
.tax-control-bar { display: flex; align-items: end; flex-wrap: wrap; gap: 12px 18px; margin-bottom: 16px; padding: 15px 17px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.tax-control-bar .field { min-width: 220px; margin: 0; }
.tax-control-bar .helper { max-width: 440px; margin: 0 0 8px; }
.monthly-tax-workspace { margin: 0 0 18px; padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.monthly-tax-heading { display: flex; align-items: start; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.monthly-tax-heading h2 { margin: 2px 0 6px; }
.monthly-tax-heading p { margin: 0; }
.monthly-tax-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; margin-bottom: 16px; }
.monthly-tax-metrics article { display: grid; gap: 3px; padding: 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-subtle); }
.monthly-tax-metrics strong { font-size: 1.2rem; }
.monthly-tax-metrics span, .monthly-tax-document span { color: var(--muted); font-size: .88rem; }
.tax-open-item { display: grid; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.tax-open-item:last-child { border-bottom: 0; }
.tax-open-item p { margin: 0; }
.monthly-tax-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(260px, .65fr); gap: 18px; }
.monthly-tax-grid > section { min-width: 0; }
.monthly-tax-review { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.monthly-tax-review summary { cursor: pointer; font-weight: 650; }
.monthly-summary-link { align-self: flex-start; margin-top: 0.35rem; padding-inline: 0; }

.workflow-deep-link-target {
  scroll-margin-block: 5rem;
}

.beleg-archive-list { display: grid; gap: 8px; }
.beleg-archive-card { appearance: none; width: 100%; min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px; border: 1px solid var(--border, #d9dfdc); border-radius: 8px; background: var(--surface, #fff); color: inherit; text-align: left; cursor: pointer; }
.beleg-archive-card:hover { border-color: var(--accent, #2e7d5b); }
.beleg-card-main { min-width: 0; display: grid; gap: 4px; }
.beleg-card-main strong, .beleg-card-main span { overflow-wrap: anywhere; }
.beleg-card-state { flex: 0 0 auto; font-size: .9rem; }
.beleg-card-state.success { color: #17653d; }
.beleg-card-state.attention { color: #8a5a00; }
.beleg-card-statuses, .document-status-rows { display: grid; gap: 4px; justify-items: end; }
.beleg-card-action { color: var(--accent); font-weight: 700; }
.document-status-rows { justify-items: start; margin-top: 6px; }
.beleg-detail { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.compact-mapping-review-list { max-width: 760px; }
.compact-mapping-card { display: grid; gap: 12px; }
.compact-mapping-card h2 { font-size: 1.1rem; margin: 0; }
.compact-fact-list { display: flex; flex-wrap: wrap; gap: 6px 10px; margin: 0; padding: 0; color: var(--muted); font-size: 13px; list-style: none; }
.compact-fact-list li { min-width: 0; overflow-wrap: anywhere; }
.mapping-primary-decision { display: grid; gap: 10px; }
.purchase-unit-confirmation { display: grid; gap: 10px; }
.purchase-unit-factor-fields { display: grid; grid-template-columns: minmax(0, 220px) auto; align-items: end; gap: 10px; }
.purchase-unit-factor-fields .field { margin: 0; }
.purchase-unit-status { min-height: 1.2em; margin: 0; color: var(--muted); }
.canonical-product-summary { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.canonical-product-summary h3 { margin: 0 0 10px; }
.canonical-summary-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.canonical-summary-filter { min-height: 56px; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: inherit; text-align: left; cursor: pointer; }
.canonical-summary-filter strong { font-size: 1.15rem; }
.canonical-summary-filter.active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.line-processing-result { display: grid; gap: 7px; margin-top: 10px; padding: 10px; border-left: 3px solid var(--border); background: var(--surface-subtle); }
.line-processing-result.success { border-left-color: var(--success); }
.line-processing-result.attention { border-left-color: var(--warning); }
.line-processing-result p, .line-processing-result ul { margin: 0; }
.purchase-source-facts { margin-top: 9px; }
.receipt-line-desktop td:first-child { min-width: 290px; }
.receipt-line-desktop { display: none; }
.receipt-line-mobile { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 10px; }
.receipt-position-card { padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-subtle); }
.receipt-position-card:first-child { border-top: 1px solid var(--line); }
.receipt-position-card[hidden], .receipt-line-table tr[hidden] { display: none !important; }
.related-sales-offers { display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.related-sales-offers h3, .related-sales-offers p, .related-sales-offers ul { margin: 0; }
.related-sales-offers .button { justify-self: start; }
.compact-candidates { display: grid; gap: 8px; }
.compact-mapping-card .shopify-product-picker { margin-top: 4px; }
.compact-mapping-card .button, .mapping-progress .button { min-height: 44px; }
.supplier-variant-result-evidence, .supplier-variant-result-conflict { font-size: .82rem; line-height: 1.35; }
.supplier-variant-result-evidence { color: var(--success); }
.supplier-variant-result-conflict { color: var(--warning); }
.supplier-variant-result.incompatible { cursor: not-allowed; opacity: .72; }
.product-draft-preview-region .notice { margin: 0; }
.automation-field-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; }

@media (max-width: 600px) {
  .beleg-archive-card { align-items: flex-start; flex-direction: column; gap: 6px; }
  .beleg-card-statuses { justify-items: start; }
  .beleg-detail { flex-direction: column; }
  .beleg-detail > .button { width: 100%; }
  .beleg-detail-summary .panel-header { flex-direction: column; }
  .beleg-detail-summary .panel-header > div { min-width: 0; width: 100%; }
  .beleg-detail-summary .status-badge { align-self: flex-start; }
  .automation-field-options { grid-template-columns: 1fr; }
  .compact-mapping-card { padding: 12px; }
  .purchase-unit-factor-fields { grid-template-columns: 1fr; }
  .purchase-unit-confirmation .button-row, .purchase-unit-confirmation .button,
  .purchase-unit-factor-fields .button, .related-sales-offers .button { width: 100%; }
  .canonical-summary-filters { grid-template-columns: 1fr 1fr; }
  .canonical-summary-filter { min-width: 0; }
  .canonical-summary-filter span { overflow-wrap: anywhere; }
  .line-processing-result .button-row, .line-processing-result .button { width: 100%; }
}

@media (max-width: 430px) {
  .canonical-summary-filters { grid-template-columns: 1fr; }
  .canonical-summary-filter span { overflow-wrap: normal; word-break: normal; }
}
.monthly-tax-document { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, .7fr); gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.monthly-tax-document > div { display: grid; gap: 3px; }
.product-tax-fact-source { grid-column: 1 / -1; min-width: 0; }
.product-tax-fact-source > summary { cursor: pointer; min-height: 44px; padding: 8px 0; }
.product-tax-fact-source form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: end; }
.product-tax-fact-source form label { display: grid; gap: 5px; min-width: 0; }
.product-tax-fact-source form input, .product-tax-fact-source form textarea { width: 100%; min-width: 0; }
.product-tax-fact-source form button { justify-self: start; }
.product-tax-manual-resolution { grid-column: 1 / -1; min-width: 0; }
.product-tax-manual-resolution > summary { cursor: pointer; min-height: 44px; padding: 8px 0; }
.product-tax-manual-resolution form { display: grid; gap: 12px; min-width: 0; max-width: 640px; }
.product-tax-manual-resolution form label { display: grid; gap: 5px; min-width: 0; }
.product-tax-manual-resolution form label:has(input[type="checkbox"]) { display: flex; align-items: flex-start; gap: 8px; }
.product-tax-manual-resolution form select,
.product-tax-manual-resolution form textarea { width: 100%; min-width: 0; }
.product-tax-manual-resolution form button { justify-self: start; }
.source-order-conflicts [data-source-correction-form] label { display: block; min-width: 0; overflow-wrap: anywhere; }
.source-order-conflicts [data-source-correction-form] select { display: block; width: 100%; max-width: 100%; min-height: 44px; box-sizing: border-box; }
.source-order-conflicts .source-position-fact { display: block; margin: 8px 0 12px; overflow-wrap: anywhere; color: var(--muted); }
.product-tax-manual-result { display: grid; gap: 12px; max-width: 640px; }
.product-tax-fact-preview { margin-top: 10px; overflow-wrap: anywhere; }
.founder-product-fact-sku { margin-top: 14px; }
.founder-product-fact-card > form { grid-column: 1 / -1; display: grid; gap: 12px; }
.refund-screenshot-card > form { grid-column: 1 / -1; display: grid; gap: 12px; }
.refund-screenshot-upload .refund-screenshot-period { max-width: 220px; }
.founder-product-fact-card textarea { min-height: 76px; }
.tax-v2-source-issue > div { min-width: 0; overflow-wrap: anywhere; }
.tax-v2-adviser-case { border-bottom: 1px solid var(--line); min-width: 0; }
.tax-v2-adviser-case > summary { cursor: pointer; min-height: 48px; padding: 10px 4px; overflow-wrap: anywhere; }
.tax-v2-adviser-case > summary strong { font-weight: 700; }
.tax-v2-adviser-case > summary span { display: block; margin: 3px 0 0 18px; color: var(--muted); font-size: .88rem; line-height: 1.4; }
.tax-v2-adviser-case > summary:hover { color: var(--accent); }
.tax-v2-adviser-case-detail { padding: 0 8px 12px 18px; overflow-wrap: anywhere; }
.tax-v2-adviser-case-detail p { margin: 4px 0 0; color: var(--muted); }
.tax-v2-document-cases { min-width: 0; margin-top: 16px; }
.tax-v2-document-cases > summary { cursor: pointer; font-weight: 700; }
.tax-v2-document-case > div { min-width: 0; overflow-wrap: anywhere; }
.tax-v2-document-case .button { justify-self: start; }
.monthly-tax-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.monthly-tax-workspace dialog ul { max-height: 220px; overflow: auto; }
.monthly-tax-metrics.is-empty { opacity: .72; }
.monthly-tax-empty { margin-bottom: 14px; }
.archive-option-list { display: grid; gap: 8px; margin: 12px 0 16px; }
.archive-option { display: grid; grid-template-columns: 22px minmax(0, 1fr); align-items: center; gap: 10px; min-height: 44px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; cursor: pointer; }
.archive-option input { width: 18px; height: 18px; margin: 0; }
.inventory-movement-list { display: grid; gap: 0; }
.inventory-movement-row { display: grid; grid-template-columns: minmax(132px, .7fr) minmax(160px, 1fr) minmax(100px, auto); gap: 6px 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.inventory-movement-row time, .inventory-movement-row > span:not(.inventory-movement-amount) { color: var(--muted); font-size: .88rem; }
.inventory-movement-row .inventory-movement-amount { justify-self: end; font-weight: 800; }
.inventory-movement-row details { grid-column: 1 / -1; }
.picker-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.column-menu { position: relative; }
.column-menu summary { list-style: none; cursor: pointer; }
.column-menu summary::-webkit-details-marker { display: none; }
.column-menu > div { position: absolute; z-index: 4; right: 0; width: 270px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-md); }
.cost-type-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 11px; }
.cost-type-card { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 11px; min-height: 126px; padding: 15px; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; text-align: left; transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease; }
.cost-type-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.cost-type-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.cost-type-card strong { align-self: center; color: var(--ink); }
.cost-type-card > span:last-child { grid-column: 1 / -1; margin-top: 10px; color: var(--muted); font-size: 13px; }
.cost-type-icon { display: grid; place-items: center; width: 36px; height: 36px; color: var(--accent-dark); background: var(--accent-soft); border: 1px solid #b8ddd2; border-radius: 8px; font-weight: 850; }
.cost-type-icon.small { flex: 0 0 36px; }
.cost-editor { margin-top: 18px; padding: 20px; background: var(--surface-subtle); border: 1px solid var(--line); border-radius: 8px; }
.cost-editor[data-empty="true"] { min-height: 88px; }
.cost-selection-help { display: flex; align-items: center; justify-content: center; gap: 18px; min-height: 48px; color: var(--muted); text-align: center; }
.cost-editor-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.cost-editor-heading h3 { margin: 0; font-size: 20px; }
.progressive-form { max-width: 860px; }
.input-suffix { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.input-suffix input { border-radius: 6px 0 0 6px; }
.input-suffix span { display: grid; place-items: center; min-width: 54px; padding: 0 10px; color: var(--muted); background: var(--surface-strong); border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 6px 6px 0; font-weight: 750; }
.form-details { margin: 4px 0 18px; padding: 0 13px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.form-details summary { min-height: 44px; padding: 11px 0; cursor: pointer; color: var(--ink); font-weight: 750; }
.saved-rules { background: var(--surface-subtle); }
.rule-list { display: grid; gap: 10px; }
.rule-card { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 15px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.rule-card-main { display: flex; align-items: flex-start; min-width: 0; gap: 12px; }
.rule-card-title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.rule-card-title h3 { margin: 0; }
.rule-card-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.rule-card p { margin: 5px 0; color: var(--muted); }
.preview-box { margin-top: 18px; padding: 16px; background: var(--surface-subtle); border: 1px solid var(--line-strong); border-radius: 7px; }
.scenario-panel { margin-top: 18px; }
.scenario-panel #scenario-result { margin-top: 18px; }
.cost-check { margin-top: 16px; background: var(--surface-subtle); }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-grid, .insight-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cost-type-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .invoice-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 50; inset: 34px auto 0 0; width: min(320px, 88vw); height: calc(100vh - 34px); transform: translateX(-105%); transition: transform 180ms ease; box-shadow: var(--shadow-md); }
  .sidebar.open { transform: translateX(0); }
  .workspace { max-width: none; padding: 22px 20px 36px; }
  .mobile-menu { display: inline-grid; }
  .topbar { justify-content: flex-start; }
  .topbar-actions { margin-left: auto; }
  .split-grid, .chat-layout { grid-template-columns: 1fr; }
  .chat-history { border-right: 0; border-bottom: 1px solid var(--line); }
  .chat-history-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .receipt-table { display: none; }
  .receipt-cards { display: grid; }
  .cost-type-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .invoice-review { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .workspace { padding: 18px 14px 30px; }
  .topbar { align-items: center; gap: 10px; }
  .topbar-actions { width: auto; margin-left: auto; gap: 5px; }
  .topbar .eyebrow { margin-bottom: 1px; font-size: 11px; }
  .topbar h1 { max-width: 48vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .profile-menu-popover { position: fixed; top: 64px; right: 14px; min-width: min(280px, calc(100vw - 28px)); }
  h1 { font-size: 25px; }
  .metric-grid, .page-grid, .action-grid, .insight-grid, .choice-grid { grid-template-columns: 1fr; }
  .metric-card .value { font-size: 24px; }
  .panel { padding: 17px; }
  .document-hero, .cost-hero { align-items: flex-start; min-height: 0; padding: 22px 20px; }
  .document-hero h2, .cost-hero h2 { font-size: 24px; }
  .document-hero .brand-signal, .cost-hero .brand-signal { display: none; }
  .upload-panel, .document-list, .cost-builder, .saved-rules { padding: 17px; }
  .chat-layout { height: max(430px, calc(100dvh - 78px)); min-height: 430px; }
  .chat-history { display: none; }
  .chat-main { grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); }
  .chat-main { width: 100%; max-width: 100%; overflow: hidden; }
  .chat-main-header, .chat-log, .chat-composer { width: 100%; max-width: 100%; }
  .chat-main-header, .chat-log, .chat-composer, .chat-message { min-width: 0; box-sizing: border-box; }
  .message-actions { display: flex; flex-wrap: wrap; max-width: 100%; }
  .chat-main-header { align-items: center; padding: 12px 14px; }
  .conversation-heading { max-width: calc(100% - 102px); gap: 9px; }
  .conversation-heading .eyebrow { display: none; }
  .conversation-heading h2 { max-width: 100%; font-size: 16px; }
  .lunar-orbit { flex-basis: 38px; width: 38px; height: 38px; }
  .chat-log { padding: 16px 14px 10px; scroll-padding-bottom: 94px; }
  .chat-composer { position: sticky; bottom: 0; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 24px rgb(21 32 28 / 8%); }
  .chat-composer-row { grid-template-columns: minmax(0, 1fr) 48px; width: 100%; min-width: 0; }
  .chat-composer textarea { min-height: 48px; max-height: 144px; }
  .chat-message { max-width: 100%; }
  .message-tools { flex-wrap: wrap; opacity: 1; }
  .preference-card { display: grid; }
  .message-tools > button, .answer-menu > summary { min-height: 38px; }
  .lunar-reminder-popover { position: fixed; top: 64px; right: 14px; width: min(340px, calc(100vw - 28px)); max-height: min(60dvh, 460px); overflow-y: auto; }
  .lunar-surface::after, .chat-main::before { opacity: .45; }
  .lunar-surface::before { right: -62px; bottom: -102px; width: 218px; height: 218px; }
  .lunar-empty { min-height: 100%; padding: 32px 20px; }
  .lunar-samples { display: grid; width: 100%; }
  .lunar-sample { width: 100%; min-height: 44px; }
  .summary-list div { grid-template-columns: 1fr; gap: 3px; }
  .form-grid { grid-template-columns: 1fr; }
  .invoice-steps { grid-template-columns: 1fr; }
  .issuer-summary { display: grid; }
  .tax-control-bar { align-items: stretch; }
  .tax-control-bar .field { width: 100%; min-width: 0; }
  .monthly-tax-workspace { padding: 14px; }
  .monthly-tax-heading { display: grid; gap: 10px; }
  .monthly-tax-metrics { display: grid; grid-template-columns: 1fr; gap: 0; border-top: 1px solid var(--line); }
  .monthly-tax-metrics article { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 8px 2px; background: transparent; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
  .monthly-tax-metrics article strong { order: 2; font-size: 1rem; }
  .monthly-tax-metrics article span { order: 1; }
  .monthly-tax-grid { grid-template-columns: 1fr; gap: 8px; }
  .monthly-tax-document { grid-template-columns: 1fr; gap: 6px; }
  .product-tax-fact-source form { grid-template-columns: 1fr; }
  .product-tax-fact-source form button { width: 100%; }
  .product-tax-manual-resolution form button { width: 100%; }
  .monthly-tax-actions { display: grid; grid-template-columns: 1fr; }
  .rule-card { align-items: stretch; flex-direction: column; }
  .rule-card-actions { justify-content: flex-start; }
  .cost-type-grid { grid-template-columns: 1fr; }
  .cost-type-card { min-height: 106px; }
  .cost-editor-heading { align-items: stretch; flex-direction: column; }
  .cost-selection-help { align-items: flex-start; flex-direction: column; text-align: left; }
  .receipt-card-top { align-items: flex-start; }
  .receipt-card { padding: 13px; }
  .receipt-card dl { margin: 9px 0; }
  .receipt-card dl > div { padding: 6px 0; }
  .review-queue-cards .button-row { align-items: stretch; }
  .review-queue-cards .button-row .button { width: 100%; }
  .product-mapping-focus-panel { padding: 13px; }
  .supplier-variant-results { max-height: none; overflow: visible; border: 0; background: transparent; }
  .supplier-variant-result { min-height: 58px; padding: 10px; border-color: var(--line); }
  .picker-actions { display: grid; grid-template-columns: 1fr; }
  .inventory-movement-row { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; }
  .inventory-movement-row time, .inventory-movement-row > span:not(.inventory-movement-amount), .inventory-movement-row details { grid-column: 1 / -1; }
  .inventory-movement-row .inventory-movement-amount { grid-column: 2; grid-row: 2; }
  .archive-option { min-height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .loading-state::before { animation: none; border-color: var(--accent); }
  .thinking-dots i { animation: none; opacity: 1; }
  .progress-track > span { animation: none; }
  .lunar-sample:hover { transform: none; }
  .cost-type-card:hover { transform: none; }
}

/* Founder review remediation: compact Shopify settings and a readable Lunar Chat canvas. */
.automation-page { width: min(100%, 1120px); gap: 16px; padding-bottom: calc(104px + env(safe-area-inset-bottom)); }
.automation-intro { max-width: 680px; }
.automation-tabs { position: sticky; z-index: 3; top: 0; padding: 5px; background: color-mix(in srgb, var(--canvas) 92%, transparent); backdrop-filter: blur(16px); }
.automation-tabs button { min-height: 42px; }
.automation-tabs button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.automation-policy-card { min-height: 156px; padding: 15px; }
.automation-policy-card small { color: var(--muted); font-size: 12px; }
.automation-policy-card > span:last-child { line-height: 1.42; }
.automation-disclosure { max-width: 860px; padding: 16px; }
.automation-supplier-card { gap: 14px; }
.automation-supplier-card .button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.automation-empty { display: grid; justify-items: start; gap: 10px; min-height: 180px; padding: 24px; }
.automation-empty h3, .automation-empty p { margin: 0; }
.automation-draft-queue { display: grid; gap: 12px; }
.automation-draft-queue > div:first-child h3 { margin: 3px 0 0; }
.automation-dialog { max-height: min(720px, calc(100dvh - 24px)); overflow: auto; }
.automation-dialog-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; }
.automation-dialog-facts div { padding: 10px; background: var(--surface-subtle); border: 1px solid var(--line); border-radius: 6px; }
.automation-dialog-facts dt { color: var(--muted); font-size: 12px; }
.automation-dialog-facts dd { margin: 3px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.automation-feedback { margin: 0; padding: 11px 13px; border: 1px solid var(--line); border-left: 3px solid var(--line-strong); border-radius: 7px; }
.automation-feedback.success { color: var(--success); border-left-color: var(--success); background: var(--success-bg); }
.automation-feedback.error { color: var(--danger); border-left-color: var(--danger); background: var(--danger-bg); }
.automation-savebar { z-index: 4; bottom: max(12px, env(safe-area-inset-bottom)); }
.automation-savebar[data-save-state="unsaved"] .automation-dirty { color: var(--warning); }
.automation-savebar[data-save-state="saving"] .automation-dirty { color: var(--muted); }
.automation-savebar[data-save-state="saved"] .automation-dirty { color: var(--success); }
.automation-savebar[data-save-state="error"] { border-color: var(--danger); }
.automation-savebar[data-save-state="error"]:has(.automation-dirty:not(:empty)) .automation-dirty { color: var(--danger); }

.lunar-workspace .lunar-home-header { width: min(100%, 1040px); margin: 0 auto 10px; }
.lunar-workspace .lunar-home-identity { display: flex; align-items: center; gap: 14px; min-width: 0; }
.lunar-workspace .lunar-home-identity img { width: 126px; height: 42px; }
.lunar-workspace .lunar-home-identity .eyebrow { margin: 0; color: #8ee2c4; }
.lunar-workspace .lunar-home-identity p:last-child { margin: 3px 0 0; max-width: 640px; color: #b5c1bc; }
.lunar-system-status { display: grid; width: min(100%, 1040px); margin: 12px auto 20px; padding: 4px 0 2px; background: transparent; border: 0; border-radius: 0; justify-items: center; }
.lunar-system-status-heading { display: flex; align-items: center; justify-content: center; gap: 9px; margin: 0 0 10px; }
.lunar-system-status-heading h2 { margin: 0; color: #dce8e4; font-size: 11px; font-weight: 780; letter-spacing: .08em; text-transform: uppercase; }
.lunar-system-status-heading span { color: #8f9c97; font-size: 12px; }
.lunar-workspace .lunar-system-status .company-status-strip { justify-content: center; flex-wrap: wrap; gap: 9px; width: 100%; }
.lunar-workspace .lunar-system-status .company-status { min-height: 42px; padding: 7px 12px; color: #c3cfca; background: rgb(255 255 255 / 3.5%); border-color: rgb(176 208 195 / 18%); border-radius: 999px; box-shadow: inset 0 1px 0 rgb(255 255 255 / 5%); cursor: pointer; font-size: 12px; }
.lunar-workspace .lunar-system-status .company-status:hover { color: #f5faf7; background: rgb(255 255 255 / 5.5%); border-color: #486159; }
.lunar-workspace .lunar-system-status .company-status:focus-visible { outline: 3px solid #18c99a; outline-offset: 2px; }
.lunar-workspace .lunar-system-status .company-status i { display: none; }
.lunar-workspace .lunar-system-status .company-status strong { color: #f3f8f5; font-size: 13px; }
.lunar-workspace .lunar-system-status .status-icon { display: inline-grid; width: 18px; height: 18px; color: #93a49d; }
.lunar-workspace .lunar-system-status .status-icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.lunar-workspace .lunar-system-status .company-status.healthy .status-icon { color: #18c99a; }
.lunar-workspace .lunar-system-status .company-status.attention .status-icon { color: #e5b859; }
.lunar-workspace .lunar-system-status .company-status.critical .status-icon { color: #f06c6c; }
.lunar-workspace .chat-layout { width: min(100%, 1040px); margin: 0 auto; }
.lunar-workspace .chat-log { padding-inline: clamp(20px, 7vw, 96px); }
.lunar-workspace .chat-message { width: min(100%, 720px); }
.lunar-workspace .chat-message.user { margin-right: 0; margin-left: auto; }
.lunar-workspace .chat-message.assistant { margin-right: auto; margin-left: 0; }
.lunar-workspace .lunar-empty { width: min(100%, 680px); margin: 0 auto; padding-block: clamp(34px, 8vh, 78px); text-align: center; justify-items: center; }
.lunar-empty-mark { display: grid; width: 56px; height: 56px; place-items: center; padding: 9px; background: #101916; border: 1px solid #2b4b41; border-radius: 8px; }
.lunar-empty-mark img { width: 100%; height: 100%; object-fit: contain; }
.lunar-workspace .lunar-samples { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: min(100%, 640px); margin-top: 26px; }
.lunar-workspace .lunar-sample { display: flex; align-items: center; min-height: 48px; padding: 10px 14px; font-size: 13px; line-height: 1.3; }
.lunar-workspace .chat-history { z-index: 65; }

@media (max-width: 600px) {
  .automation-page { padding-bottom: max(24px, calc(16px + env(safe-area-inset-bottom))); }
  .automation-tabs { margin-inline: -2px; border-radius: 7px; }
  .automation-tabs button { flex: 1 0 max-content; }
  .automation-policy-card { min-height: 0; }
  .automation-savebar { position: static; margin-inline: -2px; padding-bottom: max(12px, env(safe-area-inset-bottom)); border-radius: 8px; }
  .automation-dialog-facts { grid-template-columns: 1fr; }
  .lunar-workspace .lunar-home-header { margin-bottom: 8px; }
  .lunar-workspace .lunar-home-identity { align-items: flex-start; }
  .lunar-workspace .lunar-home-identity img { width: 78px; height: 32px; }
  .lunar-system-status { margin: 8px auto 10px; padding: 2px 0; justify-items: stretch; }
  .lunar-system-status-heading { justify-content: flex-start; margin-bottom: 8px; }
  .lunar-system-status-heading span { display: none; }
  .lunar-system-status .company-status-strip { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
  .lunar-system-status .company-status { flex: 0 0 auto; }
  .lunar-system-status .company-status span:last-child { font-size: 11px; }
  .lunar-workspace .chat-log { padding-inline: 12px; }
  .lunar-workspace .lunar-samples { grid-template-columns: 1fr; }
  .lunar-workspace .chat-layout.history-opened .chat-history { position: absolute; z-index: 80; inset: 0 auto 0 0; display: grid; width: min(320px, 88vw); box-shadow: 20px 0 45px rgb(0 0 0 / 45%); }
}

/* Shopify automation settings: compact, review-first controls within the Lunar shell. */
.automation-page { display: grid; gap: 18px; max-width: 1180px; }
.automation-intro { max-width: 760px; }
.automation-intro h2 { margin-bottom: 8px; }
.automation-intro p:last-child { margin: 0; color: var(--muted); }
.automation-tabs { display: flex; gap: 4px; max-width: 100%; padding: 4px; overflow-x: auto; background: var(--surface-subtle); border: 1px solid var(--line); border-radius: 8px; scrollbar-width: thin; }
.automation-tabs button { flex: 0 0 auto; min-height: 40px; padding: 8px 13px; color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: 6px; cursor: pointer; font-weight: 720; }
.automation-tabs button:hover { color: var(--ink); background: var(--surface); }
.automation-tabs button.active { color: var(--ink); background: var(--surface); border-color: var(--accent); box-shadow: inset 0 -2px var(--accent); }
.automation-content { min-width: 0; }
.automation-section { display: grid; gap: 16px; }
.automation-section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.automation-section-heading h2 { margin-bottom: 5px; }
.automation-section-heading p:last-child { margin: 0; }
.automation-grid { display: grid; gap: 16px; }
.automation-grid.two-up { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.automation-panel { display: grid; align-content: start; gap: 14px; }
.automation-panel h3, .automation-panel p { margin: 0; }
.automation-choice-group { display: grid; gap: 8px; margin: 0; padding: 0; border: 0; }
.automation-choice-group legend { margin-bottom: 6px; }
.automation-choice-card { position: relative; display: grid; gap: 3px; min-height: 76px; padding: 13px 42px 13px 14px; color: var(--text); background: var(--surface-subtle); border: 1px solid var(--line); border-radius: 7px; cursor: pointer; }
.automation-choice-card:has(input:checked) { border-color: var(--accent); box-shadow: inset 3px 0 var(--accent); }
.automation-choice-card input { position: absolute; top: 17px; right: 14px; width: 18px; height: 18px; accent-color: var(--accent); }
.automation-choice-card span { color: var(--muted); font-size: 13px; }
.automation-switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); cursor: pointer; }
.automation-switch > span:first-child { display: grid; gap: 3px; min-width: 0; }
.automation-switch small { color: var(--muted); }
.automation-switch-control { position: relative; display: inline-flex !important; align-items: center; gap: 8px; flex: 0 0 auto; min-width: 70px; min-height: 36px; }
.automation-switch-control input { position: absolute; opacity: 0; }
.automation-switch-control i { position: relative; width: 42px; height: 24px; pointer-events: none; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface-strong); }
.automation-switch-control i::after { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; background: var(--text); border-radius: 50%; content: ''; transition: transform 140ms ease; }
.automation-switch-control input:checked + i { background: var(--accent); border-color: var(--accent); }
.automation-switch-control input:checked + i::after { background: #06120e; transform: translateX(18px); }
.automation-switch-control input:focus-visible + i { outline: 3px solid var(--focus); outline-offset: 3px; }
.automation-switch-control b { min-width: 19px; color: var(--muted); font-size: 12px; }
.automation-switch-control input:checked ~ b { color: var(--accent); }
.automation-note { margin: 0; padding: 11px 12px; color: var(--muted); background: var(--surface-subtle); border-left: 3px solid var(--line-strong); border-radius: 4px; font-size: 13px; }
.automation-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.automation-fields .field { margin: 0; }
.input-unit { display: grid; grid-template-columns: minmax(0, 1fr) auto; overflow: hidden; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 6px; }
.input-unit:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.input-unit input { min-width: 0; border: 0; }
.input-unit span { display: grid; place-items: center; min-width: 42px; padding: 0 10px; color: var(--muted); background: var(--surface-subtle); border-left: 1px solid var(--line); font-size: 13px; }
.automation-summary { display: grid; gap: 5px; padding: 14px; background: var(--surface-subtle); border: 1px solid var(--line); border-radius: 7px; }
.automation-summary span { color: var(--muted); font-size: 13px; }
.automation-policy-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0; padding: 0; border: 0; }
.automation-policy-card { position: relative; display: grid; gap: 9px; min-height: 180px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.automation-policy-card:hover { border-color: var(--line-strong); }
.automation-policy-card.selected { border-color: var(--accent); box-shadow: inset 0 3px var(--accent); }
.automation-policy-card input { position: absolute; top: 16px; right: 16px; accent-color: var(--accent); }
.automation-policy-card > span:last-child { color: var(--muted); }
.automation-policy-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding-right: 24px; color: var(--ink); }
.automation-policy-title em { flex: 0 0 auto; padding: 2px 6px; color: var(--accent); background: var(--accent-soft); border: 1px solid rgb(24 201 154 / 35%); border-radius: 4px; font-size: 11px; font-style: normal; font-weight: 750; }
.automation-disclosure { display: grid; gap: 8px; max-width: 760px; }
.automation-disclosure h3, .automation-disclosure p { margin: 0; }
.automation-disclosure .button { justify-self: start; }
.automation-supplier-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.automation-supplier-card { display: grid; gap: 12px; padding: 17px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.automation-supplier-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.automation-supplier-head h3, .automation-supplier-head p { margin: 0; }
.automation-supplier-head p { margin-top: 3px; color: var(--muted); font-size: 13px; }
.automation-supplier-card dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; margin: 0; }
.automation-supplier-card dt { color: var(--muted); font-size: 12px; }
.automation-supplier-card dd { margin: 2px 0 0; color: var(--ink); font-size: 13px; font-weight: 700; overflow-wrap: anywhere; }
.automation-warning { margin: 0; padding: 9px 10px; color: var(--warning); background: var(--warning-bg); border-left: 3px solid var(--warning); border-radius: 4px; font-size: 13px; }
.automation-dialog { width: min(520px, calc(100vw - 32px)); padding: 0; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: var(--shadow-md); }
.automation-dialog::backdrop { background: rgb(0 0 0 / 62%); }
.automation-dialog form { display: grid; gap: 13px; padding: 22px; }
.automation-dialog h2, .automation-dialog p { margin: 0; }
.automation-dialog ul { display: grid; gap: 6px; margin: 0; padding-left: 20px; color: var(--muted); }
.automation-timeline { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.automation-timeline > li { position: relative; display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 12px; padding-bottom: 16px; }
.automation-timeline > li:last-child { padding-bottom: 0; }
.automation-timeline > li:not(:last-child)::before { position: absolute; top: 20px; bottom: 0; left: 9px; width: 1px; background: var(--line); content: ''; }
.automation-timeline-marker { position: relative; z-index: 1; width: 19px; height: 19px; margin-top: 4px; background: var(--surface); border: 4px solid var(--accent); border-radius: 50%; }
.automation-timeline article { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px 18px; padding: 15px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.automation-timeline h3, .automation-timeline p { margin: 0; }
.automation-timeline time { color: var(--muted); font-size: 13px; white-space: nowrap; }
.automation-timeline article > p, .automation-timeline details { grid-column: 1 / -1; color: var(--muted); }
.automation-timeline details summary { min-height: 34px; color: var(--accent); cursor: pointer; font-weight: 720; }
.automation-timeline details p { margin: 7px 0 0; }
.automation-savebar { position: sticky; bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 14px; background: var(--surface-strong); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: var(--shadow-md); }
.automation-dirty { color: var(--muted); font-size: 13px; font-weight: 700; }
.automation-savebar:has(.automation-dirty:not(:empty)) .automation-dirty { color: var(--accent); }

@media (max-width: 920px) {
  .automation-grid.two-up, .automation-policy-grid, .automation-supplier-list { grid-template-columns: 1fr; }
  .automation-policy-card { min-height: 132px; }
}

@media (max-width: 600px) {
  .automation-page { gap: 14px; }
  .automation-section-heading { display: block; }
  .automation-fields { grid-template-columns: 1fr; }
  .automation-supplier-card dl { grid-template-columns: 1fr; }
  .automation-timeline article { grid-template-columns: 1fr; }
  .automation-timeline time { grid-row: 1; }
  .automation-savebar { bottom: max(8px, env(safe-area-inset-bottom)); align-items: stretch; flex-direction: column; }
  .automation-savebar .button { width: 100%; }
}

.mapping-review-list {
  display: grid;
  gap: 16px;
}

.mapping-review-card {
  display: grid;
  gap: 14px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.mapping-review-card:first-child { border-top: 0; }
.mapping-review-card .button[hidden] { display: none !important; }
.mapping-review-card[data-can-assign="false"] .button-row { display: none; }
.mapping-review-card h3 { margin: 4px 0 6px; }
.mapping-review-card .summary-list { margin: 0; }
.mapping-review-card select:focus-visible {
  border-color: #18c99a;
  outline: 2px solid #18c99a;
  outline-offset: 2px;
}

/* Final responsive shell lock: all authenticated surfaces stay inside the safe viewport. */
html,
body {
  max-inline-size: 100%;
  overflow-x: clip;
}
*,
*::before,
*::after { box-sizing: border-box; }
.app-shell,
.workspace,
.topbar,
.topbar-actions,
#main-content,
#page,
.lunar-workspace,
.lunar-home-header,
.lunar-home-identity,
.company-status-strip,
.chat-layout,
.chat-main,
.chat-main-header,
.conversation-heading,
.chat-header-actions,
.chat-log,
.chat-composer,
.chat-composer-row,
.chat-composer-row .field,
.insight-rail { min-width: 0; max-width: 100%; }
.workspace { inline-size: 100%; }
.topbar {
  inline-size: 100%;
  padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right));
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.tasks-shortcut[hidden] { display: none !important; }

.lunar-home-header {
  display: grid;
  grid-template-columns: minmax(300px, .95fr) minmax(0, 1.35fr);
  align-items: center;
  inline-size: 100%;
}
.lunar-home-identity { inline-size: 100%; }
.lunar-home-header img { flex: 0 1 auto; max-width: min(360px, 100%); }
.lunar-home-header p { min-width: 0; overflow-wrap: anywhere; text-wrap: balance; }
.lunar-workspace .company-status-strip {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: none;
  scroll-padding-inline: 10px;
}
.lunar-workspace .company-status-strip::-webkit-scrollbar { display: none; }
.lunar-workspace .company-status { flex: 0 0 auto; white-space: nowrap; }

.lunar-workspace .chat-main-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
}
.conversation-heading h2 {
  max-width: 100%;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.lunar-workspace .chat-header-actions > .icon-button {
  width: 42px;
  min-width: 42px;
  height: 42px;
  min-height: 42px;
  color: #d9e5e0;
  background: transparent;
  border: 0;
  box-shadow: none;
}
.lunar-workspace .chat-header-actions > .icon-button:hover,
.lunar-workspace .chat-header-actions > .icon-button:focus-visible {
  color: #79dab5;
  background: rgb(255 255 255 / 5%);
}
.notification-trigger { position: relative; }
#notification-trigger { anchor-name: --notification-trigger; }
#conversation-menu-trigger { anchor-name: --conversation-menu-trigger; }

.workspace-popover {
  position: fixed;
  z-index: 140;
  top: max(76px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  bottom: auto;
  display: grid;
  width: min(340px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: min(68dvh, 520px);
  margin: 0;
  overflow: auto;
  overscroll-behavior: contain;
  color-scheme: dark;
  color: #edf3f0;
  background: rgb(15 20 18 / 98%);
  border: 1px solid rgb(199 221 212 / 18%);
  border-radius: 10px;
  box-shadow: 0 20px 54px rgb(0 0 0 / 56%);
  backdrop-filter: blur(20px);
}
.workspace-popover[hidden] { display: none !important; }
#conversation-menu-popover { width: min(230px, calc(100vw - 24px)); padding: 6px; }
#notification-popover { padding: 14px; }
.workspace-popover button { color: #edf3f0; }
.workspace-popover button:focus-visible { outline: 2px solid var(--lunar-accent); outline-offset: -2px; }
@supports (position-anchor: --conversation-menu-trigger) {
  #conversation-menu-popover {
    position-anchor: --conversation-menu-trigger;
    top: auto;
    right: auto;
    position-area: bottom span-left;
    position-try-fallbacks: flip-block, flip-inline;
    margin-top: 8px;
  }
  #notification-popover {
    position-anchor: --notification-trigger;
    top: auto;
    right: auto;
    position-area: bottom span-left;
    position-try-fallbacks: flip-block, flip-inline;
    margin-top: 8px;
  }
}

.lunar-workspace .chat-composer-row { width: 100%; }
.lunar-workspace .chat-composer textarea {
  width: 100%;
  max-width: 100%;
  field-sizing: content;
  overflow-y: auto;
}
.lunar-workspace .lunar-orb { flex: 0 0 50px; max-width: 50px; }
.lunar-workspace .lunar-orb:disabled {
  color: #7f9189;
  background: #101512;
  border-color: rgb(171 207 193 / 18%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 7%);
}
.profile-menu-popover,
dialog,
dialog form { max-inline-size: calc(100vw - 24px); }
.table-wrap { max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }

@media (max-width: 980px) {
  .lunar-workspace-active { height: 100dvh; min-height: 100svh; }
  .lunar-workspace-active .app-shell,
  .lunar-workspace-active .workspace,
  .lunar-workspace-active #main-content,
  .lunar-workspace-active #page { min-height: 0; height: 100%; }
  .lunar-workspace {
    width: 100%;
    padding-inline: max(10px, env(safe-area-inset-left)) max(10px, env(safe-area-inset-right));
  }
  .lunar-home-header { grid-template-columns: minmax(0, 1fr); align-items: stretch; gap: 10px; }
  .lunar-home-identity { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 16px; }
  .lunar-home-header img { width: min(210px, 42vw); height: 50px; }
  .lunar-home-header p { width: 100%; margin: 0; }
  .lunar-workspace .company-status-strip {
    justify-content: flex-start;
    width: 100%;
    padding: 2px 12px 5px 2px;
    gap: 12px;
  }
  .lunar-workspace .company-status-strip::after { flex: 0 0 1px; content: ""; }
  .insight-rail {
    width: 100%;
    max-width: 100%;
    padding-inline: 4px 12px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
  }
  .insight-rail::-webkit-scrollbar { display: none; }
  .insight-flyout {
    right: max(8px, env(safe-area-inset-right));
    left: max(8px, env(safe-area-inset-left));
    width: auto;
    max-width: none;
    max-height: min(58dvh, calc(100dvh - 210px));
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }
  .profile-menu-popover {
    position: fixed;
    top: calc(62px + env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
    left: max(12px, env(safe-area-inset-left));
    width: auto;
    min-width: 0;
  }
}

@media (max-width: 680px) {
  .lunar-workspace-active .topbar {
    min-height: 56px;
    padding-block: 7px;
  }
  .lunar-workspace-active .topbar-actions { gap: 4px; }
  .lunar-home-header { margin-bottom: 7px; }
  .lunar-home-identity { grid-template-columns: 1fr; justify-items: start; gap: 5px; }
  .lunar-home-header img { width: min(160px, 52vw); height: 36px; }
  .lunar-home-header p { font-size: .94rem; line-height: 1.3; }
  .lunar-workspace .company-status-strip { padding-bottom: 4px; }
  .lunar-workspace .chat-main-header { min-height: 54px; padding: 7px 2px 8px; gap: 4px; }
  .conversation-heading h2 {
    display: -webkit-box;
    font-size: .98rem;
    line-height: 1.25;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
  .chat-header-actions { gap: 0; }
  .lunar-workspace .chat-header-actions > .icon-button {
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
  }
  .lunar-workspace .chat-log { padding-inline: 4px; scrollbar-gutter: auto; }
  .lunar-workspace .chat-message { max-width: 100%; }
  .lunar-workspace .chat-composer {
    width: 100%;
    padding: 9px max(2px, env(safe-area-inset-right)) calc(9px + env(safe-area-inset-bottom)) max(2px, env(safe-area-inset-left));
  }
  .lunar-workspace .chat-composer-row { grid-template-columns: minmax(0, 1fr) 46px; gap: 7px; align-items: end; }
  .lunar-workspace .lunar-orb { width: 46px; min-width: 46px; max-width: 46px; height: 46px; min-height: 46px; }
  .voice-state-copy { max-width: 100%; overflow-wrap: anywhere; }
  .workspace-popover { max-height: min(60dvh, calc(100dvh - 108px)); }
  #notification-popover { width: calc(100vw - 24px); }
  #conversation-menu-popover,
  #notification-popover {
    top: auto;
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
    left: max(12px, env(safe-area-inset-left));
    width: auto;
  }
  .notification-popover-heading { align-items: flex-start; flex-direction: column; }
  .notification-popover-heading .button { width: auto; }
  dialog { width: calc(100vw - 24px); max-height: calc(100dvh - 24px); overflow: auto; }
  #monthly-tax-package-dialog[open] {
    inset-block-start: max(12px, env(safe-area-inset-top));
    inset-block-end: auto;
    margin-block: 0;
    max-height: calc(100dvh - max(24px, env(safe-area-inset-top) + env(safe-area-inset-bottom)));
    overscroll-behavior: contain;
  }
  #monthly-tax-package-dialog .dialog-actions {
    position: sticky;
    bottom: 0;
    z-index: 1;
    margin-top: 12px;
    padding: 12px 0 max(4px, env(safe-area-inset-bottom));
    background: var(--surface);
  }
}


@media (orientation: landscape) and (max-height: 520px) {
  .lunar-home-header { display: none; }
  .lunar-workspace { padding-top: 5px; }
  .workspace-popover { max-height: calc(100dvh - 24px); }
  .insight-flyout { max-height: calc(100dvh - 110px); bottom: calc(78px + env(safe-area-inset-bottom)); }
}

/* Final authenticated product theme and mobile interaction lock. */
html,
body { background: var(--canvas); }
body { color: var(--text); }
body,
.app-shell,
.workspace,
#main-content,
#page { min-width: 0; }

.public-beta-notice {
  position: relative;
  z-index: 45;
  display: flex;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 6px max(16px, env(safe-area-inset-left)) 6px max(16px, env(safe-area-inset-right));
  color: #cbd5d1;
  background: #0e1210;
  border: 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
}
.public-beta-notice strong { color: var(--lunar-accent); }
.public-beta-notice details { position: relative; }
.public-beta-notice summary {
  color: var(--lunar-accent);
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}
.public-beta-notice summary::-webkit-details-marker { display: none; }
.public-beta-notice details p {
  position: absolute;
  z-index: 60;
  top: calc(100% + 9px);
  right: 0;
  width: min(360px, calc(100vw - 24px));
  margin: 0;
  padding: 12px 14px;
  color: var(--text);
  background: #141917;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  text-align: left;
}

.app-shell,
.workspace,
.topbar,
.sidebar,
.panel,
.metric-card,
.action-card,
.connection-card,
.loading-state,
.empty,
dialog { color-scheme: dark; }
.app-shell,
.workspace,
#main-content { background: var(--canvas); }
.topbar {
  background: rgb(15 24 31 / 94%);
  border-color: var(--line);
  backdrop-filter: blur(18px);
}
.sidebar {
  color: var(--text);
  background: var(--sidebar);
  border-color: var(--line);
}
.sidebar::before { display: none; }
.sidebar .brand { background: transparent; }
.sidebar nav button,
.sidebar nav a { color: #bdc9c4; background: transparent; }
.sidebar nav button:hover,
.sidebar nav a:hover { color: #fff; background: var(--surface-subtle); }
.sidebar nav .active,
.sidebar nav [aria-current="page"] {
  color: #f4fbf8;
  background: rgb(24 201 154 / 8%);
  border-color: transparent;
  box-shadow: inset 3px 0 0 var(--lunar-accent);
}
.sidebar-footer { color: var(--muted); border-color: var(--line); }

.icon-button,
.profile-menu > summary {
  color: var(--text);
  background: transparent;
  border-color: transparent;
}
.icon-button:hover,
.profile-menu > summary:hover { color: #fff; background: var(--surface-subtle); border-color: var(--line); }
.profile-initial {
  color: #05110d;
  background: var(--lunar-accent);
  border-color: transparent;
}
.profile-menu-popover {
  color: var(--text);
  background: #121614;
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
}
body:not(.lunar-workspace-active) .profile-menu-popover { background: var(--surface); }
.profile-menu-links { border-color: var(--line); }
.profile-route { color: var(--text); }
.profile-route:hover,
.profile-route:focus-visible { color: #fff; background: var(--surface-subtle); }

.panel,
.metric-card,
.action-card,
.connection-card,
.choice-card,
.loading-state,
.empty,
.table-wrap,
table,
dialog {
  color: var(--text);
  background: var(--surface);
  border-color: var(--line);
  box-shadow: none;
}
th { color: var(--ink); background: var(--surface-subtle); }
th,
td { border-color: var(--line); overflow-wrap: normal; word-break: normal; }
.field input,
.field select,
.field textarea,
input,
select,
textarea {
  color: var(--text);
  background: var(--canvas);
  border-color: var(--line-strong);
}
:where(button, a, input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--lunar-accent);
  outline-offset: 2px;
}
.button.primary {
  color: #04100c;
  background: var(--lunar-accent);
  box-shadow: none;
}
.button.primary:hover:not([disabled]) { background: var(--lunar-accent); filter: brightness(1.08); box-shadow: none; }
.button.secondary {
  color: var(--text);
  background: var(--surface-subtle);
  border-color: var(--line-strong);
}
.button.secondary:hover:not([disabled]) { color: #fff; background: var(--surface-strong); }
.button.quiet,
.button.text,
.button.text-button { color: var(--lunar-accent); background: transparent; }
.status.success { color: var(--lunar-accent); background: rgb(24 201 154 / 9%); }
.progress-track > span { background: var(--lunar-accent); }

.lunar-workspace .company-status-strip {
  position: relative;
  max-width: 100%;
  scrollbar-width: none;
}
.lunar-workspace .company-status-strip::-webkit-scrollbar { display: none; }
.lunar-workspace .company-status {
  flex: 0 0 auto;
  color: #aebbb7;
  background: transparent;
  border-color: transparent;
}
.lunar-workspace .company-status.healthy i { background: var(--lunar-accent); }
.lunar-workspace .company-status.attention i { background: var(--warning); }
.lunar-workspace .company-status.critical i { background: var(--danger); }

.lunar-workspace .chat-message.user { border-right-color: var(--lunar-accent); }
.lunar-workspace .lunar-assistant-mark,
.lunar-workspace .lunar-thinking-mark { background: transparent; }
.lunar-workspace .chat-composer textarea:focus,
.lunar-workspace .chat-composer textarea:focus-visible {
  border-color: var(--lunar-accent);
  box-shadow: 0 0 0 3px rgb(24 201 154 / 16%);
}
.lunar-orb.has-text {
  color: #eafff8;
  background: rgb(24 201 154 / 16%);
  border-color: var(--lunar-accent);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 12%), 0 10px 24px rgb(0 0 0 / 30%);
}
.lunar-orb.has-text:hover:not(:disabled) { border-color: var(--lunar-accent); box-shadow: 0 12px 28px rgb(0 0 0 / 36%); }
.lunar-orb:focus-visible { outline-color: var(--lunar-accent); }
.lunar-orb.is-processing { color: var(--lunar-accent); border-color: var(--lunar-accent); }

.insight-rail { background: transparent; border: 0; backdrop-filter: none; }
.insight-button,
.insight-button:hover,
.insight-button:focus-visible,
.insight-button[aria-expanded="true"] {
  color: #aab9b4;
  background: transparent;
  border: 0;
  box-shadow: none;
}
.insight-button:hover,
.insight-button:focus-visible,
.insight-button[aria-expanded="true"] { color: var(--lunar-accent); }
.insight-button:focus-visible { outline-color: var(--lunar-accent); }
.insight-flyout,
.lunar-reminder-popover,
.conversation-menu-popover,
.workspace-popover {
  color: var(--text);
  background: rgb(17 22 20 / 98%);
  border-color: var(--line-strong);
}
.insight-flyout .button.primary { background: var(--lunar-accent); }

.notification-popover-heading h3 { color: var(--ink); margin: 0; }
#mark-all-notifications-read {
  min-height: 34px;
  padding: 5px 8px;
  color: var(--lunar-accent);
}
#mark-all-notifications-read:disabled { color: var(--muted); opacity: .55; }
.notification-open { color: var(--text); }
.notification-list .is-unread .notification-open strong,
.notification-action-label { color: var(--lunar-accent); }
.notification-action-label { margin-top: 3px; font-size: 12px; font-weight: 750; }
.notification-badge { color: #04100c; background: var(--lunar-accent); }

.billing-record-list { display: grid; gap: 10px; }
.billing-record {
  min-width: 0;
  padding: 14px;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.billing-record dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin: 0;
}
.billing-record dt { color: var(--muted); font-size: 12px; }
.billing-record dd { margin: 3px 0 0; color: var(--ink); overflow-wrap: anywhere; }
.billing-invoice-record { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.billing-invoice-record dl { flex: 1 1 auto; }
.segmented.inventory-filter {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.segmented.inventory-filter button {
  min-height: 36px;
  padding: 7px 11px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
}
.segmented.inventory-filter button.active { color: #04100c; background: var(--lunar-accent); }
.segmented.inventory-filter button:disabled { opacity: .45; cursor: not-allowed; }

@media (max-width: 680px) {
  .public-beta-notice {
    justify-content: flex-start;
    min-height: 29px;
    gap: 7px;
    padding-block: 5px;
    overflow: visible;
    font-size: 10.5px;
    text-align: left;
  }
  .public-beta-notice > span { min-width: 0; }
  .public-beta-notice details { flex: 0 0 auto; }
  .public-beta-notice details p { position: fixed; top: 38px; right: 12px; left: 12px; width: auto; }

  .topbar { min-height: 52px; padding-inline: max(10px, env(safe-area-inset-left)) max(10px, env(safe-area-inset-right)); }
  .topbar > div:first-of-type { min-width: 0; }
  .topbar h1 { max-width: 100%; font-size: 18px; line-height: 1.2; white-space: normal; }
  .topbar .eyebrow { display: none; }

  .sidebar { padding-bottom: max(18px, env(safe-area-inset-bottom)); }
  .profile-menu-popover {
    position: fixed;
    top: auto;
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    left: max(10px, env(safe-area-inset-left));
    width: auto;
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
  }

  .lunar-workspace .company-status-strip {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    width: 100%;
    padding: 2px 18px 5px 2px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-padding-inline: 2px 18px;
    -webkit-overflow-scrolling: touch;
    mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 24px), transparent 100%);
  }
  .lunar-workspace .company-status:last-child { margin-right: 18px; }

  .insight-rail {
    flex-direction: row;
    max-width: 100%;
    padding-inline: 2px 18px;
    overflow-x: auto;
    scrollbar-width: none;
    mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 20px), transparent 100%);
  }
  .insight-rail::-webkit-scrollbar { display: none; }
  .insight-collapse .insight-icon { transform: rotate(-90deg); }

  .lunar-reminder-popover,
  .profile-menu-popover {
    border-radius: 8px;
  }
  .lunar-reminder-popover {
    position: fixed;
    inset: auto max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    width: auto;
    max-width: none;
    max-height: min(72dvh, 620px);
    overflow-y: auto;
  }
  .notification-popover-heading { align-items: flex-start; }

  .billing-invoice-record { display: grid; }
  .billing-record dl { grid-template-columns: minmax(0, 1fr); gap: 9px; }
  .billing-record dl > div { display: grid; grid-template-columns: minmax(96px, .7fr) minmax(0, 1.3fr); gap: 10px; }
  .billing-record dd { text-align: right; }

  .table-wrap:has(td[data-label]) { overflow: visible; border: 0; background: transparent; }
  .table-wrap:has(td[data-label]) table,
  .table-wrap:has(td[data-label]) tbody { display: grid; gap: 10px; background: transparent; }
  .table-wrap:has(td[data-label]) thead,
  .table-wrap:has(td[data-label]) caption { display: none; }
  .table-wrap:has(td[data-label]) tr {
    display: grid;
    gap: 8px;
    padding: 13px;
    background: var(--surface-subtle);
    border: 1px solid var(--line);
    border-radius: 8px;
  }
  .table-wrap:has(td[data-label]) :is(th, td)[data-label] {
    display: grid;
    grid-template-columns: minmax(105px, .8fr) minmax(0, 1.2fr);
    gap: 10px;
    padding: 0;
    background: transparent;
    border: 0;
    overflow-wrap: anywhere;
  }
  .table-wrap:has(td[data-label]) :is(th, td)[data-label]::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 12px;
    font-weight: 650;
  }
  .table-wrap:has(td[data-label]) :is(th, td)[data-label] > * { justify-self: end; }

  .inventory-toolbar { align-items: stretch; }
  .segmented.inventory-filter { width: 100%; }
  .segmented.inventory-filter button { flex: 1 1 50%; }
}

@media (prefers-reduced-motion: reduce) {
  .workspace-popover,
  .company-status,
  .insight-button { scroll-behavior: auto; transition: none; }
}

/* Founder desktop consolidation: a quiet data workspace with one clear next step. */
.setup-checklist,
.inventory-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 0;
  border-bottom: 1px solid var(--border, #d9e1e4);
}
.setup-checklist h2 { margin: 2px 0 6px; }
.setup-checklist p { max-width: 62ch; margin: 0; }
.checklist-actions,
.inventory-toolbar { flex-wrap: wrap; }
.checklist-actions { display: flex; gap: 10px; align-items: center; }
.inventory-toolbar .field { min-width: min(100%, 360px); margin: 0; }
.inventory-table-panel { overflow: hidden; }

.baseline-location-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.baseline-location {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
}

.baseline-location p { margin: 4px 0 0; color: var(--muted); }
.inventory-scope { margin: 14px 0; border-bottom: 1px solid var(--line); padding-bottom: 14px; }
.inventory-scope summary { font-weight: 700; cursor: pointer; min-height: 44px; display: flex; align-items: center; }
.inventory-scope-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; margin: 12px 0; }
.inventory-scope-choice { min-width: 0; align-items: flex-start; }
.inventory-scope-choice input { width: 20px; height: 20px; flex: 0 0 20px; }
.inventory-scope-choice span { min-width: 0; overflow-wrap: anywhere; }
.inventory-scope-choice small { display: block; color: var(--muted); margin-top: 2px; }
.count-editor { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 16px; }

@media (max-width: 640px) {
  .baseline-location-grid { grid-template-columns: 1fr; }
  .baseline-location { align-items: flex-start; }
  .inventory-scope-grid { grid-template-columns: 1fr; }
  .count-editor .form-grid { grid-template-columns: 1fr; }
  .count-editor input, .count-editor select, .count-editor button { min-height: 44px; }
}
.brand img { width: 34px; height: 34px; }
.brand strong { letter-spacing: .01em; }
.chat-header-actions summary,
.answer-menu summary,
.lunar-reminder-menu summary {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text, #17323a);
  background: transparent;
  cursor: pointer;
}
.chat-header-actions summary:hover,
.answer-menu summary:hover,
.lunar-reminder-menu summary:hover { background: #edf6f3; border-color: #d4e7e0; }
.chat-header-actions summary:focus-visible,
.answer-menu summary:focus-visible,
.lunar-reminder-menu summary:focus-visible { outline: 3px solid #78c5ad; outline-offset: 2px; }
.lunar-surface { box-shadow: 0 20px 44px rgba(16, 57, 67, .08); }
@media (max-width: 760px) {
  .setup-checklist, .inventory-toolbar { align-items: stretch; }
  .checklist-actions { width: 100%; }
  .unified-import-wide-label { display: none; }
  .unified-import-short-label { display: inline; }
  .unified-import-shortcut { min-width: 90px; padding-inline: 12px; }
  .unified-import-dialog-content { width: auto; }
  .connection-import-choice { min-height: 48px; }
  .connection-card-list, .connection-facts { grid-template-columns: 1fr; }
  .mail-account .connection-summary { grid-template-columns: 1fr; }
  .connection-section-heading, .connection-card-heading { align-items: flex-start; flex-direction: column; }
}

@media (forced-colors: active) {
  :focus-visible { outline: 3px solid Highlight; }
  .nav-button[aria-current="page"], .choice-card:has(input:checked), .cost-type-card.selected, .status, .notice, .error, .success-message { border: 2px solid currentColor; }
  .metric-card::before, .progress-track > span, .voice-indicator { background: CanvasText; }
  .button, .panel, .metric-card, .action-card, .drop-zone, .table-wrap, .cost-type-card, .receipt-card { box-shadow: none; }
}

html[data-motion="reduce"] *, html[data-motion="reduce"] *::before, html[data-motion="reduce"] *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
html[data-motion="reduce"] .progress-track > span { animation: none; }

/* Chat-first Lunar workspace. Detail routes keep their established dense layout. */
.app-shell { grid-template-columns: 76px minmax(0, 1fr); transition: grid-template-columns 180ms ease; }
body.nav-expanded .app-shell { grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { padding-inline: 10px; }
.brand { min-height: 62px; padding-inline: 4px; overflow: hidden; }
.brand img.brand-master-lockup { width: 52px; height: 42px; max-width: none; object-fit: contain; object-position: left center; }
body.nav-expanded .brand img.brand-master-lockup { width: 202px; }
.nav-primary-items { display: grid; gap: 6px; }
.nav-button,
.nav-more > summary { display: flex; align-items: center; width: 100%; min-height: 48px; gap: 11px; padding: 7px; color: #c8d2cf; background: transparent; border: 1px solid transparent; border-radius: 7px; cursor: pointer; text-align: left; transition: color 170ms ease, background 170ms ease, transform 170ms ease; }
.nav-button:hover,
.nav-more > summary:hover { color: #fff; background: rgb(255 255 255 / 7%); transform: scale(1.02); }
.nav-button[aria-current="page"] { color: #fff; background: rgb(24 163 118 / 15%); border-color: rgb(71 212 158 / 30%); box-shadow: inset 2px 0 #32d39a; }
.nav-mark { display: grid; place-items: center; flex: 0 0 36px; width: 36px; height: 34px; color: #dce8e4; border: 1px solid rgb(255 255 255 / 12%); border-radius: 6px; font-size: 11px; font-weight: 850; }
.nav-mark svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-lunar-badge { display: block; width: 22px; height: 22px; object-fit: contain; }
.nav-label { display: none; white-space: nowrap; }
body.nav-expanded .nav-label,
.sidebar.open .nav-label { display: inline; }
.nav-more { margin-top: 10px; border-top: 1px solid rgb(255 255 255 / 9%); padding-top: 10px; }
.nav-secondary > h2 { margin: 0 0 6px; padding-inline: 7px; color: #aebbb7; font-size: 13px; font-weight: 750; letter-spacing: .01em; }
.nav-more > summary { list-style: none; }
.nav-more > summary::-webkit-details-marker { display: none; }
.nav-more-items { display: grid; gap: 3px; margin-top: 6px; }
.nav-more:not([open]) .nav-more-items { display: none; }
.nav-more.nav-secondary:not([open]) .nav-more-items { display: grid; }
.nav-more-items .nav-button { min-height: 42px; }
.sidebar-footer { overflow: hidden; white-space: nowrap; }
.mobile-menu { display: inline-grid; }

.lunar-workspace-active { display: flex; flex-direction: column; height: 100dvh; min-height: 0; overflow: hidden; background: #090d0c; }
.lunar-workspace-active .public-beta-notice { flex: 0 0 auto; }
.lunar-workspace-active .app-shell { flex: 1 1 auto; min-height: 0; height: auto; }
.lunar-workspace-active .sidebar { min-height: 0; height: 100%; }
.lunar-workspace-active .workspace { display: flex; flex-direction: column; min-height: 0; height: 100%; max-width: none; margin: 0; padding: 0; overflow: hidden; background: #090d0c; }
.lunar-workspace-active .topbar { min-height: 66px; padding: 10px 22px; color: #f5f8f7; background: #0d1211; border-bottom: 1px solid #26312e; }
.lunar-workspace-active .topbar h1 { color: #f5f8f7; font-size: 18px; }
.lunar-workspace-active .topbar .eyebrow { color: #91a09b; }
.lunar-workspace-active .topbar .icon-button { color: #eaf1ef; background: #151c1a; border-color: #34413d; }
.lunar-workspace-active #main-content { flex: 1 1 auto; min-height: 0; overflow: hidden; }
.lunar-workspace-active #page { height: 100%; min-height: 0; }
.lunar-workspace { display: flex; flex-direction: column; height: 100%; min-height: 0; overflow: hidden; padding: 18px 20px 20px; color: #eaf0ee; background: #090d0c; }
.lunar-home-header { display: flex; align-items: center; justify-content: space-between; gap: 28px; margin-bottom: 16px; }
.lunar-home-identity { display: grid; min-width: 300px; align-content: center; justify-items: start; }
.lunar-home-header img { display: block; width: min(280px, 44vw); height: 54px; object-fit: contain; object-position: left center; }
.lunar-home-header p { margin: 8px 0 0; color: #c3ceca; font-size: 15px; }
.company-status-strip { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.company-status { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 4px 9px; color: #aebbb7; background: rgb(255 255 255 / 2.5%); border: 1px solid rgb(166 190 181 / 14%); border-radius: 999px; font-size: 11px; backdrop-filter: blur(10px); }
.company-status i { width: 7px; height: 7px; background: #71807b; border-radius: 50%; }
.company-status.healthy i { background: var(--lunar-accent); }
.company-status.attention i { background: #e5b859; }
.company-status.critical i { background: #f06c6c; }
.company-status strong { color: #f4f8f6; font-variant-numeric: tabular-nums; }

.lunar-workspace .chat-layout { flex: 1 1 auto; grid-template-columns: 190px 64px minmax(360px, 1fr) auto; min-height: 0; height: 100%; color: #e9f0ed; background: #0e1412; border-color: #293430; border-radius: 8px; box-shadow: 0 20px 54px rgb(0 0 0 / 28%); }
.lunar-workspace .chat-history { grid-column: 1; grid-row: 1; min-height: 0; overflow-y: auto; padding: 14px 12px; background: #111715; border-color: #293430; }
.lunar-workspace .chat-history input { color: #eef4f2; background: #0b100f; border-color: #33413d; }
.lunar-workspace .chat-history button { color: #c9d3cf; }
.lunar-workspace .chat-history button:hover { color: #fff; background: #1a2421; }
.lunar-workspace .chat-main { grid-column: 3; grid-row: 1; grid-template-rows: auto minmax(0, 1fr) auto; min-height: 0; height: 100%; overflow: hidden; background: #0d1211; }
.lunar-workspace .chat-main-header { min-height: 64px; border-color: #293430; }
.lunar-workspace .chat-main-header h2,
.lunar-workspace .chat-main-header .eyebrow { color: #eef4f2; }
.lunar-workspace .chat-main-header .eyebrow { color: #76d9b6; }
.lunar-workspace .chat-header-actions summary { color: #e6efec; }
.lunar-workspace .conversation-menu-popover,
.lunar-workspace .lunar-reminder-popover { color: #e9f0ed; background: #151d1a; border-color: #34413d; }
.lunar-workspace .chat-log { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; padding: 22px clamp(16px, 4vw, 58px); background: #0d1211; }
.lunar-workspace .chat-message { max-width: min(760px, 92%); padding: 15px 17px; color: #e7eeeb; background: #151c1a; border: 1px solid #2a3632; border-radius: 8px; box-shadow: none; }
.lunar-workspace .chat-message.user { margin-left: auto; color: #edf3f1; background: #111715; border-color: #2e3935; border-right: 2px solid rgb(91 205 159 / 54%); }
.lunar-workspace .message-author { display: flex; align-items: center; gap: 8px; }
.lunar-workspace .message-author time { margin-left: auto; color: #84928d; font-size: 11px; }
.lunar-workspace .lunar-assistant-mark,
.lunar-workspace .lunar-thinking-mark,
.lunar-workspace .lunar-user-mark { display: inline-grid; place-items: center; width: 28px; height: 28px; color: #07110e; background: var(--lunar-accent); border: 0; border-radius: 6px; font-size: 10px; font-weight: 900; }
.lunar-workspace .lunar-user-mark { color: #d9e9e3; background: #1b2924; border: 1px solid #385048; }
.message-contexts { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.message-contexts span,
.context-chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 8px; color: #cde9df; background: #14251f; border: 1px solid #2c5b4b; border-radius: 5px; font-size: 12px; }
.lunar-workspace .message-sources { color: #aab8b3; }
.lunar-workspace .lunar-empty { color: #dfe8e5; }
.lunar-workspace .lunar-empty-brand { width: min(260px, 70%); height: 64px; object-fit: contain; }
.lunar-workspace .lunar-empty h3 { color: #f5f8f7; font-size: 24px; }
.lunar-workspace .lunar-empty p { color: #aebbb7; }
.lunar-workspace .lunar-sample { color: #dce7e3; background: #151c1a; border-color: #34413d; }
.lunar-workspace .lunar-sample:hover { color: #fff; border-color: var(--lunar-accent); background: #19241f; }
.lunar-workspace .chat-composer { position: relative; bottom: auto; flex: 0 0 auto; padding: 12px clamp(14px, 3vw, 34px); background: #101614; border-color: #293430; box-shadow: 0 -10px 26px rgb(0 0 0 / 18%); }
.lunar-context-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.remove-context { display: grid; place-items: center; width: 22px; height: 22px; padding: 0; color: #e6efec; background: transparent; border: 0; border-radius: 4px; cursor: pointer; }
.remove-context:hover { background: rgb(255 255 255 / 10%); }
.lunar-workspace .chat-composer-row { grid-template-columns: minmax(0, 1fr) 50px; gap: 10px; }
.lunar-workspace .chat-composer textarea { color: #f0f5f3; background: #0a0f0e; border-color: #3a4843; }
.lunar-orb { position: relative; display: grid; place-items: center; align-self: end; width: 50px; min-width: 50px; height: 50px; min-height: 50px; padding: 0; overflow: hidden; color: #8c9a95; background: radial-gradient(circle at 35% 28%, rgb(255 255 255 / 10%), transparent 38%), rgb(20 30 27 / 92%); border: 1px solid rgb(171 207 193 / 28%); border-radius: 50%; box-shadow: inset 0 1px 0 rgb(255 255 255 / 9%), inset 0 -8px 16px rgb(0 0 0 / 16%), 0 10px 24px rgb(0 0 0 / 28%); transition: transform 180ms ease, color 180ms ease, background 180ms ease, border-color 180ms ease, box-shadow 180ms ease; }
.lunar-orb span[aria-hidden="true"] { position: absolute; display: grid; place-items: center; transition: opacity 160ms ease, transform 180ms ease; }
.lunar-orb svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.lunar-orb-send, .lunar-orb-stop { opacity: 0; transform: translate(-7px, 7px) scale(.82); }
.lunar-orb.has-text { color: #dffbef; background: rgb(24 201 154 / 16%); border-color: var(--lunar-accent); box-shadow: inset 0 1px 0 rgb(255 255 255 / 28%), 0 12px 26px rgb(0 0 0 / 28%); cursor: pointer; }
.lunar-orb.has-text .lunar-orb-mic { opacity: 0; transform: translate(7px, -7px) scale(.82); }
.lunar-orb.has-text .lunar-orb-send { opacity: 1; transform: none; }
.lunar-orb.is-processing .lunar-orb-mic,
.lunar-orb.is-processing .lunar-orb-send { opacity: 0; }
.lunar-orb.is-processing .lunar-orb-stop { opacity: 1; transform: none; }
.lunar-orb.has-text:hover:not(:disabled) { color: #fff; border-color: #a2efd2; box-shadow: inset 0 1px 0 rgb(255 255 255 / 36%), 0 14px 30px rgb(31 176 123 / 30%); transform: translateY(-1px) scale(1.035); }
.lunar-orb:focus-visible { outline: 2px solid #8ae8c6; outline-offset: 3px; }
.lunar-orb:disabled { opacity: 1; cursor: not-allowed; }
.lunar-orb.is-processing { color: var(--lunar-accent); border-color: var(--lunar-accent); }
.lunar-orb.is-processing::after { position: absolute; inset: 5px; content: ""; border: 1px solid rgb(144 239 198 / 65%); border-radius: 50%; animation: lunar-orb-pulse 1.2s ease-in-out infinite; }
@keyframes lunar-orb-pulse { 50% { transform: scale(1.12); opacity: .22; } }
.voice-state-copy { margin: 6px 2px 0; color: #9fada8; font-size: .78rem; }
.lunar-workspace .chat-composer > .helper { margin: 8px 2px 0; }

.insight-rail { position: relative; z-index: 9; grid-column: 2; grid-row: 1; display: flex; flex-direction: column; align-items: center; gap: 9px; min-height: 0; padding: 15px 9px; background: rgb(9 14 12 / 42%); border-right: 1px solid rgb(179 204 195 / 10%); border-left: 1px solid rgb(179 204 195 / 6%); backdrop-filter: blur(18px); }
.insight-button { position: relative; display: grid; place-items: center; flex: 0 0 46px; width: 46px; height: 46px; padding: 0; color: #aab9b4; background: rgb(255 255 255 / 3.5%); border: 1px solid rgb(174 208 195 / 16%); border-radius: 50%; box-shadow: inset 0 1px 0 rgb(255 255 255 / 5%); cursor: pointer; transition: transform 180ms ease, color 180ms ease, background-color 180ms ease, border-color 180ms ease, box-shadow 180ms ease; }
.insight-button:hover, .insight-button:focus-visible { color: #edfff8; background: rgb(75 142 117 / 14%); border-color: rgb(100 218 175 / 52%); box-shadow: inset 0 1px 0 rgb(255 255 255 / 8%), 0 8px 24px rgb(0 0 0 / 24%); transform: translateX(2px) scale(1.06); }
.insight-button:focus-visible { outline: 2px solid var(--lunar-accent); outline-offset: 3px; }
.insight-button[aria-expanded="true"] { color: #89e8c6; background: rgb(52 155 119 / 18%); border-color: rgb(91 222 174 / 66%); box-shadow: inset 0 0 0 1px rgb(89 220 173 / 12%), 0 8px 28px rgb(0 0 0 / 28%); }
.insight-icon { display: grid; place-items: center; }
.insight-icon svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.insight-label { position: absolute; z-index: 30; left: calc(100% + 12px); top: 50%; max-width: 220px; padding: 7px 10px; color: #eef7f4; background: rgb(15 23 20 / 94%); border: 1px solid rgb(112 180 155 / 32%); border-radius: 999px; box-shadow: 0 10px 30px rgb(0 0 0 / 32%); opacity: 0; pointer-events: none; white-space: nowrap; transform: translate(-5px, -50%); transition: opacity 150ms ease, transform 180ms ease; }
.insight-button:hover .insight-label, .insight-button:focus-visible .insight-label { opacity: 1; transform: translate(0, -50%); }
.insight-flyout { grid-column: 4; grid-row: 1; width: min(380px, 32vw); overflow-y: auto; padding: 18px; color: #dfe8e5; background: #141b19; border-left: 1px solid #33403c; }
.insight-flyout[hidden] { display: none; }
.insight-flyout h3 { color: #f4f8f6; }
.insight-flyout .eyebrow { color: #6ed9b3; }
.insight-flyout .button.secondary { color: #e5eeeb; background: #18211e; border-color: #3a4944; }
.insight-flyout .button.text { color: #71dcb7; background: transparent; }
.insight-flyout .empty,
.insight-empty-state { padding: 18px; color: #dfe8e5; background: rgb(8 13 11 / 72%); border: 1px solid #2c3934; border-radius: 8px; }
.insight-flyout .empty h3,
.insight-empty-state h4 { margin: 0 0 8px; color: #f4f8f6; font-size: 16px; }
.insight-flyout .empty p,
.insight-empty-state p { margin: 0 0 15px; color: #aebbb7; }
.insight-flyout-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.insight-flyout .close-insight { flex: 0 0 34px; width: 34px; height: 34px; color: #dce6e2; background: #1a2421; border-color: #3a4944; }
.insight-document-list { display: grid; gap: 10px; margin: 0 0 16px; padding: 0; list-style: none; }
.insight-document-list li { padding: 12px; background: #0f1513; border: 1px solid #2d3935; border-radius: 7px; }
.insight-document-list li > div:first-child { display: grid; gap: 3px; }
.insight-document-list span,
.insight-document-list small { color: #9eaca7; }
.insight-facts { margin: 0 0 16px; }
.insight-facts > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 9px 0; border-bottom: 1px solid #2b3532; }
.insight-facts dt { color: #94a29d; }
.insight-facts dd { margin: 0; color: #f0f5f3; text-align: right; }
.insight-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.insight-tabs span { padding: 6px 8px; color: #9eaca7; border-bottom: 2px solid transparent; }
.insight-tabs [aria-selected="true"] { color: #f0f5f3; border-color: var(--lunar-accent); }
.workspace-tour { position: fixed; z-index: 120; inset: 0; pointer-events: none; }
.workspace-tour-card { position: absolute; right: 24px; bottom: 24px; width: min(390px, calc(100vw - 32px)); padding: 20px; color: #e9f0ed; background: #151d1a; border: 1px solid #40504a; border-radius: 8px; box-shadow: 0 22px 60px rgb(0 0 0 / 45%); pointer-events: auto; }
.workspace-tour-card h2 { color: #f4f8f6; }
.workspace-tour-card p { color: #b6c2be; }
.workspace-tour-progress { margin: 14px 0; color: #76d9b6; font-size: 12px; font-weight: 800; }
.tour-highlight { position: relative; z-index: 121 !important; outline: 3px solid #45d8a4 !important; outline-offset: 4px; box-shadow: 0 0 0 9999px rgb(0 0 0 / 26%); }

@media (max-width: 1180px) {
  .lunar-home-header { align-items: flex-start; flex-direction: column; }
  .company-status-strip { justify-content: flex-start; }
  .lunar-workspace .chat-layout { grid-template-columns: 64px minmax(0, 1fr) auto; }
  .lunar-workspace .chat-main { grid-column: 2; }
  .insight-rail { grid-column: 1; }
  .insight-flyout { grid-column: 3; }
  .lunar-workspace .chat-history { display: none; }
}

@media (max-width: 980px) {
  .app-shell, body.nav-expanded .app-shell { grid-template-columns: 1fr; }
  .sidebar { width: min(300px, 88vw); }
  .sidebar .nav-label { display: inline; }
  .brand img.brand-master-lockup { width: 210px; }
  .lunar-workspace { height: 100%; min-height: 0; padding: 12px; }
  .lunar-workspace .chat-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); min-height: 0; height: 100%; overflow: hidden; }
  .lunar-workspace .chat-main { grid-column: 1; grid-row: 2; min-height: 0; height: 100%; }
  .insight-rail { position: relative; z-index: 5; grid-column: 1; grid-row: 1; flex-direction: row; justify-content: space-around; overflow-x: auto; border-top: 0; border-right: 0; border-bottom: 1px solid #33403c; border-left: 0; }
  .insight-flyout { position: fixed; z-index: 70; right: 0; bottom: calc(220px + env(safe-area-inset-bottom)); left: 0; width: 100%; max-height: min(52dvh, calc(100dvh - 330px), 540px); border: 1px solid #485852; border-radius: 8px; box-shadow: 0 18px 50px rgb(0 0 0 / 45%); }
}

@media (max-width: 680px) {
  .lunar-workspace-active .topbar { min-height: 58px; padding: 8px 12px; }
  .lunar-workspace-active .topbar > div:first-of-type { display: none; }
  .lunar-workspace { height: 100%; min-height: 0; padding: 10px 8px; }
  .lunar-home-header { gap: 10px; margin-bottom: 10px; }
  .lunar-home-identity { min-width: 0; }
  .lunar-home-header img { width: 190px; height: 42px; }
  .lunar-home-header p { font-size: 13px; }
  .company-status-strip { flex-wrap: nowrap; width: 100%; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .company-status-strip::-webkit-scrollbar { display: none; }
  .company-status { flex: 0 0 auto; }
  .lunar-workspace .chat-main { min-height: 0; }
  .lunar-workspace .chat-log { padding: 14px 10px; }
  .lunar-workspace .chat-message { max-width: 96%; }
  .lunar-workspace .chat-composer { padding: 9px 8px calc(9px + env(safe-area-inset-bottom)); }
  .lunar-workspace .chat-composer-row { grid-template-columns: minmax(0, 1fr) 50px; }
  .insight-rail { gap: 4px; padding: 7px 4px; overflow-x: auto; }
  .insight-button { flex: 0 0 42px; width: 42px; height: 42px; }
  .insight-label { display: none; }
  .lunar-workspace .lunar-empty { padding: 24px 12px; }
  .lunar-workspace .lunar-empty-brand { width: 180px; height: 50px; }
  .lunar-workspace .lunar-empty h3 { font-size: 20px; }
  .workspace-tour-card { right: 12px; bottom: 12px; left: 12px; width: auto; }
}

/* Standard mobile drawer: backdrop dismisses without forcing a navigation. */
.mobile-nav-backdrop { position: fixed; z-index: 49; inset: 0; width: 100%; height: 100%; padding: 0; background: rgb(0 0 0 / 56%); border: 0; cursor: default; }
.mobile-nav-backdrop[hidden] { display: none; }
body.mobile-nav-open { overflow: hidden; }

@media (max-width: 980px) {
  .lunar-more-samples { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 8px 12px; color: #bfe6d7; background: transparent; border: 1px solid #34443e; border-radius: 8px; cursor: pointer; }
}

@media (min-width: 981px) { .lunar-more-samples { display: none; } }

/* The chat canvas owns the viewport; navigation and quick insights are layers. */
.lunar-workspace-active .app-shell { grid-template-columns: minmax(0, 1fr); }
.lunar-workspace-active .sidebar { position: fixed; z-index: 60; inset: 0 auto 0 0; width: min(320px, 88vw); height: 100dvh; transform: translateX(-105%); transition: transform 180ms ease; box-shadow: 18px 0 48px rgb(0 0 0 / 42%); }
.lunar-workspace-active .sidebar.open { transform: translateX(0); }
.lunar-workspace-active .mobile-menu { display: inline-grid; color: #dce8e4; background: rgb(255 255 255 / 3%); border-color: rgb(203 230 220 / 16%); }
.lunar-workspace-active .topbar { background: rgb(9 12 11 / 86%); border-bottom-color: transparent; }
.lunar-workspace-active .workspace,
.lunar-workspace,
.lunar-workspace .chat-main,
.lunar-workspace .chat-log { background: #090b0a; }
.lunar-workspace .chat-layout { position: relative; display: block; min-height: 0; overflow: hidden; background: transparent; border: 0; border-radius: 0; box-shadow: none; }
.lunar-workspace .chat-history { display: none; }
.lunar-workspace .chat-main { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-height: 0; height: 100%; overflow: hidden; }
.lunar-workspace .chat-main-header { padding: 12px clamp(18px, 4vw, 54px); background: transparent; border-bottom-color: rgb(208 231 222 / 8%); }
.lunar-workspace .chat-log { padding: 24px clamp(110px, 12vw, 180px) 28px; }
.lunar-workspace .chat-log { scrollbar-color: #4a5752 #090b0a; }
.lunar-workspace .chat-log::-webkit-scrollbar { width: 10px; }
.lunar-workspace .chat-log::-webkit-scrollbar-track { background: #090b0a; }
.lunar-workspace .chat-log::-webkit-scrollbar-thumb { background: #3e4b46; border: 3px solid #090b0a; border-radius: 999px; }
.lunar-workspace .lunar-empty { align-content: start; min-height: auto; padding-top: clamp(28px, 5vh, 56px); }
.lunar-workspace .chat-composer { padding: 12px clamp(18px, 6vw, 120px) calc(18px + env(safe-area-inset-bottom)); background: rgb(9 11 10 / 94%); border-top: 1px solid rgb(208 231 222 / 9%); box-shadow: 0 -10px 30px rgb(0 0 0 / 18%); }
.lunar-workspace .company-status { background: rgb(255 255 255 / 2%); border-color: rgb(215 235 228 / 10%); }
.lunar-workspace .company-status-strip { opacity: .93; }
.insight-rail { position: absolute; z-index: 9; top: 82px; left: 20px; grid-column: auto; grid-row: auto; display: flex; flex-direction: column; align-items: center; gap: 9px; padding: 0; background: transparent; border: 0; backdrop-filter: none; }
.insight-button { background: rgb(255 255 255 / 3%); border-color: rgb(180 216 202 / 18%); backdrop-filter: blur(12px); }
.insight-flyout { position: absolute; z-index: 20; top: 82px; left: 82px; grid-column: auto; grid-row: auto; width: min(380px, calc(100% - 108px)); max-height: calc(100% - 106px); padding: 18px; overflow-y: auto; color: #dfe8e5; background: rgb(18 25 22 / 94%); border: 1px solid rgb(160 207 188 / 24%); border-radius: 12px; box-shadow: 0 24px 56px rgb(0 0 0 / 42%); backdrop-filter: blur(20px); }
.insight-flyout .insight-empty-state { background: rgb(7 11 9 / 68%); border-color: rgb(165 207 190 / 20%); }
.lunar-workspace .chat-message.user { background: #101513; border-color: #29342f; border-right-color: rgb(91 205 159 / 50%); }

@media (max-width: 980px) {
  .lunar-workspace-active .sidebar { inset: 0 auto 0 0; height: 100dvh; }
  .lunar-workspace .chat-layout { display: grid; grid-template-rows: auto minmax(0, 1fr); }
  .insight-rail { position: relative; top: auto; left: auto; grid-column: 1; grid-row: 1; flex-direction: row; justify-content: flex-start; width: 100%; overflow-x: auto; padding: 6px 4px; }
  .insight-flyout { position: fixed; z-index: 70; top: auto; right: 8px; bottom: calc(82px + env(safe-area-inset-bottom)); left: 8px; width: auto; max-height: min(56dvh, 520px); }
  .lunar-workspace .chat-main { grid-column: 1; grid-row: 2; }
  .lunar-workspace .chat-log { padding: 14px 12px 20px; }
  .lunar-workspace .chat-composer { padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); }
}

/* Master PNG assets are rendered directly without reconstructed geometry or CSS masks. */
.brand img.brand-master-lockup { width: min(100%, 194px); height: 56px; object-fit: contain; object-position: left center; }
.brand-signal {
  display: inline-block;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  object-fit: contain;
  object-position: center;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.brand-signal::before { content: none; }
.brand-signal.large { flex-basis: 64px; width: 64px; height: 64px; }
.lunar-surface::before,
.lunar-surface::after,
.chat-main::before { display: none; }
.lunar-assistant-mark,
.lunar-thinking-mark { flex: 0 0 28px; width: 28px; height: 28px; object-fit: contain; }
.lunar-thinking-mark { flex-basis: 28px; }
.lunar-user-mark { display: inline-grid; width: 27px; height: 27px; place-items: center; background: var(--surface-strong); border-radius: 7px; color: var(--muted); font-size: 11px; font-weight: 850; }

/* One responsive control system: text actions remain readable and never collapse into circles. */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  max-inline-size: 100%;
  padding: 10px 16px;
  border-radius: 8px;
  line-height: 1.25;
  text-align: center;
  text-wrap: pretty;
  white-space: normal;
}
.button.primary { background: var(--accent); }
.button.primary:hover:not([disabled]) { background: var(--accent-dark); }
.button.quiet,
.button.text-button { min-height: 40px; padding-inline: 10px; border-radius: 6px; }
.button.danger { border-radius: 8px; }
.voice-brand-panel { display: flex; align-items: flex-start; gap: 20px; max-width: 760px; }
.voice-brand-panel > img { flex: 0 1 300px; width: min(100%, 300px); height: 48px; max-height: 48px; object-fit: contain; object-position: left top; }
.voice-mobile-brand { display: none; align-items: center; gap: 8px; color: var(--ink); font-weight: 800; }
.voice-mobile-brand img { width: 32px; height: 32px; object-fit: contain; }
.login-panel { display: grid; align-content: start; gap: 12px; }
.login-panel > * { margin: 0; }
.login-wordmark { width: min(100%, 320px); height: 64px; max-height: 64px; margin-bottom: 6px; object-fit: contain; object-position: left center; }
.conversation-wordmark { width: auto; max-width: min(232px, 32vw); height: 44px; max-height: 48px; object-fit: contain; object-position: left center; }
.conversation-symbol { display: none; flex: 0 0 28px; width: 28px; height: 28px; object-fit: contain; }
.conversation-mobile-product { display: none; }
.icon-button,
.chat-send,
.conversation-menu > summary,
.lunar-reminder-menu > summary,
.answer-menu > summary,
.message-tools .copy-message { flex: 0 0 auto; border-radius: 50%; }
.lunar-sample { border-radius: 8px; }

.onboarding-demo {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.onboarding-demo-prompts,
.lunar-result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.onboarding-demo-answer {
  margin-top: 14px;
  padding: 14px;
  border-left: 3px solid var(--accent);
  background: var(--surface-subtle);
  color: var(--ink);
}
  .lunar-result-actions .button {
  min-height: 34px;
  padding: 6px 10px;
}

/* Keep the compact product rail authoritative after the shared brand rules. */
body:not(.nav-expanded) .sidebar:not(.open) .brand img.brand-master-lockup {
  width: 52px;
  height: 42px;
  max-width: none;
}
body.nav-expanded .brand img.brand-master-lockup,
.sidebar.open .brand img.brand-master-lockup { width: 202px; }

@media (max-width: 680px) {
  .billing-onboarding > .panel-header { flex-direction: column; align-items: stretch; }
  .billing-onboarding > .panel-header > div { min-width: 0; width: 100%; }
  .billing-onboarding > .panel-header > .button { width: auto; align-self: flex-start; }
  .button:not(.chat-send) { width: min(100%, 360px); min-height: 44px; }
  .button-row .button,
  .dialog-actions .button,
  .inline-actions .button { flex: 1 1 min(100%, 170px); }
  .panel-header > .button { width: 100%; }
  .action-card .button { width: 100%; }
  .brand-signal { display: none; }
  .voice-brand-panel { display: grid; gap: 12px; }
  .voice-brand-panel > .voice-wordmark { display: none; }
  .voice-mobile-brand { display: inline-flex; }
  .conversation-wordmark { display: none; }
  .conversation-symbol { display: block; }
  .conversation-mobile-product { display: block; margin: 0 0 2px; color: var(--accent-dark); font-size: 12px; font-weight: 800; line-height: 1.1; }
  .lunar-empty-brand { width: min(48px, 30%); height: 48px; }
}

/* R1E: one quiet Lunar canvas. Only a selected insight receives a surface. */
.lunar-workspace-active .workspace,
.lunar-workspace,
.lunar-workspace .chat-main,
.lunar-workspace .chat-log,
.lunar-workspace .chat-composer {
  background: #050605;
}
.lunar-workspace .chat-main-header,
.lunar-workspace .chat-composer {
  border: 0;
  box-shadow: none;
}
.lunar-workspace .chat-main-header { padding-block: 14px 10px; }
.lunar-home-header { align-items: center; gap: 22px; }
.lunar-home-identity { display: flex; align-items: center; gap: 22px; min-width: 0; }
.lunar-home-header img { width: min(360px, 34vw); height: 72px; object-fit: contain; object-position: left center; }
.lunar-home-header p { margin: 0; color: #f0f5f2; font-size: clamp(1.05rem, 1.5vw, 1.35rem); font-weight: 650; line-height: 1.35; }
.lunar-workspace .company-status-strip { display: flex; align-items: center; justify-content: flex-end; gap: 11px; }
.lunar-workspace .company-status { padding: 3px 0; color: #b9c5c0; background: transparent; border: 0; border-radius: 0; box-shadow: none; }
.lunar-workspace .company-status i { width: 6px; height: 6px; }
.lunar-workspace .chat-log { padding-top: 18px; }
.lunar-workspace .chat-message,
.lunar-workspace .chat-message.user,
.lunar-workspace .chat-message.assistant {
  max-width: min(780px, 100%);
  color: #eaf0ed;
  background: #0a0c0b;
  border: 0;
  border-radius: 10px;
  box-shadow: none;
}
.lunar-workspace .chat-message.user { margin-left: auto; background: #0b0d0c; }
.lunar-workspace .chat-message.assistant { margin-right: auto; background: #090b0a; }
.lunar-workspace .chat-message.assistant::before { width: 2px; background: #42bd90; opacity: .72; }
.lunar-workspace .message-author { min-height: 22px; margin-bottom: 6px; color: #cfe1d9; }
.lunar-workspace .message-time { display: block; margin-top: 8px; color: #74807b; font-size: .72rem; }
.lunar-workspace .lunar-user-mark { display: none; }
.lunar-workspace .message-sources { margin-top: 12px; border-top: 1px solid rgb(255 255 255 / 7%); }

.insight-rail {
  position: absolute;
  z-index: 9;
  top: 78px;
  left: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: auto;
  min-height: 0;
  padding: 0;
  overflow: visible;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
}
.insight-button,
.insight-button:hover,
.insight-button:focus-visible,
.insight-button[aria-expanded="true"] {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  padding: 0;
  color: #87938f;
  background: transparent;
  border: 0;
  border-radius: 0;
  outline: 0;
  box-shadow: none;
  backdrop-filter: none;
}
.insight-button { transition: transform 180ms ease, color 180ms ease, filter 180ms ease; }
.insight-button:hover,
.insight-button:focus-visible { color: #d9eee5; filter: brightness(1.16); transform: scale(1.08); }
.insight-button[aria-expanded="true"] { color: #59cb9d; filter: brightness(1.12); transform: scale(1.06); }
.insight-icon svg { width: 22px; height: 22px; stroke-width: 1.65; }
.insight-label { left: calc(100% + 12px); padding: 5px 8px; color: #dce9e4; background: rgb(5 6 6 / 90%); border: 0; border-radius: 4px; box-shadow: none; }
.insight-flyout {
  top: 68px;
  left: 72px;
  width: min(370px, calc(100% - 92px));
  padding: 18px;
  color: #e2ebe7;
  background: rgb(13 17 15 / 88%);
  border: 1px solid rgb(209 238 225 / 13%);
  border-radius: 10px;
  box-shadow: 0 20px 46px rgb(0 0 0 / 38%);
  backdrop-filter: blur(20px);
}
.insight-flyout .insight-empty-state,
.insight-flyout .empty,
.insight-empty-state,
.insight-flyout .insight-document-list li {
  color: #dfe8e4;
  background: rgb(5 7 6 / 52%);
  border-color: rgb(214 236 226 / 10%);
}
.insight-flyout .close-insight { color: #d9e7e1; background: transparent; border-color: transparent; box-shadow: none; }
.insight-flyout .close-insight:hover { color: #68cfa5; background: transparent; border-color: transparent; }
.insight-flyout .insight-facts > div { border-bottom-color: rgb(255 255 255 / 8%); }

.lunar-orb {
  color: #b9d7ca;
  background: radial-gradient(circle at 35% 28%, rgb(150 235 196 / 20%), transparent 44%), #121a16;
  border-color: rgb(140 206 176 / 30%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 13%), 0 8px 20px rgb(0 0 0 / 22%);
}
.lunar-orb.has-text { color: #eafff5; background: radial-gradient(circle at 35% 28%, rgb(150 235 196 / 28%), transparent 46%), #15241e; border-color: rgb(143 223 186 / 52%); }
.lunar-orb.has-text:hover:not(:disabled) { color: #fff; background: radial-gradient(circle at 35% 28%, rgb(179 247 214 / 34%), transparent 48%), #172b23; border-color: #a2efd2; box-shadow: inset 0 1px 0 rgb(255 255 255 / 25%), 0 12px 26px rgb(0 0 0 / 28%); }

@media (max-width: 980px) {
  .lunar-home-header { align-items: flex-start; gap: 12px; }
  .lunar-home-identity { gap: 14px; }
  .lunar-home-header img { width: min(280px, 64vw); height: 56px; }
  .lunar-workspace .company-status-strip { justify-content: flex-start; width: 100%; }
  .insight-rail { position: relative; top: auto; left: auto; flex-direction: row; align-items: center; gap: 16px; width: 100%; padding: 7px 6px; overflow-x: auto; background: transparent; border: 0; box-shadow: none; }
  .insight-button,
  .insight-button:hover,
  .insight-button:focus-visible,
  .insight-button[aria-expanded="true"] { flex: 0 0 32px; width: 32px; height: 32px; }
  .insight-flyout { top: auto; left: 8px; bottom: calc(82px + env(safe-area-inset-bottom)); width: auto; }
}

@media (max-width: 680px) {
  .lunar-home-header img { width: 210px; height: 48px; }
  .lunar-home-header p { font-size: .98rem; }
  .lunar-workspace .chat-message { max-width: 98%; }
  .insight-rail { gap: 14px; }
  .insight-icon svg { width: 21px; height: 21px; }
}

/* Final Lunar workspace lock: one drawer, one canvas, truthful states.
   It must not alter unauthenticated entry pages, which share the app shell. */
.lunar-workspace-active .app-shell,
body.lunar-workspace-active.nav-expanded .app-shell { grid-template-columns: minmax(0, 1fr); }
.lunar-workspace-active .sidebar {
  position: fixed;
  z-index: 60;
  inset: 0 auto 0 0;
  width: min(320px, 88vw);
  height: 100dvh;
  transform: translateX(-105%);
  transition: transform 180ms ease;
  box-shadow: 18px 0 48px rgb(0 0 0 / 42%);
}
.sidebar.open { transform: translateX(0); }
.mobile-menu { display: inline-grid; order: 3; flex: 0 0 auto; }
.topbar > div:first-of-type { min-width: 0; }
.lunar-workspace-active .topbar > div:first-of-type { display: none; }
.lunar-workspace-active .topbar-actions { margin-left: auto; }

.lunar-workspace .lunar-assistant-mark,
.lunar-workspace .lunar-thinking-mark {
  display: block;
  width: 28px;
  height: 28px;
  object-fit: contain;
  background: transparent;
  border: 0;
  border-radius: 0;
}
.lunar-workspace .message-sources {
  color: #aebbb7;
  background: transparent;
}
.lunar-workspace .message-sources summary::before { background: #48bd91; }
.lunar-workspace .message-data-basis { display: grid; gap: 7px; margin: 6px 0 0; padding: 10px 0 2px; }
.lunar-workspace .message-data-basis > div { display: grid; grid-template-columns: minmax(110px, .45fr) minmax(0, 1fr); gap: 12px; }
.lunar-workspace .message-data-basis dt { color: #7f8d87; }
.lunar-workspace .message-data-basis dd { margin: 0; color: #d5dfdb; }
.lunar-workspace .chat-log { scrollbar-color: #35403c transparent; scrollbar-width: thin; }
.lunar-workspace .chat-log::-webkit-scrollbar { width: 6px; }
.lunar-workspace .chat-log::-webkit-scrollbar-track { background: transparent; }
.lunar-workspace .chat-log::-webkit-scrollbar-thumb { background: #35403c; border: 0; border-radius: 999px; }

.company-status,
.insight-button {
  transform-origin: center;
  will-change: transform, filter;
  transition: transform 180ms ease, color 180ms ease, filter 180ms ease;
}
.company-status[data-dock-distance="0"] { transform: scale(1.1); filter: brightness(1.16); }
.company-status[data-dock-distance="1"] { transform: scale(1.045); filter: brightness(1.08); }
.insight-button[data-dock-distance="0"] { transform: scale(1.13); filter: brightness(1.2); }
.insight-button[data-dock-distance="1"] { transform: scale(1.05); filter: brightness(1.09); }
.insight-rail.is-collapsed { gap: 0; }
.insight-collapse,
.insight-collapse:hover,
.insight-collapse:focus-visible,
.insight-collapse[aria-expanded="true"] {
  color: #788680;
  background: transparent;
  border: 0;
  box-shadow: none;
  transform: none;
}
.insight-collapse:hover,
.insight-collapse:focus-visible { color: #b9d5c9; filter: brightness(1.12); transform: scale(1.08); }
.insight-button[hidden] { display: none !important; }

.personalization-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(300px, .75fr); gap: 18px; margin-bottom: 18px; }
.settings-section + .settings-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.settings-section h2 { margin-bottom: 12px; }
.disabled-choice { color: var(--muted); }

@media (hover: none) {
  .company-status:active { transform: scale(1.035); }
  .insight-button:active { transform: scale(1.06); filter: brightness(1.12); }
}

@media (prefers-reduced-motion: reduce) {
  .company-status,
  .insight-button,
  .sidebar { transition-duration: 0.01ms; }
  .company-status[data-dock-distance],
  .insight-button[data-dock-distance] { transform: none; }
}

@media (max-width: 980px) {
  .personalization-grid { grid-template-columns: 1fr; }
  .topbar { justify-content: flex-start; }
  .topbar-actions { margin-left: auto; }
}

@media (max-width: 680px) {
  .lunar-workspace .message-data-basis > div { grid-template-columns: 1fr; gap: 2px; }
  .lunar-workspace .company-status[data-dock-distance],
  .insight-button[data-dock-distance] { transform: none; }
}

/* Final chat routing and conversation UX lock. */
.mobile-menu { order: -1; margin: 0; }
.lunar-workspace .lunar-empty-brand { display: none !important; }
.lunar-workspace .chat-composer textarea {
  min-height: 52px;
  padding: 13px 15px;
  color: #f2f6f4;
  background: rgb(12 15 14 / 96%);
  border: 1px solid rgb(224 235 231 / 42%);
  outline: 0;
  box-shadow: none;
  transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}
.lunar-workspace .chat-composer textarea:hover { border-color: rgb(235 244 241 / 60%); }
.lunar-workspace .chat-composer textarea:focus,
.lunar-workspace .chat-composer textarea:focus-visible {
  border-color: var(--lunar-accent);
  outline: 0;
  box-shadow: 0 0 0 3px rgb(65 195 147 / 18%);
}
.lunar-workspace .company-status,
.lunar-workspace .insight-button {
  transform-origin: center;
  transition: transform 180ms ease, color 180ms ease, filter 180ms ease;
}
.lunar-workspace .company-status:hover,
.lunar-workspace .company-status:focus-visible,
.lunar-workspace .insight-button:hover,
.lunar-workspace .insight-button:focus-visible {
  transform: scale(1.06);
  filter: brightness(1.12);
}
.lunar-workspace .company-status[data-dock-distance],
.lunar-workspace .insight-button[data-dock-distance] { transform: none; }
.lunar-workspace .conversation-menu-popover,
.lunar-workspace .lunar-reminder-popover {
  color-scheme: dark;
  color: #edf3f0;
  background: rgb(17 22 20 / 98%);
  border: 1px solid rgb(199 221 212 / 18%);
  box-shadow: 0 18px 48px rgb(0 0 0 / 52%);
}
.lunar-workspace .conversation-menu-popover button {
  color: #edf3f0;
  background: transparent;
  border: 1px solid transparent;
}
.lunar-workspace .conversation-menu-popover button:hover {
  color: #f7fbf9;
  background: #202a26;
}
.lunar-workspace .conversation-menu-popover button:focus-visible {
  color: #f7fbf9;
  background: #19241f;
  border-color: rgb(95 211 167 / 42%);
  outline: 2px solid var(--lunar-accent);
  outline-offset: -3px;
}
.lunar-workspace .conversation-menu-popover button:active {
  color: #fff;
  background: #26352f;
}
.lunar-workspace .conversation-menu-popover button:disabled {
  color: #87938f;
  background: transparent;
  border-color: transparent;
  opacity: 1;
  cursor: not-allowed;
}
.lunar-workspace .conversation-menu-popover .danger-action { color: #ffaaa5; }
.lunar-workspace .conversation-menu-popover .danger-action:hover {
  color: #ffd4d0;
  background: #351c1b;
}
.lunar-workspace .conversation-menu-popover .danger-action:focus-visible {
  color: #ffd4d0;
  background: #351c1b;
  border-color: rgb(95 211 167 / 42%);
  outline-color: var(--lunar-accent);
}
.lunar-workspace .conversation-menu-popover .danger-action:active {
  color: #fff0ee;
  background: #482321;
}
body.lunar-workspace-active #confirmation-dialog {
  color-scheme: dark;
  color: #edf3f0;
  background: #111714;
  border-color: rgb(199 221 212 / 22%);
  box-shadow: 0 24px 68px rgb(0 0 0 / 62%);
}
body.lunar-workspace-active #confirmation-dialog::backdrop { background: rgb(0 0 0 / 72%); }
body.lunar-workspace-active #confirmation-dialog h2 { color: #f3f8f6; }
body.lunar-workspace-active #confirmation-dialog p { color: #dfe9e5; }
body.lunar-workspace-active #confirmation-dialog .button.secondary {
  color: #dfe9e5;
  background: #18211e;
  border-color: #3b4a45;
}
body.lunar-workspace-active #confirmation-dialog .button.danger {
  color: #ffd4d0;
  background: #351c1b;
  border-color: #8f4f4a;
}
body.lunar-workspace-active #confirmation-dialog .button:focus-visible {
  outline: 2px solid var(--lunar-accent);
  outline-offset: 2px;
}
.chat-history-list .history-open {
  display: grid;
  width: 100%;
  gap: 3px;
  padding: 9px 10px;
  color: #e8efec;
  background: transparent;
  border: 0;
  text-align: left;
  cursor: pointer;
}
.chat-history-list .history-open strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-history-list .history-open small { color: #8e9c96; }
.lunar-workspace .chat-layout.history-opened .chat-history {
  position: absolute;
  z-index: 18;
  top: 56px;
  left: 18px;
  display: block;
  width: min(310px, calc(100% - 36px));
  max-height: min(520px, calc(100% - 90px));
  padding: 14px;
  overflow-y: auto;
  color: #e8efec;
  background: rgb(13 17 15 / 97%);
  border: 1px solid rgb(199 221 212 / 16%);
  border-radius: 8px;
  box-shadow: 0 20px 48px rgb(0 0 0 / 52%);
  backdrop-filter: blur(18px);
}
.notification-badge {
  position: absolute;
  top: 3px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  color: #06120e;
  background: var(--lunar-accent);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
}
.notification-popover-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.notification-popover-heading h3 { min-width: 0; overflow-wrap: normal; word-break: normal; }
#close-notifications { width: 34px; min-width: 34px; height: 34px; min-height: 34px; color: var(--muted); background: transparent; border-color: transparent; }
#close-notifications:hover,
#close-notifications:focus-visible { color: var(--ink); background: var(--surface-subtle); border-color: var(--line); }
#mark-all-notifications-read { justify-self: end; padding: 3px 6px; font-size: 11px; line-height: 1.2; }
.notification-list {
  display: grid;
  max-height: 360px;
  margin: 8px 0 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}
.notification-open {
  display: grid;
  width: 100%;
  gap: 4px;
  padding: 11px 8px;
  color: #dce7e2;
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgb(199 221 212 / 10%);
  text-align: left;
  cursor: pointer;
}
.notification-list .is-unread .notification-open strong { color: var(--lunar-accent); }
.notification-open span { color: #b2c0ba; }
.notification-open time { color: #7f8d87; font-size: 11px; }
@media (prefers-reduced-motion: reduce) {
  .lunar-workspace .company-status,
  .lunar-workspace .insight-button { transition: none; }
  .lunar-workspace .company-status:hover,
  .lunar-workspace .company-status:focus-visible,
  .lunar-workspace .insight-button:hover,
  .lunar-workspace .insight-button:focus-visible { transform: none; }
}

/* Authoritative mobile overrides must remain last in the cascade. */
.lunar-workspace .company-status:hover,
.lunar-workspace .company-status:focus-visible,
.lunar-workspace .insight-button:hover,
.lunar-workspace .insight-button:focus-visible { transform: scale(1.06); }
.lunar-workspace .company-status[data-dock-distance],
.lunar-workspace .insight-button[data-dock-distance] { transform: none; }

@media (max-width: 980px) {
  .lunar-home-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 10px;
  }
  .lunar-home-identity {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    width: 100%;
    gap: 16px;
  }
  .lunar-home-header img { width: min(210px, 42vw); max-width: 100%; height: 50px; }
  .lunar-home-header p { width: 100%; min-width: 0; margin: 0; overflow-wrap: anywhere; }
  .lunar-workspace .company-status-strip { justify-content: flex-start; width: 100%; max-width: 100%; }
  .insight-rail { width: 100%; max-width: 100%; overflow-x: auto; }
}

@media (max-width: 680px) {
  .lunar-home-identity { grid-template-columns: minmax(0, 1fr); justify-items: start; gap: 5px; }
  .lunar-home-header img { width: min(160px, 52vw); height: 36px; }
  .lunar-home-header p { font-size: .94rem; line-height: 1.3; }
  .lunar-workspace .chat-main-header { grid-template-columns: minmax(0, 1fr) auto; padding: 7px 2px 8px; }
  .lunar-workspace .chat-composer-row { grid-template-columns: minmax(0, 1fr) 46px; gap: 7px; }
  .lunar-workspace .lunar-orb { width: 46px; min-width: 46px; max-width: 46px; height: 46px; min-height: 46px; }
}

@media (orientation: landscape) and (max-height: 520px) {
  .lunar-workspace-active .public-beta-notice {
    min-height: 0;
    padding: 4px 10px;
    overflow: hidden;
    font-size: 0;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .lunar-workspace-active .public-beta-notice strong {
    display: block;
    font-size: 11px;
    text-align: center;
  }
  .lunar-workspace-active .topbar { min-height: 50px; padding-block: 4px; }
  .lunar-workspace .lunar-home-header { display: none; }
  .lunar-workspace .chat-main-header { min-height: 44px; padding-block: 4px; }
  .lunar-workspace .chat-composer { padding-block: 6px; }
  .lunar-workspace .voice-state-copy { display: none; }
  .lunar-workspace .insight-flyout {
    top: auto;
    bottom: calc(86px + env(safe-area-inset-bottom));
    max-height: calc(100dvh - 166px - env(safe-area-inset-bottom));
  }
}

/* Keep mobile account controls anchored to the viewport, not the filtered header. */
@media (max-width: 680px) {
  .topbar { backdrop-filter: none; }
  .profile-menu-popover {
    position: fixed;
    inset: auto max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    width: auto;
    max-height: calc(100dvh - 20px - env(safe-area-inset-bottom));
    overflow-y: auto;
  }
  .notification-popover-heading { align-items: center; flex-direction: row; }
  .notification-popover-heading h3 { font-size: 16px; }
  #close-notifications { margin-left: auto; }
}

/* R2B final Lunar chat polish: one black canvas, restrained controls, no decorative glow. */
body.lunar-workspace-active,
.lunar-workspace-active .workspace,
.lunar-workspace,
.lunar-workspace .chat-layout,
.lunar-workspace .chat-main,
.lunar-workspace .chat-log,
.lunar-workspace .chat-composer { background: #000; }
.lunar-workspace-active .topbar {
  color: #eef4f1;
  background: rgb(0 0 0 / 94%);
  border-bottom-color: transparent;
  box-shadow: none;
}
.lunar-workspace .chat-main-header,
.lunar-workspace .chat-composer {
  background: transparent;
  border: 0;
  box-shadow: none;
}
.lunar-workspace .company-status-strip,
.lunar-workspace .company-status,
.insight-rail,
.insight-button,
.insight-button:hover,
.insight-button:focus-visible,
.insight-button[aria-expanded="true"] {
  background: transparent;
  border: 0;
  box-shadow: none;
}
.lunar-workspace .chat-message,
.lunar-workspace .chat-message.user,
.lunar-workspace .chat-message.assistant {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
.lunar-workspace .chat-message.assistant::before {
  background: var(--lunar-accent);
  opacity: .56;
}
.lunar-workspace .chat-composer textarea {
  color: #f2f6f4;
  background: #070908;
  border-color: rgb(232 240 237 / 46%);
  box-shadow: none;
}
.lunar-workspace .chat-composer textarea:hover { border-color: rgb(242 247 245 / 68%); }
.lunar-workspace .chat-composer textarea:focus,
.lunar-workspace .chat-composer textarea:focus-visible {
  border-color: var(--lunar-accent);
  box-shadow: 0 0 0 2px rgb(24 201 154 / 14%);
}
.lunar-workspace .lunar-payment-attach-trigger { margin-top: 8px; padding: 4px 0; font-size: 12px; }
.lunar-workspace .lunar-payment-attach-panel {
  position: absolute;
  z-index: 35;
  right: clamp(12px, 6vw, 120px);
  bottom: 80px;
  width: min(420px, calc(100% - 24px));
  max-height: min(75dvh, 560px);
  overflow-y: auto;
  padding: 14px;
  color: #e9f0ed;
  background: #141b18;
  border: 1px solid #40554b;
  border-radius: 12px;
  box-shadow: 0 20px 55px rgb(0 0 0 / 48%);
}
.lunar-workspace .lunar-payment-attach-panel[hidden] { display: none; }
.lunar-workspace .lunar-payment-attach-panel [hidden] { display: none !important; }
.lunar-workspace .lunar-payment-attach-panel[data-has-targets="false"] .lunar-payment-attach-intro,
.lunar-workspace .lunar-payment-attach-panel[data-has-targets="false"] .lunar-payment-target-field,
.lunar-workspace .lunar-payment-attach-panel[data-has-targets="false"] .lunar-payment-file-field,
.lunar-workspace .lunar-payment-attach-panel[data-has-targets="false"] #lunar-payment-upload { display: none; }
.lunar-workspace .lunar-payment-attach-panel[data-ready-to-review="true"] .lunar-payment-attach-intro,
.lunar-workspace .lunar-payment-attach-panel[data-ready-to-review="true"] .lunar-payment-attach-fields,
.lunar-workspace .lunar-payment-attach-panel[data-ready-to-review="true"] #lunar-payment-upload { display: none; }
.lunar-workspace .lunar-payment-attach-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.lunar-workspace .lunar-payment-attach-panel h3 { margin: 0; font-size: 1.05rem; }
.lunar-workspace .lunar-payment-attach-close { flex: 0 0 44px; width: 44px; height: 44px; padding: 0; color: #e9f0ed; background: transparent; border: 1px solid #54685f; border-radius: 8px; cursor: pointer; font-size: 1.45rem; line-height: 1; }
.lunar-workspace .lunar-payment-attach-close:hover { background: #26352e; }
.lunar-workspace .lunar-payment-attach-close:focus-visible { outline: 2px solid #70e1b4; outline-offset: 2px; }
.lunar-workspace .lunar-payment-attach-panel p { margin: 0 0 9px; }
.lunar-workspace .lunar-payment-attach-intro { color: #bed2c6; font-size: .89rem; }
.lunar-workspace .lunar-payment-attach-fields { display: grid; gap: 8px; }
.lunar-workspace .lunar-payment-attach-fields .field { min-width: 0; margin: 0; gap: 4px; }
.lunar-workspace .lunar-payment-attach-fields input,
.lunar-workspace .lunar-payment-attach-fields select { width: 100%; max-width: 100%; }
.lunar-workspace .lunar-payment-file-label { color: #e9f0ed; font-weight: 700; }
.lunar-workspace .lunar-payment-file-picker { position: relative; display: grid; grid-template-columns: max-content minmax(0, 1fr); align-items: center; gap: 10px; min-height: 48px; padding: 5px 10px; color: #e9f0ed; background: #1d2923; border: 1px solid #61786a; border-radius: 8px; cursor: pointer; }
.lunar-workspace .lunar-payment-file-picker:hover:not([aria-disabled="true"]) { border-color: #8bd9b6; background: #24352b; }
.lunar-workspace .lunar-payment-file-picker:focus-within { outline: 2px solid #70e1b4; outline-offset: 2px; }
.lunar-workspace .lunar-payment-file-picker[aria-disabled="true"] { opacity: .58; cursor: not-allowed; }
.lunar-workspace .lunar-payment-file-picker input[type="file"] { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; opacity: 0; overflow: hidden; clip-path: inset(50%); }
.lunar-workspace .lunar-payment-file-action { color: #b6efd1; font-weight: 700; }
.lunar-workspace .lunar-payment-file-name { min-width: 0; overflow: hidden; color: #dce8df; font-size: .88rem; text-overflow: ellipsis; white-space: nowrap; }
.lunar-workspace #lunar-payment-attach-status { margin: 9px 0; }
.lunar-workspace .lunar-payment-attach-panel .button-row { margin-top: 9px; }
.lunar-workspace .lunar-payment-attach-panel .button-row .button:not([hidden]) { min-height: 44px; }
.lunar-workspace .lunar-orb,
.lunar-workspace .lunar-orb.has-text,
.lunar-workspace .lunar-orb.has-text:hover:not(:disabled) {
  color: #dbe8e2;
  background: #0b0f0d;
  border-color: rgb(232 240 237 / 24%);
  box-shadow: none;
  filter: none;
}
.lunar-workspace .lunar-orb.has-text,
.lunar-workspace .lunar-orb.has-text:hover:not(:disabled) {
  color: var(--lunar-accent);
  border-color: rgb(24 201 154 / 58%);
}
.lunar-workspace .lunar-orb:focus-visible { outline-color: var(--lunar-accent); }
@media (max-width: 600px) {
  .lunar-workspace .lunar-payment-attach-panel {
    right: 8px;
    bottom: calc(100px + env(safe-area-inset-bottom));
    width: calc(100% - 16px);
    max-height: min(70dvh, 550px);
  }
}
.insight-button::before,
.insight-button::after { display: none; }
.insight-button:hover,
.insight-button:focus-visible {
  color: #eef6f2;
  filter: brightness(1.08);
  transform: scale(1.06);
}
.insight-button[aria-expanded="true"] {
  color: var(--lunar-accent);
  filter: none;
  transform: scale(1.04);
}
.insight-flyout {
  color: #e4ece8;
  background: rgb(10 13 12 / 96%);
  border-color: rgb(229 240 235 / 14%);
  box-shadow: 0 18px 42px rgb(0 0 0 / 46%);
}
@media (max-width: 980px) {
  .insight-rail { background: #000; border: 0; box-shadow: none; }
}

/* R2C founder visual lock: a single quiet conversation canvas at every viewport. */
.lunar-workspace,
.lunar-workspace .chat-layout,
.lunar-workspace .chat-main,
.lunar-workspace .chat-log,
.lunar-workspace .chat-composer {
  color-scheme: dark;
  background: #000;
}
.lunar-workspace { padding: 10px clamp(10px, 2vw, 24px) max(10px, env(safe-area-inset-bottom)); }
.lunar-workspace .lunar-home-header {
  flex: 0 0 auto;
  min-width: 0;
  margin: 0 0 6px;
  padding: 0 clamp(8px, 2vw, 24px);
}
.lunar-workspace.has-conversation .lunar-home-identity { display: none; }
.lunar-workspace.has-conversation .lunar-home-header { justify-content: flex-end; }
.lunar-workspace .company-status-strip {
  min-width: 0;
  max-width: 100%;
  padding: 3px 2px 7px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: none;
}
.lunar-workspace .company-status-strip::-webkit-scrollbar { display: none; }
.lunar-workspace .company-status {
  flex: 0 0 auto;
  min-width: max-content;
  padding: 2px 0;
  color: #98a39f;
}
.lunar-workspace .chat-layout { border: 0; border-radius: 0; box-shadow: none; }
.lunar-workspace .chat-main-header {
  min-height: 44px;
  padding: 5px clamp(8px, 2vw, 24px);
  border: 0;
}
.lunar-workspace .chat-main-header h2 { font-size: .94rem; font-weight: 620; }
.lunar-workspace .chat-header-actions .icon-button {
  color: #9ba6a1;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
.lunar-workspace .chat-header-actions .icon-button:hover,
.lunar-workspace .chat-header-actions .icon-button:focus-visible {
  color: #edf5f1;
  background: transparent;
  border-color: transparent;
}
.lunar-workspace .chat-log { padding: 18px clamp(72px, 10vw, 150px) 22px; }
.lunar-workspace .chat-message,
.lunar-workspace .chat-message.user,
.lunar-workspace .chat-message.assistant {
  width: min(780px, 100%);
  max-width: min(780px, 100%);
  padding: 10px 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.lunar-workspace .chat-message.user { width: min(680px, 88%); padding-left: 28px; text-align: right; }
.lunar-workspace .chat-message.assistant { padding-left: 12px; }
.lunar-workspace .chat-message.assistant::before { width: 1px; opacity: .48; }
.lunar-workspace .message-sources { border-top-color: rgb(255 255 255 / 7%); }
.lunar-workspace .chat-composer {
  padding: 8px clamp(58px, 7vw, 112px) max(10px, env(safe-area-inset-bottom));
  background: transparent;
  border: 0;
  box-shadow: none;
}
.lunar-workspace .chat-composer textarea {
  color: #f1f5f3;
  background: rgb(6 8 7 / 96%);
  border-color: rgb(228 237 233 / 42%);
}
.lunar-workspace .chat-composer textarea:focus,
.lunar-workspace .chat-composer textarea:focus-visible {
  border-color: var(--lunar-accent);
  box-shadow: 0 0 0 2px rgb(24 201 154 / 12%);
}
.lunar-workspace .lunar-orb,
.lunar-workspace .lunar-orb.has-text,
.lunar-workspace .lunar-orb.has-text:hover:not(:disabled) {
  background: #070a08;
  box-shadow: none;
}
.lunar-workspace .insight-rail {
  position: absolute;
  z-index: 9;
  top: 64px;
  left: max(8px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 13px;
  width: 40px;
  max-width: 40px;
  padding: 0;
  overflow: visible;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
  pointer-events: none;
}
.lunar-workspace .insight-button,
.lunar-workspace .insight-button:hover,
.lunar-workspace .insight-button:focus-visible,
.lunar-workspace .insight-button[aria-expanded="true"] {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  pointer-events: auto;
}
.lunar-workspace .insight-button:hover,
.lunar-workspace .insight-button:focus-visible { transform: scale(1.06); filter: brightness(1.08); }
.lunar-workspace .insight-button[aria-expanded="true"] { color: var(--lunar-accent); transform: none; filter: none; }
.lunar-workspace .insight-flyout { left: 58px; }

/* R2H: one transparent dismissal layer for transient Lunar popovers. */
.workspace-overlay-backdrop {
  position: fixed;
  z-index: 130;
  inset: 0;
  display: block;
  background: transparent;
  pointer-events: none;
  touch-action: manipulation;
}
.workspace-overlay-backdrop[hidden] { display: none; }
/* The filled page-enter animation and the filtered header are separate
   stacking contexts. Raise the header itself while a workspace menu is open;
   raising only its children leaves account actions behind route content. */
.workspace-overlay-open .topbar { position: relative; z-index: 141; }
.workspace-overlay-open .workspace-overlay-backdrop { pointer-events: auto; }
/* page-enter keeps #page in its own stacking context. Lift only an active
   content popover above the dismissal layer; let clicks outside it pass through. */
.workspace-content-overlay-open #page { position: relative; z-index: 131; pointer-events: none; }
.workspace-content-overlay-open #page :is(.workspace-popover:not([hidden]), .answer-menu[open], #notification-trigger, #conversation-menu-trigger) { pointer-events: auto; }
.profile-menu[open] { z-index: 141; }
.profile-menu-popover { z-index: 141; }
.answer-menu[open] { z-index: 141; }
.answer-menu-popover { z-index: 142; }
.workspace-popover { z-index: 141; }
.workspace-overlay-open .topbar-actions { position: relative; z-index: 142; }
.workspace-overlay-open .lunar-workspace .chat-layout { z-index: 131; }
.workspace-overlay-open .chat-main-header { position: relative; z-index: 142; }
.workspace-overlay-open .profile-menu,
.workspace-overlay-open #conversation-menu-trigger,
.workspace-overlay-open #notification-trigger,
.workspace-overlay-open .answer-menu { position: relative; z-index: 142; }

/* Settings uses a dedicated full-width shell.  Focused setup flows must never
   inherit the min-content sizing behaviour of a prior workspace grid. */
.settings-mobile-shell {
  display: block;
  grid-column: 1 / -1;
  inline-size: 100%;
  max-inline-size: 100%;
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  overflow-x: clip;
}
.settings-landing,
.settings-detail,
.settings-flow-shell {
  display: block;
  inline-size: min(100%, 720px);
  max-inline-size: 720px;
  min-inline-size: 0;
  margin-inline: auto;
}
.settings-landing { display: grid; gap: 22px; }
.settings-landing > h1,
.settings-detail > h1 { inline-size: 100%; max-inline-size: 100%; overflow-wrap: normal; word-break: normal; hyphens: none; }
.settings-group { display: grid; gap: 1px; }
.settings-group h2 { margin: 0 0 7px; color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.settings-row {
  display: flex;
  align-items: center;
  inline-size: 100%;
  min-inline-size: 0;
  min-block-size: 56px;
  gap: 12px;
  padding: 10px 2px;
  color: var(--text);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  text-align: left;
}
.settings-row:hover:not([disabled]) { color: var(--ink); background: var(--surface-subtle); }
.settings-row:focus-visible { outline-offset: -2px; }
.settings-row[disabled] { cursor: not-allowed; opacity: .58; }
.settings-row-copy { display: grid; min-inline-size: 0; gap: 1px; }
.settings-row-copy strong { color: inherit; font-size: 16px; font-weight: 760; overflow-wrap: normal; word-break: normal; }
.settings-row-copy small { color: var(--muted); font-size: 13px; line-height: 1.35; overflow-wrap: normal; word-break: normal; }
.settings-row-chevron { flex: 0 0 auto; margin-left: auto; color: var(--muted); font-size: 27px; line-height: 1; }
.settings-detail { display: grid; gap: 16px; }
.settings-detail-intro { max-inline-size: 62ch; margin: -5px 0 0; color: var(--muted); }
.settings-detail .panel { inline-size: 100%; min-inline-size: 0; }
.settings-action-list { display: grid; justify-items: start; gap: 8px; }
.button.tertiary { color: var(--lunar-accent); background: transparent; border-color: transparent; box-shadow: none; }
.button.tertiary:hover:not([disabled]) { background: var(--accent-soft); }

/* Phase 1.5 setup: one task per compact, mobile-safe screen. */
.company-setup-route { inline-size: min(100%, 720px); max-inline-size: 720px; min-inline-size: 0; margin-inline: auto; }
.company-setup-page { display: grid; inline-size: 100%; min-inline-size: 0; gap: 16px; max-inline-size: 720px; margin: 0 auto; }
.company-setup-page h2,
.company-setup-page h3,
.company-setup-page p { overflow-wrap: normal; word-break: normal; hyphens: none; }
.company-setup-entry { display: grid; gap: 10px; }
.company-setup-entry p { margin: 0; }
.routing-flow-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.routing-flow-heading > div { flex: 1 1 0%; min-width: 0; min-inline-size: 0; }
.routing-flow-heading > .button { flex: 0 0 auto; inline-size: auto; width: auto; }
.routing-flow-heading h2 { margin: 0; }
.routing-flow-heading p { margin: 6px 0 0; color: var(--muted); }
.routing-setup-cards,
.routing-business-list,
.routing-account-list { display: grid; gap: 12px; }
.routing-setup-card,
.routing-business-card,
.routing-statement-card,
.routing-account-card,
.routing-identity-card { min-width: 0; padding: 16px; background: var(--surface-subtle); border: 1px solid var(--line); border-radius: 10px; }
.routing-setup-card { display: grid; gap: 12px; }
.routing-setup-card > div { min-width: 0; }
.routing-setup-card h3,
.routing-setup-card p,
.routing-business-card h3,
.routing-business-card p,
.routing-statement-card h3,
.routing-statement-card p,
.routing-account-card h3,
.routing-account-card p,
.routing-identity-card h3,
.routing-identity-card p { margin: 0; }
.routing-setup-card p + p,
.routing-statement-card p + p,
.routing-account-card p + p,
.routing-identity-card p + p { margin-top: 5px; color: var(--muted); }
.routing-setup-card.optional { border-style: dashed; }
.routing-business-card ul { display: grid; gap: 5px; margin: 10px 0 0; padding-left: 20px; color: var(--muted); }
.routing-statement-card form,
.routing-ownership-screen form,
.routing-rules-screen form { display: grid; gap: 14px; margin-top: 14px; }
.routing-account-choice { display: grid; gap: 8px; margin: 0; padding: 0; border: 0; }
.routing-account-choice legend { margin-bottom: 8px; font-weight: 750; }
.routing-existing-account,
.routing-new-account { display: grid; gap: 12px; }
.routing-account-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.routing-account-card > div { min-width: 0; }
.routing-preview-list { display: grid; margin: 0; border-top: 1px solid var(--line); }
.routing-preview-list > div { display: grid; grid-template-columns: minmax(120px, .75fr) minmax(0, 1.25fr); gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.routing-preview-list dt { color: var(--muted); }
.routing-preview-list dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.routing-rule-create { padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-subtle); }
.routing-rule-create > summary { min-height: 44px; cursor: pointer; font-weight: 800; }
.routing-evidence-upload { display: grid; gap: 12px; }
.routing-evidence-page-preview { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.routing-evidence-page-preview li { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; padding: 8px 10px; background: var(--surface-subtle); border: 1px solid var(--line); border-radius: 8px; overflow-wrap: anywhere; }
.routing-evidence-page-preview .button-row { flex: 0 0 auto; gap: 4px; }
.routing-evidence-page-preview .button { min-width: 44px; min-height: 36px; padding-inline: 8px; }
@media (max-width: 680px) {
  .settings-mobile-shell { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .settings-detail .product-autopilot-settings > .panel-header,
  .settings-detail .inventory-goods-receipt-settings > .panel-header { flex-direction: column; align-items: flex-start; }
  .settings-landing,
  .settings-detail,
  .settings-flow-shell,
  .company-setup-route { inline-size: 100%; max-inline-size: 100%; }
  .settings-landing { gap: 18px; }
  .settings-row { min-block-size: 56px; }
  .company-setup-route { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .company-setup-page { gap: 12px; }
  .routing-flow-heading { align-items: center; }
  .routing-flow-heading .button { flex: 0 0 auto; }
  .routing-setup-card { padding: 14px; }
  .routing-setup-card .button,
  .routing-statement-card .button[type="submit"] { width: 100%; min-height: 44px; }
  .routing-account-card { align-items: flex-start; flex-direction: column; }
  .routing-account-card .button { width: 100%; min-height: 44px; }
  .routing-preview-list > div { grid-template-columns: 1fr; gap: 3px; }
  .routing-ownership-screen .button-row,
  .routing-statement-card .button-row { display: grid; grid-template-columns: 1fr; }
  .routing-evidence-file-choice .button-row { display: grid; grid-template-columns: 1fr; width: 100%; }
  .routing-evidence-file-choice .button-row .button { inline-size: 100%; min-inline-size: 0; }
  .routing-evidence-page-preview li { align-items: flex-start; flex-direction: column; }
  .routing-evidence-page-preview .button-row { width: 100%; display: grid; grid-template-columns: 44px 44px 1fr; }
}
.lunar-workspace .insight-rail { align-items: flex-start; left: max(4px, env(safe-area-inset-left)); }
.lunar-workspace .insight-collapse { align-self: flex-start; }
.lunar-workspace #toggle-insights .insight-icon,
.lunar-workspace #toggle-insights .insight-icon svg { transform: none !important; }

@media (max-width: 980px) {
  .lunar-workspace { padding-inline: max(5px, env(safe-area-inset-left)) max(5px, env(safe-area-inset-right)); }
  .lunar-workspace .lunar-home-header {
    display: block;
    min-width: 0;
    padding-inline: 48px 5px;
  }
  .lunar-workspace.has-conversation .lunar-home-header { display: block; }
  .lunar-workspace:not(.has-conversation) .lunar-home-identity {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }
  .lunar-workspace:not(.has-conversation) .lunar-home-header img { width: min(156px, 46vw); height: 34px; }
  .lunar-workspace .company-status-strip { width: 100%; padding-right: 16px; }
  .lunar-workspace .chat-layout {
    position: relative;
    display: block;
    min-height: 0;
    height: 100%;
    overflow: hidden;
  }
  .lunar-workspace .chat-main { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100%; }
  .lunar-workspace .chat-main-header { padding-inline: 48px 5px; }
  .lunar-workspace .chat-log { padding: 12px 10px 18px 52px; }
  .lunar-workspace .chat-message.user { width: min(100%, 620px); padding-left: 20px; }
  .lunar-workspace .chat-composer { padding: 8px 5px max(8px, env(safe-area-inset-bottom)) 48px; }
  .lunar-workspace .insight-rail {
    position: absolute;
    top: 52px;
    left: max(4px, env(safe-area-inset-left));
    flex-direction: column;
    justify-content: flex-start;
    gap: 9px;
    width: 38px;
    max-width: 38px;
    padding: 0;
    overflow: visible;
    background: transparent;
  }
  .lunar-workspace .insight-flyout {
    position: fixed;
    z-index: 74;
    top: auto;
    right: max(8px, env(safe-area-inset-right));
    bottom: calc(78px + env(safe-area-inset-bottom));
    left: max(8px, env(safe-area-inset-left));
    width: auto;
    max-height: min(62dvh, 560px);
    overflow-y: auto;
  }
}

@media (max-width: 680px) {
  .lunar-workspace .company-status { font-size: .74rem; }
  .lunar-workspace .chat-main-header { min-height: 42px; }
  .lunar-workspace .chat-main-header h2 { font-size: .86rem; }
  .lunar-workspace .chat-message { max-width: 100%; }
  .lunar-workspace .voice-state-copy { margin-left: 2px; font-size: .68rem; }
}

@media (prefers-reduced-motion: reduce) {
  .lunar-workspace .insight-button:hover,
  .lunar-workspace .insight-button:focus-visible { transform: none; }
}

/* Final mobile safety lock: the save action follows the content instead of obscuring it. */
.automation-savebar { position: static; bottom: auto; }
.automation-tabs { position: static; top: auto; }
@media (max-width: 600px) {
  .automation-page { padding-bottom: 18px; }
  .automation-savebar { position: static; bottom: auto; margin-inline: 0; padding-bottom: max(12px, env(safe-area-inset-bottom)); border-radius: 8px; }
}

/* Final founder-review corrections: controls stay fully visible and deliberate on small screens. */
.skip-link {
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  transform: translateY(calc(-100% - 24px));
  opacity: 0;
  pointer-events: none;
  transition: transform 120ms ease, opacity 120ms ease;
}
.skip-link:focus,
.skip-link:focus-visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.automation-page { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
.automation-savebar {
  position: relative;
  bottom: auto;
  margin-top: 4px;
  isolation: isolate;
}
.automation-save-state-icon { display: none; }
.automation-savebar[data-save-state="error"] {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: var(--danger);
}
.automation-savebar[data-save-state="error"] .automation-save-state-icon {
  display: inline-grid;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  place-items: center;
  color: #fff;
  background: var(--danger);
  border-radius: 50%;
  font-size: 13px;
  font-weight: 900;
}
.automation-savebar[data-save-state="error"] .automation-save-state-icon::before { content: "!"; }
.automation-savebar[data-save-state="error"]:has(.automation-dirty:not(:empty)) .automation-dirty { color: var(--danger); }

@media (max-width: 600px) {
  .automation-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }
  .automation-tabs button {
    min-width: 0;
    padding-inline: 8px;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .automation-savebar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .automation-savebar .button { grid-column: 1 / -1; width: 100%; }
  .automation-savebar[data-save-state="error"] .automation-save-state-icon { display: inline-grid; }
  .automation-dialog {
    width: min(100% - 20px, 520px);
    max-height: calc(100dvh - 20px);
    margin: auto;
    padding: 16px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .automation-dialog form { min-height: min-content; }
  .automation-dialog .dialog-actions { position: sticky; bottom: -16px; padding: 12px 0 max(4px, env(safe-area-inset-bottom)); background: var(--surface); }
}

@media (max-width: 680px) {
  .public-beta-notice { align-items: flex-start; }
  .public-beta-notice > span { line-height: 1.28; }
  .lunar-system-status { padding: 2px 0; }
  .lunar-workspace .lunar-system-status .company-status-strip {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    padding: 0;
    overflow: visible;
  }
  .lunar-workspace .lunar-system-status .company-status {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: center;
    min-width: 0;
    min-height: 54px;
    padding: 7px 8px;
    border-radius: 8px;
    text-align: left;
    white-space: normal;
  }
  .lunar-workspace .lunar-system-status .status-icon { grid-row: 1 / span 2; }
  .lunar-workspace .lunar-system-status .company-status strong,
  .lunar-workspace .lunar-system-status .company-status span:last-child { min-width: 0; overflow-wrap: normal; word-break: normal; hyphens: none; }
  .lunar-workspace .lunar-system-status .company-status strong { font-size: 13px; }
  .lunar-workspace .lunar-system-status .company-status span:last-child { color: #b9c5c0; font-size: 11px; line-height: 1.18; }
}

/* Final Lunar Chat polish: lightweight status information belongs to the workspace, not a card. */
.lunar-workspace .lunar-home-header {
  width: min(100%, 1040px);
  margin: 0 auto 12px;
}
.lunar-workspace .lunar-home-identity { display: block; min-width: 0; }
.lunar-workspace .lunar-home-identity .eyebrow { color: #a8b7b1; }
.lunar-workspace .lunar-home-identity p:last-child { max-width: 680px; color: #b7c4bf; }

.lunar-workspace .lunar-system-status {
  width: min(100%, 1040px);
  margin: 0 auto 18px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.lunar-workspace .lunar-system-status-heading { margin-bottom: 9px; }
.lunar-workspace .lunar-system-status .company-status-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, max-content));
  justify-content: center;
  align-items: stretch;
  gap: 4px 14px;
  width: 100%;
  padding: 0;
  overflow: visible;
  mask-image: none;
}
.lunar-workspace .lunar-system-status .company-status {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  min-width: 0;
  min-height: 50px;
  padding: 5px 8px;
  color: #c8d3ce;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  text-align: left;
  white-space: normal;
}
.lunar-workspace .lunar-system-status .company-status:hover { background: rgb(255 255 255 / 3%); border-color: transparent; }
.lunar-workspace .lunar-system-status .company-status:focus-visible { outline: 2px solid #18c99a; outline-offset: 2px; }
.lunar-workspace .lunar-system-status .status-icon {
  display: grid;
  grid-row: 1;
  width: 22px;
  height: 22px;
  place-items: center;
}
.lunar-workspace .lunar-system-status .status-icon svg { width: 22px; height: 22px; stroke-width: 1.9; }
.lunar-workspace .lunar-system-status .status-copy {
  display: grid;
  gap: 1px;
  min-width: 0;
  padding-left: 7px;
}
.lunar-workspace .lunar-system-status .status-copy strong {
  color: #f0f6f3;
  font-size: 14px;
  font-weight: 760;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.lunar-workspace .lunar-system-status .status-copy > span {
  color: #aebbb6;
  font-size: 11px;
  line-height: 1.16;
}
.lunar-workspace .lunar-system-status .status-copy small {
  color: #e5b859;
  font-size: 10px;
  line-height: 1.14;
}

.lunar-workspace .lunar-samples {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  width: min(100%, 640px);
  margin-top: 22px;
}
.lunar-workspace .lunar-sample {
  justify-content: flex-start;
  min-height: 50px;
  padding: 10px 13px;
  color: #d9e6e1;
  background: rgb(255 255 255 / 2.5%);
  border-color: rgb(193 222 211 / 16%);
  border-radius: 7px;
}
.lunar-workspace .lunar-sample:hover,
.lunar-workspace .lunar-sample:focus-visible { border-color: rgb(24 201 154 / 70%); background: rgb(24 201 154 / 7%); }

@media (min-width: 681px) and (max-width: 1140px) {
  .lunar-workspace .lunar-system-status .company-status-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-width: 760px;
  }
}

@media (min-width: 681px) {
  .lunar-workspace-active #page-title {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
  }
}

@media (max-width: 680px) {
  .lunar-workspace-active .topbar #company-label { display: none; }
  .lunar-workspace-active .topbar #page-title {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
  }
  .lunar-workspace .lunar-home-header { margin-bottom: 8px; }
  .lunar-workspace .lunar-home-identity p:last-child { font-size: 13px; line-height: 1.32; }
  .lunar-workspace .lunar-system-status { margin-bottom: 12px; }
  .lunar-workspace .lunar-system-status-heading { justify-content: flex-start; margin-bottom: 5px; }
  .lunar-workspace .lunar-system-status .company-status-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    justify-content: stretch;
  }
  .lunar-workspace .lunar-system-status .company-status {
    grid-template-columns: 20px minmax(0, 1fr);
    min-height: 48px;
    padding: 7px 5px;
    border-bottom: 1px solid rgb(207 231 222 / 10%);
  }
  .lunar-workspace .lunar-system-status .company-status:nth-child(odd) { border-right: 1px solid rgb(207 231 222 / 10%); }
  .lunar-workspace .lunar-system-status .status-icon { width: 20px; height: 20px; }
  .lunar-workspace .lunar-system-status .status-icon svg { width: 20px; height: 20px; }
  .lunar-workspace .lunar-system-status .status-copy { padding-left: 6px; }
  .lunar-workspace .lunar-system-status .status-copy strong { font-size: 13px; }
  .lunar-workspace .lunar-system-status .status-copy > span { font-size: 10.5px; }
  .lunar-workspace .lunar-system-status .status-copy small { font-size: 9.5px; }
  .lunar-workspace .lunar-samples { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 16px; }
  .lunar-workspace .lunar-sample { min-height: 52px; padding: 8px 9px; font-size: 11.5px; line-height: 1.24; }
  .lunar-workspace .insight-rail { display: none; }
  .lunar-workspace .chat-layout { grid-template-rows: minmax(0, 1fr); }
  .lunar-workspace .chat-main { grid-column: 1; grid-row: 1; }
}

/* Discoverable navigation and structured product search. */
.navigation-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.navigation-heading .brand { min-width: 0; }
.navigation-toggle { display: inline-grid; flex: 0 0 42px; width: 42px; height: 42px; place-items: center; color: #dce8e4; background: transparent; border: 1px solid rgb(255 255 255 / 14%); }
.navigation-toggle svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.navigation-toggle:hover, .navigation-toggle:focus-visible { color: #fff; background: rgb(255 255 255 / 7%); border-color: rgb(24 201 154 / 68%); }
.nav-button[aria-current="page"] .nav-mark { color: #fff; border-color: rgb(24 201 154 / 50%); }

.shopify-product-picker { display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.shopify-product-picker[hidden] { display: none !important; }
.shopify-product-picker h4 { margin: 0; color: var(--text); font-size: 1rem; }
.supplier-variant-results { display: grid; max-height: 420px; gap: 6px; overflow: auto; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-subtle); }
.supplier-variant-result { display: grid; gap: 3px; width: 100%; min-height: 58px; padding: 10px 12px; color: var(--text); background: transparent; border: 1px solid transparent; border-radius: 6px; cursor: pointer; text-align: left; }
.supplier-variant-result { grid-template-columns: 52px minmax(0, 1fr); align-items: start; }
.supplier-variant-image { position: relative; display: grid; width: 48px; height: 48px; place-items: center; overflow: hidden; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.supplier-variant-image-fallback { display: grid; width: 100%; height: 100%; place-items: center; color: var(--muted); background: var(--surface-subtle); font-size: .82rem; font-weight: 800; letter-spacing: 0; }
.supplier-variant-image img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: var(--surface); }
.supplier-variant-image:not(.has-image) img { visibility: hidden; }
.supplier-variant-image.has-image .supplier-variant-image-fallback { visibility: hidden; }
.supplier-variant-result-copy { display: grid; min-width: 0; gap: 3px; }
.supplier-variant-result:hover { background: rgb(24 201 154 / 7%); border-color: rgb(24 201 154 / 42%); }
.supplier-variant-result[aria-selected="true"] { color: var(--text); background: rgb(24 201 154 / 12%); border-color: #18c99a; box-shadow: inset 3px 0 #18c99a; }
.supplier-variant-selected-marker { display: none; justify-self: start; margin-top: 4px; padding: 2px 7px; border-radius: 999px; color: #173a2d; background: #dff5e9; font-size: .76rem; font-weight: 800; }
.supplier-variant-result[aria-selected="true"] .supplier-variant-selected-marker { display: inline-flex; }
.supplier-variant-result-title { font-weight: 760; }
.supplier-variant-result-meta { color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.picker-empty, .picker-status { margin: 0; color: var(--muted); }

@media (min-width: 981px) {
  .app-shell, body.nav-expanded .app-shell { grid-template-columns: 76px minmax(0, 1fr); }
  body.nav-expanded .app-shell,
  body.lunar-workspace-active.nav-expanded .app-shell { grid-template-columns: 244px minmax(0, 1fr); }
  .sidebar, .lunar-workspace-active .sidebar { width: 76px; transition: width 180ms ease; }
  body.nav-expanded .sidebar, body.lunar-workspace-active.nav-expanded .sidebar { width: 244px; }
  body.nav-expanded .sidebar .nav-label { display: inline; }
  body.nav-expanded .sidebar .brand img.brand-master-lockup { width: 168px; }
  body.nav-expanded .sidebar .sidebar-footer { white-space: normal; }
  .navigation-toggle { display: inline-grid; }
  /* The persistent sidebar already owns the desktop menu control. */
  body:not(.lunar-workspace-active) .topbar > .mobile-menu { display: none; }
  body:not(.nav-expanded) .sidebar-footer,
  body:not(.nav-expanded) .sidebar .task-count-badge { display: none; }
}

@media (max-width: 980px) {
  .navigation-toggle { display: none; }
  .sidebar .nav-label { display: inline; }
  .sidebar { overflow: hidden; }
  #primary-navigation { min-height: 0; overscroll-behavior: contain; }
}

@media (max-width: 680px) {
  .supplier-variant-results { max-height: none; overflow: visible; }
  .supplier-variant-result { min-height: 64px; }
  .supplier-variant-result-meta { line-height: 1.3; }
}

@media (prefers-reduced-motion: reduce) {
  .app-shell, .sidebar { transition-duration: .01ms; }
}

/* Lunar simple navigation and guided review.  Primary destinations stay identical on desktop and mobile. */
.lunar-primary-navigation { display: grid; gap: 6px; }
.lunar-primary-navigation .nav-button { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; min-height: 48px; padding: 10px 12px; }
.lunar-primary-navigation .nav-mark { display: inline-grid; width: 24px; height: 24px; place-items: center; }
.lunar-primary-navigation .nav-mark svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.lunar-start-intro { margin-bottom: 14px; }
.lunar-start-status { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 16px; padding: 24px; border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.lunar-start-status h2 { margin-bottom: 6px; font-size: clamp(1.45rem, 3vw, 2rem); }
.lunar-start-status p { margin: 0; }
.lunar-start-state { margin-bottom: 7px !important; color: var(--accent-dark); font-weight: 800; }
.lunar-start-action { display: grid; gap: 7px; min-width: 190px; }
.lunar-task-preview { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.lunar-task-preview:last-of-type { border-bottom: 0; }
.lunar-task-preview span { color: var(--muted); font-size: .9rem; }
.lunar-technical-details { margin-top: 16px; padding: 14px 0 0; border-top: 1px solid var(--line); }
.lunar-technical-details > summary { min-height: 44px; color: var(--accent-dark); cursor: pointer; font-weight: 750; }
.lunar-unified-task-queue { display: grid; gap: 0; }
.lunar-unified-task { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 0; border-top: 1px solid var(--line); }
.lunar-unified-task:first-of-type { border-top: 0; }
.lunar-unified-task > div { min-width: 0; }
.lunar-unified-task h3, .lunar-unified-task p { margin: 0; overflow-wrap: anywhere; }
.lunar-unified-task p { margin-top: 3px; color: var(--muted); }
.lunar-task-month-context p, .tax-v2-evidence-explanation { overflow-wrap: anywhere; }
.task-category { display: inline-block; margin-bottom: 5px; color: var(--accent-dark); font-size: .78rem; font-weight: 800; text-transform: uppercase; }
.tax-readiness-summary { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.tax-readiness-summary h2, .tax-readiness-summary p { margin: 0; }
.tax-readiness-summary p { margin-top: 5px; color: var(--muted); }
.tax-readiness-summary .button { margin-top: 12px; }
.tax-readiness-summary > div:last-child { display: grid; min-width: 170px; gap: 3px; padding: 13px 15px; color: var(--accent-dark); background: var(--accent-soft); border-radius: 9px; text-align: right; }
.tax-readiness-summary > div:last-child strong { font-size: 1.2rem; }
.tax-readiness-summary > div:last-child span { color: var(--muted); font-size: .86rem; }

.guided-payment-review { display: grid; width: 100%; max-width: 100%; min-width: 0; gap: 16px; margin: 18px 0; padding: clamp(16px, 3vw, 28px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.guided-payment-review > *, .guided-payment-review > header > *, .guided-payment-step > *, .guided-document-picker > * { min-width: 0; max-width: 100%; }
.guided-payment-review > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.guided-payment-review h2, .guided-payment-review h3, .guided-payment-review h4, .guided-payment-review p, .guided-payment-review strong, .guided-payment-review small { overflow-wrap: anywhere; }
.guided-payment-review h2, .guided-payment-review h3, .guided-payment-review h4, .guided-payment-review p { margin-top: 0; }
.guided-payment-progress { display: grid; flex: 0 0 auto; gap: 0; padding: 9px 12px; color: var(--accent-dark); background: var(--accent-soft); border-radius: 8px; text-align: right; }
.guided-payment-progress span { color: var(--muted); font-size: .78rem; }
.guided-payment-review progress { width: 100%; height: 8px; overflow: hidden; border: 0; border-radius: 999px; accent-color: var(--accent); }
.guided-payment-review progress::-webkit-progress-bar { background: var(--surface-subtle); border-radius: 999px; }
.guided-payment-review progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
.inline-payment-upload { min-height: 240px; padding-bottom: max(18px, env(safe-area-inset-bottom)); }
.inline-upload-business-assignment { margin: 18px 0; padding: 16px; border: 1px solid var(--border); border-radius: 14px; }
.inline-upload-business-assignment h4 { margin: 0 0 6px; }
.inline-upload-business-assignment select { min-height: 44px; width: 100%; }
.inline-upload-business-error { margin-top: 8px; }
.inline-upload-previews { display: grid; gap: 8px; }
.inline-upload-previews article, .guided-source-document { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-subtle); }
.inline-upload-previews article { align-items: flex-start; }
.inline-upload-preview { width: 72px; height: 92px; flex: 0 0 72px; display: grid; place-items: center; overflow: hidden; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); }
.inline-upload-preview img { max-width: 100%; max-height: 100%; object-fit: contain; transition: transform 120ms ease; }
.inline-upload-file-icon { font-size: 12px; font-weight: 700; color: var(--muted); }
.inline-upload-previews article > div:nth-child(2) { min-width: 0; flex: 1; display: grid; gap: 3px; }
.inline-upload-previews article > div:nth-child(2) span { font-size: 13px; color: var(--muted); }
.inline-upload-page-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px; }
.inline-upload-previews span, .guided-source-document p { min-width: 0; overflow-wrap: anywhere; }
.inline-payment-upload progress { width: 100%; min-height: 10px; accent-color: var(--accent); }
.guided-source-document { display: grid; grid-template-columns: 1fr auto; }
.guided-source-document strong, .guided-source-document p { grid-column: 1; margin: 0; }
.guided-source-document .button { grid-column: 2; grid-row: 1 / span 2; }
.guided-source-document .guided-source-actions { grid-column: 2; grid-row: 1 / span 3; display: grid; gap: 8px; justify-items: stretch; min-width: 0; }
.guided-source-document .guided-source-actions .button { grid-column: auto; grid-row: auto; white-space: normal; }
.guided-source-document .guided-source-actions .retained-gmail-review-state { grid-column: auto; font-size: 12px; }
.retained-gmail-review-dialog { width: min(520px, calc(100vw - 24px)); }
.retained-gmail-review-dialog > * { max-width: 100%; overflow-wrap: anywhere; }
.retained-gmail-review-dialog .checkbox-line { display: flex; align-items: center; gap: 12px; min-height: 48px; margin: 12px 0; padding: 8px 4px; cursor: pointer; }
.retained-gmail-review-dialog .checkbox-line input { flex: none; width: 22px; height: 22px; margin: 0; }
.retained-mail-review-dialog { width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain; }
.retained-mail-review-content { display: grid; gap: 10px; padding: 18px; }
.retained-mail-review-content > * { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.retained-mail-review-content h2, .retained-mail-review-content p { margin: 0; }
.retained-mail-review-original { justify-self: start; }
.retained-mail-review-dialog .checkbox-line { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 4px; cursor: pointer; }
.retained-mail-review-dialog .checkbox-line input { flex: none; width: 22px; height: 22px; margin: 0; }
@media (max-width: 460px) {
  .guided-source-document { grid-template-columns: minmax(0, 1fr); }
  .guided-source-document .guided-source-actions { grid-column: 1; grid-row: auto; }
  .guided-source-document .guided-source-actions .button { width: 100%; min-height: 44px; }
  .retained-gmail-review-dialog .dialog-actions { display: grid; grid-template-columns: minmax(0, 1fr); }
  .retained-gmail-review-dialog .dialog-actions .button { width: 100%; min-height: 48px; white-space: nowrap; }
  .retained-mail-review-dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .retained-mail-review-content { padding: 14px; }
  .retained-mail-review-original { width: 100%; min-height: 44px; }
  .retained-mail-review-dialog .dialog-actions { display: grid; grid-template-columns: minmax(0, 1fr); }
  .retained-mail-review-dialog .dialog-actions .button { width: 100%; min-height: 48px; white-space: nowrap; }
  .inline-upload-previews article { display: grid; grid-template-columns: 64px 1fr; }
  .inline-upload-preview { width: 64px; height: 82px; flex-basis: 64px; }
  .inline-upload-page-actions { grid-column: 1 / -1; justify-content: flex-start; }
}
.guided-payment-group { padding: 16px; background: var(--surface-subtle); border: 1px solid var(--line); border-radius: 10px; }
.guided-payment-group > p { color: var(--muted); }
.guided-payment-list { display: grid; gap: 8px; }
.guided-payment-list-item, .guided-document-choice { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 58px; gap: 14px; padding: 10px 12px; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; text-align: left; }
.guided-payment-list-item:hover, .guided-document-choice:hover, .guided-document-choice.is-selected { border-color: var(--accent); background: var(--accent-soft); }
.guided-payment-list-item span, .guided-document-choice span { display: grid; min-width: 0; gap: 2px; }
.guided-payment-list-item small, .guided-document-choice small { color: var(--muted); overflow-wrap: anywhere; }
.guided-payment-list-item > span:last-child, .guided-document-choice > span:last-child { color: var(--accent-dark); font-weight: 760; }
.guided-payment-summary { padding: 18px; background: var(--surface-subtle); border-radius: 10px; }
.guided-payment-summary h3 { margin-bottom: 12px; }
.guided-payment-summary dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; margin: 0; }
.guided-payment-summary dl div { min-width: 0; }
.guided-payment-summary dt { color: var(--muted); font-size: .8rem; }
.guided-payment-summary dd { margin: 2px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.guided-payment-summary .notice, .guided-payment-summary .success-message { margin: 15px 0 0; }
.guided-payment-evidence { display: grid; width: 100%; max-width: 100%; min-width: 0; gap: 4px; padding: 12px 14px; color: var(--text); background: #182129; border: 1px solid #45535b; border-inline-start: 3px solid var(--accent); border-radius: 9px; }
.guided-payment-evidence > div { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); min-width: 0; gap: 8px; }
.guided-payment-evidence dt, .guided-payment-evidence dd { min-width: 0; overflow-wrap: anywhere; }
.guided-payment-evidence dd { margin: 0; }
.guided-payment-evidence strong { color: var(--success); }
.guided-payment-evidence p { margin: 0; overflow-wrap: anywhere; }
.guided-payment-evidence details { margin-top: 4px; }
.guided-payment-step { display: grid; gap: 14px; padding: 4px 0 0; }
.guided-payment-step > p { color: var(--muted); }
.guided-purpose-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.guided-purpose-choice { display: grid; min-height: 105px; gap: 5px; padding: 16px; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; text-align: left; }
.guided-purpose-choice:hover, .guided-purpose-choice:focus-visible { border-color: var(--accent); background: var(--accent-soft); }
.guided-purpose-choice strong { color: var(--ink); font-size: 1rem; }
.guided-purpose-choice span { color: var(--muted); font-size: .9rem; }
.guided-choice-stack { display: grid; gap: 9px; justify-items: start; }
.guided-choice-stack .button { min-width: min(100%, 360px); }
.guided-payment-submit[aria-busy="true"] { gap: 9px; opacity: .85; }
.guided-payment-submit[aria-busy="true"]::before {
  content: "";
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border: 2px solid currentColor;
  border-left-color: transparent;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.guided-advance-evidence { display: grid; min-width: 0; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-subtle); }
.guided-advance-evidence h4, .guided-advance-evidence p { margin: 0; }
.guided-document-suggestions { display: grid; gap: 8px; }
.guided-document-suggestions h4 { margin-bottom: 0; }
.guided-open-invoice { min-width: 0; max-width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-subtle); }
.guided-payment-view-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; max-width: 100%; gap: 8px; }
.guided-payment-view-tabs .button { width: 100%; min-width: 0; }
.guided-document-search { display: grid; grid-template-columns: minmax(0, 1fr) auto; width: 100%; max-width: 100%; gap: 8px; }
.guided-document-search label { grid-column: 1 / -1; }
.guided-document-search input { width: 100%; max-width: 100%; min-width: 0; font-size: 16px; }
.guided-payment-rule { padding-top: 8px; border-top: 1px solid var(--line); }
.guided-payment-rule summary { min-height: 44px; padding-top: 10px; color: var(--accent-dark); cursor: pointer; font-weight: 750; }
.guided-split-total, .guided-grouped-total { padding: 10px 12px; background: var(--surface-subtle); border-radius: 7px; font-weight: 750; }

@media (max-width: 980px) {
  body { padding-bottom: 0; }
  .mobile-menu { display: inline-grid !important; }
  .sidebar.open { z-index: 100; }
  .lunar-start-status { align-items: flex-start; flex-direction: column; }
  .lunar-start-action { width: 100%; }
  .lunar-unified-task { align-items: flex-start; flex-direction: column; }
  .lunar-unified-task .button { width: 100%; }
  .lunar-unified-task-queue > .panel-header { flex-direction: column; }
  .lunar-unified-task-queue > .panel-header .button, .lunar-task-month-context .button { width: 100%; }
  .review-queue-return-month, .review-queue-return-documents { width: 100%; }
  .tax-readiness-summary { align-items: flex-start; flex-direction: column; }
  .tax-readiness-summary > div:last-child { width: 100%; text-align: left; }
}

@media (max-width: 600px) {
  .workspace { padding-right: 16px; padding-left: 16px; }
  .guided-payment-review { margin-right: -4px; margin-left: -4px; padding: 16px; scroll-margin-block: max(16px, env(safe-area-inset-top)) calc(24px + env(safe-area-inset-bottom)); }
  .guided-payment-review > header { align-items: stretch; flex-direction: column; }
  .guided-payment-progress { justify-items: start; text-align: left; }
  .guided-payment-summary dl, .guided-purpose-choices { grid-template-columns: 1fr; }
  .guided-payment-list-item, .guided-document-choice { display: grid; grid-template-columns: minmax(0, 1fr); align-items: flex-start; }
  .guided-payment-list-item > span:last-child, .guided-document-choice > span:last-child { width: 100%; padding-top: 2px; white-space: normal; }
  .guided-document-choice > span:last-child { min-height: 44px; align-content: center; padding: 9px 12px; border-radius: 8px; background: var(--accent); color: var(--on-accent, #fff); text-align: center; }
  .guided-document-search { grid-template-columns: minmax(0, 1fr); }
  .guided-document-search label { grid-column: auto; }
  .guided-document-search .button { width: 100%; }
  .guided-payment-review .button-row { display: grid; grid-template-columns: minmax(0, 1fr); width: 100%; }
  .guided-payment-review .button-row .button { width: 100%; }
  .guided-choice-stack .button { width: 100%; }
  .guided-payment-step textarea { min-height: 88px; }
  .guided-payment-step .form-grid { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
}
.shopify-product-picker { padding-top: 4px; border-top: 1px solid var(--line); }
.shopify-product-picker summary { min-height: 44px; padding: 11px 0; color: var(--accent); cursor: pointer; font-weight: 760; }
.shopify-product-picker select { min-height: 180px; }

/* Compact chat layout: wide desktop canvas, drawer-only mobile nav, horizontal mobile status. */
@media (min-width: 981px) {
  .lunar-workspace-active .app-shell,
  body.lunar-workspace-active.nav-expanded .app-shell { grid-template-columns: 76px minmax(0, 1fr); }
  .lunar-workspace-active .sidebar,
  .lunar-workspace-active .sidebar.open {
    position: sticky;
    inset: 0 auto auto 0;
    width: 76px;
    height: 100%;
    min-height: 0;
    transform: none;
    box-shadow: none;
  }
  .sidebar .nav-label,
  .sidebar.open .nav-label { display: none; }
  .sidebar .brand img.brand-master-lockup,
  .sidebar.open .brand img.brand-master-lockup { width: 52px; height: 42px; }
  .lunar-workspace-active .mobile-menu { display: none; }
}

.lunar-workspace {
  align-items: center;
  padding-inline: clamp(12px, 2vw, 28px);
}
.lunar-workspace .lunar-home-header,
.lunar-workspace .lunar-system-status,
.lunar-workspace .chat-layout {
  width: min(100%, 1360px);
  margin-inline: auto;
}
.lunar-workspace .lunar-home-header { margin-bottom: 10px; }
.lunar-workspace .lunar-home-identity {
  display: grid;
  justify-items: center;
  text-align: center;
}
.lunar-workspace .lunar-home-identity p:last-child { max-width: 760px; }
.lunar-workspace .lunar-system-status { width: min(100%, 1240px); margin-bottom: 18px; }
.lunar-workspace .chat-layout { flex: 1 1 auto; min-height: 0; }
.lunar-workspace .chat-log { padding-inline: max(48px, calc((100% - 1040px) / 2)); }
.lunar-workspace .chat-message,
.lunar-workspace .chat-message.assistant { width: min(840px, 100%); max-width: min(840px, 100%); }
.lunar-workspace .chat-message.user { width: min(720px, 88%); max-width: min(720px, 88%); }
.lunar-workspace .chat-composer { padding-inline: max(48px, calc((100% - 1120px) / 2)); }
.lunar-workspace .lunar-samples { width: min(100%, 760px); gap: 12px; }
.lunar-workspace .lunar-sample { min-height: 56px; padding: 12px 16px; font-size: 13px; }
.lunar-workspace .copy-message.is-copied { color: #18c99a; }
.lunar-workspace .copy-message.copy-failed { color: #f08a82; }

/* A conversation list is workspace content, not another global navigation. */
@media (min-width: 981px) {
  .lunar-workspace .chat-layout { display: grid; grid-template-columns: 254px minmax(0, 1fr); }
  .lunar-workspace .chat-history { position: relative; display: flex; flex-direction: column; grid-column: 1; grid-row: 1; min-width: 0; height: 100%; padding: 16px 12px; overflow: hidden; background: #101614; border-right: 1px solid #283630; }
  .lunar-workspace .chat-main { grid-column: 2; grid-row: 1; min-width: 0; }
  .lunar-workspace .insight-rail { display: none; }
  .lunar-workspace .chat-layout.insights-opened .insight-rail { position: absolute; z-index: 36; top: 62px; right: 18px; left: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; align-items: stretch; width: min(330px, calc(100% - 36px)); max-width: none; height: auto; padding: 10px; background: #15201a; border: 1px solid #405348; border-radius: 8px; box-shadow: 0 18px 48px rgb(0 0 0 / 48%); }
  .lunar-workspace .chat-layout.insights-opened .insight-rail .insight-button { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 7px; border-radius: 6px; box-shadow: none; }
  .lunar-workspace .chat-layout.insights-opened .insight-rail .insight-label { position: static; max-width: none; padding: 0; opacity: 1; color: #d7e8df; background: transparent; border: 0; box-shadow: none; font-size: 11px; line-height: 1.2; text-align: left; white-space: normal; transform: none; }
  .lunar-workspace .chat-layout.insights-opened .insight-rail .insight-collapse { display: none; }
  .lunar-workspace .insight-flyout { position: absolute; z-index: 36; top: 62px; right: 18px; left: auto; width: min(380px, calc(100% - 36px)); max-height: calc(100% - 76px); border: 1px solid #405348; border-radius: 8px; box-shadow: 0 18px 48px rgb(0 0 0 / 48%); }
  .lunar-workspace #conversation-switcher,
  .lunar-workspace #conversation-history-close { display: none; }
}
.lunar-workspace #insight-switcher { min-height: 40px; padding: 7px 12px; color: #c3d7cb; background: #142019; border-color: #304b3a; font-size: 12px; }
.lunar-workspace .chat-history-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.lunar-workspace .chat-history-heading h2 { margin: 0; color: #e7f0eb; font-size: 15px; font-weight: 650; }
.lunar-workspace .chat-history > .button.primary { flex: 0 0 auto; min-height: 44px; text-align: center; }
.lunar-workspace .chat-history .field { flex: 0 0 auto; margin: 14px 0 4px; }
.lunar-workspace .chat-history input { width: 100%; min-height: 44px; }
.lunar-workspace #conversation-history-results { min-height: 0; overflow-y: auto; scrollbar-color: #405149 transparent; }
.lunar-workspace .chat-history-status { margin: 6px 0; color: #e6bd79; font-size: 12px; line-height: 1.4; }
.lunar-workspace .chat-history-status:empty { display: none; }
.lunar-workspace .chat-history-list { display: grid; grid-template-columns: 1fr; gap: 5px; margin: 0; }
.lunar-workspace .chat-history-item { min-width: 0; padding: 2px; border-left: 2px solid transparent; border-radius: 5px; }
.lunar-workspace .chat-history-item.is-active { background: #1c2b25; border-left-color: #75cda7; }
.lunar-workspace .chat-history-row { display: grid; grid-template-columns: minmax(0, 1fr) 44px; align-items: center; min-width: 0; }
.lunar-workspace .chat-history-list .history-open { min-width: 0; min-height: 44px; padding: 6px 8px; touch-action: pan-y; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.lunar-workspace .chat-history-list .history-open:disabled { opacity: .7; cursor: wait; }
.lunar-workspace .history-menu-trigger { display: grid; place-items: center; width: 44px; min-height: 44px; padding: 0; color: #c4d9cc; background: transparent; font-size: 22px; letter-spacing: 2px; opacity: .64; text-align: center; }
.lunar-workspace .chat-history-item:hover .history-menu-trigger,
.lunar-workspace .chat-history-item:focus-within .history-menu-trigger,
.lunar-workspace .chat-history-item.has-menu .history-menu-trigger { opacity: 1; }
.lunar-workspace .history-menu-trigger:focus-visible,
.lunar-workspace .chat-history-actions button:focus-visible,
.lunar-workspace .history-open:focus-visible { outline: 2px solid #80d0aa; outline-offset: -2px; }
.lunar-workspace .chat-history-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px; padding: 5px 4px 7px; border-top: 1px solid #32443a; }
.lunar-workspace .chat-history-actions button { width: 100%; min-height: 44px; padding: 8px 7px; color: #d1e1d6; font-size: 13px; text-align: center; }
.lunar-workspace .chat-history-actions button:hover { color: #fff; background: #2b4033; }
.lunar-workspace .chat-history-actions button[data-history-action="delete"] { color: #f0b2ad; }
.lunar-workspace .chat-history-export-status { margin: 0 4px 6px; color: #b8d3c0; font-size: 12px; }
.lunar-workspace .chat-history-export-status.is-error { color: #ffd1c7; }
.lunar-workspace .chat-history-empty { padding: 14px 8px; color: #a9b9b0; font-size: 13px; }
.lunar-workspace #conversation-history-more,
.lunar-workspace #conversation-history-retry { width: 100%; min-height: 44px; margin-top: 12px; }
.lunar-workspace .chat-history-backdrop[hidden] { display: none; }
.chat-history-dialog { width: min(440px, calc(100vw - 28px)); padding: 22px; color: #e8f0eb; background: #161f1a; border: 1px solid #43574b; border-radius: 10px; box-shadow: 0 22px 72px rgb(0 0 0 / 55%); }
.chat-history-dialog::backdrop { background: rgb(0 0 0 / 68%); }
.chat-history-dialog h2 { margin: 0 0 14px; font-size: 19px; }
.chat-history-dialog p { color: #c4d3ca; }
.chat-history-dialog label { display: block; margin-bottom: 7px; }
.chat-history-dialog input { width: 100%; min-height: 44px; color: #f1f8f3; background: #0d1510; border: 1px solid #53665a; border-radius: 6px; }
.chat-history-dialog .button-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.chat-history-dialog .button-row .button { min-height: 44px; }
.chat-history-dialog-status { min-height: 1.3em; margin: 8px 0; color: #e8bc78; }
.lunar-workspace .chat-export-status { margin: 0; padding: 8px 20px; color: #c5decc; background: #16221a; font-size: 12px; }
.lunar-workspace .chat-export-status.is-error { color: #ffd1c7; background: #2c1d1a; }
.lunar-workspace .chat-older { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 16px; }
.lunar-workspace .chat-older .button { min-height: 44px; }
.lunar-workspace .chat-older p { color: #ffd1c7; }

@media (max-width: 980px) {
  .lunar-workspace #insight-switcher { display: none; }
  .lunar-workspace .chat-layout { display: block; }
  .lunar-workspace .chat-main { height: 100%; }
  .lunar-workspace .chat-history-backdrop:not([hidden]) { position: absolute; z-index: 79; inset: 0; display: block; width: 100%; height: 100%; padding: 0; background: rgb(0 0 0 / 60%); border: 0; }
  .lunar-workspace .chat-layout.history-opened .chat-history { position: absolute; z-index: 80; inset: 0 auto 0 0; display: flex; flex-direction: column; width: min(330px, 88vw); height: 100%; max-height: none; padding: 18px 14px; overflow: hidden; background: #101714; border: 0; border-right: 1px solid #415248; border-radius: 0; box-shadow: 16px 0 46px rgb(0 0 0 / 50%); }
  .lunar-workspace #conversation-history-close { display: inline-grid; flex: 0 0 44px; width: 44px; height: 44px; place-items: center; }
  .lunar-workspace .history-menu-trigger { opacity: .86; }
}

@media (max-width: 980px) {
  .app-shell,
  body.nav-expanded .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; transform: translateX(-105%); }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu { display: inline-grid; }
}

@media (max-width: 680px) {
  .lunar-workspace { width: 100%; padding-inline: max(8px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-right)); }
  .lunar-workspace .lunar-home-header { padding-inline: 4px; }
  .lunar-workspace .lunar-home-identity { justify-items: center; text-align: center; }
  .lunar-workspace .lunar-system-status-heading { justify-content: center; }
  .lunar-workspace .lunar-system-status .company-status-strip {
    display: flex;
    flex-wrap: nowrap;
    grid-template-columns: none;
    justify-content: flex-start;
    gap: 10px;
    width: 100%;
    padding: 2px 16px 6px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    scroll-padding-inline: 16px;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    mask-image: linear-gradient(to right, transparent, #000 18px, #000 calc(100% - 18px), transparent);
  }
  .lunar-workspace .lunar-system-status .company-status-strip::-webkit-scrollbar { display: none; }
  .lunar-workspace .lunar-system-status .company-status {
    flex: 0 0 calc((100% - 42px) / 2);
    grid-template-columns: 22px minmax(0, 1fr);
    min-width: 124px;
    min-height: 52px;
    padding: 5px 4px;
    border: 0;
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }
  .lunar-workspace .lunar-system-status .company-status:nth-child(odd) { border-right: 0; }
  .lunar-workspace .lunar-system-status .status-copy { padding-left: 7px; }
  .lunar-workspace .lunar-system-status .status-copy strong { font-size: 14px; }
  .lunar-workspace .lunar-system-status .status-copy > span { font-size: 10.5px; }
  .lunar-workspace .chat-main-header,
  .lunar-workspace .chat-log,
  .lunar-workspace .chat-composer { padding-inline: 6px; }
  .lunar-workspace .chat-log { padding-top: 12px; }
  .lunar-workspace .lunar-samples { gap: 8px; }
  .lunar-workspace .lunar-sample { min-height: 52px; padding: 9px 10px; }
}

/* Final precedence: desktop starts expanded; only an explicit user choice compacts it. */
@media (min-width: 981px) {
  .lunar-workspace-active .app-shell,
  body.lunar-workspace-active.nav-expanded .app-shell { grid-template-columns: 244px minmax(0, 1fr); }
  body.lunar-workspace-active:not(.nav-expanded) .app-shell { grid-template-columns: 76px minmax(0, 1fr); }
  .lunar-workspace-active .sidebar { width: 244px; }
  body.lunar-workspace-active:not(.nav-expanded) .sidebar { width: 76px; }
  .lunar-workspace-active .sidebar .nav-label { display: inline; }
  body.lunar-workspace-active:not(.nav-expanded) .sidebar .nav-label { display: none; }
  .lunar-workspace-active .sidebar .brand img.brand-master-lockup { width: 168px; height: 42px; }
  body.lunar-workspace-active:not(.nav-expanded) .sidebar .brand img.brand-master-lockup { width: 52px; }
  .lunar-workspace-active .navigation-toggle { display: inline-grid; }
}
.operating-profile-form {
  display: grid;
  gap: 16px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.operating-profile-form .choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.operating-profile-form > .button.primary {
  min-height: 48px;
  justify-self: start;
}

.operating-profile-save-status {
  min-height: 1.5rem;
}

.operating-profile-save-status .success-message,
.operating-profile-save-status .error-message {
  margin: 0 0 0.75rem;
}

.compact-mapping-card .button.quiet,
.mapping-progress .button.quiet { min-height: 44px; }

/* The workspace keeps navigation, the active decision, and evidence visible
   on desktop while collapsing to one clear reading flow on touch screens. */
.product-mapping-page { max-width: 1120px; }
.mapping-workspace-tabs { display: flex; flex-wrap: wrap; gap: 8px; width: min(100%, 1280px); margin: 0 0 12px; }
.mapping-workspace-tabs button { min-height: 44px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); text-align: left; cursor: pointer; }
.mapping-workspace-tabs button.active { border-color: var(--line-strong); box-shadow: inset 0 -3px var(--accent); }
.mapping-workspace-tabs strong, .mapping-workspace-tabs span { display: block; }
.mapping-workspace-tabs span { color: var(--muted); font-size: .82rem; }
.product-mapping-workspace { display: grid; grid-template-columns: minmax(210px, .8fr) minmax(0, 1.5fr) minmax(210px, .8fr); align-items: start; gap: 14px; width: min(100%, 1280px); }
.product-mapping-workspace > .panel { min-width: 0; margin: 0; }
.product-mapping-workspace .product-mapping-focus-panel { width: 100%; }
.mapping-workspace-list { display: grid; gap: 6px; max-height: none; overflow: visible; }
.mapping-workspace-record { display: grid; gap: 3px; width: 100%; min-height: 60px; padding: 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-subtle); color: var(--ink); text-align: left; cursor: pointer; }
.mapping-workspace-record:hover { border-color: var(--accent); }
.mapping-workspace-record[aria-current="true"] { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); background: var(--surface); }
.mapping-workspace-record strong, .mapping-workspace-record small, .mapping-workspace-record span { overflow-wrap: anywhere; }
.mapping-workspace-record small { color: var(--muted); }
.mapping-workspace-record span { color: #8a5a00; font-size: .82rem; font-weight: 700; }
.mapping-workspace-evidence { display: grid; gap: 10px; }
.mapping-workspace-evidence h3, .mapping-workspace-evidence p { margin: 0; }
.mapping-workflow-step { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.mapping-workflow-step > div { min-width: 0; }
.mapping-workflow-step p { margin: 4px 0 0; }
.mapping-workflow-step.current { border-color: var(--line-strong); box-shadow: inset 3px 0 var(--accent); }
.mapping-workflow-step.complete { color: #173a2d; border-color: #9bc7b3; background: #f4fbf7; }
.mapping-workflow-step.future { color: var(--muted); background: var(--surface-subtle); }
.mapping-step-number { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: #fff; background: var(--accent); font-weight: 800; }
.mapping-workflow-step.complete .mapping-step-number { background: var(--success); }
.mapping-workflow-step.future .mapping-step-number { color: var(--muted); background: var(--line); }
.mapping-workflow-later { display: grid; gap: 8px; }
.mapping-source-facts { padding: 9px 10px; border-radius: 7px; background: var(--surface-subtle); }
.purchase-unit-facts { display: grid; gap: 0; margin: 10px 0; }
.purchase-unit-facts > div { display: grid; grid-template-columns: minmax(150px, .8fr) minmax(0, 1.2fr); gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.purchase-unit-facts dt { color: var(--muted); }
.purchase-unit-facts dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.supplier-variant-parent-group { display: grid; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.supplier-variant-parent-group h4 { margin: 0; color: var(--muted); font-size: .82rem; font-weight: 650; overflow-wrap: anywhere; }
.supplier-variant-parent, .supplier-variant-pack-level, .supplier-variant-reason { display: block; }
.supplier-variant-parent { color: var(--muted); font-size: .82rem; }
.supplier-variant-pack-level { justify-self: start; padding: 2px 7px; border-radius: 999px; background: var(--surface-subtle); color: var(--ink); font-size: .76rem; font-weight: 750; }
.supplier-variant-reason { display: grid; gap: 2px; margin-top: 4px; font-size: .82rem; }
.product-mapping-workspace .supplier-variant-results { max-height: none; overflow: visible; }
.private-position-selector { scroll-margin-top: 16px; }
.private-position-list { display: grid; gap: 8px; }
.private-position-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-subtle); }
.private-position-choice { display: flex; min-width: 0; min-height: 44px; align-items: center; gap: 10px; cursor: pointer; }
.private-position-choice input { width: 20px; height: 20px; flex: 0 0 auto; }
.private-position-choice span { display: grid; min-width: 0; gap: 2px; }
.private-position-choice strong, .private-position-choice small { overflow-wrap: anywhere; }
.private-position-choice small, .private-linked-effect { color: var(--muted); }
.private-linked-effect { font-size: .82rem; }
.line-usage-options { grid-column: 1 / -1; padding-top: 8px; border-top: 1px solid var(--line); }
.line-usage-options p { margin-top: 0; }
.private-position-actions { margin-top: 14px; }
.private-position-actions .button, .line-usage-options .button { min-height: 44px; }
.confirmation-details { display: grid; gap: 10px; margin: 12px 0; }
.confirmation-details section { padding: 10px 12px; border-left: 3px solid var(--accent); background: var(--surface-subtle); }
.confirmation-details h3 { margin: 0 0 6px; font-size: .95rem; }
.confirmation-details ul { margin: 0; padding-left: 20px; }
.related-sales-offers { padding-top: 0; border-top: 0; }
.related-sales-offers summary { min-height: 44px; cursor: pointer; font-weight: 700; }
.product-mapping-workspace details > summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; }
.related-sales-offers li { display: grid; gap: 2px; }
.related-sales-offers li span { color: var(--muted); }

@media (max-width: 900px) {
  .product-mapping-workspace { grid-template-columns: minmax(190px, .72fr) minmax(0, 1.28fr); }
  .mapping-workspace-evidence { grid-column: 1 / -1; }
  .private-position-row { grid-template-columns: minmax(0, 1fr); }
  .line-usage-options { grid-column: 1; }
}

@media (max-width: 540px) {
  .product-mapping-workspace { grid-template-columns: 1fr; gap: 9px; }
  .mapping-workspace-list { order: 2; max-height: none; overflow: visible; }
  .product-mapping-workspace .product-mapping-focus-panel { order: 1; }
  .mapping-workspace-evidence { grid-column: auto; order: 3; }
  .mapping-workspace-tabs { display: grid; grid-template-columns: 1fr 1fr; }
  .mapping-workspace-tabs button { min-width: 0; }
  .operating-profile-form .choice-grid { grid-template-columns: 1fr; }
  .operating-profile-form > .button.primary { width: 100%; }
  .purchase-unit-facts > div { grid-template-columns: 1fr; gap: 2px; }
  .mapping-action-footer { position: sticky; z-index: 3; bottom: max(0px, env(safe-area-inset-bottom)); margin-inline: -12px; padding: 10px 12px max(10px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); box-shadow: 0 -5px 14px rgb(24 46 38 / 8%); }
  .mapping-action-footer .button { width: 100%; min-height: 44px; }
  .product-mapping-workspace, .product-mapping-workspace > *, .compact-mapping-card { max-width: 100%; overflow-wrap: anywhere; }
}

/* Inventory activation is a consent flow, not an error state. Keep one clear
   decision visible at a time and one scroll surface inside the modal. */
.inventory-activation-card { width: min(100%, 1120px); }
.inventory-settings-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 24px; }
.inventory-settings-facts > div { min-width: 0; }
.inventory-setup-dialog { width: min(920px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: hidden; }
.inventory-setup-dialog > form { display: grid; max-height: calc(100dvh - 34px); overflow-y: auto; overscroll-behavior: contain; }
.inventory-setup-dialog fieldset[hidden],
.inventory-setup-dialog [hidden] { display: none !important; }
.inventory-setup-progress { margin: 0 0 12px; color: var(--muted); font-size: .86rem; font-weight: 750; }
.inventory-setup-dialog .inventory-enabled-settings { min-width: 0; }
.inventory-setup-dialog .inventory-enabled-settings > fieldset { margin-bottom: 0; }
.inventory-location-create { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.inventory-location-create input { min-width: 0; }
.inventory-location-create .button { min-height: 44px; }
.inventory-activation-status { min-height: 1.5rem; margin: 10px 0 0; color: var(--muted); }
.inventory-setup-dialog .dialog-actions { position: sticky; z-index: 2; bottom: -22px; margin: 0 -22px -22px; padding: 12px 22px max(12px, env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 96%, transparent); border-top: 1px solid var(--line); }
.product-autopilot-settings .catalog-readiness { margin-block: 16px; padding: 14px; background: var(--surface-subtle); border: 1px solid var(--line); border-radius: 8px; }
.product-autopilot-wizard .setup-progress { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin: 0; padding: 0; list-style: none; }
.product-autopilot-wizard .setup-progress li { min-width: 0; padding: 8px; color: var(--muted); border-bottom: 3px solid var(--line); font-size: .84rem; text-align: center; }
.product-autopilot-wizard .setup-progress li.active { color: var(--text); border-color: var(--accent); font-weight: 700; }
.product-autopilot-wizard .autopilot-step { display: grid; align-content: start; min-height: 300px; gap: 14px; }
.product-autopilot-wizard .catalog-readiness { padding: 16px; border: 1px solid var(--line); border-radius: 8px; }
.product-autopilot-wizard .choice-card { min-height: 96px; }
.product-autopilot-wizard .autopilot-summary { padding: 4px 0; }
.connection-inventory-setup { border-left: 3px solid var(--accent); }
.external-goods-receipt-list { display: grid; gap: 14px; }
.external-goods-receipt-card { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-subtle); }
.external-goods-receipt-card h4,
.external-goods-receipt-card p,
.external-goods-receipt-card dd { overflow-wrap: anywhere; }
.goods-receipt-effects { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-block: 14px; }
.goods-receipt-effects .notice { margin: 0; }
.goods-receipt-correction { margin-top: 12px; }
.goods-receipt-status:not(:empty) { min-height: 24px; margin-top: 10px; }

@media (max-width: 680px) {
  .inventory-settings-facts { grid-template-columns: 1fr; }
  .inventory-setup-dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .inventory-setup-dialog > form { max-height: calc(100dvh - 18px); padding: 16px; }
  .inventory-setup-dialog .choice-grid,
  .inventory-setup-dialog .form-grid,
  .inventory-location-create { grid-template-columns: 1fr; }
  .inventory-setup-dialog .choice-card { min-height: 88px; }
  .inventory-setup-dialog .dialog-actions { bottom: -16px; margin: 0 -16px -16px; padding-inline: 16px; }
  .inventory-setup-dialog .dialog-actions .button { width: 100%; min-height: 44px; }
  .product-autopilot-wizard .setup-progress { display: none; }
  .product-autopilot-wizard .autopilot-step { min-height: 0; }
  .supplier-variant-result { grid-template-columns: 44px minmax(0, 1fr); min-height: 64px; }
  .supplier-variant-image { width: 40px; height: 40px; }
  .inventory-activation-card .panel-header { align-items: flex-start; }
  .goods-receipt-effects { grid-template-columns: 1fr; }
  .external-goods-receipt-card { padding: 13px; }
  .external-goods-receipt-card .button-row .button { width: 100%; min-height: 44px; }
}

/* IA v2: the monthly tax view deliberately keeps the decision surface small.
   Detailed evidence remains available, but it never competes with the next
   normal-user action. */
.tax-v2-page { width: min(100%, 960px); margin: 0 auto; }
.tax-v2-page-header, .tax-v2-status, .tax-v2-package, .tax-v2-automation, .upload-return-state { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.tax-v2-page-header { margin-bottom: 20px; }
.tax-v2-page-header h1, .tax-v2-status h3, .tax-v2-package h3 { margin: 0; }
.tax-v2-period-trigger { display: grid; min-width: 148px; min-height: 44px; gap: 1px; padding: 8px 12px; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; cursor: pointer; text-align: left; }
.tax-v2-period-trigger span { font-weight: 760; }
.tax-v2-period-trigger small { color: var(--muted); font-size: .76rem; }
.tax-v2-period-picker { width: min(100%, 480px); display: grid; gap: 16px; }
.tax-v2-period-picker > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.tax-v2-period-picker h2, .tax-v2-period-picker p { margin: 0; }
.tax-v2-period-picker p { margin-top: 4px; color: var(--muted); }
.tax-v2-period-close { flex: 0 0 auto; font-size: 1.35rem; }
.tax-v2-period-months { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tax-v2-period-month { display: grid; min-height: 68px; gap: 4px; padding: 10px; color: var(--text); background: var(--surface-subtle); border: 1px solid var(--line); border-radius: 9px; cursor: pointer; text-align: left; }
.tax-v2-period-month:hover, .tax-v2-period-month:focus-visible, .tax-v2-period-month[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.tax-v2-period-month span { font-weight: 750; }
.tax-v2-period-month small { color: var(--muted); font-size: .76rem; }
.tax-v2-period-month.is-current small { color: var(--accent-dark); font-weight: 720; }
.tax-v2-workspace { display: grid; gap: 16px; }
.tax-v2-workspace:has(> .tax-month-v2) { padding: 0; border: 0; border-radius: 0; background: transparent; }
.tax-month-v2 { display: grid; gap: 22px; }
.tax-v2-status, .tax-v2-package, .upload-return-state { padding: clamp(16px, 2.8vw, 24px); border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.tax-v2-status.open { border-left: 4px solid var(--warning); }
.tax-v2-status.complete, .upload-return-state.success { border-left: 4px solid var(--success); }
.tax-v2-status.adviser-review, .tax-v2-package.adviser-review { border-left: 4px solid var(--warning); }
.tax-v2-status .eyebrow { color: var(--muted); letter-spacing: .07em; }
.tax-v2-status h3 { font-size: clamp(1.16rem, 2vw, 1.32rem); }
.tax-v2-status p, .tax-v2-package p, .upload-return-state p { margin: 6px 0 0; color: var(--muted); }
.tax-v2-package p:empty { display: none; }
.tax-v2-status .button, .tax-v2-package .button, .upload-return-state .button { min-height: 44px; flex: 0 0 auto; }
.tax-v2-next-steps { padding: 12px 18px; }
.tax-v2-next-steps h3 { margin: 0 0 4px; font-size: .94rem; }
.tax-v2-next-steps ul { margin: 0; padding: 0; list-style: none; }
.tax-v2-next-steps li { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 6px 0; border-top: 1px solid var(--line); }
.tax-v2-next-steps li span { min-width: 0; font-weight: 650; overflow-wrap: anywhere; }
.tax-v2-next-steps li .button { min-height: 44px; white-space: normal; text-align: right; }
.tax-v2-results-pending { padding: 13px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.tax-v2-results-pending h3 { margin: 0 0 4px; font-size: 1rem; }
.tax-v2-results-pending p { margin: 0; color: var(--muted); }
.tax-v2-readiness-collapsed { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.tax-v2-readiness-collapsed > summary { min-height: 44px; padding: 10px 0; cursor: pointer; font-weight: 680; }
.tax-v2-readiness-collapsed > .tax-v2-readiness { margin: 0 0 12px; }
.tax-v2-summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; padding: 4px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.tax-v2-summary-grid article { min-width: 0; padding: 8px 14px; border-right: 1px solid var(--line); }
.tax-v2-summary-grid article:first-child { padding-left: 0; }
.tax-v2-summary-grid article:last-child { border-right: 0; }
.tax-v2-summary-grid h3 { margin: 0 0 5px; color: var(--muted); font-size: .86rem; font-weight: 660; }
.tax-v2-summary-grid p { margin: 0; color: var(--ink); font-size: 1.08rem; font-weight: 730; overflow-wrap: anywhere; }
.tax-v2-business-summary { padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.tax-v2-business-summary > .panel-header { align-items: end; margin-bottom: 10px; }
.tax-v2-business-summary > .panel-header h3 { margin: 0; font-size: 1.08rem; }
.tax-v2-business-scope { display: block; margin-top: 2px; color: var(--warning); font-size: .82rem; font-weight: 710; }
.tax-v2-business-reconciliation { margin: 8px 0 12px; }
.tax-v2-business-summary .tax-v2-summary-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 0; }
.tax-v2-business-summary .metric-card { min-height: 116px; padding: 14px 12px; border: 0; border-right: 1px solid var(--line); border-radius: 0; background: transparent; box-shadow: none; }
.tax-v2-business-summary .metric-card:first-child { padding-left: 0; }
.tax-v2-business-summary .metric-card:last-child { border-right: 0; }
.tax-v2-business-summary .metric-card::before { display: none; }
.tax-v2-business-summary .metric-card:hover { border-color: var(--line); background: var(--surface-subtle); box-shadow: none; transform: none; }
.tax-v2-business-summary .metric-card h3 { margin: 0 0 7px; color: var(--muted); font-size: .84rem; font-weight: 660; }
.tax-v2-business-summary .metric-card p { margin: 0; color: var(--ink); font-size: 1.32rem; font-variant-numeric: tabular-nums; }
.tax-v2-business-summary .metric-card span { display: block; margin-top: 4px; color: var(--muted); font-size: .82rem; }
.tax-v2-business-summary .tax-v2-business-method summary,
.tax-v2-business-summary .tax-v2-business-details summary { color: var(--text); }
.tax-v2-automation { padding: 10px 0 0; border-top: 1px solid var(--line); }
.tax-v2-automation > div { display: grid; gap: 2px; }
.tax-v2-automation span { color: var(--muted); font-size: .9rem; }
.tax-v2-automation > div:last-child { display: flex; align-items: center; gap: 4px; }
.tax-v2-readiness { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.tax-v2-readiness-title { grid-column: 1 / -1; margin: 0; padding: 1px 8px 8px; color: var(--muted); font-size: .84rem; font-weight: 680; }
.month-dimension { display: grid; min-width: 0; min-height: 78px; align-content: start; gap: 3px; padding: 9px 12px; color: var(--text); background: transparent; border: 0; border-top: 1px solid var(--line); border-right: 1px solid var(--line); border-radius: 0; text-align: left; }
.month-dimension[data-month-action] { cursor: pointer; }
.month-dimension:last-child { border-right: 0; }
.month-dimension[data-month-action]:hover { background: var(--surface-subtle); }
.month-dimension strong { color: var(--text); }
.month-dimension.needs-review strong, .month-dimension.has-advisory strong { color: var(--warning); }
.month-dimension small { color: var(--muted); overflow-wrap: anywhere; }
.month-dimension[data-month-action] small:last-child { color: var(--accent-dark); font-weight: 680; }
.tax-v2-source-row .tax-v2-source-next { max-width: 58ch; margin: 8px 0 0; }
.tax-month-v2 > .tax-v2-document-cases { margin: 0; padding: 2px 4px; border: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; box-shadow: none; }
.tax-month-v2 > .tax-v2-package { padding: 12px 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: transparent; }
.tax-month-v2 > .tax-v2-package.adviser-review { padding-left: 13px; border-left: 3px solid var(--warning); }
.tax-v2-details { padding-top: 3px; border-top: 1px solid var(--line); }
.tax-v2-details summary { min-height: 44px; padding: 10px 0; color: var(--text); cursor: pointer; font-weight: 680; }
.tax-v2-review-header { display: grid; gap: 8px; margin-bottom: 4px; }
.tax-v2-review-header h2, .tax-v2-review-header p { margin: 0; }
.tax-v2-review-header p { color: var(--muted); }
.tax-v2-import-source-readback { display: grid; gap: 12px; padding: 18px 20px; }
.tax-v2-import-source-readback h3, .tax-v2-import-source-readback p { margin: 0; }
.tax-v2-import-source-readback > .notice { max-width: 72ch; }
.tax-v2-import-heading { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.tax-v2-import-heading .eyebrow { margin: 0 0 3px; }
.tax-v2-import-flag { flex: none; padding: 5px 9px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); font-size: .78rem; font-weight: 680; }
.tax-v2-import-channel { display: flex; align-items: start; justify-content: space-between; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.tax-v2-import-channel > div { display: grid; gap: 3px; min-width: 0; }
.tax-v2-import-channel strong, .tax-v2-import-channel span { overflow-wrap: anywhere; }
.tax-v2-import-channel span, .tax-v2-import-channel details, .tax-v2-import-source-readback .helper { color: var(--muted); font-size: .88rem; }
.tax-v2-import-channel summary { min-height: 28px; cursor: pointer; }
.tax-v2-import-channel ul, .tax-v2-import-quarantine { margin: 8px 0 0; padding-left: 19px; }
.tax-v2-import-channel li, .tax-v2-import-quarantine li { display: grid; gap: 3px; margin-block: 9px; overflow-wrap: anywhere; }
.tax-v2-import-quarantine details { color: var(--muted); font-size: .82rem; }
.tax-v2-import-quarantine summary { min-height: 28px; cursor: pointer; }
.tax-v2-import-quarantine details span { display: block; overflow-wrap: anywhere; }
.tax-v2-shopify-tax-readback { display: grid; gap: 12px; padding: 18px 20px; }
.tax-v2-shopify-tax-readback[hidden] { display: none; }
.tax-v2-shopify-tax-readback .panel-header, .tax-v2-shopify-tax-readback .panel-header p { margin: 0; }
.tax-v2-shopify-tax-readback .panel-header h3 { margin: 3px 0 6px; }
.tax-v2-shopify-tax-readback .helper { margin: 0; }
.tax-v2-shopify-tax-controls { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tax-v2-shopify-tax-controls [data-shopify-tax-account-name] { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tax-v2-shopify-tax-controls .button { flex: none; }
.tax-v2-shopify-tax-preview { display: grid; gap: 12px; min-width: 0; }
.tax-v2-shopify-tax-preview > p, .tax-v2-shopify-tax-preview h4 { margin: 0; }
.tax-v2-shopify-tax-buckets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tax-v2-shopify-tax-buckets article { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.tax-v2-shopify-tax-buckets dl { display: grid; gap: 6px; margin: 10px 0 0; }
.tax-v2-shopify-tax-buckets dl div { display: flex; justify-content: space-between; gap: 8px; }
.tax-v2-shopify-tax-buckets dd { margin: 0; font-weight: 700; text-align: right; }
.tax-v2-shopify-tax-preview details p { overflow-wrap: anywhere; }
.tax-v2-channel-table { min-width: 540px; table-layout: auto; }
.tax-v2-channel-table th:first-child,
.tax-v2-channel-table td:first-child { width: 42%; }
.tax-v2-channel-table th:not(:first-child),
.tax-v2-channel-table td:not(:first-child) { white-space: nowrap; text-align: right; }
.tax-v2-channel-table .tax-v2-channel-drill {
  justify-content: flex-start;
  width: 100%;
  min-width: 0;
  padding-inline: 0;
  overflow-wrap: anywhere;
  white-space: normal;
  text-align: left;
}
.document-review-summary ul { display: grid; gap: 7px; margin: 14px 0; padding: 0; list-style: none; }
.document-review-summary li { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-bottom: 7px; border-bottom: 1px solid var(--line); }
.document-review-summary li span { color: var(--muted); font-size: .9rem; text-align: right; }

/* Optional recurring-cost setup reuses the normal dialog treatment.  The
   action footer stays reachable above mobile browser controls and the wizard
   never creates a horizontal scroll surface. */
.recurring-cost-wizard { width: min(680px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); }
.recurring-cost-wizard::backdrop { background: rgb(0 0 0 / .5); }
.recurring-cost-wizard > form { display: grid; gap: 14px; max-height: calc(100dvh - 34px); overflow-y: auto; overscroll-behavior: contain; padding: 22px; }
.recurring-cost-wizard h2, .recurring-cost-wizard p { margin: 0; }
.recurring-cost-wizard .progress-track { min-height: 6px; overflow: hidden; border-radius: 6px; background: var(--surface-subtle); }
.recurring-cost-wizard .progress-track > span { display: block; height: 100%; background: var(--accent); }
.recurring-cost-wizard .dialog-actions { position: sticky; z-index: 2; bottom: -22px; margin: 0 -22px -22px; padding: 12px 22px max(12px, env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 96%, transparent); border-top: 1px solid var(--line); }
.supplier-routing-followup-dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow: auto;
}
.supplier-routing-followup-dialog > section { padding: 22px; }
.supplier-routing-followup-dialog h2 { font-size: clamp(1.25rem, 4vw, 1.7rem); line-height: 1.25; }
.supplier-routing-followup-dialog .dialog-actions { margin-top: 20px; }
.tax-v2-source-review #tax-v2-source-projection-dialog > section,
.tax-v2-source-review #tax-v2-source-link-revoke-dialog > section { padding: 22px; }
.tax-v2-source-review > .tax-v2-projection-panel { margin-block: 12px; padding: 18px 20px; background: transparent; border: 0; border-block-start: 1px solid var(--line); border-radius: 0; box-shadow: none; }
.tax-v2-source-link.needs-review > div:last-child > span { color: var(--warning); }
.guided-business-unit-remembered {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
}
.guided-business-unit-remembered > summary { cursor: pointer; font-weight: 700; }
.recurring-costs-start-card { align-content: start; }

@media (max-width: 680px) {
  .recurring-cost-wizard { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .recurring-cost-wizard > form { max-height: calc(100dvh - 18px); padding: 16px; }
  .recurring-cost-wizard .form-grid { grid-template-columns: 1fr; }
  .recurring-cost-wizard .dialog-actions { bottom: -16px; margin: 0 -16px -16px; padding-inline: 16px; }
  .recurring-cost-wizard .dialog-actions .button { width: 100%; min-height: 44px; }
  .supplier-routing-followup-dialog > section { padding: 16px; }
  .supplier-routing-followup-dialog .dialog-actions { display: grid; grid-template-columns: 1fr; }
  .supplier-routing-followup-dialog .dialog-actions .button,
  .supplier-routing-followup-dialog .supplier-routing-open-settings { width: 100%; min-height: 44px; }
  .tax-v2-source-review #tax-v2-source-projection-dialog > section,
  .tax-v2-source-review #tax-v2-source-link-revoke-dialog > section { padding: 16px; }
  .tax-v2-source-review > .tax-v2-projection-panel { padding-inline: 16px; }
  .tax-v2-source-review #tax-v2-source-projection-dialog .dialog-actions,
  .tax-v2-source-review #tax-v2-source-link-revoke-dialog .dialog-actions { display: grid; grid-template-columns: 1fr; }
}

@media (max-width: 980px) {
  .workspace { padding-top: max(28px, calc(18px + env(safe-area-inset-top))); padding-bottom: max(28px, calc(18px + env(safe-area-inset-bottom))); scroll-padding-top: max(28px, calc(18px + env(safe-area-inset-top))); }
  .tax-v2-page-header { align-items: flex-start; }
}

@media (max-width: 680px) {
  .lunar-workspace-active .topbar > .topbar-actions { display: flex; }
  .tax-v2-source-review > .panel > .panel-header { align-items: stretch; flex-direction: column; }
  .tax-v2-import-source-readback { padding: 16px; }
  .tax-v2-import-heading, .tax-v2-import-channel { flex-direction: column; }
  .tax-v2-import-flag { align-self: start; }
  .tax-v2-shopify-tax-readback { padding: 16px; }
  .tax-v2-shopify-tax-controls { align-items: stretch; flex-direction: column; }
  .tax-v2-shopify-tax-controls [data-shopify-tax-account-name] { flex: none; width: 100%; }
  .tax-v2-shopify-tax-controls .button { width: 100%; }
  .tax-v2-shopify-tax-buckets { grid-template-columns: 1fr; }
  .tax-v2-business-summary > .panel-header { align-items: stretch; flex-direction: column; }
  .tax-v2-business-summary > .panel-header .field { width: 100%; }
  .tax-v2-page-header, .tax-v2-status, .tax-v2-package, .upload-return-state { align-items: stretch; flex-direction: column; }
  .tax-v2-page-header h1 { font-size: clamp(1.7rem, 8vw, 2rem); }
  .tax-v2-page-header .tax-v2-period-trigger, .tax-v2-status .button, .tax-v2-package .button, .upload-return-state .button { width: 100%; }
  .tax-v2-next-steps { padding: 12px 16px; }
  .tax-v2-next-steps li { align-items: stretch; flex-direction: column; gap: 4px; }
  .tax-v2-next-steps li .button { align-self: flex-start; text-align: left; }
  .tax-v2-period-months { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tax-v2-summary-grid { grid-template-columns: 1fr; gap: 0; }
  .tax-v2-summary-grid article { display: block; padding: 11px 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .tax-v2-summary-grid article:last-child { border-bottom: 0; }
  .tax-v2-summary-grid article p { text-align: left; }
  .tax-v2-business-summary .tax-v2-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tax-v2-business-summary .metric-card { display: grid; min-height: 110px; padding: 12px; border-bottom: 1px solid var(--line); }
  .tax-v2-business-summary .metric-card:first-child { padding-left: 12px; }
  .tax-v2-business-summary .metric-card:nth-child(even) { border-right: 0; }
  .tax-v2-business-summary .metric-card:nth-last-child(-n + 2) { border-bottom: 0; }
  .tax-v2-business-summary .metric-card p { text-align: left; }
  .tax-v2-readiness { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .month-dimension { min-height: 78px; }
  .month-dimension:nth-of-type(even) { border-right: 0; }
  .month-dimension:nth-of-type(-n + 2) { border-bottom: 1px solid var(--line); }
  .tax-v2-automation { align-items: flex-start; flex-direction: column; }
  .tax-v2-automation > div:last-child { width: 100%; justify-content: space-between; }
  .tax-v2-review-header .button { justify-self: start; }
  .document-review-summary li { align-items: flex-start; flex-direction: column; gap: 2px; }
  .document-review-summary li span { text-align: left; }
  .tax-v2-channel-table { min-width: 0; }
  .tax-v2-channel-table td[data-label] { text-align: right; white-space: normal; }
  .tax-v2-channel-table td[data-label="Kanal"] { align-items: start; }
  .tax-v2-channel-table .tax-v2-channel-drill { min-height: 0; justify-self: end; text-align: right; }
}

@media (max-width: 360px) {
  .tax-v2-business-summary .tax-v2-summary-grid { grid-template-columns: 1fr; }
  .tax-v2-business-summary .metric-card { border-right: 0; border-bottom: 1px solid var(--line); }
  .tax-v2-business-summary .metric-card:nth-last-child(2) { border-bottom: 1px solid var(--line); }
}

/* Keep account controls on the first mobile row. A permitted sales import gets
   its own clearly labelled row instead of wrapping the profile control. */
@media (max-width: 600px) {
  body:not(.lunar-workspace-active) .topbar {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto auto;
    align-items: center;
    column-gap: 8px;
    row-gap: 10px;
  }
  body:not(.lunar-workspace-active) .topbar > .mobile-menu { grid-column: 1; grid-row: 1; }
  body:not(.lunar-workspace-active) .topbar > div:not(.topbar-actions) { grid-column: 2; grid-row: 1; }
  body:not(.lunar-workspace-active) .topbar > .topbar-actions { display: contents; }
  body:not(.lunar-workspace-active) .topbar #tasks-shortcut:not([hidden]) { grid-column: 3; grid-row: 1; }
  body:not(.lunar-workspace-active) .topbar .profile-menu { grid-column: 4; grid-row: 1; }
  body:not(.lunar-workspace-active) .topbar .unified-import-shortcut:not([hidden]) {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    min-width: 0;
    margin: 0;
  }
  body:not(.lunar-workspace-active) .topbar .unified-import-wide-label { display: inline; }
  body:not(.lunar-workspace-active) .topbar .unified-import-short-label { display: none; }
}

/* Chat actions and states stay explicit even when voice is not available. */
.lunar-workspace.has-conversation .lunar-home-header { display: none; }
.lunar-workspace .chat-composer-row { grid-template-columns: minmax(0, 1fr) auto; }
.lunar-workspace .lunar-orb,
.lunar-workspace .lunar-orb.has-text,
.lunar-workspace .lunar-orb.has-text:hover:not(:disabled) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 92px;
  max-width: none;
  height: 48px;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 10px;
  font-size: .92rem;
  font-weight: 700;
  letter-spacing: .01em;
  transform: none;
}
.lunar-workspace .lunar-orb:disabled { opacity: .68; }
.lunar-workspace .lunar-orb.has-text { color: #eafff4; background: #123d30; border-color: #4ca987; }
.lunar-workspace .lunar-orb.is-processing { color: #f6e8cb; background: #372b1a; border-color: #a98b50; }
.lunar-workspace .lunar-orb.is-processing::after { display: none; }
.lunar-workspace .lunar-orb-label { position: static; display: inline; transform: none; opacity: 1; }
.lunar-workspace .lunar-message-state {
  display: block;
  margin: 2px 0 4px;
  color: #9de0be;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.lunar-workspace .lunar-message-state.is-error { color: #ffb9b2; }
.lunar-workspace .lunar-message-state.is-stopped { color: #f1d49d; }
.lunar-workspace #lunar-progress:not(.sr-only) { margin: 8px 2px 0; color: #b9d4c8; }

.bundle-tax-review { display: grid; gap: 14px; }
.multipack-consent { display: block; }
.multipack-consent > details > summary { cursor: pointer; font-weight: 650; }
.multipack-consent > details > p { margin: 10px 0; }
.multipack-consent-list { display: grid; gap: 10px; margin-top: 12px; }
.multipack-consent-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px; border: 1px solid var(--line); border-radius: 9px; }
.multipack-consent-card > div { display: grid; gap: 3px; min-width: 0; }
.multipack-consent-card p { margin: 0; }
.multipack-consent-card span, .multipack-consent-card small { color: var(--muted); }
.multipack-consent-provenance { margin-top: 5px; font-size: .84rem; color: var(--muted); }
.multipack-consent-provenance summary { cursor: pointer; }
.multipack-consent-provenance p { margin: 5px 0 0; }
.multipack-consent-provenance code { overflow-wrap: anywhere; }
.multipack-consent-dialog { width: min(600px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: auto; }
.multipack-consent-dialog-body { display: grid; gap: 14px; padding: 20px; }
.multipack-consent-dialog-body h2, .multipack-consent-dialog-body p { margin: 0; }
.multipack-consent-preview { display: grid; gap: 10px; }
.multipack-consent-feedback { min-height: 1.4em; }
.multipack-consent-dialog .multipack-consent-save:disabled { opacity: .48; filter: grayscale(1); cursor: not-allowed; }
.bundle-tax-review .panel-header p { max-width: 72ch; margin: 4px 0 0; color: var(--muted); }
.bundle-tax-review-list { display: grid; gap: 8px; }
.bundle-tax-review-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px; border: 1px solid var(--line); border-radius: 9px; }
.bundle-tax-review-card > div { display: grid; gap: 2px; min-width: 0; }
.bundle-tax-review-card span { color: var(--muted); font-size: .88rem; }
.bundle-tax-review-card small { color: var(--muted); font-size: .76rem; }
.bundle-tax-review-dialog { width: min(880px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: auto; }
.bundle-tax-review-dialog > form { display: grid; gap: 16px; padding: 20px; }
.bundle-tax-group-context { display: grid; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: 9px; }
.bundle-tax-group-context h3,
.bundle-tax-group-context p { margin: 0; }
.bundle-tax-group-context ul { display: grid; gap: 6px; margin: 8px 0 0; padding: 0; list-style: none; }
.bundle-tax-group-context li { display: grid; gap: 2px; padding: 8px; background: var(--surface-subtle); border-radius: 7px; }
.bundle-tax-group-context li span,
.bundle-tax-group-context li small { color: var(--muted); }
.bundle-tax-provenance code { overflow-wrap: anywhere; word-break: break-word; }
.bundle-tax-selected-target { display: grid; gap: 4px; padding: 9px 12px; border-left: 3px solid var(--accent); background: var(--surface-subtle); border-radius: 5px; }
.bundle-tax-selected-target p { margin: 0; }
.bundle-tax-selected-target details { color: var(--muted); font-size: .85rem; }
.bundle-tax-selected-target summary { cursor: pointer; }
.bundle-tax-selected-target code { overflow-wrap: anywhere; word-break: break-word; }
.bundle-tax-dialog-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.bundle-tax-dialog-heading h2 { margin: 0; }
.bundle-tax-components { display: grid; gap: 12px; }
.bundle-tax-component-row { display: grid; grid-template-columns: minmax(210px, 1.7fr) minmax(90px, .55fr) minmax(145px, .8fr) minmax(150px, .8fr); gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 9px; }
.bundle-tax-component-row legend { padding-inline: 5px; font-weight: 700; }
.bundle-tax-component-row .bundle-tax-price-hint { grid-column: 1 / -1; margin: 0; }
.bundle-tax-component-row .bundle-tax-evidence { grid-column: 1 / -2; }
.bundle-tax-component-row .bundle-tax-remove { align-self: end; justify-self: end; }
.bundle-tax-preview-result { padding: 12px; border-left: 3px solid var(--accent); background: var(--surface-subtle); }
.bundle-tax-preview-result h3 { margin-top: 0; }
.bundle-tax-preview-result ul { display: grid; gap: 5px; padding: 0; list-style: none; }
.bundle-tax-preview-result li { display: flex; justify-content: space-between; gap: 12px; }
.bundle-tax-apply-step { display: grid; gap: 12px; padding-top: 14px; border-top: 1px solid var(--line); }
.bundle-tax-apply-step[hidden] { display: none; }
.bundle-tax-open-sources[hidden] { display: none !important; }
.bundle-tax-add[hidden] { display: none !important; }
.bundle-tax-preview[hidden] { display: none !important; }
.bundle-tax-options-state .bundle-tax-help { display: block; margin-top: 10px; }
.bundle-tax-preview-actions { justify-content: end; }
@media (max-width: 600px) {
  .lunar-workspace .chat-composer-row { grid-template-columns: minmax(0, 1fr) auto; }
  .lunar-workspace .lunar-orb { min-width: 82px; padding-inline: 12px; }
}

/* Lunar keeps one persistent workspace navigation: conversations. App routes are a drawer. */
body.lunar-workspace-active {
  --lunar-ink-page: #080d15;
  --lunar-ink-chat: #162435;
  --lunar-ink-sidebar: #080f19;
  --lunar-ink-header: #162435;
  --lunar-ink-footer: #162435;
  --lunar-ink-composer: #213242;
  --lunar-ink-raised: #2b3c4b;
  --lunar-ink-hover: #334758;
  --lunar-ink-line: #293947;
  --lunar-ink-control-line: #647c90;
  --lunar-ink-text: #f1f5f7;
  --lunar-ink-muted: #b8c5cf;
  --lunar-ink-action: #a4b7c5;
  --lunar-ink-placeholder: #b6c6d0;
  --lunar-mint: #8be0b9;
  background: var(--lunar-ink-page);
}
body.lunar-workspace-active .workspace,
body.lunar-workspace-active .topbar,
.lunar-workspace { background: var(--lunar-ink-page); }
body.lunar-workspace-active .sidebar.open { background: var(--lunar-ink-sidebar); }
@media (min-width: 981px) {
  body.lunar-workspace-active .app-shell,
  body.lunar-workspace-active.nav-expanded .app-shell,
  body.lunar-workspace-active:not(.nav-expanded) .app-shell { grid-template-columns: minmax(0, 1fr); }
  body.lunar-workspace-active .sidebar,
  body.lunar-workspace-active.nav-expanded .sidebar,
  body.lunar-workspace-active:not(.nav-expanded) .sidebar,
  body.lunar-workspace-active .sidebar.open {
    position: fixed;
    z-index: 70;
    inset: 0 auto 0 0;
    width: min(320px, 88vw);
    height: 100dvh;
    transform: translateX(-105%);
    box-shadow: 18px 0 48px rgb(0 0 0 / 42%);
  }
  body.lunar-workspace-active .sidebar.open { transform: translateX(0); }
  body.lunar-workspace-active .sidebar .nav-label { display: inline; }
  body.lunar-workspace-active .sidebar .brand img.brand-master-lockup { width: 168px; }
  body.lunar-workspace-active .navigation-toggle { display: none; }
  body.lunar-workspace-active .mobile-menu { display: inline-grid; order: 1; }
}

body.lunar-workspace-active .workspace { width: 100%; max-width: none; }
.lunar-workspace { width: 100%; align-items: stretch; padding: 4px clamp(8px, 1.5vw, 22px) 12px; }
.lunar-workspace .chat-layout { width: min(100%, 1600px); margin-inline: auto; background: var(--lunar-ink-chat); border: 1px solid var(--lunar-ink-line); border-radius: 16px; box-shadow: 0 14px 40px rgb(0 0 0 / 9%); }
.lunar-workspace .chat-history { background: var(--lunar-ink-sidebar); border-right-color: transparent; }
.lunar-workspace .chat-history-heading h2 { color: var(--lunar-ink-text); font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.lunar-workspace .chat-history > .button.primary { display: flex; align-items: center; justify-content: flex-start; gap: 10px; padding-inline: 13px; color: var(--lunar-ink-text); background: var(--lunar-ink-composer); border: 1px solid var(--lunar-ink-control-line); border-radius: 10px; box-shadow: none; font-size: 13px; font-weight: 600; }
.lunar-workspace .chat-history > .button.primary:hover { color: #fff; background: var(--lunar-ink-hover); border-color: var(--lunar-ink-control-line); }
.lunar-workspace .chat-history > .button.primary:focus-visible { outline: 2px solid var(--lunar-mint); outline-offset: 2px; }
.lunar-workspace .new-conversation-icon { display: inline-flex; color: var(--lunar-mint); }
.lunar-workspace .new-conversation-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.lunar-workspace .chat-history .field { margin-top: 10px; }
.lunar-workspace .chat-history input { background: var(--lunar-ink-sidebar); border-color: var(--lunar-ink-line); border-radius: 9px; }
.lunar-workspace .chat-history-list { gap: 2px; }
.lunar-workspace .chat-history-date { padding: 12px 10px 3px; list-style: none; }
.lunar-workspace .chat-history-date h3 { margin: 0; color: var(--lunar-ink-muted); font-size: 11px; font-weight: 600; line-height: 1.4; }
.lunar-workspace .chat-history-item { border-radius: 9px; }
.lunar-workspace .chat-history-item .history-open { padding-block: 8px; }
.lunar-workspace .chat-history-item .history-open strong { color: var(--lunar-ink-text); font-size: 13px; font-weight: 570; }
.lunar-workspace .chat-history-item .history-open small { color: var(--lunar-ink-muted); font-size: 11px; }
.lunar-workspace .chat-history-item.is-active { background: var(--lunar-ink-raised); border-left-color: var(--lunar-mint); }
.lunar-workspace .history-menu-trigger { opacity: 0; }
.lunar-workspace .history-menu-trigger svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; }
@media (hover: none) { .lunar-workspace .history-menu-trigger { opacity: .72; } }
.lunar-workspace .chat-main,
.lunar-workspace .chat-log,
.lunar-workspace .chat-composer { background: var(--lunar-ink-chat); }
.lunar-workspace .chat-main-header { min-height: 62px; padding: 9px clamp(14px, 2vw, 28px); background: var(--lunar-ink-header); border-bottom: 0; box-shadow: 0 8px 20px rgb(0 0 0 / 10%); }
.lunar-workspace .chat-main-header h2 { color: var(--lunar-ink-text); font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.lunar-workspace .chat-log { padding: 20px max(18px, calc((100% - 820px) / 2)); background-image: none; }
.lunar-workspace .lunar-empty { align-content: center; min-height: 100%; padding: 24px 8px; background: radial-gradient(ellipse 42% 30% at 50% 45%, rgb(128 158 182 / 7%), transparent 100%); }
.lunar-workspace .lunar-empty-brand { filter: drop-shadow(0 0 18px rgb(139 224 185 / 10%)); }
.lunar-workspace .lunar-empty h3 { font-size: clamp(23px, 2.2vw, 29px); font-weight: 650; }
.lunar-workspace .lunar-samples { width: min(100%, 620px); margin-top: 26px; }
.lunar-workspace .lunar-sample { min-height: 48px; color: var(--lunar-ink-text); background: var(--lunar-ink-chat); border-color: var(--lunar-ink-line); border-radius: 8px; }
.lunar-workspace .chat-composer { padding: 12px clamp(14px, 2vw, 28px) 14px; background: var(--lunar-ink-footer); border-top: 1px solid transparent; box-shadow: 0 -16px 30px rgb(4 9 15 / 18%); }
.lunar-workspace .chat-composer textarea { min-height: 48px; padding: 12px 6px; color: var(--lunar-ink-text); background: transparent; border: 0; box-shadow: none; resize: none; }
.lunar-workspace .chat-composer textarea:hover,
.lunar-workspace .chat-composer textarea:focus { border: 0; box-shadow: none; outline: 0; }
.lunar-workspace .chat-composer-row,
.lunar-workspace .lunar-payment-attach-trigger { width: min(100%, 820px); margin-inline: auto; }
.lunar-workspace .chat-composer-row { align-items: center; gap: 6px; padding: 4px 5px 4px 12px; background: var(--lunar-ink-composer); border: 1px solid var(--lunar-ink-control-line); border-radius: 14px; transition: border-color 150ms ease, box-shadow 150ms ease; }
.lunar-workspace .chat-composer-row:focus-within { border-color: var(--lunar-mint); box-shadow: 0 0 0 3px rgb(139 224 185 / 16%); }
.lunar-workspace .chat-composer-row .field { min-width: 0; }
.lunar-workspace .chat-composer-row .lunar-orb,
.lunar-workspace .chat-composer-row .lunar-orb.has-text,
.lunar-workspace .chat-composer-row .lunar-orb.has-text:hover:not(:disabled) { width: 44px; min-width: 44px; max-width: 44px; min-height: 44px; height: 44px; padding: 0; border-radius: 10px; box-shadow: none; }
.lunar-workspace .chat-composer-row .lunar-orb-icon { display: inline-flex; }
.lunar-workspace .chat-composer-row .lunar-orb svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.lunar-workspace .chat-composer-row .lunar-orb-stop-icon { display: none; }
.lunar-workspace .chat-composer-row .lunar-orb.is-processing .lunar-orb-send-icon { display: none; }
.lunar-workspace .chat-composer-row .lunar-orb.is-processing .lunar-orb-stop-icon { display: inline-flex; }
.lunar-workspace .chat-composer-row .lunar-orb-label.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.lunar-workspace .chat-composer-row .lunar-orb:disabled { color: var(--lunar-ink-muted); background: var(--lunar-ink-raised); border-color: var(--lunar-ink-control-line); opacity: 1; }
.lunar-workspace .chat-composer-row .lunar-orb.has-text { color: #0f2922; background: var(--lunar-mint); border-color: var(--lunar-mint); }
.lunar-workspace .chat-composer-row .lunar-orb.has-text:hover:not(:disabled) { color: #0f2922; background: #a9edce; border-color: #a9edce; }
.lunar-workspace .chat-composer-row .lunar-orb.is-processing { color: #f6e8cb; background: #433627; border-color: #a98b50; }
.lunar-workspace .lunar-payment-attach-trigger { display: block; text-align: left; }
.lunar-workspace .chat-message,
.lunar-workspace .chat-message.user,
.lunar-workspace .chat-message.assistant { margin-bottom: 18px; padding-top: 6px; padding-bottom: 6px; }
.lunar-workspace .chat-message p { display: inline; margin: 0; }
.lunar-workspace .chat-message .message-author { margin-bottom: 2px; }
.lunar-workspace .chat-message .message-time { display: block; margin: 2px 0 0; color: var(--lunar-ink-muted); font-size: 11px; line-height: 1.1; white-space: nowrap; }
.lunar-workspace .chat-message.assistant .message-tools { position: absolute; z-index: 2; top: 3px; right: 0; margin: 0; }
.lunar-workspace #insight-switcher { min-height: 44px; color: var(--lunar-ink-text); background: var(--lunar-ink-raised); border-color: var(--lunar-ink-line); border-radius: 10px; font-size: 13px; }
.lunar-workspace #insight-switcher:hover { background: var(--lunar-ink-hover); border-color: var(--lunar-ink-control-line); }
.lunar-workspace .chat-history input { color: var(--lunar-ink-text); background: var(--lunar-ink-sidebar); border-color: var(--lunar-ink-control-line); }
.lunar-workspace #conversation-search::placeholder,
.lunar-workspace #lunar-input::placeholder { color: var(--lunar-ink-placeholder); opacity: 1; }
.lunar-workspace .chat-history-item.is-active { background: var(--lunar-ink-raised); border-left-color: var(--lunar-mint); }
.lunar-workspace .chat-history-actions { border-top-color: var(--lunar-ink-line); }
.lunar-workspace .chat-history-actions button:hover { background: var(--lunar-ink-hover); }
.lunar-workspace #conversation-history-close { color: var(--lunar-ink-muted); background: var(--lunar-ink-composer); border: 1px solid var(--lunar-ink-line); border-radius: 9px; }
.lunar-workspace #conversation-history-close:hover,
.lunar-workspace #conversation-history-close:focus-visible { color: var(--lunar-ink-text); background: var(--lunar-ink-hover); border-color: var(--lunar-ink-control-line); }
.lunar-workspace #conversation-search:focus-visible { outline-color: var(--lunar-mint); }
.lunar-workspace .chat-history .history-menu-trigger { color: var(--lunar-ink-muted); }
.lunar-workspace .insight-switcher-mobile { display: none; }
.lunar-workspace .insight-rail { display: none; }
.lunar-workspace .chat-layout.insights-opened .insight-rail {
  position: absolute;
  z-index: 50;
  top: 60px;
  right: 16px;
  left: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  align-items: stretch;
  width: min(520px, calc(100% - 32px));
  max-width: none;
  height: auto;
  max-height: calc(100% - 76px);
  padding: 14px;
  overflow-y: auto;
  color: var(--lunar-ink-text);
  background: var(--lunar-ink-raised);
  border: 1px solid var(--lunar-ink-control-line);
  border-radius: 10px;
  box-shadow: 0 20px 55px rgb(0 0 0 / 48%);
}
.lunar-workspace .chat-layout.insights-opened .insight-rail .lunar-system-status { grid-column: 1 / -1; display: block; width: 100%; margin: 0 0 8px; padding: 0 0 12px; border-bottom: 1px solid var(--lunar-ink-line); }
.lunar-workspace .chat-layout.insights-opened .lunar-system-status-heading { justify-content: flex-start; margin: 0 0 8px; }
.lunar-workspace .chat-layout.insights-opened .lunar-system-status-heading h2 { color: var(--lunar-ink-text); font-size: 12px; letter-spacing: .02em; text-transform: none; }
.lunar-workspace .chat-layout.insights-opened .lunar-system-status-heading span { display: none; }
.lunar-workspace .chat-layout.insights-opened .insight-rail .company-status-strip { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; width: 100%; padding: 0; overflow: visible; mask-image: none; }
.lunar-workspace .chat-layout.insights-opened .insight-rail .company-status { width: 100%; min-width: 0; min-height: 50px; padding: 7px 8px; border: 1px solid var(--lunar-ink-line); border-radius: 6px; text-align: left; }
.lunar-workspace .chat-layout.insights-opened .insight-rail .status-copy { min-width: 0; }
.lunar-workspace .chat-layout.insights-opened .insight-rail .status-copy strong,
.lunar-workspace .chat-layout.insights-opened .insight-rail .status-copy span { overflow: hidden; text-overflow: ellipsis; }
.lunar-workspace .chat-layout.insights-opened .insight-rail .insight-collapse { display: none; }
.lunar-workspace .chat-layout.insights-opened .insight-rail .insight-button[data-insight] { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 7px 9px; color: var(--lunar-ink-text); border: 1px solid transparent; border-radius: 6px; box-shadow: none; }
.lunar-workspace .chat-layout.insights-opened .insight-rail .insight-button[data-insight]:hover,
.lunar-workspace .chat-layout.insights-opened .insight-rail .insight-button[data-insight]:focus-visible { background: var(--lunar-ink-hover); border-color: var(--lunar-mint); }
.lunar-workspace .chat-layout.insights-opened .insight-rail .insight-label { position: static; max-width: none; padding: 0; opacity: 1; color: inherit; background: transparent; border: 0; box-shadow: none; font-size: 13px; line-height: 1.25; text-align: left; white-space: normal; transform: none; }
.lunar-workspace .insight-flyout { z-index: 51; top: 60px; right: 16px; bottom: auto; left: auto; width: min(430px, calc(100% - 32px)); max-height: calc(100% - 76px); }

/* A conversation is the primary surface; controls recede until they are needed. */
.lunar-workspace .chat-main-header { border-bottom-color: rgb(163 185 205 / 7%); }
.lunar-workspace .chat-header-actions { gap: 3px; }
.lunar-workspace .conversation-heading #conversation-switcher,
.lunar-workspace .chat-header-actions .icon-button { color: var(--lunar-ink-action); background: transparent; border: 0; border-radius: 10px; box-shadow: none; }
.lunar-workspace .conversation-heading #conversation-switcher:hover,
.lunar-workspace .conversation-heading #conversation-switcher:focus-visible,
.lunar-workspace .chat-header-actions .icon-button:hover,
.lunar-workspace .chat-header-actions .icon-button:focus-visible { color: var(--lunar-ink-text); background: var(--lunar-ink-hover); }
.lunar-workspace #insight-switcher { color: var(--lunar-ink-muted); background: transparent; border-color: transparent; }
.lunar-workspace #insight-switcher:hover,
.lunar-workspace #insight-switcher:focus-visible { color: var(--lunar-ink-text); background: var(--lunar-ink-hover); border-color: var(--lunar-ink-line); }
.lunar-workspace .lunar-samples { gap: 22px; }
.lunar-workspace .lunar-sample { position: relative; min-height: 48px; padding: 10px 25px 10px 4px; color: var(--lunar-ink-text); background: transparent; border: 0; border-bottom: 1px solid var(--lunar-ink-line); border-radius: 0; text-align: left; }
.lunar-workspace .lunar-sample::after { position: absolute; top: calc(50% - 4px); right: 6px; width: 7px; height: 7px; border-top: 1.5px solid #8fb6a6; border-right: 1.5px solid #8fb6a6; content: ""; transform: rotate(45deg); }
.lunar-workspace .lunar-sample:hover,
.lunar-workspace .lunar-sample:focus-visible { color: #fff; background: var(--lunar-ink-raised); border-bottom-color: var(--lunar-mint); }
.lunar-workspace .chat-composer { background: var(--lunar-ink-footer); border-top-color: transparent; }
.lunar-workspace .lunar-payment-attach-trigger { margin-top: 6px; color: var(--lunar-mint); font-size: 12px; }
.lunar-workspace .lunar-payment-attach-trigger:hover,
.lunar-workspace .lunar-payment-attach-trigger:focus-visible { color: #a6e9c7; }
.lunar-workspace .lunar-mobile-menu-action { display: none; }
.lunar-workspace .chat-message.assistant .message-tools { top: 2px; }
.lunar-workspace .message-tools .answer-menu > summary { width: 44px; min-height: 44px; color: var(--lunar-ink-action); background: transparent; border: 0; border-radius: 10px; }
.lunar-workspace .message-tools .answer-menu > summary:hover,
.lunar-workspace .message-tools .answer-menu > summary:focus-visible { color: var(--lunar-ink-text); background: var(--lunar-ink-hover); outline-color: var(--lunar-mint); }
.lunar-workspace .message-tools .answer-menu-popover { min-width: 188px; padding: 5px; color: var(--lunar-ink-text); background: var(--lunar-ink-raised); border: 1px solid var(--lunar-ink-control-line); border-radius: 10px; box-shadow: 0 14px 40px rgb(0 0 0 / 40%); }
.lunar-workspace .message-tools .answer-menu-popover button { width: 100%; min-height: 44px; color: var(--lunar-ink-text); border: 0; border-radius: 7px; font-size: 13px; text-align: left; }
.lunar-workspace .message-tools .answer-menu-popover .copy-message { display: flex; align-items: center; gap: 10px; padding: 9px; }
.lunar-workspace .message-tools .answer-menu-popover .copy-message svg { flex: 0 0 18px; width: 18px; height: 18px; }
.lunar-workspace .message-tools .answer-menu-popover button:hover,
.lunar-workspace .message-tools .answer-menu-popover button:focus-visible { color: #fff; background: var(--lunar-ink-hover); }
.lunar-workspace .chat-message.assistant:not(:hover, :focus-within) .message-tools { opacity: 0; }
.lunar-workspace .chat-message.assistant .message-tools:has(.answer-menu[open]) { opacity: 1; }

@media (min-width: 981px) {
  .lunar-workspace { padding: 0; }
  .lunar-workspace .chat-layout { width: 100%; max-width: none; border: 0; border-radius: 0; box-shadow: none; }
  .lunar-workspace .chat-history { border-right-color: transparent; }
  .lunar-workspace .chat-main-header { padding-inline: clamp(22px, 2.4vw, 36px); }
  .lunar-workspace .chat-composer { padding-bottom: 20px; }
  .lunar-workspace .chat-message.assistant .message-tools { position: relative; top: auto; right: auto; left: auto; height: 0; margin: 0; opacity: 0; pointer-events: none; }
  .lunar-workspace .chat-message.assistant:hover .message-tools,
  .lunar-workspace .chat-message.assistant:focus-within .message-tools { height: auto; min-height: 44px; margin-top: 4px; opacity: 1; pointer-events: auto; }
  .lunar-workspace .chat-message.assistant .answer-menu-popover { position: static; margin-bottom: 8px; box-shadow: none; }
}

@media (max-width: 980px) {
  .lunar-workspace { padding: 0; }
  .lunar-workspace .conversation-heading { gap: 4px; }
  .lunar-workspace .conversation-heading #conversation-switcher { flex: 0 0 44px; width: 44px; min-height: 44px; }
  .lunar-workspace .conversation-heading #conversation-switcher svg,
  .lunar-workspace .chat-header-actions .icon-button svg,
  .lunar-workspace .message-tools .answer-menu > summary svg { width: 20px; height: 20px; stroke-width: 1.75; }
  .lunar-workspace #insight-switcher,
  .lunar-workspace #notification-trigger { display: none; }
  .lunar-workspace .conversation-menu-popover .lunar-mobile-menu-action { display: block; min-height: 44px; }
  .lunar-workspace .chat-header-actions { gap: 1px; }
  .lunar-workspace .chat-header-actions .icon-button { width: 44px; min-width: 44px; min-height: 44px; }
  .lunar-workspace .chat-message.assistant .message-tools { opacity: 1; }
  .lunar-workspace .chat-message.assistant:not(:hover, :focus-within) .message-tools { opacity: 1; }
  .lunar-workspace .message-tools .answer-menu[open] > summary { color: var(--lunar-mint); background: var(--lunar-ink-raised); }
  .lunar-workspace .message-tools .answer-menu-popover {
    position: absolute;
    inset: auto 0 calc(100% + 8px) auto;
    width: min(224px, calc(100vw - 24px));
    min-width: 0;
    padding: 7px;
    border-radius: 14px;
    box-shadow: 0 18px 44px rgb(0 0 0 / 45%);
  }
  .lunar-workspace .message-tools .answer-menu-popover:popover-open {
    position: fixed;
    inset: auto 12px max(12px, env(safe-area-inset-bottom)) 12px;
    width: min(420px, calc(100vw - 24px));
    max-height: min(50dvh, 320px);
    margin: 0 auto;
    overflow: auto;
    padding: 8px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgb(0 0 0 / 55%);
  }
  .lunar-workspace .message-tools .answer-menu-popover button { min-height: 48px; padding: 10px 12px; }
  .lunar-workspace .message-tools .answer-menu-popover button + button { border-top: 1px solid var(--lunar-ink-line); }
  body.lunar-workspace-active #conversation-menu-popover {
    position: fixed;
    position-anchor: auto;
    inset: auto 12px max(12px, env(safe-area-inset-bottom)) 12px;
    width: min(420px, calc(100vw - 24px));
    margin-inline: auto;
    padding: 8px;
    border-radius: 16px;
  }
  .lunar-workspace .conversation-menu-popover button { min-height: 48px; padding: 10px 12px; }
  .lunar-workspace .conversation-menu-popover #rename-conversation { border-top: 1px solid var(--lunar-ink-line); }
  .lunar-workspace .chat-layout { border: 0; border-radius: 0; }
  .lunar-workspace .chat-layout.history-opened .chat-history { background: var(--lunar-ink-sidebar); border-right-color: var(--lunar-ink-line); }
  .lunar-workspace .chat-history-item { position: static; }
  .lunar-workspace .chat-history-item.has-menu .chat-history-actions { position: absolute; z-index: 90; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); left: 12px; display: grid; grid-template-columns: 1fr; gap: 0; padding: 8px; background: var(--lunar-ink-raised); border: 1px solid var(--lunar-ink-control-line); border-radius: 14px; box-shadow: 0 18px 50px rgb(0 0 0 / 55%); }
  .lunar-workspace .chat-history-item.has-menu .chat-history-actions button { min-height: 48px; padding: 10px 14px; border-radius: 8px; text-align: left; }
  .lunar-workspace .chat-history-item.has-menu .chat-history-actions button + button { border-top: 1px solid var(--lunar-ink-line); }
  /* Keep the 44px accessible menu target, but let titles lead the touch list. */
  .lunar-workspace .history-menu-trigger { opacity: .48; }
  .lunar-workspace .history-menu-trigger svg { width: 16px; height: 16px; }
  .lunar-workspace .chat-history-item.is-active .history-menu-trigger { opacity: .76; }
  .lunar-workspace .chat-main-header { min-height: 54px; padding: 6px 9px; }
  .lunar-workspace .chat-log { padding: 14px 12px; }
  .lunar-workspace .chat-composer { padding: 9px 8px max(9px, env(safe-area-inset-bottom)); }
  .lunar-workspace #insight-switcher { display: inline-flex; padding: 8px 10px; }
  .lunar-workspace .insight-switcher-desktop { display: none; }
  .lunar-workspace .insight-switcher-mobile { display: inline; }
  .lunar-workspace .chat-layout.insights-opened .insight-rail { top: 52px; right: 8px; width: min(430px, calc(100% - 16px)); max-height: calc(100% - 66px); }
  .lunar-workspace .insight-flyout { top: 52px; right: 8px; left: 8px; width: auto; max-height: calc(100% - 66px); }
}

/* Mobile has one clear overflow entry for secondary status and notices. */
@media (max-width: 980px) {
  .lunar-workspace .chat-header-actions #insight-switcher,
  .lunar-workspace .chat-header-actions #notification-trigger { display: none; }
  body.lunar-workspace-active .sidebar.open { transform: translateX(0); }
}

/* Legacy chat drawers and transient controls use the same cool surface ladder
   as the conversation. Mint stays an interaction accent, not a panel fill. */
body.lunar-workspace-active .topbar .icon-button { color: var(--lunar-ink-muted); background: var(--lunar-ink-sidebar); border-color: var(--lunar-ink-line); }
body.lunar-workspace-active .topbar .icon-button:hover,
body.lunar-workspace-active .topbar .icon-button:focus-visible { color: var(--lunar-ink-text); background: var(--lunar-ink-hover); border-color: var(--lunar-ink-control-line); }
body.lunar-workspace-active .chat-history-dialog { color: var(--lunar-ink-text); background: var(--lunar-ink-raised); border-color: var(--lunar-ink-control-line); }
body.lunar-workspace-active .chat-history-dialog p { color: var(--lunar-ink-muted); }
body.lunar-workspace-active .chat-history-dialog input { color: var(--lunar-ink-text); background: var(--lunar-ink-chat); border-color: var(--lunar-ink-control-line); }
body.lunar-workspace-active .chat-history-dialog .button.secondary { color: var(--lunar-ink-text); background: var(--lunar-ink-composer); border-color: var(--lunar-ink-control-line); }
body.lunar-workspace-active .chat-history-dialog .button.secondary:hover { background: var(--lunar-ink-hover); }
body.lunar-workspace-active .workspace-popover { color: var(--lunar-ink-text); background: var(--lunar-ink-raised); border-color: var(--lunar-ink-control-line); }
body.lunar-workspace-active .workspace-popover button { color: var(--lunar-ink-text); }
body.lunar-workspace-active .workspace-popover button:hover { background: var(--lunar-ink-hover); }
.lunar-workspace .chat-history-actions button { color: var(--lunar-ink-text); }
.lunar-workspace .chat-history-actions button:hover { background: var(--lunar-ink-hover); }
.lunar-workspace .chat-history-export-status,
.lunar-workspace .chat-export-status { color: var(--lunar-ink-muted); background: var(--lunar-ink-sidebar); }
.lunar-workspace .chat-message { color: var(--lunar-ink-text); }
.lunar-workspace .message-author { color: var(--lunar-ink-text); }
.lunar-workspace .message-time,
.lunar-workspace .message-sources { color: var(--lunar-ink-muted); }
.lunar-workspace .message-contexts span,
.lunar-workspace .context-chip { color: var(--lunar-ink-text); background: var(--lunar-ink-raised); border-color: var(--lunar-ink-line); }
.lunar-workspace .insight-flyout { color: var(--lunar-ink-text); background: var(--lunar-ink-raised); border-color: var(--lunar-ink-control-line); }
.lunar-workspace .insight-flyout .empty,
.lunar-workspace .insight-flyout .insight-empty-state,
.lunar-workspace .insight-flyout .insight-document-list li { color: var(--lunar-ink-text); background: var(--lunar-ink-sidebar); border-color: var(--lunar-ink-line); }
.lunar-workspace .insight-flyout .button.secondary,
.lunar-workspace .insight-flyout .close-insight { color: var(--lunar-ink-text); background: var(--lunar-ink-composer); border-color: var(--lunar-ink-control-line); }
@media (max-width: 680px) {
  .bundle-tax-review-card { align-items: stretch; flex-direction: column; }
  .multipack-consent-card { align-items: stretch; flex-direction: column; }
  .multipack-consent-card .button, .multipack-consent-dialog .button { width: 100%; }
  .multipack-consent-dialog-body { padding: 14px; }
  .bundle-tax-review-card .button { width: 100%; }
  .bundle-tax-review-dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .bundle-tax-review-dialog > form { padding: 14px; }
  .bundle-tax-dialog-heading { align-items: stretch; flex-direction: column; }
  .bundle-tax-dialog-heading .bundle-tax-dialog-close { align-self: flex-end; order: -1; width: fit-content; }
  .bundle-tax-dialog-heading h2 { max-width: 100%; overflow-wrap: normal; word-break: normal; hyphens: none; }
  .bundle-tax-component-row { grid-template-columns: 1fr; }
  .bundle-tax-component-row .bundle-tax-price-hint { grid-column: 1; }
  .bundle-tax-component-row .bundle-tax-evidence { grid-column: 1; }
  .bundle-tax-component-row .bundle-tax-remove,
  .bundle-tax-preview-actions .button,
  .bundle-tax-apply-step .button { width: 100%; justify-self: stretch; }
  .bundle-tax-preview-result li { align-items: flex-start; flex-direction: column; }
}
.product-tax-fact-original code { overflow-wrap: anywhere; word-break: break-word; }
