/* Shared grayscale presentation override. Keep status meaning and chart series colored. */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f4f4;
  --nav: #ffffff;
  --surface: #ffffff;
  --surface-2: #f0f0f0;
  --surface-3: #e7e7e7;
  --line: #d1d1d1;
  --line-strong: #a6a6a6;
  --muted: #595959;
  --text: #171717;
  --ci-bg: var(--bg);
  --ci-surface: var(--surface);
  --ci-primary: #414141;
  --ci-violet: #606060;
  --ci-cyan: #686868;
  --cyan: var(--ci-cyan);
  --blue: var(--ci-primary);
  --violet: var(--ci-violet);
  --shadow: 0 12px 32px rgb(0 0 0 / 8%);
  --shadow-soft: 0 5px 18px rgb(0 0 0 / 6%);
  --focus-ring: 0 0 0 3px rgb(45 45 45 / 24%);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141414;
  --nav: #161616;
  --surface: #1c1c1c;
  --surface-2: #242424;
  --surface-3: #2c2c2c;
  --line: #3d3d3d;
  --line-strong: #646464;
  --muted: #b8b8b8;
  --text: #f2f2f2;
  --ci-bg: var(--bg);
  --ci-surface: var(--surface);
  --ci-primary: #c8c8c8;
  --ci-violet: #b5b5b5;
  --ci-cyan: #d0d0d0;
  --cyan: var(--ci-cyan);
  --blue: var(--ci-primary);
  --violet: var(--ci-violet);
  --shadow: 0 18px 48px rgb(0 0 0 / 42%);
  --shadow-soft: 0 8px 24px rgb(0 0 0 / 30%);
  --focus-ring: 0 0 0 3px rgb(220 220 220 / 34%);
}

html[data-theme="dark"] {
  --chart-primary: #818cf8;
  --chart-cyan: #22d3ee;
  --chart-violet: #a78bfa;
}

/* The chart palette deliberately retains the existing colored data series. */
:root {
  --chart-primary: #4f46e5;
  --chart-cyan: #06b6d4;
  --chart-violet: #7c3aed;
  --chart-flow-violet: #b5aeff;
  --chart-flow-track: #b6aeff;
  --chart-flow-violet-fill: #b9b2ff;
  --chart-cyan-flow: #67e8f9;
}

html,
body,
#app {
  background-color: var(--bg);
  color: var(--text);
}

body,
body * {
  scrollbar-color: var(--line-strong) transparent;
}

.app-shell,
html[data-theme="light"] .app-shell,
html[data-theme="dark"] .app-shell {
  background: var(--bg) !important;
  color: var(--text) !important;
}

/* Main frame, navigation, selection and profile chrome. */
.sidebar,
html[data-theme="light"] .sidebar,
html[data-theme="dark"] .sidebar {
  background: var(--nav) !important;
  border-color: var(--line) !important;
  box-shadow: 7px 0 26px rgb(0 0 0 / 8%) !important;
}
.brand-mark,
.brand-symbol img {
  background: linear-gradient(145deg, #454545, #777777) !important;
  box-shadow: 0 6px 16px rgb(0 0 0 / 18%) !important;
}
.brand-lockup,
.profile-row {
  border-color: var(--line) !important;
}
.brand-lockup::after {
  background-image: linear-gradient(90deg, var(--line), transparent) !important;
}
.nav-item:hover,
.nav-item.active,
html[data-theme="light"] .nav-item.active,
html[data-theme="dark"] .nav-item.active {
  border-color: var(--line-strong) !important;
  background: linear-gradient(100deg, var(--surface-3), var(--surface-2)) !important;
  color: var(--text) !important;
  box-shadow: inset 3px 0 #555555, 0 5px 16px rgb(0 0 0 / 8%) !important;
}
.nav-item.active .nav-icon,
html[data-theme="dark"] .nav-item.active .nav-icon {
  color: var(--text) !important;
}
.nav-active-dot {
  background: #555555 !important;
  box-shadow: 0 0 0 3px rgb(80 80 80 / 18%) !important;
}
.nav-subcategory.active,
html[data-theme="dark"] .nav-subcategory.active {
  background: #5555551a !important;
  color: var(--text) !important;
}
.nav-subcategory.active::before {
  background: #555555 !important;
}
.secure-card,
html[data-theme="dark"] .secure-card {
  background: var(--surface-2) !important;
  border-color: var(--line) !important;
}
.secure-icon,
html[data-theme="dark"] .secure-icon {
  background: var(--surface-3) !important;
  color: var(--text) !important;
}
.avatar,
html[data-theme="light"] .topbar .avatar {
  border-color: var(--line-strong) !important;
  background: linear-gradient(145deg, #666666, #3e3e3e) !important;
  color: #ffffff !important;
}
.profile-avatar-button,
html[data-theme="light"] .profile-avatar-button,
html[data-theme="dark"] .profile-avatar-button {
  box-shadow: 0 0 0 1px var(--line-strong) !important;
}
.topbar,
html[data-theme="light"] .topbar,
html[data-theme="dark"] .topbar {
  background: rgb(255 255 255 / 94%) !important;
  border-color: var(--line) !important;
  box-shadow: 0 8px 24px rgb(0 0 0 / 8%) !important;
}
html[data-theme="dark"] .topbar {
  background: rgb(24 24 24 / 96%) !important;
}
.topbar .icon-button:hover,
html[data-theme="light"] .topbar .icon-button:hover {
  border-color: var(--line-strong) !important;
  background: var(--surface-3) !important;
  color: var(--text) !important;
}

/* Dashboard hero surfaces, ornamental lines and stat-card art. */
.dashboard-welcome,
html[data-theme="light"] .dashboard-welcome,
html[data-theme="dark"] .dashboard-welcome {
  background: linear-gradient(115deg, var(--surface), var(--surface-2)) !important;
  border-color: var(--line) !important;
  box-shadow: 0 10px 26px rgb(0 0 0 / 8%) !important;
}
.page-heading::before,
html[data-theme="light"] .page-heading::before,
html[data-theme="dark"] .page-heading::before,
.dashboard-welcome::before {
  background: linear-gradient(#4c4c4c, #858585) !important;
}
.page-heading::after,
html[data-theme="light"] .page-heading::after,
html[data-theme="dark"] .page-heading::after,
.dashboard-welcome::after {
  border-color: rgb(80 80 80 / 16%) !important;
  box-shadow: 0 0 0 25px rgb(80 80 80 / 5%), 0 0 0 50px rgb(80 80 80 / 3%) !important;
}
.page-heading-eyebrow,
html[data-theme="light"] .page-heading-eyebrow,
html[data-theme="dark"] .page-heading-eyebrow,
.dashboard-welcome-eyebrow,
html[data-theme="dark"] .dashboard-welcome-eyebrow,
.dashboard-welcome .eyebrow,
.settings-eyebrow {
  color: var(--muted) !important;
}
.dashboard-welcome h2,
.dashboard-welcome p {
  color: var(--text) !important;
}
.dashboard-welcome p {
  color: var(--muted) !important;
}
.dashboard-welcome-eyebrow i {
  background: #666666 !important;
  box-shadow: 0 0 0 4px rgb(80 80 80 / 14%) !important;
}
.dashboard-ink-swatch-blue,
.dashboard-ink-swatch-teal,
.dashboard-ink-swatch-rose {
  background: linear-gradient(180deg, #a0a0a0, #555555) !important;
}
.stat-card,
html[data-theme="light"] .stat-card,
html[data-theme="dark"] .stat-card {
  background: linear-gradient(145deg, var(--surface), var(--surface-2)) !important;
  border-color: var(--line) !important;
  box-shadow: var(--shadow-soft) !important;
}
/* Keep decoration monochrome without changing card geometry or artwork elsewhere. */
.stat-card::before,
.stat-card::after {
  filter: grayscale(1);
}
.stat-card.accent-cyan,
.stat-card.accent-blue,
.stat-card.accent-violet {
  color: var(--text) !important;
  border-top-color: var(--line-strong) !important;
}
.stat-orb {
  background: #777777 !important;
  box-shadow: 0 0 12px rgb(90 90 90 / 35%) !important;
}

/* Panels, cards and tables use the shared neutral surfaces. */
.panel,
.overview-section,
html[data-theme="light"] .panel,
html[data-theme="light"] .overview-section,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .overview-section,
.settings-card,
.settings-scope-card,
html[data-theme="dark"] .settings-card,
.search-select-menu,
.search-select-list,
html[data-theme="dark"] .search-select-menu {
  background: var(--surface) !important;
  border-color: var(--line) !important;
  box-shadow: var(--shadow-soft) !important;
}
.panel::before,
.overview-section::before,
html[data-theme="light"] .panel::before,
html[data-theme="dark"] .panel::before {
  background: linear-gradient(90deg, #555555, #9a9a9a) !important;
}
.panel-heading,
html[data-theme="light"] .panel-heading,
html[data-theme="dark"] .panel-heading,
.modal-header,
.modal-footer,
html[data-theme="light"] .modal-header,
html[data-theme="dark"] .modal-header,
.settings-card-heading,
.branding-preview-lines {
  border-color: var(--line) !important;
}
.table-scroll,
html[data-theme="light"] .table-scroll,
html[data-theme="dark"] .table-scroll {
  border-color: var(--line) !important;
}
.data-table thead th,
html[data-theme="light"] .data-table thead th,
html[data-theme="dark"] .data-table thead th,
.data-table tfoot th,
html[data-theme="light"] .data-table tfoot th,
html[data-theme="dark"] .data-table tfoot th {
  background: var(--surface-3) !important;
  border-color: var(--line) !important;
  color: var(--text) !important;
}
.data-table tbody tr:nth-child(even),
html[data-theme="light"] .data-table tbody tr:nth-child(even),
html[data-theme="dark"] .data-table tbody tr:nth-child(even),
.data-table tbody tr:hover,
html[data-theme="light"] .data-table tbody tr:hover,
html[data-theme="dark"] .data-table tbody tr:hover {
  background: var(--surface-2) !important;
}
.data-table td,
html[data-theme="light"] .data-table td,
html[data-theme="dark"] .data-table td {
  border-color: var(--line) !important;
}

/* Modals, popups, dropdowns and form controls. */
.modal-card,
html[data-theme="light"] .modal-card,
html[data-theme="dark"] .modal-card,
.dashboard-production-quick-modal,
.dashboard-production-choice-modal,
.dashboard-printing-detail-modal,
.detail-popup-card,
html[data-theme="dark"] .detail-popup-card {
  background: var(--surface) !important;
  border-color: var(--line) !important;
  box-shadow: var(--shadow) !important;
}
.modal-backdrop,
html[data-theme="light"] .modal-backdrop,
html[data-theme="dark"] .modal-backdrop {
  background: rgb(0 0 0 / 48%) !important;
}
.search-select-menu,
.search-select-list {
  background: var(--surface) !important;
}
.form-field input,
.form-field select,
.form-field textarea,
.recipe-line input,
.recipe-line select,
.search-select-input,
.search-select-toggle,
.table-search input,
.catalog-search input,
.export-pair-picker-search,
.company-settings-workspace .form-field input,
.company-settings-workspace .form-field textarea,
html[data-theme="light"] .form-field input,
html[data-theme="light"] .form-field select,
html[data-theme="light"] .form-field textarea,
html[data-theme="dark"] .form-field input,
html[data-theme="dark"] .form-field select,
html[data-theme="dark"] .form-field textarea {
  background: var(--surface) !important;
  border-color: var(--line-strong) !important;
  color: var(--text) !important;
}
.form-field input::placeholder,
.form-field textarea::placeholder,
.table-search input::placeholder,
html[data-theme="dark"] .form-field input::placeholder {
  color: var(--muted) !important;
  opacity: 1;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus,
.recipe-line input:focus,
.recipe-line select:focus,
.search-select-input:focus,
.table-search input:focus,
.company-settings-workspace .form-field input:focus,
.company-settings-workspace .form-field textarea:focus,
.export-pair-picker-search:focus,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  border-color: #595959 !important;
  outline-color: #595959 !important;
  box-shadow: var(--focus-ring) !important;
}
input[type="checkbox"],
input[type="radio"],
.export-pair-option input {
  accent-color: #555555 !important;
}
.icon-button:hover,
.button-quiet:hover,
.settings-button:hover,
html[data-theme="dark"] .icon-button:hover {
  border-color: var(--line-strong) !important;
  background: var(--surface-3) !important;
  color: var(--text) !important;
}
.button-primary,
html[data-theme="light"] .button-primary,
html[data-theme="dark"] .button-primary,
.settings-button,
html[data-theme="dark"] .settings-button,
.offline-status button,
html[data-theme="dark"] .offline-status button {
  border-color: #454545 !important;
  background: linear-gradient(110deg, #3f3f3f, #666666) !important;
  color: #ffffff !important;
  box-shadow: 0 5px 18px rgb(0 0 0 / 14%) !important;
}
.button-primary:hover,
.settings-button:hover,
.offline-status button:hover {
  background: #333333 !important;
}
.button-quiet,
html[data-theme="dark"] .button-quiet,
.icon-button,
html[data-theme="dark"] .icon-button {
  border-color: var(--line) !important;
  background: var(--surface) !important;
  color: var(--text) !important;
}

/* Non-semantic informational tags and guidance; leave live/positive, warning,
   error, balance-positive/negative, and other red/amber/green states untouched. */
.read-only-tag,
.chart-tag,
.record-count,
html[data-theme="light"] .read-only-tag,
html[data-theme="dark"] .read-only-tag,
html[data-theme="light"] .chart-tag,
html[data-theme="dark"] .chart-tag,
.export-pair-picker-count {
  border-color: var(--line-strong) !important;
  background: var(--surface-2) !important;
  color: var(--text) !important;
}
.callout-info,
html[data-theme="light"] .callout-info,
html[data-theme="dark"] .callout-info,
.settings-access-note,
html[data-theme="dark"] .settings-access-note,
.offline-status,
html[data-theme="dark"] .offline-status {
  border-color: var(--line) !important;
  background: var(--surface-2) !important;
  color: var(--text) !important;
}
.callout-info > span,
html[data-theme="light"] .callout-info > span,
html[data-theme="dark"] .callout-info > span {
  background: var(--surface-3) !important;
  color: var(--text) !important;
}
.callout-info strong,
.callout-info p,
html[data-theme="light"] .callout-info strong,
html[data-theme="light"] .callout-info p,
html[data-theme="dark"] .callout-info strong,
html[data-theme="dark"] .callout-info p {
  color: var(--text) !important;
}
.settings-step,
.settings-access-dot,
html[data-theme="dark"] .settings-step {
  background: var(--surface-3) !important;
  color: var(--text) !important;
  box-shadow: none !important;
}
.settings-scope-card li::marker,
.settings-access-note strong,
.settings-eyebrow,
.settings-scope-card li {
  color: var(--text) !important;
}
.mobile-company-settings-link,
.mobile-company-settings-link.active,
html[data-theme="dark"] .mobile-company-settings-link,
html[data-theme="dark"] .mobile-company-settings-link.active {
  border-color: var(--line) !important;
  background: var(--surface-2) !important;
  color: var(--text) !important;
}

/* Descriptive production-entry type labels are not positive/negative states. */
.production-entry-type-badge--input,
.production-entry-type-badge--delivery,
.production-entry-type-badge--other,
html[data-theme="dark"] .production-entry-type-badge--input,
html[data-theme="dark"] .production-entry-type-badge--delivery,
html[data-theme="dark"] .production-entry-type-badge--other {
  border-color: var(--line-strong) !important;
  background: var(--surface-2) !important;
  color: var(--text) !important;
}
.entry-type-card:has(input:checked),
html[data-theme="dark"] .entry-type-card:has(input:checked),
.dashboard-production-choices .entry-type-card:hover {
  border-color: var(--line-strong) !important;
  background: var(--surface-2) !important;
  color: var(--text) !important;
  box-shadow: inset 0 0 0 1px var(--line-strong) !important;
}

/* Login hero and toast/decorative elements. Logo images are intentionally not filtered. */
.login-screen,
html[data-theme="light"] .login-screen,
html[data-theme="dark"] .login-screen {
  background: radial-gradient(ellipse at 70% 20%, #eeeeee, transparent 38%),
    linear-gradient(135deg, var(--bg), var(--surface-2)) !important;
}
.login-brand-panel,
html[data-theme="light"] .login-brand-panel,
html[data-theme="dark"] .login-brand-panel {
  background: linear-gradient(145deg, #303030, #5b5b5b 58%, #777777) !important;
  color: #ffffff !important;
}
.login-brand-panel::before,
.login-brand-panel::after {
  border-color: rgb(255 255 255 / 18%) !important;
  box-shadow: 0 0 0 24px rgb(255 255 255 / 5%), 0 0 0 48px rgb(255 255 255 / 3%) !important;
}
.login-card,
html[data-theme="light"] .login-card,
html[data-theme="dark"] .login-card {
  background: var(--surface) !important;
  border-color: var(--line) !important;
  box-shadow: var(--shadow) !important;
}
.login-card h1,
html[data-theme="light"] .login-card h1,
html[data-theme="dark"] .login-card h1 {
  color: var(--text) !important;
}
.toast,
html[data-theme="light"] .toast,
html[data-theme="dark"] .toast {
  border-color: var(--line-strong) !important;
  background: var(--surface) !important;
  color: var(--text) !important;
}
.offline-status button:focus-visible,
html[data-theme="dark"] .offline-status button:focus-visible {
  outline-color: #777777 !important;
}

/* Preserve the chart's original teal/blue/violet data encoding in both themes. */
.bar {
  background: linear-gradient(180deg, #8b83f5, var(--chart-primary)) !important;
  box-shadow: 0 0 12px rgb(79 70 229 / 13%) !important;
}
.bar.blue {
  background: linear-gradient(180deg, #48d6ea, var(--chart-cyan)) !important;
  box-shadow: 0 0 12px rgb(6 182 212 / 13%) !important;
}
.bar-cap {
  fill: var(--chart-violet) !important;
}
.hbar-track i {
  background: linear-gradient(90deg, var(--chart-primary), var(--chart-violet)) !important;
}
.overview-chart-legend span:first-child i {
  background: var(--chart-primary) !important;
}
.overview-chart-legend span:nth-child(2) i {
  background: var(--chart-cyan) !important;
}
.flow-legend i {
  background: var(--chart-flow-violet) !important;
}
.flow-track i {
  background: var(--chart-flow-track) !important;
}
.flow-legend span:nth-child(2) i,
.flow-item:nth-of-type(2) .flow-track i {
  background: var(--chart-cyan-flow) !important;
}
.flow-track-base {
  fill: #ffffff2e !important;
}
.flow-track-fill {
  fill: var(--chart-flow-violet-fill) !important;
}
.flow-delivery .flow-track-fill {
  fill: var(--chart-cyan-flow) !important;
}
/* SVG .bar-rect/.bar-cap fills supplied by chart data keep their original inline series colors. */

/* Final neutral cleanup for icon tiles, settings, administrative labels and tables. */
html[data-theme="light"] .theme-toggle-icon,
html[data-theme="dark"] .theme-toggle-icon {
  background: var(--surface-3) !important;
  color: var(--text) !important;
}
html[data-theme="light"] .page-heading-symbol,
html[data-theme="dark"] .page-heading-symbol {
  border-color: var(--line) !important;
  background: var(--surface-3) !important;
  box-shadow: none !important;
}
html[data-theme="light"] .stat-icon,
html[data-theme="dark"] .stat-icon,
html[data-theme="light"] .accent-cyan .stat-icon,
html[data-theme="dark"] .accent-cyan .stat-icon,
html[data-theme="light"] .accent-violet .stat-icon,
html[data-theme="dark"] .accent-violet .stat-icon,
html[data-theme="light"] .accent-lime .stat-icon,
html[data-theme="dark"] .accent-lime .stat-icon {
  border-color: var(--line) !important;
  background: var(--surface-3) !important;
  color: var(--text) !important;
  box-shadow: var(--shadow-soft) !important;
}
html[data-theme="light"] .status-admin,
html[data-theme="dark"] .status-admin {
  border-color: var(--line) !important;
  background: var(--surface-2) !important;
  color: var(--text) !important;
}
html[data-theme="light"] .inventory-tab-button.active,
html[data-theme="dark"] .inventory-tab-button.active,
html[data-theme="light"] .inventory-tab-button[aria-selected="true"],
html[data-theme="dark"] .inventory-tab-button[aria-selected="true"] {
  box-shadow: none !important;
}
html[data-theme="light"] .inventory-tab-button.active .inventory-tab-count,
html[data-theme="dark"] .inventory-tab-button.active .inventory-tab-count,
html[data-theme="light"] .inventory-tab-button[aria-selected="true"] .inventory-tab-count,
html[data-theme="dark"] .inventory-tab-button[aria-selected="true"] .inventory-tab-count {
  border-color: var(--line-strong) !important;
  background: var(--surface-3) !important;
  color: var(--text) !important;
}
html[data-theme="light"] .stock-management-choice:has(input:checked),
html[data-theme="dark"] .stock-management-choice:has(input:checked) {
  border-color: var(--line-strong) !important;
  background: var(--surface-2) !important;
}
html[data-theme="light"] .stock-movement-ledger,
html[data-theme="dark"] .stock-movement-ledger,
html[data-theme="light"] .stock-movement-ledger th,
html[data-theme="dark"] .stock-movement-ledger th,
html[data-theme="light"] .stock-movement-ledger td,
html[data-theme="dark"] .stock-movement-ledger td {
  border-color: var(--line) !important;
  background-color: var(--surface) !important;
  color: var(--text) !important;
}
html[data-theme="light"] .company-settings-workspace,
html[data-theme="dark"] .company-settings-workspace {
  --settings-ink: var(--text) !important;
  color: var(--text) !important;
}
.company-settings-workspace h2,
.company-settings-workspace h3,
.company-settings-workspace h4 {
  color: var(--text) !important;
}
.company-settings-savebar {
  box-shadow: var(--shadow) !important;
}
table.data-table {
  border-color: var(--line) !important;
  color: var(--text) !important;
}
.dashboard-flow-visual,
html[data-theme="light"] .dashboard-flow-visual,
html[data-theme="dark"] .dashboard-flow-visual {
  border-color: var(--line) !important;
  background: var(--surface-2) !important;
  box-shadow: var(--shadow-soft) !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}
.flow-visual-heading,
.flow-item > span,
.flow-item strong,
.flow-item .flow-legend strong,
.flow-item .flow-legend strong small,
.flow-note {
  color: var(--text) !important;
}
html[data-theme="light"] .dashboard-welcome h2,
html[data-theme="light"] .dashboard-welcome p,
html[data-theme="dark"] .dashboard-welcome h2,
html[data-theme="dark"] .dashboard-welcome p {
  color: var(--text) !important;
}
html[data-theme="light"] .dashboard-welcome p,
html[data-theme="dark"] .dashboard-welcome p {
  color: var(--muted) !important;
}
.callout:not(.callout-warn):not(.callout-error) > span {
  background: var(--surface-3) !important;
  color: var(--text) !important;
}
[class*="mobile-detail-popup"] {
  box-shadow: var(--shadow-soft) !important;
}
[class*="mobile-detail-popup-backdrop"],
.mobile-settings-backdrop,
.mobile-settings-scrim {
  background: rgb(0 0 0 / 48%) !important;
  box-shadow: none !important;
}

/* Zero is neutral information, not a positive/negative status color. */
.balance-zero,
html[data-theme="light"] .balance-zero,
html[data-theme="dark"] .balance-zero,
.balance-zero :is(strong, b, span, em, dd) {
  color: var(--text) !important;
}
