:root {
  --bg: #f4f5f3; --surface: #fff; --ink: #1d2523; --muted: #5f6b67; --line: #d9ded9;
  --accent: #14594f; --accent-ink: #fff; --accent-soft: #e2efeb;
  --danger: #a92a22; --danger-soft: #fbeae8; --warn: #8a5a00; --warn-soft: #fdf3dc; --info: #2c5a8a; --info-soft: #e8f0f8;
  --radius: 6px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.6 "BIZ UDPGothic", "Yu Gothic UI", "Meiryo", sans-serif; }
h1 { font-size: 20px; margin: 0; } h2 { font-size: 15px; margin: 0 0 10px; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); } .small { font-size: 12px; }

.topbar { display: flex; align-items: center; gap: 20px; height: 48px; padding: 0 16px; background: var(--accent); color: var(--accent-ink); }
.brand { font-weight: 700; white-space: nowrap; }
.nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.nav a { color: inherit; text-decoration: none; padding: 5px 11px; border-radius: var(--radius); white-space: nowrap; }
.nav a:hover { background: rgba(255,255,255,.12); }
.nav a.active { background: rgba(255,255,255,.22); font-weight: 700; }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 5px; border-radius: 10px; background: #fff; color: var(--accent); font-size: 12px; font-weight: 700; text-align: center; }
.user { display: flex; align-items: center; gap: 10px; white-space: nowrap; font-size: 13px; }
.user button { background: none; border: 1px solid rgba(255,255,255,.5); color: inherit; border-radius: var(--radius); padding: 1px 9px; cursor: pointer; }

.page { max-width: 1240px; margin: 0 auto; padding: 22px 16px 48px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }

.btn { border: 1px solid var(--line); background: var(--surface); padding: 6px 14px; border-radius: var(--radius); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.btn.primary:hover { background: #0f4a41; }
.btn.danger { color: var(--danger); border-color: #e3bdb9; }
.btn.large { padding: 10px 22px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: default; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 400; color: var(--muted); border-bottom: 1px solid var(--line); padding: 6px 8px; white-space: nowrap; }
td { padding: 8px; border-bottom: 1px solid #eceeeb; vertical-align: middle; }
th.num { text-align: right; }
tr.row-link { cursor: pointer; } tr.row-link:hover td { background: var(--accent-soft); }
.table-wrap { overflow-x: auto; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

.pill { display: inline-block; padding: 0 8px; border-radius: 10px; font-size: 12px; white-space: nowrap; background: var(--accent-soft); color: var(--accent); }
.pill.gray { background: #eceeeb; color: var(--muted); } .pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }

label.field { display: block; margin-bottom: 8px; }
label.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
input[type=text], input[type=password], input[type=date], input:not([type]), select, textarea { width: 100%; padding: 5px 8px; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
input.amount { text-align: right; font-variant-numeric: tabular-nums; }
textarea { resize: vertical; min-height: 54px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.grid3 { display: grid; grid-template-columns: 2fr 1fr 2fr; gap: 0 10px; }
fieldset { border: 0; border-top: 1px solid var(--line); margin: 12px 0 0; padding: 10px 0 0; }
legend { font-weight: 700; padding: 0 8px 0 0; font-size: 13px; }

.alerts { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.alert { padding: 7px 10px; border-radius: 4px; font-size: 13px; border-left: 3px solid; }
.alert.danger { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.alert.warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.alert.info { background: var(--info-soft); border-color: var(--info); color: var(--info); }
.alert ul { margin: 0; padding-left: 18px; }

.review { display: grid; grid-template-columns: minmax(0, 1fr) 500px; height: calc(100vh - 48px); }
.viewer { background: #525659; min-height: 0; } .viewer iframe { width: 100%; height: 100%; border: 0; display: block; }
.viewer .img-wrap { height: 100%; overflow: auto; } .viewer img { width: 100%; display: block; }
.side { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-left: 1px solid var(--line); }
.side-head { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.side-head .spacer { flex: 1; }
.side-body { flex: 1; overflow-y: auto; padding: 14px; }
.side-foot { border-top: 1px solid var(--line); padding: 10px 14px; background: #fafbf9; }
.foot-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.foot-row .spacer { flex: 1; }

.pay-total { display: flex; justify-content: space-between; align-items: baseline; padding: 7px 10px; background: var(--accent-soft); border-radius: 4px; margin: 2px 0 8px; }
.pay-total b { font-size: 19px; font-variant-numeric: tabular-nums; }
dl.facts { display: grid; grid-template-columns: 112px 1fr; gap: 3px 10px; margin: 0; }
dl.facts dt { color: var(--muted); font-size: 12px; padding-top: 2px; } dl.facts dd { margin: 0; overflow-wrap: anywhere; }
.amount-big { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.timeline { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.timeline li { padding: 5px 0 5px 12px; border-left: 2px solid var(--line); }
.timeline .comment { background: #f4f5f3; padding: 2px 8px; border-radius: 4px; margin-top: 2px; white-space: pre-wrap; }

.drop { border: 2px dashed #a9b5af; border-radius: var(--radius); padding: 34px 16px; text-align: center; background: var(--surface); cursor: pointer; margin-bottom: 16px; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop strong { font-size: 16px; display: block; margin-bottom: 4px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs a { padding: 6px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--accent); border-color: var(--accent); font-weight: 700; }
.toolbar { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.toolbar label.field { margin: 0; }
.total-line { font-size: 16px; font-weight: 700; }

dialog { border: 0; border-radius: var(--radius); padding: 18px; width: min(560px, calc(100vw - 32px)); max-height: 88vh; box-shadow: 0 10px 40px rgba(0,0,0,.28); }
dialog::backdrop { background: rgba(20,30,27,.4); }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.check-row { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.check-row label, .inline-check { display: inline-flex; gap: 5px; align-items: center; }

.auth { max-width: 380px; margin: 11vh auto 0; padding: 0 16px; }
.auth h1 { margin-bottom: 14px; }
.auth .btn { width: 100%; margin-top: 6px; }

#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: #22302c; color: #fff; padding: 9px 14px; border-radius: var(--radius); max-width: 420px; }
.toast.error { background: var(--danger); }

@media (max-width: 960px) {
  .review { grid-template-columns: 1fr; grid-template-rows: 46vh auto; height: auto; }
  .side-body { overflow: visible; }
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 16px; gap: 6px 14px; }
  .grid3 { grid-template-columns: 1fr; }
}

.qr { display: block; max-width: 100%; margin: 8px auto 12px; image-rendering: pixelated; }
.secret { display: block; padding: 6px 8px; background: #f4f5f3; border-radius: 4px; overflow-wrap: anywhere; font-size: 13px; }
.recovery { padding: 10px 14px; background: #f4f5f3; border-radius: 4px; font-size: 15px; line-height: 1.8; columns: 2; }
.auth details { margin-bottom: 10px; }
@media print { .btn, .inline-check { display: none; } }
