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

:root {
  --role-current: #1d5fd0;
  --role-current-bg: #eef5ff;
  --role-high: #e60012;
  --role-high-bg: #fff3f4;
  --role-low: #0d974a;
  --role-low-bg: #f2fff7;
}

body {
  margin: 0;
  font-family: "Noto Sans JP", Arial, sans-serif;
  color: #252525;
  background: #fff;
}

.app-header {
  background: #111;
  color: #fff;
}

.header-inner {
  max-width: 1180px;
  min-height: 62px;
  margin: 0 auto;
  padding: 10px 18px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
}

.brand img {
  height: 38px;
  display: block;
}

h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.segmented {
  display: inline-flex;
  border: 1px solid #5d5d5d;
  border-radius: 4px;
  overflow: hidden;
}

.segmented button {
  border: 0;
  border-right: 1px solid #5d5d5d;
  background: transparent;
  color: #ddd;
  padding: 6px 11px;
  cursor: pointer;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  background: #e60012;
  color: #fff;
}

.currency-select {
  height: 32px;
  border: 1px solid #5d5d5d;
  border-radius: 4px;
  background: #222;
  color: #fff;
  padding: 0 8px;
}

.page-shell {
  width: 980px;
  max-width: 100%;
  margin: 0 auto;
  padding: 30px 20px 64px;
}

.hero-section {
  margin-bottom: 28px;
}

.hero-section img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 5;
  object-fit: cover;
  object-position: center;
  border-radius: 4px;
}

.input-panel,
.result-panel,
.loading-panel {
  background: #fff;
  margin-bottom: 22px;
}

.input-panel {
  border: 0;
  border-radius: 0;
  padding: 0;
}

.result-panel,
.loading-panel {
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 22px;
}

h2 {
  margin: 0 0 14px;
  font-size: 22px;
}

h3 {
  margin: 0 0 14px;
  font-size: 16px;
  border-bottom: 1px solid #e0e0e0;
  padding-bottom: 8px;
}

.section-title {
  font-size: 20px;
  font-weight: 600;
  color: #333;
  border-bottom: 1px solid #dbdbdb;
  padding-bottom: 10px;
  margin: 40px 0 20px;
}

.section-title:first-of-type {
  margin-top: 0;
}

.required-note,
.discount-note {
  font-size: 13px;
  color: #777;
  margin: 0 0 10px;
}

.ae-caution-note {
  border-left: 4px solid #d99a00;
  background: #fff8df;
  color: #5c4300;
  font-size: 13px;
  line-height: 1.6;
  margin: 0 0 18px;
  padding: 10px 12px;
}

.p-userdata {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  margin-bottom: 10px;
}

.p-userdata th {
  width: 45%;
  border-bottom: 0;
  background: transparent;
  padding: 15px 7px;
  text-align: left;
  vertical-align: middle;
  font-size: 15px;
  font-weight: 400;
  color: #333;
}

.p-userdata td {
  border-bottom: 0;
  padding: 15px 7px;
  vertical-align: middle;
}

.p-userdata input[type="number"],
.p-userdata select {
  width: 260px;
  max-width: 60%;
  height: 40px;
  border: 1px solid #cfcfcf;
  border-radius: 0;
  background: #fafafa;
  padding: 10px 20px;
  font: inherit;
  font-family: Arial, sans-serif;
  font-size: 15px;
  color: #000;
  text-align: right;
}

.p-userdata select {
  text-align: left;
}

.unit-label {
  margin-left: 6px;
  font-size: 15px;
  color: #333;
}

.gl-inline-row td {
  padding: 15px 7px;
}

.gl-inline-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
  gap: 18px;
  align-items: start;
}

.gl-fields {
  display: grid;
  gap: 12px;
}

.gl-field {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 14px;
  align-items: center;
  font-size: 15px;
  color: #333;
}

.gl-input {
  white-space: nowrap;
}

.p-userdata .gl-input input[type="number"] {
  max-width: none;
}

.gl-inline-figure {
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 8px;
  border: 1px solid #dbdbdb;
  background: #fff;
  cursor: zoom-in;
  transform-origin: top right;
  transition: transform .16s ease, box-shadow .16s ease;
}

.gl-inline-figure:hover {
  z-index: 30;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
  transform: scale(1.65);
}

.gl-attention-img {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
}

.primary-btn {
  display: block;
  width: min(320px, 100%);
  min-height: 48px;
  margin: 24px auto 0;
  border: 0;
  border-radius: 4px;
  background: #e60012;
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}

.primary-btn:disabled {
  opacity: .55;
  cursor: wait;
}

.error-box,
.error-result {
  color: #a40000;
  background: #fff4f4;
  border-color: #f0b5b5;
}

.error-box {
  margin-top: 18px;
  padding: 12px;
  border: 1px solid #f0b5b5;
  border-radius: 4px;
}

.loading-panel {
  text-align: center;
  font-weight: 700;
}

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

.current-summary {
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--role-current);
  border-left: 4px solid var(--role-current);
  border-radius: 4px;
  background: var(--role-current-bg);
}

.current-summary h3 {
  border: 0;
  margin: 0 0 10px;
  padding: 0;
  font-size: 13px;
  color: var(--role-current);
}

.current-metric-grid,
.candidate-cost-grid {
  display: grid;
  gap: 10px;
}

.current-metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.candidate-cost-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.current-metric-grid div,
.candidate-cost-grid div {
  min-width: 0;
  padding: 10px;
  border: 1px solid #e1e1e1;
  border-left: 4px solid var(--role-current);
  border-radius: 4px;
  background: #fff;
}

.candidate-cost-grid div {
  border-left-color: var(--role-low);
}

.current-metric-grid span,
.candidate-cost-grid span {
  display: block;
  margin-bottom: 6px;
  color: #555;
  font-size: 12px;
  font-weight: 700;
}

.current-metric-grid strong,
.candidate-cost-grid strong {
  display: block;
  overflow-wrap: anywhere;
  color: #111;
  font-size: 18px;
}

.current-detail-section {
  margin-top: 12px;
}

.current-detail-section h4 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--role-current);
}

.current-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
  gap: 8px;
}

.current-detail-grid div {
  min-width: 0;
  padding: 8px;
  border: 1px solid #cfe0fa;
  border-left: 3px solid var(--role-current);
  border-radius: 4px;
  background: #fff;
}

.current-detail-grid span {
  display: block;
  margin-bottom: 5px;
  color: #555;
  font-size: 11px;
  font-weight: 800;
}

.current-detail-grid strong {
  display: block;
  overflow-wrap: anywhere;
  color: #111;
  font-size: 13px;
  line-height: 1.35;
}

.summary-grid article {
  border: 1px solid #ddd;
  border-left: 4px solid #ddd;
  border-radius: 4px;
  padding: 12px;
}

.summary-grid h3 {
  border: 0;
  margin: 0 0 8px;
  padding: 0;
  font-size: 13px;
  color: #555;
}

.candidate-heading {
  display: flex;
  align-items: center;
  gap: 6px;
}

.candidate-emoji {
  flex: 0 0 auto;
  font-size: 16px;
  line-height: 1;
}

.summary-grid p {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.candidate-summary {
  background: #fff;
}

.candidate-summary.candidate-high {
  border-color: var(--role-high);
  border-left-color: var(--role-high);
  background: var(--role-high-bg);
}

.candidate-summary.candidate-low {
  border-color: var(--role-low);
  border-left-color: var(--role-low);
  background: var(--role-low-bg);
}

.candidate-high .candidate-heading {
  color: var(--role-high);
}

.candidate-low .candidate-heading {
  color: var(--role-low);
}

.tool-title {
  margin-bottom: 10px;
  display: grid;
  gap: 8px;
  color: #111;
}

.tool-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--role-low);
  border-left: 3px solid var(--role-low);
  border-radius: 4px;
  background: #f8fffb;
  color: #111;
  text-decoration: none;
}

.candidate-high .tool-title-row {
  border-color: var(--role-high);
  border-left-color: var(--role-high);
  background: #fff8f8;
}

.candidate-low .tool-title-row {
  border-color: var(--role-low);
  border-left-color: var(--role-low);
  background: #f8fffb;
}

.tool-image-frame {
  flex: 0 0 64px;
  width: 64px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  background: #fff;
}

.tool-type-image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.tool-title-text {
  flex: 1 1 auto;
  min-width: 0;
}

.tool-title-label {
  display: block;
  margin-bottom: 2px;
  color: #555;
  font-size: 12px;
  font-weight: 700;
}

.tool-title-value {
  display: block;
  overflow-wrap: anywhere;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.25;
}

.tool-feature {
  display: block;
  margin-top: 4px;
  color: #555;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.catalog-link {
  flex: 0 0 auto;
  padding: 5px 9px;
  border: 1px solid var(--role-low);
  border-radius: 4px;
  background: #fff;
  color: var(--role-low);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.candidate-high .catalog-link {
  border-color: var(--role-high);
  color: var(--role-high);
}

.candidate-low .catalog-link {
  border-color: var(--role-low);
  color: var(--role-low);
}

.catalog-link::after {
  content: ">";
  margin-left: 5px;
}

.tool-title-row:hover .catalog-link,
.tool-title-row:focus-visible .catalog-link {
  background: var(--role-low);
  color: #fff;
}

.candidate-high .tool-title-row:hover .catalog-link,
.candidate-high .tool-title-row:focus-visible .catalog-link {
  background: var(--role-high);
}

.candidate-low .tool-title-row:hover .catalog-link,
.candidate-low .tool-title-row:focus-visible .catalog-link {
  background: var(--role-low);
}

.tool-title-row:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px rgba(13, 151, 74, .22);
}

.tool-dimensions {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.dimension-group {
  min-width: 0;
}

.dimension-group-title {
  margin-bottom: 6px;
  color: #333;
  font-size: 12px;
  font-weight: 800;
}

.dimension-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dimension-chip {
  display: inline-flex;
  align-items: baseline;
  max-width: 100%;
  min-height: 26px;
  gap: 5px;
  padding: 4px 7px;
  border: 1px solid #dfe7e1;
  border-radius: 4px;
  background: #fff;
  line-height: 1.2;
}

.dimension-code {
  flex: 0 0 auto;
  color: var(--role-low);
  font-size: 11px;
  font-weight: 900;
}

.candidate-high .dimension-code {
  color: var(--role-high);
}

.candidate-low .dimension-code {
  color: var(--role-low);
}

.dimension-value {
  min-width: 0;
  color: #222;
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.dimension-chip-warning {
  border-color: #e2a217;
  background: #fff8e6;
}

.dimension-chip-warning .dimension-code {
  color: #9c6500;
}

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

.candidate-metrics div {
  padding: 10px;
  border: 1px solid #e1e1e1;
  border-left: 4px solid var(--role-low);
  border-radius: 4px;
  background: #fff;
}

.candidate-high .candidate-metrics div,
.candidate-high .candidate-cost-grid div {
  border-left-color: var(--role-high);
}

.candidate-low .candidate-metrics div,
.candidate-low .candidate-cost-grid div {
  border-left-color: var(--role-low);
}

.candidate-metrics span {
  display: block;
  margin-bottom: 6px;
  color: #555;
  font-size: 12px;
  font-weight: 700;
}

.candidate-metrics strong {
  display: block;
  color: #111;
  font-size: 18px;
}

.candidate-cost-comparison {
  margin-top: 14px;
}

.candidate-cost-comparison h4 {
  margin: 0 0 8px;
  font-size: 13px;
  color: #333;
}

.target-lines {
  margin-top: 14px;
}

.target-lines h4 {
  margin: 0 0 8px;
  font-size: 13px;
  color: #333;
}

.target-lines table {
  min-width: 0;
  border: 1px solid #e1e1e1;
}

.target-lines th,
.target-lines td {
  padding: 8px 9px;
  font-size: 12px;
}

.target-lines thead th {
  background: #f3f3f3;
  color: #555;
}

.target-lines tbody th {
  width: 40%;
  background: #fff;
  color: #222;
}

.target-lines tbody td {
  font-weight: 700;
}

.candidate-summary.candidate-high {
  border-color: var(--role-high);
  border-left-color: var(--role-high);
}

.candidate-summary.candidate-high .tool-title-row,
.candidate-summary.candidate-high .dimension-chip,
.candidate-summary.candidate-high .target-lines table {
  border-color: var(--role-high);
}

.candidate-summary.candidate-high .tool-title-row,
.candidate-summary.candidate-high .candidate-metrics div,
.candidate-summary.candidate-high .candidate-cost-grid div {
  border-left-color: var(--role-high);
}

.candidate-summary.candidate-high .candidate-heading,
.candidate-summary.candidate-high .dimension-code,
.candidate-summary.candidate-high .catalog-link,
.candidate-summary.candidate-high .candidate-cost-comparison h4,
.candidate-summary.candidate-high .target-lines h4 {
  color: var(--role-high);
}

.comparison-section-row th {
  background: #f3f3f3;
  color: #333;
  font-size: 12px;
  font-weight: 900;
  text-align: left;
}

.result-block {
  margin-top: 24px;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  border-bottom: 1px solid #e2e2e2;
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  background: #f8f8f8;
  font-weight: 700;
}

thead th.table-current {
  background: var(--role-current-bg);
  color: var(--role-current);
}

thead th.table-high {
  background: var(--role-high-bg);
  color: var(--role-high);
}

thead th.table-low {
  background: var(--role-low-bg);
  color: var(--role-low);
}

td.table-current {
  border-left: 3px solid var(--role-current);
  background: #f8fbff;
}

td.table-high {
  border-left: 3px solid var(--role-high);
  background: #fffafa;
}

td.table-low {
  border-left: 3px solid var(--role-low);
  background: #f9fffb;
}

td.table-empty {
  color: transparent;
}

.charts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
}

.chart-card {
  padding: 18px 22px 16px;
  border: 1px solid #e1e1e1;
  border-radius: 4px;
  background: #fff;
}

.chart-card canvas {
  width: 100% !important;
  height: 430px !important;
  max-width: 100%;
  background: #fff;
}

#breakeven-chart {
  height: 470px !important;
}

@media (max-width: 860px) {
  .header-inner {
    grid-template-columns: 1fr;
  }

  .header-controls {
    flex-wrap: wrap;
  }

  .hero-section img {
    aspect-ratio: 16 / 9;
  }

  .summary-grid,
  .charts-grid {
    grid-template-columns: 1fr;
  }

  .current-metric-grid,
  .candidate-cost-grid {
    grid-template-columns: 1fr;
  }

  .tool-title-row {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .tool-image-frame {
    flex-basis: 56px;
    width: 56px;
    height: 48px;
  }

  .catalog-link {
    margin-left: auto;
  }

  .dimension-chip {
    flex: 1 1 auto;
  }

  .p-userdata,
  .p-userdata tbody,
  .p-userdata tr,
  .p-userdata th,
  .p-userdata td {
    display: block;
    width: 100%;
  }

  .p-userdata th {
    padding: 12px 0 5px;
  }

  .p-userdata td {
    padding: 0 0 12px;
  }

  .p-userdata input[type="number"],
  .p-userdata select {
    width: calc(100% - 56px);
    max-width: none;
  }

  .gl-inline-panel,
  .gl-field {
    grid-template-columns: 1fr;
  }

  .gl-inline-figure {
    max-width: 360px;
    transform-origin: top left;
  }
}

@media print {
  .app-header,
  .input-panel,
  .print-btn,
  .loading-panel,
  .error-result {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .page-shell {
    padding: 0;
  }

  .result-panel {
    border: 0;
    padding: 0;
  }
}
