﻿/* Presentation-only enterprise design layer. Business bindings remain in the original markup and scripts. */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-width: 280px;
    font-size: 14px;
    background: var(--ui-canvas);
    scrollbar-color: #9aa7b3 transparent;
    scrollbar-width: thin;
}

body {
    min-width: 280px;
    margin: 0;
    color: var(--ui-text);
    background: var(--ui-canvas);
    font-family: var(--ui-font-sans);
    font-size: 14px;
    line-height: 1.45;
    letter-spacing: 0;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
    color: inherit;
    font: inherit;
    letter-spacing: 0;
}

button,
select,
summary {
    cursor: pointer;
}

a {
    color: var(--ui-link);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

a:hover {
    color: var(--ui-link-hover);
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

svg.lucide {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    stroke-width: 1.8;
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 3px solid var(--ui-focus);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px var(--ui-focus-ring);
}

.desktop-body :where(a, button, input, select, textarea, summary, [tabindex]):focus-visible,
.login-body :where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 3px solid var(--ui-focus) !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 4px var(--ui-focus-ring) !important;
}

::selection {
    color: var(--ui-text-strong);
    background: var(--ui-selection);
}

.skip-link {
    z-index: calc(var(--ui-z-progress) + 10);
    top: 10px;
    left: 12px;
    min-height: var(--ui-touch-target);
    border: 0;
    border-radius: var(--ui-radius-md);
    color: var(--ui-text-inverse);
    background: var(--ui-shell);
    font-weight: 700;
    padding: 10px 14px;
    box-shadow: var(--ui-shadow-popover);
}

.skip-link:focus,
.skip-link:focus-visible {
    outline-color: var(--ui-brand);
}

.dashboard-column-chooser > summary {
    min-height: var(--ui-touch-target);
}

.shell-progress {
    z-index: var(--ui-z-progress);
    height: 3px;
    background: var(--ui-brand-tint);
}

.shell-progress span {
    background: var(--ui-brand);
}

/* Login */

.login-body {
    min-height: 100dvh;
    overflow: auto;
    background: var(--ui-canvas);
}

.login-shell {
    min-height: 100dvh;
    place-items: center;
    padding: clamp(20px, 5vw, 64px);
}

.login-surface {
    width: min(468px, 100%);
}

.login-panel {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius-lg);
    background: var(--ui-surface);
    padding: 38px 40px 40px;
    box-shadow: 0 24px 64px rgb(21 29 37 / 13%);
}

.login-panel::before {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    margin-bottom: 24px;
    border-radius: var(--ui-radius-md);
    color: var(--ui-text-inverse);
    background: var(--ui-brand);
    content: "T";
    font-size: 19px;
    font-weight: 700;
}

.login-panel h1 {
    color: var(--ui-text-strong);
    font-size: 24px;
    font-weight: 700;
    line-height: 32px;
}

.muted,
.module-head p,
.section-title > span,
.section-title p {
    color: var(--ui-text-muted);
}

.login-form {
    gap: 7px;
    margin-top: 28px;
}

.login-form label {
    margin-top: 10px;
    color: var(--ui-text);
    font-size: 13px;
    font-weight: 600;
}

.login-form input,
.login-form select {
    min-height: 44px;
    border: 1px solid var(--ui-border-control);
    border-radius: var(--ui-radius-md);
    padding: 9px 11px;
    background: var(--ui-surface);
}

.login-form button[type="submit"] {
    min-height: 44px;
    margin-top: 16px;
    border: 1px solid var(--ui-brand);
    border-radius: var(--ui-radius-md);
    color: var(--ui-text-inverse);
    background: var(--ui-brand);
    font-weight: 700;
    transition: background var(--ui-duration-fast) var(--ui-ease), border-color var(--ui-duration-fast) var(--ui-ease);
}

.login-form button[type="submit"]:hover {
    border-color: var(--ui-brand-hover);
    background: var(--ui-brand-hover);
}

.validation-summary,
.field-validation-error {
    color: var(--ui-danger);
}

.validation-summary:not(:empty) {
    margin-bottom: 8px;
    border: 1px solid var(--ui-danger-border);
    border-radius: var(--ui-radius-md);
    background: var(--ui-danger-bg);
    padding: 12px 14px;
}

/* Application shell */

.desktop-body {
    color: var(--ui-text);
    background: var(--ui-canvas);
}

.desktop-frame {
    grid-template-columns: var(--ui-nav-width) minmax(0, 1fr);
    background: var(--ui-canvas);
}

.desktop-main {
    grid-column: 2;
    grid-template-rows: var(--ui-topbar-height) minmax(0, 1fr);
    background: var(--ui-canvas);
}

.side-menu {
    z-index: var(--ui-z-shell);
    width: var(--ui-nav-width);
    gap: 0;
    border-right: 1px solid var(--ui-shell-border);
    color: var(--ui-text-inverse);
    background: var(--ui-shell);
    padding: 0;
}

.side-logo {
    min-height: var(--ui-topbar-height);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 11px;
    color: var(--ui-text-inverse);
    padding: 0 18px;
}

.side-brand-mark,
.top-company-avatar {
    display: grid;
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: var(--ui-radius-md);
    color: var(--ui-text-inverse);
    background: var(--ui-brand);
    font-size: 15px;
    font-weight: 700;
}

.side-brand-copy,
.top-session-copy {
    min-width: 0;
    display: grid;
    gap: 1px;
    line-height: 1.2;
}

.side-brand-copy strong {
    font-size: var(--ui-font-size-md);
    font-weight: var(--ui-font-weight-bold);
}

.side-brand-copy small {
    color: var(--ui-text-inverse-muted);
    font-size: var(--ui-font-size-xs);
}

.top-bar {
    position: relative;
    z-index: 30;
    min-width: 0;
    gap: var(--ui-space-4);
    border-bottom: 1px solid var(--ui-border);
    color: var(--ui-text);
    background: rgb(255 255 255 / 96%);
    padding: 0 var(--ui-page-gutter);
    backdrop-filter: blur(14px);
}

.shell-menu-trigger {
    display: none;
}

.top-product-context {
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.top-module-label {
    color: var(--ui-brand);
    font-size: var(--ui-font-size-sm);
    font-weight: var(--ui-font-weight-bold);
}

.top-title {
    overflow: hidden;
    color: var(--ui-text-strong);
    font-size: var(--ui-font-size-md);
    font-weight: var(--ui-font-weight-semibold);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.top-session {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.top-company-avatar {
    color: var(--ui-brand);
    background: var(--ui-brand-tint);
    font-size: 12px;
}

.top-company {
    overflow: hidden;
    color: var(--ui-text-strong);
    font-size: var(--ui-font-size-base);
    font-weight: var(--ui-font-weight-semibold);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.top-context {
    margin: 0;
    overflow: hidden;
    color: var(--ui-text-muted);
    font-size: var(--ui-font-size-xs);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shell-navigation {
    z-index: calc(var(--ui-z-shell) + 1);
    inset: var(--ui-topbar-height) auto 0 0;
    width: var(--ui-nav-width);
}

.shell-navigation-content {
    gap: 0;
    color: var(--ui-text-inverse-muted);
    background: var(--ui-shell);
    padding: 12px 10px 16px;
}

.shell-navigation-mobile-head {
    display: none;
}

.side-nav-scroll {
    gap: 22px;
    padding: 12px 0;
    scrollbar-color: var(--ui-shell-control-border) transparent;
}

.side-nav-group {
    gap: 3px;
}

.side-section-label {
    min-height: 24px;
    align-items: center;
    color: var(--ui-shell-section);
    font-size: var(--ui-font-size-xs);
    font-weight: var(--ui-font-weight-bold);
    text-transform: uppercase;
    padding: 0 11px;
}

.side-link,
.shell-navigation-content .side-link {
    position: relative;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 11px;
    border: 0;
    border-radius: var(--ui-radius-md);
    color: var(--ui-shell-link);
    background: transparent;
    font-size: var(--ui-font-size-base);
    font-weight: var(--ui-font-weight-medium);
    padding: 0 11px;
    transition: color var(--ui-duration-fast) var(--ui-ease), background var(--ui-duration-fast) var(--ui-ease);
}

.side-link:hover,
.shell-navigation-content .side-link:hover {
    color: var(--ui-text-inverse);
    background: var(--ui-shell-hover);
}

.side-link.active,
.shell-navigation-content .side-link.active {
    color: var(--ui-shell-active);
    background: var(--ui-shell-selected);
    box-shadow: none;
    font-weight: var(--ui-font-weight-semibold);
}

.side-link.active::before {
    position: absolute;
    inset: 9px auto 9px -10px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--ui-shell-accent);
    content: "";
}

.side-link svg {
    width: 17px;
    height: 17px;
}

.side-signout {
    margin-top: auto;
    color: #e4b8b4;
}

.shell-nav-filter {
    margin-bottom: 8px;
    border: 1px solid #36434e;
    border-radius: var(--ui-radius-md);
    color: #dce5ec;
    background: var(--ui-shell-control);
}

.shell-nav-filter-summary {
    min-height: 40px;
    justify-content: flex-start;
    gap: 9px;
    font-size: 12px;
    font-weight: 600;
    padding: 0 10px;
}

.shell-nav-filter-summary::after {
    margin-left: auto;
}

.shell-nav-filter-body {
    gap: 8px;
    border-color: #3b4853;
    padding: 10px;
}

.shell-nav-filter input,
.shell-nav-filter select,
.shell-nav-filter button {
    min-height: 36px;
    border: 1px solid var(--ui-shell-control-border);
    border-radius: var(--ui-radius-sm);
}

.shell-nav-filter input,
.shell-nav-filter select {
    color: var(--ui-text-strong);
    background: var(--ui-surface);
}

.shell-nav-filter button {
    color: var(--ui-text-inverse);
    background: var(--ui-shell-control-hover);
}

.work-area {
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 24px var(--ui-page-gutter) 48px;
    background: var(--ui-canvas);
    scrollbar-gutter: stable;
    touch-action: pan-y;
}

.work-area > * {
    width: min(100%, var(--ui-content-max));
    margin-right: auto;
    margin-left: auto;
}

.desktop-footer {
    display: none;
}

/* Page headers and actions */

.module-head {
    min-height: 78px;
    display: flex;
    align-items: flex-start;
    gap: 24px;
    border: 0;
    border-bottom: 1px solid var(--ui-border);
    border-radius: 0;
    background: transparent;
    padding: 0 0 20px;
    box-shadow: none;
}

.module-head > div:first-child {
    flex: 1 1 340px;
}

.module-head h1 {
    margin: 0;
    color: var(--ui-text-strong);
    font-size: var(--ui-font-size-title);
    font-weight: var(--ui-font-weight-bold);
    line-height: var(--ui-line-height-title);
}

.module-head p {
    max-width: var(--ui-reading-max);
    margin: 4px 0 0;
    font-size: var(--ui-font-size-base);
    line-height: 20px;
}

.module-actions,
.toolbar-actions,
.entry-actions,
.split-actions,
.report-export-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.module-actions {
    max-width: min(62%, 820px);
    flex: 0 1 auto;
    overflow: visible;
    padding: 0;
}

.module-actions > :last-child {
    position: static;
    box-shadow: none;
}

.module-actions > .btn-primary-form:not(:last-child) {
    border-color: var(--ui-border-strong);
    color: var(--ui-text-strong);
    background: var(--ui-surface);
}

@media screen and (min-width: 1201px) {
    .sales-entry-head {
        position: sticky;
        z-index: var(--ui-z-sticky);
        top: calc(-1 * var(--ui-page-gutter));
        border-bottom-color: var(--ui-border-strong);
        background: var(--ui-canvas);
        padding-top: 8px;
        box-shadow: 0 12px 18px -18px rgb(11 17 23 / 45%);
    }
}

@media screen and (min-width: 480px) and (max-width: 1200px) {
    .work-area:has(.sales-entry-head) {
        padding-bottom: calc(88px + env(safe-area-inset-bottom)) !important;
    }

    .sales-entry-head .module-actions {
        position: fixed;
        z-index: var(--ui-z-sticky);
        right: var(--ui-page-gutter);
        bottom: max(8px, env(safe-area-inset-bottom));
        width: min(360px, calc(100vw - (2 * var(--ui-page-gutter))));
        max-width: none;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        border: 1px solid var(--ui-border);
        border-radius: var(--ui-radius-lg);
        background: color-mix(in srgb, var(--ui-surface) 96%, transparent);
        padding: 4px;
        box-shadow: var(--ui-shadow-popover);
        backdrop-filter: blur(14px);
    }

    .sales-entry-head .module-actions > * {
        width: 100%;
        min-width: 0;
        min-height: var(--ui-touch-target);
    }

    .sales-entry-head .ui-action-menu-content {
        top: auto;
        right: 0;
        bottom: calc(100% + 8px);
    }
}

.ui-action-menu {
    position: relative;
}

.ui-action-menu > summary {
    min-height: var(--ui-control-height);
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 1px solid var(--ui-border-strong);
    border-radius: var(--ui-radius-md);
    list-style: none;
    color: var(--ui-text-strong);
    background: var(--ui-surface);
    font-size: 13px;
    font-weight: 600;
    padding: 9px 14px;
}

.ui-action-menu > summary::-webkit-details-marker {
    display: none;
}

.ui-action-menu > summary::after {
    content: "";
}

.ui-action-menu-content {
    position: absolute;
    z-index: var(--ui-z-popover);
    top: calc(100% + 6px);
    right: 0;
    width: max-content;
    min-width: 190px;
    display: grid;
    overflow: hidden;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius-md);
    background: var(--ui-surface);
    padding: 6px;
    box-shadow: var(--ui-shadow-popover);
}

.ui-action-menu-content a,
.ui-action-menu-content button,
.ui-action-menu-content > span {
    min-height: 40px;
    display: flex;
    align-items: center;
    border: 0;
    border-radius: var(--ui-radius-sm);
    color: var(--ui-text);
    background: transparent;
    width: 100%;
    font-size: var(--ui-font-size-base);
    font-weight: var(--ui-font-weight-medium);
    padding: 8px 10px;
    text-decoration: none;
}

.ui-action-menu-content .danger-line {
    color: var(--ui-danger);
}

.ui-action-menu-content > .disabled,
.ui-action-menu-content > [disabled] {
    cursor: not-allowed;
    color: #8895a1;
    background: var(--ui-surface-muted);
}

.ui-action-menu-content a:hover,
.ui-action-menu-content button:hover {
    color: var(--ui-text-strong);
    background: var(--ui-surface-muted);
}

.reports-menu-content {
    max-height: min(68vh, 560px);
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    overflow-y: auto;
}

.btn-line,
.btn-primary-form,
.btn-danger-form,
.entry-actions button,
.search-row button,
.sales-item-picker button,
.purchase-item-picker button,
.report-filter-grid button,
.toolbar-actions button,
.toolbar-actions a,
.report-export-toolbar button,
.report-export-toolbar a {
    min-height: var(--ui-control-height);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid var(--ui-border-control);
    border-radius: var(--ui-radius-md);
    color: var(--ui-text-strong);
    background: var(--ui-surface);
    font-size: 13px;
    font-weight: 600;
    line-height: 18px;
    padding: 9px 14px;
    text-decoration: none;
    transition: border-color var(--ui-duration-fast) var(--ui-ease), background var(--ui-duration-fast) var(--ui-ease), color var(--ui-duration-fast) var(--ui-ease);
}

.btn-line:hover,
.toolbar-actions button:hover,
.toolbar-actions a:hover {
    border-color: #9eabb7;
    color: var(--ui-text-strong);
    background: var(--ui-surface-muted);
}

.btn-primary-form,
.entry-actions button:not(.btn-line):not(.danger-line):not(.danger-action),
.search-row button,
.sales-item-picker button,
.purchase-item-picker button,
.report-filter-grid button[type="submit"] {
    border-color: var(--ui-brand);
    color: var(--ui-text-inverse);
    background: var(--ui-brand);
}

.btn-primary-form:hover,
.entry-actions button:not(.btn-line):not(.danger-line):not(.danger-action):hover,
.search-row button:hover,
.sales-item-picker button:hover,
.purchase-item-picker button:hover,
.report-filter-grid button[type="submit"]:hover {
    border-color: var(--ui-brand-hover);
    color: var(--ui-text-inverse);
    background: var(--ui-brand-hover);
}

.danger-line,
.btn-danger-form,
.entry-actions .danger-action {
    border-color: var(--ui-danger);
    color: var(--ui-danger);
    background: var(--ui-surface);
}

.danger-line:hover,
.btn-danger-form:hover,
.entry-actions .danger-action:hover {
    border-color: var(--ui-danger);
    color: var(--ui-danger-hover);
    background: var(--ui-danger-bg);
}

.span-4 {
    grid-column: 1 / -1;
}

.check-fieldset {
    min-width: 0;
    margin: 0;
    border: 0;
    padding: 0;
}

.check-fieldset legend {
    margin-bottom: 8px;
    color: var(--ui-text);
    font-size: var(--ui-font-size-sm);
    font-weight: var(--ui-font-weight-semibold);
}

.whatsapp-line {
    border-color: var(--ui-success-border);
    color: var(--ui-success);
    background: var(--ui-surface);
}

:where(button, .btn-line, .btn-primary-form, .btn-danger-form)[disabled],
.btn-line.disabled,
[aria-disabled="true"] {
    cursor: not-allowed;
    opacity: 1;
    border-color: var(--ui-border);
    color: #8895a1;
    background: var(--ui-surface-muted);
    box-shadow: none;
}

/* Form and surface system */

.master-split {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    margin-top: 18px;
}

.entry-panel,
.grid-panel,
.work-panel,
.report-filter-panel,
.statement-wrap,
.settings-shell,
.accounts-shell,
.sales-shell,
.purchase-shell,
.inventory-shell,
.payroll-shell,
.gst-return-shell,
.reports-shell,
.masters-shell {
    min-width: 0;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius-lg);
    background: var(--ui-surface);
    box-shadow: var(--ui-shadow-sm);
}

.entry-panel,
.grid-panel,
.work-panel,
.report-filter-panel,
.settings-shell,
.accounts-shell,
.sales-shell,
.purchase-shell,
.inventory-shell,
.payroll-shell,
.gst-return-shell,
.reports-shell,
.masters-shell {
    padding: 18px;
}

.entry-panel,
.grid-panel {
    height: auto;
    max-height: none;
    overflow: visible;
}

.settings-shell,
.accounts-shell,
.sales-shell,
.purchase-shell,
.inventory-shell,
.payroll-shell,
.gst-return-shell,
.reports-shell,
.masters-shell {
    border: 0;
    background: transparent;
    padding: 0;
    box-shadow: none;
}

.accounts-shell > .work-panel,
.sales-shell > .work-panel,
.purchase-shell > .work-panel,
.inventory-shell > .work-panel,
.masters-shell > .work-panel,
.gst-return-shell > .work-panel,
.reports-shell > .work-panel {
    max-height: none;
    overflow: visible;
    scrollbar-gutter: auto;
}

.section-title,
.inline-title {
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--ui-divider);
    padding: 0 0 12px;
}

.section-title h2,
.inline-title h2,
.entry-panel h2,
.work-panel h2 {
    margin: 0;
    color: var(--ui-text-strong);
    font-size: 16px;
    font-weight: 600;
    line-height: 24px;
}

.form-grid,
.report-filter-grid {
    gap: 12px 14px;
}

.form-grid label,
.report-filter-grid label,
.search-row label,
.sales-item-picker label,
.purchase-item-picker label {
    min-width: 0;
    color: var(--ui-text);
    font-size: 12px;
    font-weight: 600;
    line-height: 18px;
    overflow-wrap: anywhere;
}

.form-grid input,
.form-grid select,
.form-grid textarea,
.report-filter-grid input,
.report-filter-grid select,
.search-row input,
.search-row select,
.sales-item-picker input,
.sales-item-picker select,
.purchase-item-picker input,
.purchase-item-picker select,
.data-grid input,
.data-grid select,
.data-grid textarea {
    min-width: 0;
    min-height: var(--ui-control-height);
    border: 1px solid var(--ui-border-control);
    border-radius: var(--ui-radius-md);
    color: var(--ui-text-strong);
    background: var(--ui-surface);
    padding: 8px 10px;
}

.form-grid textarea,
.data-grid textarea {
    min-height: 76px;
    resize: vertical;
}

.form-grid input[readonly],
.form-grid input:disabled,
.form-grid select:disabled,
.data-grid input:disabled,
.data-grid select:disabled {
    border-color: var(--ui-border);
    color: var(--ui-text-muted);
    background: var(--ui-surface-muted);
}

.form-grid :where(input, select, textarea)[aria-invalid="true"],
.form-grid :where(input, select, textarea).input-validation-error,
.login-form :where(input, select)[aria-invalid="true"] {
    border-color: var(--ui-danger);
    background: #fffafa;
}

.check-row,
.check-strip label {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--ui-text);
    font-size: 13px;
    font-weight: 500;
}

.check-row input[type="checkbox"],
.check-strip input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-height: 0;
    accent-color: var(--ui-brand);
}

.search-row {
    gap: 8px;
}

/* Feedback */

.message-bar,
.status-band,
.settings-status,
.shell-empty-state {
    min-height: 44px;
    margin-top: 14px;
    border: 1px solid var(--ui-info-border);
    border-radius: var(--ui-radius-md);
    color: var(--ui-info);
    background: var(--ui-info-bg);
    padding: 11px 14px;
    line-height: 20px;
}

.message-bar.success,
.status-band.ok,
.settings-status.ready {
    border-color: var(--ui-success-border);
    color: var(--ui-success);
    background: var(--ui-success-bg);
}

.message-bar.warning,
.status-band.warn,
.settings-status.warning {
    border-color: var(--ui-warning-border);
    color: var(--ui-warning);
    background: var(--ui-warning-bg);
}

.message-bar.error,
.status-band.error,
.shell-empty-state.offline {
    border-color: var(--ui-danger-border);
    color: var(--ui-danger);
    background: var(--ui-danger-bg);
}

.status-pill,
.table-status,
.settings-status-pill {
    min-height: 24px;
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-pill, 999px);
    color: var(--ui-text-muted);
    background: var(--ui-surface-muted);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
}

.status-pill.ok,
.table-status.ready,
.settings-status-pill.ok {
    border-color: var(--ui-success-border);
    color: var(--ui-success);
    background: var(--ui-success-bg);
}

.status-pill.warning,
.table-status.started {
    border-color: var(--ui-warning-border);
    color: var(--ui-warning);
    background: var(--ui-warning-bg);
}

.status-pill.error,
.status-pill.offline {
    border-color: var(--ui-danger-border);
    color: var(--ui-danger);
    background: var(--ui-danger-bg);
}

/* Data and metrics */

.data-grid-wrap,
.table-wrap,
.responsive-table-wrap {
    position: relative;
    min-width: 0;
    max-width: 100%;
    overflow: auto;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius-md);
    background: var(--ui-surface);
    scrollbar-color: #8f9ca8 var(--ui-surface-muted);
    scrollbar-width: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
}

.data-grid-wrap:focus-visible,
.table-wrap:focus-visible,
.responsive-table-wrap:focus-visible {
    outline-offset: 3px;
}

.data-grid,
.dashboard-module-grid,
.activity-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    color: var(--ui-text);
    background: var(--ui-surface);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.data-grid th,
.dashboard-module-grid th,
.activity-table th {
    position: sticky;
    z-index: 3;
    top: 0;
    min-height: var(--ui-table-row-compact);
    border: 0;
    border-right: 1px solid var(--ui-divider);
    border-bottom: 1px solid var(--ui-border-strong);
    color: var(--ui-text-muted);
    background: var(--ui-surface-subtle);
    font-size: 11px;
    font-weight: 700;
    line-height: 16px;
    text-transform: none;
    white-space: nowrap;
    padding: 9px 10px;
}

.data-grid td,
.dashboard-module-grid td,
.activity-table td {
    min-height: var(--ui-table-row);
    border: 0;
    border-right: 1px solid var(--ui-divider);
    border-bottom: 1px solid var(--ui-divider);
    background: var(--ui-surface);
    line-height: 18px;
    padding: 8px 10px;
    vertical-align: middle;
}

.data-grid tr:last-child td,
.activity-table tr:last-child td {
    border-bottom: 0;
}

.data-grid tbody tr:hover td,
.dashboard-module-grid tbody tr:hover td,
.activity-table tbody tr:hover td {
    background: #f8fafb;
}

.data-grid tr.selected td,
.dashboard-module-grid tr.selected td {
    background: var(--ui-brand-tint);
}

.data-grid .num,
.metric-card strong,
.metric-card .num,
.number {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.data-grid a,
.dashboard-module-grid a {
    color: var(--ui-link);
    font-weight: 600;
}

.data-grid input,
.data-grid select {
    min-height: 34px;
    border-color: var(--ui-border-strong);
    border-radius: var(--ui-radius-sm);
    padding: 5px 7px;
}

.metric-grid {
    gap: 0;
    overflow: hidden;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius-lg);
    background: var(--ui-surface);
}

.metric-card {
    min-width: 0;
    min-height: 104px;
    display: grid;
    align-content: center;
    gap: 4px;
    border: 0;
    border-right: 1px solid var(--ui-divider);
    border-radius: 0;
    background: transparent;
    padding: 16px 18px;
    box-shadow: none;
}

.metric-card:last-child {
    border-right: 0;
}

.metric-card > span {
    color: var(--ui-text-muted);
    font-size: 12px;
    font-weight: 500;
}

.metric-card strong {
    color: var(--ui-text-strong);
    font-size: 20px;
    font-weight: 600;
    line-height: 28px;
}

.metric-card small {
    color: var(--ui-text-soft);
    font-size: 11px;
}

/* Gateway and dashboard content */

.sales-action-grid,
.purchase-action-grid,
.inventory-action-grid,
.accounts-action-grid,
.gst-return-action-grid,
.reports-action-grid,
.masters-action-grid,
.payroll-action-grid {
    gap: 10px;
}

.sales-action,
.purchase-action,
.inventory-action,
.accounts-action,
.gst-return-action,
.reports-action,
.masters-action,
.payroll-action {
    min-height: 94px;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius-md);
    color: var(--ui-text);
    background: var(--ui-surface);
    padding: 14px 16px;
    box-shadow: none;
    transition: border-color var(--ui-duration-fast) var(--ui-ease), background var(--ui-duration-fast) var(--ui-ease);
}

:where(.sales-action, .purchase-action, .inventory-action, .accounts-action, .gst-return-action, .reports-action, .masters-action, .payroll-action):hover {
    border-color: var(--ui-brand-border);
    color: var(--ui-text);
    background: var(--ui-brand-tint);
    transform: none;
}

:where(.sales-action, .purchase-action, .inventory-action, .accounts-action, .gst-return-action, .reports-action, .masters-action, .payroll-action) strong {
    color: var(--ui-text-strong);
    font-size: 14px;
    font-weight: 600;
}

:where(.sales-action, .purchase-action, .inventory-action, .accounts-action, .gst-return-action, .reports-action, .masters-action, .payroll-action) small {
    display: none;
}

.dashboard-hero {
    border: 0;
    border-bottom: 1px solid var(--ui-border);
    border-radius: 0;
    color: var(--ui-text);
    background: transparent;
    padding: 0 0 20px;
    box-shadow: none;
}

.dashboard-hero h1 {
    color: var(--ui-text-strong);
    font-size: 26px;
    line-height: 34px;
}

.dashboard-layout {
    gap: 18px;
}

.dashboard-overview {
    display: grid;
    gap: 28px;
    margin-top: 22px;
}

.dashboard-section {
    min-width: 0;
}

.dashboard-section > .section-title {
    margin-bottom: 12px;
}

.dashboard-metric-stack {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.dashboard-focus-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.dashboard-focus-list a,
.dashboard-quick-card,
.home-menu-card {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.dashboard-focus-list a {
    min-height: 76px;
    padding: 12px 14px;
}

.dashboard-focus-list a > span,
.dashboard-quick-card > span,
.home-menu-card > span:not(.home-menu-icon) {
    min-width: 0;
    display: grid;
    flex: 1 1 auto;
    gap: 2px;
}

.dashboard-focus-list a > svg:first-child,
.dashboard-quick-card > svg:first-child {
    width: 32px;
    height: 32px;
    border-radius: var(--ui-radius-md);
    color: var(--ui-brand);
    background: var(--ui-brand-tint);
    padding: 7px;
}

.dashboard-focus-list a > svg:last-child,
.dashboard-quick-card > svg:last-child,
.home-menu-card > svg:last-child {
    width: 16px;
    height: 16px;
    color: var(--ui-text-soft);
}

.dashboard-focus-list small,
.dashboard-quick-card small,
.home-menu-card small {
    overflow: hidden;
    color: var(--ui-text-muted);
    font-size: 12px;
    font-weight: 400;
    line-height: 18px;
    text-overflow: ellipsis;
}

.dashboard-quick-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.dashboard-quick-card {
    min-height: 82px;
    padding: 13px 14px;
}

.home-menu-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.home-menu-card {
    min-height: 96px;
    padding: 14px;
}

.home-menu-icon {
    flex: 0 0 auto;
}

.home-menu-icon svg {
    width: 18px;
    height: 18px;
}

.dashboard-system-details {
    margin-top: 0;
}

.dashboard-system-details > summary small {
    margin-left: 8px;
    color: var(--ui-text-muted);
    font-weight: 500;
}

.dashboard-system-details > summary::after {
    margin-left: 0;
}

.home-menu-grid,
.dashboard-quick-grid {
    gap: 10px;
}

.home-menu-card,
.dashboard-quick-card,
.dashboard-focus-list a {
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius-md);
    color: var(--ui-text);
    background: var(--ui-surface);
    box-shadow: none;
    transition: border-color var(--ui-duration-fast) var(--ui-ease), background var(--ui-duration-fast) var(--ui-ease);
}

.home-menu-card:hover,
.dashboard-quick-card:hover,
.dashboard-focus-list a:hover {
    border-color: var(--ui-brand-border);
    color: var(--ui-text);
    background: var(--ui-brand-tint);
    transform: none;
}

.home-menu-card[class*="accent-"] {
    border-left: 1px solid var(--ui-border);
}

.home-menu-icon {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: var(--ui-radius-md);
    color: var(--ui-brand);
    background: var(--ui-brand-tint);
    font-size: 13px;
}

.dashboard-progress-track span {
    background: var(--ui-brand);
}

/* Entry and report workspaces */

.sales-entry-split,
.purchase-entry-split {
    gap: 18px;
}

.entry-workflow-section {
    min-width: 0;
}

.entry-workflow-section > .section-title {
    margin-bottom: 14px;
}

.entry-workflow-section + .sales-item-picker,
.entry-workflow-section + .purchase-item-picker {
    margin-top: 16px;
}

.purchase-import-disclosure {
    margin-bottom: 16px;
}

.purchase-import-panel {
    border: 0;
    background: transparent;
    padding: 0;
}

.sales-item-picker,
.purchase-item-picker {
    display: grid;
    align-items: end;
    gap: 8px;
    border: 0;
    border-top: 1px solid var(--ui-divider);
    border-bottom: 1px solid var(--ui-divider);
    border-radius: 0;
    background: transparent;
    padding: 12px 0;
}

.sales-item-picker {
    grid-template-columns: auto minmax(240px, 1fr) auto minmax(100px, 140px) auto;
}

.purchase-item-picker {
    grid-template-columns: auto minmax(240px, 1fr) auto minmax(100px, 140px) auto;
}

.sales-entry-totals,
.purchase-entry-totals,
.gstr1-totals {
    margin-top: 16px;
}

.sales-item-wrap,
.purchase-item-wrap {
    max-height: min(52vh, 620px);
    margin-top: 10px;
}

.data-grid.purchase-entry-item-grid {
    min-width: 2740px;
}

.line-remove-action {
    min-height: 32px;
    padding: 5px 9px;
}

.mobile-line-toggle {
    display: none;
}

.mobile-line-toggle-cell {
    display: none;
}

.report-filter-panel {
    margin-top: 14px;
}

.report-filter-grid {
    align-items: end;
}

/* Header actions proxy these existing submit controls; keep the bindings without a duplicate visual action. */
.report-filter-grid > button[id$="FilterSubmit"] {
    display: none;
}

.report-export-toolbar {
    border-top: 1px solid var(--ui-divider);
    margin-top: 14px;
    padding-top: 12px;
}

.report-filter-panel + .status-band,
.report-filter-panel ~ .metric-grid,
.status-band + .metric-grid,
.metric-grid + .work-panel,
.work-panel + .work-panel {
    margin-top: 14px;
}

.ui-disclosure,
.entry-disclosure,
.dashboard-system-details {
    margin-top: 14px;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius-md);
    background: var(--ui-surface);
}

.entry-panel .entry-disclosure {
    margin-top: 0;
    border: 0;
    border-top: 1px solid var(--ui-divider);
    border-radius: 0;
    background: transparent;
}

.entry-panel .entry-disclosure > summary,
.entry-panel .entry-disclosure-content {
    padding-right: 0;
    padding-left: 0;
}

.ui-disclosure > summary,
.entry-disclosure > summary,
.dashboard-system-details > summary {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 8px;
    list-style: none;
    color: var(--ui-text-strong);
    font-size: 13px;
    font-weight: 600;
    padding: 0 14px;
}

.ui-disclosure > summary::-webkit-details-marker,
.entry-disclosure > summary::-webkit-details-marker,
.dashboard-system-details > summary::-webkit-details-marker {
    display: none;
}

.ui-disclosure > summary::after,
.entry-disclosure > summary::after,
.dashboard-system-details > summary::after {
    margin-left: auto;
    color: var(--ui-text-muted);
    content: "+";
    font-size: 18px;
}

.ui-disclosure[open] > summary::after,
.entry-disclosure[open] > summary::after,
.dashboard-system-details[open] > summary::after {
    content: "-";
}

.ui-disclosure-content,
.entry-disclosure-content,
.dashboard-system-details-content {
    border-top: 1px solid var(--ui-divider);
    padding: 14px;
}

/* Compact shell and responsive content */

@media screen and (max-width: 1200px) {
    html,
    body,
    body.desktop-body {
        height: auto !important;
        min-height: 100% !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        background: var(--ui-canvas);
        touch-action: pan-y !important;
    }

    .desktop-frame,
    .desktop-main {
        width: 100% !important;
        min-height: 100dvh !important;
        height: auto !important;
        overflow: visible !important;
    }

    .desktop-main {
        display: block !important;
    }

    .side-menu {
        display: none !important;
    }

    .top-bar {
        position: sticky !important;
        top: 0;
        min-height: var(--ui-topbar-height);
        align-items: center !important;
        flex-direction: row !important;
        gap: var(--ui-space-3) !important;
        padding-right: var(--ui-page-gutter);
        padding-left: var(--ui-page-gutter);
    }

    .shell-menu-trigger {
        width: var(--ui-touch-target);
        height: var(--ui-touch-target);
        display: grid;
        flex: 0 0 var(--ui-touch-target);
        place-items: center;
        border: 1px solid var(--ui-border);
        border-radius: var(--ui-radius-md);
        color: var(--ui-text-strong);
        background: var(--ui-surface);
        padding: 0;
    }

    .ui-navigation-open {
        overflow: hidden !important;
    }

    .btn-line,
    .btn-primary-form,
    .btn-danger-form,
    .entry-actions button,
    .search-row button,
    .sales-item-picker button,
    .purchase-item-picker button,
    .report-filter-grid button,
    .toolbar-actions button,
    .toolbar-actions a,
    .report-export-toolbar button,
    .report-export-toolbar a,
    .data-grid input,
    .data-grid select,
    .line-remove-action {
        min-height: var(--ui-touch-target);
    }

    .top-product-context {
        display: none;
    }

    .top-session {
        max-width: 100%;
        margin-left: auto;
    }

    .shell-navigation {
        position: fixed !important;
        z-index: var(--ui-z-drawer);
        inset: 0;
        width: 100%;
        height: 100dvh;
        display: none;
        border: 0;
        background: rgb(11 17 23 / 54%);
        box-shadow: none;
    }

    .shell-navigation-summary {
        display: none !important;
    }

    .shell-navigation-summary::after,
    .shell-navigation-summary > strong {
        display: none;
    }

    .shell-navigation[open] {
        display: block;
        background: rgb(11 17 23 / 54%);
    }

    .shell-navigation[open] > .shell-navigation-summary {
        display: none;
    }

    .shell-navigation:not([open]) > .shell-navigation-content {
        display: none !important;
    }

    .shell-navigation[open] > .shell-navigation-content {
        width: min(360px, 90vw);
        height: 100dvh;
        max-height: none;
        display: flex !important;
        flex-direction: column;
        gap: 0;
        overflow-x: hidden;
        overflow-y: auto;
        color: var(--ui-text);
        background: var(--ui-surface);
        padding: 0 10px 18px;
        box-shadow: var(--ui-shadow-popover);
        touch-action: pan-y;
    }

    .shell-navigation-mobile-head {
        min-height: 64px;
        display: flex;
        align-items: center;
        gap: 10px;
        border-bottom: 1px solid var(--ui-divider);
        margin: 0 -10px 12px;
        padding: 0 14px;
    }

    .shell-navigation-mobile-head .side-brand-copy strong {
        color: var(--ui-text-strong);
    }

    .shell-navigation-mobile-head .side-brand-copy small {
        color: var(--ui-text-muted);
    }

    .shell-navigation-mobile-head button {
        width: 44px;
        height: 44px;
        display: grid;
        place-items: center;
        margin-left: auto;
        border: 0;
        border-radius: var(--ui-radius-md);
        color: var(--ui-text);
        background: transparent;
    }

    .shell-navigation-content .shell-nav-filter {
        display: block;
        flex: 0 0 auto;
        border-color: var(--ui-border);
        color: var(--ui-text);
        background: var(--ui-surface-subtle);
    }

    .shell-navigation-content .shell-nav-filter-body {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        border-color: var(--ui-divider);
    }

    .shell-navigation-content .side-nav-scroll {
        min-height: 0;
        display: flex;
        flex: 1 1 auto;
        gap: 18px;
        overflow: visible;
        padding: 10px 0;
    }

    .shell-navigation-content .side-nav-group {
        display: grid;
        gap: 3px;
    }

    .shell-navigation-content .side-section-label {
        display: flex;
        color: var(--ui-text-soft);
    }

    .shell-navigation-content .side-link {
        min-height: var(--ui-touch-target);
        display: flex;
        border: 0;
        border-radius: var(--ui-radius-md);
        color: var(--ui-text);
        background: transparent;
        padding: 0 11px;
    }

    .shell-navigation-content .side-link:hover {
        color: var(--ui-text-strong);
        background: var(--ui-surface-muted);
    }

    .shell-navigation-content .side-link.active {
        color: var(--ui-brand);
        background: var(--ui-brand-tint);
        box-shadow: none;
    }

    .shell-navigation-content .side-link.active::before {
        left: -10px;
    }

    .shell-navigation-content .side-signout {
        flex: 0 0 auto;
        border: 1px solid var(--ui-danger-border);
        color: var(--ui-danger);
        background: var(--ui-danger-bg);
    }

    .work-area {
        height: auto !important;
        max-height: none !important;
        min-height: calc(100dvh - var(--ui-topbar-height)) !important;
        overflow-x: hidden !important;
        overflow-y: visible !important;
        padding: 20px var(--ui-page-gutter) calc(72px + env(safe-area-inset-bottom)) !important;
        touch-action: pan-y !important;
    }

    .master-split,
    .entry-panel,
    .grid-panel,
    .work-panel,
    .statement-wrap {
        height: auto !important;
        max-height: none !important;
        overflow-y: visible !important;
    }

    .data-grid-wrap,
    .table-wrap,
    .responsive-table-wrap {
        max-height: min(68dvh, 640px) !important;
        overflow: auto !important;
        touch-action: pan-x pan-y !important;
    }

    .module-head {
        gap: 16px;
    }

    .module-actions {
        max-width: 54%;
    }

    .form-grid.compact {
        grid-template-columns: minmax(110px, auto) minmax(0, 1fr) minmax(110px, auto) minmax(0, 1fr);
    }

    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .metric-card:nth-child(even) {
        border-right: 0;
    }

    .metric-card:nth-child(n+3) {
        border-top: 1px solid var(--ui-divider);
    }
}

@media screen and (max-width: 1023px) {
    .module-head {
        min-height: 0;
        display: grid;
        grid-template-columns: minmax(0, 1fr);
    }

    .module-actions {
        max-width: none;
        justify-content: flex-start;
    }

    .module-actions > :last-child.btn-primary-form,
    .module-actions > :last-child:not(.danger-line) {
        margin-left: auto;
    }

    .form-grid.compact,
    .report-filter-grid {
        grid-template-columns: minmax(110px, auto) minmax(0, 1fr);
    }

    .form-grid .span-3,
    .report-filter-grid .span-3 {
        grid-column: auto;
    }

    .sales-item-picker,
    .purchase-item-picker {
        grid-template-columns: minmax(0, 1fr) minmax(92px, 130px) auto;
    }

    .sales-item-picker > label:first-child,
    .purchase-item-picker > label:first-child,
    .sales-item-picker > label:nth-of-type(2),
    .purchase-item-picker > label:nth-of-type(2) {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .dashboard-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .dashboard-quick-grid,
    .home-menu-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media screen and (max-width: 767px) {
    .top-session-copy {
        max-width: calc(100vw - 132px);
    }

    .top-company {
        font-size: 12px;
    }

    .top-context {
        font-size: 10px;
    }

    .work-area {
        padding-top: 16px !important;
    }

    .module-head {
        padding-bottom: 16px;
    }

    .module-head h1 {
        font-size: var(--ui-font-size-title-mobile);
        line-height: 28px;
    }

    .module-head p {
        font-size: 12px;
    }

    .module-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .module-actions > * {
        width: 100%;
        min-width: 0;
        min-height: var(--ui-touch-target);
    }

    .ui-action-menu,
    .ui-action-menu > summary {
        width: 100%;
    }

    .ui-action-menu > summary {
        min-height: var(--ui-touch-target);
    }

    .ui-action-menu-content {
        position: absolute;
        width: min(280px, calc(100vw - 24px));
        margin-top: 0;
        box-shadow: var(--ui-shadow-popover);
    }

    .ui-action-menu-content a,
    .ui-action-menu-content button,
    .ui-action-menu-content > span {
        min-height: var(--ui-touch-target);
    }

    .data-grid-wrap td a,
    .data-grid-wrap td button,
    .table-wrap td a,
    .table-wrap td button,
    .responsive-table-wrap td a,
    .responsive-table-wrap td button {
        min-width: var(--ui-touch-target);
        min-height: var(--ui-touch-target);
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .settings-shell,
    .accounts-shell,
    .sales-shell,
    .purchase-shell,
    .inventory-shell,
    .payroll-shell,
    .gst-return-shell,
    .reports-shell,
    .masters-shell {
        border: 0;
        margin-right: 0;
        margin-left: 0;
        background: transparent;
        padding: 0;
        box-shadow: none;
    }

    .reports-menu-content {
        grid-template-columns: minmax(0, 1fr);
    }

    .module-actions > :last-child {
        margin-left: 0;
    }

    .entry-panel,
    .grid-panel,
    .work-panel,
    .report-filter-panel,
    .settings-shell,
    .accounts-shell,
    .sales-shell,
    .purchase-shell,
    .inventory-shell,
    .payroll-shell,
    .gst-return-shell,
    .reports-shell,
    .masters-shell {
        border-right: 0;
        border-left: 0;
        border-radius: 0;
        margin-right: calc(var(--ui-page-gutter) * -1);
        margin-left: calc(var(--ui-page-gutter) * -1);
        padding: 16px var(--ui-page-gutter);
        box-shadow: none;
    }

    .settings-shell,
    .accounts-shell,
    .sales-shell,
    .purchase-shell,
    .inventory-shell,
    .payroll-shell,
    .gst-return-shell,
    .reports-shell,
    .masters-shell {
        border: 0;
        margin-right: 0;
        margin-left: 0;
        background: transparent;
        padding: 0;
        box-shadow: none;
    }

    .form-grid.compact,
    .report-filter-grid {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 5px;
    }

    .form-grid.compact > label,
    .report-filter-grid > label {
        margin-top: 9px;
    }

    .form-grid input,
    .form-grid select,
    .form-grid textarea,
    .report-filter-grid input,
    .report-filter-grid select,
    .search-row input,
    .sales-item-picker input,
    .sales-item-picker select,
    .purchase-item-picker input,
    .purchase-item-picker select,
    .btn-line,
    .btn-primary-form,
    .entry-actions button,
    .search-row button,
    .sales-item-picker button,
    .purchase-item-picker button,
    .report-filter-grid button {
        min-height: var(--ui-touch-target);
    }

    .check-strip {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
    }

    .check-row,
    .check-strip label {
        min-height: var(--ui-touch-target);
    }

    .sales-item-picker,
    .purchase-item-picker {
        grid-template-columns: minmax(0, 1fr) 92px;
        padding: 10px;
    }

    .sales-item-picker button,
    .purchase-item-picker button {
        grid-column: 1 / -1;
    }

    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .metric-card {
        min-height: 90px;
        padding: 12px 14px;
    }

    .metric-card strong {
        font-size: 17px;
        line-height: 24px;
    }

    .metric-card:nth-child(even) {
        border-right: 0;
    }

    .metric-card:nth-child(n+3) {
        border-top: 1px solid var(--ui-divider);
    }

    .sales-item-wrap,
    .purchase-item-wrap {
        max-height: none !important;
        overflow: visible !important;
        border: 0;
        background: transparent;
    }

    .sales-entry-item-grid,
    .purchase-entry-item-grid {
        min-width: 0 !important;
        display: block;
        background: transparent;
    }

    .sales-entry-item-grid thead,
    .purchase-entry-item-grid thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .mobile-line-toggle-header {
        display: none;
    }

    .sales-entry-item-grid tbody,
    .purchase-entry-item-grid tbody {
        display: grid;
        gap: 12px;
    }

    .sales-entry-item-grid tbody tr,
    .purchase-entry-item-grid tbody tr {
        min-width: 0;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0;
        overflow: hidden;
        border: 1px solid var(--ui-border);
        border-radius: var(--ui-radius-md);
        background: var(--ui-surface);
        box-shadow: var(--ui-shadow-sm);
    }

    .sales-entry-item-grid tbody td,
    .purchase-entry-item-grid tbody td {
        min-width: 0;
        display: grid;
        align-content: start;
        gap: 5px;
        border: 0;
        border-right: 1px solid var(--ui-divider);
        border-bottom: 1px solid var(--ui-divider);
        background: var(--ui-surface);
        padding: 10px;
        white-space: normal;
        overflow-wrap: anywhere;
        text-align: left;
    }

    .sales-entry-item-grid tbody td::before,
    .purchase-entry-item-grid tbody td::before {
        color: var(--ui-text-muted);
        content: attr(data-mobile-label);
        font-size: 10px;
        font-weight: 700;
        line-height: 14px;
    }

    .sales-entry-item-grid tbody td[data-mobile-wide="true"],
    .purchase-entry-item-grid tbody td[data-mobile-wide="true"],
    .sales-entry-item-grid .line-action-cell,
    .purchase-entry-item-grid .line-action-cell {
        grid-column: 1 / -1;
    }

    .sales-entry-item-grid tbody tr:not([data-mobile-expanded="true"]) td[data-mobile-field="advanced"],
    .purchase-entry-item-grid tbody tr:not([data-mobile-expanded="true"]) td[data-mobile-field="advanced"] {
        display: none;
    }

    .sales-entry-item-grid input,
    .sales-entry-item-grid select,
    .purchase-entry-item-grid input,
    .purchase-entry-item-grid select {
        width: 100%;
        min-height: var(--ui-touch-target);
    }

    .mobile-line-toggle {
        min-height: var(--ui-touch-target);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 7px;
        grid-column: 1 / -1;
        border: 0;
        border-top: 1px solid var(--ui-divider);
        color: var(--ui-brand);
        background: var(--ui-surface-subtle);
        font-size: 12px;
        font-weight: 600;
    }

    .sales-entry-item-grid tbody td.mobile-line-toggle-cell,
    .purchase-entry-item-grid tbody td.mobile-line-toggle-cell {
        display: block;
        grid-column: 1 / -1;
        border: 0;
        padding: 0;
    }

    .sales-entry-item-grid tbody td.mobile-line-toggle-cell::before,
    .purchase-entry-item-grid tbody td.mobile-line-toggle-cell::before {
        display: none;
    }

    .data-grid.sales-entry-item-grid .line-remove-action,
    .data-grid.purchase-entry-item-grid .line-remove-action {
        width: 100%;
        min-height: var(--ui-touch-target);
        padding: 8px 12px;
    }

    .toolbar-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .toolbar-actions > button,
    .toolbar-actions > a {
        min-height: var(--ui-touch-target);
    }

    .data-grid-wrap:not(.sales-item-wrap):not(.purchase-item-wrap),
    .table-wrap,
    .responsive-table-wrap {
        min-height: 180px;
        max-height: 66dvh !important;
        overflow: auto !important;
        scrollbar-gutter: stable both-edges;
    }

    .home-menu-grid,
    .dashboard-quick-grid,
    .sales-action-grid,
    .purchase-action-grid,
    .inventory-action-grid,
    .accounts-action-grid,
    .gst-return-action-grid,
    .reports-action-grid,
    .masters-action-grid,
    .payroll-action-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .dashboard-focus-list {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media screen and (max-width: 479px) {
    .top-company-avatar {
        display: none;
    }

    .top-session-copy {
        max-width: calc(100vw - 88px);
    }

    .work-area:has(.sales-entry-head) {
        padding-bottom: calc(112px + env(safe-area-inset-bottom)) !important;
    }

    .sales-entry-head .module-actions {
        position: fixed;
        z-index: var(--ui-z-sticky);
        right: 12px;
        bottom: max(4px, env(safe-area-inset-bottom));
        left: 12px;
        width: auto;
        max-width: none;
        border: 1px solid var(--ui-border);
        border-radius: var(--ui-radius-lg);
        background: color-mix(in srgb, var(--ui-surface) 96%, transparent);
        padding: 4px;
        box-shadow: var(--ui-shadow-popover);
        backdrop-filter: blur(14px);
    }

    .sales-entry-head .ui-action-menu-content {
        top: auto;
        right: auto;
        bottom: calc(100% + 8px);
        left: 0;
    }

    .metric-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .metric-card,
    .metric-card:nth-child(even) {
        border-right: 0;
        border-bottom: 1px solid var(--ui-divider);
    }

    .metric-card:last-child {
        border-bottom: 0;
    }

    .sales-entry-item-grid tbody tr,
    .purchase-entry-item-grid tbody tr {
        grid-template-columns: minmax(0, 1fr);
    }

    .sales-entry-item-grid tbody td,
    .purchase-entry-item-grid tbody td,
    .sales-entry-item-grid tbody td[data-mobile-wide="true"],
    .purchase-entry-item-grid tbody td[data-mobile-wide="true"] {
        grid-column: 1;
        border-right: 0;
    }
}

@media print {
    html,
    body {
        width: auto;
        height: auto;
        margin: 0;
        overflow: visible;
        background: #fff;
    }

    .desktop-frame,
    .desktop-main,
    .work-area {
        display: block !important;
        width: auto !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
        padding: 0 !important;
        background: #fff !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
