/* Desktop ERP workspace: shared dimensions, full-width documents and compact grids. */
:root {
    color-scheme: light;
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
    font-size: 13px;
    line-height: 1.35;
    color: #202b35;
    background: #e7ebef;
    --green: #216447;
    --line: #b9c2cb;
    --muted: #536271;
    --surface: #f1f3f5;
    --selection: #dcebe2;
    --sidebar-width: 176px;
    --control-height: 28px;
}

/* Appearance is a local browser preference; print documents keep a white paper background. */
.theme-choice {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.developer-editor {
    padding: 16px;
}
.developer-layout {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}
.developer-main {
    min-width: 0;
}
.developer-file-label {
    display: grid;
    gap: 6px;
    font-weight: 600;
}
.developer-file-label select {
    width: 100%;
}
.developer-create {
    border: 1px solid var(--line);
    padding: 10px;
}
.developer-create > summary {
    cursor: pointer;
    color: #fff;
    background: var(--green);
    padding: 7px 12px;
    width: fit-content;
    font-weight: 600;
}
.developer-create-form,
.developer-create-form label,
.developer-migration-form {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}
.developer-migration {
    border: 1px solid #b57724;
    padding: 12px;
    margin-top: 12px;
}
.developer-migration pre {
    max-height: 280px;
    overflow: auto;
    background: #090909;
    color: #f8f8f2;
    padding: 10px;
}
.developer-sidebar {
    position: sticky;
    top: 0;
    max-height: 75vh;
    overflow: auto;
    padding-right: 8px;
}
.developer-sidebar h2 {
    font-size: 13px;
    margin: 14px 0 8px;
}
.developer-sidebar button {
    display: block;
    width: 100%;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
}
.developer-sections {
    display: grid;
    gap: 4px;
}
.developer-sections button[aria-current=location] {
    border-left: 4px solid #ffad42;
    font-weight: 700;
}
.developer-form,
.developer-preview-form {
    display: grid;
    gap: 12px;
    margin: 14px 0;
}
.developer-form label,
.developer-preview-form label {
    display: grid;
    gap: 6px;
}
.developer-source,
.developer-preview-form textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--line);
    font: 13px/1.5 Consolas, monospace;
    resize: vertical;
}
.developer-preview {
    overflow: auto;
    max-height: 450px;
    white-space: pre-wrap;
}
/* Identical metrics keep the editable textarea aligned with its noninteractive color mirror. */
html .developer-code-editor {
    display: block;
    position: relative;
    background: #090909;
    color-scheme: dark;
}
html .developer-code-editor .developer-source,
html .developer-code-editor .developer-highlight {
    margin: 0;
    padding: 10px;
    border: 1px solid #617385;
    border-radius: 0;
    font: 13px/1.5 Consolas, monospace;
    font-variant-ligatures: none;
    letter-spacing: normal;
    text-align: left;
    tab-size: 4;
    white-space: pre;
    overflow-wrap: normal;
    word-break: normal;
}
html .developer-code-editor .developer-source {
    display: block;
    position: relative;
    width: 100%;
    min-height: 200px;
    background: #090909;
    color: #f8f8f2;
    caret-color: #fff;
    overflow: auto;
}
html .developer-code-editor .developer-highlight {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    color: #f8f8f2;
    background: #090909;
}
html .developer-code-editor.is-highlighted .developer-source {
    color: transparent;
    background: transparent;
    -webkit-text-fill-color: transparent;
}
html .developer-code-editor .developer-source::selection {
    color: #fff;
    -webkit-text-fill-color: #fff;
    background: #264f78;
}
.developer-highlight .code-group {
    color: #ffad42;
}
.developer-highlight .code-key {
    color: #ff6969;
}
.developer-highlight .code-value {
    color: #f8f8f2;
}
.developer-highlight .code-comment {
    color: #a0a0a0;
}
@media (max-width: 720px) {
    .developer-layout {
        grid-template-columns: 135px minmax(0, 1fr);
        gap: 10px;
    }
    .developer-editor {
        padding: 8px;
    }
}
@media (forced-colors: active) {
    html .developer-code-editor.is-highlighted .developer-source {
        color: CanvasText;
        -webkit-text-fill-color: CanvasText;
    }
    .developer-highlight {
        visibility: hidden;
    }
}
.login-card > .theme-choice {
    margin-top: 14px;
}
.login-remember-note {
    color: var(--muted);
    font-size: 12px;
}
html[data-theme=dark] {
    color-scheme: dark;
    color: #e0e8ef;
    background: #101820;
    --green: #347c5c;
    --line: #43515e;
    --muted: #b5c1cb;
    --surface: #25313c;
    --selection: #29483d;
}
html[data-theme=dark] body,
html[data-theme=dark] #workspace {
    background: #101820;
    color: #e0e8ef;
}
html[data-theme=dark] :is(.topbar,.tabs,.statusbar,.page-heading,.search-toolbar,.form-footer,.pagination,.login-card,.dashboard-box,.form-section,.detail-section,.card,.kanban-column,.welcome-note,.entity-tabs,.related-tabs,.developer-editor) {
    background: #1c2833;
    color: #e0e8ef;
    border-color: var(--line);
}
html[data-theme=dark] :is(.tab-panel,.results,.table-wrap,.entity-list,.record-form,.field-grid,.detail-view,.dashboard,.tab,.empty-state,.child-grid-wrap) {
    background: #16222c;
    color: #e0e8ef;
    border-color: var(--line);
}
html[data-theme=dark] :is(input,select,textarea,button) {
    color: #e0e8ef;
    background: #263746;
    border-color: #617385;
}
html[data-theme=dark] button:hover {
    background: #354b5d;
}
html[data-theme=dark] button.primary {
    background: #347c5c;
    color: #fff;
}
html[data-theme=dark] .tab[aria-selected=true],
html[data-theme=dark] .nav-item.active {
    background: #29483d;
    color: #eef8f2;
}
html[data-theme=dark] :is(th,thead,.child-list-toolbar) {
    background: #293b49;
    color: #e0e8ef;
}
html[data-theme=dark] td {
    border-color: var(--line);
}
html[data-theme=dark] tbody tr:nth-child(even) {
    background: #1d2c37;
}
html[data-theme=dark] tbody tr:hover {
    background: #29483d;
}
html[data-theme=dark] :is(.record-link,.breadcrumb,.lookup-status,.search-hint,.field small,.page-heading p,.empty-state p,.welcome p) {
    color: #b9d7ef;
}
html[data-theme=dark] :is(.form-error,.danger) {
    color: #ffb6b6;
}
html[data-theme=dark] :is(.kpi-tile,.chart-card,.chart-data,.chart-note,.dashboard-chart) {
    color: #e0e8ef;
    background: #263746;
    border-color: var(--line);
}
html[data-theme=dark] .report-paper,
html[data-theme=dark] .report-paper :is(th,td,button) {
    color: #202b35;
    background: #fff;
}
@media print {
    html[data-theme=dark],
    html[data-theme=dark] body {
        color: #000;
        background: #fff;
    }
}
* {
    box-sizing: border-box;
}
body {
    margin: 0;
}
button,
input,
select {
    font: inherit;
}
button,
a,
input,
select {
    outline-offset: 1px;
}
button {
    min-height: var(--control-height);
    padding: 3px 10px;
    border: 1px solid #aab5bf;
    border-radius: 2px;
    background: #f8f9fa;
    color: #263744;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}
button:hover {
    background: #e2e8ed;
    border-color: #7b8c9b;
}
button:active {
    background: #d1dbe3;
}
button:disabled {
    opacity: .55;
    cursor: wait;
}
button:focus-visible,
a:focus-visible {
    outline: 2px solid #24658f;
}
button.primary {
    background: var(--green);
    color: #fff;
    border-color: #154b33;
}
button.primary:hover {
    background: #174f36;
}
a {
    color: inherit;
}
input,
select {
    min-width: 0;
    height: var(--control-height);
    padding: 3px 6px;
    border: 1px solid #aab5bf;
    border-radius: 1px;
    background: #fff;
    color: #16252f;
}
input:focus,
select:focus {
    border-color: #24658f;
    outline: 1px solid #24658f;
}
input[type=checkbox] {
    width: 14px;
    height: 14px;
    margin: 0;
    accent-color: var(--green);
}
input::placeholder {
    color: #677785;
    opacity: 1;
}
[hidden],
.tab-panel[hidden],
#welcome[hidden] {
    display: none !important;
}

/* The shell stays mounted; the active document owns its scrolling. */
.app-shell {
    display: flex;
    height: 100dvh;
    overflow: hidden;
}
.sidebar {
    width: var(--sidebar-width);
    flex: 0 0 var(--sidebar-width);
    display: flex;
    flex-direction: column;
    border-right: 1px solid #9eabb6;
    background: #e8edf1;
}
.brand {
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 36px;
    padding: 5px 9px;
    border-bottom: 1px solid var(--line);
    background: #d8e0e6;
    font-size: 15px;
    font-weight: 650;
    text-decoration: none;
}
.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 23px;
    height: 23px;
    border: 1px solid #174b33;
    background: var(--green);
    color: white;
    font-size: 15px;
    font-weight: 700;
}
.brand-sub {
    margin-left: auto;
    font-size: 10px;
    color: #536373;
    font-weight: 500;
}
.nav-caption {
    padding: 7px 9px 5px;
    font-size: 11px;
    font-weight: 650;
    color: #455767;
    border-bottom: 1px solid #c9d1d8;
}
.sidebar nav {
    padding: 3px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    min-height: 29px;
    padding: 4px 7px;
    margin: 1px 0;
    text-align: left;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 1px;
}
.nav-item.active {
    background: var(--selection);
    border-color: #8fab98;
    color: #164d31;
    font-weight: 650;
}
.nav-icon {
    font-size: 14px;
    color: #476557;
}
.nav-arrow {
    margin-left: auto;
}
.sidebar-bottom {
    margin-top: auto;
    padding: 7px;
    border-top: 1px solid var(--line);
    font-size: 11px;
    color: var(--muted);
}
.sidebar-bottom small {
    display: block;
    margin-top: 3px;
    font-size: 10px;
}
.live-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-right: 4px;
    border-radius: 50%;
    background: #318050;
}
.main-shell {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 0 0 36px;
    gap: 10px;
    padding: 3px 9px;
    border-bottom: 1px solid var(--line);
    background: #e8edf1;
    font-size: 12px;
}
.breadcrumb {
    color: #566776;
}
.breadcrumb-divider {
    margin: 0 7px;
    color: #7d8b97;
}
.topbar strong {
    font-weight: 600;
}
.account {
    display: flex;
    align-items: center;
    gap: 10px;
}
.quiet {
    padding: 2px 7px;
    min-height: 25px;
    background: transparent;
}
.tabs {
    display: flex;
    align-items: stretch;
    flex: 0 0 30px;
    min-height: 30px;
    gap: 2px;
    padding: 3px 4px 0;
    border-bottom: 1px solid #98a7b3;
    background: #d8e0e6;
    overflow-x: auto;
}
.tab {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    min-width: 100px;
    max-width: 260px;
    border: 1px solid #a9b5bf;
    border-bottom: 0;
    border-radius: 2px 2px 0 0;
    background: #e5eaee;
}
.tab[aria-selected=true] {
    background: #fff;
    border-color: #7c9285;
    box-shadow: inset 0 2px var(--green);
}
.tab-label {
    flex: 1;
    min-width: 0;
    min-height: 25px;
    padding: 3px 8px;
    border: 0;
    background: transparent;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tab-close {
    min-height: 22px;
    padding: 0 6px;
    margin-right: 2px;
    border: 0;
    background: transparent;
    font-size: 15px;
    color: #576775;
}
#workspace {
    position: relative;
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: #fff;
}
.tab-panel {
    height: 100%;
    width: 100%;
    padding: 7px;
    overflow: auto;
    scrollbar-gutter: stable;
}
.statusbar {
    display: flex;
    justify-content: space-between;
    flex: 0 0 23px;
    align-items: center;
    gap: 8px;
    padding: 2px 8px;
    border-top: 1px solid #aab6c0;
    background: #e4e9ed;
    color: #465968;
    font-size: 11px;
}
.statusbar > span + span {
    border-left: 1px solid #bcc7cf;
    padding-left: 9px;
}

/* Compact document commands and search controls. */
.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 37px;
    margin: 0 0 6px;
    padding: 4px 7px;
    border: 1px solid var(--line);
    background: var(--surface);
}
.page-heading h1 {
    display: inline;
    margin: 0;
    font-size: 16px;
    line-height: 1.3;
    font-weight: 650;
    letter-spacing: 0;
    overflow-wrap: anywhere;
}
.page-heading .eyebrow {
    display: none;
}
.page-heading p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 12px;
}
.button-group {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.search-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 5px;
    border: 1px solid var(--line);
    background: #edf0f3;
}
.search-label {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1 1 230px;
    max-width: 520px;
}
.search-label > span {
    position: absolute;
    left: 7px;
    font-size: 17px;
    color: #617383;
}
.search-label input {
    width: 100%;
    padding-left: 26px;
    font-size: 12px;
}
.deleted-filter {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0 4px;
    font-size: 12px;
    white-space: nowrap;
}
.search-hint {
    margin-left: auto;
    font-size: 11px;
    color: #5a6b78;
}
.view-control select {
    height: 28px;
    padding: 3px 5px;
    font-size: 12px;
}
.results {
    min-height: 0;
    border: 1px solid var(--line);
    border-top: 0;
    background: #fff;
}
.entity-list {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}
.entity-list > .page-heading,
.entity-list > .search-toolbar {
    flex-shrink: 0;
}
.entity-list > .results {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: auto;
}
.results > .table-wrap {
    flex: 1;
    min-height: 0;
}
.results > .pagination {
    flex-shrink: 0;
}
.empty-state {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 10px;
    color: #526574;
}
.empty-icon {
    display: inline-block;
    font-size: 21px;
    line-height: 1;
    color: #657d6e;
}
.empty-state p {
    margin: 0;
    font-size: 12px;
}
.table-wrap {
    overflow: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 13px;
}
th {
    position: sticky;
    top: 0;
    z-index: 1;
    height: 27px;
    padding: 4px 7px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid #9eacb8;
    background: #e4e9ed;
    color: #2f4352;
    font-size: 12px;
    font-weight: 650;
    white-space: nowrap;
}
td {
    height: 28px;
    padding: 3px 7px;
    border-right: 1px solid #ced5dc;
    border-bottom: 1px solid #d4dbe1;
    max-width: 300px;
    overflow-wrap: anywhere;
    vertical-align: middle;
}
th:last-child,
td:last-child {
    border-right: 0;
}
tbody tr:nth-child(even) {
    background: #f3f6f8;
}
tbody tr:hover {
    background: #e2edf5;
}
.row-actions {
    width: 1%;
    white-space: nowrap;
}
button.record-link {
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #175b91;
    text-align: left;
    white-space: normal;
    text-decoration: underline;
    text-underline-offset: 2px;
}
button.record-link:hover,
button.record-link:focus-visible {
    background: transparent;
    text-decoration: underline;
}
.row-actions button {
    min-height: 22px;
    padding: 1px 6px;
    margin-right: 3px;
    border: 1px solid #b7c2cb;
    background: #f8fafb;
    font-size: 12px;
}
.danger {
    color: #a02f2f;
}
.chip {
    display: inline-block;
    padding: 0 5px;
    border: 1px solid #afc6b6;
    border-radius: 2px;
    background: #e7f0e9;
    color: #29573b;
    font-size: 12px;
    line-height: 18px;
}
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 31px;
    padding: 3px 6px;
    border-top: 1px solid var(--line);
    background: var(--surface);
    color: #465968;
    font-size: 12px;
}
.pagination button {
    min-height: 24px;
    padding: 2px 7px;
    margin-left: 4px;
    font-size: 12px;
}

/* Field groups use the document width with compact label/control spacing. */
.record-form .page-heading {
    position: sticky;
    top: -7px;
    z-index: 2;
}
.form-section {
    min-width: 0;
    margin: 0 0 8px;
    padding: 7px 8px 9px;
    border: 1px solid #aebbc5;
    border-radius: 0;
    background: #f7f9fa;
}
.form-section legend {
    padding: 0 5px;
    color: #344e60;
    font-size: 12px;
    font-weight: 650;
}
.field-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
    gap: 8px 12px;
}
.field {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 3px;
    font-size: 12px;
}
.field > span,
.lookup label > span {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 5px;
}
.field small {
    color: #5a6c7a;
    font-size: 10px;
    font-weight: 400;
}
.field input,
.field select {
    width: 100%;
    font-size: 13px;
}
.lookup label {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 3px;
}
.lookup-choice {
    margin-top: 0;
}
.lookup-status {
    line-height: 1.2;
}
.form-footer {
    padding: 2px 3px 6px;
    color: #536776;
    font-size: 11px;
}
.form-error {
    color: #a02f2f;
    line-height: 1.4;
}
.form-error:not(:empty) {
    padding: 6px 8px;
    margin: 0 0 6px;
    border: 1px solid #d29b93;
    background: #fff0ed;
}
.detail-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--line);
    border-left: 1px solid var(--line);
    background: white;
}
.detail-grid > div {
    display: grid;
    grid-template-columns: minmax(80px, 40%) minmax(0, 1fr);
    min-width: 0;
    min-height: 31px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}
.detail-grid dt {
    margin: 0;
    padding: 5px 6px;
    border-right: 1px solid #d4dbe1;
    background: #eef2f5;
    font-size: 12px;
    color: #465b6a;
}
.detail-grid dd {
    min-width: 0;
    margin: 0;
    padding: 5px 6px;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    font-size: 13px;
}
.related-section {
    margin-top: 8px;
    padding: 7px;
    border: 1px solid var(--line);
    background: #f1f4f6;
}
.related-section h2 {
    display: inline;
    margin: 0 10px 0 0;
    font-size: 13px;
}
.related-section p {
    margin: 0 0 5px;
    color: var(--muted);
    font-size: 11px;
}
.related-section button {
    margin-right: 3px;
    font-size: 12px;
}
.result-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 7px;
    padding: 7px;
}
.result-card {
    min-width: 0;
    padding: 7px;
    border: 1px solid #b9c5ce;
    background: #fafbfc;
}
.result-card dl {
    margin: 0 0 5px;
}
.result-card dl > div {
    display: grid;
    grid-template-columns: 90px minmax(0, 1fr);
    gap: 6px;
    padding: 3px 0;
    border-bottom: 1px solid #dde3e8;
}
.result-card dt {
    color: #536776;
    font-size: 11px;
}
.result-card dd {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
    font-size: 12px;
}
.result-card dl > div:first-child dd {
    font-weight: 650;
}
.kanban {
    display: flex;
    gap: 7px;
    padding: 7px;
    overflow: auto;
}
.kanban-column {
    flex: 1;
    min-width: 235px;
    border: 1px solid var(--line);
    background: #eaf0f3;
}
.kanban-column h2 {
    margin: 0;
    padding: 5px 7px;
    border-bottom: 1px solid var(--line);
    background: #dce5eb;
    color: #344f60;
    font-size: 12px;
}
.kanban-column .result-cards {
    display: grid;
    grid-template-columns: 1fr;
    padding: 5px;
}
.kanban-column .pagination {
    display: none;
}

/* Start center uses the same panels and command sizing. */
.welcome {
    height: 100%;
    overflow: auto;
    padding: 10px;
    background: #edf1f4;
}
.welcome .eyebrow {
    font-size: 11px;
    font-weight: 600;
    color: #526575;
}
.welcome h1 {
    margin: 4px 0;
    font-size: 18px;
    font-weight: 650;
}
.welcome > p {
    margin: 4px 0 10px;
    color: #4b6273;
    font-size: 12px;
}
.welcome-note {
    margin-top: 10px;
    color: #536776;
    font-size: 11px;
}
.htmx-request {
    opacity: .7;
}
.loading {
    padding: 15px;
    color: #536776;
}
.sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
}

/* Retain both existing navigation arrangements. */

/* Login remains a compact standard dialog. */
.login-page {
    display: grid;
    place-items: center;
    min-height: 100dvh;
    background: #e5ebef;
}
.login-card {
    width: min(370px, 95vw);
    padding: 23px;
    border: 1px solid #9eadb9;
    border-top: 3px solid var(--green);
    background: #f8fafb;
}
.login-card h1 {
    margin: 8px 0;
    font-size: 22px;
    font-weight: 600;
}
.login-card p {
    color: #516879;
}
.login-card .eyebrow {
    font-size: 11px;
    font-weight: 600;
}
.login-card form {
    margin-top: 18px;
}
.login-card label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
    font-size: 12px;
}
.login-card button {
    width: 100%;
    margin: 4px 0;
}
.login-card > small {
    color: #5b6e7c;
    font-size: 11px;
}

@media (min-width: 1650px) {
    .field-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}
@media (max-width: 1100px) {
    :root {
        --sidebar-width: 154px;
    }
    .field-grid,
    .detail-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .search-hint {
        display: none;
    }
}
@media (max-width: 720px) {
    .app-shell {
        flex-direction: column;
    }
    .sidebar {
        flex: 0 0 auto;
        flex-direction: row;
        width: auto;
        align-items: stretch;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }
    .brand {
        min-height: 34px;
        border-bottom: 0;
        padding: 4px 6px;
        font-size: 13px;
    }
    .brand-sub,
    .nav-caption,
    .sidebar-bottom,
    .nav-arrow {
        display: none;
    }
    .sidebar nav {
        display: flex;
    }
    .nav-item {
        width: auto;
        margin: 0 2px;
        padding: 3px 6px;
    }
    .topbar {
        flex: 0 0 auto;
        min-height: 32px;
        padding: 3px 6px;
    }
    .topbar > div:first-child {
        display: none;
    }
    .account {
        flex-wrap: wrap;
        width: 100%;
        justify-content: flex-end;
        gap: 7px;
    }
    .tab-panel {
        padding: 5px;
    }
    .record-form .page-heading {
        top: -5px;
    }
    .page-heading {
        flex-wrap: wrap;
        padding: 5px;
        gap: 5px;
    }
    .page-heading h1 {
        font-size: 15px;
    }
    .field-grid,
    .detail-grid {
        grid-template-columns: 1fr;
    }
    .search-label {
        max-width: none;
        flex-basis: 100%;
    }
    .statusbar > span:last-child {
        display: none;
    }
    .welcome {
        padding: 7px;
    }
}
/* Registered module navigation and transactional child drafts. */
.sidebar nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}
.nav-caption {
    margin: 5px 0 2px;
}
.nav-group {
    margin: 0;
}
.workflow-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 6px;
}
.workflow-toolbar:empty {
    display: none;
}
.child-row {
    border: 1px solid var(--line);
    margin-bottom: 6px;
    padding: 6px;
    background: #fff;
}
.child-row .field-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px 8px;
}
.child-row > button {
    margin-top: 5px;
}
.collection-hint {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 11px;
}
.warning {
    color: #9b3508;
    background: #fff0cd;
    padding: 0 4px;
}
.report-paper {
    max-width: 980px;
    padding: 20px;
    border: 1px solid var(--line);
    background: #fff;
    margin: 0 auto;
}
.report-paper > p {
    white-space: pre-wrap;
}
.report-total {
    text-align: right;
    font-weight: 700;
    font-size: 16px;
}
.pdf-help {
    margin: 0 0 6px;
    padding: 6px;
    border: 1px solid #b9cbd8;
    background: #edf4fa;
    font-size: 12px;
}
.otp-status {
    color: #526574;
    font-size: 12px;
}
@media (max-width: 1100px) {
    .child-row .field-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media print {
    .sidebar,
    .topbar,
    .tabs,
    .statusbar,
    .document-report > .page-heading,
    .pdf-help {
        display: none !important;
    }
    .app-shell,
    .main-shell,
    #workspace,
    .tab-panel {
        display: block;
        height: auto;
        overflow: visible;
        margin: 0;
        padding: 0;
    }
    .tab-panel[hidden],
    #welcome {
        display: none !important;
    }
    .report-paper {
        border: 0;
        padding: 0;
        max-width: none;
    }
    .report-paper thead {
        display: table-header-group;
    }
    .report-paper tr {
        break-inside: avoid;
    }
    .report-paper th {
        position: static;
    }
    th {
        position: static;
    }
    tr {
        break-inside: avoid;
    }
}
/* Global discovery stays in the application bar. */
.topbar {
    overflow: visible;
    z-index: 5;
}
.global-search {
    position: relative;
    flex: 1;
    min-width: 160px;
    max-width: 560px;
    margin: 0 14px;
}
.global-search-label {
    display: block;
}
.global-search input {
    width: 100%;
    height: 27px;
}
.global-search-results {
    position: absolute;
    top: calc(100% + 3px);
    left: 0;
    right: 0;
    z-index: 30;
    max-height: min(65dvh, 560px);
    overflow: auto;
    border: 1px solid #8d9daa;
    background: #fff;
    box-shadow: 0 3px 8px #23374624;
}
.global-matches section {
    border-bottom: 1px solid var(--line);
}
.global-matches h2 {
    margin: 0;
    padding: 4px 7px;
    font-size: 11px;
    background: #e9eef2;
    color: #526575;
}
.global-matches button {
    display: block;
    width: 100%;
    padding: 5px 8px;
    text-align: left;
    white-space: normal;
    border: 0;
    border-radius: 0;
    background: #fff;
}
.global-matches button:hover,
.global-matches button:focus {
    background: #e3edf5;
}
.global-matches > p {
    margin: 0;
    padding: 5px 7px;
    color: var(--muted);
    font-size: 10px;
}
.record-detail {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}
.record-detail > .page-heading,
.record-detail > .workflow-toolbar {
    flex-shrink: 0;
}
.related-tabs {
    display: flex;
    flex-shrink: 0;
    gap: 2px;
    min-height: 32px;
    padding: 3px 3px 0;
    border: 1px solid var(--line);
    background: #e2e8ed;
    overflow-x: auto;
}
.related-tabs button {
    border-radius: 2px 2px 0 0;
    border-bottom: 0;
    padding: 3px 9px;
    background: #edf1f4;
}
.related-tabs button[aria-selected=true] {
    background: #fff;
    border-color: #7c9285;
    box-shadow: inset 0 2px var(--green);
}
.related-count {
    display: inline-block;
    min-width: 20px;
    margin-left: 4px;
    padding: 0 4px;
    border: 1px solid #bdc8d0;
    background: #dfe7ed;
    color: #344d5e;
    font-size: 11px;
    line-height: 17px;
    text-align: center;
}
[data-record-summary] {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding-top: 5px;
}
.related-panels {
    flex: 1;
    min-height: 0;
    padding-top: 5px;
}
.related-panel {
    height: 100%;
    min-height: 0;
    overflow: auto;
}
.related-panel .page-heading {
    min-height: 31px;
}
/* Invoice items use a column-aligned editable list. */
.child-grid-wrap {
    overflow: auto;
    max-height: 420px;
    border: 1px solid var(--line);
}
.child-grid {
    min-width: 1250px;
    table-layout: auto;
}
.child-grid .child-row {
    margin: 0;
    padding: 0;
    border: 0;
}
.child-grid td {
    padding: 2px 4px;
    min-width: 95px;
    height: 31px;
}
.child-grid .field {
    gap: 0;
}
.child-grid .field > span,
.child-grid .lookup label > span,
.child-grid .lookup-status {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
}
.child-grid input,
.child-grid select {
    height: 25px;
    padding: 2px 4px;
}
.child-grid input:disabled {
    color: #465d6b;
    background: #edf1f4;
    border-color: #d0d8df;
    opacity: 1;
}
.child-grid .child-description {
    min-width: 230px;
}
.child-grid .child-task_id {
    min-width: 245px;
}
.child-grid .lookup {
    flex-direction: row;
    align-items: center;
    gap: 3px;
}
.child-grid .lookup label {
    flex: 1;
    min-width: 90px;
}
.child-grid .lookup .lookup-choice {
    flex: 1.2;
}
.child-list-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 5px;
    font-size: 11px;
    color: var(--muted);
}
@media (max-width: 720px) {
    .topbar {
        flex-wrap: wrap;
    }
    .global-search {
        max-width: none;
        flex-basis: 100%;
        margin: 0;
        order: 2;
    }
    .account {
        justify-content: space-between;
    }
    .global-search-results {
        max-height: 55dvh;
    }
    .related-tabs button {
        padding: 3px 6px;
    }
}
@media print {
    .global-search,
    .related-tabs,
    .workflow-toolbar {
        display: none !important;
    }
}
.report-classic {
    font-family: Georgia, "Times New Roman", serif;
    border: 3px double #65727c;
}
.report-modern h1 {
    color: #216447;
    border-bottom: 3px solid #216447;
    padding-bottom: 8px;
}
.report-standard h1 {
    border-bottom: 1px solid var(--line);
    padding-bottom: 6px;
}
.report-qr {
    width: 120px;
    height: 120px;
    object-fit: contain;
}
/* Single sidebar navigation with native keyboard-accessible group disclosure. */
.nav-caption {
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    list-style: none;
    margin: 2px 0;
    padding: 6px 7px;
    background: #dce4ea;
    border: 1px solid #c0cbd4;
    font-size: 11px;
    user-select: none;
}
.nav-caption::-webkit-details-marker {
    display: none;
}
.nav-caption:hover {
    background: #d0dce5;
}
.nav-caption:focus-visible {
    outline: 2px solid #24658f;
    outline-offset: -2px;
}
.group-chevron {
    width: 6px;
    height: 6px;
    border-right: 1.5px solid #526574;
    border-bottom: 1.5px solid #526574;
    transform: rotate(-45deg);
    margin-right: 2px;
}
.nav-group[open] > .nav-caption .group-chevron {
    transform: rotate(45deg);
}
.nav-group-items {
    padding: 1px 0 4px 5px;
}
.nav-icon {
    width: 14px;
    height: 14px;
    flex: 0 0 14px;
}
.nav-item {
    white-space: normal;
    line-height: 1.25;
}
.nav-title {
    flex: 1;
    min-width: 0;
}
.nav-count {
    flex-shrink: 0;
    min-width: 22px;
    padding: 0 4px;
    border: 1px solid #bdc8d0;
    border-radius: 2px;
    background: #e7edf1;
    color: #344d5e;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    line-height: 17px;
    text-align: right;
}

/* Action workspace: compact colored KPIs, static SVG bar charts and lists. */
.dashboard {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.dashboard > .page-heading {
    margin-bottom: 0;
}
.dashboard .button-group {
    align-items: center;
}
.dashboard .button-group label {
    display: flex;
    align-items: center;
    gap: 4px;
}
.kpi-row {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 7px;
}
button.kpi-tile {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    gap: 5px;
    min-height: 110px;
    padding: 9px 10px;
    border: 1px solid rgba(0, 0, 0, .2);
    border-radius: 2px;
    color: #fff;
    text-align: left;
    white-space: normal;
    box-shadow: inset 0 1px rgba(255, 255, 255, .18);
}
button.kpi-tile:hover {
    filter: brightness(1.1);
}
button.kpi-tile:focus-visible {
    outline: 3px solid #172f45;
    outline-offset: 2px;
}
.kpi-title {
    font-size: 13px;
    font-weight: 650;
}
.kpi-tile strong {
    font-size: clamp(17px, 1.55vw, 24px);
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}
.kpi-tile > span:last-of-type {
    font-size: 11px;
}
.kpi-tile small {
    font-size: 10px;
    opacity: .95;
}
.kpi-outstanding {
    background: #985019;
}
.kpi-tasks {
    background: #245e9b;
}
.kpi-leads {
    background: #7146a1;
}
.kpi-sales {
    background: #19704e;
}
.kpi-expenses {
    background: #9a3d56;
}
.dashboard-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
}
.chart-columns {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
}
.dashboard-box {
    min-width: 0;
    border: 1px solid var(--line);
    background: #fff;
}
.dashboard-box h2 {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    margin: 0;
    min-height: 31px;
    padding: 4px 7px;
    border-bottom: 1px solid var(--line);
    background: #e8eef2;
    font-size: 13px;
    font-weight: 650;
}
.dashboard-box h2 small {
    color: #526574;
    font-weight: 400;
    font-size: 11px;
}
.dashboard-box h2 button {
    margin-left: auto;
    min-height: 22px;
    padding: 1px 6px;
    font-size: 11px;
}
.dashboard-figure {
    margin: 0;
    padding: 5px;
    overflow-x: auto;
}
.dashboard-svg {
    display: block;
    width: 100%;
    min-width: 340px;
    height: auto;
}
.chart-gridline {
    stroke: #d6dfe6;
    stroke-width: 1;
}
.chart-axis {
    fill: #526574;
    font:
        11px "Segoe UI",
        sans-serif;
    font-variant-numeric: tabular-nums;
}
.chart-label {
    fill: #2b3c49;
    font:
        13px "Segoe UI",
        sans-serif;
}
.chart-year {
    fill: #647687;
    font:
        11px "Segoe UI",
        sans-serif;
}
.chart-value {
    fill: #2b3c49;
    font:
        12px "Segoe UI",
        sans-serif;
    font-variant-numeric: tabular-nums;
}
.chart-bar {
    fill: #358461;
}
.chart-parties .chart-bar {
    fill: #487ca8;
}
.chart-opportunities .chart-bar {
    fill: #8052ae;
}
.chart-bar:hover {
    opacity: .8;
}
.chart-note {
    margin: 5px 7px 0;
    color: #526574;
    font-size: 11px;
}
.chart-empty {
    margin: 0 5px 6px;
    padding: 6px;
    border: 1px solid #d6dfe6;
    background: #f5f7f9;
    color: #526574;
    font-size: 12px;
}
.chart-data {
    padding: 3px;
    font-size: 11px;
}
.chart-data summary {
    cursor: pointer;
    color: #175b91;
}
.chart-data th {
    position: static;
}
.chart-data td,
.chart-data th {
    font-size: 11px;
}
.dashboard-table td {
    max-width: 220px;
    font-size: 12px;
}
.action-columns .dashboard-table {
    max-height: 355px;
    overflow: auto;
}
.due-group th {
    position: static;
    background: #f0e8db;
    color: #654a24;
    font-size: 11px;
    white-space: normal;
}
.dashboard-empty {
    padding: 10px;
    color: var(--muted);
}
.offline-retry {
    display: inline-block;
    padding: 5px 10px;
    background: var(--green);
    color: #fff;
}
.is-offline .live-dot {
    background: #b85821;
}
@media (max-width: 1100px) {
    .kpi-row {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .action-columns {
        grid-template-columns: minmax(0, 1fr);
    }
    .chart-columns {
        grid-template-columns: minmax(0, 1fr);
    }
}
@media (max-width: 600px) {
    .kpi-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .dashboard > .page-heading {
        align-items: flex-start;
        flex-direction: column;
    }
    .dashboard > .page-heading .button-group {
        flex-wrap: wrap;
    }
}
#toggle-sidebar {
    min-height: 25px;
    padding: 2px 7px;
}
body.sidebar-hidden .sidebar {
    display: none;
}
@media (max-width: 720px) {
    .app-shell {
        flex-direction: row;
    }
    .sidebar {
        width: 148px;
        flex: 0 0 148px;
        flex-direction: column;
        max-height: none;
        border-right: 1px solid var(--line);
        border-bottom: 0;
    }
    .sidebar nav {
        display: block;
        overflow-x: hidden;
        overflow-y: auto;
    }
    .nav-caption {
        display: flex;
    }
    .nav-group {
        width: 100%;
    }
    .nav-item {
        width: 100%;
        margin: 1px 0;
    }
    .sidebar-bottom {
        display: block;
    }
    .topbar > #toggle-sidebar {
        display: block;
    }
    .account {
        width: auto;
        flex: 1;
        justify-content: flex-end;
    }
}
/* Enter opens full search results as a persistent workspace document. */
.search-workspace {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}
.search-workspace > .page-heading {
    flex-shrink: 0;
}
.search-workspace > .page-heading > span {
    color: var(--muted);
    font-size: 12px;
}
.search-entity-panels {
    flex: 1;
    min-height: 0;
    padding-top: 5px;
}
.search-entity-panel {
    height: 100%;
    min-height: 0;
    overflow: auto;
}
.search-entity-panel .entity-list > .page-heading {
    min-height: 31px;
}
mark {
    background: #ffe285;
    color: #312500;
    padding: 0 1px;
    border-radius: 1px;
}
@media (max-width: 720px) {
    .topbar > div:first-of-type {
        display: none;
    }
}
