:root {
    color-scheme: light;
    --orange: #f57c00;
    --orange-dark: #d96800;
    --orange-soft: #fff1df;
    --blue: #087cca;
    --ink: #2c241d;
    --muted: #75685e;
    --line: #ead8c7;
    --paper: #fffaf4;
    --danger: #b7352c;
}

* { box-sizing: border-box; }
html { font-family: "Yu Gothic UI", "Meiryo", system-ui, sans-serif; background: #f6f1eb; color: var(--ink); }
body { margin: 0; min-height: 100vh; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, a, label { -webkit-tap-highlight-color: transparent; }

.site-header {
    position: sticky; top: 0; z-index: 20;
    min-height: 68px; padding: 10px clamp(16px, 4vw, 54px);
    display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center;
    color: white; background: linear-gradient(115deg, #e96e00, #ff922e);
    box-shadow: 0 4px 18px #8c4b1428;
}
.brand { display: inline-flex; align-items: center; justify-self: start; font-size: clamp(1.05rem, 2.3vw, 1.45rem); font-weight: 800; letter-spacing: .04em; text-decoration: none; }
.brand-icon { display: inline-grid; place-items: center; width: 34px; height: 34px; margin-right: 8px; border: 2px solid #fff; border-radius: 8px; }
.site-title { justify-self: center; font-size: clamp(1.2rem, 2.7vw, 1.7rem); font-weight: 800; text-decoration: none; white-space: nowrap; }
.header-actions { min-width: 0; justify-self: end; }
.page-shell { width: min(1480px, 96vw); margin: 24px auto 48px; }
footer { padding: 26px; color: var(--muted); text-align: center; font-size: .85rem; }

.portal-shell {
    min-height: calc(100vh - 190px); padding: clamp(28px, 6vw, 78px);
    display: grid; align-content: center; gap: clamp(28px, 5vw, 54px);
    overflow: hidden; position: relative;
    background:
        radial-gradient(circle at 8% 10%, #ffbd7438 0 14%, transparent 36%),
        radial-gradient(circle at 92% 95%, #168ed224 0 15%, transparent 38%),
        white;
    border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 18px 55px #67411f16;
}
.portal-shell::after {
    content: ""; position: absolute; width: 300px; height: 300px; right: -145px; top: -145px;
    border: 42px solid #f57c000b; border-radius: 50%; pointer-events: none;
}
.portal-hero { max-width: 760px; position: relative; z-index: 1; }
.portal-kicker {
    display: inline-block; margin-bottom: 10px; color: var(--orange-dark);
    font-size: .82rem; font-weight: 900; letter-spacing: .16em;
}
.portal-hero h1 { margin: 0 0 12px; font-size: clamp(2rem, 5vw, 3.8rem); line-height: 1.15; }
.portal-hero p { margin: 0; color: var(--muted); font-size: clamp(1rem, 2vw, 1.25rem); line-height: 1.8; }
.portal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(18px, 3vw, 30px); position: relative; z-index: 1; }
.portal-card {
    min-height: 230px; padding: clamp(22px, 3vw, 34px);
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: clamp(18px, 3vw, 30px);
    color: white; border-radius: 22px; text-decoration: none; overflow: hidden; position: relative;
    box-shadow: 0 16px 38px #49311e25; transition: transform .18s ease, box-shadow .18s ease;
}
.portal-card:hover { transform: translateY(-5px); box-shadow: 0 22px 48px #49311e33; }
.portal-card::after {
    content: ""; position: absolute; width: 190px; height: 190px; right: -86px; bottom: -105px;
    border: 30px solid #ffffff12; border-radius: 50%;
}
.portal-card-receipt { background: linear-gradient(135deg, #dd6200, #ff922e); }
.portal-card-voucher { background: linear-gradient(135deg, #086fae, #14a2d4); }
.portal-card-icon {
    width: clamp(72px, 8vw, 98px); height: clamp(72px, 8vw, 98px);
    display: grid; place-items: center; border: 2px solid #ffffffad; border-radius: 22px;
    background: #ffffff17; font-size: clamp(2.2rem, 5vw, 3.5rem); font-weight: 900;
}
.portal-card-icon-voucher { font-size: clamp(1.8rem, 4vw, 2.7rem); }
.portal-card-copy { min-width: 0; display: grid; gap: 7px; }
.portal-card-copy small { color: #ffffffcf; font-weight: 900; letter-spacing: .15em; }
.portal-card-copy strong { font-size: clamp(1.55rem, 3vw, 2.2rem); }
.portal-card-copy > span { color: #fffdf4e8; line-height: 1.7; }
.portal-card-arrow { position: relative; z-index: 1; font-size: 3.4rem; font-weight: 300; }

.voucher-placeholder {
    width: min(900px, 100%); min-height: calc(100vh - 210px); margin: auto; padding: clamp(28px, 6vw, 70px);
    display: grid; place-items: center; align-content: center; gap: 16px; text-align: center;
    background: white; border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 18px 55px #67411f16;
}
.voucher-placeholder-icon {
    width: 96px; height: 96px; display: grid; place-items: center;
    color: white; background: linear-gradient(135deg, #086fae, #14a2d4);
    border-radius: 26px; box-shadow: 0 12px 28px #087cca30; font-size: 2.6rem; font-weight: 900;
}
.voucher-kicker { margin: 4px 0 -8px; color: var(--blue); }
.voucher-placeholder h1 { margin: 0; font-size: clamp(2rem, 5vw, 3.2rem); }
.voucher-placeholder > p { max-width: 680px; margin: 0; color: var(--muted); font-size: 1.08rem; line-height: 1.8; }
.voucher-field-preview { width: min(670px, 100%); display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.voucher-field-preview span { padding: 8px 14px; color: #176d9e; background: #e9f7fd; border: 1px solid #a8daef; border-radius: 999px; font-weight: 800; }
.voucher-placeholder-note {
    width: min(670px, 100%); padding: 16px; display: grid; gap: 4px;
    color: #28596f; background: #f2fbff; border: 1px dashed #71bfdf; border-radius: 12px;
}
.voucher-placeholder-note span { color: var(--muted); }
.voucher-placeholder-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

.voucher-upload-card {
    padding: clamp(20px, 3vw, 34px); display: grid; grid-template-columns: minmax(0, 1fr) minmax(390px, .8fr); gap: 26px; align-items: center;
    background: white; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 10px 30px #67411f12;
}
.voucher-upload-intro { display: grid; gap: 8px; }
.voucher-upload-intro h1 { margin: 0; font-size: clamp(1.55rem, 3vw, 2.35rem); }
.voucher-upload-intro p { margin: 0; color: var(--muted); line-height: 1.7; }
.voucher-upload-intro .voucher-field-preview { justify-content: flex-start; margin-top: 8px; }
.voucher-upload-form { display: grid; gap: 5px; }
.voucher-file-drop { min-height: 145px; }
.voucher-upload-help { color: var(--muted); text-align: center; }
.voucher-toolbar { margin: 14px 4px 10px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.voucher-summary { display: flex; align-items: center; gap: 18px; color: var(--muted); }
.voucher-summary strong { color: var(--ink); }
.voucher-toolbar-actions { display: flex; align-items: center; gap: 6px; }
.voucher-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: 16px; align-items: start; }
.voucher-workspace.single { grid-template-columns: 1fr; }
.voucher-table-wrap { overflow: auto; max-height: calc(100vh - 285px); }
.voucher-table { min-width: 1060px; }
.voucher-table td { vertical-align: top; }
.voucher-cell-lines { min-width: 185px; display: grid; gap: 4px; }
.voucher-cell-lines > span { display: flex; justify-content: space-between; gap: 14px; }
.voucher-cell-lines b { font-weight: 700; }
.voucher-cell-lines em { font-style: normal; font-variant-numeric: tabular-nums; white-space: nowrap; }
.voucher-cell-empty { color: var(--muted); }
.voucher-edit-card { padding: 16px; }
.voucher-preview { height: 270px; }
.voucher-edit-form { display: grid; gap: 14px; }
.voucher-basic-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.voucher-basic-grid label, .voucher-total-field, .voucher-memo-field, .voucher-line-row label {
    display: grid; gap: 4px; color: var(--muted); font-size: .8rem; font-weight: 700;
}
.voucher-customer-field { grid-column: 1 / -1; }
.voucher-line-section { padding: 12px; display: grid; gap: 10px; background: #f4fbff; border: 1px solid #b9dff0; border-radius: 12px; }
.voucher-staff-section { background: #fff8ee; border-color: #f2cf9e; }
.voucher-line-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.voucher-line-heading > div { display: grid; gap: 2px; }
.voucher-line-heading strong { color: #176d9e; }
.voucher-staff-section .voucher-line-heading strong { color: var(--orange-dark); }
.voucher-line-heading small { color: var(--muted); }
.voucher-add-line { padding: 6px 9px; color: #176d9e; background: white; border: 1px solid #80c3df; border-radius: 7px; font-size: .76rem; font-weight: 800; cursor: pointer; white-space: nowrap; }
.voucher-staff-section .voucher-add-line { color: var(--orange-dark); border-color: #e8b36f; }
.voucher-line-list { display: grid; gap: 8px; }
.voucher-line-row { display: grid; align-items: end; gap: 6px; }
.voucher-store-line { grid-template-columns: minmax(74px, 1fr) auto minmax(74px, 1fr) minmax(105px, 1.15fr) auto; }
.voucher-staff-line { grid-template-columns: minmax(0, 1fr) minmax(110px, .65fr) auto; }
.voucher-line-row input { width: 100%; min-width: 0; padding: 7px 8px; }
.voucher-time-separator { padding-bottom: 10px; color: var(--muted); }
.voucher-remove-line { width: 34px; height: 42px; padding: 0; color: #a23a32; background: white; border: 1px solid #dfaaa5; border-radius: 7px; cursor: pointer; }
.voucher-total-breakdown { padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; color: var(--muted); background: #f8f5f1; border-radius: 9px; font-size: .78rem; }
.voucher-total-breakdown b { color: var(--ink); font-variant-numeric: tabular-nums; }
.voucher-total-breakdown strong { color: var(--orange-dark); }
.voucher-total-field { padding: 12px; color: var(--ink); background: var(--orange-soft); border: 2px solid #f2a154; border-radius: 10px; font-size: .95rem; }
.voucher-total-field input { font-size: 1.2rem; font-weight: 900; text-align: right; }
.voucher-memo-field textarea { width: 100%; }
.voucher-save-button { width: 100%; }
.voucher-secondary-action { margin-top: 10px; }
.voucher-secondary-action button { width: 100%; }

.upload-card, .toolbar-card, .table-card, .edit-card, .login-card {
    background: #fff; border: 1px solid var(--line); border-radius: 16px;
    box-shadow: 0 10px 30px #67411f12;
}
.upload-card { display: grid; grid-template-columns: 1fr minmax(360px, .8fr); gap: 24px; align-items: center; padding: 24px; }
.upload-card h1 { margin: 0 0 6px; font-size: clamp(1.35rem, 3vw, 2rem); }
.upload-card p { margin: 0; color: var(--muted); }
.upload-form { width: 100%; display: grid; gap: 10px; }
.file-drop {
    width: 100%; min-height: 124px; padding: 18px;
    display: grid; place-content: center; text-align: center;
    border: 2px dashed #f4aa64; border-radius: 12px;
    background: var(--orange-soft); cursor: pointer;
    transition: border-color .16s ease, background .16s ease, box-shadow .16s ease, transform .16s ease;
}
.file-drop:hover { border-color: var(--orange); background: #ffe8cd; }
.file-drop.is-dragover {
    border-color: var(--orange); background: #ffd8ac;
    box-shadow: 0 0 0 5px #f57c0024; transform: translateY(-2px);
}
.file-drop span, .file-drop small { display: block; }
.file-drop span { font-weight: 800; }
.file-drop small { color: var(--muted); margin-top: 2px; }
.file-drop input { width: 100%; margin-top: 8px; font-size: .85rem; }
.mobile-camera-actions { display: grid; gap: 4px; text-align: center; }
.mobile-camera-actions small { color: var(--muted); }
.mobile-camera-button {
    width: 100%; min-height: 52px; padding: 11px 18px;
    color: white; background: linear-gradient(115deg, #087cca, #18a0d8);
    border: 0; border-radius: 10px; font-weight: 800; cursor: pointer;
    box-shadow: 0 5px 14px #087cca2b;
}
.mobile-camera-button:hover { background: linear-gradient(115deg, #066baF, #118bbd); }
.scansnap-actions { display: grid; gap: 4px; text-align: center; }
.scansnap-actions small { color: var(--muted); }
.scansnap-button {
    width: 100%; min-height: 52px; padding: 11px 18px;
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    color: white; background: linear-gradient(115deg, #252525, #505050);
    border: 0; border-radius: 10px; font-weight: 800; cursor: pointer;
    box-shadow: 0 5px 14px #1f1f1f25;
}
.scansnap-button:hover { background: linear-gradient(115deg, #111, #3b3b3b); }
.scansnap-button:disabled { cursor: wait; opacity: .7; }
.scansnap-icon { font-size: 1.25rem; transform: rotate(90deg); }
.scansnap-button.is-busy .scansnap-icon { animation: scansnap-pulse 1s ease-in-out infinite; }
@keyframes scansnap-pulse { 50% { opacity: .35; transform: rotate(90deg) scale(.85); } }

body.camera-open, body.analysis-open { overflow: hidden; }
.mobile-camera-overlay {
    position: fixed; inset: 0; z-index: 100;
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    display: grid; place-items: center; background: #050505ee;
}
.mobile-camera-overlay[hidden] { display: none; }
.mobile-camera-panel {
    width: min(760px, 100%); max-height: 100%; padding: 16px;
    display: grid; gap: 12px; overflow: auto;
    color: white; background: #171717; border: 1px solid #ffffff30; border-radius: 18px;
}
.mobile-camera-heading { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.mobile-camera-heading h2 { margin: 0 0 2px; font-size: 1.2rem; }
.mobile-camera-heading small { color: #d2d2d2; }
.camera-close-button {
    width: 42px; height: 42px; flex: 0 0 42px; padding: 0;
    color: white; background: #ffffff1b; border: 1px solid #ffffff4b; border-radius: 50%;
    font-size: 1.8rem; line-height: 1; cursor: pointer;
}
.camera-viewfinder {
    position: relative; min-height: min(62vh, 520px); overflow: hidden;
    background: #000; border-radius: 12px;
}
.camera-viewfinder video { width: 100%; height: 100%; position: absolute; inset: 0; object-fit: contain; }
.camera-guide {
    position: absolute; inset: 7% 12%; pointer-events: none;
    border: 2px solid #ffffffc9; border-radius: 8px; box-shadow: 0 0 0 9999px #00000024;
}
.camera-analysis-badge {
    position: absolute; z-index: 3; top: 50%; left: 50%; transform: translate(-50%, -50%);
    min-width: min(270px, calc(100% - 32px)); max-width: calc(100% - 32px); padding: 18px 24px;
    display: inline-flex; align-items: center; justify-content: center; gap: 9px;
    color: white; background: #111111db; border: 1px solid #ffffff55; border-radius: 999px;
    box-shadow: 0 8px 26px #000b; font-size: 1.15rem; white-space: nowrap;
}
.camera-analysis-badge[hidden] { display: none; }
.analysis-mini-spinner {
    width: 18px; height: 18px; flex: 0 0 18px;
    border: 3px solid #ffffff55; border-top-color: #ff8a00; border-radius: 50%;
    animation: analysis-spin .8s linear infinite;
}
.camera-viewfinder.is-flashing::after {
    content: ""; position: absolute; inset: 0; background: white; pointer-events: none;
    animation: camera-flash .24s ease-out forwards;
}
@keyframes camera-flash { from { opacity: .9; } to { opacity: 0; } }
.camera-progress { display: flex; justify-content: space-between; gap: 12px; color: #d7d7d7; }
.camera-progress strong { color: white; white-space: nowrap; }
.camera-controls { display: grid; grid-template-columns: 1fr 1.25fr; gap: 12px; }
.camera-shutter-button {
    min-height: 64px; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    color: white; background: #087cca; border: 0; border-radius: 12px; cursor: pointer;
}
.camera-shutter-button > span { width: 34px; height: 34px; background: white; border: 5px solid #d9edf8; border-radius: 50%; }
.camera-shutter-button:disabled { opacity: .5; cursor: wait; }

.analysis-overlay {
    position: fixed; inset: 0; z-index: 130; padding: 20px;
    display: grid; place-items: center;
    background: #1b100be8; backdrop-filter: blur(4px);
}
.analysis-overlay[hidden] { display: none; }
.analysis-panel {
    width: min(420px, 100%); padding: 28px 24px;
    display: grid; justify-items: center; gap: 12px;
    color: var(--ink); text-align: center; background: white;
    border: 2px solid #ff8a00; border-radius: 20px; box-shadow: 0 18px 60px #0008;
}
.analysis-panel > strong { color: var(--orange-dark); font-size: 1.45rem; }
.analysis-panel > small { color: var(--muted); }
.analysis-spinner {
    width: 58px; height: 58px;
    border: 7px solid #ffe0c0; border-top-color: var(--orange); border-radius: 50%;
    animation: analysis-spin .8s linear infinite;
}
.analysis-progress-track {
    width: 100%; height: 10px; overflow: hidden;
    background: #f1e6dc; border-radius: 999px;
}
.analysis-progress-track > span {
    display: block; width: 0; height: 100%;
    background: linear-gradient(90deg, #ff7300, #ffb347); border-radius: inherit;
    transition: width .25s ease;
}
.analysis-progress-track > span.is-indeterminate {
    animation: analysis-progress 1.2s ease-in-out infinite;
}
@keyframes analysis-spin { to { transform: rotate(360deg); } }
@keyframes analysis-progress {
    0% { transform: translateX(-130%); }
    100% { transform: translateX(330%); }
}

.primary-button, .secondary-button, .danger-button, .ghost-button, .text-button, .csv-import label {
    display: inline-flex; align-items: center; justify-content: center; min-height: 42px;
    padding: 9px 17px; border-radius: 9px; border: 1px solid transparent;
    font-weight: 800; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.primary-button { color: white; background: var(--orange); }
.primary-button:hover { background: var(--orange-dark); }
.secondary-button, .csv-import label { color: var(--orange-dark); background: #fff; border-color: #efad70; }
.danger-button { width: 100%; margin-top: 10px; color: var(--danger); background: #fff; border-color: #e1aaa6; }
.reocr-button { width: 100%; margin-top: 10px; }
.ghost-button { color: white; background: #ffffff1f; border-color: #ffffff70; }
.text-button { color: var(--muted); padding-inline: 8px; }

.toolbar-card { margin-top: 16px; padding: 14px; display: flex; gap: 16px; justify-content: space-between; align-items: center; }
.filter-form, .data-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-form input { width: min(360px, 70vw); }
input, select, textarea { min-height: 42px; padding: 9px 11px; color: var(--ink); border: 1px solid #ccb9a8; border-radius: 8px; background: white; }
input:focus, select:focus, textarea:focus { outline: 3px solid #ffbd7c77; border-color: var(--orange); }
.csv-import input { display: none; }
.summary-strip { margin: 16px 4px 8px; display: flex; gap: 18px; color: var(--muted); }
.summary-strip strong { color: var(--ink); }
.monthly-summary-card { margin-bottom: 14px; padding: 14px; background: white; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 8px 24px #67411f0d; }
.monthly-summary-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.monthly-summary-heading a { color: var(--orange-dark); font-size: .85rem; }
.monthly-summary-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(285px, 1fr)); gap: 8px; }
.monthly-summary-item {
    display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 13px;
    color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 9px; text-decoration: none;
}
.monthly-summary-item:hover, .monthly-summary-item.active { color: white; background: var(--orange); border-color: var(--orange); }
.monthly-summary-period { white-space: nowrap; font-weight: 800; }
.monthly-summary-item small { color: var(--muted); font-size: .76rem; }
.monthly-summary-item:hover small, .monthly-summary-item.active small { color: #fff5e9; }
.monthly-summary-money { display: grid; justify-items: end; text-align: right; }
.monthly-summary-money strong { white-space: nowrap; font-variant-numeric: tabular-nums; }
.category-summary-card { margin-bottom: 14px; padding: 14px; background: white; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 8px 24px #67411f0d; }
.category-summary-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.category-summary-heading a { color: var(--orange-dark); font-size: .85rem; }
.category-summary-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; }
.category-summary-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 9px; text-decoration: none; }
.category-summary-item:hover, .category-summary-item.active { color: white; background: var(--orange); border-color: var(--orange); }
.category-summary-item small { color: var(--muted); }
.category-summary-item:hover small, .category-summary-item.active small { color: #fff5e9; }
.category-summary-item strong { white-space: nowrap; font-variant-numeric: tabular-nums; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.workspace.single { grid-template-columns: 1fr; }
.table-card { min-width: 0; overflow: hidden; }
.receipt-table-wrap { overflow: auto; max-height: calc(100vh - 300px); }
.receipt-table { width: 100%; border-collapse: collapse; white-space: nowrap; }
.receipt-table th { position: sticky; top: 0; z-index: 2; padding: 10px; color: white; background: var(--orange); text-align: left; }
.receipt-table th:first-child { background: var(--blue); }
.receipt-table td { padding: 10px; border-bottom: 1px solid var(--line); max-width: 240px; }
.receipt-table tbody tr { cursor: pointer; background: #fff; }
.receipt-table tbody tr:nth-child(odd) { background: var(--paper); }
.receipt-table tbody tr:hover, .receipt-table tbody tr.selected { background: #ffe2be; }
.money { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; }
.empty-state { min-height: 300px; display: grid; place-content: center; gap: 8px; text-align: center; color: var(--muted); }
.empty-state strong { color: var(--ink); font-size: 1.2rem; }

.edit-card { position: sticky; top: 86px; padding: 18px; }
.edit-heading { display: flex; align-items: center; justify-content: space-between; }
.edit-heading h2 { margin: 0 0 12px; font-size: 1.15rem; }
.edit-heading a { color: var(--muted); }
.preview { display: block; height: 220px; margin-bottom: 14px; border-radius: 10px; overflow: hidden; background: #f0ebe6; }
.preview img { width: 100%; height: 100%; object-fit: contain; }
.pdf-preview { width: 100%; height: 100%; display: grid; place-content: center; gap: 5px; color: var(--orange-dark); text-align: center; font-weight: 800; }
.pdf-preview small { max-width: 300px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-weight: 500; }
.edit-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.edit-form label { display: grid; gap: 4px; color: var(--muted); font-size: .85rem; font-weight: 700; }
.edit-form label:nth-of-type(2), .edit-form .full, .edit-actions { grid-column: 1 / -1; }
.store-edit { padding: 10px; border: 2px solid #f2a154; border-radius: 10px; background: var(--orange-soft); }
.store-edit small { color: var(--orange-dark); font-weight: 700; }
.edit-actions, .replace-form { display: flex; gap: 8px; }
.edit-actions > *, .replace-form > * { flex: 1; }
.replace-form { margin-top: 10px; }
.replace-form input { display: none; }
textarea { resize: vertical; }

.alert { margin-bottom: 14px; padding: 12px 16px; border-radius: 10px; font-weight: 700; }
.alert.success { color: #225f38; background: #e7f7ec; border: 1px solid #a8d8b6; }
.alert.error { color: #8c2923; background: #fff0ee; border: 1px solid #e7b3af; }
.receipt-table td.ocr-warning { color: #c62828; font-weight: 800; }
.login-card { width: min(440px, 94vw); margin: 10vh auto; padding: 32px; text-align: center; }
.login-card h1 { margin: 8px 0; }
.login-card p { color: var(--muted); }
.login-mark { width: 64px; height: 64px; margin: auto; display: grid; place-items: center; border-radius: 18px; color: white; background: var(--orange); font-size: 2rem; }
.stack-form { display: grid; gap: 14px; margin-top: 22px; text-align: left; }
.stack-form label { display: grid; gap: 5px; font-weight: 700; }

@media (max-width: 950px) {
    .portal-grid { grid-template-columns: 1fr; }
    .voucher-upload-card { grid-template-columns: 1fr; }
    .voucher-workspace { grid-template-columns: 1fr; }
    .voucher-edit-card { position: static; order: -1; }
    .voucher-table-wrap { max-height: none; }
    .upload-card { grid-template-columns: 1fr; }
    .toolbar-card { align-items: stretch; flex-direction: column; }
    .workspace { grid-template-columns: 1fr; }
    .edit-card { position: static; order: -1; }
    .receipt-table-wrap { max-height: none; }
}

@media (max-width: 640px) {
    .site-header { min-height: 60px; padding: 8px 10px; gap: 6px; }
    .brand { font-size: .72rem; letter-spacing: 0; }
    .brand-icon { width: 25px; height: 25px; margin-right: 4px; border-width: 1px; border-radius: 6px; }
    .site-title { font-size: .96rem; }
    .site-header .ghost-button { min-height: 36px; padding: 7px 9px; font-size: .76rem; }
    .page-shell { width: min(100% - 20px, 1480px); margin-top: 12px; }
    .portal-shell { min-height: calc(100vh - 150px); padding: 24px 16px; gap: 24px; border-radius: 18px; }
    .portal-card { min-height: 188px; grid-template-columns: auto minmax(0, 1fr); padding: 20px 16px; gap: 14px; border-radius: 16px; }
    .portal-card-icon { width: 62px; height: 62px; border-radius: 16px; }
    .portal-card-copy > span { font-size: .86rem; line-height: 1.55; }
    .portal-card-arrow { display: none; }
    .voucher-placeholder { min-height: calc(100vh - 160px); padding: 28px 16px; border-radius: 18px; }
    .voucher-upload-card { padding: 17px; }
    .voucher-upload-intro .voucher-field-preview { display: none; }
    .voucher-toolbar { align-items: flex-start; }
    .voucher-summary { align-items: flex-start; flex-direction: column; gap: 2px; }
    .voucher-toolbar-actions { align-items: flex-end; flex-direction: column; }
    .voucher-table { min-width: 0; }
    .voucher-cell-lines { min-width: 0; }
    .voucher-cell-lines > span { justify-content: flex-start; }
    .voucher-basic-grid { grid-template-columns: 1fr; }
    .voucher-customer-field { grid-column: 1; }
    .voucher-line-heading { align-items: flex-start; }
    .voucher-store-line { grid-template-columns: 1fr auto 1fr; padding-bottom: 8px; border-bottom: 1px dashed #b9dff0; }
    .voucher-store-line .voucher-line-money { grid-column: 1 / 3; }
    .voucher-store-line .voucher-remove-line { grid-column: 3; grid-row: 2; justify-self: end; }
    .voucher-staff-line { grid-template-columns: minmax(0, 1fr) auto; padding-bottom: 8px; border-bottom: 1px dashed #f2cf9e; }
    .voucher-staff-line .voucher-line-money { grid-column: 1; }
    .voucher-staff-line .voucher-remove-line { grid-column: 2; grid-row: 2; }
    .upload-card { padding: 17px; }
    .upload-form { flex-direction: column; }
    .filter-form input, .filter-form select, .filter-form .secondary-button { width: 100%; }
    .summary-strip { flex-wrap: wrap; gap: 8px 14px; }
    .monthly-summary-list { grid-template-columns: 1fr; }
    .monthly-summary-item { align-items: flex-start; }
    .category-summary-list { grid-template-columns: 1fr; }
    .data-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .receipt-table thead { display: none; }
    .receipt-table, .receipt-table tbody, .receipt-table tr, .receipt-table td { display: block; width: 100%; }
    .receipt-table tr { padding: 12px; border-bottom: 1px solid var(--line); }
    .receipt-table td { display: grid; grid-template-columns: 90px 1fr; padding: 4px 0; border: 0; max-width: none; white-space: normal; }
    .receipt-table td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; font-weight: 700; }
    .money { text-align: left; }
    .edit-form { grid-template-columns: 1fr; }
    .edit-form label, .edit-form label:nth-of-type(2), .edit-form .full, .edit-actions { grid-column: 1; }
    .edit-actions, .replace-form { flex-direction: column; }
    .mobile-camera-overlay { padding: 0; place-items: stretch; }
    .mobile-camera-panel { width: 100%; height: 100%; max-height: none; border: 0; border-radius: 0; }
    .camera-viewfinder { min-height: 0; height: min(62vh, 560px); }
    .camera-progress { flex-direction: column; gap: 3px; }
    .camera-controls { grid-template-columns: 1fr; }
    .camera-shutter-button { order: -1; min-height: 72px; }
    .analysis-overlay { padding: 14px; }
    .analysis-panel { padding: 24px 18px; }
    .camera-analysis-badge { padding: 16px 20px; font-size: 1.05rem; }
}
