/* =========================================================
   费用报销单系统 - 全局样式
   包含：报销单纸张样式 / 列表页样式 / 打印样式
   字体统一使用宋体（SimSun），贴近纸质单据质感
   ========================================================= */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    /* 顶部留白 25px，整体内容下移并写死；左右/底部保持 20px */
    padding: 25px 20px 20px;
    font-family: "宋体", "SimSun", "Songti SC", serif;
    background: #f0f0f0;
    color: #000;
    font-size: 14px;
}

.page {
    max-width: 820px;
    margin: 0 auto;
}

/* ---------------------- 报销单纸张 ---------------------- */
/* A4 纵向比例 210:297 ≈ 1:1.414；宽度保持 210mm 不变，高度按比例自动推导，
   任意屏幕尺寸下均由同一比例计算，保持一致。内容高于比例高度时允许撑开避免裁切。 */
.sheet {
    background: #fff;
    width: 210mm;
    max-width: 100%;
    aspect-ratio: 210 / 297;
    margin: 0 auto;
    padding: 12mm 14mm;
    border: none;
    overflow: visible;
}

.sheet-title {
    text-align: center;
    font-size: 26px;
    letter-spacing: 6px;
    margin: 0 0 14px 0;
    font-weight: bold;
}

.sheet-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 8px;
    font-size: 14px;
}

.sheet-top .company {
    font-weight: bold;
}

.sheet-top .top-right {
    white-space: nowrap;
}

.unit-tip {
    color: #555;
}

/* 日期：取消边框 */
.sheet-top input[type="date"] {
    border: none;
    background: transparent;
}

/* 表格：内部网格线 1px，外框加粗为 2px，还原纸质表单版式 */
.form-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    border: 2px solid #000;
}

.form-table th,
.form-table td {
    border-top: 1px solid #000;
    border-left: 1px solid #000;
    border-right: 1px solid #000;
    border-bottom: 1px solid #000;
    padding: 6px 8px;
    vertical-align: middle;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.form-table th.label {
    width: 135px;
    background: #fafafa;
    font-weight: bold;
    text-align: center;
    white-space: nowrap;
}

/* 审核/签字行：固定高度 81px，写死不随内容伸缩 */
.sign-cell {
    height: 81px;
}

/* 输入控件：取消下划线，仅作文本占位 */
.form-table input[type="text"],
.form-table input[type="date"] {
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 14px;
    width: 100%;
    padding: 2px 2px;
    outline: none;
}

.form-table input[type="date"] {
    width: auto;
}

/* 报销事由单元格 */
.reason-cell {
    height: 160px;
    vertical-align: top;
}

.items {
    min-height: 80px;
}

.item-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.item-index {
    width: 22px;
    flex: 0 0 22px;
    text-align: right;
}

.item-summary {
    flex: 1 1 auto;
}

.item-amount {
    flex: 0 0 120px;
    width: 120px;
}

.input-error {
    outline: 1px solid #e22 !important;
    background: #fff0f0 !important;
}

.item-del {
    flex: 0 0 auto;
}

/* 人民币符号前缀（金额前） */
.item-cur {
    flex: 0 0 auto;
    font-weight: bold;
}

/* 报销摘要 / 金额：取消下划线 */
.items .item-summary,
.items .item-amount {
    border: none;
    background: transparent;
}

.items .item-summary.input-error,
.items .item-amount.input-error {
    border: none !important;
    outline: 1px solid #e22 !important;
    background: #fff0f0 !important;
}

.item-actions {
    margin: 6px 0;
}

.agent-line {
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

.agent-line input {
    flex: 0 0 180px;
    width: 180px;
}

/* 金额展示 */
.amount-cell .amount-cn {
    margin-bottom: 6px;
    font-weight: bold;
}

.amount-cn-text {
    letter-spacing: 1px;
}

.amount-num-text {
    font-weight: bold;
}

/* ---------------------- 按钮 ---------------------- */
.btn {
    display: inline-block;
    padding: 8px 16px;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid #333;
    border-radius: 3px;
    text-decoration: none;
    line-height: 1.2;
}

.btn-primary {
    background: #1a73e8;
    color: #fff;
    border-color: #1a73e8;
}

.btn-secondary {
    background: #fff;
    color: #333;
}

.btn-danger {
    background: #fff;
    color: #c00;
    border-color: #c00;
    padding: 4px 10px;
}

.btn-link {
    background: transparent;
    border: none;
    color: #1a73e8;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.actions {
    max-width: 210mm;
    margin: 16px auto 0;
    text-align: center;
}

.msg {
    display: inline-block;
    margin-left: 12px;
    font-size: 14px;
}

.msg-ok {
    color: #178a3a;
}

.msg-error {
    color: #c00;
}

/* ---------------------- 列表页 ---------------------- */
.list-wrap {
    max-width: 1000px;
    margin: 0 auto;
    background: #fff;
    padding: 20px 24px;
    border-radius: 4px;
}

.list-title {
    font-size: 22px;
    margin: 0 0 16px;
    border-bottom: 2px solid #333;
    padding-bottom: 10px;
}

.list-toolbar {
    margin-bottom: 14px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th,
.data-table td {
    border: 1px solid #ccc;
    padding: 8px 10px;
    text-align: left;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.data-table thead th {
    background: #f2f2f2;
}

.data-table tbody tr {
    cursor: pointer;
}

.data-table tbody tr:hover {
    background: #f7fbff;
}

.table-empty {
    text-align: center;
    color: #888;
    padding: 30px 0;
}

/* 详情 / 弹层 */
.modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 30px 10px;
    overflow: auto;
    z-index: 1000;
}

.modal-mask.show {
    display: flex;
}

.modal-box {
    background: #fff;
    width: auto;
    max-width: 100%;
    padding: 0;
    border: none;
    position: relative;
    overflow: visible;
    display: flex;
    align-items: stretch;
}

/* 左侧竖向书签导航面板：仅屏幕显示，不参与打印（.no-print） */
.doc-bookmarks {
    flex: 0 0 150px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 18px 0;
    background: #f6f7f9;
    border-right: 1px solid #e3e6ea;
}

.doc-bookmark {
    padding: 14px 14px 14px 16px;
    font-size: 15px;
    line-height: 1.4;
    color: #333;
    cursor: pointer;
    border-left: 4px solid transparent;
    user-select: none;
    background: transparent;
    transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}

.doc-bookmark:hover {
    background: #eceef1;
    color: #1a73e8;
}

.doc-bookmark.is-active {
    background: #e8f0fe;
    color: #1a73e8;
    border-left-color: #1a73e8;
    font-weight: bold;
}

.doc-bookmark:focus-visible {
    outline: 2px solid #1a73e8;
    outline-offset: -2px;
}

/* 右侧打印内容区：复用原报销单纸张版式（A4 比例 + 内边距） */
.doc-sheet {
    flex: 1 1 auto;
    width: 210mm;
    max-width: 100%;
    aspect-ratio: 210 / 297;
    padding: 14mm 16mm;
    background: #fff;
    overflow: visible;
    box-sizing: border-box;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 16px;
    font-size: 22px;
    cursor: pointer;
    border: none;
    background: transparent;
}

.detail-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    margin-top: 10px;
}

.detail-table th,
.detail-table td {
    border: 1px solid #000;
    padding: 6px 8px;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.detail-items {
    margin-top: 12px;
}

.detail-items table,
.detail-items-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.detail-items th,
.detail-items td,
.detail-items-table th,
.detail-items-table td {
    border: 1px solid #000;
    padding: 6px;
    text-align: left;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.detail-actions {
    margin-top: 16px;
    text-align: center;
}

/* ---------------------- 打印样式 ---------------------- */
@media print {
    body {
        background: #fff;
        /* 同步屏幕：顶部留白 25px，使打印内容与屏幕一致下移；左右/底部沿用 0（由打印机物理边距控制） */
        padding: 25px 0 0;
    }

    /* 打印时取消左右两栏布局，仅保留表单本身（侧栏已被 .no-print 隐藏） */
    .app-layout {
        display: block;
        max-width: none;
    }

    .app-layout .page {
        flex: none;
        max-width: none;
        width: 100%;
        margin: 0;
    }

    /* 打印详情时，仅显示弹层报销单，隐藏列表本身 */
    body.printing .list-wrap {
        display: none !important;
    }

    /* 隐藏所有非打印元素 */
    .no-print,
    .actions,
    .item-actions,
    .modal-close,
    .detail-actions,
    .list-wrap .list-toolbar,
    .list-wrap .data-table thead th:last-child,
    .list-wrap .data-table tbody td:last-child {
        display: none !important;
    }

    .page,
    .sheet,
    .list-wrap {
        max-width: none;
        width: 100%;
        margin: 0;
        padding: 0;
        border: none;
    }

    /* 打印时取消弹层 flex 布局，仅保留右侧单据内容（左侧书签已被 .no-print 隐藏） */
    .modal-box {
        display: block;
        max-width: none;
        width: 100%;
        margin: 0;
        padding: 0;
        border: none;
    }

    /* 单据内容区打印时占满宽度，沿用原报销单打印内边距，取消 A4 比例强制高度 */
    .doc-sheet {
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 12mm 14mm;
        aspect-ratio: auto;
        box-sizing: border-box;
    }

    .sheet {
        border: none;
        padding: 12mm 14mm;
    }

    /* 打印列表详情弹层时，仅显示弹层内容 */
    .modal-mask.show {
        position: static;
        display: block !important;
        background: #fff;
        padding: 0;
    }

    .modal-mask:not(.show) {
        display: none !important;
    }

    /* 弹层内打印：隐藏遮罩背景（内边距由 .doc-sheet 接管） */
    .modal-mask.show .modal-box {
        border: none;
        padding: 0;
    }
}

/* =========================================================
   「我的」模块（右侧侧栏，位于白色 A4 纸张之外，不参与打印）
   ========================================================= */
.app-layout {
    max-width: 1160px;
    margin: 0 auto;
    display: flex;
    align-items: flex-start;
    gap: 24px;
}

/* 左侧报销单容器在布局内不再自行居中 */
.app-layout .page {
    margin: 0;
    flex: 0 0 820px;
    max-width: 820px;
}

/* 右侧「我的」面板：取消卡片边框/阴影/背景，保持扁平 */
/* 宽度随内容自适应（align-self: flex-start + 子项 fit-content），不再统一 320px */
/* 整体下移 60px：margin-top 决定初始位置，sticky top 同步 +60（25→85）避免滚动时跳动 */
.my-panel {
    flex: 0 1 auto;
    align-self: flex-start;
    width: auto;
    min-width: 0;
    margin-top: 60px;
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
    position: sticky;
    top: 85px;
    font-family: "宋体", "SimSun", "Songti SC", serif;
    box-sizing: border-box;
}

/* 折叠项容器：宽度适配文字内容，不统一宽度（收起时按标题文字，展开时按内容） */
.my-acc {
    margin-bottom: 12px;
    width: -moz-fit-content;
    width: fit-content;
    max-width: 100%;
    min-width: 0;
}

/* 折叠标题（可点击文字）：灰色背景 + 黑色文字 */
.my-head {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    background: #e8e8e8;
    color: #000;
    border: none;
    border-radius: 12px;
    padding: 4px 0.5em;
    margin: 0;
    cursor: pointer;
    font-family: inherit;
    font-size: 15px;
    font-weight: bold;
    text-align: left;
    line-height: 1.3;
    transition: background 150ms ease;
}
.my-head:hover { background: #dedede; }
.my-head:focus-visible {
    outline: 2px solid #1a73e8;
    outline-offset: 2px;
}
/* 展开时标题仅保留上方圆角，与下方展开区无缝拼接；收起时四角全圆 */
.my-head.open {
    border-radius: 12px 12px 0 0;
}

/* 折叠展开区：灰色背景 + 黑色文字；左右内边距为半个字高（0.5em）
   收起/展开动画：max-height + opacity 过渡。max-height 的具体值由 JS 按内容实测写入，
   展开完成后再置为 none，以便内容后续增减（如新增账户、出现错误提示）不被裁切。
   偏好「减少动态效果」时由 JS 直接切换状态、不走过渡。 */
.my-body {
    background: #f2f2f2;
    color: #000;
    padding: 0.5em;
    border-radius: 0 0 12px 12px;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
}
.my-body.is-open { opacity: 1; }

/* 折叠区内「添加账户」按钮 */
.my-add-btn {
    margin: 12px 0 0;
}

/* 个人信息展示 */
.my-field {
    display: flex;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #ddd;
}
.my-field:last-child { border-bottom: none; }

.my-label {
    width: 56px;
    color: #444;
    flex: 0 0 56px;
}

.my-value {
    flex: 1 1 auto;
    word-break: break-all;
}

/* 表单行（登录 / 编辑 / 添加共用） */
.my-form-row {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-size: 14px;
}
.my-form-row > span {
    width: 64px;
    flex: 0 0 64px;
    color: #333;
}
.my-form-row input {
    flex: 1 1 auto;
    padding: 8px 10px;
    border: 1px solid #bbb;
    border-radius: 4px;
    background: #fff;
    color: #000;
    font-family: inherit;
    font-size: 14px;
    width: 100%;
    box-sizing: border-box;
}
.my-form-row input:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 3px rgb(26 115 232 / 0.12);
}

.my-form-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}
.my-form-actions .btn {
    font-size: 13px;
    padding: 7px 14px;
}

.my-tip {
    font-size: 12px;
    margin: 6px 0 0;
    min-height: 16px;
}
.my-tip-ok { color: #178a3a; }
.my-tip-err { color: #c00; }

/* 银行账户列表 */
.my-bank-list {
    list-style: none;
    margin: 0 0 8px;
    padding: 0;
}
.my-bank-item {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 9px 11px;
    margin-bottom: 8px;
    background: #fff;
}
.my-bank-item .bank-name {
    font-weight: bold;
    color: #000;
}
.my-bank-item .bank-sub {
    color: #444;
    font-size: 12px;
    margin-top: 2px;
    word-break: break-all;
}
.my-bank-item .bank-actions {
    margin-top: 6px;
    display: flex;
    gap: 8px;
}
.my-bank-item .bank-actions button {
    font-size: 12px;
    padding: 4px 10px;
}
.my-bank-empty {
    color: #666;
    font-size: 13px;
    padding: 6px 0;
}

/* 表单内「选择已保存账户」控件 */
.bank-select-wrap {
    margin-bottom: 6px;
    font-size: 13px;
    color: #555;
}

.bank-select-wrap select {
    font-family: inherit;
    font-size: 13px;
    padding: 4px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    max-width: 100%;
}

/* 未登录：左侧表单置灰不可编辑 */
.form-table input:disabled,
.form-table select:disabled,
.sheet-top input:disabled {
    background: #f2f2f2;
    color: #9a9a9a;
    cursor: not-allowed;
}
.item-del:disabled { opacity: .5; pointer-events: none; }

/* 未登录提示条 */
.login-hint {
    max-width: 210mm;
    margin: 14px auto 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: #fff8e1;
    border: 1px solid #f0d98c;
    color: #7a5b00;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 14px;
}
.login-hint[hidden] { display: none; }
.btn-sm { padding: 5px 12px; font-size: 13px; }

/* 收款账户：未登录提示 / 已登录工作区 切换 */
.bank-guest {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #000;
    font-size: 14px;
}
.bank-guest[hidden],
.bank-work[hidden] { display: none; }

/* 窄屏：侧栏移至下方并占满宽度，字号略放大增强可读性 */
@media (max-width: 900px) {
    .app-layout {
        flex-direction: column;
        gap: 16px;
    }
    .app-layout .page,
    .my-panel {
        flex: 1 1 auto;
        width: 100%;
        max-width: 100%;
        align-self: stretch;
    }
    .my-panel {
        position: static;
        /* 移动端为上下堆叠，无“右侧”概念；取消 60px 下移，仅保留 16px 布局间距 */
        margin-top: 0;
    }
    /* 移动端：卡片占满宽度以保证可读性，左右内边距仍为半个字高 */
    .my-acc {
        width: 100%;
    }
    .my-head {
        font-size: 16px;
        padding: 4px 0.5em;
    }
    .my-body {
        padding: 0.5em;
    }
}

/* 窄屏：竖向书签改为顶部横向排列，避免挤压单据内容；单据内容取消 A4 比例强制高度 */
@media (max-width: 720px) {
    .modal-box {
        flex-direction: column;
    }
    .doc-bookmarks {
        flex: 0 0 auto;
        flex-direction: row;
        gap: 0;
        padding: 8px 0;
        border-right: none;
        border-bottom: 1px solid #e3e6ea;
        overflow-x: auto;
    }
    .doc-bookmark {
        white-space: nowrap;
        border-left: none;
        border-bottom: 4px solid transparent;
        padding: 10px 14px;
    }
    .doc-bookmark.is-active {
        border-left: none;
        border-bottom-color: #1a73e8;
    }
    .doc-sheet {
        width: 100%;
        aspect-ratio: auto;
        padding: 10mm 8mm;
    }
}
