.tercas-shell {
  display: grid;
  gap: 22px;
}

.tercas-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.tercas-shell[data-step="3"] .tercas-layout,
.tercas-shell[data-step="4"] .tercas-layout {
  grid-template-columns: minmax(0, 1fr);
}

.tercas-shell[data-step="3"] .tercas-side,
.tercas-shell[data-step="4"] .tercas-side {
  display: none;
}

.tercas-main,
.tercas-side {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.tercas-panel {
  display: none;
  border: 1px solid var(--calc-border);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(18, 32, 51, 0.06);
  padding: 22px;
}

.tercas-panel.is-active,
.tercas-side .tercas-panel {
  display: block;
}

.tercas-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.tercas-panel h2,
.tercas-panel h3 {
  margin: 0;
  color: var(--calc-ink);
  font-weight: 850;
}

.tercas-panel h2 {
  font-size: clamp(1.4rem, 2vw, 2rem);
}

.tercas-panel h3 {
  font-size: 1.05rem;
  margin-bottom: 12px;
}

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

.tercas-form-grid label {
  display: grid;
  gap: 7px;
  color: #30445b;
  font-weight: 800;
  font-size: 0.88rem;
}

.tercas-profile-picker {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.tercas-profile-picker label {
  min-width: 0;
}

.tercas-preset-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  border: 1px solid #b9c8d8;
  border-radius: 6px;
  background: #f8fafc;
  color: var(--calc-ink);
  padding: 10px 12px;
  font: inherit;
  font-weight: 850;
  cursor: pointer;
}

.tercas-preset-button.is-icon-only {
  width: 44px;
  padding: 0;
  font-size: 1.05rem;
}

.tercas-preset-button:hover,
.tercas-preset-button:focus {
  border-color: #d89a00;
  background: #fff7df;
}

.tercas-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(17, 24, 39, 0.56);
}

.tercas-modal-backdrop[hidden] {
  display: none;
}

.tercas-profile-modal {
  width: min(980px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid #d8e0e8;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(18, 32, 51, 0.28);
  overflow: hidden;
}

.tercas-steel-modal {
  width: min(720px, 100%);
}

.tercas-norma-modal {
  width: min(1120px, 100%);
}

.tercas-profile-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid #d8e0e8;
}

.tercas-profile-modal-head h2 {
  margin: 0;
  color: var(--calc-ink);
  font-size: 1.45rem;
  font-weight: 900;
}

.tercas-modal-close {
  width: 40px;
  height: 40px;
  border: 1px solid #d8e0e8;
  border-radius: 6px;
  background: #fff;
  color: #1f2933;
  cursor: pointer;
}

.tercas-profile-modal-body {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  gap: 16px;
  min-height: 0;
  padding: 16px;
}

.tercas-preset-list {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow: auto;
}

.tercas-steel-list {
  padding: 16px;
}

.tercas-norma-image {
  min-height: 0;
  overflow: auto;
  padding: 16px;
  background: #f8fafc;
}

.tercas-norma-image img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid #d8e0e8;
  border-radius: 8px;
  background: #fff;
}

.tercas-preset-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  border: 1px solid #d8e0e8;
  border-radius: 6px;
  background: #f8fafc;
  padding: 10px 12px;
  color: var(--calc-ink);
  text-align: left;
  cursor: pointer;
}

.tercas-preset-option:hover {
  border-color: #d89a00;
  background: #fff7df;
}

.tercas-preset-option.is-active {
  border-color: #d89a00;
  background: #fff7df;
}

.tercas-preset-option strong {
  font-size: 0.84rem;
  font-weight: 900;
}

.tercas-preset-option span {
  color: #5c6b7f;
  font-size: 0.74rem;
  font-weight: 800;
}

.tercas-preset-option small {
  grid-column: 1 / -1;
  color: #6b7280;
  font-size: 0.72rem;
  font-weight: 750;
}

.tercas-preset-option em {
  align-self: start;
  border: 1px solid #d8e0e8;
  border-radius: 999px;
  background: #fff;
  color: #1f2933;
  padding: 3px 8px;
  font-style: normal;
  font-size: 0.72rem;
  font-weight: 900;
}

.tercas-preset-preview {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
}

#profilePresetSketch {
  display: block;
  width: 100%;
  min-height: 260px;
  border: 1px solid #d8e0e8;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(216, 154, 0, 0.06) 0 1px, transparent 1px 100%),
    linear-gradient(180deg, rgba(216, 154, 0, 0.05) 0 1px, transparent 1px 100%),
    #fff;
  background-size: 24px 24px, 24px 24px, auto;
}

.tercas-preset-info {
  display: grid;
  gap: 8px;
  border: 1px solid #d8e0e8;
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
  color: #30445b;
  font-weight: 800;
}

.tercas-form-grid input,
.tercas-form-grid select {
  width: 100%;
  min-height: 44px;
  border: 1px solid #b9c8d8;
  border-radius: 6px;
  background: #fff;
  color: var(--calc-ink);
  padding: 10px 12px;
  font: inherit;
}

.tercas-form-grid input[readonly] {
  background: #f8fafc;
  cursor: default;
}

.tercas-form-grid input:focus,
.tercas-form-grid select:focus {
  outline: 3px solid rgba(216, 154, 0, 0.16);
  border-color: var(--calc-blue);
}

.tercas-form-grid input:disabled,
.tercas-form-grid select:disabled {
  background: #eef3f7;
  color: #64748b;
  cursor: not-allowed;
}

.tercas-wide {
  grid-column: 1 / -1;
}

.tercas-note {
  border: 1px solid #d8e0e8;
  border-radius: 8px;
  background: #f7f2e8;
  color: #374151;
  padding: 12px 14px;
  font-weight: 700;
}

.tercas-load-form {
  grid-template-columns: 1fr;
}

.tercas-load-grid {
  display: grid;
  gap: 12px;
}

.tercas-load-group {
  display: grid;
  gap: 10px;
}

.tercas-load-group h3 {
  margin: 0;
  color: var(--calc-ink);
  font-size: 1rem;
  font-weight: 900;
}

.tercas-load-table {
  width: 100%;
  max-width: 100%;
  table-layout: auto;
  border-collapse: collapse;
  border: 1px solid #d8e0e8;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.tercas-load-table th,
.tercas-load-table td {
  border-bottom: 1px solid #d8e0e8;
  padding: 7px 5px;
  vertical-align: middle;
  text-align: left;
}

.tercas-load-table th {
  background: #eef2f7;
  color: var(--calc-ink);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.tercas-load-table th .tercas-gamma {
  font-family: "Segoe UI Symbol", "DejaVu Sans", Arial, sans-serif;
  text-transform: none;
  font-weight: 900;
  letter-spacing: 0;
}

.tercas-load-table th .tercas-gamma sub {
  font-size: 0.72em;
  line-height: 0;
}

.tercas-load-table td:first-child {
  width: auto;
}

.tercas-load-table th:nth-child(2),
.tercas-load-table td:nth-child(2),
.tercas-load-table th:nth-child(3),
.tercas-load-table td:nth-child(3),
.tercas-load-table th:nth-child(4),
.tercas-load-table td:nth-child(4),
.tercas-load-table th:nth-child(5),
.tercas-load-table td:nth-child(5) {
  width: 1%;
  white-space: nowrap;
}

.tercas-load-table strong,
.tercas-load-table small {
  display: block;
}

.tercas-load-table strong {
  color: var(--calc-ink);
  font-size: 0.8rem;
  font-weight: 900;
}

.tercas-load-table small {
  margin-top: 3px;
  color: #64748b;
  font-size: 0.66rem;
  font-weight: 700;
}

.tercas-load-table input {
  min-height: 34px;
  width: 68px;
  max-width: 68px;
  min-width: 0;
  padding: 6px;
  font-size: 0.82rem;
}

.tercas-load-table output {
  color: #30445b;
  font-weight: 900;
  white-space: nowrap;
}

.tercas-results-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.tercas-result-card {
  display: grid;
  gap: 8px;
  min-height: 130px;
  border: 1px solid var(--calc-border);
  border-radius: 8px;
  background: #f8fafc;
  padding: 16px;
}

.tercas-result-card span {
  color: var(--calc-muted);
  font-weight: 800;
  font-size: 0.82rem;
}

.tercas-result-card strong {
  color: var(--calc-ink);
  font-size: 1.18rem;
  font-weight: 900;
}

.tercas-result-card small {
  color: #5c6b7f;
  font-weight: 700;
}

.tercas-result-diagrams {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.tercas-result-diagram {
  border: 1px solid var(--calc-border);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.tercas-result-diagram h3 {
  margin: 0 0 10px;
  color: var(--calc-ink);
  font-size: 1rem;
  font-weight: 900;
}

.tercas-table-wrap {
  overflow-x: auto;
}

.tercas-load-group .tercas-table-wrap {
  overflow-x: visible;
}

.tercas-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid #d8e0e8;
  border-radius: 8px;
  background: #fff;
  font-size: 0.86rem;
}

.tercas-table th,
.tercas-table td {
  padding: 10px;
  border-bottom: 1px solid #d8e0e8;
  text-align: left;
  vertical-align: top;
}

.tercas-table th {
  background: #eef2f7;
  color: var(--calc-ink);
  font-weight: 900;
}

.tercas-table td {
  color: #30445b;
  font-weight: 700;
}

.tercas-table tr:last-child td {
  border-bottom: 0;
}

.tercas-side-panel {
  position: static;
}

.tercas-side-panel + .tercas-side-panel {
  position: static;
}

.tercas-side-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.tercas-side-head h3 {
  margin: 0;
}

.tercas-side-head label {
  display: grid;
  gap: 4px;
  min-width: 210px;
  margin: 0;
  color: var(--calc-ink);
  font-size: 0.78rem;
  font-weight: 900;
}

.tercas-side-head select {
  min-height: 38px;
  border: 1px solid #b8c7d9;
  border-radius: 7px;
  background: #fff;
  padding: 6px 10px;
  color: var(--calc-ink);
  font: inherit;
}

.tercas-shell[data-step="1"] .tercas-croqui-panel,
.tercas-shell[data-step="2"] .tercas-section-panel {
  display: none;
}

.tercas-shell[data-step="1"] .tercas-section-panel,
.tercas-shell[data-step="2"] .tercas-croqui-panel {
  display: block;
}

#purlinSketch,
#profileSketch,
#resultLoadSketch,
#momentSketch {
  display: block;
  width: 100%;
  border: 1px solid #d8e0e8;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(216, 154, 0, 0.055) 0 1px, transparent 1px 100%),
    linear-gradient(180deg, rgba(71, 85, 105, 0.06) 0 1px, transparent 1px 100%),
    #fff;
  background-size: 28px 28px, 28px 28px, auto;
}

#purlinSketch {
  min-height: 300px;
}

#profileSketch {
  min-height: 280px;
}

#purlinSketch text,
#profileSketch text,
#resultLoadSketch text,
#momentSketch text {
  font-family: "Segoe UI", Arial, sans-serif;
}

#resultLoadSketch {
  height: 240px;
}

#momentSketch {
  height: 220px;
}

.tercas-moment-line {
  fill: none;
  stroke: #e97817;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.tercas-moment-fill {
  fill: rgba(233, 120, 23, 0.16);
  stroke: none;
}

.tercas-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.tercas-legend span {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border: 1px solid var(--calc-border);
  border-radius: 6px;
  background: #fff;
  padding: 8px;
  color: #30445b;
  font-weight: 750;
  font-size: 0.78rem;
}

.tercas-legend i {
  width: 20px;
  height: 4px;
  border-radius: 2px;
}

.tercas-legend .is-main { background: #475569; }
.tercas-legend .is-lateral { background: #0891b2; }
.tercas-legend .is-purlin { background: #16a34a; }
.tercas-legend .is-wind { background: #d89a00; }

.tercas-summary,
.tercas-report {
  display: grid;
  gap: 10px;
}

.tercas-summary div,
.tercas-report-item {
  display: grid;
  gap: 5px;
  border: 1px solid var(--calc-border);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
}

.tercas-summary span,
.tercas-report-item span {
  color: var(--calc-muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.tercas-summary strong,
.tercas-report-item strong {
  color: var(--calc-ink);
  font-weight: 900;
}

.tercas-report-section {
  border: 1px solid var(--calc-border);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

.tercas-report-section + .tercas-report-section {
  margin-top: 12px;
}

.tercas-report-section p {
  margin: 0;
  color: #374151;
  font-weight: 700;
}

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

.tercas-report-diagram {
  border: 1px solid #d8e0e8;
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.tercas-report-diagram strong {
  display: block;
  margin-bottom: 8px;
  color: var(--calc-ink);
  font-weight: 900;
}

.tercas-report-diagram svg {
  width: 100%;
  max-height: 220px;
  border: 1px solid #d8e0e8;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(216, 154, 0, 0.055) 0 1px, transparent 1px 100%),
    linear-gradient(180deg, rgba(71, 85, 105, 0.06) 0 1px, transparent 1px 100%),
    #fff;
  background-size: 28px 28px, 28px 28px, auto;
}

.tercas-report-vertical {
  display: grid;
  gap: 10px;
}

.tercas-check-row td:first-child {
  width: 46px;
  text-align: center;
}

.tercas-check-icon {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  font-weight: 900;
}

.tercas-check-icon.is-ok { background: #16a34a; }
.tercas-check-icon.is-fail { background: #dc2626; }

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

.tercas-equation {
  display: grid;
  gap: 4px;
  border: 1px solid #d8e0e8;
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
}

.tercas-equation code {
  color: #1f2933;
  font-weight: 900;
}

@media (max-width: 1180px) {
  .tercas-layout,
  .tercas-form-grid,
  .tercas-results-grid,
  .tercas-result-diagrams,
  .tercas-report-diagrams {
    grid-template-columns: 1fr;
  }

  .tercas-side-panel,
  .tercas-side-panel + .tercas-side-panel {
    position: static;
  }
}

@media (max-width: 900px) {
  .tercas-form-grid,
  .tercas-profile-picker,
  .tercas-load-form {
    grid-template-columns: 1fr;
  }

  .tercas-side-head {
    align-items: stretch;
    flex-direction: column;
  }

  .tercas-side-head label {
    min-width: 0;
  }

  .tercas-load-table,
  .tercas-load-table tbody,
  .tercas-load-table tr,
  .tercas-load-table td {
    display: block;
    width: 100%;
  }

  .tercas-load-table thead {
    display: none;
  }

  .tercas-load-table tr {
    border-bottom: 1px solid #d8e0e8;
    padding: 8px 0;
  }

  .tercas-load-table tr:last-child {
    border-bottom: 0;
  }

  .tercas-load-table td {
    display: grid;
    grid-template-columns: minmax(112px, 0.82fr) minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    border-bottom: 0;
    padding: 5px 8px;
    white-space: normal;
  }

  .tercas-load-table td::before {
    color: #64748b;
    font-size: 0.68rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .tercas-load-table td:nth-child(1)::before { content: "Carga"; }
  .tercas-load-table td:nth-child(2)::before { content: "Valor"; }
  .tercas-load-table td:nth-child(3)::before { content: "Caso 1 \03B3 q"; }
  .tercas-load-table td:nth-child(4)::before { content: "Caso 2 \03B3 g"; }
  .tercas-load-table td:nth-child(5)::before { content: "Carga linear"; }

  .tercas-load-table input {
    width: 100%;
    max-width: none;
  }
}

@media (max-width: 760px) {
  .tercas-panel {
    padding: 18px;
  }

  .tercas-panel-head {
    flex-direction: column;
  }

  .tercas-profile-picker {
    grid-template-columns: 1fr;
  }

  .tercas-legend {
    grid-template-columns: 1fr;
  }

  .tercas-profile-modal-body {
    grid-template-columns: 1fr;
  }
}
