:root {
  color: #273746;
  background: #f5f7fa;
  font-family: "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: #f5f7fa;
  color: #273746;
}

.app-shell {
  width: min(980px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2.1rem 0 3rem;
}

h1 {
  margin: 0 0 1.55rem;
  color: #17324d;
  font-size: clamp(2rem, 4vw, 2.65rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

h2 {
  color: #17324d;
  font-size: 1.45rem;
}

.calculator-form {
  padding: 1rem;
  border: 1px solid #dbe4ec;
  border-radius: 14px;
  background: #fff;
}

.input-grid,
.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2.2rem;
}

.sensor-panel h2 {
  margin: 0 0 1.1rem;
}

label {
  display: block;
  margin: 0 0 0.45rem;
  color: #273746;
  font-size: 0.98rem;
  font-weight: 600;
}

input {
  width: 100%;
  min-height: 2.7rem;
  margin: 0 0 1.2rem;
  padding: 0.62rem 0.72rem;
  border: 1px solid #bcc9d4;
  border-radius: 8px;
  background: #fff;
  color: #1f2f3d;
  font: inherit;
}

input:focus {
  border-color: #ff4b4b;
  outline: 3px solid rgba(255, 75, 75, 0.16);
}

.calculate-button {
  width: 100%;
  min-height: 2.8rem;
  border: 0;
  border-radius: 8px;
  background: #ff4b4b;
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.calculate-button:hover {
  background: #e53f3f;
}

.calculate-button:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(255, 75, 75, 0.28);
  outline-offset: 2px;
}

.limit-caption,
.boundaries {
  margin: 0.55rem 0 0;
  color: #506579;
  font-size: 0.88rem;
}

.results hr {
  margin: 1.65rem 0;
  border: 0;
  border-top: 1px solid #dbe4ec;
}

.metric-grid {
  gap: 1rem;
}

.metric-card {
  min-height: 6.1rem;
  padding: 0.8rem 1rem;
  border: 1px solid #dbe4ec;
  border-radius: 12px;
  background: #fff;
}

.metric-card span {
  display: block;
  margin-bottom: 0.45rem;
  color: #506579;
  font-size: 0.88rem;
}

.metric-card strong {
  display: block;
  color: #17324d;
  font-size: clamp(1.3rem, 3vw, 1.85rem);
  line-height: 1.2;
}

.boundaries {
  margin-bottom: 1rem;
}

.result-card {
  margin: 0.4rem 0 1rem;
  padding: 1.2rem 1.35rem;
  border: 1px solid #c8d7e5;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(20, 48, 76, 0.07);
}

.result-card.selected {
  border-left: 7px solid #1f9d55;
  background: #f1fbf5;
}

.result-card.preferred {
  border-left: 7px solid #d69e2e;
  background: #fffaf0;
}

.result-label {
  color: #506579;
  font-size: 0.86rem;
  font-weight: 700;
  text-transform: uppercase;
}

.result-range {
  margin: 0.2rem 0;
  color: #17324d;
  font-size: clamp(1.55rem, 4vw, 1.85rem);
  font-weight: 750;
}

.status-selected,
.status-preferred,
.status-rejected,
.status-acceptable {
  font-weight: 800;
}

.status-selected { color: #137a3e; }
.status-preferred { color: #9a6700; }
.status-rejected { color: #a12727; }
.status-acceptable { color: #204e78; }

.alert {
  margin: 0.8rem 0 1rem;
  padding: 0.9rem 1rem;
  border-radius: 8px;
}

.alert-error {
  border: 1px solid #f0b7b7;
  background: #fde8e8;
  color: #842121;
}

.alert-warning {
  border: 1px solid #ead18e;
  background: #fff6d9;
  color: #6e4d00;
}

#options-section {
  margin-top: 1.35rem;
}

#options-section h2 {
  margin: 0 0 0.75rem;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid #dbe4ec;
  border-radius: 10px;
  background: #fff;
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  padding: 0.65rem 0.7rem;
  border-bottom: 1px solid #e5ebf0;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f7f9fb;
  color: #3e5264;
  font-weight: 700;
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.status-cell {
  border-radius: 5px;
  font-weight: 700;
  white-space: nowrap;
}

.status-cell.selected { background: #dff5e7; color: #126a37; }
.status-cell.preferred { background: #fff1c7; color: #805500; }
.status-cell.acceptable { background: #e8f2ff; color: #204e78; }
.status-cell.rejected { background: #fde8e8; color: #9b2c2c; }

.calculation-details {
  margin-top: 1.25rem;
  border: 1px solid #dbe4ec;
  border-radius: 10px;
  background: #fff;
}

.calculation-details summary {
  padding: 0.9rem 1rem;
  color: #17324d;
  font-weight: 700;
  cursor: pointer;
}

.details-content {
  padding: 0.15rem 1.1rem 1.1rem;
  border-top: 1px solid #e5ebf0;
}

.detail-step {
  padding: 0.35rem 0 0.5rem;
}

.detail-step + .detail-step {
  border-top: 1px solid #edf1f4;
}

.detail-step h3 {
  margin: 0.8rem 0 0.65rem;
  color: #17324d;
  font-size: 1.05rem;
}

.detail-step p {
  margin: 0.35rem 0 0.75rem;
  line-height: 1.55;
}

.detail-option {
  margin: 0.35rem 0 0.8rem;
  line-height: 1.55;
}

.candidate-list {
  margin: 0.3rem 0 0.85rem;
  padding-left: 1.35rem;
}

code {
  padding: 0.08rem 0.3rem;
  border-radius: 4px;
  background: #f0f2f4;
  color: #17324d;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.93em;
}

[hidden] {
  display: none !important;
}

@media (max-width: 700px) {
  .app-shell {
    width: min(100% - 1rem, 980px);
    padding-top: 1.25rem;
  }

  .input-grid,
  .metric-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .calculator-form {
    padding: 0.9rem;
  }
}
