#labelManagerModal {
  position: fixed;
  inset: 0;
  z-index: 620;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.62);
}

#labelManagerContent {
  position: relative;
  width: min(1120px, 94vw);
  height: min(850px, 90vh);
  display: flex;
  flex-direction: column;
  padding: 22px;
  border: 1px solid #2f3850;
  border-radius: 8px;
  background: #1e2230;
  box-shadow: 0 18px 54px rgba(0,0,0,0.48);
  color: var(--text);
}

#labelManagerContent h2 {
  margin: 0 34px 4px 0;
  color: var(--text-bright);
  font-size: 17px;
  font-weight: 600;
}

.lmSubhead {
  margin-bottom: 14px;
  color: #9aa3b8;
  font-size: 12px;
}

.lmBody {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

.lmSection {
  min-width: 0;
  min-height: 0;
  padding: 12px;
  border: 1px solid #30384e;
  border-radius: 7px;
  background: #202638;
}

.lmSection:nth-child(2) {
  grid-row: 1 / span 2;
  grid-column: 2;
  display: flex;
  flex-direction: column;
}

.lmSectionTitle {
  margin-bottom: 10px;
  color: #f5f7fb;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.lmControlsGrid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.lmControlsGrid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: #aeb7c9;
  font-size: 12px;
}

.lmControlsGrid label.lmDisabledField {
  opacity: 0.48;
}

.lmControlsGrid select,
.lmControlsGrid input,
.lmInlineTools input,
#lmRulesTable input {
  min-width: 0;
  height: 30px;
  padding: 5px 8px;
  border: 1px solid #394257;
  border-radius: 6px;
  background: #161b27;
  color: var(--text-bright);
  font: inherit;
  font-size: 12px;
  outline: none;
}

.lmControlsGrid input:disabled,
.lmControlsGrid select:disabled {
  cursor: not-allowed;
}

.lmControlsGrid select:focus,
.lmControlsGrid input:focus,
.lmInlineTools input:focus,
#lmRulesTable input:focus {
  border-color: var(--accent);
}

.lmSourceSummary,
#lmStatus {
  color: #9aa3b8;
  font-size: 12px;
  line-height: 1.4;
}

.lmSourceSummary {
  margin-top: 12px;
}

.lmActionRow {
  display: flex;
  margin-top: 12px;
}

#labelManagerModal button {
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid #3b465e;
  border-radius: 6px;
  background: #293246;
  color: #e5e9f3;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

#labelManagerModal button:hover:not(:disabled) {
  border-color: #52617d;
  background: #323d55;
}

#labelManagerModal button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

#labelManagerModal .lmPrimary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

#labelManagerModal .lmPrimary:hover:not(:disabled) {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.lmToolRows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.lmToolRow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.lmInlineTools span {
  color: #aeb7c9;
  font-size: 12px;
}

.lmInlineTools input[type="number"] {
  width: 74px;
}

.lmInlineTools input[type="text"] {
  width: 132px;
}

#lmRulesHost {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.lmRulesWrap {
  flex: 1;
  min-height: 220px;
  overflow: auto;
  border: 1px solid #30384e;
  border-radius: 6px;
  background: #171c29;
}

#lmRulesTable {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  color: var(--text);
  font-size: 12px;
}

#lmRulesTable th,
#lmRulesTable td {
  height: 34px;
  padding: 5px 7px;
  border-bottom: 1px solid #293145;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#lmRulesTable th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #252d40;
  color: #f0f3f9;
  font-size: 11px;
  font-weight: 700;
}

#lmRulesTable th:nth-child(1),
#lmRulesTable td:nth-child(1) {
  width: 34px;
  text-align: center;
}

#lmRulesTable th:nth-child(2),
#lmRulesTable td:nth-child(2) {
  width: 76px;
}

#lmRulesTable th:nth-child(4),
#lmRulesTable td:nth-child(4) {
  width: 64px;
}

#lmRulesTable th:nth-child(5),
#lmRulesTable td:nth-child(5) {
  width: 82px;
}

#lmRulesTable th:nth-child(6),
#lmRulesTable td:nth-child(6) {
  width: 88px;
}

#lmRulesTable tbody tr:hover {
  background: #20283a;
}

#lmRulesTable input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}

#lmRulesTable .lmTargetValue {
  width: 72px;
}

#lmRulesTable .lmTargetName {
  width: 100%;
}

.lmValueCell {
  display: flex;
  align-items: center;
  gap: 7px;
}

.lmSwatch {
  flex: 0 0 12px;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18);
}

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

.lmNameText {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lmMixedBadge {
  flex: 0 0 auto;
  padding: 1px 5px;
  border: 1px solid #3b465e;
  border-radius: 4px;
  background: #252d40;
  color: #d4dae7;
  font-size: 10px;
  line-height: 1.4;
  text-transform: uppercase;
}

.lmEmpty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  border: 1px dashed #394257;
  border-radius: 6px;
  color: #9aa3b8;
  font-size: 12px;
}

.lmWarn,
.lmSkipped {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #2d2630;
  color: #ffd08a;
  font-size: 12px;
}

.lmSkipped summary,
.lmNameConflicts summary {
  cursor: pointer;
}

.lmSkipped div {
  margin-top: 6px;
  color: #d8c4a5;
  line-height: 1.5;
}

.lmNameConflicts {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid #30384e;
  border-radius: 6px;
  background: #202638;
  color: #dbe3f3;
  font-size: 12px;
}

.lmNameConflictBody {
  max-height: 190px;
  margin-top: 8px;
  overflow: auto;
  border: 1px solid #30384e;
  border-radius: 6px;
  background: #171c29;
}

.lmNameConflictBody table {
  width: 100%;
  border-collapse: collapse;
}

.lmNameConflictBody td {
  padding: 7px 8px;
  border-bottom: 1px solid #293145;
  vertical-align: top;
}

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

.lmNameConflictValue {
  width: 86px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: #f0f3f9;
  font-weight: 700;
  white-space: nowrap;
}

.lmNameConflictVariant + .lmNameConflictVariant {
  margin-top: 8px;
}

.lmNameConflictVariant strong {
  color: #f5f7fb;
}

.lmNameConflictVariant span,
.lmNameConflictExample {
  color: #aeb7c9;
}

.lmNameConflictExample {
  margin-top: 3px;
  font-size: 11px;
}

.lmOutputModes {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 12px;
}

.lmOutputModes label,
.lmCheckLabel {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #d4dae7;
}

.lmOutputModes input,
.lmCheckLabel input {
  accent-color: var(--accent);
}

.lmOutputGrid {
  margin-bottom: 10px;
}

#lmStatus {
  min-height: 22px;
  padding-top: 10px;
}

.lmFooter {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 10px;
}

@media (max-width: 900px) {
  #labelManagerContent {
    width: 96vw;
    height: 92vh;
    padding: 16px;
  }

  .lmBody {
    display: flex;
    flex-direction: column;
    overflow: auto;
  }

  .lmSection:nth-child(2) {
    display: flex;
    min-height: 420px;
  }

  .lmInlineTools input[type="text"] {
    width: min(160px, 42vw);
  }
}
