:root { font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif; color: #243b43; background: #f3f6f6; font-size: 14px; }
* { box-sizing: border-box; }
body { margin: 0; }
header { height: 64px; background: #fff; border-bottom: 1px solid #dde5e6; display: flex; align-items: center; justify-content: space-between; padding: 0 28px; }
.brand { display: flex; gap: 14px; align-items: center; font-size: 26px; font-weight: 700; color: #137477; }
.brand span { font-size: 16px; letter-spacing: .05em; }
.header-actions { display: flex; gap: 10px; align-items: center; font-size: 13px; color: #557078; }
.notice { background: #fff4d9; color: #725119; padding: 10px 28px; font-size: 12px; }
#status { position: sticky; top: 0; z-index: 10; background: #dceee8; padding: 0 24px; line-height: 34px; min-height: 34px; }
#status.error { background: #ffe4df; color: #962d26; }
#status:empty { display: none; }

#workspace { display: grid; grid-template-columns: 235px minmax(0, 1fr); max-width: 1800px; margin: auto; }
#workspace[hidden], #login[hidden] { display: none; }
aside { padding: 26px 18px; border-right: 1px solid #dce5e6; min-height: calc(100vh - 110px); }
aside > button { width: 100%; margin-bottom: 8px; }
#projects button { width: 100%; text-align: left; background: transparent; color: #38565c; border: 1px solid #d0dfe0; margin-top: 8px; white-space: normal; line-height: 1.6; font-weight: 500; }
#projects button.current { border-color: #167976; background: #e8f3f2; }
#projects small { color: #72868a; }
.aside-note { font-size: 12px; color: #72868a; line-height: 1.9; margin: 26px 0; }
article { padding: 26px 30px; min-width: 0; }

.eyebrow { font-size: 12px; letter-spacing: .12em; color: #6b898f; margin: 0 0 8px; }
h1 { font-size: 24px; margin: 0 0 8px; letter-spacing: .02em; }
h2 { font-size: 17px; margin: 0 0 16px; }
h3 { font-size: 14px; margin: 18px 0 10px; }
.title-row, .section-heading { display: flex; justify-content: space-between; gap: 18px; align-items: center; flex-wrap: wrap; }
.title-row { margin-bottom: 18px; }
#revision, .hint { color: #72858a; font-size: 12px; line-height: 1.8; }
.hint { margin: 0 0 12px; }
.card { background: #fff; border: 1px solid #dce6e6; border-radius: 9px; padding: 22px; margin-bottom: 18px; box-shadow: 0 3px 10px #21373e05; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: #557078; }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid #cad8da; border-radius: 5px; background: #fff; color: #243b43; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid #3f9b99; outline-offset: 1px; }
input[readonly] { background: #f5f8f8; color: #6b898f; }
textarea { width: 100%; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
button { border: 1px solid transparent; border-radius: 5px; padding: 9px 15px; background: #167976; color: #fff; cursor: pointer; font: inherit; font-weight: 600; white-space: nowrap; }
button:hover { filter: brightness(.94); }
button:disabled { opacity: .4; cursor: not-allowed; }
.secondary { background: #fff; border-color: #c6d9db; color: #3f686e; }
.ghost { background: transparent; border-color: transparent; color: #3f686e; padding: 6px 10px; }
.danger { background: #fff; border-color: #e5b6b0; color: #962d26; }
.small { font-size: 12px; padding: 5px 9px; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; margin-top: 12px; }
.row label { flex: 1; min-width: 120px; }
.row .narrow { flex: 0 0 120px; }
.checkbox { flex-direction: row; align-items: center; gap: 6px; }

.summary { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 14px; margin-bottom: 16px; }
.summary section { padding: 18px 20px; background: #fff; border: 1px solid #dce6e6; border-radius: 8px; }
.summary span { display: block; font-size: 12px; color: #71898f; margin-bottom: 8px; }
.summary strong { font-size: 26px; font-variant-numeric: tabular-nums; }
.summary .total { background: #184d55; color: #fff; }
.summary .total span { color: #bbd7da; }
.summary.stale strong { color: #b9860f; }
.summary.stale .total strong { color: #ffd98a; }
.calc-error { background: #ffe4df; color: #962d26; border-radius: 6px; padding: 10px 14px; margin-bottom: 14px; }

.tabs { display: flex; gap: 4px; border-bottom: 2px solid #dce6e6; margin-bottom: 18px; flex-wrap: wrap; }
.tabs button { background: transparent; color: #557078; border: none; border-bottom: 3px solid transparent; border-radius: 0; padding: 10px 16px; margin-bottom: -2px; }
.tabs button.active { color: #137477; border-bottom-color: #137477; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th { background: #f4f8f8; font-size: 12px; font-weight: 500; color: #69858a; text-align: left; padding: 10px 8px; white-space: nowrap; }
td { padding: 7px 6px; border-bottom: 1px solid #e8eeee; vertical-align: middle; }
td input, td select { width: 100%; padding: 6px 8px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.ops { white-space: nowrap; }
td.ops button { font-size: 11px; padding: 5px 7px; margin: 1px; }
tr.group td { background: #f9fbfb; font-weight: 600; }
tr.group td.name-cell button { font-weight: 600; }
tr.selected td { background: #e8f3f2; }
.muted { color: #72858a; }
.tag { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 10px; background: #e8f0f1; color: #3f686e; margin-right: 4px; }
.tag.warn { background: #fff0cc; color: #7a5a10; }
.tag.bad { background: #ffe4df; color: #962d26; }
.tag.ok { background: #dcf1e6; color: #1e6b45; }

.build { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 18px; }
.tree-nav { background: #fff; border: 1px solid #dce6e6; border-radius: 9px; padding: 14px; max-height: 70vh; overflow: auto; }
.tree-nav button { display: block; width: 100%; text-align: left; background: transparent; color: #38565c; border: none; padding: 6px 8px; font-weight: 500; border-radius: 4px; white-space: normal; }
.tree-nav button.current { background: #e8f3f2; color: #137477; font-weight: 600; }
.tree-nav .sub { font-size: 12px; color: #72868a; margin-left: 8px; }
.breadcrumb { font-size: 13px; color: #557078; margin-bottom: 10px; }
.breadcrumb button { background: transparent; border: none; color: #137477; padding: 0 4px; font-weight: 600; }
.breadcrumb span { margin: 0 4px; color: #a5b7ba; }
.add-panel { border-top: 1px dashed #cad8da; margin-top: 16px; padding-top: 16px; }
.candidates { max-height: 220px; overflow: auto; border: 1px solid #dce6e6; border-radius: 6px; margin-top: 8px; }
.candidates button { display: block; width: 100%; text-align: left; background: transparent; border: none; border-bottom: 1px solid #eef2f2; color: #243b43; padding: 8px 10px; font-weight: 500; white-space: normal; }
.candidates button.current { background: #e8f3f2; }
.candidates small { color: #72868a; display: block; }
.conditions-box { background: #f7fafa; border: 1px solid #dce6e6; border-radius: 6px; padding: 12px; margin-top: 10px; }
.conditions-box .grid-3 { gap: 10px; }
.preview-box { background: #f0f7f6; border: 1px solid #c6dedd; border-radius: 6px; padding: 12px 14px; margin-top: 10px; font-variant-numeric: tabular-nums; }
.trace { margin-left: 14px; border-left: 2px solid #e2ebeb; padding-left: 12px; font-size: 13px; line-height: 1.8; }
.trace details summary { cursor: pointer; }
.trace .line { display: flex; gap: 10px; flex-wrap: wrap; }
.trace .line .n { min-width: 200px; }
.evidence-row { border-bottom: 1px solid #e7eeee; padding: 10px 0; line-height: 1.8; }
.source { color: #72858a; font-size: 12px; }
.warnings ul { margin: 0; padding-left: 20px; line-height: 1.8; max-height: 300px; overflow: auto; }
.warnings li.warn { color: #7a5a10; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: #6b898f; }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }
pre { white-space: pre-wrap; word-break: break-word; font-size: 12px; line-height: 1.7; background: #f7fafa; padding: 10px; border-radius: 6px; }
details.card summary { cursor: pointer; font-weight: 600; }
details.card[open] summary { margin-bottom: 14px; }
.diff-added td { background: #e6f5ec; }
.diff-removed td { background: #fbe9e6; }
.diff-changed td { background: #fff7e0; }
.dialog { background: #fff; border: 1px solid #c6d9db; border-radius: 9px; padding: 18px; margin-top: 14px; }
.login { max-width: 470px; margin: 70px auto; background: #fff; border: 1px solid #dce6e6; border-radius: 12px; padding: 36px; }
.login p { line-height: 1.9; color: #72858a; }
.login label { margin: 16px 0; }
.login button { width: 100%; }
.notice a { color: inherit; margin-left: 8px; }
.demo-entry { background: #eef7f4; border: 1px solid #cfe5dc; border-radius: 9px; padding: 16px 18px; margin: 8px 0 22px; }
.demo-entry p { margin: 0 0 10px; color: #3c5a5a; }
.demo-entry .checkbox { display: block; margin: 8px 0 12px; }
.demo-entry .hint { margin: 12px 0 0; }
.login-foot { margin: 22px 0 0; text-align: center; }
.login-foot a { color: inherit; margin-left: 8px; }
.fee-line { padding: 12px 0; border-bottom: 1px solid #e8eeee; }
.fee-inputs { display: grid; grid-template-columns: 2fr 1fr 1.4fr 1.2fr .8fr .8fr 1fr; gap: 8px; align-items: end; }
.fee-result { display: flex; gap: 16px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.fee-result .amount { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 15px; min-width: 140px; }
.fee-result .actions { margin-left: auto; }
.stage-list { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; }
.stage-list div { background: #f4f8f8; border-radius: 6px; padding: 8px 12px; font-size: 13px; }
.stage-list strong { display: block; font-variant-numeric: tabular-nums; }

@media (max-width: 1100px) { .build { grid-template-columns: 1fr; } .fee-inputs { grid-template-columns: 1fr 1fr 1fr; } .grid-4, .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 760px) { #workspace { display: block; } aside { min-height: 0; border-bottom: 1px solid #ddd; } .summary { grid-template-columns: 1fr; } article { padding: 16px; } .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* utility classes (inline styles are blocked by the CSP) */
.mt-6 { margin-top: 6px; } .mt-8 { margin-top: 8px; } .mt-10 { margin-top: 10px; } .mt-12 { margin-top: 12px; } .mt-14 { margin-top: 14px; } .mt-18 { margin-top: 18px; }
.plain-list { list-style: none; padding: 0; margin: 0; }
.clamp { max-width: 360px; }
.tiny { font-size: 11px; }
.w-90 { width: 90px; } .w-100 { width: 100px; } .right { text-align: right; }
.span-all { grid-column: 1 / -1; }
.pad-10 { padding: 10px; }
.tree-nav button[data-depth="1"] { padding-left: 22px; } .tree-nav button[data-depth="2"] { padding-left: 36px; } .tree-nav button[data-depth="3"] { padding-left: 50px; }
.tree-nav button[data-depth="4"] { padding-left: 64px; } .tree-nav button[data-depth="5"] { padding-left: 78px; } .tree-nav button[data-depth="6"] { padding-left: 92px; }
.tree-nav button[data-depth="7"] { padding-left: 106px; } .tree-nav button[data-depth="8"] { padding-left: 120px; }
td.name-cell { min-width: 170px; }
td.name-cell input { display: block; width: 100%; }
td.name-cell .spec-input { margin-top: 4px; font-size: 12px; padding: 4px 8px; color: #557078; }
td.qty-cell input { display: block; width: 96px; margin-left: auto; }
td.qty-cell .unit-input { width: 60px; margin-top: 4px; font-size: 12px; padding: 4px 8px; text-align: center; }
.build { grid-template-columns: 220px minmax(0, 1fr); }
.w-60 { width: 60px; }
