/* 通用样式 — 参考 OMS 卡片风，纯 CSS 无框架 */
:root {
    --bg: #eef2f6;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #1e3a8a;
    --primary-light: #2563eb;
    --primary-hover: #1d4ed8;
    --border: #e8ecf1;
    --border-strong: #d1d5db;
    --danger: #b91c1c;
    --status-gray: #9ca3af;
    --status-red: #dc2626;
    --status-green: #22c55e;
    --status-yellow: #eab308;
    --radius: 10px;
    --shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary-light);
    text-decoration: none;
}

.app-main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 12px 14px 40px;
}

.app-header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.app-header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.brand {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    font-size: 13px;
}

.header-nav a {
    color: var(--muted);
}

.header-nav a.active {
    color: var(--primary);
    font-weight: 600;
}

.user-chip {
    color: var(--muted);
    font-size: 12px;
    padding: 2px 8px;
    background: var(--bg);
    border-radius: 999px;
}

/* 页面标题（居中，贴近参考图顶栏） */
.page-title-bar {
    margin: 0 0 14px;
    text-align: center;
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.02em;
}

.page-title-bar--sub {
    margin-top: 4px;
    margin-bottom: 12px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 16px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    background: var(--border);
    color: var(--text);
    transition: background 0.15s, border-color 0.15s;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-outline {
    background: #fff;
    border: 1px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background: #eff6ff;
}

.btn-edit {
    padding: 4px 12px;
    font-size: 13px;
    font-weight: 500;
    background: transparent;
    border: 1px solid var(--primary-light);
    color: var(--primary-light);
    border-radius: 6px;
}

.btn-edit.is-disabled,
.btn-edit:disabled {
    color: #9ca3af;
    border-color: #d1d5db;
    cursor: not-allowed;
    opacity: 0.65;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

.btn-block {
    width: 100%;
}

.field {
    display: block;
    margin-bottom: 14px;
}

.field span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 13px;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.field-computed .computed-value {
    display: block;
    font-size: 20px;
    font-weight: 600;
    color: var(--primary);
    padding: 8px 0;
}

.section-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 16px 14px;
    margin-bottom: 12px;
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.section-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-head h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.section-head-tools {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.section-head-editing {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.section-head-editing.hidden {
    display: none !important;
}

/* 与 .btn-edit 同形，仅配色不同 */
.btn-head-save {
    color: #1e3a6e;
    border-color: #1e3a6e;
    background: #fff;
}

.btn-head-save:active {
    background: #eef2f8;
}

.btn-head-cancel {
    color: #c45c5c;
    border-color: #e8a8a8;
    background: #fff;
}

.btn-head-cancel:active {
    background: #fef2f2;
}

.section-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.section-icon--done {
    background: #22c55e;
    color: #fff;
}

.section-icon--warn {
    background: #fef3c7;
    border: 1px solid #f59e0b;
}

.section-icon--warn .section-icon-dot {
    background: #f59e0b;
}

.section-icon--pending {
    background: #f3f4f6;
    border: 1px solid var(--border-strong);
}

.section-icon--info {
    background: #e8f1ff;
    border: 1px solid #93c5fd;
}

.section-icon--info .section-icon-dot {
    background: #3b82f6;
}

.section-icon-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--status-gray);
}

.hidden {
    display: none !important;
}

.alert {
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 13px;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
}

.alert-ok {
    background: #ecfdf5;
    color: #065f46;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    line-height: 1.4;
}

.badge-info {
    background: #e0e7ff;
    color: #3730a3;
}

.badge-warn {
    background: #ffedd5;
    color: #c2410c;
}

.badge-muted {
    background: #f3f4f6;
    color: #6b7280;
}

.badge-success {
    background: #d1fae5;
    color: #047857;
}

.dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-gray,
.status-neutral {
    background: var(--status-gray);
}

.status-red {
    background: var(--status-red);
}

.status-green {
    background: var(--status-green);
}

.status-yellow {
    background: var(--status-yellow);
}

.status-blue {
    background: #3b82f6;
}

.section-icon--alert {
    background: #fef9c3;
    border: 1px solid var(--status-yellow);
}

.section-icon--alert .section-icon-dot {
    background: var(--status-yellow);
}

.kv-list {
    margin: 0;
}

.kv-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    padding: 11px 0;
}

.kv-row + .kv-row {
    border-top: 1px solid #f3f4f6;
}

.kv-row dt {
    color: var(--muted);
    margin: 0;
    font-size: 13px;
    flex-shrink: 0;
}

.kv-row dd {
    margin: 0;
    text-align: right;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    word-break: break-all;
}

/* 备注：标签与正文同一灰底块内自然换行 */
.kv-remark-row {
    padding: 6px 0 2px;
}

.kv-row + .kv-remark-row,
.kv-remark-row + .kv-row {
    border-top: 1px solid #f3f4f6;
}

/* 备注正文：灰底块（无标签前缀），对齐 restore-sql 内边距 */
.kv-remark-block {
    display: block;
    box-sizing: border-box;
    width: 100%;
    margin: 0;
    padding: 6px 8px;
    background: #f3f4f6;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.45;
    font-weight: 400;
    color: #6b7280;
    text-align: left;
    word-break: break-word;
    white-space: pre-wrap;
}

.hint {
    color: var(--muted);
    font-size: 12px;
    margin: 4px 0 0;
}

.hint-banner {
    background: #eff6ff;
    color: #1e40af;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    margin: 10px 0 0;
}

.back-link {
    font-size: 13px;
    color: var(--muted);
    display: inline-block;
    margin-bottom: 4px;
}

.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* 利润：实收输入缩短，右侧留「分成无误」 */
.field-profit-received > span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 13px;
}

.profit-received-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 12px;
}

.profit-received-row .profit-received-input {
    flex: 0 1 auto;
    width: min(168px, 48%);
    max-width: 100%;
    min-width: 96px;
    padding: 11px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
}

.profit-split-check {
    display: inline-flex;
    align-items: center;
    align-self: center;
    gap: 8px;
    margin: 0;
    font-size: 13px;
    font-weight: 400;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    line-height: 20px;
}

.profit-split-check span {
    display: block;
    font-size: inherit;
    color: inherit;
    line-height: 20px;
}

.profit-split-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    padding: 0;
    cursor: pointer;
    accent-color: var(--primary-light);
    flex-shrink: 0;
    vertical-align: middle;
}

.profit-split-hint {
    margin: 10px 0 0;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.45;
    font-weight: 400;
    color: #1e40af;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
}

/* 筛选：待办多选（PC/手机共用结构） */
.filter-fieldset {
    margin: 0;
    padding: 0;
    border: none;
}

.filter-legend {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 8px;
    padding: 0;
}

.filter-check-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
}

/* 筛选：日期等表单项（勿用裸 label，避免误伤下拉选项行） */
.filter-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
    font-size: 13px;
    color: var(--muted);
}

.filter-field--full {
    grid-column: 1 / -1;
}

/* 筛选：下拉（单选 / 多选，PC/手机共用结构） */
.filter-dropdown {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.filter-dropdown__legend {
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
}

.filter-dropdown__trigger {
    box-sizing: border-box;
    width: 100%;
    min-height: 38px;
    padding: 8px 32px 8px 10px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: #fff;
    font-size: 14px;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.filter-dropdown__trigger[aria-expanded="true"] {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.filter-dropdown__panel--tall {
    max-height: min(58vh, 360px);
}

.filter-dropdown__panel {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    z-index: 50;
    max-height: min(52vh, 320px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 4px 0;
    background: #fff;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    box-shadow: var(--shadow);
}

.filter-dropdown__panel[hidden] {
    display: none;
}

.filter-dropdown__option {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
}

.filter-dropdown__option:hover {
    background: #f9fafb;
}

.filter-dropdown__option input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.filter-dropdown__check {
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    margin-top: 1px;
    border: 1.5px solid var(--border-strong);
    border-radius: 4px;
    background: #fff;
}

.filter-dropdown__option input:checked + .filter-dropdown__check {
    border-color: var(--primary-light);
    background: var(--primary-light) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='10' viewBox='0 0 12 10'%3E%3Cpath d='M1 5l3.5 3.5L11 1.5' stroke='%23fff' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center;
}

.filter-dropdown__text {
    flex: 1;
    min-width: 0;
    line-height: 1.35;
}

/* 详情摘要卡 */
.detail-summary-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 12px;
}

.detail-summary-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.detail-summary-divider {
    border: none;
    border-top: 1px solid #eceff3;
    margin: 10px 0 8px;
}

.detail-no {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-light);
    letter-spacing: 0.02em;
}

.detail-meta-line {
    margin: 8px 0 0;
    font-size: 13px;
    color: var(--muted);
}

.detail-remark {
    margin: 12px 0 0;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
    font-size: 13px;
    color: var(--muted);
}

.detail-remark span {
    display: block;
    font-size: 12px;
    margin-bottom: 4px;
}

.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    padding-top: calc(24px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(48px + env(safe-area-inset-bottom, 0px));
    position: relative;
    z-index: 1;
    box-sizing: border-box;
}

.login-bg {
    position: fixed;
    left: 0;
    right: 0;
    top: calc(-1 * env(safe-area-inset-top, 0px));
    bottom: calc(-1 * env(safe-area-inset-bottom, 0px));
    z-index: 0;
    background-color: #dbeafe;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.login-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(30, 58, 138, 0.18) 0%, rgba(15, 35, 75, 0.32) 100%);
}

body.ui-login-page {
    min-height: 100vh;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    background: #c7d9f0;
}

body.ui-login-page .app-main {
    max-width: none;
    margin: 0;
    padding: 0;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    background: transparent;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: rgba(255, 255, 255, 0.62);
    backdrop-filter: blur(18px) saturate(1.2);
    -webkit-backdrop-filter: blur(18px) saturate(1.2);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 16px;
    padding: 32px 28px;
    box-shadow: 0 12px 40px rgba(15, 35, 75, 0.18);
}

.login-icp {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    margin: 0;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
    text-align: center;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.88);
    text-shadow: 0 1px 2px rgba(15, 35, 75, 0.35);
}

.login-card h1 {
    margin: 0 0 4px;
    font-size: 22px;
    text-align: center;
}

.login-sub {
    text-align: center;
    color: var(--muted);
    margin: 0 0 24px;
    font-size: 13px;
}

.admin-tip {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 16px;
    font-size: 13px;
}

.admin-tip code {
    background: #f3f4f6;
    padding: 2px 4px;
    border-radius: 4px;
    word-break: break-all;
}

.restore-sql {
    display: block;
    background: #f3f4f6;
    padding: 8px;
    border-radius: 6px;
    font-size: 12px;
    word-break: break-all;
    margin: 8px 0 12px;
}

.section-danger {
    border: 1px solid #fecaca;
}

.empty {
    text-align: center;
    color: var(--muted);
    padding: 32px;
}

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

.is-negative {
    color: var(--danger) !important;
    font-weight: 600;
}
