/* ============================================================
   站点应用层样式（LinSuYo kdesign 主题配套）
   仅放报表网格等应用特有样式；组件样式一律用 linsuyo-kd.css 的
   lsy-* 类名契约，令牌取 --lsy-*（夜间默认 / data-lsy-theme="light" 白天）。
   ============================================================ */

/* ===== 应用主区（navbar 之下、footer 之上） ===== */
.app-main {
    flex: 1;
    width: 100%;
    padding: var(--lsy-sp-6);
    box-sizing: border-box;
}

/* ===== 报表页 ===== */
.report-page {
    display: flex;
    flex-direction: column;
}

.report-pageheader {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--lsy-sp-3);
    flex-wrap: wrap;
    margin-bottom: var(--lsy-sp-4);
    padding-bottom: var(--lsy-sp-3);
    border-bottom: 1px solid var(--lsy-border);
}

.report-pageheader__title {
    font-size: 18px;
    font-weight: 500;
    margin: 0;
    color: var(--lsy-text);
}

.report-pageheader__desc {
    font-size: 12px;
    color: var(--lsy-muted);
}

/* ===== 查询卡片 ===== */
.query-card {
    /* 卡片内边距归零：由 body 提供统一留白，避免卡片 24px + body 16px 双层堆叠 */
    padding: 0;
}

.query-card .lsy-card__body {
    display: flex;
    align-items: flex-end;
    gap: var(--lsy-sp-3);
    flex-wrap: wrap;
    padding: var(--lsy-sp-3) var(--lsy-sp-4);
}

.query-field {
    display: flex;
    flex-direction: column;
    gap: var(--lsy-sp-1);
}

.query-field__label {
    font-size: 11px;
    color: var(--lsy-muted);
}

.query-field__range {
    display: flex;
    align-items: center;
    gap: var(--lsy-sp-2);
}

.query-field__range .lsy-input {
    width: 150px;
}

.query-field__separator {
    color: var(--lsy-dim);
    font-size: 12px;
}

/* ===== 结果表格（台账专用网格） =====
   基于 .lsy-table 令牌扩展：双行分组表头、sticky、采购蓝/销售绿分组。
   38 列台账容易“糊成一片”，这里放宽行高与单元格留白、补斑马纹与 hover，
   并用分组色带 + 分组起始列强调线做视觉分段。 */
.report-table {
    /* 分组表头行高：第二行表头 sticky 的 top 偏移取它 */
    --report-group-head-h: 42px;
    width: auto;
    min-width: 100%;
    /* separate + 0 间距：sticky 表头在收缩时边框不丢 */
    border-collapse: separate;
    border-spacing: 0;
    white-space: nowrap;
    font-size: 13px;
    line-height: 1.6;
    font-variant-numeric: tabular-nums;
}

.report-table th,
.report-table td {
    border-right: 1px solid var(--lsy-border);
}

.report-table th:last-child,
.report-table td:last-child {
    border-right: 0;
}

/* 表头：两行分别 sticky（第一行分组、第二行字段） */
.report-table thead th {
    position: sticky;
    z-index: 5;
    padding: 10px var(--lsy-sp-4);
    background: var(--lsy-s2);
    color: var(--lsy-muted);
    font-size: 12px;
    font-weight: 500;
    line-height: 20px;
    text-align: left;
    border-bottom: 1px solid var(--lsy-border);
}

.report-table thead tr:first-child th {
    top: 0;
    z-index: 6;
    height: var(--report-group-head-h);
    padding-top: 0;
    padding-bottom: 0;
}

.report-table thead tr:nth-child(2) th {
    /* -1px：与分组条重叠 1px，避免缩放取整出现漏数据的缝 */
    top: calc(var(--report-group-head-h) - 1px);
}

/* 列筛选单元格：纵向堆叠的紧凑控件（列头漏斗气泡内复用） */
.filter-cell__controls {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-cell .lsy-input,
.filter-cell .lsy-select {
    width: 100%;
    height: 26px;
    padding: 2px 6px;
    font-size: 11px;
    line-height: 20px;
}

.filter-cell .lsy-select { padding-right: 22px; background-position: right 6px center; }

/* 数字输入框去掉上下箭头，避免 26px 高度内被挤压 */
.filter-cell input[type="number"]::-webkit-outer-spin-button,
.filter-cell input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.filter-cell input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* ===== 列头筛选漏斗按钮（第二行表头每个列标题右侧） ===== */
.th-filter-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-left: 4px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--lsy-radius-sm);
    background: transparent;
    color: var(--lsy-muted);
    opacity: .55;
    cursor: pointer;
    vertical-align: middle;
    transition: background .15s ease, color .15s ease, opacity .15s ease;
}

.th-filter-btn:hover {
    opacity: 1;
    color: var(--lsy-text);
    background: var(--lsy-s4);
}

.th-filter-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(85, 130, 243, .35);
}

/* 该列已有生效条件：漏斗高亮为主色 */
.th-filter-btn.is-active {
    opacity: 1;
    color: var(--lsy-coral);
    background: rgba(85, 130, 243, .12);
}

.th-filter-btn svg {
    display: block;
    width: 11px;
    height: 11px;
}

/* ===== 列筛选小气泡（贴着漏斗按钮，fixed + JS 贴位） ===== */
.filter-popover {
    position: fixed;
    top: 0;
    left: 0;
    /* 高于网页全屏（.result-card.web-fullscreen z-index: 200） */
    z-index: 300;
    display: flex;
    flex-direction: column;
    width: min(300px, calc(100vw - 16px));
    background: var(--lsy-s1);
    border: 1px solid var(--lsy-border);
    border-radius: var(--lsy-radius);
    box-shadow: 0 10px 28px rgba(0, 0, 0, .28);
}

.filter-popover[hidden] { display: none; }

/* 小箭头：对准漏斗中心（left 由 JS 写入 --filter-arrow-x） */
.filter-popover::before {
    content: "";
    position: absolute;
    top: -6px;
    left: var(--filter-arrow-x, 12px);
    width: 12px;
    height: 12px;
    margin-left: -6px;
    background: var(--lsy-s1);
    border-top: 1px solid var(--lsy-border);
    border-left: 1px solid var(--lsy-border);
    transform: rotate(45deg);
}

.filter-popover--above::before {
    top: auto;
    bottom: -6px;
    border-top: 0;
    border-left: 0;
    border-right: 1px solid var(--lsy-border);
    border-bottom: 1px solid var(--lsy-border);
}

.filter-popover__header {
    display: flex;
    align-items: baseline;
    gap: var(--lsy-sp-2);
    padding: var(--lsy-sp-2) var(--lsy-sp-3);
    border-bottom: 1px solid var(--lsy-border);
}

.filter-popover__title {
    font-size: 12px;
    font-weight: 500;
    color: var(--lsy-text);
}

.filter-popover__group {
    font-size: 11px;
    color: var(--lsy-muted);
}

.filter-popover__body {
    padding: var(--lsy-sp-3);
}

/* 只显示当前列那一块（.filter-cell 无 display 规则，hidden 原生生效；此处显式兜底） */
.filter-popover .filter-cell[hidden] { display: none; }

.filter-popover__footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--lsy-sp-2);
    padding: var(--lsy-sp-2) var(--lsy-sp-3);
    border-top: 1px solid var(--lsy-border);
}

.report-table th.th-purchase,
.report-table th.th-sales {
    text-align: center;
    font-weight: 500;
    letter-spacing: .06em;
    color: #fff;
}

.report-table th.th-purchase { background: var(--lsy-coral); }
.report-table th.th-sales { background: var(--lsy-success); }

.report-table td.num,
.report-table th.num {
    text-align: right;
}

/* 行：斑马纹 + hover 高亮（hover 需压过斑马纹，故写在后面） */
.report-table tbody tr {
    background: var(--lsy-s1);
    transition: background .15s ease;
}

.report-table tbody tr:nth-child(even) { background: var(--lsy-s2); }
.report-table tbody tr:hover { background: rgba(85, 130, 243, .14); }

html[data-lsy-theme="light"] .report-table tbody tr:hover { background: #EAF1FF; }

.report-table tbody td {
    padding: 10px var(--lsy-sp-4);
    border-bottom: 1px solid var(--lsy-border);
    vertical-align: middle;
}

.report-table tbody tr:last-child td { border-bottom: 0; }

/* 分组起始列：左侧色条，横向滚动时也能看清采购 / 销售分界 */
.report-table .group-start { border-left: 2px solid var(--lsy-border); }
.report-table .group-start--purchase { border-left-color: var(--lsy-coral); }
.report-table .group-start--sales { border-left-color: var(--lsy-success); }

/* 汇总列（利润 / 部门）与销售明细之间的分隔线 */
.report-table .summary-start { border-left: 1px solid var(--lsy-s4); }

/* ===== 报表分页条 ===== */
.report-pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--lsy-sp-3);
    flex-wrap: wrap;
    padding: var(--lsy-sp-3) var(--lsy-sp-6);
    border-top: 1px solid var(--lsy-border);
}

.report-pager__info {
    font-size: 12px;
    color: var(--lsy-dim);
}

.report-pager__controls {
    display: flex;
    align-items: center;
    gap: var(--lsy-sp-2);
}

.report-pager__label {
    font-size: 11px;
    color: var(--lsy-muted);
    white-space: nowrap;
}

.report-pager__size {
    width: 76px;
}

/* 网页全屏 */
.result-card.web-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 200;
    margin: 0;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    background: var(--lsy-s1);
}

.result-card.web-fullscreen .lsy-protable__toolbar {
    flex: none;
}

.result-card.web-fullscreen .lsy-table-wrap {
    flex: 1;
    min-height: 0;
    max-height: none !important;
    overflow: auto !important;
}

.result-card.web-fullscreen .report-pager {
    margin-top: auto;
}

.result-card .lsy-table-wrap {
    max-height: 70vh;
}

/* ===== 表单行（Razor 页面通用） ===== */
.form-inline-row {
    display: flex;
    align-items: flex-end;
    gap: var(--lsy-sp-3);
    flex-wrap: wrap;
}

.form-inline-row .lsy-field {
    margin-bottom: 0;
    min-width: 150px;
}

/* ===== 筛选表单（紧凑单行）：字段定宽，按钮组行内右贴 ===== */
.filter-form {
    display: flex;
    align-items: flex-end;
    gap: var(--lsy-sp-3);
    flex-wrap: wrap;
}

.filter-form .lsy-field {
    margin-bottom: 0;
    min-width: 0;
}

.filter-form .lsy-field input[type="date"] {
    width: 150px;
}

.filter-form__field--user input {
    width: 150px;
}

.filter-form__field--select {
    width: 150px;
}

/* 按钮组：不套 label 字段结构，与输入框底部对齐，行内排布 */
.filter-form__actions {
    display: flex;
    align-items: center;
    gap: var(--lsy-sp-2);
    margin-left: auto;
}

/* 窄屏兜底：塞不下时允许整组换行，按钮仍保持同组一行 */
@media (max-width: 1100px) {
    .filter-form__actions {
        margin-left: 0;
    }
}

/* ===== 登录页（布局内自适应高度） ===== */
.app-login {
    min-height: calc(100vh - 160px);
}

/* ===== 通用小工具 ===== */
.app-text-muted { color: var(--lsy-muted); }
.app-text-danger { color: var(--lsy-danger); }

/* 校验摘要：asp-validation-summary 始终渲染空 div，无错误时隐藏 */
.lsy-alert:empty { display: none; }
.lsy-alert.validation-summary-valid { display: none; }

/* ===== 导航栏右侧个人信息（无边框） =====
   复用 .lsy-btn 的尺寸与字体，只去掉边框与底色，hover 时才给一层浅底 */
.lsy-navbar__user.lsy-btn {
    padding-inline: var(--lsy-sp-1);
    border-color: transparent;
    background: transparent;
    color: var(--lsy-text);
}

.lsy-navbar__user.lsy-btn:hover {
    border-color: transparent;
    background: var(--lsy-s2);
}

.lsy-navbar__user .lsy-avatar {
    width: 24px;
    height: 24px;
    font-size: 11px;
}

/* ===== 管理中心顶栏个人信息（无边框） =====
   .lsy-admin__user 在 linsuyo-kd.css 中只有布局样式，button 的默认
   边框 / 底色会透出来；这里重置为无边框透明底，hover 才给浅色底 */
.lsy-admin__user {
    padding: var(--lsy-sp-1) var(--lsy-sp-2);
    border: 0;
    border-radius: var(--lsy-radius-sm);
    background: transparent;
    color: var(--lsy-text);
    font-family: var(--lsy-font-ui);
    cursor: pointer;
    transition: background .18s ease;
}

.lsy-admin__user:hover { background: var(--lsy-s2); }

.lsy-admin__user:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(85, 130, 243, .25);
}

/* ===== 页面骨架：footer 落地 ===== */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-main {
    flex: 1 0 auto;
}

/* Admin 主区内 footer 落地（紧凑版） */
.lsy-admin__main .lsy-footer {
    flex: none;
    margin-top: 0;
    padding: var(--lsy-sp-3) var(--lsy-sp-6);
    border-top: 1px solid var(--lsy-border);
    background: var(--lsy-s1);
}

/* Admin 内容区小标题 */
.app-section-title {
    font-size: 12px;
    font-weight: 500;
    color: var(--lsy-text);
    margin: 0 0 var(--lsy-sp-3);
}

/* ============================================================
   核对页（应付/应收）+ 服务端分页链接样式
   复用 lsy-* 令牌；仅补应用特有布局。
   ============================================================ */

/* 服务端分页：禁用态链接（无 JS 时不误导点击） */
.lsy-page-btn.is-disabled {
    opacity: .4;
    cursor: not-allowed;
    pointer-events: none;
}

/* ===== 核对页：指标卡 ===== */
.reconcile-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--lsy-sp-3);
    margin-bottom: var(--lsy-sp-4);
}

@media (max-width: 900px) {
    .reconcile-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.reconcile-metric {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--lsy-sp-3) var(--lsy-sp-4);
    background: var(--lsy-s1);
    border: 1px solid var(--lsy-border);
    border-radius: var(--lsy-radius-sm);
}

.reconcile-metric__label {
    font-size: 11px;
    color: var(--lsy-muted);
}

.reconcile-metric__value {
    font-family: var(--lsy-font-display);
    font-size: 20px;
    font-variant-numeric: tabular-nums;
    color: var(--lsy-text);
}

.reconcile-metric__hint {
    font-size: 11px;
    color: var(--lsy-dim);
}

/* ===== 核对页：分块与表格 ===== */
.reconcile-block {
    margin-bottom: var(--lsy-sp-5);
}

.reconcile-block > .lsy-protable__title {
    margin-bottom: var(--lsy-sp-2);
}

.reconcile-table {
    /* 单行表头：sticky 只需 top: 0 */
    --report-group-head-h: 0px;
}

.reconcile-table thead th {
    top: 0;
}

.reconcile-table tbody td {
    font-size: 12px;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 匹配结果标签 */
.reconcile-tag {
    display: inline-block;
    padding: 1px var(--lsy-sp-2);
    border-radius: var(--lsy-radius-sm);
    font-size: 11px;
    border: 1px solid transparent;
    white-space: nowrap;
}

.reconcile-tag--ok {
    color: var(--lsy-success);
    border-color: rgba(85, 130, 243, .35);
    background: rgba(85, 130, 243, .08);
}

.reconcile-tag--warn {
    color: var(--lsy-warning, #d98324);
    border-color: rgba(217, 131, 36, .35);
    background: rgba(217, 131, 36, .08);
}

.reconcile-tag--danger {
    color: var(--lsy-danger);
    border-color: rgba(220, 80, 80, .35);
    background: rgba(220, 80, 80, .08);
}

/* 单行核对用：暂估链·单据级（介于分录级与订单兜底之间） */
.reconcile-tag--info {
    color: var(--lsy-info, #7c5cd6);
    border-color: rgba(124, 92, 214, .35);
    background: rgba(124, 92, 214, .08);
}

/* ===== 单行核对：报表行「核对」列（第 39 列） ===== */
.report-table thead tr:first-child th.th-ops {
    /* rowspan=2 跨两行表头：放开分组条 42px 高度并恢复内边距、垂直居中 */
    height: auto;
    padding: 10px var(--lsy-sp-4);
    vertical-align: middle;
    text-align: center;
}

.report-table td.ops {
    text-align: center;
    white-space: nowrap;
    /* 与部门列（汇总区）之间的分隔，对齐 summary-start 视觉 */
    border-left: 1px solid var(--lsy-s4);
}

.report-table td.ops .row-reconcile-link {
    color: var(--lsy-primary, #5582f3);
    font-weight: 500;
}

.report-table td.ops .row-reconcile-link:hover {
    text-decoration: underline;
}

/* ============================================================
   单行核对页：分段标题放大 + 分段边界强化
   仅作用于 .report-page--row-reconcile（BusinessSummaryRowReconcile），
   不影响「核对数据」页与其它报表页；颜色全部走 --lsy-* 令牌，自动适配明暗主题。
   ============================================================ */

/* 页标题：18px → 22px，与分段标题拉开层级 */
.report-page--row-reconcile .report-pageheader__title {
    font-size: 22px;
}

/* 顶层分段（业务单据上下文 / 应付侧 / 应收侧）：卡片化 + 左侧主色带 */
.report-page--row-reconcile > .reconcile-block {
    padding: var(--lsy-sp-4);
    border: 1px solid var(--lsy-border);
    border-left: 3px solid var(--lsy-coral);
    border-radius: var(--lsy-radius);
    background: var(--lsy-s1);
    margin-bottom: var(--lsy-sp-5);
}

/* 顶层分段标题：17px + 下分隔线 */
.report-page--row-reconcile > .reconcile-block > .lsy-protable__title {
    font-size: 17px;
    padding-bottom: var(--lsy-sp-2);
    margin-bottom: var(--lsy-sp-3);
    border-bottom: 1px solid var(--lsy-border);
}

/* 内部分段（侧面板内的小标题）：15px + 灰色左标记，与顶层区分 */
.report-page--row-reconcile .reconcile-block .reconcile-block {
    margin-bottom: var(--lsy-sp-4);
}

.report-page--row-reconcile .reconcile-block .reconcile-block > .lsy-protable__title {
    font-size: 15px;
    margin-bottom: var(--lsy-sp-2);
    padding-left: var(--lsy-sp-2);
    border-left: 3px solid var(--lsy-s4);
}

/* 卡片内的指标块提亮一档，避免与卡片底色糊在一起 */
.report-page--row-reconcile .reconcile-metric {
    background: var(--lsy-s2);
}

/* ===== 单行核对：单据号（金蝶 Cosmic 超链接） ===== */
.reconcile-link {
    color: var(--lsy-primary, #5582f3);
    font-weight: 500;
    word-break: break-all;
}

.reconcile-link:hover {
    text-decoration: underline;
}

/* 指标卡内链接跟随数值字号（20px），不被 12px 表格字号压小 */
.reconcile-metric__value .reconcile-link {
    font-size: inherit;
}

/* ===== 报表查询：业务单元下拉多选 ===== */
.org-select {
    position: relative;
    min-width: 260px;
}

.org-select__toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--lsy-sp-2);
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.org-select__toggle::after {
    content: "▾";
    color: var(--lsy-muted);
}

.org-select__panel {
    position: absolute;
    z-index: 20;
    top: calc(100% + 4px);
    left: 0;
    width: 320px;
    max-width: 80vw;
    padding: var(--lsy-sp-2);
    background: var(--lsy-s1);
    border: 1px solid var(--lsy-border);
    border-radius: var(--lsy-radius-sm);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
}

.org-select__search {
    width: 100%;
    margin-bottom: var(--lsy-sp-2);
}

.org-select__actions {
    display: flex;
    gap: var(--lsy-sp-2);
    margin-bottom: var(--lsy-sp-2);
}

.org-select__list {
    max-height: 260px;
    overflow-y: auto;
}

.org-select__item {
    display: flex;
    align-items: center;
    gap: var(--lsy-sp-2);
    padding: 4px var(--lsy-sp-2);
    border-radius: var(--lsy-radius-sm);
    font-size: 12px;
    line-height: 1.5;
    word-break: break-all;
    cursor: pointer;
}

.org-select__item:hover {
    background: var(--lsy-s2);
}

.org-select__empty {
    padding: var(--lsy-sp-3);
    font-size: 12px;
    color: var(--lsy-muted);
}

/* ===== 核对页侧边抽屉（用户设置：核对页面打开方式） ===== */
.reconcile-drawer {
    position: fixed;
    inset: 0;
    /* 高于网页全屏（.result-card.web-fullscreen z-index: 200），保证全屏时抽屉仍覆盖在最上层 */
    z-index: 300;
}

.reconcile-drawer[hidden] {
    display: none;
}

.reconcile-drawer__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .45);
}

.reconcile-drawer__panel {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
    /* 宽度可由左边缘拖拽改变，JS 写入 --reconcile-drawer-width；未设置时用默认值 */
    width: var(--reconcile-drawer-width, min(1100px, 92vw));
    min-width: min(360px, 100vw);
    max-width: calc(100vw - 24px);
    background: var(--lsy-s1);
    border-left: 1px solid var(--lsy-border);
    box-shadow: -8px 0 24px rgba(0, 0, 0, .18);
}

/* 左边缘拖拽条：改变抽屉宽度（双击恢复默认，方向键微调） */
.reconcile-drawer__resizer {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    width: 8px;
    height: 100%;
    margin-left: -4px;
    cursor: col-resize;
    touch-action: none;
}

.reconcile-drawer__resizer::after {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 100%;
    margin-left: -1px;
    background: transparent;
    transition: background .15s ease;
}

.reconcile-drawer__resizer:hover::after,
.reconcile-drawer__resizer:focus-visible::after,
body.reconcile-drawer-resizing .reconcile-drawer__resizer::after {
    background: var(--lsy-primary, #5582f3);
}

.reconcile-drawer__resizer:focus-visible {
    outline: none;
}

body.reconcile-drawer-resizing {
    cursor: col-resize;
    user-select: none;
}

body.reconcile-drawer-resizing .reconcile-drawer__frame {
    pointer-events: none;
}

.reconcile-drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--lsy-sp-3);
    padding: var(--lsy-sp-3) var(--lsy-sp-4);
    border-bottom: 1px solid var(--lsy-border);
}

.reconcile-drawer__title {
    font-weight: 600;
}

.reconcile-drawer__actions {
    display: flex;
    gap: var(--lsy-sp-2);
}

.reconcile-drawer__frame {
    flex: 1;
    width: 100%;
    border: 0;
    background: var(--lsy-s1);
}

/* ===== 个人中心：设置项内联控件 ===== */
.app-setting-inline {
    display: inline-flex;
    align-items: center;
    gap: var(--lsy-sp-2);
    font-size: 13px;
}