:root {
    --primary: #1677FF;
    --success: #00B42A;
    --warning: #FF7D00;
    --danger: #F53F3F;
    --text-1: #1D2129;
    --text-2: #4E5969;
    --text-3: #86909C;
    --line: #E5E6EB;
    --bg: #F2F3F5;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: PingFang SC, Microsoft YaHei, sans-serif;
    background: var(--bg);
    color: var(--text-1);
}

.page {
    max-width: 375px;
    margin: 0 auto;
    padding: 16px 16px 34px;
}

.card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px;
}

.card + .card {
    margin-top: 12px;
}

h1 {
    margin: 0 0 8px;
    font-size: 20px;
}

h2 {
    margin: 0 0 10px;
    font-size: 16px;
}

p {
    margin: 0;
    color: var(--text-3);
    line-height: 1.45;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.input {
    width: 100%;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 12px;
    color: var(--text-1);
    background: #fff;
}

.input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.12);
}

.input[disabled] {
    background: #f7f8fa;
    color: #c9cdd4;
}

.textarea {
    width: 100%;
    min-height: 88px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text-1);
    background: #fff;
    font: inherit;
    resize: vertical;
    line-height: 1.45;
}

.textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.12);
}

.dropdown-wrap {
    position: relative;
}

.dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 240px;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 8px 18px rgba(29, 33, 41, 0.12);
    z-index: 40;
}

.option {
    width: 100%;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: #fff;
    text-align: left;
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-1);
}

.option:last-child {
    border-bottom: 0;
}

.tag {
    font-size: 12px;
    color: var(--text-2);
    background: #f2f3f5;
    border-radius: 6px;
    padding: 2px 8px;
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.btn {
    height: 44px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-secondary {
    background: #fff;
    border-color: var(--primary);
    color: var(--primary);
}

.btn-danger {
    background: #fff;
    border-color: var(--danger);
    color: var(--danger);
}

.btn:disabled {
    background: #f2f3f5;
    color: #c9cdd4;
    border-color: #f2f3f5;
}

.hint {
    font-size: 12px;
    color: var(--text-3);
}

.error {
    color: var(--danger);
    font-size: 13px;
}

.success {
    color: var(--success);
    font-size: 13px;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.photo-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px;
}

.product-item {
    position: relative;
    padding-top: 24px;
}

.product-close-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 50%;
    background: #f2f3f5;
    color: #4e5969;
    font-size: 16px;
    line-height: 22px;
    padding: 0;
}

.photo-item img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 6px;
}

.row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.receipt-main {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
}

.receipt-thumb-btn {
    position: relative;
    width: 104px;
    border: 0;
    border-radius: 8px;
    padding: 0;
    background: transparent;
    overflow: hidden;
}

.receipt-thumb-image {
    width: 100%;
    aspect-ratio: 3 / 5;
    object-fit: cover;
    border-radius: 8px;
    display: block;
}

.receipt-thumb-tag {
    position: absolute;
    left: 6px;
    right: 6px;
    bottom: 6px;
    height: 20px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 11px;
    line-height: 20px;
    text-align: center;
}

.receipt-fields .input {
    height: 40px;
}

.amount-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 28px;
}

.amount-value {
    font-size: 15px;
    color: var(--text-1);
    word-break: break-all;
}

.input-readonly {
    background: #f6f8fc;
    color: #667085;
    opacity: 1;
    cursor: not-allowed;
}

.total-receipt-item {
    position: relative;
    max-width: 160px;
}

.total-receipt-grid {
    display: flex;
    justify-content: center;
}

.section-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.section-title-row h2 {
    margin: 0;
}

.section-title-action {
    height: 30px;
    border: 1px solid #ff4d4f;
    border-radius: 999px;
    background: #fff;
    color: #ff4d4f;
    font-size: 12px;
    padding: 0 12px;
}

.section-title-action:disabled {
    opacity: 0.45;
}

.toggle-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.toggle-btn {
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text-2);
    font-size: 14px;
}

.toggle-btn.active {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(22, 119, 255, 0.08);
}

.flow-candidates {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.flow-candidates .btn {
    height: 36px;
    padding: 0 12px;
}

.json {
    background: #111827;
    color: #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 280px;
    overflow: auto;
    font-size: 12px;
    line-height: 1.5;
}

.capture-page {
    max-width: 100%;
    min-height: 100vh;
    padding: 0;
    background: #000;
}

.capture-stage {
    position: relative;
    width: 100%;
    min-height: 100vh;
    background: #000;
    overflow: hidden;
    --capture-actions-height: 110px;
    --capture-thumbs-height: 86px;
    --capture-controls-space: calc(var(--capture-actions-height) + var(--capture-thumbs-height) + 20px + env(safe-area-inset-bottom, 0px));
}

.capture-video {
    width: 100%;
    height: calc(100vh - var(--capture-controls-space));
    object-fit: cover;
    display: block;
}

.capture-mask {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: var(--capture-controls-space);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.capture-frame {
    width: min(90vw, calc((100vh - var(--capture-controls-space) - 20px) * 3 / 8));
    height: min(calc(100vh - var(--capture-controls-space) - 20px), calc(90vw * 8 / 3));
    border: 2px solid rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.15);
}

.capture-tip {
    position: absolute;
    top: 23%;
    left: 0;
    right: 0;
    text-align: center;
    color: rgba(255, 255, 255, 0.95);
    font-size: 16px;
    font-weight: 500;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.capture-tip.capture-tip-danger {
    color: #ff4d4f;
}

.capture-message {
    position: absolute;
    top: 8px;
    left: 16px;
    right: 16px;
    text-align: center;
    z-index: 4;
}

.capture-count {
    position: absolute;
    top: 28px;
    left: 16px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 12px;
    z-index: 4;
}

.capture-progress {
    position: absolute;
    left: 16px;
    right: 16px;
    top: 44px;
    z-index: 5;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(16, 16, 16, 0.62);
    backdrop-filter: blur(4px);
}

.capture-progress-text {
    color: #fff;
    font-size: 12px;
    margin-bottom: 6px;
}

.capture-progress-track {
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.28);
    overflow: hidden;
}

.capture-progress-fill {
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: linear-gradient(90deg, #2f88ff 0%, #35c8ff 100%);
    transition: width 0.2s linear;
}

.capture-thumbs {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: calc(var(--capture-actions-height) + env(safe-area-inset-bottom, 0px) + 8px);
    display: flex;
    gap: 8px;
    overflow-x: auto;
    z-index: 12;
}

.capture-thumb {
    position: relative;
    width: 56px;
    height: 78px;
    flex: 0 0 auto;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.75);
    background: rgba(255, 255, 255, 0.1);
}

.capture-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.capture-thumb-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    font-size: 14px;
    line-height: 18px;
    text-align: center;
    padding: 0;
}

.capture-actions {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 0;
    width: min(100vw, 560px);
    box-sizing: border-box;
    display: grid;
    grid-template-columns: 120px auto 120px;
    align-items: center;
    justify-content: center;
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(10, 10, 10, 0.88) 35%, rgba(10, 10, 10, 0.96) 100%);
    z-index: 15;
}

.capture-actions-left {
    width: 120px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
}

.capture-actions-right {
    width: 120px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.capture-action-btn {
    width: clamp(46px, 12vw, 56px);
    height: clamp(46px, 12vw, 56px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 0;
    background: rgba(35, 35, 35, 0.9);
    color: #fff;
    flex-shrink: 0;
}

.capture-action-icon {
    width: 24px;
    height: 24px;
    display: block;
    fill: none;
    stroke: #fff;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.capture-spin-icon {
    animation: captureSpin 1s linear infinite;
}

.submit-success-mask {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.submit-success-dialog {
    width: min(92vw, 320px);
    background: #fff;
    border-radius: 12px;
    padding: 20px 16px;
    text-align: center;
}

.submit-success-dialog h3 {
    margin: 0;
    font-size: 22px;
    color: var(--success);
}

.submit-success-dialog p {
    margin: 10px 0 0;
    color: var(--text-2);
    font-size: 15px;
}

.capture-action-btn:disabled {
    opacity: 0.45;
}

.capture-shutter-btn {
    margin: 0 10px;
    width: clamp(70px, 18vw, 82px);
    height: clamp(70px, 18vw, 82px);
    border-radius: 50%;
    border: 4px solid #fff;
    background: #fff;
    box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.28);
    flex-shrink: 0;
}

.capture-file-input {
    display: none;
}

.capture-shutter-btn:disabled {
    opacity: 0.55;
}

.capture-preview-mask {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
}

.capture-preview-mask[hidden] {
    display: none;
}

.capture-preview-image {
    max-width: 100vw;
    max-height: 100vh;
    object-fit: contain;
}

.capture-preview-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    font-size: 28px;
    line-height: 38px;
    text-align: center;
    padding: 0;
}

@keyframes captureSpin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}
