html, body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; margin: 0; color: #111827; background: #f9fafb; }

/* App shell: vertical stack — topbar fills the width, sidebar+content below. */
.app-shell { display: flex; flex-direction: column; min-height: 100vh; }
.app-body  { display: flex; flex: 1; min-height: 0; }
.sidebar   { width: 240px; background: #1f2937; color: #e5e7eb; padding-top: 0.75rem; flex-shrink: 0; }
.content   { flex: 1; padding: 1.5rem 2rem; background: #f9fafb; overflow-x: auto; }
.content > * { max-width: 1100px; }
.content > .table.aging { max-width: none; }   /* Aging has many columns — let it span freely. */

.nav-panel .nav-list { list-style: none; padding: 0; margin: 0; }
.nav-panel .nav-list li a { display: block; padding: 0.55rem 1.25rem; color: #d1d5db; text-decoration: none; font-size: 0.9rem; border-left: 3px solid transparent; }
.nav-panel .nav-list li a:hover { background: #374151; color: #fff; }
.nav-panel .nav-list li a.active { background: #111827; color: #fff; border-left-color: #2563eb; font-weight: 600; }
.nav-panel .nav-list li.section { padding: 0.9rem 1.25rem 0.35rem; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: #9ca3af; border-top: 1px solid #374151; margin-top: 0.5rem; }
.nav-panel .nav-list li:first-child.section { border-top: 0; margin-top: 0; padding-top: 0.5rem; }

.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tfoot tr.totals td { background: #f9fafb; border-top: 2px solid #d1d5db; }
.table tbody tr:hover { background: #f9fafb; }
.table td a { color: #2563eb; text-decoration: none; }
.table td a:hover { text-decoration: underline; }

.btn-outline { background: #fff; color: #2563eb; border: 1px solid #2563eb; }
.btn-outline:hover { background: #eff6ff; }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.page-header h1 { margin: 0; }

.tx-header { display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1.5rem; max-width: 720px; margin-bottom: 1.5rem; }
.tx-header dt { font-weight: 600; color: #4b5563; }
.tx-header dd { margin: 0; color: #111827; }

/* User chip / dropdown styles are defined further below in the topbar block. */

.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #f3f4f6; padding: 2rem; }
.login-card { background: #fff; padding: 2rem 2.25rem; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); width: 100%; max-width: 380px; }
.login-card h1 { margin: 0 0 0.4rem; font-size: 1.5rem; }
.login-card p.muted { margin: 0 0 1.2rem; color: #6b7280; }
.login-card form label { display: flex; flex-direction: column; margin-bottom: 0.9rem; font-size: 0.85rem; color: #4b5563; gap: 0.3rem; }
.login-card form label span { font-weight: 500; }
.login-card form input { padding: 0.55rem 0.7rem; border: 1px solid #d1d5db; border-radius: 4px; font-size: 0.95rem; }
.login-card form input:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.18); }
.login-card form button { width: 100%; padding: 0.6rem; font-size: 0.95rem; margin-top: 0.4rem; }

.table td.fx, .table th.fx { background: #fef9e7; }
.table th.group { background: #eef2ff; }

.date-range-filter, .as-of-filter { display: flex; align-items: end; gap: 0.5rem; }
.date-range-filter label, .as-of-filter label { font-size: 0.85rem; color: #4b5563; align-self: end; padding-bottom: 0.45rem; font-weight: 500; }
.date-range-filter select, .date-range-filter input[type=date], .as-of-filter input[type=date] { padding: 0.4rem 0.6rem; border: 1px solid #d1d5db; border-radius: 4px; }
.date-range-filter .arrow { color: #6b7280; align-self: center; }
.date-range-filter .range { color: #4b5563; font-variant-numeric: tabular-nums; font-size: 0.85rem; align-self: center; }

p.muted { color: #6b7280; font-style: italic; }

/* ── Top bar (full width, brand + client + user) ─────────────────────── */
.topbar { background: #fff; border-bottom: 1px solid #e5e7eb; box-shadow: 0 1px 2px rgba(0,0,0,0.04); padding: 0 1rem 0 0; height: 56px; display: flex; align-items: center; gap: 1rem; flex-wrap: nowrap; position: relative; flex-shrink: 0; }
.topbar-left  { display: flex; align-items: center; gap: 0.75rem; min-width: 0; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }

/* Brand sits inside the topbar's leftmost slot, occupying the same width
   as the sidebar so the vertical line under it visually continues into the
   nav menu — same trick Xero/QBO use to keep the chrome visually unified. */
.topbar .brand { display: inline-flex; align-items: center; gap: 0.6rem; width: 240px; height: 100%; padding: 0 0 0 1.25rem; box-sizing: border-box; background: #1f2937; color: #fff; text-decoration: none; flex-shrink: 0; }
.topbar .brand:hover { background: #111827; }
.topbar .brand .brand-mark { width: 28px; height: 28px; border-radius: 6px; background: #2563eb; color: #fff; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-size: 0.95rem; flex-shrink: 0; }
.topbar .brand .brand-name { font-weight: 600; font-size: 0.95rem; letter-spacing: 0.01em; white-space: nowrap; }

.topbar-divider { width: 1px; height: 28px; background: #e5e7eb; margin: 0 0.25rem; }

/* Client picker as a chip-button */
.client-picker { display: inline-flex; align-items: center; gap: 0.5rem; background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; padding: 0.3rem 0.5rem 0.3rem 0.7rem; transition: border-color 0.15s, background 0.15s; }
.client-picker:hover { background: #f3f4f6; border-color: #d1d5db; }
.client-picker:focus-within { border-color: #2563eb; background: #fff; box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
.client-picker .cp-icon { color: #6b7280; display: inline-flex; align-items: center; }
.client-picker select { background: transparent; border: 0; padding: 0.25rem 1.5rem 0.25rem 0; font: inherit; font-weight: 600; color: #111827; cursor: pointer; appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='2 2 6 6 10 2'/></svg>"); background-repeat: no-repeat; background-position: right 0.4rem center; background-size: 10px 6px; }
.client-picker select:focus { outline: none; }
.client-picker .cp-muted { color: #9ca3af; font-style: italic; padding: 0.25rem 0.4rem; }

/* User menu dropdown — uses native <details>/<summary>, no JS */
.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.25rem 0.6rem 0.25rem 0.3rem; border-radius: 8px; user-select: none; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary::marker { content: ""; }
.user-menu summary:hover { background: #f3f4f6; }
.user-menu[open] summary { background: #f3f4f6; }
.user-menu .avatar { width: 32px; height: 32px; border-radius: 50%; background: #2563eb; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.02em; flex-shrink: 0; }
.user-menu .user-name { font-weight: 500; color: #111827; font-size: 0.9rem; }
.user-menu .chevron { color: #6b7280; font-size: 0.75rem; }

.user-dropdown { position: absolute; right: 0; top: calc(100% + 6px); min-width: 240px; background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; box-shadow: 0 10px 25px rgba(0,0,0,0.08); z-index: 100; overflow: hidden; }
.user-dropdown-header { padding: 0.75rem 1rem; border-bottom: 1px solid #e5e7eb; }
.user-dropdown-header .dh-name { font-weight: 600; color: #111827; font-size: 0.9rem; }
.user-dropdown-header .dh-email { color: #6b7280; font-size: 0.8rem; margin-top: 0.15rem; word-break: break-all; }
.user-dropdown form { margin: 0; }
.user-dropdown-item { width: 100%; text-align: left; background: transparent; border: 0; padding: 0.6rem 1rem; font: inherit; font-size: 0.9rem; color: #111827; cursor: pointer; }
.user-dropdown-item:hover { background: #f3f4f6; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 0.5rem 0.75rem; border-bottom: 1px solid #e5e7eb; text-align: left; }
.table thead th { background: #f9fafb; font-weight: 600; }

.filters { display: flex; gap: 1rem; align-items: end; margin-bottom: 1rem; flex-wrap: wrap; }
.filters label { display: flex; flex-direction: column; font-size: 0.85rem; color: #4b5563; }
.filters label.check { flex-direction: row; align-items: center; gap: 0.4rem; }
.tb-warn { background: #fef3c7; color: #92400e; padding: 0.5rem 0.75rem; font-weight: 500; }
.tb-warn-row { background: #fef3c7 !important; }
.tb-warn-row td { color: #92400e; }
.table.tie-out { margin-top: 1.25rem; }
.table.tie-out tbody td { background: #f9fafb; }
.alert-success { background: #dcfce7; color: #14532d; border: 1px solid #86efac; padding: 0.6rem 0.9rem; border-radius: 4px; margin: 0.6rem 0; }
.num.warn { color: #b91c1c; font-weight: 600; }
.table th.group { text-align: center; border-bottom: 1px solid #d1d5db; background: #eef2ff; }

.table.report tbody tr.section-header td { background: #1f2937; color: #f9fafb; padding: 0.5rem 0.75rem; }
.table.report tbody tr.subtotal td { background: #f3f4f6; border-top: 1px solid #d1d5db; }
.table.report tbody tr.grand-total td { background: #1e40af; color: #fff; border-top: 2px solid #1e3a8a; padding: 0.6rem 0.75rem; }
.table.report tbody td:first-child { padding-left: 1.5rem; }
.table.report tbody tr.section-header td, .table.report tbody tr.subtotal td:first-child, .table.report tbody tr.grand-total td:first-child { padding-left: 0.75rem; }
.table.report { max-width: 720px; }

.export-buttons { display: flex; gap: 0.4rem; margin-left: auto; }
.export-buttons .btn { padding: 0.4rem 0.75rem; font-size: 0.85rem; }
.filters { align-items: end; }

.je-form .je-header { display: flex; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.je-form .je-header label { display: flex; flex-direction: column; font-size: 0.85rem; color: #4b5563; gap: 0.25rem; }
.je-form .je-header label.grow { flex: 1; min-width: 240px; }
.je-form .je-header input { padding: 0.4rem 0.6rem; border: 1px solid #d1d5db; border-radius: 4px; }
.table.je-lines td { padding: 0.3rem 0.4rem; }
.table.je-lines select, .table.je-lines input { width: 100%; padding: 0.35rem 0.5rem; border: 1px solid #d1d5db; border-radius: 4px; box-sizing: border-box; }
.table.je-lines input.num { text-align: right; font-variant-numeric: tabular-nums; }
.btn-remove { background: transparent; border: 0; color: #b91c1c; font-size: 1.2rem; line-height: 1; cursor: pointer; padding: 0.2rem 0.5rem; }
.btn-remove:hover { color: #7f1d1d; }
.je-actions { display: flex; gap: 0.5rem; margin-top: 1rem; align-items: center; }

.table.general-journal tbody tr.je-header td { background: #f3f4f6; border-top: 1px solid #d1d5db; padding-top: 0.5rem; padding-bottom: 0.4rem; }
.table.general-journal tbody tr.je-line td:nth-child(2) { padding-left: 1.5rem; }
.table.general-journal .badge { display: inline-block; background: #2563eb; color: #fff; font-size: 0.7rem; padding: 0.1rem 0.45rem; border-radius: 4px; margin-left: 0.4rem; vertical-align: middle; }
.table.general-journal .muted-inline { color: #6b7280; font-size: 0.9em; }

.table.aging tbody tr.group-header td { background: #eef2ff; padding-top: 0.6rem; padding-bottom: 0.4rem; border-top: 1px solid #c7d2fe; }
.table.aging tbody tr.subtotal td { background: #f9fafb; border-top: 1px solid #e5e7eb; }
.table.aging tbody tr.subtotal td:first-child { font-weight: 500; }
.table.aging tbody tr.credit-row td { color: #14532d; font-style: italic; background: #f0fdf4; }
.filters input { padding: 0.4rem; border: 1px solid #d1d5db; border-radius: 4px; }

.btn { padding: 0.45rem 0.9rem; border: 1px solid transparent; border-radius: 4px; cursor: pointer; font-size: 0.9rem; }
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }

.alert { padding: 0.75rem 1rem; border-radius: 4px; margin-bottom: 1rem; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

.text-muted { color: #6b7280; }
.text-danger { color: #b91c1c; }
.small { font-size: 0.85rem; }

#blazor-error-ui { background: #fef3c7; border-top: 1px solid #f59e0b; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2); display: none; left: 0; padding: 0.6rem 1.25rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }
