:root {
  --bg: #F4F6F5; --surface: #FFFFFF; --surface-2: #EDF1F0;
  --ink: #1B2730; --ink-2: #5A6A73; --ink-3: #6E7C85; --line: #DDE4E2;
  --accent: #0E6F78; --accent-ink: #FFFFFF; --accent-soft: #DCEFF1;
  --danger: #C0392B; --danger-soft: #FBE6E3; --warn: #9A6410; --warn-soft: #FBEFD9; --ok: #2E7D4F; --ok-soft: #DDF2E5;
  --shadow: 0 8px 24px rgba(20, 40, 45, .14); --radius: 12px;
  --font: "Zen Kaku Gothic New", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121A1D; --surface: #1B2529; --surface-2: #243034; --ink: #E8EEEE; --ink-2: #A9B7BC; --ink-3: #7D8B91; --line: #2F3D42;
    --accent: #3FB1BC; --accent-ink: #0B1517; --accent-soft: #1A3D42;
    --danger: #EF7A6C; --danger-soft: #45231F; --warn: #E0A548; --warn-soft: #3E3118; --ok: #5CC28A; --ok-soft: #1B3B2A;
    --shadow: 0 8px 24px rgba(0,0,0,.5);
  }
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; }
[hidden] { display: none !important; }
a { color: var(--accent); }
.hint { color: var(--ink-2); font-size: 13px; margin: 4px 0 8px; }
.form-error { color: var(--danger); font-size: 13px; margin: 6px 0 0; }

/* ---------- 共通 ---------- */
.wrap { max-width: 720px; margin: 0 auto; padding: 16px 16px 80px; }
.card { background: var(--surface); border-radius: 16px; padding: 18px 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card h2 { font-size: 17px; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.card h2 .sub { font-weight: 400; font-size: 13px; color: var(--ink-2); }
.brand { display: flex; align-items: center; gap: 12px; margin: 6px 0 16px; }
.brand-mark { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 13px; flex: none; }
.brand h1 { font-size: 18px; }
.brand p { margin: 0; color: var(--ink-2); font-size: 13px; }
.notice { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 14px; }
.notice strong { font-weight: 700; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 13px; color: var(--ink-2); }
.field label .req { color: var(--danger); margin-left: 4px; font-size: 11px; }
input[type="text"], input[type="number"], input[type="tel"], input[type="email"], input[type="password"], input[type="date"], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); min-height: 44px;
}
input[type="number"] { text-align: right; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 500; min-height: 44px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-block { width: 100%; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-sm { padding: 6px 10px; min-height: 34px; font-size: 13px; }
.actions { display: flex; gap: 10px; margin-top: 16px; }
.actions .btn { flex: 1; }
.link-btn { background: none; border: 0; color: var(--accent); padding: 0; text-decoration: underline; }

/* ---------- ログイン ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; }

/* ---------- 種類の選択 ---------- */
.kind-cards { display: grid; gap: 10px; }
.kind-card { text-align: left; padding: 16px; border: 2px solid var(--line); border-radius: 14px; background: var(--surface); display: flex; flex-direction: column; gap: 4px; }
.kind-card strong { font-size: 16px; }
.kind-card span { font-size: 13px; color: var(--ink-2); }
.kind-card.active { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- 明細行 ---------- */
.section { margin-bottom: 8px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.section-head h3 { font-size: 15px; }
.section-total { font-size: 13px; color: var(--ink-2); }
.section-total b { color: var(--ink); font-size: 15px; }
.line { background: var(--surface-2); border-radius: 12px; padding: 12px; margin-bottom: 8px; position: relative; }
.line .field { margin-bottom: 8px; }
.line .field:last-child { margin-bottom: 0; }
.line-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 13px; color: var(--ink-2); }
.line-head .subtotal { font-weight: 700; color: var(--ink); font-size: 14px; }
.line-remove { background: none; border: 0; color: var(--ink-3); font-size: 13px; padding: 2px 6px; }
.line-remove:hover { color: var(--danger); }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid-arrow { display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px; align-items: end; }
.grid-arrow .arrow { padding-bottom: 12px; color: var(--ink-3); }
.add-line { width: 100%; margin-top: 4px; border-style: dashed; }
.total-box { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; background: var(--accent-soft); border-radius: 12px; font-weight: 700; margin-top: 8px; }
.total-box .amt { font-size: 20px; }

/* ---------- ファイル ---------- */
.files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.file-thumb { position: relative; width: 84px; height: 84px; border-radius: 10px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); display: grid; place-items: center; font-size: 11px; color: var(--ink-2); text-align: center; padding: 4px; }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-thumb .x { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; border: 0; font-size: 12px; line-height: 22px; padding: 0; }
.file-thumb.uploading::after { content: "送信中…"; position: absolute; inset: 0; display: grid; place-items: center; background: rgba(255,255,255,.7); color: var(--ink); font-size: 11px; }
.file-add { width: 84px; height: 84px; border-radius: 10px; border: 1px dashed var(--accent); color: var(--accent); background: transparent; display: grid; place-items: center; font-size: 12px; line-height: 1.3; }
.file-add input { display: none; }

/* ---------- 確認画面 ---------- */
.summary dl { display: grid; grid-template-columns: 7em 1fr; gap: 6px 10px; margin: 0; font-size: 14px; }
.summary dt { color: var(--ink-2); }
.summary dd { margin: 0; word-break: break-all; }
.summary table { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; }
.summary th, .summary td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.summary td.num, .summary th.num { text-align: right; white-space: nowrap; }
.summary tr.ng td { color: var(--ink-3); text-decoration: line-through; }
.done-no { font-size: 32px; font-weight: 700; color: var(--accent); text-align: center; margin: 8px 0; }
.copy-box { display: flex; gap: 8px; align-items: center; }
.copy-box input { flex: 1; font-size: 12px; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; margin: 14px 0 4px; }
.check input { width: 20px; height: 20px; margin-top: 2px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow); z-index: 50; max-width: 90vw; }
.toast.err { background: var(--danger); color: #fff; }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; z-index: 40; color: #fff; font-weight: 700; }
.mono { font-family: ui-monospace, Menlo, monospace; }
@media (max-width: 480px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-3 > :first-child { grid-column: 1 / -1; }
}
