/* 工数見積り：数値を読む業務画面。見せ場は工数サマリーの「総工数」と工程配分の帯のみ。 */
:root {
    --ink: #1c2b3a;
    --muted: #5b6878;
    --page: #f4f6f8;
    --surface: #ffffff;
    --rule: #d9dfe6;
    --rule-strong: #b9c3ce;
    --accent: #1d5fa8;
    --accent-weak: #e8f0f9;
    --dev: #c4861a;
    --dev-weak: #fbf1df;
    --danger: #b42318;
    --danger-weak: #fdecea;
    --ok: #1f7a4d;
    --ok-weak: #e7f4ec;
    --font: "BIZ UDPGothic", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
    --radius: 4px;
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 15px; }

body {
    margin: 0;
    font-family: var(--font);
    color: var(--ink);
    background: var(--page);
    line-height: 1.6;
    font-variant-numeric: tabular-nums;
}

a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

h1 { font-size: 1.6rem; line-height: 1.3; margin: 0 0 .25rem; font-weight: 700; }
h2 { font-size: 1.1rem; margin: 2rem 0 .75rem; font-weight: 700; }

.visually-hidden {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---- 枠組み ---- */
.topbar {
    display: flex; align-items: center; gap: 2rem;
    padding: .6rem 1.5rem;
    background: var(--ink); color: #fff;
}
.brand { color: #fff; font-weight: 700; text-decoration: none; font-size: 1.05rem; }
.topnav { display: flex; gap: 1.25rem; }
.topnav a { color: #c9d4e0; text-decoration: none; padding: .2rem 0; border-bottom: 2px solid transparent; }
.topnav a.active, .topnav a:hover { color: #fff; border-bottom-color: #fff; }
.account { margin-left: auto; display: flex; align-items: center; gap: 1rem; font-size: .9rem; color: #c9d4e0; }
.account form { margin: 0; }
.account .link-button { color: #fff; }

.page { max-width: 1480px; margin: 0 auto; padding: 1.25rem 1.5rem 4rem; }

.crumbs { margin: 0 0 .25rem; font-size: .9rem; color: var(--muted); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.subtitle { margin: 0; color: var(--muted); display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.lead { color: var(--muted); margin-top: 0; }
.hint { color: var(--muted); font-size: .85rem; margin: .35rem 0 0; }
.muted { color: var(--muted); }
.prose { max-width: 70ch; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 700; }

/* ---- ボタン・入力 ---- */
.button {
    display: inline-flex; align-items: center; justify-content: center;
    padding: .45rem 1rem; min-height: 2.25rem;
    border: 1px solid var(--rule-strong); border-radius: var(--radius);
    background: var(--surface); color: var(--ink);
    font: inherit; text-decoration: none; cursor: pointer;
}
.button:hover { border-color: var(--accent); }
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button.primary:hover { background: #174e8c; }
.button:disabled { opacity: .45; cursor: not-allowed; }

.link-button {
    background: none; border: 0; padding: 0; font: inherit; color: var(--accent);
    cursor: pointer; text-decoration: underline;
}
.link-button.danger { color: var(--danger); }

input, select, textarea {
    font: inherit; color: var(--ink);
    padding: .35rem .5rem;
    border: 1px solid var(--rule-strong); border-radius: var(--radius);
    background: var(--surface);
    min-width: 0;
}
input:disabled, select:disabled { background: var(--page); color: var(--muted); }
input[type="number"] { text-align: right; }

.field { display: flex; flex-direction: column; gap: .25rem; }
.field > span { font-size: .85rem; color: var(--muted); }
.field.inline { flex-direction: row; align-items: center; gap: .5rem; }
.check { display: flex; align-items: center; gap: .5rem; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.form-narrow { max-width: 36rem; }
.form-row { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.form-row .grow { flex: 1 1 14rem; }
.actions { display: flex; gap: .5rem; }
.validation-message { color: var(--danger); font-size: .85rem; }
.filters { display: flex; gap: 1.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters input[type="search"] { width: 22rem; max-width: 60vw; }

/* ---- お知らせ ---- */
.notice { padding: .6rem .9rem; border-left: 4px solid var(--rule-strong); background: var(--surface); margin: 0 0 1rem; }
.notice ul { margin: .25rem 0 0; padding-left: 1.25rem; }
.notice p { margin: 0; }
.notice-error { border-left-color: var(--danger); background: var(--danger-weak); }
.notice-ok { border-left-color: var(--ok); background: var(--ok-weak); }
.dirty { margin: 0 0 .75rem; font-size: .9rem; color: var(--dev); font-weight: 700; }
.empty { padding: 2rem; border: 1px dashed var(--rule-strong); background: var(--surface); text-align: center; }
.empty p { margin-top: 0; }

/* ---- 状態 ---- */
.status { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .8rem; border: 1px solid currentColor; white-space: nowrap; }
.status-draft { color: var(--muted); }
.status-inreview { color: var(--dev); }
.status-approved, .status-presented { color: var(--accent); }
.status-accepted { color: var(--ok); }
.status-declined, .status-expired { color: var(--danger); }
.status-superseded { color: var(--muted); text-decoration: line-through; }

/* ---- 表 ---- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .5rem .75rem; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
.table thead th { font-size: .85rem; color: var(--muted); font-weight: 400; background: var(--page); border-bottom-color: var(--rule-strong); }
.table tbody th { font-weight: 400; }
.table tfoot th, .table tfoot td { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: 0; }
.num { text-align: right !important; }
.row-actions { display: flex; gap: .75rem; }
.table tr.is-dev > th { box-shadow: inset 3px 0 0 var(--dev); }
.totals { background: var(--surface); border: 1px solid var(--rule); }
.totals tr.strong th, .totals tr.strong td { font-weight: 700; }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 1.5rem; }

.facts { display: flex; flex-wrap: wrap; gap: .5rem 2.5rem; margin: 0 0 1rem; }
.facts dt { font-size: .8rem; color: var(--muted); }
.facts dd { margin: 0; }

/* ---- 明細入力 ---- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 18.5rem; gap: 1.25rem; align-items: start; }
.grid { border-collapse: collapse; width: 100%; }
.grid th, .grid td { padding: .3rem .35rem; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.grid thead th { position: sticky; top: 0; z-index: 1; background: var(--page); font-size: .8rem; color: var(--muted); font-weight: 400; text-align: left; white-space: nowrap; }
.grid input, .grid select { width: 100%; padding: .25rem .35rem; }
.grid .w-group { min-width: 5rem; }
.grid .w-name { min-width: 8.5rem; }
.grid .w-num { width: 4rem; }
.grid .w-type { min-width: 8rem; }
.grid .w-cx { min-width: 4.5rem; }
.grid th.three-head { text-align: center; }
.grid .col-no { width: 2.5rem; color: var(--muted); text-align: right; }
.grid .readonly { color: var(--muted); }
.grid .three { white-space: nowrap; }
.grid .three input { width: 3.5rem; }
.grid .three input + input { margin-left: .2rem; }
.grid .three input::placeholder { font-size: .75rem; }
.grid tr.has-issue > td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.detail-row td { background: var(--page); border-bottom-color: var(--rule); }
.detail { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: .5rem 1rem; padding: .25rem 0 .5rem; }
.issue { margin: 0; color: var(--danger); font-size: .85rem; grid-column: 1 / -1; }
.add-row { margin-top: .75rem; }

/* 工数サマリー（この画面の主役） */
.summary {
    position: sticky; top: 1rem;
    background: var(--surface); border: 1px solid var(--rule); border-top: 4px solid var(--ink);
    padding: 1rem 1.1rem 1.25rem;
}
.meter { margin-bottom: 1rem; }
.meter-label { margin: 0; font-size: .85rem; color: var(--muted); }
.meter-value { margin: 0; display: flex; align-items: baseline; gap: .35rem; }
.meter-number { font-size: 2.6rem; font-weight: 700; line-height: 1.1; letter-spacing: -.01em; }
.meter-unit { font-size: 1rem; color: var(--muted); }
.meter-sub { margin: .1rem 0 0; color: var(--muted); }

.phase-bar { display: flex; height: .9rem; gap: 2px; margin-bottom: .6rem; }
.phase-bar .seg { flex-basis: 0; min-width: 2px; background: #9fb6cf; }
.phase-bar .seg:nth-child(even) { background: #c3d2e2; }
.phase-bar .seg-dev, .phase-bar .seg-dev:nth-child(even) { background: var(--dev); }
.phase-list { width: 100%; border-collapse: collapse; font-size: .9rem; }
.phase-list th { text-align: left; font-weight: 400; padding: .15rem 0; }
.phase-list td { padding: .15rem 0; }
.phase-list tr.is-dev th, .phase-list tr.is-dev td { color: var(--dev); font-weight: 700; }

.amounts { margin: 1rem 0 0; border-top: 1px solid var(--rule); padding-top: .75rem; }
.amounts div { display: flex; justify-content: space-between; gap: 1rem; padding: .15rem 0; }
.amounts dt { color: var(--muted); }
.amounts dd { margin: 0; font-weight: 700; text-align: right; }
.amounts small { font-weight: 400; color: var(--muted); }

.adjustments { margin-top: 1.25rem; border-top: 1px solid var(--rule); padding-top: .75rem; display: flex; flex-direction: column; gap: .6rem; }
.adjustments h2 { margin: 0; font-size: 1rem; }

/* ---- ログイン ---- */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-brand { font-weight: 700; font-size: 1.1rem; margin: 0 0 1rem; }
.auth-panel { width: 100%; max-width: 24rem; background: var(--surface); border: 1px solid var(--rule); border-top: 4px solid var(--ink); padding: 1.5rem; }
.auth-panel input { width: 100%; }

/* ---- 回線エラー ---- */
#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; padding: .75rem 1.5rem; background: var(--danger-weak); color: var(--danger); border-top: 2px solid var(--danger); z-index: 10; }
#blazor-error-ui .reload { margin-left: 1rem; }

@media (max-width: 1100px) {
    .editor { grid-template-columns: minmax(0, 1fr); }
    .summary { position: static; }
}

@media (max-width: 640px) {
    .page { padding: 1rem; }
    .topbar { flex-wrap: wrap; gap: .75rem 1.25rem; }
    .account { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* ---- 第3弾：手続き・提示・ダッシュボード・質問・ポータル ---- */
.pre { white-space: pre-wrap; }
.block { display: block; }
.warn-text { color: var(--dev); font-weight: 700; }
.section { margin-bottom: 2rem; }
.fieldset { border: 1px solid var(--rule); padding: .75rem 1rem 1rem; margin: 0; display: flex; flex-direction: column; gap: .5rem; background: var(--surface); }
.fieldset legend { padding: 0 .35rem; font-size: .85rem; color: var(--muted); }
.inline-choices { flex-direction: row; flex-wrap: wrap; gap: 1.25rem; }
.check { align-items: flex-start; }
.check input { margin-top: .3rem; }
.table tr.inactive td { color: var(--muted); }

.workflow { background: var(--surface); border: 1px solid var(--rule); border-left: 4px solid var(--accent); padding: .75rem 1rem 1rem; margin: 0 0 1.5rem; }
.workflow h2 { margin: 0 0 .5rem; font-size: 1rem; }
.workflow p { margin: .25rem 0 .75rem; }
.workflow-review { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.workflow-review .grow { flex: 1 1 20rem; }
.workflow-review textarea { width: 100%; }
.workflow .facts { margin: 0; }

.present { display: grid; grid-template-columns: 22rem minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.present-form { display: flex; flex-direction: column; gap: 1rem; position: sticky; top: 1rem; }
.present-preview { background: var(--page); border: 1px dashed var(--rule-strong); padding: 1rem 1.25rem; }
.preview-label { margin: 0 0 .75rem; font-size: .85rem; color: var(--muted); }

.dash { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.dash-block { background: var(--surface); border: 1px solid var(--rule); padding: .75rem 1rem 1rem; }
.dash-block.wide { grid-column: 1 / -1; }
.dash-block h2 { margin: 0 0 .5rem; font-size: 1rem; display: flex; align-items: baseline; gap: .5rem; }
.count { font-size: 1.4rem; font-weight: 700; }
.dash-list { list-style: none; margin: 0; padding: 0; }
.dash-list li { display: flex; gap: .75rem; align-items: baseline; flex-wrap: wrap; padding: .35rem 0; border-bottom: 1px solid var(--rule); }
.dash-list li:last-child { border-bottom: 0; }

.history { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--rule-strong); }
.history li { padding: .3rem 0 .3rem 1rem; display: flex; gap: .75rem; flex-wrap: wrap; }
.history-time { color: var(--muted); font-size: .9rem; }
.history-action { font-weight: 700; }
.history-note { color: var(--danger); }

.thread { background: var(--surface); border: 1px solid var(--rule); padding: .75rem 1rem 1rem; margin-bottom: 1rem; }
.thread-head { display: flex; gap: .75rem; align-items: baseline; flex-wrap: wrap; }
.thread-head h2, .thread-head h3 { margin: 0; font-size: 1rem; }
.thread-link { margin-left: auto; font-size: .9rem; }
.messages { list-style: none; margin: .75rem 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.message { padding: .5rem .75rem; max-width: 46rem; border-radius: var(--radius); }
.message p { margin: 0; }
.from-customer { background: var(--page); border: 1px solid var(--rule); }
.from-staff { background: var(--accent-weak); border: 1px solid #c9daef; margin-left: 2rem; }
.message-meta { font-size: .8rem; color: var(--muted); }
.reply textarea { width: 100%; }
.reply .actions { margin-top: .5rem; }

/* 顧客ポータル */
.portal-bar { background: var(--surface); color: var(--ink); border-bottom: 3px solid var(--ink); }
.portal-bar .brand { color: var(--ink); }
.portal-bar .account { color: var(--muted); }
.portal-bar .account .link-button { color: var(--accent); }
.page-portal { max-width: 1100px; }
.quote-total { border-top: 3px solid var(--ink); border-bottom: 1px solid var(--rule); padding: .75rem 0 1rem; margin: 1rem 0 .5rem; }
.quote-total-label { margin: 0; color: var(--muted); font-size: .9rem; }
.quote-total-value { margin: 0; font-size: 2.4rem; font-weight: 700; line-height: 1.2; }
.quote-total-sub { margin: .25rem 0 0; color: var(--muted); }
.amount-table { max-width: 28rem; }
.respond { margin-top: 2rem; background: var(--surface); border: 1px solid var(--rule); border-top: 3px solid var(--accent); padding: .75rem 1.25rem 1.25rem; }
.respond h2 { margin-top: .25rem; }
.questions { margin-top: 2rem; }
.ask { margin-top: 1.25rem; }
.ask h3 { margin: 0; font-size: 1rem; }

@media (max-width: 1000px) {
    .present { grid-template-columns: minmax(0, 1fr); }
    .present-form { position: static; }
    .dash { grid-template-columns: minmax(0, 1fr); }
}

/* ---- 二要素認証 ---- */
.auth-panel { max-width: 28rem; }
.auth:has(.steps) .auth-panel, .auth:has(.codes) .auth-panel { max-width: 34rem; }
.steps { padding-left: 1.25rem; display: flex; flex-direction: column; gap: 1rem; }
.steps p { margin: 0 0 .5rem; }
.qr { width: 11rem; height: 11rem; border: 1px solid var(--rule); padding: .25rem; background: #fff; }
.qr svg { width: 100%; height: 100%; display: block; }
.totp-key { font-size: 1.05rem; letter-spacing: .04em; background: var(--page); padding: .2rem .45rem; border: 1px solid var(--rule); word-break: break-all; }
.codes { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem 1rem; margin: 1rem 0 1.25rem; }
.codes code { font-size: 1rem; letter-spacing: .04em; }
.account a.account-name { color: inherit; }
h1[tabindex="-1"]:focus { outline: none; }

/* ---- マスタ管理 ---- */
.master-index { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1rem; }
.master-index a { display: flex; flex-direction: column; gap: .25rem; padding: .9rem 1rem; background: var(--surface); border: 1px solid var(--rule); border-left: 4px solid var(--accent); text-decoration: none; color: var(--ink); }
.master-index a:hover { border-color: var(--accent); }
.master-index span { color: var(--muted); font-size: .9rem; }
.master-card { background: var(--surface); border: 1px solid var(--rule); padding: 1rem 1.1rem; margin: 1rem 0; }
.master-card.inactive { opacity: .7; }
.master-card h2 { margin-top: 0; }
.master-card .grid { margin: .75rem 0; }
.narrow-table { max-width: 44rem; margin-top: 1rem; }
.grid .w-code { width: 9rem; }
.grid .w-money, .w-money { width: 8.5rem; }
.form-row .w-num, .field .w-num { width: 6rem; }
.levels, .ratios, .rates { max-width: 44rem; }
.ratios tr.is-dev th { box-shadow: inset 3px 0 0 var(--dev); padding-left: .6rem; }
.ratios tfoot th, .ratios tfoot td { font-weight: 700; border-top: 2px solid var(--ink); }
.ratios tr.sum-ng td { color: var(--danger); }
.rates tr.is-current td { font-weight: 700; }
.detail-json { font-size: .8rem; color: var(--muted); max-width: 32rem; word-break: break-all; }

.grid tbody th { text-align: left; font-weight: 400; }

/* ---- FP法による検算 ---- */
.fp-compare { display: flex; flex-wrap: wrap; gap: 1rem 2.5rem; align-items: flex-end; background: var(--surface); border: 1px solid var(--rule); border-top: 4px solid var(--ink); padding: .9rem 1.1rem; margin-bottom: 1rem; }
.fp-compare p { margin: 0; }
.fp-value { font-size: 1.7rem; font-weight: 700; line-height: 1.2; }
.fp-value span { font-size: .9rem; font-weight: 400; color: var(--muted); }
.fp-ok .fp-value { color: var(--ok); }
.fp-warn .fp-value { color: var(--dev); }
.fp-compare .hint { max-width: 22rem; }
.fp-help { margin-top: 1.5rem; }
.fp-help summary { cursor: pointer; color: var(--accent); }
.fp-help caption { text-align: left; font-weight: 700; padding: .5rem 0; }
