/* 見積書・請求書の一括作成の体験版。色は common/base.css のトークンだけを使う（書類の見本は元のひな形の色のまま） */
.qi { max-width: 1120px; margin: 0 auto; padding: 20px var(--gutter) 56px; }

/* 作業の流れ（1→2→3） */
.qi-steps { display: flex; align-items: center; gap: 10px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; width: fit-content; max-width: 100%; margin: 0 auto 22px; box-shadow: var(--shadow-s); }
.qi-steps button { display: flex; align-items: center; gap: 8px; padding: 7px 16px 7px 8px; border-radius: 999px; font-size: 14px; font-weight: 700; color: var(--ink-3); white-space: nowrap; }
.qi-steps button:hover { background: var(--sunken); color: var(--ink); }
.qi-steps .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--sunken); font-size: 13px; }
.qi-steps button[aria-current="step"] { background: var(--brand); color: #fff; }
.qi-steps button[aria-current="step"] .n { background: var(--accent); color: #fff; }
.qi-steps-line { width: 22px; height: 2px; background: var(--line-2); flex: none; }

.scr-head { max-width: 780px; margin-bottom: 18px; }
.scr-head h2 { font-size: 24px; font-weight: 800; line-height: 1.4; }
.scr-lead { margin-top: 6px; color: var(--ink-2); line-height: 1.85; }
.btn-big { min-height: 50px; padding: 0 24px; font-size: 16px; border-radius: 12px; }
.btn .short { display: none; }
a.btn { text-decoration: none; }
.ex-note { font-size: 12.5px; color: var(--ink-3); line-height: 1.7; }
.empty-msg { padding: 40px 20px; text-align: center; color: var(--ink-3); background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--r-l); display: grid; gap: 14px; justify-items: center; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 18px; box-shadow: var(--shadow-s); min-width: 0; }

/* 1. 明細 */
.flash { margin-bottom: 14px; padding: 10px 14px; border-radius: var(--r-m); background: var(--ok-soft); color: var(--ok); font-weight: 600; font-size: 14px; line-height: 1.7; }
.errbox { margin-bottom: 18px; background: var(--surface); border: 1.5px solid var(--bad-line); border-radius: var(--r-l); padding: 14px 16px; box-shadow: var(--shadow-s); }
.err-sum { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.err-sum .chip { height: 28px; font-size: 13.5px; padding: 0 12px; }
.err-lead { font-size: 13px; color: var(--ink-2); }
.err-table { margin-top: 10px; display: grid; gap: 4px; }
.err-row { display: grid; grid-template-columns: 56px 76px minmax(150px, 190px) minmax(0, 1fr); gap: 4px 12px; align-items: baseline; padding: 6px 10px; border-radius: var(--r-s); font-size: 13.5px; line-height: 1.55; }
.err-row.e { background: var(--bad-soft); }
.err-row.w { background: var(--warn-soft); }
.err-row .chip { height: 22px; align-self: center; justify-self: start; }
.e-doc { font-weight: 700; }
.e-where { color: var(--ink-2); }
.err-hint { margin-top: 8px; font-size: 12.5px; color: var(--ink-3); }

.doc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(500px, 1fr)); gap: 16px; align-items: start; }
.dc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--shadow-s); overflow: hidden; min-width: 0; }
.dc.has-err { border-color: var(--bad-line); }
.dc.has-warn { border-color: var(--warn-line); }
.dc.is-new { box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-s); border-color: var(--accent); }
.dc-head { padding: 12px 14px 10px; border-bottom: 1px solid var(--line); background: var(--paper); }
.dc-id { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.dc-no { font-size: 15px; letter-spacing: .01em; word-break: break-all; }
.dc-st { margin-left: auto; }
.dc-subject { font-size: 15.5px; font-weight: 700; margin-top: 4px; line-height: 1.5; }
.dc-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 6px; font-size: 13px; color: var(--ink-2); }
.dc-client { display: flex; align-items: center; gap: 6px; min-width: 0; }
.dc-client span { white-space: nowrap; }
.dc-client select { min-width: 0; max-width: 270px; height: 32px; padding: 0 6px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface); font-size: 13px; }
.dc-lines { padding: 6px 10px 4px; }
.ln-wrap { border-bottom: 1px solid var(--line); padding: 5px 0; }
.ln-wrap:last-child { border-bottom: 0; }
.ln { display: grid; grid-template-columns: 26px minmax(0, 1fr) 62px 86px 74px 88px; gap: 6px; align-items: center; }
.ln-row { font-size: 11px; color: var(--ink-3); text-align: center; }
.ln-name { font-size: 14px; line-height: 1.4; min-width: 0; overflow-wrap: anywhere; }
.ln-f { display: block; min-width: 0; }
.ln-f > span { display: none; }
.ln-f input, .ln-f select { width: 100%; min-width: 0; height: 34px; padding: 0 7px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface); font-size: 14px; }
.ln-f input { text-align: right; }
.ln-amt { text-align: right; font-weight: 700; font-size: 14px; white-space: nowrap; }
.bad-f { background: var(--bad-soft) !important; border-color: var(--bad-line) !important; }
.warn-f { background: var(--warn-soft) !important; border-color: var(--warn-line) !important; }
.ln-msg { margin: 2px 0 0 32px; padding: 3px 8px; border-radius: 5px; background: var(--bad-soft); color: var(--bad); font-size: 12.5px; line-height: 1.5; }
.ln-msg.warn { background: var(--warn-soft); color: var(--warn); }
.dc-foot:not(:empty) { padding: 8px 14px 12px; border-top: 1px solid var(--line); background: var(--paper); font-size: 13px; }
.tt-title { font-size: 11.5px; font-weight: 700; color: var(--ink-3); margin-bottom: 2px; }
.tt-row { display: flex; justify-content: space-between; gap: 12px; padding: 1px 0; color: var(--ink-2); }
.tt-row.sum { font-weight: 800; color: var(--ink); border-top: 1px solid var(--line-2); margin-top: 3px; padding-top: 3px; font-size: 14px; }
.tt-row.wh { color: var(--bad); }
.temp-note { margin-top: 14px; font-size: 12.5px; color: var(--ink-3); }
.act-bar {
  position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 10px; margin: 18px calc(var(--gutter) * -1) 0; padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  background: rgba(246, 244, 238, .94); backdrop-filter: blur(6px); border-top: 1px solid var(--line);
}
.act-gap { flex: 1; }

/* 2. 発行と履歴 */
.resbox { margin-bottom: 16px; padding: 14px 16px; border-radius: var(--r-l); border: 1.5px solid var(--line-2); background: var(--surface); }
.resbox.ok { border-color: #9cc6ad; background: var(--ok-soft); }
.resbox.bad { border-color: var(--bad-line); background: var(--bad-soft); }
.res-title { font-weight: 800; font-size: 16px; }
.resbox.ok .res-title { color: var(--ok); }
.resbox.bad .res-title { color: var(--bad); }
.res-lines { list-style: none; margin: 8px 0 0; display: grid; gap: 3px; font-size: 14px; }
.res-lines li { padding-left: 14px; position: relative; word-break: break-all; }
.res-lines li::before { content: ''; position: absolute; left: 2px; top: .8em; width: 5px; height: 5px; border-radius: 50%; background: var(--ink-3); }
.res-note { margin-top: 8px; font-size: 13px; color: var(--ink-2); line-height: 1.7; }
.res-note.warn { color: var(--warn); font-weight: 600; }
.hist-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.hist-tools .ex-note { flex-basis: 100%; }
.hist-list { display: grid; gap: 10px; }
.hrow { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.5fr) auto; grid-template-areas: "main nums act" "sub nums act" "draft draft act"; gap: 2px 16px; align-items: center; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); box-shadow: var(--shadow-s); }
.hrow.old { background: var(--paper); box-shadow: none; opacity: .85; }
.h-main { grid-area: main; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.h-no { font-size: 15px; }
.h-sub { grid-area: sub; display: flex; flex-direction: column; font-size: 13px; color: var(--ink-2); min-width: 0; }
.h-subj { color: var(--ink-3); font-size: 12.5px; }
.h-nums { grid-area: nums; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 14px; }
.h-nums span { display: flex; flex-direction: column; line-height: 1.35; }
.h-nums i { font-style: normal; font-size: 11px; color: var(--ink-3); }
.h-nums .bl { font-weight: 800; }
.h-nums .wh { color: var(--bad); }
.h-draft { grid-area: draft; font-size: 12px; color: var(--ink-3); margin-top: 2px; word-break: break-all; }
.h-act { grid-area: act; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.convert { margin-top: 24px; }
.convert h3 { font-size: 17px; font-weight: 800; }
.panel-lead { margin-top: 4px; font-size: 13.5px; color: var(--ink-2); line-height: 1.8; }
.cv-list { display: grid; gap: 6px; margin: 12px 0 14px; }
.cv { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-s); cursor: pointer; background: var(--paper); }
.cv:hover { border-color: var(--line-2); }
.cv input { width: 20px; height: 20px; flex: none; accent-color: var(--brand); }
.cv-t { display: flex; flex-direction: column; font-size: 14px; min-width: 0; }
.cv-t small { font-size: 12.5px; color: var(--ink-3); }
.cv-empty { margin-top: 10px; color: var(--ink-3); font-size: 13.5px; }

/* 3. 書類・メール */
.view-grid { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 18px; align-items: start; }
.view-list { display: grid; gap: 6px; position: sticky; top: 12px; }
.vi { display: grid; grid-template-columns: auto 1fr; gap: 0 8px; align-items: center; text-align: left; padding: 8px 10px; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-m); font-size: 13.5px; }
.vi small { grid-column: 2; color: var(--ink-3); font-size: 12px; }
.vi:hover { border-color: var(--line-2); }
.vi.on { border-color: var(--brand-2); box-shadow: 0 0 0 2px var(--brand-soft); }
.vi.old { opacity: .75; }
.view-main { min-width: 0; }
.view-tabs { display: flex; gap: 4px; padding: 4px; background: var(--sunken); border-radius: 999px; width: fit-content; margin-bottom: 12px; }
.view-tabs button { padding: 6px 18px; border-radius: 999px; font-size: 14px; font-weight: 700; color: var(--ink-3); }
.view-tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-s); }
.view-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 12px; }
.view-tools .ex-note { flex-basis: 100%; }
.paper-wrap { width: 100%; max-width: 794px; margin: 0 auto; }
.paper { position: relative; background: #fff; box-shadow: var(--shadow); border: 1px solid var(--line); overflow: hidden; margin: 0 auto; }
.paper iframe { position: absolute; left: 0; top: 0; width: 794px; height: 1123px; border: 0; transform-origin: 0 0; background: #fff; }
.mail-banner { margin-bottom: 10px; padding: 8px 12px; border-radius: var(--r-s); background: var(--warn-soft); color: var(--warn); font-weight: 600; font-size: 13.5px; }
.mail-card { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-m); box-shadow: var(--shadow-s); overflow: hidden; }
.mail-head { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 4px 10px; padding: 14px 16px; margin: 0; background: var(--paper); border-bottom: 1px solid var(--line); font-size: 13.5px; }
.mail-head dt { color: var(--ink-3); font-size: 12.5px; padding-top: 1px; }
.mail-head dd { margin: 0; word-break: break-all; }
.mail-head .att { display: flex; align-items: center; gap: 6px; }
.mail-body { margin: 0; padding: 16px; font-family: var(--font); font-size: 14px; line-height: 1.85; white-space: pre-wrap; word-break: break-word; }

/* 確認のダイアログ */
.modal { position: fixed; inset: 0; z-index: 1050; display: grid; place-items: center; padding: 16px; background: rgba(22, 36, 44, .5); }
.cf-card { box-sizing: border-box; width: min(440px, 100%); background: var(--surface); border-radius: var(--r-l); box-shadow: var(--shadow-l); padding: 22px 22px 18px; }
.cf-card h3 { font-size: 18px; font-weight: 800; }
.cf-body { margin-top: 10px; display: grid; gap: 6px; font-size: 14.5px; line-height: 1.75; color: var(--ink-2); }
.cf-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

@media (max-width: 1100px) {
  .doc-list { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .view-grid { grid-template-columns: minmax(0, 1fr); }
  .view-list { position: static; display: flex; overflow-x: auto; padding-bottom: 6px; gap: 6px; margin: 0 calc(var(--gutter) * -1); padding-left: var(--gutter); padding-right: var(--gutter); }
  .vi { flex: none; min-width: 150px; }
  .hrow { grid-template-columns: minmax(0, 1fr); grid-template-areas: "main" "sub" "nums" "draft" "act"; gap: 4px; }
  .h-act { justify-content: flex-start; margin-top: 6px; }
  .h-nums { margin-top: 4px; }
}
@media (max-width: 640px) {
  .qi { padding-top: 14px; }
  .qi-steps { gap: 2px; padding: 4px; width: 100%; justify-content: space-between; margin-bottom: 18px; }
  .qi-steps button { flex-direction: column; gap: 2px; padding: 5px 4px; font-size: 11.5px; flex: 1; border-radius: 14px; white-space: normal; text-align: center; line-height: 1.35; }
  .qi-steps-line { width: 10px; }
  .scr-head h2 { font-size: 20px; }
  .scr-lead { font-size: 14px; line-height: 1.8; }
  .btn .long { display: none; }
  .btn .short { display: inline; }
  .act-bar { gap: 8px; padding-top: 10px; }
  .act-bar .reset { display: none; }
  .act-bar .btn-big { flex: 1; min-width: 0; padding: 0 8px; font-size: 15px; min-height: 52px; }
  .errbox { padding: 12px; }
  .err-row { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "lvl doc" "where where" "msg msg"; gap: 2px 8px; }
  .err-row .chip { grid-area: lvl; }
  .e-doc { grid-area: doc; }
  .e-where { grid-area: where; font-size: 12.5px; }
  .e-msg { grid-area: msg; }
  .dc-head { padding: 10px 12px 8px; }
  .dc-client { flex: 1 1 100%; }
  .dc-client select { flex: 1; max-width: none; font-size: 16px; height: 44px; }
  .dc-lines { padding: 4px 10px 2px; }
  .ln { grid-template-columns: 22px minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "row name name" "row qty price" "row rate amt"; gap: 5px 6px; }
  .ln-row { grid-area: row; align-self: start; padding-top: 3px; }
  .ln-name { grid-area: name; font-weight: 600; }
  .ln-f { display: flex; align-items: center; gap: 6px; }
  .ln-f > span { display: block; font-size: 12px; color: var(--ink-3); width: 2.2em; flex: none; }
  .f-q { grid-area: qty; } .f-p { grid-area: price; } .f-r { grid-area: rate; }
  .ln-f input, .ln-f select { height: 44px; font-size: 16px; }
  .ln-amt { grid-area: amt; align-self: center; font-size: 15px; }
  .ln-msg { margin-left: 28px; }
  .dc-foot:not(:empty) { padding: 8px 12px 12px; }
  .view-tabs { width: 100%; }
  .view-tabs button { flex: 1; padding: 8px 6px; }
  .view-tools .btn { flex: 1 1 100%; }
  .qi .btn, .view-tabs button { min-height: 44px; }
  .cv { min-height: 48px; }
  .cf-card { min-width: 0; width: 100%; box-sizing: border-box; }
  .cf-btns { flex-direction: column-reverse; }
  .cf-btns .btn { flex: none; width: 100%; min-height: 48px; }
  .hist-tools .btn { flex: 1 1 100%; }
  .h-act .btn { flex: 1; }
  .mail-head { grid-template-columns: 48px minmax(0, 1fr); padding: 12px; }
  .mail-body { padding: 12px; font-size: 14px; }
}
