:root {
  color-scheme: light;
  --paper: #faf8f5;
  --surface: #ffffff;
  --surface-soft: #f7f5f2;
  --surface-stone: #efebe5;
  --ink: #1a1a1a;
  --muted: #6a6a6a;
  --line: rgba(139, 165, 181, 0.28);
  --teal: #3d5f6e;
  --teal-dark: #1e2a30;
  --teal-light: #c5d5de;
  --teal-pale: #e8eff3;
  --amber: #c4a96a;
  --rose: #5e4a5c;
  --green: #4a7fa0;
  --shadow: 0 18px 44px rgba(30, 42, 48, 0.07);
  --font-en: Optima, "Palatino Linotype", "Noto Sans JP", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(170deg, rgba(232, 239, 243, 0.86), rgba(250, 248, 245, 0) 330px),
    var(--paper);
  color: var(--ink);
  font-family:
    "Noto Sans JP", "Hiragino Sans", "Helvetica Neue", Arial, "Yu Gothic", Meiryo,
    sans-serif;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 30px clamp(18px, 4vw, 44px) 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal-dark);
  font-family: Optima, "Palatino Linotype", serif;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.32em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 44px);
  font-family: var(--font-en);
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

h3 {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.topbar__meta {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-family: var(--font-en);
  font-size: 12px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.topbar__meta a {
  color: var(--teal-dark);
  font-weight: 500;
  text-decoration: none;
}

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  grid-template-areas:
    "controls forecast"
    "controls evidence";
  gap: 18px;
  padding: 0 clamp(18px, 4vw, 44px) 36px;
}

.control-surface,
.forecast-surface,
.evidence-surface {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.control-surface {
  grid-area: controls;
  align-self: start;
  max-height: none;
  overflow: visible;
  overscroll-behavior: auto;
  padding: 18px;
  position: sticky;
  top: 14px;
}

.forecast-surface {
  grid-area: forecast;
  padding: 18px;
}

.evidence-surface {
  grid-area: evidence;
  padding: 18px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.section-heading--compact {
  margin-bottom: 10px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.choice-block {
  margin-bottom: 14px;
}

.choice-block--compact {
  margin: 14px 0 8px;
}

.choice-block__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.choice-block__header span,
label span,
.metric-label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.choice-block__header span {
  margin-bottom: 0;
}

.choice-block__header strong {
  color: var(--teal);
  font-size: 12px;
  font-weight: 500;
}

select,
input,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  outline: none;
}

select,
input {
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 12px;
  line-height: 1.8;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(139, 165, 181, 0.22);
}

.toggle-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.toggle-grid label,
.check-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  font-size: 13px;
  font-weight: 500;
  transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.check-grid label {
  background: #fff;
}

.toggle-grid label:has(input:checked),
.check-grid label:has(input:checked) {
  border-color: rgba(61, 95, 110, 0.45);
  background: var(--teal-pale);
  box-shadow: inset 0 0 0 1px rgba(61, 95, 110, 0.12);
}

.toggle-grid input,
.check-grid input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--teal);
}

[hidden] {
  display: none !important;
}

.freeword {
  display: block;
  margin-top: 10px;
}

.primary-button,
.ghost-button,
.segmented__button {
  min-height: 38px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 500;
  letter-spacing: 0.04em;
  transition: background 180ms ease, border-color 180ms ease, box-shadow 180ms ease, color 180ms ease, transform 180ms ease;
}

.primary-button {
  width: 100%;
  margin-top: 14px;
  background: var(--teal-dark);
  color: #f0ede8;
}

.primary-button--compact {
  width: auto;
  margin-top: 0;
  padding: 0 16px;
}

.primary-button:hover {
  background: #2a3940;
  box-shadow: 0 8px 22px rgba(61, 95, 110, 0.18);
  transform: translateY(-1px);
}

.ghost-button {
  padding: 0 12px;
  border-color: rgba(61, 95, 110, 0.42);
  background: #fff;
  color: var(--teal);
}

.ghost-button:hover {
  border-color: var(--teal);
  background: var(--teal);
  color: #f0ede8;
  transform: translateY(-1px);
}

.status-pill,
.tag,
.reason {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.status-pill {
  background: rgba(196, 169, 106, 0.2);
  color: #7a6a54;
}

.status-pill.is-good {
  background: rgba(139, 165, 181, 0.22);
  color: var(--teal);
}

.status-pill.is-risk {
  background: rgba(94, 74, 92, 0.13);
  color: var(--rose);
}

.price-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.simulation-summary {
  margin-bottom: 16px;
}

.price-option {
  min-height: 134px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.96);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.price-option:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(30, 42, 48, 0.06);
}

.price-option strong {
  display: block;
  margin-top: 10px;
  font-family: var(--font-en);
  font-size: clamp(22px, 3vw, 34px);
  font-weight: 600;
  line-height: 1;
}

.price-option span {
  display: block;
  color: var(--muted);
  font-family: var(--font-en);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.price-option.is-main {
  border-color: rgba(61, 95, 110, 0.38);
  background: linear-gradient(180deg, rgba(232, 239, 243, 0.86), #fff 72%);
}

.meter-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin: 18px 0;
}

.meter-row strong {
  font-family: var(--font-en);
  font-size: 22px;
}

.meter {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-stone);
}

.meter span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--amber), var(--rose));
  transition: width 180ms ease;
}

.estimate-lines {
  margin-top: 18px;
}

.copy-output {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.copy-output textarea {
  min-height: 128px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre;
}

.copy-status {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.workflow-panel {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.workflow-status {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.workflow-status[data-tone="draft"] {
  background: var(--teal-pale);
  color: var(--teal);
}

.workflow-status[data-tone="saved"] {
  background: rgba(196, 169, 106, 0.18);
  color: #7a6a54;
}

.workflow-status[data-tone="warn"] {
  background: rgba(94, 74, 92, 0.12);
  color: var(--rose);
}

.saved-estimates {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.saved-estimates__empty {
  color: var(--muted);
  font-size: 12px;
}

.saved-estimate-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.72);
}

.saved-estimate-row strong,
.saved-estimate-row span {
  display: block;
}

.saved-estimate-row strong {
  font-size: 13px;
  font-weight: 500;
}

.saved-estimate-row span {
  color: var(--muted);
  font-family: var(--font-en);
  font-size: 12px;
}

.saved-estimate-row em {
  font-family: var(--font-en);
  font-style: normal;
  font-weight: 600;
  white-space: nowrap;
}

.project-card,
.stat-box,
.vendor-row {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.quote-paper {
  padding: clamp(18px, 3vw, 34px);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 8px 28px rgba(30, 42, 48, 0.05);
}

.quote-paper__title {
  margin: 8px 0 20px;
  text-align: center;
}

.quote-paper__title h3 {
  color: var(--teal-dark);
  font-size: 28px;
  font-weight: 300;
  letter-spacing: 0;
}

.quote-head {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(260px, 340px);
  gap: 24px;
  align-items: start;
}

.quote-head__left,
.quote-head__right {
  min-width: 0;
}

.quote-head p {
  margin-top: 18px;
  line-height: 1.65;
}

.quote-client {
  max-width: 520px;
  min-height: 48px;
  border: 0;
  border-bottom: 1px solid rgba(61, 95, 110, 0.42);
  border-radius: 0;
  font-size: 26px;
  font-weight: 600;
}

.quote-fields,
.quote-meta {
  display: grid;
  align-items: center;
}

.quote-fields {
  grid-template-columns: 120px minmax(240px, 1fr);
  max-width: 540px;
  margin-top: 14px;
}

.quote-meta {
  grid-template-columns: 86px minmax(0, 1fr);
  max-width: 260px;
}

.quote-meta input,
input[type="number"] {
  font-family: var(--font-en);
}

.quote-fields span,
.quote-meta span {
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 0 10px;
  background: var(--surface-stone);
  color: var(--teal-dark);
  font-weight: 500;
}

.quote-fields input,
.quote-meta input,
#quoteOwner {
  min-height: 36px;
  border-radius: 0;
}

#quoteOwner {
  margin-top: 10px;
}

.quote-total {
  display: grid;
  grid-template-columns: 150px minmax(220px, 340px) 96px;
  align-items: stretch;
  width: fit-content;
  margin-top: 22px;
  border: 1px solid var(--line);
}

.quote-total span,
.quote-total strong,
.quote-total em {
  display: flex;
  align-items: center;
  min-height: 58px;
  padding: 0 16px;
  font-style: normal;
}

.quote-total span {
  background: var(--surface-stone);
  font-size: 20px;
  font-weight: 600;
}

.quote-total strong {
  justify-content: flex-end;
  border-left: 1px solid var(--line);
  font-family: var(--font-en);
  font-size: 26px;
  font-weight: 600;
}

.quote-total em {
  border-left: 1px solid var(--line);
  font-size: 20px;
  font-weight: 500;
}

.board-table {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.board-row {
  display: grid;
  grid-template-columns: 36px minmax(250px, 1.8fr) 66px 68px 104px 78px 110px 116px;
  gap: 0;
  align-items: center;
  min-width: 900px;
  border-bottom: 1px solid var(--line);
}

.board-row:last-child {
  border-bottom: 0;
}

.board-row--header {
  min-height: 40px;
  background: var(--surface-stone);
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 500;
}

.board-row--header span,
.board-row > * {
  padding: 8px 10px;
}

.board-row > * + * {
  border-left: 1px solid var(--line);
}

.board-input {
  min-height: 36px;
  border: 1px solid rgba(139, 165, 181, 0.35);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
}

.board-input--summary {
  min-width: 0;
}

.board-row-handle {
  align-self: stretch;
  display: grid;
  place-items: center;
  background: var(--surface-stone);
  color: #5f666b;
  font-size: 12px;
}

.board-row--group {
  background: var(--surface-soft);
}

.board-row--group .board-input--summary {
  grid-column: 2 / 7;
  border-color: rgba(61, 95, 110, 0.55);
  font-weight: 500;
}

.board-group-fill {
  align-self: stretch;
  grid-column: 7;
}

.board-row--group .board-actions {
  grid-column: 8;
}

.board-amount {
  text-align: right;
  font-family: var(--font-en);
  font-size: 16px;
  font-weight: 500;
}

.board-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.board-actions .ghost-button {
  min-height: 30px;
  padding: 0 8px;
  font-size: 12px;
}

.estimate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.estimate-total-box {
  display: grid;
  justify-content: end;
  margin-top: 12px;
}

.estimate-total-box div {
  display: grid;
  grid-template-columns: 120px 160px;
  min-height: 40px;
}

.estimate-total-box span,
.estimate-total-box strong {
  display: flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--surface-stone);
}

.estimate-total-box strong {
  justify-content: flex-end;
  background: #fff;
  font-family: var(--font-en);
  font-size: 18px;
  font-weight: 600;
}

.quote-remarks {
  margin-top: 18px;
}

.quote-remarks span {
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 0 10px;
  background: var(--surface-stone);
  border: 1px solid var(--line);
  border-bottom: 0;
  color: var(--teal-dark);
  font-weight: 500;
}

.quote-remarks textarea {
  min-height: 132px;
  border-radius: 0;
}

.project-card__amount strong {
  font-family: var(--font-en);
  font-size: 18px;
}

.project-card__amount span {
  font-family: var(--font-en);
}

.line-copy-button {
  white-space: nowrap;
}

.project-card p,
.vendor-row span {
  color: var(--muted);
  font-size: 12px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.segmented__button {
  min-width: 72px;
  border-radius: 0;
  background: #fff;
  color: var(--muted);
}

.segmented__button + .segmented__button {
  border-left: 1px solid var(--line);
}

.segmented__button.is-active {
  background: var(--teal-dark);
  color: #f0ede8;
}

.project-list {
  display: grid;
  gap: 10px;
}

.project-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 16px;
  padding: 16px;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.project-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(30, 42, 48, 0.05);
}

.project-card h3 {
  margin-bottom: 8px;
  line-height: 1.45;
}

.project-card__meta,
.project-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.tag {
  background: var(--surface-soft);
  color: #3d4148;
}

.reason {
  background: var(--teal-pale);
  color: var(--teal);
}

.project-card__amount {
  display: grid;
  align-content: start;
  gap: 9px;
  text-align: right;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stat-box {
  padding: 12px;
}

.stat-box strong {
  display: block;
  margin-top: 8px;
  font-size: 20px;
}

.vendor-list {
  display: grid;
  gap: 8px;
}

@media (max-width: 1040px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "controls"
      "forecast"
      "evidence";
  }

  .control-surface {
    position: static;
  }
}

@media (max-width: 1280px) {
  .quote-head {
    grid-template-columns: 1fr;
  }

  .quote-head__right {
    justify-self: end;
    width: min(100%, 420px);
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .field-grid,
  .check-grid,
  .toggle-grid,
  .price-grid,
  .stats-strip,
  .project-card,
  .quote-head {
    grid-template-columns: 1fr;
  }

  .quote-total {
    grid-template-columns: 116px minmax(160px, 1fr) 70px;
    width: 100%;
  }

  .quote-head__right {
    justify-self: stretch;
    width: 100%;
  }

  .project-card__amount {
    text-align: left;
  }

  .meter-row {
    grid-template-columns: 1fr;
  }
}
