/* 工作台共用组件：尺寸与间距由此处统一管理，颜色沿用当前主题。 */
:root {
  --workspace-control-height: 40px;
  --workspace-control-radius: 8px;
  --workspace-card-padding: 24px;
  --workspace-gap: 16px;
  --workspace-icon-size: 40px;
  --workspace-segment-height: 34px;
  --workspace-segment-bg: var(--surface);
  --workspace-segment-active: var(--panel);
  --workspace-metric-icon-size: 40px;
  --workspace-metric-height: 104px;
  --workspace-metric-font: 26px;
  --workspace-metric-gap: 16px;
}

/* 预留滚动条空间，切换长短页面时内容边线保持稳定。 */
@media (min-width: 931px) {
  .content { scrollbar-gutter: stable; }
}
.brand-page-shell { max-width: none; margin: 0; }
.page .page-head,
.page .receiving-head { margin-bottom: var(--workspace-gap); }
.page .page-desc { color: var(--muted); font-size: 13px; line-height: 1.6; }

/* 同级分类、视图切换采用同一分段控件，业务位置由各页决定。 */
.page :is(.brand-tabs, .settings-tabs, .dictionary-type-tabs, .date-mode-toggle, .view-switch-group) {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  max-width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--workspace-control-radius);
  background: var(--workspace-segment-bg);
  box-shadow: var(--shadow-xs);
  box-sizing: border-box;
}
.page :is(.brand-tabs, .settings-tabs) {
  width: max-content;
  margin: 0 0 var(--workspace-gap);
  overflow-x: auto;
  scrollbar-width: none;
}
.page :is(.brand-tabs, .settings-tabs)::-webkit-scrollbar { display: none; }
.page :is(.brand-tab, .settings-tab, .dictionary-type, .date-mode-btn, .view-switch-btn) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  gap: 8px;
  height: var(--workspace-segment-height);
  min-height: var(--workspace-segment-height);
  padding: 0 14px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}
.page :is(.brand-tab, .settings-tab, .dictionary-type, .date-mode-btn, .view-switch-btn) svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.page :is(.brand-tab, .settings-tab, .dictionary-type, .date-mode-btn, .view-switch-btn):hover {
  color: var(--primary);
  background: var(--primary-soft);
}
.page :is(.brand-tab, .settings-tab, .dictionary-type, .date-mode-btn, .view-switch-btn).active {
  color: var(--primary);
  background: var(--workspace-segment-active);
  box-shadow: var(--shadow-xs);
  font-weight: 600;
}
.page .view-switch-btn { width: 34px; padding: 0; }
html[data-theme="aurora"] {
  --workspace-segment-bg: var(--aurora-glass);
  --workspace-segment-active: var(--panel);
}
html[data-theme="aurora"] .page :is(.brand-tabs, .settings-tabs, .dictionary-type-tabs, .date-mode-toggle, .view-switch-group) {
  background: var(--workspace-segment-bg);
  border-color: var(--aurora-edge);
  box-shadow: inset 0 1px 0 var(--aurora-edge);
}

/* 同一层级的设置卡片：标题可带图标，正文统一从卡片内边线开始。 */
.page :is(.brand-section-card, .parameter-card, .calculation-rules-card, .security-setting-card) {
  padding: var(--workspace-card-padding);
  border-radius: 12px;
}
.page :is(.brand-section-heading, .settings-section-heading, .security-card-main, .parameter-copy) {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.page .brand-section-heading { justify-content: space-between; margin-bottom: 20px; }
.workspace-section-title { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.workspace-section-title > div:last-child { min-width: 0; }
.page :is(.brand-section-heading h2, .parameter-card h3, .calculation-rules-card h3, .security-setting-card h3) {
  margin: 0 0 4px;
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  font-weight: 650;
}
.page :is(.brand-section-heading p, .parameter-card p, .calculation-rules-card > .settings-section-heading p, .security-setting-card p) {
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}
.page .settings-card-icon {
  width: var(--workspace-icon-size);
  height: var(--workspace-icon-size);
  flex: 0 0 var(--workspace-icon-size);
  border-radius: var(--workspace-control-radius);
}
.page .settings-card-icon svg { width: 20px; height: 20px; }
.page .settings-overview-grid,
.page .security-settings-grid,
.page .brand-pane.active { gap: var(--workspace-gap); }
.page .security-settings-grid { margin-bottom: var(--workspace-gap); }
.page .fixed-cost-main,
.page .fixed-cost-footer { margin-left: 0; }
.page .calc-demo-notice { margin: 0; }
.page .brand-save-actions .btn { height: var(--workspace-control-height); }

/* 常规输入、下拉与按钮的共同规格；组合日期内部按钮保留紧凑规格。 */
.app :is(.btn, .custom-select-trigger, .select, .search-input, .input),
.app .field :is(input:not([type="range"]):not([type="checkbox"]):not([type="file"]), select),
.app .brand-field input,
.app .dictionary-search-wrap {
  height: var(--workspace-control-height);
  border-radius: var(--workspace-control-radius);
}
.app .btn { font-weight: 600; letter-spacing: 0; white-space: nowrap; background-clip: padding-box; }
.app .btn-secondary { font-weight: 500; }
.app .security-setting-card > .btn { flex-shrink: 0; }
.btn:disabled,
.app .btn:disabled,
html.dark-theme .btn:disabled,
html[data-theme="aurora"] .btn:disabled,
html.dark-theme[data-theme="aurora"] .btn:disabled { cursor: not-allowed; opacity: 0.48 !important; transform: none !important; box-shadow: none !important; }
@media (forced-colors: active) {
  .btn,
  .app .btn,
  html.dark-theme .btn,
  html[data-theme="aurora"] .btn,
  html.dark-theme[data-theme="aurora"] .btn { border: 1px solid ButtonText !important; }
  .btn-primary,
  .app .btn-primary,
  html.dark-theme .btn-primary,
  html[data-theme="aurora"] .btn-primary,
  html.dark-theme[data-theme="aurora"] .btn-primary { background: Highlight !important; color: HighlightText !important; border-color: Highlight !important; }
}
.app :is(.field label, .brand-label-row label, .receiving-field-label) { color: var(--text-2); font-size: 12px; line-height: 1.5; font-weight: 600; }
.page .toolbar { gap: 8px; align-items: center; }
.page .dictionary-controls { gap: 8px; }
.page .dictionary-search-wrap input { height: 100%; border-radius: 0; }
.page .cost-input-group,
.page .fixed-cost-card .cost-submit-btn { height: var(--workspace-control-height); }
.page .cost-input-group { border-radius: var(--workspace-control-radius); }
.page .cost-input-group input { height: 100%; border-radius: 0; }
.page .receiving-date-nav { height: 42px; }
.page .receiving-date-nav .receiving-today-btn { height: 34px; }
.page .date-picker-switcher,
.page .month-switch,
.page .range-picker-wrapper { height: 42px; }
.page .month-switch { border-radius: var(--workspace-control-radius); }
.page #entryRangeInput { height: 100%; border-radius: 0; }
.page :is(#entryTrashBtn, #receivingTrashBtn, #todoTrashBtn) {
  height: var(--workspace-control-height);
  min-height: var(--workspace-control-height);
  border-radius: var(--workspace-control-radius);
  padding: 0 14px;
}
.page :is(#entryTrashBtn, #receivingTrashBtn, #todoTrashBtn)[aria-pressed="true"],
.app .btn-secondary[aria-pressed="true"],
html.dark-theme .app .btn-secondary[aria-pressed="true"]:hover:not(:disabled) {
  color: var(--primary) !important;
  background: var(--primary-soft) !important;
  border-color: var(--primary) !important;
}
.page #addRecordBtn { margin-left: auto; }

/* 所有统计卡片共用图标、排版和材质，保留指标数量及辅助信息。 */
.page :is(.summary-grid, .receiving-summary-grid, .kpi-grid) { gap: var(--workspace-metric-gap); }
.page :is(.summary-card, .receiving-summary-card, .kpi-card) {
  border-radius: 12px;
  padding: 16px;
  min-height: var(--workspace-metric-height);
}
.page :is(.summary-icon, .receiving-summary-icon, .kpi-icon) {
  display: grid;
  place-items: center;
  width: var(--workspace-metric-icon-size);
  height: var(--workspace-metric-icon-size);
  border-radius: var(--workspace-control-radius);
  flex-shrink: 0;
}
.page :is(.summary-icon, .receiving-summary-icon, .kpi-icon) svg { width: 20px; height: 20px; }
.page :is(.summary-label, .receiving-summary-label, .kpi-label) { font-size: 12px; line-height: 1.5; color: var(--muted); }
.page :is(.summary-value, .receiving-summary-val, .kpi-value) { margin-top: 6px; font-size: var(--workspace-metric-font); line-height: 1.25; font-weight: 600; }
.page .kpi-num-part { font-size: inherit; font-weight: inherit; font-family: inherit; }
.page :is(.summary-value .unit, .receiving-summary-unit, .kpi-unit-part) { font-size: 12px; font-weight: 500; color: var(--muted); }
.page :is(.receiving-summary-sub, .kpi-foot) { margin-top: 6px; font-size: 12px; line-height: 1.5; color: var(--muted); }
.page .kpi-card { display: grid; grid-template-columns: minmax(0, 1fr) var(--workspace-metric-icon-size); gap: 0 10px; align-content: center; }
.page .kpi-card .kpi-top { grid-column: 1; grid-row: 1; }
.page .kpi-card .kpi-value { display: flex; align-items: baseline; grid-column: 1; grid-row: 2; flex-wrap: wrap; gap: 4px; }
.page .kpi-card .kpi-foot { grid-column: 1 / -1; grid-row: 3; }
.page .kpi-icon { grid-column: 2; grid-row: 1 / 3; align-self: center; color: var(--metric-color); background: color-mix(in srgb, var(--metric-color) 9%, transparent); }
/* 数字动画结束后仍保留完整金额及单位，避免一张卡换行撑高整排。 */
#page-stats .kpi-card .kpi-value { display: flex !important; flex-wrap: nowrap; }
#page-stats .kpi-value :is(.kpi-num-part, .kpi-unit-part) { white-space: nowrap; }
#page-stats .kpi-value .kpi-unit-part { margin-left: 0 !important; }
html[data-theme="aurora"] .page .receiving-summary-card {
  background: var(--aurora-glass);
  border-color: var(--aurora-edge);
  box-shadow: var(--aurora-shadow);
}

/* 卡片/表格空状态共享构图；整页引导保留较宽的说明空间。 */
.page :is(.empty-state, .chart-empty, .receiving-empty, .market-empty-box) {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 160px;
  padding: 24px 16px;
  margin: 0 auto;
  text-align: center;
  color: var(--muted);
  box-sizing: border-box;
}
.page :is(.empty-state-icon, .chart-empty-icon, .market-empty-illustration) {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  margin: 0 0 4px;
  flex-shrink: 0;
}
.page :is(.empty-state-icon, .chart-empty-icon) svg { width: 22px; height: 22px; }
.page :is(.empty-state, .chart-empty, .receiving-empty, .market-empty-box) :is(b, strong) { margin: 0; color: var(--text-2); font-size: 13px; line-height: 1.5; font-weight: 650; }
.page :is(.empty-state, .chart-empty, .receiving-empty, .market-empty-box) > :is(p, span:not(.empty-state-icon):not(.chart-empty-icon)) { max-width: 360px; margin: 0; font-size: 12px; line-height: 1.6; color: var(--muted); }
.page .market-empty { padding: 0; }
.page .market-empty-box { width: 100%; max-width: none; }

.page :is(.brand-tab, .settings-tab, .dictionary-type, .date-mode-btn, .view-switch-btn, .btn):focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

@media (max-width: 720px) {
  :root { --workspace-card-padding: 16px; --workspace-metric-icon-size: 28px; --workspace-metric-height: 88px; --workspace-metric-font: 20px; --workspace-metric-gap: 10px; }
  .page :is(.brand-tabs, .settings-tabs) { width: 100%; }
  .page :is(.brand-tab, .settings-tab) { flex: 1; padding: 0 10px; }
  .page .security-setting-card { gap: 16px; }
  .page .idle-editor .field { min-width: 0; }
  .page .idle-editor > .btn { flex-shrink: 0; }
  .page :is(.summary-card, .receiving-summary-card, .kpi-card) { padding: 12px; }
  .page :is(.summary-icon, .receiving-summary-icon, .kpi-icon) svg { width: 16px; height: 16px; }
  .page :is(.empty-state, .chart-empty, .receiving-empty, .market-empty-box) { min-height: 140px; padding: 20px 12px; }
  .page .search-input { font-size: 16px; }
  #page-todo .toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  #page-todo .toolbar > .custom-select { min-width: 0; width: 100%; }
  #page-todo :is(#todoSearch, #addTodoBtn) { grid-column: 1 / -1; width: 100%; }
  #page-todo .view-switch-group { width: max-content; }
  #page-todo #todoTrashBtn { width: auto; justify-self: end; }
}

/* ==========================================================================
   动效变量：新增或调整的动画统一使用以下时长与缓动，避免各处数值发散。
   ========================================================================== */
:root {
  --dur-fast: 140ms;
  --dur-base: 200ms;
  --dur-slow: 280ms;
  --dur-chart: 700ms;
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-enter: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-exit: cubic-bezier(0.4, 0, 1, 1);
  --ease-out: var(--ease-enter);
  --z-toast: 9999;
}

/* 首次进入保留分段入场；之后切页做轻柔淡入微浮，兼顾速度与顺滑感。 */
@keyframes quickPageIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes paneSwitchIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
html.quick-page-switch .page.active {
  animation: quickPageIn 180ms var(--ease-enter);
}
@media (max-width: 930px) {
  /* 移动端发货页保留纯淡入，避免 transform 影响悬浮新增按钮的 fixed 参照。 */
  html.quick-page-switch #page-entry.active {
    animation-name: pageFadeIn;
    animation-duration: var(--dur-fast);
  }
}
html.quick-page-switch .page.active :is(.page-head, .summary-grid, .kpi-grid, .toolbar, .home-getting-started, .home-grid, .dash-grid, .panel, .table-scroll, .settings-top, .settings-grid) {
  animation: none;
}

/* 桌面左侧主导航：跟随激活项平滑滑动的竖向高亮指示条。 */
@media (min-width: 931px) {
  .sidebar { position: relative; }
  .sidebar-nav-indicator {
    position: absolute;
    left: 10px;
    top: 0;
    width: 3.5px;
    height: 22px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--primary) 78%, #ffffff);
    box-shadow: 0 0 12px rgba(var(--primary-rgb), 0.45);
    opacity: 0;
    pointer-events: none;
    z-index: 2;
    transform: translate3d(0, 0, 0);
    transition: transform 260ms var(--ease-enter), opacity var(--dur-fast) var(--ease-standard);
  }
  .sidebar-nav-indicator.is-ready { opacity: 1; }
  .app.sidebar-collapsed .sidebar-nav-indicator { left: 6px; }
  html[data-theme="light-blue"] .sidebar-nav-indicator {
    background: var(--primary);
    box-shadow: 0 0 10px rgba(var(--primary-rgb), 0.35);
  }
  html[data-theme="aurora"] .sidebar-nav-indicator {
    background: linear-gradient(180deg, #8ee8df, #a8a4ff);
    box-shadow: 0 0 12px rgba(142, 232, 223, 0.5);
  }
}
@media (max-width: 930px) {
  .sidebar-nav-indicator { display: none !important; }
}

/* 全站分段控件统一滑动胶囊指示器（无 JS 时退化为原 .active 背景）。 */
.page :is(.brand-tabs, .settings-tabs, .dictionary-type-tabs, .date-mode-toggle, .view-switch-group, .receiving-view-switch, .market-segmented) {
  position: relative;
}
.page :is(.brand-tabs, .settings-tabs, .dictionary-type-tabs, .date-mode-toggle, .view-switch-group, .receiving-view-switch, .market-segmented) > button {
  position: relative;
  z-index: 1;
}
.segment-pill-indicator {
  position: absolute;
  top: 0;
  left: 0;
  border-radius: 7px;
  background: var(--workspace-segment-active);
  box-shadow: var(--shadow-xs);
  opacity: 0;
  pointer-events: none;
  z-index: 0;
  transform: translate3d(0, 0, 0);
  transition: transform 240ms var(--ease-enter), width 240ms var(--ease-enter), height 240ms var(--ease-enter), opacity var(--dur-fast) var(--ease-standard);
}
#entryDateModeToggle > .segment-pill-indicator { border-radius: 10px; }
.segment-pill-indicator.is-ready { opacity: 1; }
.has-segment-pill > button.active,
.has-segment-pill > button[aria-pressed="true"],
.has-segment-pill > button[aria-selected="true"] {
  background: transparent !important;
  box-shadow: none !important;
}
html.dark-theme .segment-pill-indicator {
  background: var(--panel);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
html[data-theme="aurora"] .segment-pill-indicator {
  background: var(--workspace-segment-active);
  box-shadow: 0 2px 10px -4px rgba(53, 68, 126, 0.28), inset 0 1px 0 var(--aurora-edge);
}

/* 登录页或启动过渡层淡出揭示工作台时抑制重叠入场动画，避免先透明后显现。 */
html.unlock-reveal .page.active { animation: none; }
html.unlock-reveal .page.active :is(.page-head, .summary-grid, .kpi-grid, .toolbar, .home-getting-started, .home-grid, .dash-grid, .panel, .table-scroll, .settings-top, .settings-grid) {
  animation: none;
}

/* 危险确认框使用更克制的进场，不做缩放回弹。 */
.confirm-overlay.confirm-danger.show .confirm-modal {
  animation: confirmCalmIn var(--dur-base) var(--ease-standard) forwards !important;
}
@keyframes confirmCalmIn {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* 提示条：带“撤销”等操作按钮时的样式。 */
.toast .toast-text { min-width: 0; }
.toast { z-index: var(--z-toast) !important; }
.toast.has-action { padding-right: 6px !important; }
.toast .toast-action {
  flex-shrink: 0;
  min-height: 28px;
  margin-left: 4px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard);
}
.toast .toast-action:hover { background: rgba(255, 255, 255, 0.24); border-color: rgba(255, 255, 255, 0.4); }
.toast .toast-action:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* 顶栏同步状态：保存中 / 已保存 / 保存失败 / 离线。 */
.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 10px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 20px;
  vertical-align: middle;
  white-space: nowrap;
}
.sync-status[hidden] { display: none; }
.sync-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.sync-status[data-state="saving"] { color: var(--primary); }
@media (prefers-reduced-motion: no-preference) {
  .sync-status[data-state="saving"] .sync-status-dot { animation: syncPulse 1s var(--ease-standard) infinite; }
}
.sync-status[data-state="saved"] { color: #15803d; }
.sync-status[data-state="error"] { color: #b42318; background: #fef3f2; }
.sync-status[data-state="offline"] { color: #b54708; background: #fffaeb; }
html.dark-theme .sync-status { background: rgba(255, 255, 255, 0.06); }
html.dark-theme .sync-status[data-state="saved"] { color: #4ade80; }
html.dark-theme .sync-status[data-state="error"] { color: #fda29b; background: rgba(240, 68, 56, 0.14); }
html.dark-theme .sync-status[data-state="offline"] { color: #fdb022; background: rgba(247, 144, 9, 0.14); }
@keyframes syncPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
@media (max-width: 560px) {
  .toast .toast-action { min-height: 44px; }
  /* 手机端只显示状态点，文字保留给读屏与悬停提示。 */
  .sync-status { margin-left: 6px; padding: 0; background: transparent !important; }
  .sync-status-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) {
  .sync-status[data-state="saving"] .sync-status-dot { animation: none; }
  .confirm-overlay.confirm-danger.show .confirm-modal { animation: none !important; opacity: 1; transform: none; }
  html.quick-page-switch .page.active,
  .brand-pane.active { animation: none !important; }
  .sidebar-nav-indicator,
  .segment-pill-indicator { transition: none !important; }
}
/* 宽表在触摸滚动之外提供统一的键盘入口，内侧描边不被面板裁掉。 */
.app :is(.table-scroll,.mini-table-wrap,.month-table-wrap,.receiving-summary-table-wrap,.market-table-scroll):focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -3px;
}

/* ==========================================================================
   ChatGPT 风格滚动条：9px 透明轨道 + 2px 内边距 5px 纤细胶囊 + 顶部渐变融入
   ========================================================================== */
:root {
  --scrollbar-thumb: rgba(0, 0, 0, 0.16);
  --scrollbar-thumb-hover: rgba(0, 0, 0, 0.34);
  --scrollbar-thumb-active: rgba(0, 0, 0, 0.48);
  --scrollbar-track: transparent;
}

html.dark-theme {
  --scrollbar-thumb: rgba(255, 255, 255, 0.18);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.36);
  --scrollbar-thumb-active: rgba(255, 255, 255, 0.52);
  --scrollbar-track: transparent;
}

@media (prefers-contrast: more) {
  :root {
    --scrollbar-thumb: rgba(0, 0, 0, 0.42);
    --scrollbar-thumb-hover: rgba(0, 0, 0, 0.68);
    --scrollbar-thumb-active: rgba(0, 0, 0, 0.82);
  }

  html.dark-theme {
    --scrollbar-thumb: rgba(255, 255, 255, 0.46);
    --scrollbar-thumb-hover: rgba(255, 255, 255, 0.72);
    --scrollbar-thumb-active: rgba(255, 255, 255, 0.88);
  }
}

@supports not selector(::-webkit-scrollbar) {
  :root,
  * {
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  }

  .category-profit-scroll,
  #recordOverlay .drawer-summary-pane {
    scrollbar-width: auto;
  }
}

/* Chromium/WebKit 下清除前置样式表中的 scrollbar-width: thin，避免回退为系统带箭头滚动条，同时不覆盖 Firefox 配色 */
@supports selector(::-webkit-scrollbar) {
  .category-profit-scroll,
  #recordOverlay .drawer-summary-pane {
    scrollbar-width: auto;
    scrollbar-color: auto;
  }
}

::-webkit-scrollbar,
.attachment-viewer .modal-body::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-button,
.attachment-viewer .modal-body::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

::-webkit-scrollbar-track,
.attachment-viewer .modal-body::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

::-webkit-scrollbar-corner,
.attachment-viewer .modal-body::-webkit-scrollbar-corner {
  background: transparent;
}

::-webkit-scrollbar-thumb,
.attachment-viewer .modal-body::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border: 2px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
  min-width: 32px;
  min-height: 32px;
}

::-webkit-scrollbar-thumb:hover,
.attachment-viewer .modal-body::-webkit-scrollbar-thumb:hover {
  background-color: var(--scrollbar-thumb-hover);
}

::-webkit-scrollbar-thumb:active,
.attachment-viewer .modal-body::-webkit-scrollbar-thumb:active {
  background-color: var(--scrollbar-thumb-active);
}

/* 紧凑下拉面板沿用同一胶囊语言，收窄轨道并留出上下圆角间距 */
:is(.custom-datalist-dropdown, .custom-select-dropdown, .period-dropdown, .receiving-datalist-pop)::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

:is(.custom-datalist-dropdown, .custom-select-dropdown, .period-dropdown, .receiving-datalist-pop)::-webkit-scrollbar-track {
  margin: 6px 0;
}

:is(.custom-datalist-dropdown, .custom-select-dropdown, .period-dropdown, .receiving-datalist-pop)::-webkit-scrollbar-thumb {
  min-height: 26px;
}

/* 桌面主内容区右侧滚动槽顶部渐变遮罩：滑块停靠最顶时由背景色渐隐融入，拉离顶部后呈现通体均匀浅灰 */
@media (min-width: 931px) {
  .main {
    position: relative;
  }

  .main::after {
    content: "";
    position: absolute;
    top: 58px;
    right: 0;
    width: 11px;
    height: 46px;
    pointer-events: none;
    z-index: 21;
    background: linear-gradient(
      to bottom,
      var(--bg) 0%,
      color-mix(in srgb, var(--bg) 76%, transparent) 38%,
      transparent 100%
    );
  }
}

@media (hover: none) and (pointer: coarse) {
  ::-webkit-scrollbar,
  .attachment-viewer .modal-body::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
  }

  .main::after {
    display: none;
  }
}
