:root {
    --ink: #1c2b26;
    --muted: #5e7268;
    --paper: #f4f7f5;
    --card: #ffffff;
    --line: #d7e4dc;
    --green: #16865d;
    --green-deep: #0f6b49;
    --blue: #2377b8;
    --blue-deep: #1a5e92;
    --amber: #e7a340;
    --amber-ink: #7a5414;
    --danger: #9b3b3b;
    --danger-bg: #fff5f5;
    --soft: #e8f6ef;
    --blue-soft: #e8f3fb;
    --amber-soft: #fff6e8;
    --shadow: 0 10px 28px rgba(28, 62, 48, 0.06);
    --radius: 14px;
    --control: 44px;
    --space: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; max-width: 100%; }
body {
    min-height: 100vh;
    color: var(--ink);
    background:
        radial-gradient(900px 320px at 100% -40px, rgba(35, 119, 184, 0.1), transparent 55%),
        radial-gradient(820px 300px at -80px -60px, rgba(22, 134, 93, 0.14), transparent 50%),
        var(--paper);
    font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic", sans-serif;
    font-size: 16px;
    line-height: 1.65;
    overflow-x: hidden;
}
img { max-width: 100%; }
a { color: var(--blue-deep); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
h1, h2, h3 { line-height: 1.35; font-weight: 700; letter-spacing: 0; }
h1 { font-size: 1.65rem; margin: 0 0 8px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
h3 { font-size: 0.98rem; margin: 16px 0 6px; }
.with-icon { display: flex; align-items: center; gap: 8px; }
.icon { width: 18px; height: 18px; flex: 0 0 auto; }

.app-shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.side {
    background: linear-gradient(180deg, #ffffff 0%, #f3faf6 100%);
    color: var(--ink);
    border-right: 1px solid var(--line);
    padding: 22px 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.side a { color: inherit; text-decoration: none; }
.mark {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 750;
    letter-spacing: 0.04em;
    padding: 4px 8px 8px;
}
.mark small { display: block; font-weight: 600; letter-spacing: 0.14em; color: var(--green); font-size: 0.68rem; }
.nav-main, .nav-admin { display: grid; gap: 12px; }
.nav-main a, .nav-admin a, .side button {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 8px 12px;
    border-radius: 12px;
    background: transparent;
    border: 0;
    color: var(--ink);
    text-align: left;
    width: 100%;
}
.nav-main a { font-weight: 700; }
.nav-main a:hover, .nav-admin a:hover { background: var(--soft); }
.nav-main a.is-current {
    background: var(--green);
    color: white;
}
.nav-admin a.is-current { background: var(--blue-soft); color: var(--blue-deep); }
.nav-more { border-top: 1px solid var(--line); padding-top: 10px; }
.nav-label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    color: var(--muted);
    cursor: pointer;
}
.who { margin-top: auto; display: grid; gap: 12px; font-size: 0.88rem; color: var(--muted); padding: 0 8px; }
.who form { display: block; }
.app-main { padding: 28px 32px 72px; min-width: 0; }
.app-main > * { max-width: 1080px; }
.context-bar { margin: 0 0 14px; color: var(--muted); }

.hero, .panel, .doc-card, .stat {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.hero, .panel { padding: 20px; margin: 0 0 16px; min-width: 0; max-width: 100%; }
.hero {
    background: linear-gradient(115deg, #e7f8ef 0%, #ffffff 46%, #e7f3fb 100%);
}
.lede, .meta { color: var(--muted); overflow-wrap: anywhere; }
.actions, .company-picks, .toolbar, .action-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: stretch; }
.company-picks { margin-top: 8px; }
.company-picks a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: white;
    color: var(--ink);
    text-decoration: none;
}
.company-picks a.current { background: var(--green); color: white; border-color: var(--green); }

.button, button[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: var(--control);
    padding: 8px 16px;
    border-radius: 12px;
    border: 1px solid var(--green);
    background: var(--green);
    color: white;
    text-decoration: none;
    font-weight: 700;
    cursor: pointer;
    width: auto;
}
.button:hover, button[type="submit"]:hover { background: var(--green-deep); }
.button.secondary, button.secondary,
button.ghost {
    min-height: 44px;
}
.button.secondary, button.secondary {
    background: white;
    color: var(--blue-deep);
    border-color: #b7d4ea;
}
.button.secondary:hover, button.secondary:hover { background: var(--blue-soft); }
.button.confirm, button.confirm {
    background: var(--blue);
    border-color: var(--blue);
    color: white;
}
.button.confirm:hover, button.confirm:hover { background: var(--blue-deep); }
.button.warn, button.warn, .button.warning, button.warning {
    background: var(--amber-soft);
    color: var(--amber-ink);
    border-color: var(--amber);
}
.button.danger, button.danger {
    background: white;
    color: var(--danger);
    border-color: #efc4c4;
}
.button.ghost, button.ghost, .side button.ghost {
    background: transparent;
    color: var(--ink);
    border-color: var(--line);
    font-weight: 650;
}
.button.large { min-height: 52px; padding: 12px 20px; font-size: 1.05rem; }
button:disabled, .button:disabled { opacity: 0.55; cursor: not-allowed; }
.copy-figure {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    box-sizing: border-box;
    max-width: 100%;
    min-width: 0;
    min-height: 44px;
    margin: 0;
    padding: 0 10px;
    border: 0;
    border-radius: 10px;
    background: #e7f2ea;
    color: inherit;
    font: inherit;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    text-align: center;
    vertical-align: middle;
    appearance: none;
}
.copy-figure[data-copied="1"]::after {
    content: "コピーしました";
    margin-left: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--green-deep);
}
.copy-figure[data-copied="0"]::after {
    content: "コピーできませんでした";
    margin-left: 6px;
    font-size: 0.75rem;
    color: var(--danger);
}
.money .copy-figure { background: transparent; min-height: 44px; padding: 0 8px; border-radius: 8px; line-height: 1; }
.copy-figure .money-main, .copy-figure .yen-unit { line-height: 1; }
.money .copy-figure:hover, .copy-figure:hover { background: #e7f2ea; }
.sheet-thumb {
    width: 84px;
    height: 112px;
    min-height: 44px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #f7fbf8;
    overflow: hidden;
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
}
.sheet-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.period-edit { display: grid; gap: 8px; margin-top: 8px; min-width: 0; }
.period-edit .button { min-height: 44px; }
.save-state { min-height: 1.2em; }
.viewer-modal {
    width: min(960px, calc(100vw - 16px));
    height: min(860px, calc(100svh - 16px));
    max-width: 100%;
    border: 0;
    border-radius: 16px;
    padding: 12px;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 8px;
}
.viewer-modal::backdrop { background: rgba(20, 40, 32, 0.72); }
.viewer-modal[open] { display: grid; }
.photo-stage { min-width: 0; min-height: 0; overflow: hidden; touch-action: none; display: grid; place-items: center; background: #10241c; }
.photo-stage img { max-width: 100%; max-height: 100%; transform-origin: center; }
.copy-amount {
    min-height: 44px;
    padding: 2px 8px;
    border-radius: 8px;
    border: 1px solid #c5ddf0;
    background: white;
    color: var(--blue-deep);
    font-size: 0.78rem;
    font-weight: 650;
}
.yen { font-variant-numeric: tabular-nums; font-weight: 700; }

.status, .alert, .notice, .field-error { border-radius: 12px; padding: 10px 12px; margin: 0 0 12px; }
.status { background: var(--soft); color: var(--green-deep); border: 1px solid #cfe8db; }
.alert, .field-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #f0d0d0; }
.notice { background: var(--amber-soft); color: var(--amber-ink); border: 1px solid #f3ddb0; }
.tag, .pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 2px 10px;
    background: var(--soft);
    color: var(--green-deep);
    font-size: 0.82rem;
    font-weight: 700;
}
.pill.warn, .warn { background: var(--amber-soft); color: var(--amber-ink); }
.pill.status-uploaded, .pill.status-processing { background: var(--blue-soft); color: var(--blue-deep); }
.pill.status-needs_review { background: var(--amber-soft); color: var(--amber-ink); }
.pill.status-confirmed { background: var(--soft); color: var(--green-deep); }
.pill.status-failed { background: var(--danger-bg); color: var(--danger); }

.stats, .stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(148px, 100%), 1fr)); gap: 12px; margin: 0 0 16px; min-width: 0; }
.stat { display: grid; gap: 4px; padding: 14px 16px; text-decoration: none; color: inherit; min-width: 0; overflow-wrap: anywhere; }
.stat strong { font-size: 1.7rem; line-height: 1.2; overflow-wrap: anywhere; }
.stat-label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.9rem; }
.row { display: grid; grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); gap: 8px 16px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.row > :only-child { grid-column: 1 / -1; }
.row > :last-child { min-width: 0; overflow-wrap: anywhere; }
.hash { word-break: break-all; font-family: ui-monospace, monospace; font-size: 0.85rem; }

form { display: grid; gap: 14px; }
form button, form .button { justify-self: start; }
label { display: grid; gap: 6px; min-width: 0; max-width: 100%; }
label[hidden] { display: none; }
label:has(.copy-amount) { gap: 12px; }
label span { font-weight: 700; }
input, select, textarea {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    min-height: var(--control);
    border: 1px solid #c9d9d1;
    border-radius: 12px;
    padding: 8px 12px;
    background: white;
}
input[type="month"],
input[type="date"],
input[type="time"],
input[type="datetime-local"] {
    display: block;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    min-inline-size: 0;
}
input[type="month"]::-webkit-datetime-edit,
input[type="date"]::-webkit-datetime-edit,
input[type="month"]::-webkit-datetime-edit-fields-wrapper,
input[type="date"]::-webkit-datetime-edit-fields-wrapper {
    min-width: 0;
    padding: 0;
}
input[type="month"]::-webkit-calendar-picker-indicator,
input[type="date"]::-webkit-calendar-picker-indicator {
    margin-inline-start: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--green); outline: none; box-shadow: 0 0 0 3px rgba(22, 134, 93, 0.15); }
.field-grid, .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: end; min-width: 0; }
.field-grid > *, .line-row > *, .filters > * { min-width: 0; max-width: 100%; }
.filters { grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); }
.line-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.6fr) minmax(0, 0.8fr) minmax(0, 0.8fr) auto; gap: 12px; align-items: end; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; min-height: 0; }
.priority-fields { display: grid; gap: 12px; padding: 12px; border-radius: 12px; background: #f7fbf8; border: 1px solid #d7eadf; }

.compare { display: grid; grid-template-columns: minmax(260px, 0.9fr) minmax(320px, 1.1fr); gap: 16px; align-items: start; }
.viewer-stage { overflow: auto; max-height: 72vh; background: #eef4f1; border-radius: 12px; border: 1px solid var(--line); }
.viewer-stage img { transform-origin: center top; display: block; margin: 0 auto; }
.toolbar button { min-height: 44px; }
.dropzone > .icon { width: 36px; height: 36px; color: var(--green); }
.dropzone {
    border: 2px dashed #8dccb0;
    border-radius: 16px;
    background: linear-gradient(180deg, #f4fbf7, #ffffff);
    padding: 22px;
    text-align: center;
    display: grid;
    gap: 12px;
    justify-items: center;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}
.pick-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
    width: 100%;
    min-width: 0;
}
.pick {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 88px;
    min-width: 0;
    padding: 12px 8px;
    border: 1px solid #b7d4ea;
    border-radius: 12px;
    background: white;
    color: var(--blue-deep);
    text-align: center;
    cursor: pointer;
}
.pick .icon { width: 28px; height: 28px; }
.pick span { line-height: 1.35; overflow-wrap: anywhere; }
.pick-input {
    position: absolute;
    width: 1px;
    height: 1px;
    min-height: 0;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    border: 0;
    white-space: nowrap;
}
.dropzone > .button { justify-self: center; }
.account-field { display: grid; gap: 12px; min-width: 0; max-width: 100%; }
.account-field select, .account-field input { min-width: 0; max-width: 100%; }
.account-fold { width: 100%; min-width: 0; }
.account-fold summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; }
.account-inline { display: grid; gap: 12px; margin-top: 12px; }
.account-inline .button { width: 100%; }
.title-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.title-list li { border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; background: white; }
.title-row { display: grid; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.title-row form { display: grid; gap: 12px; }
.title-add { display: grid; gap: 12px; margin-top: 16px; }
.ocr-progress-track { display: block; height: 8px; border-radius: 999px; background: #e6f2ea; overflow: hidden; }
.ocr-progress-track span { display: block; height: 100%; width: 0; background: var(--green); }
.ocr-progress-track.is-indeterminate span { width: 40%; animation: ocr-slide 1.2s ease-in-out infinite; }
@keyframes ocr-slide { 0% { transform: translateX(-120%); } 100% { transform: translateX(280%); } }
.ocr-modal {
    width: min(480px, calc(100vw - 24px));
    max-width: 100%;
    border: 0;
    border-radius: 16px;
    padding: 0;
    box-shadow: 0 18px 50px rgba(28, 62, 48, 0.18);
}
.ocr-modal::backdrop { background: rgba(20, 40, 32, 0.48); }
.ocr-modal[open] { display: block; }
.ocr-modal-card { display: grid; gap: 12px; padding: 20px; }
.ocr-modal-title { margin: 0; font-weight: 700; }
.ocr-modal .button { width: 100%; min-height: 44px; }
body:has(.ocr-modal[open]) { overflow: hidden; }
.thumbs { display: grid; gap: 8px; width: 100%; text-align: left; }
.file-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.file-row button { min-height: 44px; }
.file-row img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; background: white; }
.doc-card { display: flex; flex-direction: column; gap: 8px; align-items: stretch; padding: 14px 16px; margin: 0 0 10px; }
.doc-card strong, .doc-card p, .hash { overflow-wrap: anywhere; }
.doc-card .actions { margin-top: 4px; }
.card-line { display: grid; grid-template-columns: minmax(0, 1fr) 6.5rem auto; gap: 12px; align-items: center; }
.card-line .button { min-width: 6.5rem; }
.clip, .clip-line, .clip-sub { min-width: 0; }
.clip-line, .clip-sub { display: block; overflow-wrap: anywhere; }
.clip-sub { color: var(--muted); font-size: 0.82rem; line-height: 1.4; }
.num, .stat strong, .yen { font-variant-numeric: tabular-nums; }
.sheet { display: grid; gap: 8px; }
.sheet-head { display: none; }
.sheet-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px 12px;
    align-items: center;
    margin: 0;
}
.sheet-row > * { min-width: 0; }
@media (max-width: 700px) {
    .card-line { grid-template-columns: 1fr; }
    .card-line .button { width: 100%; }
}
.sheet-row > [data-label]::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.3;
}
.sheet-status { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.sheet-action.actions { display: grid; gap: 12px; margin: 0; }
.pick-switch { display: flex; align-items: center; gap: 12px; min-height: 44px; min-width: 0; max-width: 100%; font-weight: 700; }
.pick-switch input[type="checkbox"] {
    appearance: none;
    width: 48px;
    height: 28px;
    min-height: 28px;
    flex: 0 0 48px;
    margin: 0;
    padding: 0;
    border-radius: 999px;
    background: #d5e3db;
    position: relative;
}
.pick-switch input[type="checkbox"]::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: white;
}
.pick-switch input[type="checkbox"]:checked { background: var(--green); }
.pick-switch input[type="checkbox"]:checked::after { left: 22px; }
.pick-switch input[type="checkbox"]:disabled { opacity: 0.55; }
.bulk-tools { display: grid; gap: 8px; margin: 0 0 12px; min-width: 0; }
.bulk-tools-row { display: flex; flex-wrap: wrap; gap: 12px; }
.bulk-tools-row .button { flex: 1 1 8rem; min-width: 0; min-height: 44px; }
.bulk-dock {
    position: fixed;
    left: 252px;
    right: 0;
    bottom: var(--vv-bottom, 0px);
    z-index: 13;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px 8px;
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 24px rgba(28, 62, 48, 0.06);
}
.bulk-dock[hidden] { display: none; }
.bulk-dock-summary { margin: 0; min-width: 0; }
.bulk-dock .button { min-height: 44px; min-width: 0; }
body:has(.bulk-dock:not([hidden])) .app-main { padding-bottom: calc(88px + var(--vv-bottom, 0px)); }
.bulk-modal {
    width: min(520px, calc(100vw - 24px));
    max-width: 100%;
    max-height: calc(100dvh - 24px);
    overflow: auto;
    border: 0;
    border-radius: 16px;
    padding: 18px;
}
.bulk-modal::backdrop { background: rgba(20, 40, 32, 0.48); }
.bulk-modal ul { margin: 0; padding-left: 1.2rem; }
.bulk-modal-actions { display: flex; gap: 12px; }
.bulk-modal-actions .button { flex: 1 1 0; min-width: 0; min-height: 44px; }
.list-confirm { display: grid; gap: 8px; min-width: 0; }
.confirm-target { margin: 0; font-weight: 700; line-height: 1.4; overflow-wrap: anywhere; }
.list-block { margin: 0; }
.more-actions { margin: 0; }
.more-actions-row { display: flex; gap: 12px; margin-top: 12px; }
.sheet-row .more-actions-row > .button { width: auto; flex: 1 1 0; min-width: 0; min-height: 44px; }
.sheet-row .list-confirm .button { width: 100%; min-height: 44px; }
.more-actions .account-fold { margin-top: 12px; }
.sheet-row .button, .sheet-row .copy-amount { width: 100%; }
.sheet-row .copy-amount { min-height: 44px; }
.period-flag { display: block; margin-top: 4px; font-size: 0.82rem; line-height: 1.45; }
.pager { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 8px; }
.pager .button { min-height: 44px; }
.quiet-block { color: var(--muted); }
details { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fbfefc; }
summary { cursor: pointer; font-weight: 700; }

.auth-shell { display: grid; grid-template-columns: minmax(220px, 340px) 1fr; min-height: 100vh; }
.auth-aside {
    background: linear-gradient(165deg, #3dba86 0%, #16865d 46%, #2377b8 100%);
    color: white;
    padding: 40px 28px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.auth-aside .mark, .auth-aside .lead, .auth-aside .sub { color: white; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 24px; }
.card { width: min(100%, 440px); background: white; border-radius: 18px; padding: 28px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.card > form + form { margin-top: 12px; }
.logout-inline { margin-top: 12px; }
.qr { display: flex; justify-content: center; }
.qr svg { display: block; width: min(192px, 100%); height: auto; }
.action-row > button,
.action-row > .button,
.action-row > form { flex: 1 1 8.75rem; min-width: 0; margin: 0; }
.action-row form { display: flex; }
.action-row button,
.action-row .button { width: 100%; min-height: 44px; white-space: normal; }
#loading-overlay { position: fixed; inset: 0; background: rgba(244, 248, 246, 0.72); display: grid; place-items: center; z-index: 20; }
#loading-overlay[hidden] { display: none; }
#loading-message { background: white; border-radius: 16px; padding: 20px 24px; font-weight: 700; border: 1px solid var(--line); }

@media (min-width: 701px) {
    .progress-sheet .sheet-head { display: grid; }
    .progress-sheet .sheet-row,
    .progress-sheet .sheet-head { grid-template-columns: var(--sheet); }
    .progress-sheet .sheet-row > [data-label]::before { content: none; }
    .recent-sheet .sheet-row,
    .docs-sheet .sheet-row { grid-template-columns: minmax(0, 1.15fr) minmax(9.6rem, 0.9fr); align-items: start; }
    .recent-sheet .sheet-issuer { grid-area: issuer; }
    .recent-sheet .sheet-amount { grid-area: amount; }
    .recent-sheet .copy-slot { grid-area: copy; }
    .recent-sheet .sheet-status { grid-area: status; }
    .recent-sheet .sheet-place { grid-area: place; }
    .recent-sheet .sheet-action { grid-area: action; }
    .recent-sheet .sheet-row {
        grid-template-areas:
            "issuer status"
            "amount copy"
            "place action";
    }
    .docs-sheet .sheet-when { grid-area: when; }
    .docs-sheet .sheet-issuer { grid-area: issuer; }
    .docs-sheet .sheet-amount { grid-area: amount; }
    .docs-sheet .copy-slot { grid-area: copy; }
    .docs-sheet .sheet-place { grid-area: place; }
    .docs-sheet .sheet-status { grid-area: status; }
    .docs-sheet .sheet-action { grid-area: action; }
    .docs-sheet .sheet-row {
        grid-template-areas:
            "when issuer"
            "amount copy"
            "place status"
            "action action";
    }
    .card-line { grid-template-columns: minmax(0, 1fr) 6.5rem auto; }
}
@media (min-width: 1200px) {
    .recent-sheet .sheet-head,
    .docs-sheet .sheet-head,
    .progress-sheet .sheet-head {
        display: grid;
        grid-template-columns: var(--sheet);
        column-gap: 12px;
        align-items: center;
        color: var(--muted);
        font-size: 0.78rem;
        font-weight: 700;
        padding: 0 16px;
    }
    .recent-sheet .sheet-row,
    .docs-sheet .sheet-row,
    .progress-sheet .sheet-row {
        grid-template-columns: var(--sheet);
        grid-template-areas: none;
        align-items: center;
    }
    .recent-sheet .sheet-issuer,
    .recent-sheet .sheet-amount,
    .recent-sheet .copy-slot,
    .recent-sheet .sheet-status,
    .recent-sheet .sheet-place,
    .recent-sheet .sheet-action,
    .docs-sheet .sheet-when,
    .docs-sheet .sheet-issuer,
    .docs-sheet .sheet-amount,
    .docs-sheet .copy-slot,
    .docs-sheet .sheet-place,
    .docs-sheet .sheet-status,
    .docs-sheet .sheet-action { grid-area: auto; }
    .sheet-row > [data-label]::before { content: none; }
    .clip-line, .clip-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .period-flag { white-space: normal; overflow: visible; text-overflow: clip; }
    .sheet-amount { text-align: right; }
    .sheet-amount .yen { display: inline-block; min-width: 6.5rem; text-align: right; }
}

.amount-line { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; min-width: 0; max-width: 100%; }
.amount-line input { width: auto; flex: 1 1 8rem; min-width: 0; max-width: 100%; }
.review-field { min-width: 0; max-width: 100%; }
.state-fold { margin-top: 4px; }
.app-main > .review-screen, .app-main > .review-dock { max-width: none; }
.review-screen { display: grid; grid-template-columns: minmax(280px, 0.86fr) minmax(340px, 1.14fr); gap: 16px; min-height: 0; }
.review-pane { min-height: 0; overflow: auto; margin: 0; }
.review-head h2 { margin-bottom: 4px; }
.review-dock {
    position: fixed;
    left: 252px;
    right: 0;
    bottom: var(--vv-bottom, 0px);
    z-index: 12;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    max-width: none;
    padding: 10px 20px 8px;
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 24px rgba(28, 62, 48, 0.06);
}
.review-dock .notice, .review-dock .meta { margin: 0; flex: 1 1 100%; }
.review-dock-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.dock-short { display: none; }
body:has(.review-screen) { overflow: hidden; }
body:has(.review-screen) .app-shell { height: 100vh; }
body:has(.review-screen) .app-main {
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding-bottom: calc(72px + var(--vv-bottom, 0px));
}
@supports (height: 100svh) {
    body:has(.review-screen) .app-shell,
    body:has(.review-screen) .app-main { height: 100svh; }
}
body:has(.review-screen) .review-screen { flex: 1; }
.review-fields, #fields { padding-bottom: 12px; }

@media (max-width: 980px) {
    body:has(.review-screen) { overflow: auto; }
    body:has(.review-screen) .app-shell,
    body:has(.review-screen) .app-main { height: auto; overflow: visible; display: block; }
    .review-screen { display: block; }
    .review-pane { overflow: visible; margin-bottom: 16px; }
    .review-dock, .bulk-dock { left: 0; bottom: var(--vv-bottom, 0px); }
    #fields { padding-bottom: calc(88px + var(--vv-bottom, 0px)); }
}

@media (max-width: 860px) {
    .app-shell, .auth-shell, .compare, .field-grid, .line-row, .filters { grid-template-columns: minmax(0, 1fr); }
    .side { position: sticky; top: 0; z-index: 5; padding: 10px 10px 8px; gap: 8px; border-right: 0; border-bottom: 1px solid var(--line); }
    .nav-main { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; overflow: visible; }
    .nav-main a, .nav-admin a, .side button.ghost { width: auto; }
    .nav-main a { background: white; border: 1px solid var(--line); }
    h2.with-icon { display: block; }
    h2.with-icon .icon { vertical-align: -3px; }
    .who { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
    .who form { width: auto; }
    .app-main { padding: 16px 14px 48px; }
    .button.large, form button[type="submit"] { width: 100%; justify-self: stretch; }
    .review-dock, .bulk-dock { gap: 12px; padding: 8px 10px 8px; }
    .review-dock-actions { gap: 12px; width: 100%; }
    .review-dock-actions > .button,
    .review-dock-actions > button {
        flex: 1 1 8.5rem;
        width: auto;
        min-width: 0;
        min-height: 44px;
        padding: 8px 10px;
        font-size: 0.92rem;
        white-space: normal;
    }
    .review-dock .dock-full { display: none; }
    .review-dock .dock-short { display: inline; }
    .review-dock .notice, .review-dock .meta { font-size: 0.78rem; line-height: 1.35; }
}

.period-modal {
    width: min(520px, calc(100vw - 24px));
    max-height: calc(100vh - 24px - env(safe-area-inset-bottom));
    overflow: auto;
    border: 0;
    border-radius: 16px;
    padding: 18px;
    box-shadow: 0 18px 50px rgba(28, 62, 48, 0.18);
}
.period-modal::backdrop { background: rgba(20, 40, 32, 0.48); }
body:has(.period-modal[open]) .review-dock { visibility: hidden; }
.period-modal-body { display: grid; gap: 12px; }
.period-modal button { width: 100%; min-height: 44px; }
@media (max-width: 860px) {
    .period-modal { width: calc(100vw - 16px); padding: 16px; }
}

fieldset { min-width: 0; max-width: 100%; }
legend { overflow-wrap: anywhere; }
.choice { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; }
.choice legend { font-weight: 700; margin-bottom: 2px; }
.choice .check { min-height: 44px; }
.copy-row, .invite-url-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: start; }
.copy-value, .invite-url-text {
    margin: 0;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid #c9d9d1;
    border-radius: 12px;
    background: white;
    overflow-wrap: anywhere;
    word-break: break-all;
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 0.92rem;
    line-height: 1.45;
}
.invite-copy { min-height: 44px; white-space: nowrap; }
.invite-open { display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.invite-open + .invite-open { margin-top: 12px; }
.invite-open form { gap: 12px; }
form + form { margin-top: 12px; }
.action-row form { margin-top: 0; }
@media (max-width: 860px) {
    .review-dock-actions > button[type="submit"] { width: auto; }
}
@media (max-width: 700px) {
    .copy-row, .invite-url-row { grid-template-columns: minmax(0, 1fr); }
    .invite-copy, .copy-row > .button { width: 100%; }
}

.setup-stack {
    container-type: inline-size;
    display: grid;
    gap: 16px;
}
.setup-stack > * { margin: 0; }
.setup-stack label { gap: 8px; }
.setup-stack > .action-row { margin-top: 4px; }
.action-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 16px;
    align-items: stretch;
}
.button-pair { container-type: inline-size; margin-top: 16px; }
.action-row > button,
.action-row > .button { flex: 1 1 auto; min-width: max-content; }
.action-row > form { flex: 0 0 auto; margin: 0; }
.action-row form { display: flex; margin: 0; }
.action-row button,
.action-row .button,
.action-row form button[type="submit"] {
    width: auto;
    min-width: max-content;
    min-height: 44px;
    padding: 8px 12px;
    white-space: nowrap;
}
@container (max-width: 260px) {
    .action-row { flex-wrap: wrap; }
    .action-row > button,
    .action-row > .button,
    .action-row > form { flex: 1 1 100%; min-width: 0; }
    .action-row button,
    .action-row .button,
    .action-row form button[type="submit"] { width: 100%; min-width: 0; }
}

.usage-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0 0 16px; min-width: 0; }
.usage-total { grid-column: 1 / -1; }
.usage-cards .stat strong { overflow-wrap: normal; word-break: keep-all; white-space: nowrap; font-variant-numeric: tabular-nums; font-size: clamp(0.95rem, 4.2vw, 1.35rem); }
.usage-cards .usage-total strong { font-size: clamp(1.35rem, 7vw, 2.8rem); line-height: 1.15; }
.usage-sub { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.money { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 2px; max-width: 100%; min-width: 0; }
.money-main { font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; white-space: nowrap; }
.yen-unit { font-size: 0.62em; font-weight: 700; margin-left: 0.12em; }
.money-sub { color: var(--muted); font-size: 0.78rem; font-weight: 500; line-height: 1.3; white-space: nowrap; }
.usage-total .money { align-items: flex-start; }
.usage-total .money-main { font-size: clamp(1.35rem, 7vw, 2.8rem); }
.usage-total .money-sub { font-size: 0.95rem; }
.limit-item { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 8px 16px; margin: 0 0 14px; }
.limit-item > span:first-child { font-weight: 700; min-width: 0; }
.limit-item small { display: block; margin-top: 4px; color: var(--muted); font-weight: 500; }
.panel label small { display: block; margin-top: 6px; color: var(--muted); font-size: 0.85rem; line-height: 1.4; }
.money-pair { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 10px; }
.money-sep { font-weight: 700; line-height: 1; padding-bottom: 1.15rem; }
.usage-chart, .hbar, .usage-doc, .usage-table { min-width: 0; max-width: 100%; }
.vbars { display: flex; align-items: flex-end; gap: 4px; height: 168px; margin: 0 0 12px; }
.vbar { flex: 1 1 0; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.vbar i { display: block; width: min(100%, 22px); border-radius: 6px 6px 0 0; background: var(--green); }
.vbar span { display: block; height: 16px; max-width: 100%; overflow: hidden; color: var(--muted); font-size: 0.68rem; line-height: 16px; white-space: nowrap; }
.hbar { display: grid; grid-template-columns: minmax(0, 11rem) minmax(0, 1fr) max-content; gap: 12px; align-items: center; margin: 0 0 12px; }
.hbar-label { min-width: 0; overflow: visible; text-overflow: clip; white-space: normal; overflow-wrap: anywhere; }
.hbar-track { height: 12px; border-radius: 999px; background: var(--soft); overflow: hidden; }
.hbar-track span { display: block; height: 100%; background: var(--blue); }
.usage-table td { font-variant-numeric: tabular-nums; }
.usage-table { width: 100%; border-collapse: collapse; }
.usage-table th, .usage-table td { padding: 8px 0; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.usage-table th { font-weight: 700; overflow-wrap: break-word; word-break: normal; }
.usage-table td { text-align: right; }
.usage-row { grid-template-columns: minmax(0, 1fr) max-content; }
.usage-row > span { white-space: nowrap; overflow-wrap: normal; }
.usage-doc { display: grid; gap: 4px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.usage-doc strong, .usage-doc span { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 390px) {
    .hbar { grid-template-columns: minmax(0, 1fr) max-content; }
    .hbar-track { grid-column: 1 / -1; }
    .usage-row { grid-template-columns: minmax(0, 1fr); }
    .usage-row > span:first-child { white-space: normal; }
    .usage-row .money, .usage-doc .money, .usage-table .money { align-items: flex-start; }
    .money-sub { white-space: normal; }
}
@media (max-width: 340px) {
    .usage-cards { grid-template-columns: minmax(0, 1fr); }
    .usage-sub { white-space: normal; }
}
.card-top { display: block; min-width: 0; width: 100%; }
.card-top .sheet-thumb { float: right; margin: 0 0 8px 12px; }
.card-top-main { display: block; min-width: 0; }
.card-top-main > * + * { margin-top: 4px; }
.card-rest {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    min-width: 0;
    width: 100%;
    clear: both;
}
.card-rest > * { width: 100%; max-width: 100%; min-width: 0; }
.copy-figure.yen { display: inline-flex; width: auto; min-width: 0; text-align: center; justify-content: center; }
.docs-sheet .doc-card [data-label]::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.3;
}
@media (max-width: 1199px) {
    .docs-sheet .doc-card.sheet-row {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: none;
    }
}
@media (min-width: 1200px) {
    .docs-sheet .card-top,
    .docs-sheet .card-top-main,
    .docs-sheet .card-rest { display: contents; }
    .docs-sheet .doc-card { position: relative; }
    .docs-sheet .sheet-thumb {
        position: absolute;
        grid-column: 2;
        grid-row: 1;
        justify-self: end;
        align-self: start;
        width: 64px;
        height: 84px;
        z-index: 1;
    }
    .docs-sheet .sheet-issuer { padding-right: 72px; }
    .docs-sheet .doc-card [data-label]::before { content: none; }
}
