.emt-panel-modules__toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 14px;
  margin-bottom: 18px;
}

.emt-panel-modules__template-select {
  max-width: 760px;
}

.emt-panel-device-list {
  display: grid;
  gap: 16px;
}

.emt-panel-device {
  position: relative;
  min-width: 0;
  margin: 0;
  padding: 22px;
  border: 1px solid var(--emt-calc-line);
  border-radius: var(--emt-calc-radius-small);
  background: var(--emt-calc-bg);
}

.emt-panel-device > legend {
  padding: 0 8px;
  font-weight: 800;
}

.emt-panel-device__remove {
  position: absolute;
  top: 15px;
  right: 16px;
  padding: 5px 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--emt-calc-danger);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.emt-panel-device__remove:hover,
.emt-panel-device__remove:focus-visible {
  background: #fff0f0;
  outline: none;
}

.emt-panel-device__remove:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.emt-panel-device__subtotal {
  margin: 14px 0 0;
  color: var(--emt-calc-muted);
  font-size: 14px;
}

.emt-panel-device__subtotal strong {
  color: var(--emt-calc-text);
}

.emt-panel-modules__row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
}

.emt-panel-modules__row-actions p {
  flex: 1 1 420px;
  margin: 0;
  color: var(--emt-calc-muted);
  font-size: 14px;
}

.emt-panel-modules__stale {
  margin: 16px 0 0;
  padding: 13px 15px;
  border: 1px solid #e5c568;
  border-radius: 12px;
  background: #fff9e7;
  color: #6e5000;
  font-size: 14px;
  font-weight: 700;
}

.emt-panel-modules__section {
  margin-top: 26px;
}

.emt-panel-modules__section-note {
  margin: -4px 0 14px;
  color: var(--emt-calc-muted);
  font-size: 14px;
}

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

.emt-panel-modules__capacity-grid > div {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--emt-calc-line);
  border-radius: 13px;
  background: var(--emt-calc-bg);
}

.emt-panel-modules__capacity-grid span,
.emt-panel-modules__capacity-grid strong,
.emt-panel-modules__capacity-grid small {
  display: block;
}

.emt-panel-modules__capacity-grid span {
  color: var(--emt-calc-muted);
  font-size: 13px;
  font-weight: 700;
}

.emt-panel-modules__capacity-grid strong {
  margin-top: 5px;
  font-size: 21px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.emt-panel-modules__capacity-grid small {
  margin-top: 5px;
  color: var(--emt-calc-muted);
  font-size: 12px;
  line-height: 1.4;
}

.emt-panel-layout {
  display: grid;
  gap: 12px;
}

.emt-panel-layout__row {
  overflow: hidden;
  border: 1px solid var(--emt-calc-line);
  border-radius: 14px;
  background: #fff;
}

.emt-panel-layout__head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 15px;
  background: #edf2f5;
}

.emt-panel-layout__head strong {
  flex: 0 0 auto;
}

.emt-panel-layout__head span {
  color: var(--emt-calc-muted);
  font-size: 13px;
  text-align: right;
}

.emt-panel-layout__items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 15px 16px;
}

.emt-panel-layout__chip,
.emt-panel-layout__empty {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 7px 10px;
  border: 1px solid #d9e3e8;
  border-radius: 999px;
  background: #f7fafb;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.emt-panel-layout__chip b {
  white-space: nowrap;
}

.emt-panel-layout__empty {
  border-style: dashed;
  color: var(--emt-calc-muted);
}

.emt-panel-modules__selected {
  margin-top: 24px;
  padding: 20px;
  border: 1px solid var(--emt-calc-line);
  border-left-width: 5px;
  border-radius: 14px;
  background: #f7fafc;
}

.emt-panel-modules__selected h4,
.emt-panel-modules__selected p:last-child {
  margin-bottom: 0;
}

.emt-panel-modules__selected--success {
  border-left-color: var(--emt-calc-success);
  background: #f0faf6;
}

.emt-panel-modules__selected--warning {
  border-left-color: #b47c00;
  background: #fff9e7;
}

.emt-panel-modules__selected--danger {
  border-left-color: var(--emt-calc-danger);
  background: #fff3f3;
}

.emt-panel-modules .emt-result-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--emt-calc-line);
  border-radius: 14px;
}

.emt-panel-modules table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

.emt-panel-modules th,
.emt-panel-modules td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--emt-calc-line);
  text-align: left;
  vertical-align: top;
}

.emt-panel-modules thead th {
  background: #edf2f5;
  font-size: 14px;
}

.emt-panel-modules tfoot th {
  background: #f8fafb;
}

.emt-panel-modules tbody tr:last-child td,
.emt-panel-modules tfoot tr:last-child th {
  border-bottom: 0;
}

@media (max-width: 920px) {
  .emt-panel-modules__capacity-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .emt-panel-modules__toolbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .emt-panel-modules__toolbar .emt-button,
  .emt-panel-modules__row-actions .emt-button {
    width: 100%;
  }

  .emt-panel-device {
    padding: 18px 14px;
  }

  .emt-panel-device__remove {
    position: static;
    display: inline-flex;
    margin: 0 0 14px auto;
  }

  .emt-panel-modules__capacity-grid {
    grid-template-columns: 1fr;
  }

  .emt-panel-layout__head {
    display: block;
  }

  .emt-panel-layout__head span {
    display: block;
    margin-top: 4px;
    text-align: left;
  }

  .emt-panel-layout__chip,
  .emt-panel-layout__empty {
    width: 100%;
    justify-content: space-between;
    border-radius: 10px;
  }

  .emt-panel-modules .emt-result-table-wrap {
    overflow: visible;
    border: 0;
  }

  .emt-panel-modules .emt-result-table-wrap table {
    min-width: 0;
  }

  .emt-panel-modules table,
  .emt-panel-modules thead,
  .emt-panel-modules tbody,
  .emt-panel-modules tfoot,
  .emt-panel-modules tr,
  .emt-panel-modules th,
  .emt-panel-modules td {
    display: block;
    width: 100%;
  }

  .emt-panel-modules thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .emt-panel-modules tbody tr,
  .emt-panel-modules tfoot tr {
    margin-bottom: 12px;
    padding: 12px 14px;
    border: 1px solid var(--emt-calc-line);
    border-radius: 13px;
    background: #fff;
  }

  .emt-panel-modules td,
  .emt-panel-modules tfoot th {
    display: grid;
    grid-template-columns: minmax(110px, 42%) minmax(0, 1fr);
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--emt-calc-line);
  }

  .emt-panel-modules td::before {
    content: attr(data-label);
    color: var(--emt-calc-muted);
    font-size: 12px;
    font-weight: 800;
  }

  .emt-panel-modules tbody tr td:last-child,
  .emt-panel-modules tfoot tr th:last-child {
    border-bottom: 0;
  }
}

@media print {
  .emt-panel-modules .emt-calculator__form,
  .emt-panel-modules .emt-result__actions,
  .emt-panel-modules .emt-copy-status {
    display: none !important;
  }

  .emt-panel-modules .emt-result {
    box-shadow: none;
  }
}
